@pie-lib/config-ui 11.26.6-esmbeta.0 → 11.27.0-mui-update.0
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 +36 -0
- package/lib/alert-dialog.js +23 -42
- package/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js +56 -71
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/feedback-menu.js +24 -63
- package/lib/choice-configuration/feedback-menu.js.map +1 -1
- package/lib/choice-configuration/index.js +201 -257
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/choice-utils.js +6 -18
- package/lib/choice-utils.js.map +1 -1
- package/lib/feedback-config/feedback-selector.js +77 -114
- package/lib/feedback-config/feedback-selector.js.map +1 -1
- package/lib/feedback-config/group.js +26 -40
- package/lib/feedback-config/group.js.map +1 -1
- package/lib/feedback-config/index.js +38 -90
- package/lib/feedback-config/index.js.map +1 -1
- package/lib/form-section.js +24 -33
- package/lib/form-section.js.map +1 -1
- package/lib/help.js +39 -80
- package/lib/help.js.map +1 -1
- package/lib/index.js +1 -31
- package/lib/index.js.map +1 -1
- package/lib/input.js +21 -54
- package/lib/input.js.map +1 -1
- package/lib/inputs.js +61 -95
- package/lib/inputs.js.map +1 -1
- package/lib/langs.js +56 -100
- package/lib/langs.js.map +1 -1
- package/lib/layout/config-layout.js +30 -65
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/layout/index.js +0 -3
- package/lib/layout/index.js.map +1 -1
- package/lib/layout/layout-contents.js +72 -101
- package/lib/layout/layout-contents.js.map +1 -1
- package/lib/layout/settings-box.js +27 -56
- package/lib/layout/settings-box.js.map +1 -1
- package/lib/mui-box/index.js +41 -57
- package/lib/mui-box/index.js.map +1 -1
- package/lib/number-text-field-custom.js +79 -161
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js +57 -115
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js +23 -31
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/display-size.js +16 -32
- package/lib/settings/display-size.js.map +1 -1
- package/lib/settings/index.js +14 -47
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js +142 -228
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js +21 -30
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js +34 -46
- package/lib/settings/toggle.js.map +1 -1
- package/lib/tabs/index.js +22 -57
- package/lib/tabs/index.js.map +1 -1
- package/lib/tags-input/index.js +50 -99
- package/lib/tags-input/index.js.map +1 -1
- package/lib/two-choice.js +46 -90
- package/lib/two-choice.js.map +1 -1
- package/lib/with-stateful-model.js +8 -31
- package/lib/with-stateful-model.js.map +1 -1
- package/package.json +12 -17
- package/src/__tests__/number-text-field.test.jsx +1 -1
- package/src/alert-dialog.jsx +14 -18
- package/src/checkbox.jsx +42 -46
- package/src/choice-configuration/feedback-menu.jsx +5 -5
- package/src/choice-configuration/index.jsx +205 -193
- package/src/feedback-config/feedback-selector.jsx +51 -53
- package/src/feedback-config/group.jsx +21 -22
- package/src/feedback-config/index.jsx +27 -29
- package/src/form-section.jsx +18 -18
- package/src/help.jsx +20 -28
- package/src/input.jsx +1 -1
- package/src/inputs.jsx +34 -50
- package/src/langs.jsx +40 -46
- package/src/layout/config-layout.jsx +27 -23
- package/src/layout/layout-contents.jsx +34 -34
- package/src/layout/settings-box.jsx +16 -19
- package/src/mui-box/index.jsx +35 -43
- package/src/number-text-field-custom.jsx +30 -36
- package/src/number-text-field.jsx +22 -30
- package/src/radio-with-label.jsx +17 -13
- package/src/settings/display-size.jsx +12 -11
- package/src/settings/panel.jsx +83 -89
- package/src/settings/settings-radio-label.jsx +17 -13
- package/src/settings/toggle.jsx +29 -29
- package/src/tabs/index.jsx +8 -8
- package/src/tags-input/index.jsx +35 -38
- package/src/two-choice.jsx +15 -19
- package/esm/index.js +0 -78747
- package/esm/index.js.map +0 -1
- package/esm/package.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 {
|
|
5
|
-
import classNames from 'classnames';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
const StyledChoiceHolder = styled('div')(() => ({
|
|
7
|
+
display: 'flex',
|
|
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': {
|
|
9
18
|
fontSize: theme.typography.fontSize - 2,
|
|
10
19
|
},
|
|
11
|
-
|
|
12
|
-
display: 'flex',
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
},
|
|
15
|
-
choiceHolder: {
|
|
16
|
-
display: 'flex',
|
|
17
|
-
alignItems: 'center',
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
+
}));
|
|
20
21
|
|
|
21
22
|
const Group = (props) => {
|
|
22
|
-
const { feedbackLabels, value,
|
|
23
|
+
const { feedbackLabels, value, className, onChange, keys } = props;
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
|
-
<
|
|
26
|
+
<StyledChoiceHolder className={className}>
|
|
26
27
|
{keys.map((key) => {
|
|
27
28
|
return (
|
|
28
|
-
<
|
|
29
|
-
<
|
|
29
|
+
<StyledChoice key={key}>
|
|
30
|
+
<StyledRadioWithLabel
|
|
30
31
|
value={key}
|
|
31
32
|
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
|
+
</StyledChoice>
|
|
37
37
|
);
|
|
38
38
|
})}
|
|
39
|
-
</
|
|
39
|
+
</StyledChoiceHolder>
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -44,9 +44,8 @@ Group.propTypes = {
|
|
|
44
44
|
className: PropTypes.string,
|
|
45
45
|
feedbackLabels: PropTypes.object.isRequired,
|
|
46
46
|
value: PropTypes.string.isRequired,
|
|
47
|
-
classes: PropTypes.object.isRequired,
|
|
48
47
|
keys: PropTypes.arrayOf(PropTypes.string),
|
|
49
48
|
onChange: PropTypes.func,
|
|
50
49
|
};
|
|
51
50
|
|
|
52
|
-
export default
|
|
51
|
+
export default Group;
|
|
@@ -1,27 +1,26 @@
|
|
|
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 '@material
|
|
9
|
-
import ExpandMoreIcon from '@
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import Accordion from '@mui/material/Accordion';
|
|
6
|
+
import AccordionSummary from '@mui/material/AccordionSummary';
|
|
7
|
+
import AccordionDetails from '@mui/material/AccordionDetails';
|
|
8
|
+
import Typography from '@mui/material/Typography';
|
|
9
|
+
import ExpandMoreIcon from '@mui/icons-material/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
|
-
|
|
24
|
-
};
|
|
14
|
+
const StyledFeedbackContainer = styled('div')(() => ({
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flex: 1,
|
|
17
|
+
flexDirection: 'column',
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const StyledAccordionDetails = styled(AccordionDetails)(() => ({
|
|
21
|
+
paddingTop: 0,
|
|
22
|
+
paddingBottom: 0,
|
|
23
|
+
}));
|
|
25
24
|
|
|
26
25
|
export const buildDefaults = (input) => {
|
|
27
26
|
return merge(
|
|
@@ -45,7 +44,6 @@ export class FeedbackConfig extends React.Component {
|
|
|
45
44
|
partial: PropTypes.shape(FeedbackType),
|
|
46
45
|
}),
|
|
47
46
|
onChange: PropTypes.func.isRequired,
|
|
48
|
-
classes: PropTypes.object.isRequired,
|
|
49
47
|
toolbarOpts: PropTypes.object,
|
|
50
48
|
};
|
|
51
49
|
|
|
@@ -68,17 +66,17 @@ export class FeedbackConfig extends React.Component {
|
|
|
68
66
|
onPartialChange = this.onChange.bind(this, 'partial');
|
|
69
67
|
|
|
70
68
|
render() {
|
|
71
|
-
const {
|
|
69
|
+
const { className, allowPartial, feedback, toolbarOpts } = this.props;
|
|
72
70
|
|
|
73
71
|
return (
|
|
74
72
|
<div className={className}>
|
|
75
|
-
<
|
|
76
|
-
<
|
|
77
|
-
<Typography
|
|
78
|
-
</
|
|
73
|
+
<Accordion>
|
|
74
|
+
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
|
75
|
+
<Typography>Feedback</Typography>
|
|
76
|
+
</AccordionSummary>
|
|
79
77
|
|
|
80
|
-
<
|
|
81
|
-
<
|
|
78
|
+
<StyledAccordionDetails>
|
|
79
|
+
<StyledFeedbackContainer>
|
|
82
80
|
<FeedbackSelector
|
|
83
81
|
label="If correct, show"
|
|
84
82
|
feedback={feedback.correct}
|
|
@@ -101,12 +99,12 @@ export class FeedbackConfig extends React.Component {
|
|
|
101
99
|
onChange={this.onIncorrectChange}
|
|
102
100
|
toolbarOpts={toolbarOpts}
|
|
103
101
|
/>
|
|
104
|
-
</
|
|
105
|
-
</
|
|
106
|
-
</
|
|
102
|
+
</StyledFeedbackContainer>
|
|
103
|
+
</StyledAccordionDetails>
|
|
104
|
+
</Accordion>
|
|
107
105
|
</div>
|
|
108
106
|
);
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
export default
|
|
110
|
+
export default FeedbackConfig;
|
package/src/form-section.jsx
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Typography from '@material
|
|
3
|
-
import
|
|
4
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
2
|
+
import Typography from '@mui/material/Typography';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
label: {
|
|
12
|
-
marginBottom: theme.spacing.unit,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
5
|
+
const StyledFormSection = styled('div')(({ theme }) => ({
|
|
6
|
+
marginTop: theme.spacing(2),
|
|
7
|
+
marginBottom: theme.spacing(2),
|
|
8
|
+
}));
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
const StyledTypography = styled(Typography)(({ theme }) => ({
|
|
11
|
+
marginBottom: theme.spacing(1),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const FormSection = ({ className, label, children, labelExtraStyle }) => (
|
|
15
|
+
<StyledFormSection className={className}>
|
|
16
|
+
<StyledTypography variant="subtitle1" style={labelExtraStyle}>
|
|
19
17
|
{label}
|
|
20
|
-
</
|
|
18
|
+
</StyledTypography>
|
|
21
19
|
{children}
|
|
22
|
-
</
|
|
23
|
-
)
|
|
20
|
+
</StyledFormSection>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export default FormSection;
|
package/src/help.jsx
CHANGED
|
@@ -1,42 +1,34 @@
|
|
|
1
|
-
import Dialog from '@material
|
|
2
|
-
import DialogTitle from '@material
|
|
3
|
-
import DialogContentText from '@material
|
|
4
|
-
import DialogContent from '@material
|
|
5
|
-
import DialogActions from '@material
|
|
1
|
+
import Dialog from '@mui/material/Dialog';
|
|
2
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
3
|
+
import DialogContentText from '@mui/material/DialogContentText';
|
|
4
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
5
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
|
|
8
|
-
import Button from '@material
|
|
9
|
-
import HelpIcon from '@
|
|
10
|
-
import IconButton from '@material
|
|
8
|
+
import Button from '@mui/material/Button';
|
|
9
|
+
import HelpIcon from '@mui/icons-material/Help';
|
|
10
|
+
import IconButton from '@mui/material/IconButton';
|
|
11
11
|
import React from 'react';
|
|
12
|
-
import {
|
|
12
|
+
import { styled } from '@mui/material/styles';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const StyledIconButton = styled(IconButton)(({ theme }) => ({
|
|
15
|
+
'&:hover': {
|
|
16
|
+
color: theme.palette.grey[300],
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
export const HelpButton = ({ onClick }) => (
|
|
21
|
+
<StyledIconButton onClick={onClick} size="large">
|
|
21
22
|
<HelpIcon />
|
|
22
|
-
</
|
|
23
|
+
</StyledIconButton>
|
|
23
24
|
);
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
HelpButton.propTypes = {
|
|
26
27
|
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
|
-
|
|
38
30
|
export const HelpDialog = ({ open, onClose, children, title }) => (
|
|
39
|
-
<Dialog open={open}
|
|
31
|
+
<Dialog open={open} onClose={onClose}>
|
|
40
32
|
<DialogTitle>{title}</DialogTitle>
|
|
41
33
|
<DialogContent>
|
|
42
34
|
<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 '@material
|
|
3
|
+
import { default as MaterialInput } from '@mui/material/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,15 +1,13 @@
|
|
|
1
|
-
import Checkbox from '@material
|
|
2
|
-
import Radio from '@material
|
|
1
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
2
|
+
import Radio from '@mui/material/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 '@material
|
|
7
|
-
import {
|
|
8
|
-
import classNames from 'classnames';
|
|
6
|
+
import Switch from '@mui/material/Switch';
|
|
7
|
+
import { styled } from '@mui/material/styles';
|
|
9
8
|
import { color } from '@pie-lib/render-ui';
|
|
10
9
|
|
|
11
10
|
const InputTypes = {
|
|
12
|
-
classes: PropTypes.object.isRequired,
|
|
13
11
|
className: PropTypes.string,
|
|
14
12
|
label: PropTypes.string,
|
|
15
13
|
checked: PropTypes.bool,
|
|
@@ -18,81 +16,67 @@ const InputTypes = {
|
|
|
18
16
|
error: PropTypes.string,
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
const
|
|
19
|
+
const StyledSwitch = styled(Switch)(() => ({
|
|
20
|
+
justifyContent: 'inherit',
|
|
21
|
+
transform: 'translate(-20%, 20%)',
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const InputSwitch = ({ className, label, checked, onChange }) => {
|
|
22
25
|
return (
|
|
23
26
|
<InputContainer className={className} label={label}>
|
|
24
|
-
<
|
|
27
|
+
<StyledSwitch checked={checked} onChange={onChange} aria-label={label} />
|
|
25
28
|
</InputContainer>
|
|
26
29
|
);
|
|
27
30
|
};
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const InputSwitch = withStyles({
|
|
32
|
-
switchRoot: {
|
|
33
|
-
justifyContent: 'inherit',
|
|
34
|
-
transform: 'translate(-20%, 20%)',
|
|
35
|
-
},
|
|
36
|
-
})(RawInputSwitch);
|
|
32
|
+
InputSwitch.propTypes = { ...InputTypes };
|
|
37
33
|
|
|
38
|
-
const
|
|
39
|
-
|
|
34
|
+
const StyledCheckbox = styled(Checkbox)(({ theme, error }) => ({
|
|
35
|
+
transform: 'translate(-25%, 20%)',
|
|
36
|
+
color: `${color.tertiary()} !important`,
|
|
37
|
+
...(error && {
|
|
38
|
+
color: `${theme.palette.error.main} !important`,
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
40
41
|
|
|
42
|
+
const InputCheckbox = ({ className, label, checked, onChange, disabled, error }) => {
|
|
41
43
|
return (
|
|
42
44
|
<InputContainer className={className} label={label}>
|
|
43
|
-
<
|
|
44
|
-
className={classNames(classes.checkboxRoot, classes.customColor, error && classes.error)}
|
|
45
|
+
<StyledCheckbox
|
|
45
46
|
disabled={disabled}
|
|
46
47
|
checked={checked}
|
|
47
48
|
onChange={onChange}
|
|
48
49
|
aria-label={label}
|
|
50
|
+
error={error}
|
|
49
51
|
/>
|
|
50
52
|
</InputContainer>
|
|
51
53
|
);
|
|
52
54
|
};
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
InputCheckbox.propTypes = { ...InputTypes };
|
|
55
57
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
+
const StyledRadio = styled(Radio)(({ theme, error }) => ({
|
|
59
|
+
transform: 'translate(-20%, 20%)',
|
|
60
|
+
color: `${color.tertiary()} !important`,
|
|
61
|
+
...(error && {
|
|
62
|
+
color: `${theme.palette.error.main} !important`,
|
|
63
|
+
}),
|
|
64
|
+
}));
|
|
58
65
|
|
|
66
|
+
const InputRadio = ({ className, label, checked, onChange, disabled, error }) => {
|
|
59
67
|
return (
|
|
60
68
|
<InputContainer className={className} label={label}>
|
|
61
|
-
<
|
|
62
|
-
className={classNames(classes.radioRoot, classes.customColor, error && classes.error)}
|
|
69
|
+
<StyledRadio
|
|
63
70
|
disabled={disabled}
|
|
64
71
|
checked={checked}
|
|
65
72
|
onChange={onChange}
|
|
66
73
|
aria-label={label}
|
|
74
|
+
error={error}
|
|
67
75
|
/>
|
|
68
76
|
</InputContainer>
|
|
69
77
|
);
|
|
70
78
|
};
|
|
71
79
|
|
|
72
|
-
|
|
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);
|
|
80
|
+
InputRadio.propTypes = { ...InputTypes };
|
|
97
81
|
|
|
98
82
|
export { InputSwitch, InputCheckbox, InputRadio };
|
package/src/langs.jsx
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
import Input from '@material
|
|
2
|
-
import InputLabel from '@material
|
|
1
|
+
import Input from '@mui/material/Input';
|
|
2
|
+
import InputLabel from '@mui/material/InputLabel';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import FormControl from '@material-ui/core/FormControl';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
import Select from '@mui/material/Select';
|
|
7
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
8
|
+
import FormControl from '@mui/material/FormControl';
|
|
10
9
|
import debug from 'debug';
|
|
11
10
|
|
|
12
11
|
const log = debug('pie-elements:config-ui:langs');
|
|
13
12
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
formControl: {
|
|
24
|
-
position: 'initial',
|
|
25
|
-
},
|
|
26
|
-
inputLabel: {
|
|
27
|
-
paddingBottom: theme.spacing.unit,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
13
|
+
const StyledRoot = styled('div')(() => ({
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
alignItems: 'start',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
position: 'relative',
|
|
18
|
+
paddingTop: '0px',
|
|
19
|
+
paddingRight: '0px',
|
|
20
|
+
}));
|
|
30
21
|
|
|
31
|
-
|
|
22
|
+
const StyledFormControl = styled(FormControl)(() => ({
|
|
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 {
|
|
32
31
|
static propTypes = {
|
|
33
32
|
onChange: PropTypes.func,
|
|
34
33
|
langs: PropTypes.array,
|
|
35
34
|
selected: PropTypes.string,
|
|
36
35
|
label: PropTypes.string,
|
|
37
|
-
classes: PropTypes.object.isRequired,
|
|
38
36
|
uid: PropTypes.string,
|
|
39
37
|
};
|
|
40
38
|
|
|
@@ -52,16 +50,16 @@ export class RawLangs extends React.Component {
|
|
|
52
50
|
};
|
|
53
51
|
|
|
54
52
|
render() {
|
|
55
|
-
let { langs, selected, label
|
|
53
|
+
let { langs, selected, label } = this.props;
|
|
56
54
|
|
|
57
55
|
log('[render] selected:', selected);
|
|
58
56
|
|
|
59
57
|
return (
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
<
|
|
58
|
+
<StyledRoot>
|
|
59
|
+
<StyledFormControl>
|
|
60
|
+
<StyledInputLabel htmlFor={this.uid}>
|
|
63
61
|
{label}
|
|
64
|
-
</
|
|
62
|
+
</StyledInputLabel>
|
|
65
63
|
|
|
66
64
|
<Select value={selected} onChange={this.choose} input={<Input id={this.uid} />}>
|
|
67
65
|
{langs.map((l, index) => (
|
|
@@ -70,27 +68,23 @@ export class RawLangs extends React.Component {
|
|
|
70
68
|
</MenuItem>
|
|
71
69
|
))}
|
|
72
70
|
</Select>
|
|
73
|
-
</
|
|
74
|
-
</
|
|
71
|
+
</StyledFormControl>
|
|
72
|
+
</StyledRoot>
|
|
75
73
|
);
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
const Langs = withStyles(styles, { name: 'Langs' })(RawLangs);
|
|
80
76
|
export default Langs;
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
})(({ classes, langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
|
|
90
|
-
const names = classNames(classes.languageControls, className);
|
|
78
|
+
const StyledLanguageControls = styled('div')(() => ({
|
|
79
|
+
display: 'grid',
|
|
80
|
+
gridAutoFlow: 'column',
|
|
81
|
+
gridAutoColumns: '1fr',
|
|
82
|
+
gridGap: '8px',
|
|
83
|
+
}));
|
|
91
84
|
|
|
85
|
+
export const LanguageControls = ({ langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
|
|
92
86
|
return (
|
|
93
|
-
<
|
|
87
|
+
<StyledLanguageControls className={className}>
|
|
94
88
|
<Langs
|
|
95
89
|
label="Choose language to edit"
|
|
96
90
|
langs={langs}
|
|
@@ -98,9 +92,9 @@ export const LanguageControls = withStyles({
|
|
|
98
92
|
onChange={(l) => onActiveLangChange(l)}
|
|
99
93
|
/>
|
|
100
94
|
<Langs label="Default language" langs={langs} selected={defaultLang} onChange={(l) => onDefaultLangChange(l)} />
|
|
101
|
-
</
|
|
95
|
+
</StyledLanguageControls>
|
|
102
96
|
);
|
|
103
|
-
}
|
|
97
|
+
};
|
|
104
98
|
|
|
105
99
|
LanguageControls.propTypes = {
|
|
106
100
|
langs: PropTypes.array,
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Measure from 'react-measure';
|
|
3
|
+
import { createTheme, ThemeProvider, StyledEngineProvider } from '@mui/material/styles';
|
|
3
4
|
import { withContentRect } from 'react-measure';
|
|
4
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import LayoutContents from './layout-contents';
|
|
8
8
|
import SettingsBox from './settings-box';
|
|
9
9
|
import { AppendCSSRules } from '@pie-lib/render-ui';
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const theme = createTheme({
|
|
12
|
+
typography: {
|
|
13
|
+
fontFamily: 'inherit',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
14
16
|
|
|
15
17
|
class MeasuredConfigLayout extends AppendCSSRules {
|
|
16
18
|
static propTypes = {
|
|
17
19
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
|
|
18
20
|
className: PropTypes.string,
|
|
19
|
-
classes: PropTypes.object,
|
|
20
21
|
dimensions: PropTypes.object,
|
|
21
22
|
settings: PropTypes.element,
|
|
22
23
|
sidePanelMinWidth: PropTypes.number,
|
|
@@ -47,29 +48,32 @@ class MeasuredConfigLayout extends AppendCSSRules {
|
|
|
47
48
|
|
|
48
49
|
render() {
|
|
49
50
|
return (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
<StyledEngineProvider injectFirst>(<ThemeProvider theme={theme}>
|
|
52
|
+
<Measure bounds onResize={this.onResize}>
|
|
53
|
+
{({ measureRef }) => {
|
|
54
|
+
const { children, settings, hideSettings, dimensions } = this.props;
|
|
55
|
+
const { layoutMode } = this.state;
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const settingsPanel =
|
|
58
|
+
layoutMode === 'inline' ? <SettingsBox className="settings-box">{settings}</SettingsBox> : settings;
|
|
59
|
+
const secondaryContent = hideSettings ? null : settingsPanel;
|
|
60
|
+
const finalClass = classNames('main-container');
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
return (
|
|
63
|
+
<div ref={measureRef} className={finalClass}>
|
|
64
|
+
<LayoutContents mode={layoutMode} secondary={secondaryContent} dimensions={dimensions}>
|
|
65
|
+
{children}
|
|
66
|
+
</LayoutContents>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}}
|
|
70
|
+
</Measure>
|
|
71
|
+
</ThemeProvider>)
|
|
72
|
+
</StyledEngineProvider>
|
|
69
73
|
);
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
|
|
73
|
-
const ConfigLayout =
|
|
77
|
+
const ConfigLayout = withContentRect('bounds')(MeasuredConfigLayout);
|
|
74
78
|
|
|
75
79
|
export default ConfigLayout;
|