@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,42 +1,42 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import RadioWithLabel from '../radio-with-label';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
|
+
import classNames from 'classnames';
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
alignItems: 'center',
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
const StyledChoice = styled('div')(() => ({
|
|
12
|
-
display: 'flex',
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
const StyledRadioWithLabel = styled(RadioWithLabel)(({ theme }) => ({
|
|
17
|
-
'& .MuiFormControlLabel-label': {
|
|
7
|
+
const styles = (theme) => ({
|
|
8
|
+
radioLabel: {
|
|
18
9
|
fontSize: theme.typography.fontSize - 2,
|
|
19
10
|
},
|
|
20
|
-
|
|
11
|
+
choice: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
},
|
|
15
|
+
choiceHolder: {
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
21
20
|
|
|
22
21
|
const Group = (props) => {
|
|
23
|
-
const { feedbackLabels, value, className, onChange, keys } = props;
|
|
22
|
+
const { feedbackLabels, value, classes, className, onChange, keys } = props;
|
|
24
23
|
|
|
25
24
|
return (
|
|
26
|
-
<
|
|
25
|
+
<div className={classNames(classes.choiceHolder, className)}>
|
|
27
26
|
{keys.map((key) => {
|
|
28
27
|
return (
|
|
29
|
-
<
|
|
30
|
-
<
|
|
28
|
+
<div className={classes.choice} key={key}>
|
|
29
|
+
<RadioWithLabel
|
|
31
30
|
value={key}
|
|
32
31
|
checked={value === key}
|
|
32
|
+
classes={{ label: classes.radioLabel }}
|
|
33
33
|
onChange={(e) => onChange(e.currentTarget.value)}
|
|
34
34
|
label={feedbackLabels[key]}
|
|
35
35
|
/>
|
|
36
|
-
</
|
|
36
|
+
</div>
|
|
37
37
|
);
|
|
38
38
|
})}
|
|
39
|
-
</
|
|
39
|
+
</div>
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -44,8 +44,9 @@ Group.propTypes = {
|
|
|
44
44
|
className: PropTypes.string,
|
|
45
45
|
feedbackLabels: PropTypes.object.isRequired,
|
|
46
46
|
value: PropTypes.string.isRequired,
|
|
47
|
+
classes: PropTypes.object.isRequired,
|
|
47
48
|
keys: PropTypes.arrayOf(PropTypes.string),
|
|
48
49
|
onChange: PropTypes.func,
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
export default Group;
|
|
52
|
+
export default withStyles(styles)(Group);
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import FeedbackSelector, { FeedbackType } from './feedback-selector';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import Typography from '@
|
|
9
|
-
import ExpandMoreIcon from '@
|
|
4
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
|
+
import ExpansionPanel from '@material-ui/core/ExpansionPanel';
|
|
6
|
+
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
|
|
7
|
+
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
|
|
8
|
+
import Typography from '@material-ui/core/Typography';
|
|
9
|
+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
10
10
|
import merge from 'lodash/merge';
|
|
11
11
|
|
|
12
12
|
export { FeedbackSelector };
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
14
|
+
const style = {
|
|
15
|
+
feedbackContainer: {
|
|
16
|
+
display: 'flex',
|
|
17
|
+
flex: 1,
|
|
18
|
+
flexDirection: 'column',
|
|
19
|
+
},
|
|
20
|
+
panelDetails: {
|
|
21
|
+
paddingTop: 0,
|
|
22
|
+
paddingBottom: 0,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
24
25
|
|
|
25
26
|
export const buildDefaults = (input) => {
|
|
26
27
|
return merge(
|
|
@@ -44,6 +45,7 @@ export class FeedbackConfig extends React.Component {
|
|
|
44
45
|
partial: PropTypes.shape(FeedbackType),
|
|
45
46
|
}),
|
|
46
47
|
onChange: PropTypes.func.isRequired,
|
|
48
|
+
classes: PropTypes.object.isRequired,
|
|
47
49
|
toolbarOpts: PropTypes.object,
|
|
48
50
|
};
|
|
49
51
|
|
|
@@ -66,17 +68,17 @@ export class FeedbackConfig extends React.Component {
|
|
|
66
68
|
onPartialChange = this.onChange.bind(this, 'partial');
|
|
67
69
|
|
|
68
70
|
render() {
|
|
69
|
-
const { className, allowPartial, feedback, toolbarOpts } = this.props;
|
|
71
|
+
const { classes, className, allowPartial, feedback, toolbarOpts } = this.props;
|
|
70
72
|
|
|
71
73
|
return (
|
|
72
74
|
<div className={className}>
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
<Typography>Feedback</Typography>
|
|
76
|
-
</
|
|
75
|
+
<ExpansionPanel>
|
|
76
|
+
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
|
|
77
|
+
<Typography className={classes.heading}>Feedback</Typography>
|
|
78
|
+
</ExpansionPanelSummary>
|
|
77
79
|
|
|
78
|
-
<
|
|
79
|
-
<
|
|
80
|
+
<ExpansionPanelDetails className={classes.panelDetails}>
|
|
81
|
+
<div className={classes.feedbackContainer}>
|
|
80
82
|
<FeedbackSelector
|
|
81
83
|
label="If correct, show"
|
|
82
84
|
feedback={feedback.correct}
|
|
@@ -99,12 +101,12 @@ export class FeedbackConfig extends React.Component {
|
|
|
99
101
|
onChange={this.onIncorrectChange}
|
|
100
102
|
toolbarOpts={toolbarOpts}
|
|
101
103
|
/>
|
|
102
|
-
</
|
|
103
|
-
</
|
|
104
|
-
</
|
|
104
|
+
</div>
|
|
105
|
+
</ExpansionPanelDetails>
|
|
106
|
+
</ExpansionPanel>
|
|
105
107
|
</div>
|
|
106
108
|
);
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
|
|
110
|
-
export default FeedbackConfig;
|
|
112
|
+
export default withStyles(style)(FeedbackConfig);
|
package/src/form-section.jsx
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Typography from '@
|
|
3
|
-
import
|
|
2
|
+
import Typography from '@material-ui/core/Typography';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const styles = (theme) => ({
|
|
7
|
+
formSection: {
|
|
8
|
+
marginTop: theme.spacing.unit * 2,
|
|
9
|
+
marginBottom: theme.spacing.unit * 2,
|
|
10
|
+
},
|
|
11
|
+
label: {
|
|
12
|
+
marginBottom: theme.spacing.unit,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const FormSection = ({ className, label, children, labelExtraStyle }) => (
|
|
15
|
-
<StyledFormSection className={className}>
|
|
16
|
-
<StyledTypography variant="subtitle1" style={labelExtraStyle}>
|
|
16
|
+
export default withStyles(styles)(({ className, classes, label, children, labelExtraStyle }) => (
|
|
17
|
+
<div className={classNames(classes.formSection, className)}>
|
|
18
|
+
<Typography className={classes.label} type="subheading" style={labelExtraStyle}>
|
|
17
19
|
{label}
|
|
18
|
-
</
|
|
20
|
+
</Typography>
|
|
19
21
|
{children}
|
|
20
|
-
</
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export default FormSection;
|
|
22
|
+
</div>
|
|
23
|
+
));
|
package/src/help.jsx
CHANGED
|
@@ -1,34 +1,42 @@
|
|
|
1
|
-
import Dialog from '@
|
|
2
|
-
import DialogTitle from '@
|
|
3
|
-
import DialogContentText from '@
|
|
4
|
-
import DialogContent from '@
|
|
5
|
-
import DialogActions from '@
|
|
1
|
+
import Dialog from '@material-ui/core/Dialog';
|
|
2
|
+
import DialogTitle from '@material-ui/core/DialogTitle';
|
|
3
|
+
import DialogContentText from '@material-ui/core/DialogContentText';
|
|
4
|
+
import DialogContent from '@material-ui/core/DialogContent';
|
|
5
|
+
import DialogActions from '@material-ui/core/DialogActions';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
|
|
8
|
-
import Button from '@
|
|
9
|
-
import HelpIcon from '@
|
|
10
|
-
import IconButton from '@
|
|
8
|
+
import Button from '@material-ui/core/Button';
|
|
9
|
+
import HelpIcon from '@material-ui/icons/Help';
|
|
10
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
11
11
|
import React from 'react';
|
|
12
|
-
import {
|
|
12
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<StyledIconButton onClick={onClick} size="large">
|
|
14
|
+
const RawHelpButton = ({ onClick, classes }) => (
|
|
15
|
+
<IconButton
|
|
16
|
+
classes={{
|
|
17
|
+
label: classes.icon,
|
|
18
|
+
}}
|
|
19
|
+
onClick={onClick}
|
|
20
|
+
>
|
|
22
21
|
<HelpIcon />
|
|
23
|
-
</
|
|
22
|
+
</IconButton>
|
|
24
23
|
);
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
RawHelpButton.propTypes = {
|
|
27
26
|
onClick: PropTypes.func,
|
|
27
|
+
classes: PropTypes.object.isRequired,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
export const HelpButton = withStyles((theme) => ({
|
|
31
|
+
icon: {
|
|
32
|
+
'&:hover': {
|
|
33
|
+
color: theme.palette.grey[300],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}))(RawHelpButton);
|
|
37
|
+
|
|
30
38
|
export const HelpDialog = ({ open, onClose, children, title }) => (
|
|
31
|
-
<Dialog open={open}
|
|
39
|
+
<Dialog open={open} onRequestClose={onClose}>
|
|
32
40
|
<DialogTitle>{title}</DialogTitle>
|
|
33
41
|
<DialogContent>
|
|
34
42
|
<DialogContentText>{children}</DialogContentText>
|
package/src/input.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { default as MaterialInput } from '@
|
|
3
|
+
import { default as MaterialInput } from '@material-ui/core/Input';
|
|
4
4
|
import { InputContainer } from '@pie-lib/render-ui';
|
|
5
5
|
|
|
6
6
|
export default class Input extends React.Component {
|
package/src/inputs.jsx
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import Checkbox from '@
|
|
2
|
-
import Radio from '@
|
|
1
|
+
import Checkbox from '@material-ui/core/Checkbox';
|
|
2
|
+
import Radio from '@material-ui/core/Radio';
|
|
3
3
|
import { InputContainer } from '@pie-lib/render-ui';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import Switch from '@
|
|
7
|
-
import {
|
|
6
|
+
import Switch from '@material-ui/core/Switch';
|
|
7
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
8
|
+
import classNames from 'classnames';
|
|
8
9
|
import { color } from '@pie-lib/render-ui';
|
|
9
10
|
|
|
10
11
|
const InputTypes = {
|
|
12
|
+
classes: PropTypes.object.isRequired,
|
|
11
13
|
className: PropTypes.string,
|
|
12
14
|
label: PropTypes.string,
|
|
13
15
|
checked: PropTypes.bool,
|
|
@@ -16,67 +18,81 @@ const InputTypes = {
|
|
|
16
18
|
error: PropTypes.string,
|
|
17
19
|
};
|
|
18
20
|
|
|
19
|
-
const
|
|
20
|
-
justifyContent: 'inherit',
|
|
21
|
-
transform: 'translate(-20%, 20%)',
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
const InputSwitch = ({ className, label, checked, onChange }) => {
|
|
21
|
+
const RawInputSwitch = ({ classes, className, label, checked, onChange }) => {
|
|
25
22
|
return (
|
|
26
23
|
<InputContainer className={className} label={label}>
|
|
27
|
-
<
|
|
24
|
+
<Switch className={classes.switchRoot} checked={checked} onChange={onChange} aria-label={label} />
|
|
28
25
|
</InputContainer>
|
|
29
26
|
);
|
|
30
27
|
};
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
RawInputSwitch.propTypes = { ...InputTypes };
|
|
30
|
+
|
|
31
|
+
const InputSwitch = withStyles({
|
|
32
|
+
switchRoot: {
|
|
33
|
+
justifyContent: 'inherit',
|
|
34
|
+
transform: 'translate(-20%, 20%)',
|
|
35
|
+
},
|
|
36
|
+
})(RawInputSwitch);
|
|
33
37
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
color: `${color.tertiary()} !important`,
|
|
37
|
-
...(error && {
|
|
38
|
-
color: `${theme.palette.error.main} !important`,
|
|
39
|
-
}),
|
|
40
|
-
}));
|
|
38
|
+
const RawInputCheckbox = (props) => {
|
|
39
|
+
const { classes, className, label, checked, onChange, disabled, error } = props;
|
|
41
40
|
|
|
42
|
-
const InputCheckbox = ({ className, label, checked, onChange, disabled, error }) => {
|
|
43
41
|
return (
|
|
44
42
|
<InputContainer className={className} label={label}>
|
|
45
|
-
<
|
|
43
|
+
<Checkbox
|
|
44
|
+
className={classNames(classes.checkboxRoot, classes.customColor, error && classes.error)}
|
|
46
45
|
disabled={disabled}
|
|
47
46
|
checked={checked}
|
|
48
47
|
onChange={onChange}
|
|
49
48
|
aria-label={label}
|
|
50
|
-
error={error}
|
|
51
49
|
/>
|
|
52
50
|
</InputContainer>
|
|
53
51
|
);
|
|
54
52
|
};
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
RawInputCheckbox.propTypes = { ...InputTypes };
|
|
57
55
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
color: `${color.tertiary()} !important`,
|
|
61
|
-
...(error && {
|
|
62
|
-
color: `${theme.palette.error.main} !important`,
|
|
63
|
-
}),
|
|
64
|
-
}));
|
|
56
|
+
const RawInputRadio = (props) => {
|
|
57
|
+
const { classes, className, label, checked, onChange, disabled, error } = props;
|
|
65
58
|
|
|
66
|
-
const InputRadio = ({ className, label, checked, onChange, disabled, error }) => {
|
|
67
59
|
return (
|
|
68
60
|
<InputContainer className={className} label={label}>
|
|
69
|
-
<
|
|
61
|
+
<Radio
|
|
62
|
+
className={classNames(classes.radioRoot, classes.customColor, error && classes.error)}
|
|
70
63
|
disabled={disabled}
|
|
71
64
|
checked={checked}
|
|
72
65
|
onChange={onChange}
|
|
73
66
|
aria-label={label}
|
|
74
|
-
error={error}
|
|
75
67
|
/>
|
|
76
68
|
</InputContainer>
|
|
77
69
|
);
|
|
78
70
|
};
|
|
79
71
|
|
|
80
|
-
|
|
72
|
+
RawInputRadio.propTypes = { ...InputTypes };
|
|
73
|
+
|
|
74
|
+
const InputCheckbox = withStyles((theme) => ({
|
|
75
|
+
checkboxRoot: {
|
|
76
|
+
transform: 'translate(-25%, 20%)',
|
|
77
|
+
},
|
|
78
|
+
error: {
|
|
79
|
+
color: theme.palette.error.main,
|
|
80
|
+
},
|
|
81
|
+
customColor: {
|
|
82
|
+
color: `${color.tertiary()} !important`,
|
|
83
|
+
},
|
|
84
|
+
}))(RawInputCheckbox);
|
|
85
|
+
|
|
86
|
+
const InputRadio = withStyles((theme) => ({
|
|
87
|
+
radioRoot: {
|
|
88
|
+
transform: 'translate(-20%, 20%)',
|
|
89
|
+
},
|
|
90
|
+
error: {
|
|
91
|
+
color: theme.palette.error.main,
|
|
92
|
+
},
|
|
93
|
+
customColor: {
|
|
94
|
+
color: `${color.tertiary()} !important`,
|
|
95
|
+
},
|
|
96
|
+
}))(RawInputRadio);
|
|
81
97
|
|
|
82
98
|
export { InputSwitch, InputCheckbox, InputRadio };
|
package/src/langs.jsx
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import Input from '@
|
|
2
|
-
import InputLabel from '@
|
|
1
|
+
import Input from '@material-ui/core/Input';
|
|
2
|
+
import InputLabel from '@material-ui/core/InputLabel';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
7
|
+
import Select from '@material-ui/core/Select';
|
|
8
|
+
import MenuItem from '@material-ui/core/MenuItem';
|
|
9
|
+
import FormControl from '@material-ui/core/FormControl';
|
|
9
10
|
import debug from 'debug';
|
|
10
11
|
|
|
11
12
|
const log = debug('pie-elements:config-ui:langs');
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const styles = (theme) => ({
|
|
15
|
+
root: {
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
alignItems: 'start',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
position: 'relative',
|
|
20
|
+
paddingTop: '0px',
|
|
21
|
+
paddingRight: '0px',
|
|
22
|
+
},
|
|
23
|
+
formControl: {
|
|
24
|
+
position: 'initial',
|
|
25
|
+
},
|
|
26
|
+
inputLabel: {
|
|
27
|
+
paddingBottom: theme.spacing.unit,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
position: 'initial',
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
const StyledInputLabel = styled(InputLabel)(({ theme }) => ({
|
|
27
|
-
paddingBottom: theme.spacing(1),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
export class Langs extends React.Component {
|
|
31
|
+
export class RawLangs extends React.Component {
|
|
31
32
|
static propTypes = {
|
|
32
33
|
onChange: PropTypes.func,
|
|
33
34
|
langs: PropTypes.array,
|
|
34
35
|
selected: PropTypes.string,
|
|
35
36
|
label: PropTypes.string,
|
|
37
|
+
classes: PropTypes.object.isRequired,
|
|
36
38
|
uid: PropTypes.string,
|
|
37
39
|
};
|
|
38
40
|
|
|
@@ -50,16 +52,16 @@ export class Langs extends React.Component {
|
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
render() {
|
|
53
|
-
let { langs, selected, label } = this.props;
|
|
55
|
+
let { langs, selected, label, classes } = this.props;
|
|
54
56
|
|
|
55
57
|
log('[render] selected:', selected);
|
|
56
58
|
|
|
57
59
|
return (
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
<
|
|
60
|
+
<div className={classes.root}>
|
|
61
|
+
<FormControl className={classes.formControl}>
|
|
62
|
+
<InputLabel className={classes.inputLabel} htmlFor={this.uid}>
|
|
61
63
|
{label}
|
|
62
|
-
</
|
|
64
|
+
</InputLabel>
|
|
63
65
|
|
|
64
66
|
<Select value={selected} onChange={this.choose} input={<Input id={this.uid} />}>
|
|
65
67
|
{langs.map((l, index) => (
|
|
@@ -68,23 +70,27 @@ export class Langs extends React.Component {
|
|
|
68
70
|
</MenuItem>
|
|
69
71
|
))}
|
|
70
72
|
</Select>
|
|
71
|
-
</
|
|
72
|
-
</
|
|
73
|
+
</FormControl>
|
|
74
|
+
</div>
|
|
73
75
|
);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
78
|
+
|
|
79
|
+
const Langs = withStyles(styles, { name: 'Langs' })(RawLangs);
|
|
76
80
|
export default Langs;
|
|
77
81
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
export const LanguageControls = withStyles({
|
|
83
|
+
languageControls: {
|
|
84
|
+
display: 'grid',
|
|
85
|
+
gridAutoFlow: 'column',
|
|
86
|
+
gridAutoColumns: '1fr',
|
|
87
|
+
gridGap: '8px',
|
|
88
|
+
},
|
|
89
|
+
})(({ classes, langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
|
|
90
|
+
const names = classNames(classes.languageControls, className);
|
|
84
91
|
|
|
85
|
-
export const LanguageControls = ({ langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
|
|
86
92
|
return (
|
|
87
|
-
<
|
|
93
|
+
<div className={names}>
|
|
88
94
|
<Langs
|
|
89
95
|
label="Choose language to edit"
|
|
90
96
|
langs={langs}
|
|
@@ -92,9 +98,9 @@ export const LanguageControls = ({ langs, activeLang, defaultLang, onActiveLangC
|
|
|
92
98
|
onChange={(l) => onActiveLangChange(l)}
|
|
93
99
|
/>
|
|
94
100
|
<Langs label="Default language" langs={langs} selected={defaultLang} onChange={(l) => onDefaultLangChange(l)} />
|
|
95
|
-
</
|
|
101
|
+
</div>
|
|
96
102
|
);
|
|
97
|
-
};
|
|
103
|
+
});
|
|
98
104
|
|
|
99
105
|
LanguageControls.propTypes = {
|
|
100
106
|
langs: PropTypes.array,
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Measure from 'react-measure';
|
|
3
|
-
import {
|
|
3
|
+
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
|
|
4
4
|
import { withContentRect } from 'react-measure';
|
|
5
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
6
|
import PropTypes from 'prop-types';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import LayoutContents from './layout-contents';
|
|
8
9
|
import SettingsBox from './settings-box';
|
|
9
10
|
import { AppendCSSRules } from '@pie-lib/render-ui';
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
const styles = {
|
|
13
|
+
extraCSSRules: {},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const theme = createMuiTheme({
|
|
12
17
|
typography: {
|
|
18
|
+
// In MUI v3, this opts into the h1–h6 variants; otherwise use display1/headline/etc.
|
|
19
|
+
useNextVariants: true,
|
|
13
20
|
fontFamily: 'inherit',
|
|
14
21
|
},
|
|
15
22
|
});
|
|
@@ -18,6 +25,7 @@ class MeasuredConfigLayout extends AppendCSSRules {
|
|
|
18
25
|
static propTypes = {
|
|
19
26
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
|
|
20
27
|
className: PropTypes.string,
|
|
28
|
+
classes: PropTypes.object,
|
|
21
29
|
dimensions: PropTypes.object,
|
|
22
30
|
settings: PropTypes.element,
|
|
23
31
|
sidePanelMinWidth: PropTypes.number,
|
|
@@ -43,38 +51,41 @@ class MeasuredConfigLayout extends AppendCSSRules {
|
|
|
43
51
|
const layoutMode =
|
|
44
52
|
bounds.width > sidePanelMinWidth && (maxWidth ? maxWidth > sidePanelMinWidth : true) ? 'inline' : 'tabbed';
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
// Only update state (and cause a re-render) if the computed layoutMode changed.
|
|
55
|
+
if (layoutMode !== this.state.layoutMode) {
|
|
56
|
+
this.setState({ layoutMode });
|
|
57
|
+
}
|
|
47
58
|
};
|
|
48
59
|
|
|
49
60
|
render() {
|
|
50
61
|
return (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
// TODO: REVIEW MuiThemeProvider usage
|
|
63
|
+
// Different theme object identities will force theme consumers to re-render.
|
|
64
|
+
<MuiThemeProvider theme={theme}>
|
|
65
|
+
<Measure bounds onResize={this.onResize}>
|
|
66
|
+
{({ measureRef }) => {
|
|
67
|
+
const { children, settings, hideSettings, dimensions, classes } = this.props;
|
|
68
|
+
const { layoutMode } = this.state;
|
|
57
69
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
const settingsPanel =
|
|
71
|
+
layoutMode === 'inline' ? <SettingsBox className="settings-box">{settings}</SettingsBox> : settings;
|
|
72
|
+
const secondaryContent = hideSettings ? null : settingsPanel;
|
|
73
|
+
const finalClass = classNames('main-container', classes.extraCSSRules);
|
|
62
74
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</StyledEngineProvider>
|
|
75
|
+
return (
|
|
76
|
+
<div ref={measureRef} className={finalClass}>
|
|
77
|
+
<LayoutContents mode={layoutMode} secondary={secondaryContent} dimensions={dimensions}>
|
|
78
|
+
{children}
|
|
79
|
+
</LayoutContents>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}}
|
|
83
|
+
</Measure>
|
|
84
|
+
</MuiThemeProvider>
|
|
74
85
|
);
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
|
|
78
|
-
const ConfigLayout = withContentRect('bounds')(MeasuredConfigLayout);
|
|
89
|
+
const ConfigLayout = withStyles(styles)(withContentRect('bounds')(MeasuredConfigLayout));
|
|
79
90
|
|
|
80
91
|
export default ConfigLayout;
|