@pie-lib/config-ui 11.0.24-next.4 → 11.0.25
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 +16 -0
- package/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/feedback-menu.js.map +1 -1
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/choice-utils.js.map +1 -1
- package/lib/feedback-config/feedback-selector.js.map +1 -1
- package/lib/feedback-config/group.js.map +1 -1
- package/lib/feedback-config/index.js.map +1 -1
- package/lib/form-section.js.map +1 -1
- package/lib/help.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/input.js.map +1 -1
- package/lib/inputs.js.map +1 -1
- package/lib/langs.js.map +1 -1
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/layout/layout-contents.js.map +1 -1
- package/lib/layout/settings-box.js.map +1 -1
- package/lib/mui-box/index.js.map +1 -1
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/display-size.js.map +1 -1
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js.map +1 -1
- package/lib/tabs/index.js.map +1 -1
- package/lib/tags-input/index.js.map +1 -1
- package/lib/two-choice.js.map +1 -1
- package/lib/with-stateful-model.js.map +1 -1
- package/package.json +5 -5
- package/src/alert-dialog.jsx +2 -9
- package/src/checkbox.jsx +9 -9
- package/src/choice-configuration/feedback-menu.jsx +10 -20
- package/src/choice-configuration/index.jsx +33 -33
- package/src/choice-utils.js +1 -1
- package/src/feedback-config/feedback-selector.jsx +17 -19
- package/src/feedback-config/group.jsx +9 -9
- package/src/feedback-config/index.jsx +8 -8
- package/src/form-section.jsx +4 -4
- package/src/help.jsx +9 -13
- package/src/index.js +2 -5
- package/src/input.jsx +7 -7
- package/src/inputs.jsx +12 -17
- package/src/langs.jsx +24 -39
- package/src/layout/config-layout.jsx +6 -12
- package/src/layout/layout-contents.jsx +7 -11
- package/src/layout/settings-box.jsx +3 -3
- package/src/mui-box/index.jsx +9 -9
- package/src/number-text-field-custom.jsx +25 -25
- package/src/number-text-field.jsx +12 -12
- package/src/radio-with-label.jsx +2 -2
- package/src/settings/display-size.jsx +5 -5
- package/src/settings/index.js +11 -11
- package/src/settings/panel.jsx +30 -32
- package/src/settings/settings-radio-label.jsx +2 -2
- package/src/settings/toggle.jsx +6 -6
- package/src/tabs/index.jsx +5 -7
- package/src/tags-input/index.jsx +15 -17
- package/src/two-choice.jsx +8 -8
- package/src/with-stateful-model.jsx +4 -4
package/src/inputs.jsx
CHANGED
|
@@ -14,18 +14,13 @@ const InputTypes = {
|
|
|
14
14
|
checked: PropTypes.bool,
|
|
15
15
|
onChange: PropTypes.func,
|
|
16
16
|
disabled: PropTypes.bool,
|
|
17
|
-
error: PropTypes.string
|
|
17
|
+
error: PropTypes.string,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const RawInputSwitch = ({ classes, className, label, checked, onChange }) => {
|
|
21
21
|
return (
|
|
22
22
|
<InputContainer className={className} label={label}>
|
|
23
|
-
<Switch
|
|
24
|
-
className={classes.switchRoot}
|
|
25
|
-
checked={checked}
|
|
26
|
-
onChange={onChange}
|
|
27
|
-
aria-label={label}
|
|
28
|
-
/>
|
|
23
|
+
<Switch className={classes.switchRoot} checked={checked} onChange={onChange} aria-label={label} />
|
|
29
24
|
</InputContainer>
|
|
30
25
|
);
|
|
31
26
|
};
|
|
@@ -35,11 +30,11 @@ RawInputSwitch.propTypes = { ...InputTypes };
|
|
|
35
30
|
const InputSwitch = withStyles({
|
|
36
31
|
switchRoot: {
|
|
37
32
|
justifyContent: 'inherit',
|
|
38
|
-
transform: 'translate(-20%, 20%)'
|
|
39
|
-
}
|
|
33
|
+
transform: 'translate(-20%, 20%)',
|
|
34
|
+
},
|
|
40
35
|
})(RawInputSwitch);
|
|
41
36
|
|
|
42
|
-
const RawInputCheckbox = props => {
|
|
37
|
+
const RawInputCheckbox = (props) => {
|
|
43
38
|
const { classes, className, label, checked, onChange, disabled, error } = props;
|
|
44
39
|
|
|
45
40
|
return (
|
|
@@ -57,7 +52,7 @@ const RawInputCheckbox = props => {
|
|
|
57
52
|
|
|
58
53
|
RawInputCheckbox.propTypes = { ...InputTypes };
|
|
59
54
|
|
|
60
|
-
const RawInputRadio = props => {
|
|
55
|
+
const RawInputRadio = (props) => {
|
|
61
56
|
const { classes, className, label, checked, onChange, disabled, error } = props;
|
|
62
57
|
|
|
63
58
|
return (
|
|
@@ -77,20 +72,20 @@ RawInputRadio.propTypes = { ...InputTypes };
|
|
|
77
72
|
|
|
78
73
|
const InputCheckbox = withStyles({
|
|
79
74
|
checkboxRoot: {
|
|
80
|
-
transform: 'translate(-25%, 20%)'
|
|
75
|
+
transform: 'translate(-25%, 20%)',
|
|
81
76
|
},
|
|
82
77
|
error: {
|
|
83
|
-
color: 'red'
|
|
84
|
-
}
|
|
78
|
+
color: 'red',
|
|
79
|
+
},
|
|
85
80
|
})(RawInputCheckbox);
|
|
86
81
|
|
|
87
82
|
const InputRadio = withStyles(() => ({
|
|
88
83
|
radioRoot: {
|
|
89
|
-
transform: 'translate(-20%, 20%)'
|
|
84
|
+
transform: 'translate(-20%, 20%)',
|
|
90
85
|
},
|
|
91
86
|
error: {
|
|
92
|
-
color: 'red'
|
|
93
|
-
}
|
|
87
|
+
color: 'red',
|
|
88
|
+
},
|
|
94
89
|
}))(RawInputRadio);
|
|
95
90
|
|
|
96
91
|
export { InputSwitch, InputCheckbox, InputRadio };
|
package/src/langs.jsx
CHANGED
|
@@ -11,21 +11,21 @@ import debug from 'debug';
|
|
|
11
11
|
|
|
12
12
|
const log = debug('pie-elements:config-ui:langs');
|
|
13
13
|
|
|
14
|
-
const styles = theme => ({
|
|
14
|
+
const styles = (theme) => ({
|
|
15
15
|
root: {
|
|
16
16
|
flexDirection: 'column',
|
|
17
17
|
alignItems: 'start',
|
|
18
18
|
display: 'flex',
|
|
19
19
|
position: 'relative',
|
|
20
20
|
paddingTop: '0px',
|
|
21
|
-
paddingRight: '0px'
|
|
21
|
+
paddingRight: '0px',
|
|
22
22
|
},
|
|
23
23
|
formControl: {
|
|
24
|
-
position: 'initial'
|
|
24
|
+
position: 'initial',
|
|
25
25
|
},
|
|
26
26
|
inputLabel: {
|
|
27
|
-
paddingBottom: theme.spacing.unit
|
|
28
|
-
}
|
|
27
|
+
paddingBottom: theme.spacing.unit,
|
|
28
|
+
},
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
export class RawLangs extends React.Component {
|
|
@@ -35,7 +35,7 @@ export class RawLangs extends React.Component {
|
|
|
35
35
|
selected: PropTypes.string,
|
|
36
36
|
label: PropTypes.string,
|
|
37
37
|
classes: PropTypes.object.isRequired,
|
|
38
|
-
uid: PropTypes.string
|
|
38
|
+
uid: PropTypes.string,
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
constructor(props) {
|
|
@@ -43,7 +43,7 @@ export class RawLangs extends React.Component {
|
|
|
43
43
|
this.uid = props.uid || (Math.random() * 10000).toFixed();
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
choose = event => {
|
|
46
|
+
choose = (event) => {
|
|
47
47
|
log('[choose] event: ', event);
|
|
48
48
|
if (this.props.onChange) {
|
|
49
49
|
this.props.onChange(event.target.value);
|
|
@@ -80,43 +80,28 @@ export const LanguageControls = withStyles({
|
|
|
80
80
|
display: 'grid',
|
|
81
81
|
gridAutoFlow: 'column',
|
|
82
82
|
gridAutoColumns: '1fr',
|
|
83
|
-
gridGap: '8px'
|
|
84
|
-
}
|
|
85
|
-
})(
|
|
86
|
-
(
|
|
87
|
-
classes,
|
|
88
|
-
langs,
|
|
89
|
-
activeLang,
|
|
90
|
-
defaultLang,
|
|
91
|
-
onActiveLangChange,
|
|
92
|
-
onDefaultLangChange,
|
|
93
|
-
className
|
|
94
|
-
}) => {
|
|
95
|
-
const names = classNames(classes.languageControls, className);
|
|
83
|
+
gridGap: '8px',
|
|
84
|
+
},
|
|
85
|
+
})(({ classes, langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
|
|
86
|
+
const names = classNames(classes.languageControls, className);
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
onChange={l => onDefaultLangChange(l)}
|
|
110
|
-
/>
|
|
111
|
-
</div>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
);
|
|
88
|
+
return (
|
|
89
|
+
<div className={names}>
|
|
90
|
+
<Langs
|
|
91
|
+
label="Choose language to edit"
|
|
92
|
+
langs={langs}
|
|
93
|
+
selected={activeLang}
|
|
94
|
+
onChange={(l) => onActiveLangChange(l)}
|
|
95
|
+
/>
|
|
96
|
+
<Langs label="Default language" langs={langs} selected={defaultLang} onChange={(l) => onDefaultLangChange(l)} />
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
});
|
|
115
100
|
|
|
116
101
|
LanguageControls.propTypes = {
|
|
117
102
|
langs: PropTypes.array,
|
|
118
103
|
activeLang: PropTypes.string.isRequired,
|
|
119
104
|
defaultLang: PropTypes.string.isRequired,
|
|
120
105
|
onActiveLangChange: PropTypes.func.isRequired,
|
|
121
|
-
onDefaultLangChange: PropTypes.func.isRequired
|
|
106
|
+
onDefaultLangChange: PropTypes.func.isRequired,
|
|
122
107
|
};
|
|
@@ -6,29 +6,25 @@ import SettingsBox from './settings-box';
|
|
|
6
6
|
|
|
7
7
|
class ConfigLayout extends React.Component {
|
|
8
8
|
static propTypes = {
|
|
9
|
-
children: PropTypes.oneOfType([
|
|
10
|
-
PropTypes.string,
|
|
11
|
-
PropTypes.arrayOf(PropTypes.element),
|
|
12
|
-
PropTypes.element
|
|
13
|
-
]),
|
|
9
|
+
children: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
|
|
14
10
|
settings: PropTypes.element,
|
|
15
11
|
className: PropTypes.string,
|
|
16
12
|
classes: PropTypes.object,
|
|
17
|
-
sidePanelMinWidth: PropTypes.number
|
|
13
|
+
sidePanelMinWidth: PropTypes.number,
|
|
18
14
|
};
|
|
19
15
|
|
|
20
16
|
static defaultProps = {
|
|
21
|
-
sidePanelMinWidth: 950
|
|
17
|
+
sidePanelMinWidth: 950,
|
|
22
18
|
};
|
|
23
19
|
|
|
24
20
|
constructor(props) {
|
|
25
21
|
super(props);
|
|
26
22
|
this.state = {
|
|
27
|
-
layoutMode: undefined
|
|
23
|
+
layoutMode: undefined,
|
|
28
24
|
};
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
onResize = contentRect => {
|
|
27
|
+
onResize = (contentRect) => {
|
|
32
28
|
const { bounds } = contentRect;
|
|
33
29
|
const { sidePanelMinWidth } = this.props;
|
|
34
30
|
const layoutMode = bounds.width >= sidePanelMinWidth ? 'inline' : 'tabbed';
|
|
@@ -47,9 +43,7 @@ class ConfigLayout extends React.Component {
|
|
|
47
43
|
<div ref={measureRef}>
|
|
48
44
|
<LayoutContents
|
|
49
45
|
mode={layoutMode}
|
|
50
|
-
secondary={
|
|
51
|
-
layoutMode === 'inline' ? <SettingsBox>{settings}</SettingsBox> : settings
|
|
52
|
-
}
|
|
46
|
+
secondary={layoutMode === 'inline' ? <SettingsBox>{settings}</SettingsBox> : settings}
|
|
53
47
|
>
|
|
54
48
|
{children}
|
|
55
49
|
</LayoutContents>
|
|
@@ -9,7 +9,7 @@ class RawLayoutContents extends React.Component {
|
|
|
9
9
|
mode: PropTypes.oneOf(['tabbed', 'inline']),
|
|
10
10
|
secondary: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
11
11
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
12
|
-
classes: PropTypes.object
|
|
12
|
+
classes: PropTypes.object,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
render() {
|
|
@@ -24,11 +24,7 @@ class RawLayoutContents extends React.Component {
|
|
|
24
24
|
</div>
|
|
25
25
|
)}
|
|
26
26
|
{mode === 'tabbed' && (
|
|
27
|
-
<Tabs
|
|
28
|
-
onChange={this.onTabsChange}
|
|
29
|
-
contentClassName={classes.contentContainer}
|
|
30
|
-
indicatorColor="primary"
|
|
31
|
-
>
|
|
27
|
+
<Tabs onChange={this.onTabsChange} contentClassName={classes.contentContainer} indicatorColor="primary">
|
|
32
28
|
<div title="Design">{children}</div>
|
|
33
29
|
<div title="settings">{secondary}</div>
|
|
34
30
|
</Tabs>
|
|
@@ -41,20 +37,20 @@ class RawLayoutContents extends React.Component {
|
|
|
41
37
|
const styles = () => ({
|
|
42
38
|
flow: {
|
|
43
39
|
display: 'flex',
|
|
44
|
-
justifyContent: 'space-between'
|
|
40
|
+
justifyContent: 'space-between',
|
|
45
41
|
},
|
|
46
42
|
container: {
|
|
47
43
|
display: 'flex',
|
|
48
44
|
flexDirection: 'column',
|
|
49
|
-
position: 'relative'
|
|
45
|
+
position: 'relative',
|
|
50
46
|
},
|
|
51
47
|
contentContainer: {
|
|
52
|
-
padding: '32px 16px 0 16px'
|
|
48
|
+
padding: '32px 16px 0 16px',
|
|
53
49
|
},
|
|
54
50
|
configContainer: {
|
|
55
51
|
flex: '1',
|
|
56
|
-
marginRight: '20px'
|
|
57
|
-
}
|
|
52
|
+
marginRight: '20px',
|
|
53
|
+
},
|
|
58
54
|
});
|
|
59
55
|
|
|
60
56
|
export default withStyles(styles)(RawLayoutContents);
|
|
@@ -6,7 +6,7 @@ export class SettingsBox extends React.Component {
|
|
|
6
6
|
static propTypes = {
|
|
7
7
|
classes: PropTypes.object.isRequired,
|
|
8
8
|
className: PropTypes.string,
|
|
9
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired
|
|
9
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
10
10
|
};
|
|
11
11
|
static defaultProps = {};
|
|
12
12
|
render() {
|
|
@@ -25,7 +25,7 @@ const styles = () => ({
|
|
|
25
25
|
maxWidth: '300px',
|
|
26
26
|
padding: '24px 8px 24px 24px',
|
|
27
27
|
width: '80%',
|
|
28
|
-
zIndex: 99
|
|
29
|
-
}
|
|
28
|
+
zIndex: 99,
|
|
29
|
+
},
|
|
30
30
|
});
|
|
31
31
|
export default withStyles(styles)(SettingsBox);
|
package/src/mui-box/index.jsx
CHANGED
|
@@ -6,7 +6,7 @@ import classNames from 'classnames';
|
|
|
6
6
|
|
|
7
7
|
const log = debug('pie-elements:config-ui:mui-box');
|
|
8
8
|
|
|
9
|
-
const MuiBox = withStyles(theme => {
|
|
9
|
+
const MuiBox = withStyles((theme) => {
|
|
10
10
|
const light = theme.palette.type === 'light';
|
|
11
11
|
const bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)';
|
|
12
12
|
|
|
@@ -26,10 +26,10 @@ const MuiBox = withStyles(theme => {
|
|
|
26
26
|
position: 'absolute',
|
|
27
27
|
transition: 'background-color 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
|
|
28
28
|
pointerEvents: 'none',
|
|
29
|
-
backgroundColor: bottomLineColor
|
|
29
|
+
backgroundColor: bottomLineColor,
|
|
30
30
|
},
|
|
31
31
|
'&:hover:before': {
|
|
32
|
-
height: '2px'
|
|
32
|
+
height: '2px',
|
|
33
33
|
},
|
|
34
34
|
'&:after': {
|
|
35
35
|
left: 0,
|
|
@@ -41,14 +41,14 @@ const MuiBox = withStyles(theme => {
|
|
|
41
41
|
transform: 'scaleX(0)',
|
|
42
42
|
transition: 'transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms',
|
|
43
43
|
pointerEvents: 'none',
|
|
44
|
-
backgroundColor: theme.palette.primary[theme.palette.type] //'#304ffe'
|
|
45
|
-
}
|
|
44
|
+
backgroundColor: theme.palette.primary[theme.palette.type], //'#304ffe'
|
|
45
|
+
},
|
|
46
46
|
},
|
|
47
47
|
focused: {
|
|
48
48
|
'&:after': {
|
|
49
|
-
transform: 'scaleX(1)'
|
|
50
|
-
}
|
|
51
|
-
}
|
|
49
|
+
transform: 'scaleX(1)',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
52
|
};
|
|
53
53
|
})(({ children, classes, focused }) => {
|
|
54
54
|
const names = classNames(classes.muiBox, focused && classes.focused);
|
|
@@ -58,7 +58,7 @@ const MuiBox = withStyles(theme => {
|
|
|
58
58
|
|
|
59
59
|
MuiBox.propTypes = {
|
|
60
60
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
61
|
-
focused: PropTypes.bool.isRequired
|
|
61
|
+
focused: PropTypes.bool.isRequired,
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
export default MuiBox;
|
|
@@ -9,23 +9,23 @@ import InputAdornment from '@material-ui/core/InputAdornment';
|
|
|
9
9
|
import Remove from '@material-ui/icons/Remove';
|
|
10
10
|
import Add from '@material-ui/icons/Add';
|
|
11
11
|
|
|
12
|
-
const styles = theme => ({
|
|
12
|
+
const styles = (theme) => ({
|
|
13
13
|
input: {
|
|
14
14
|
'& input[type=number]': {
|
|
15
|
-
'-moz-appearance': 'textfield'
|
|
15
|
+
'-moz-appearance': 'textfield',
|
|
16
16
|
},
|
|
17
17
|
'& input[type=number]::-webkit-outer-spin-button': {
|
|
18
18
|
'-webkit-appearance': 'none',
|
|
19
|
-
margin: 0
|
|
19
|
+
margin: 0,
|
|
20
20
|
},
|
|
21
21
|
'& input[type=number]::-webkit-inner-spin-button': {
|
|
22
22
|
'-webkit-appearance': 'none',
|
|
23
|
-
margin: 0
|
|
24
|
-
}
|
|
23
|
+
margin: 0,
|
|
24
|
+
},
|
|
25
25
|
},
|
|
26
26
|
iconButton: {
|
|
27
|
-
padding: '2px'
|
|
28
|
-
}
|
|
27
|
+
padding: '2px',
|
|
28
|
+
},
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
const fallbackNumber = (min, max) => {
|
|
@@ -58,7 +58,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
58
58
|
step: PropTypes.number,
|
|
59
59
|
label: PropTypes.string,
|
|
60
60
|
disableUnderline: PropTypes.bool,
|
|
61
|
-
variant: PropTypes.string
|
|
61
|
+
variant: PropTypes.string,
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
static defaultProps = {
|
|
@@ -66,7 +66,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
66
66
|
customValues: [],
|
|
67
67
|
textAlign: 'center',
|
|
68
68
|
variant: 'standard',
|
|
69
|
-
onlyIntegersAllowed: false
|
|
69
|
+
onlyIntegersAllowed: false,
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
constructor(props) {
|
|
@@ -76,7 +76,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
76
76
|
|
|
77
77
|
this.state = {
|
|
78
78
|
value,
|
|
79
|
-
currentIndex
|
|
79
|
+
currentIndex,
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
if (value !== props.value) {
|
|
@@ -116,7 +116,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
116
116
|
|
|
117
117
|
normalizeValueAndIndex = (customValues, number) => {
|
|
118
118
|
const value = this.clamp(number);
|
|
119
|
-
const currentIndex = (customValues || []).findIndex(val => val === value);
|
|
119
|
+
const currentIndex = (customValues || []).findIndex((val) => val === value);
|
|
120
120
|
|
|
121
121
|
if ((customValues || []).length > 0 && currentIndex === -1) {
|
|
122
122
|
const closestValue = this.getClosestValue(customValues, value);
|
|
@@ -131,10 +131,10 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
131
131
|
customValues.reduce(
|
|
132
132
|
(closest, value, index) =>
|
|
133
133
|
Math.abs(value - number) < Math.abs(closest.value - number) ? { value, index } : closest,
|
|
134
|
-
{ value: customValues[0], index: 0 }
|
|
134
|
+
{ value: customValues[0], index: 0 },
|
|
135
135
|
);
|
|
136
136
|
|
|
137
|
-
onBlur = event => {
|
|
137
|
+
onBlur = (event) => {
|
|
138
138
|
const { customValues, onlyIntegersAllowed } = this.props;
|
|
139
139
|
const { value } = event.target;
|
|
140
140
|
const rawNumber = onlyIntegersAllowed ? parseInt(value) : parseFloat(value);
|
|
@@ -145,9 +145,9 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
145
145
|
this.setState(
|
|
146
146
|
{
|
|
147
147
|
value: number.toString(),
|
|
148
|
-
currentIndex
|
|
148
|
+
currentIndex,
|
|
149
149
|
},
|
|
150
|
-
() => this.props.onChange(event, number)
|
|
150
|
+
() => this.props.onChange(event, number),
|
|
151
151
|
);
|
|
152
152
|
}
|
|
153
153
|
};
|
|
@@ -181,13 +181,13 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
181
181
|
this.setState(
|
|
182
182
|
{
|
|
183
183
|
value: number.toString(),
|
|
184
|
-
currentIndex: updatedIndex
|
|
184
|
+
currentIndex: updatedIndex,
|
|
185
185
|
},
|
|
186
186
|
() => {
|
|
187
187
|
if (shouldUpdate) {
|
|
188
188
|
onChange(event, number);
|
|
189
189
|
}
|
|
190
|
-
}
|
|
190
|
+
},
|
|
191
191
|
);
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -204,7 +204,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
204
204
|
disableUnderline,
|
|
205
205
|
helperText,
|
|
206
206
|
variant,
|
|
207
|
-
textAlign
|
|
207
|
+
textAlign,
|
|
208
208
|
} = this.props;
|
|
209
209
|
const { value } = this.state;
|
|
210
210
|
const names = classNames(className, classes.input);
|
|
@@ -212,7 +212,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
212
212
|
return (
|
|
213
213
|
<TextField
|
|
214
214
|
variant={variant}
|
|
215
|
-
inputRef={ref => (this.inputRef = ref)}
|
|
215
|
+
inputRef={(ref) => (this.inputRef = ref)}
|
|
216
216
|
disabled={disabled}
|
|
217
217
|
label={label}
|
|
218
218
|
value={value}
|
|
@@ -220,13 +220,13 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
220
220
|
helperText={helperText}
|
|
221
221
|
onChange={this.onChange}
|
|
222
222
|
onBlur={this.onBlur}
|
|
223
|
-
onKeyPress={e => {
|
|
223
|
+
onKeyPress={(e) => {
|
|
224
224
|
// once the Enter key is pressed, we force input blur
|
|
225
225
|
if (e.key === 'Enter' && this.inputRef) {
|
|
226
226
|
this.inputRef.blur();
|
|
227
227
|
}
|
|
228
228
|
}}
|
|
229
|
-
onKeyDown={e => {
|
|
229
|
+
onKeyDown={(e) => {
|
|
230
230
|
if (e.key === 'ArrowUp') {
|
|
231
231
|
this.changeValue(e);
|
|
232
232
|
}
|
|
@@ -245,7 +245,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
245
245
|
<IconButton
|
|
246
246
|
className={classes.iconButton}
|
|
247
247
|
disabled={disabled}
|
|
248
|
-
onClick={e => this.changeValue(e, -1, true)}
|
|
248
|
+
onClick={(e) => this.changeValue(e, -1, true)}
|
|
249
249
|
>
|
|
250
250
|
<Remove fontSize="small" />
|
|
251
251
|
</IconButton>
|
|
@@ -256,17 +256,17 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
256
256
|
<IconButton
|
|
257
257
|
className={classes.iconButton}
|
|
258
258
|
disabled={disabled}
|
|
259
|
-
onClick={e => this.changeValue(e, 1, true)}
|
|
259
|
+
onClick={(e) => this.changeValue(e, 1, true)}
|
|
260
260
|
>
|
|
261
261
|
<Add fontSize="small" />
|
|
262
262
|
</IconButton>
|
|
263
263
|
</InputAdornment>
|
|
264
|
-
)
|
|
264
|
+
),
|
|
265
265
|
}}
|
|
266
266
|
inputProps={{
|
|
267
267
|
style: { textAlign },
|
|
268
268
|
min,
|
|
269
|
-
max
|
|
269
|
+
max,
|
|
270
270
|
}}
|
|
271
271
|
/>
|
|
272
272
|
);
|
|
@@ -8,8 +8,8 @@ import isFinite from 'lodash/isFinite';
|
|
|
8
8
|
import InputAdornment from '@material-ui/core/InputAdornment';
|
|
9
9
|
const log = debug('@pie-lib:config-ui:number-text-field');
|
|
10
10
|
|
|
11
|
-
const styles = theme => ({
|
|
12
|
-
root: { marginRight: theme.spacing.unit }
|
|
11
|
+
const styles = (theme) => ({
|
|
12
|
+
root: { marginRight: theme.spacing.unit },
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
const fallbackNumber = (min, max) => {
|
|
@@ -39,11 +39,11 @@ export class NumberTextField extends React.Component {
|
|
|
39
39
|
suffix: PropTypes.string,
|
|
40
40
|
showErrorWhenOutsideRange: PropTypes.bool,
|
|
41
41
|
disableUnderline: PropTypes.bool,
|
|
42
|
-
variant: PropTypes.string
|
|
42
|
+
variant: PropTypes.string,
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
static defaultProps = {
|
|
46
|
-
showErrorWhenOutsideRange: false
|
|
46
|
+
showErrorWhenOutsideRange: false,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
constructor(props) {
|
|
@@ -52,7 +52,7 @@ export class NumberTextField extends React.Component {
|
|
|
52
52
|
const value = this.clamp(props.value);
|
|
53
53
|
|
|
54
54
|
this.state = {
|
|
55
|
-
value
|
|
55
|
+
value,
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
if (value !== props.value) {
|
|
@@ -87,7 +87,7 @@ export class NumberTextField extends React.Component {
|
|
|
87
87
|
* on Blur (this can be triggered by pressing Enter, see below)
|
|
88
88
|
* we check the entered value and reset it if needed
|
|
89
89
|
*/
|
|
90
|
-
onBlur = event => {
|
|
90
|
+
onBlur = (event) => {
|
|
91
91
|
const value = event.target.value;
|
|
92
92
|
|
|
93
93
|
const rawNumber = parseFloat(value);
|
|
@@ -149,7 +149,7 @@ export class NumberTextField extends React.Component {
|
|
|
149
149
|
inputClassName,
|
|
150
150
|
disableUnderline,
|
|
151
151
|
showErrorWhenOutsideRange,
|
|
152
|
-
variant
|
|
152
|
+
variant,
|
|
153
153
|
} = this.props;
|
|
154
154
|
const names = classNames(classes.root, className);
|
|
155
155
|
|
|
@@ -157,7 +157,7 @@ export class NumberTextField extends React.Component {
|
|
|
157
157
|
return (
|
|
158
158
|
<TextField
|
|
159
159
|
variant={variant || 'standard'}
|
|
160
|
-
inputRef={ref => {
|
|
160
|
+
inputRef={(ref) => {
|
|
161
161
|
this.inputRef = ref;
|
|
162
162
|
}}
|
|
163
163
|
disabled={disabled}
|
|
@@ -167,7 +167,7 @@ export class NumberTextField extends React.Component {
|
|
|
167
167
|
helperText={error}
|
|
168
168
|
onChange={this.onChange}
|
|
169
169
|
onBlur={this.onBlur}
|
|
170
|
-
onKeyPress={e => {
|
|
170
|
+
onKeyPress={(e) => {
|
|
171
171
|
// once the Enter key is pressed, we force input blur
|
|
172
172
|
if (e.key === 'Enter' && this.inputRef) {
|
|
173
173
|
this.inputRef.blur();
|
|
@@ -176,16 +176,16 @@ export class NumberTextField extends React.Component {
|
|
|
176
176
|
type="number"
|
|
177
177
|
className={names}
|
|
178
178
|
InputLabelProps={{
|
|
179
|
-
shrink: true
|
|
179
|
+
shrink: true,
|
|
180
180
|
}}
|
|
181
181
|
InputProps={{
|
|
182
182
|
endAdornment: suffix && <InputAdornment position="end">{suffix}</InputAdornment>,
|
|
183
183
|
className: inputClassName,
|
|
184
|
-
disableUnderline: disableUnderline
|
|
184
|
+
disableUnderline: disableUnderline,
|
|
185
185
|
}}
|
|
186
186
|
inputProps={{
|
|
187
187
|
min,
|
|
188
|
-
max
|
|
188
|
+
max,
|
|
189
189
|
}}
|
|
190
190
|
margin="normal"
|
|
191
191
|
/>
|
package/src/radio-with-label.jsx
CHANGED
|
@@ -6,8 +6,8 @@ import { withStyles } from '@material-ui/core/styles';
|
|
|
6
6
|
export default withStyles({
|
|
7
7
|
label: {
|
|
8
8
|
left: '-5px',
|
|
9
|
-
position: 'relative'
|
|
10
|
-
}
|
|
9
|
+
position: 'relative',
|
|
10
|
+
},
|
|
11
11
|
})(({ label, value, checked, onChange, classes }) => (
|
|
12
12
|
<FormControlLabel
|
|
13
13
|
value={value}
|
|
@@ -4,11 +4,11 @@ import Typography from '@material-ui/core/Typography';
|
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import NumberTextField from '../number-text-field';
|
|
6
6
|
|
|
7
|
-
const DisplaySize = withStyles(theme => ({
|
|
7
|
+
const DisplaySize = withStyles((theme) => ({
|
|
8
8
|
displaySize: {
|
|
9
9
|
display: 'flex',
|
|
10
|
-
paddingTop: theme.spacing.unit
|
|
11
|
-
}
|
|
10
|
+
paddingTop: theme.spacing.unit,
|
|
11
|
+
},
|
|
12
12
|
}))(({ size, label, classes, onChange }) => {
|
|
13
13
|
const updateSize = (key, v) => {
|
|
14
14
|
onChange({ ...size, [key]: v });
|
|
@@ -43,10 +43,10 @@ const DisplaySize = withStyles(theme => ({
|
|
|
43
43
|
DisplaySize.propTypes = {
|
|
44
44
|
size: PropTypes.shape({
|
|
45
45
|
width: PropTypes.number.isRequired,
|
|
46
|
-
height: PropTypes.number.isRequired
|
|
46
|
+
height: PropTypes.number.isRequired,
|
|
47
47
|
}).isRequired,
|
|
48
48
|
label: PropTypes.string.isRequired,
|
|
49
|
-
onChange: PropTypes.func
|
|
49
|
+
onChange: PropTypes.func,
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
export default DisplaySize;
|