@pie-lib/render-ui 4.35.2-next.0 → 4.37.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 +22 -9
- package/lib/append-css-rules.js +10 -37
- package/lib/append-css-rules.js.map +1 -1
- package/lib/assets/enableAudioAutoplayImage.js +1 -2
- package/lib/assets/enableAudioAutoplayImage.js.map +1 -1
- package/lib/collapsible/index.js +31 -64
- package/lib/collapsible/index.js.map +1 -1
- package/lib/color.js +57 -201
- package/lib/color.js.map +1 -1
- package/lib/feedback.js +56 -97
- package/lib/feedback.js.map +1 -1
- package/lib/has-media.js +2 -7
- package/lib/has-media.js.map +1 -1
- package/lib/has-text.js +1 -7
- package/lib/has-text.js.map +1 -1
- package/lib/html-and-math.js +10 -30
- package/lib/html-and-math.js.map +1 -1
- package/lib/index.js +1 -24
- package/lib/index.js.map +1 -1
- package/lib/input-container.js +43 -44
- package/lib/input-container.js.map +1 -1
- package/lib/preview-layout.js +22 -58
- package/lib/preview-layout.js.map +1 -1
- package/lib/preview-prompt.js +89 -136
- package/lib/preview-prompt.js.map +1 -1
- package/lib/purpose.js +1 -7
- package/lib/purpose.js.map +1 -1
- package/lib/readable.js +1 -7
- package/lib/readable.js.map +1 -1
- package/lib/response-indicators.js +37 -86
- package/lib/response-indicators.js.map +1 -1
- package/lib/ui-layout.js +70 -81
- package/lib/ui-layout.js.map +1 -1
- package/lib/withUndoReset.js +51 -97
- package/lib/withUndoReset.js.map +1 -1
- package/package.json +14 -11
- package/src/collapsible/index.jsx +17 -17
- package/src/color.js +1 -5
- package/src/feedback.jsx +44 -46
- package/src/input-container.jsx +41 -32
- package/src/preview-layout.jsx +11 -23
- package/src/preview-prompt.jsx +62 -62
- package/src/response-indicators.jsx +22 -29
- package/src/ui-layout.jsx +60 -40
- package/src/withUndoReset.jsx +48 -50
package/src/preview-layout.jsx
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import UiLayout from './ui-layout';
|
|
5
5
|
|
|
6
|
+
const StyledUiLayout = styled(UiLayout)({
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexDirection: 'column',
|
|
9
|
+
position: 'relative',
|
|
10
|
+
});
|
|
11
|
+
|
|
6
12
|
class PreviewLayout extends React.Component {
|
|
7
13
|
static propTypes = {
|
|
8
14
|
ariaLabel: PropTypes.string,
|
|
9
15
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
10
|
-
classes: PropTypes.object,
|
|
11
16
|
role: PropTypes.string,
|
|
12
17
|
extraCSSRules: PropTypes.shape({
|
|
13
18
|
names: PropTypes.arrayOf(PropTypes.string),
|
|
@@ -17,32 +22,15 @@ class PreviewLayout extends React.Component {
|
|
|
17
22
|
};
|
|
18
23
|
|
|
19
24
|
render() {
|
|
20
|
-
const { children,
|
|
25
|
+
const { children, ariaLabel, role, extraCSSRules, fontSizeFactor, classes } = this.props;
|
|
21
26
|
const accessibility = ariaLabel ? { 'aria-label': ariaLabel, role } : {};
|
|
22
27
|
|
|
23
28
|
return (
|
|
24
|
-
<
|
|
25
|
-
className={classes.container}
|
|
26
|
-
{...accessibility}
|
|
27
|
-
extraCSSRules={extraCSSRules}
|
|
28
|
-
fontSizeFactor={fontSizeFactor}
|
|
29
|
-
>
|
|
29
|
+
<StyledUiLayout {...accessibility} extraCSSRules={extraCSSRules} fontSizeFactor={fontSizeFactor} classes={classes}>
|
|
30
30
|
{children}
|
|
31
|
-
</
|
|
31
|
+
</StyledUiLayout>
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
container: {
|
|
38
|
-
display: 'flex',
|
|
39
|
-
flexDirection: 'column',
|
|
40
|
-
position: 'relative',
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const Styled = withStyles(styles)(PreviewLayout);
|
|
45
|
-
|
|
46
|
-
const RootElem = (props) => <Styled {...props} />;
|
|
47
|
-
|
|
48
|
-
export default RootElem;
|
|
36
|
+
export default PreviewLayout;
|
package/src/preview-prompt.jsx
CHANGED
|
@@ -1,15 +1,68 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import * as color from './color';
|
|
5
5
|
|
|
6
|
+
const StyledPromptContainer = styled('div')(({ theme, tagName }) => ({
|
|
7
|
+
// Base promptTable styles
|
|
8
|
+
'&:not(.MathJax) > table': {
|
|
9
|
+
borderCollapse: 'collapse',
|
|
10
|
+
},
|
|
11
|
+
// Apply vertical striping only when first column is a header column (th)
|
|
12
|
+
'&:not(.MathJax) > table:has(tr:first-child th:first-child) td': {
|
|
13
|
+
'&:nth-child(2n)': {
|
|
14
|
+
backgroundColor: '#f6f8fa',
|
|
15
|
+
color: theme.palette.common.black,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
// Apply horizontal striping for tables where first element is NOT a header (th)
|
|
19
|
+
'&:not(.MathJax) > table:not(:has(tr:first-child th:first-child)) tr': {
|
|
20
|
+
'&:nth-child(2n)': {
|
|
21
|
+
backgroundColor: '#f6f8fa',
|
|
22
|
+
color: theme.palette.common.black,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
// align table content to left as per STAR requirement PD-3687
|
|
26
|
+
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
27
|
+
padding: '.6em 1em',
|
|
28
|
+
textAlign: 'left',
|
|
29
|
+
},
|
|
30
|
+
// added this to fix alignment of text in prompt imported from studio (PD-3423)
|
|
31
|
+
'&:not(.MathJax) > table td > p.kds-indent': {
|
|
32
|
+
textAlign: 'initial',
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// Conditional styles based on class names
|
|
36
|
+
'&.prompt': {
|
|
37
|
+
verticalAlign: 'middle',
|
|
38
|
+
color: color.text(),
|
|
39
|
+
},
|
|
40
|
+
'&.legend': {
|
|
41
|
+
width: '100%',
|
|
42
|
+
fontSize: 'inherit !important',
|
|
43
|
+
},
|
|
44
|
+
'&.rationale': {
|
|
45
|
+
paddingLeft: theme.spacing(4),
|
|
46
|
+
paddingBottom: theme.spacing(1),
|
|
47
|
+
},
|
|
48
|
+
'&.label': {
|
|
49
|
+
color: `${color.text()} !important`,
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
verticalAlign: 'middle',
|
|
53
|
+
cursor: 'pointer',
|
|
54
|
+
'& > p': {
|
|
55
|
+
margin: '0 0 0 0 !important',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
59
|
+
|
|
6
60
|
//Used these below to replace \\embed{newLine} with \\newline from prompt which will get parsed in MathJax
|
|
7
61
|
const NEWLINE_BLOCK_REGEX = /\\embed\{newLine\}\[\]/g;
|
|
8
62
|
const NEWLINE_LATEX = '\\newline ';
|
|
9
63
|
|
|
10
64
|
export class PreviewPrompt extends Component {
|
|
11
65
|
static propTypes = {
|
|
12
|
-
classes: PropTypes.object,
|
|
13
66
|
prompt: PropTypes.string,
|
|
14
67
|
tagName: PropTypes.string,
|
|
15
68
|
className: PropTypes.string,
|
|
@@ -186,19 +239,18 @@ export class PreviewPrompt extends Component {
|
|
|
186
239
|
}
|
|
187
240
|
|
|
188
241
|
render() {
|
|
189
|
-
const { prompt,
|
|
190
|
-
|
|
191
|
-
// legend tag was added once with accessibility tasks, wee need extra style to make it work with images alignment
|
|
242
|
+
const { prompt, tagName, className, onClick, defaultClassName } = this.props;
|
|
243
|
+
// legend tag was added once with accessibility tasks, we need extra style to make it work with images alignment
|
|
192
244
|
const legendClass = tagName === 'legend' ? 'legend' : '';
|
|
193
|
-
const customClasses = `${
|
|
194
|
-
legendClass
|
|
195
|
-
] || ''}`;
|
|
245
|
+
const customClasses = `${className || ''} ${defaultClassName || ''} ${legendClass}`.trim();
|
|
196
246
|
|
|
197
247
|
return (
|
|
198
|
-
<
|
|
248
|
+
<StyledPromptContainer
|
|
249
|
+
as={tagName || 'div'}
|
|
199
250
|
id={'preview-prompt'}
|
|
200
251
|
onClick={onClick}
|
|
201
252
|
className={customClasses}
|
|
253
|
+
tagName={tagName}
|
|
202
254
|
dangerouslySetInnerHTML={{
|
|
203
255
|
__html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX),
|
|
204
256
|
}}
|
|
@@ -207,56 +259,4 @@ export class PreviewPrompt extends Component {
|
|
|
207
259
|
}
|
|
208
260
|
}
|
|
209
261
|
|
|
210
|
-
|
|
211
|
-
prompt: {
|
|
212
|
-
verticalAlign: 'middle',
|
|
213
|
-
color: color.text(),
|
|
214
|
-
},
|
|
215
|
-
legend: {
|
|
216
|
-
width: '100%',
|
|
217
|
-
fontSize: 'inherit !important',
|
|
218
|
-
},
|
|
219
|
-
rationale: {
|
|
220
|
-
paddingLeft: theme.spacing.unit * 4,
|
|
221
|
-
paddingBottom: theme.spacing.unit,
|
|
222
|
-
},
|
|
223
|
-
label: {
|
|
224
|
-
color: `${color.text()} !important`, //'var(--choice-input-color, black)',
|
|
225
|
-
display: 'flex',
|
|
226
|
-
flexDirection: 'column',
|
|
227
|
-
verticalAlign: 'middle',
|
|
228
|
-
cursor: 'pointer',
|
|
229
|
-
'& > p': {
|
|
230
|
-
margin: '0 0 0 0 !important',
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
promptTable: {
|
|
234
|
-
'&:not(.MathJax) > table': {
|
|
235
|
-
borderCollapse: 'collapse',
|
|
236
|
-
},
|
|
237
|
-
// Apply vertical striping only when first column is a header column (th)
|
|
238
|
-
'&:not(.MathJax) > table:has(tr:first-child th:first-child) td': {
|
|
239
|
-
'&:nth-child(2n)': {
|
|
240
|
-
backgroundColor: '#f6f8fa',
|
|
241
|
-
color: theme.palette.common.black,
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
// Apply horizontal striping for tables where first element is NOT a header (th)
|
|
245
|
-
'&:not(.MathJax) > table:not(:has(tr:first-child th:first-child)) tr': {
|
|
246
|
-
'&:nth-child(2n)': {
|
|
247
|
-
backgroundColor: '#f6f8fa',
|
|
248
|
-
color: theme.palette.common.black,
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
// align table content to left as per STAR requirement PD-3687
|
|
252
|
-
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
253
|
-
padding: '.6em 1em',
|
|
254
|
-
textAlign: 'left',
|
|
255
|
-
},
|
|
256
|
-
// added this to fix alignment of text in prompt imported from studio (PD-3423)
|
|
257
|
-
'&:not(.MathJax) > table td > p.kds-indent': {
|
|
258
|
-
textAlign: 'initial',
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
export default withStyles(styles)(PreviewPrompt);
|
|
262
|
+
export default PreviewPrompt;
|
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import * as icons from '@pie-lib/icons';
|
|
4
|
-
import Popover from '@material
|
|
5
|
-
import {
|
|
4
|
+
import Popover from '@mui/material/Popover';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
6
|
import Feedback from './feedback';
|
|
7
7
|
import debug from 'debug';
|
|
8
8
|
|
|
9
9
|
const log = debug('pie-libs:render-ui:response-indicators');
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
popperClose: {
|
|
23
|
-
cursor: 'pointer',
|
|
24
|
-
},
|
|
11
|
+
const ResponseIndicatorContainer = styled('div')(({ hasFeedback }) => ({
|
|
12
|
+
cursor: hasFeedback ? 'pointer' : 'default',
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
const StyledPopover = styled(Popover)({
|
|
16
|
+
cursor: 'pointer',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const PopoverPaper = styled('div')({
|
|
20
|
+
padding: '0',
|
|
21
|
+
borderRadius: '4px',
|
|
25
22
|
});
|
|
26
23
|
|
|
27
24
|
const BuildIndicator = (Icon, correctness) => {
|
|
28
|
-
class
|
|
25
|
+
class Indicator extends React.Component {
|
|
29
26
|
constructor(props) {
|
|
30
27
|
super(props);
|
|
31
28
|
this.state = {};
|
|
@@ -41,20 +38,17 @@ const BuildIndicator = (Icon, correctness) => {
|
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
render() {
|
|
44
|
-
const { feedback
|
|
41
|
+
const { feedback } = this.props;
|
|
45
42
|
const { anchorEl } = this.state;
|
|
46
43
|
return (
|
|
47
|
-
<
|
|
44
|
+
<ResponseIndicatorContainer hasFeedback={!!feedback}>
|
|
48
45
|
<span ref={(r) => (this.icon = r)} onClick={this.handlePopoverOpen}>
|
|
49
46
|
<Icon />
|
|
50
47
|
</span>
|
|
51
48
|
|
|
52
49
|
{feedback && (
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
classes={{
|
|
56
|
-
paper: classes.paper,
|
|
57
|
-
}}
|
|
50
|
+
<StyledPopover
|
|
51
|
+
PaperComponent={PopoverPaper}
|
|
58
52
|
open={!!anchorEl}
|
|
59
53
|
anchorEl={anchorEl}
|
|
60
54
|
anchorOrigin={{
|
|
@@ -68,19 +62,18 @@ const BuildIndicator = (Icon, correctness) => {
|
|
|
68
62
|
onClose={this.handlePopoverClose}
|
|
69
63
|
>
|
|
70
64
|
<Feedback feedback={feedback} correctness={correctness} />
|
|
71
|
-
</
|
|
65
|
+
</StyledPopover>
|
|
72
66
|
)}
|
|
73
|
-
</
|
|
67
|
+
</ResponseIndicatorContainer>
|
|
74
68
|
);
|
|
75
69
|
}
|
|
76
70
|
}
|
|
77
71
|
|
|
78
|
-
|
|
72
|
+
Indicator.propTypes = {
|
|
79
73
|
feedback: PropTypes.string,
|
|
80
|
-
classes: PropTypes.object.isRequired,
|
|
81
74
|
};
|
|
82
75
|
|
|
83
|
-
return
|
|
76
|
+
return Indicator;
|
|
84
77
|
};
|
|
85
78
|
|
|
86
79
|
export const Correct = BuildIndicator(icons.Correct, 'correct');
|
package/src/ui-layout.jsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { createTheme, ThemeProvider, StyledEngineProvider } from '@mui/material/styles';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
4
5
|
import classNames from 'classnames';
|
|
5
6
|
import AppendCSSRules from './append-css-rules';
|
|
6
7
|
|
|
7
|
-
const theme =
|
|
8
|
+
const theme = createTheme({
|
|
8
9
|
typography: {
|
|
9
|
-
useNextVariants: true,
|
|
10
10
|
fontFamily: 'inherit',
|
|
11
11
|
},
|
|
12
12
|
palette: {
|
|
@@ -14,57 +14,88 @@ const theme = createMuiTheme({
|
|
|
14
14
|
disabled: 'rgba(0, 0, 0, 0.54);',
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
components: {
|
|
18
18
|
MuiTypography: {
|
|
19
|
-
|
|
19
|
+
styleOverrides: {
|
|
20
|
+
root: { fontFamily: 'inherit' },
|
|
21
|
+
},
|
|
20
22
|
},
|
|
21
23
|
MuiRadio: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
styleOverrides: {
|
|
25
|
+
root: {
|
|
26
|
+
'&.Mui-checked': {
|
|
27
|
+
color: '#3f51b5 !important',
|
|
28
|
+
},
|
|
25
29
|
},
|
|
26
30
|
},
|
|
27
31
|
},
|
|
28
32
|
MuiCheckbox: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
styleOverrides: {
|
|
34
|
+
root: {
|
|
35
|
+
'&.Mui-checked': {
|
|
36
|
+
color: '#3f51b5 !important',
|
|
37
|
+
},
|
|
32
38
|
},
|
|
33
39
|
},
|
|
34
40
|
},
|
|
35
41
|
MuiTabs: {
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
styleOverrides: {
|
|
43
|
+
root: {
|
|
44
|
+
borderBottom: '1px solid #eee',
|
|
45
|
+
},
|
|
38
46
|
},
|
|
39
47
|
},
|
|
40
48
|
MuiSwitch: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
styleOverrides: {
|
|
50
|
+
root: {
|
|
51
|
+
'&.Mui-checked': {
|
|
52
|
+
color: '#3f51b5 !important',
|
|
53
|
+
'& + .MuiSwitch-track': {
|
|
54
|
+
backgroundColor: '#3f51b5 !important',
|
|
55
|
+
opacity: 0.5,
|
|
56
|
+
},
|
|
47
57
|
},
|
|
48
58
|
},
|
|
49
59
|
},
|
|
50
60
|
},
|
|
61
|
+
MuiButton: {
|
|
62
|
+
styleOverrides: {
|
|
63
|
+
contained: {
|
|
64
|
+
backgroundColor: '#e0e0e0',
|
|
65
|
+
color: '#000000',
|
|
66
|
+
'&:hover': {
|
|
67
|
+
backgroundColor: '#bdbdbd',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const StyledContainer = styled('div')({
|
|
76
|
+
// need this because some browsers set their own style on table
|
|
77
|
+
'& table, th, td': {
|
|
78
|
+
fontSize: 'inherit' /* Ensure table elements inherit font size */,
|
|
51
79
|
},
|
|
52
80
|
});
|
|
53
81
|
|
|
54
82
|
class UiLayout extends AppendCSSRules {
|
|
55
83
|
static propTypes = {
|
|
56
|
-
classes: PropTypes.object,
|
|
57
84
|
className: PropTypes.string,
|
|
58
85
|
children: PropTypes.array,
|
|
59
86
|
extraCSSRules: PropTypes.shape({
|
|
60
87
|
names: PropTypes.arrayOf(PropTypes.string),
|
|
61
88
|
rules: PropTypes.string,
|
|
62
89
|
}),
|
|
90
|
+
classes: PropTypes.shape({
|
|
91
|
+
extraCSSRules: PropTypes.string,
|
|
92
|
+
}),
|
|
63
93
|
fontSizeFactor: PropTypes.number,
|
|
64
94
|
};
|
|
65
95
|
|
|
66
96
|
static defaultProps = {
|
|
67
97
|
extraCSSRules: {},
|
|
98
|
+
classes: {},
|
|
68
99
|
fontSizeFactor: 1,
|
|
69
100
|
};
|
|
70
101
|
|
|
@@ -84,32 +115,21 @@ class UiLayout extends AppendCSSRules {
|
|
|
84
115
|
}
|
|
85
116
|
|
|
86
117
|
render() {
|
|
87
|
-
const { children, className,
|
|
118
|
+
const { children, className, fontSizeFactor, ...rest } = this.props;
|
|
88
119
|
|
|
89
|
-
const finalClass = classNames(className, classes.extraCSSRules, classes.uiLayoutContainer);
|
|
90
120
|
const { extraCSSRules, ...restProps } = rest;
|
|
91
121
|
const style = this.computeStyle(fontSizeFactor);
|
|
92
122
|
|
|
93
123
|
return (
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
{
|
|
97
|
-
|
|
98
|
-
|
|
124
|
+
<StyledEngineProvider injectFirst>
|
|
125
|
+
<ThemeProvider theme={theme}>
|
|
126
|
+
<StyledContainer className={className} {...restProps} {...(style && { style })}>
|
|
127
|
+
{children}
|
|
128
|
+
</StyledContainer>
|
|
129
|
+
</ThemeProvider>
|
|
130
|
+
</StyledEngineProvider>
|
|
99
131
|
);
|
|
100
132
|
}
|
|
101
133
|
}
|
|
102
134
|
|
|
103
|
-
|
|
104
|
-
extraCSSRules: {},
|
|
105
|
-
// need this because some browsers set their own style on table
|
|
106
|
-
uiLayoutContainer: {
|
|
107
|
-
'& table, th, td': {
|
|
108
|
-
fontSize: 'inherit' /* Ensure table elements inherit font size */,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const Styled = withStyles(styles)(UiLayout);
|
|
114
|
-
|
|
115
|
-
export default Styled;
|
|
135
|
+
export default UiLayout;
|
package/src/withUndoReset.jsx
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Button from '@material
|
|
4
|
-
import {
|
|
5
|
-
import Restore from '@
|
|
6
|
-
import Undo from '@
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
icon: {
|
|
19
|
-
width: '24px',
|
|
20
|
-
height: '24px',
|
|
21
|
-
color: 'gray',
|
|
22
|
-
marginRight: theme.spacing.unit,
|
|
23
|
-
},
|
|
24
|
-
buttonContainer: {
|
|
25
|
-
display: 'flex',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
marginLeft: theme.spacing.unit * 3,
|
|
28
|
-
marginRight: theme.spacing.unit * 3,
|
|
29
|
-
},
|
|
3
|
+
import Button from '@mui/material/Button';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import Restore from '@mui/icons-material/Restore';
|
|
6
|
+
import Undo from '@mui/icons-material/Undo';
|
|
7
|
+
|
|
8
|
+
const Wrapper = styled('div')({
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const ResetUndoContainer = styled('div')({
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'center',
|
|
30
17
|
});
|
|
31
18
|
|
|
19
|
+
const StyledIcon = styled('div')(({ theme }) => ({
|
|
20
|
+
width: '24px',
|
|
21
|
+
height: '24px',
|
|
22
|
+
color: 'gray',
|
|
23
|
+
marginRight: theme.spacing(1),
|
|
24
|
+
display: 'flex',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const StyledButton = styled(Button)(({ theme }) => ({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
marginLeft: theme.spacing(3),
|
|
32
|
+
marginRight: theme.spacing(3),
|
|
33
|
+
}));
|
|
34
|
+
|
|
32
35
|
/**
|
|
33
36
|
* HOC that adds undo and reset functionality for session values
|
|
34
37
|
*/
|
|
35
38
|
const withUndoReset = (WrappedComponent) => {
|
|
36
39
|
class WithUndoReset extends React.Component {
|
|
37
40
|
static propTypes = {
|
|
38
|
-
classes: PropTypes.object,
|
|
39
41
|
session: PropTypes.object,
|
|
40
42
|
onSessionChange: PropTypes.func,
|
|
41
43
|
};
|
|
@@ -81,36 +83,32 @@ const withUndoReset = (WrappedComponent) => {
|
|
|
81
83
|
};
|
|
82
84
|
|
|
83
85
|
render() {
|
|
84
|
-
const {
|
|
86
|
+
const { ...rest } = this.props;
|
|
85
87
|
const { changes, session } = this.state;
|
|
86
88
|
|
|
87
89
|
return (
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
>
|
|
104
|
-
<Restore className={classes.icon} /> Start Over
|
|
105
|
-
</Button>
|
|
106
|
-
</div>
|
|
90
|
+
<Wrapper>
|
|
91
|
+
<ResetUndoContainer>
|
|
92
|
+
<StyledButton color="primary" disabled={changes.length === 0} onClick={this.onUndo}>
|
|
93
|
+
<StyledIcon>
|
|
94
|
+
<Undo />
|
|
95
|
+
</StyledIcon>
|
|
96
|
+
Undo
|
|
97
|
+
</StyledButton>
|
|
98
|
+
<StyledButton color="primary" disabled={changes.length === 0} onClick={this.onReset}>
|
|
99
|
+
<StyledIcon>
|
|
100
|
+
<Restore />
|
|
101
|
+
</StyledIcon>
|
|
102
|
+
Start Over
|
|
103
|
+
</StyledButton>
|
|
104
|
+
</ResetUndoContainer>
|
|
107
105
|
<WrappedComponent {...rest} session={session} onSessionChange={this.onSessionChange} />
|
|
108
|
-
</
|
|
106
|
+
</Wrapper>
|
|
109
107
|
);
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
return
|
|
111
|
+
return WithUndoReset;
|
|
114
112
|
};
|
|
115
113
|
|
|
116
114
|
export default withUndoReset;
|