@pie-lib/mask-markup 1.12.16-next.4 → 1.12.17
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/choices/choice.js.map +1 -1
- package/lib/choices/index.js.map +1 -1
- package/lib/components/blank.js.map +1 -1
- package/lib/components/correct-input.js.map +1 -1
- package/lib/components/dropdown.js.map +1 -1
- package/lib/components/input.js.map +1 -1
- package/lib/constructed-response.js.map +1 -1
- package/lib/drag-in-the-blank.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/inline-dropdown.js.map +1 -1
- package/lib/mask.js.map +1 -1
- package/lib/serialization.js.map +1 -1
- package/lib/with-mask.js.map +1 -1
- package/package.json +6 -6
- package/src/choices/choice.jsx +13 -13
- package/src/choices/index.jsx +8 -10
- package/src/components/blank.jsx +30 -30
- package/src/components/correct-input.jsx +18 -18
- package/src/components/dropdown.jsx +27 -38
- package/src/components/input.jsx +3 -3
- package/src/constructed-response.jsx +2 -4
- package/src/drag-in-the-blank.jsx +8 -10
- package/src/index.js +1 -8
- package/src/inline-dropdown.jsx +2 -3
- package/src/mask.jsx +13 -13
- package/src/serialization.js +14 -14
- package/src/with-mask.jsx +2 -9
package/src/choices/index.jsx
CHANGED
|
@@ -7,11 +7,9 @@ export default class Choices extends React.Component {
|
|
|
7
7
|
static propTypes = {
|
|
8
8
|
disabled: PropTypes.bool,
|
|
9
9
|
duplicates: PropTypes.bool,
|
|
10
|
-
choices: PropTypes.arrayOf(
|
|
11
|
-
PropTypes.shape({ label: PropTypes.string, value: PropTypes.string })
|
|
12
|
-
),
|
|
10
|
+
choices: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.string, value: PropTypes.string })),
|
|
13
11
|
value: PropTypes.object,
|
|
14
|
-
choicePosition: PropTypes.string.isRequired
|
|
12
|
+
choicePosition: PropTypes.string.isRequired,
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
getStyleForWrapper = () => {
|
|
@@ -20,30 +18,30 @@ export default class Choices extends React.Component {
|
|
|
20
18
|
switch (choicePosition) {
|
|
21
19
|
case 'above':
|
|
22
20
|
return {
|
|
23
|
-
margin: '0 0 40px 0'
|
|
21
|
+
margin: '0 0 40px 0',
|
|
24
22
|
};
|
|
25
23
|
case 'below':
|
|
26
24
|
return {
|
|
27
|
-
margin: '40px 0 0 0'
|
|
25
|
+
margin: '40px 0 0 0',
|
|
28
26
|
};
|
|
29
27
|
case 'right':
|
|
30
28
|
return {
|
|
31
|
-
margin: '0 0 0 40px'
|
|
29
|
+
margin: '0 0 0 40px',
|
|
32
30
|
};
|
|
33
31
|
default:
|
|
34
32
|
return {
|
|
35
|
-
margin: '0 40px 0 0'
|
|
33
|
+
margin: '0 40px 0 0',
|
|
36
34
|
};
|
|
37
35
|
}
|
|
38
36
|
};
|
|
39
37
|
|
|
40
38
|
render() {
|
|
41
39
|
const { disabled, duplicates, choices, value } = this.props;
|
|
42
|
-
const filteredChoices = choices.filter(c => {
|
|
40
|
+
const filteredChoices = choices.filter((c) => {
|
|
43
41
|
if (duplicates === true) {
|
|
44
42
|
return true;
|
|
45
43
|
}
|
|
46
|
-
const foundChoice = findKey(value, v => v === c.id);
|
|
44
|
+
const foundChoice = findKey(value, (v) => v === c.id);
|
|
47
45
|
return foundChoice === undefined;
|
|
48
46
|
});
|
|
49
47
|
const elementStyle = this.getStyleForWrapper();
|
package/src/components/blank.jsx
CHANGED
|
@@ -14,7 +14,7 @@ export const DRAG_TYPE = 'MaskBlank';
|
|
|
14
14
|
const useStyles = withStyles(() => ({
|
|
15
15
|
content: {
|
|
16
16
|
border: `solid 0px ${color.primary()}`,
|
|
17
|
-
minWidth: '200px'
|
|
17
|
+
minWidth: '200px',
|
|
18
18
|
},
|
|
19
19
|
chip: {
|
|
20
20
|
minWidth: '90px',
|
|
@@ -22,34 +22,34 @@ const useStyles = withStyles(() => ({
|
|
|
22
22
|
minHeight: '32px',
|
|
23
23
|
height: 'auto',
|
|
24
24
|
maxWidth: '374px',
|
|
25
|
-
position: 'relative'
|
|
25
|
+
position: 'relative',
|
|
26
26
|
},
|
|
27
27
|
chipLabel: {
|
|
28
28
|
whiteSpace: 'pre-wrap',
|
|
29
29
|
'& img': {
|
|
30
30
|
display: 'block',
|
|
31
|
-
padding: '2px 0'
|
|
32
|
-
}
|
|
31
|
+
padding: '2px 0',
|
|
32
|
+
},
|
|
33
33
|
},
|
|
34
34
|
hidden: {
|
|
35
35
|
color: 'transparent',
|
|
36
|
-
opacity: 0
|
|
36
|
+
opacity: 0,
|
|
37
37
|
},
|
|
38
38
|
dragged: {
|
|
39
39
|
position: 'absolute',
|
|
40
40
|
left: 14,
|
|
41
|
-
maxWidth: '60px'
|
|
41
|
+
maxWidth: '60px',
|
|
42
42
|
},
|
|
43
43
|
correct: {
|
|
44
|
-
border: `solid 1px ${color.correct()}
|
|
44
|
+
border: `solid 1px ${color.correct()}`,
|
|
45
45
|
},
|
|
46
46
|
incorrect: {
|
|
47
|
-
border: `solid 1px ${color.incorrect()}
|
|
47
|
+
border: `solid 1px ${color.incorrect()}`,
|
|
48
48
|
},
|
|
49
49
|
over: {
|
|
50
50
|
whiteSpace: 'nowrap',
|
|
51
|
-
overflow: 'hidden'
|
|
52
|
-
}
|
|
51
|
+
overflow: 'hidden',
|
|
52
|
+
},
|
|
53
53
|
}));
|
|
54
54
|
|
|
55
55
|
export class BlankContent extends React.Component {
|
|
@@ -62,13 +62,13 @@ export class BlankContent extends React.Component {
|
|
|
62
62
|
isOver: PropTypes.bool,
|
|
63
63
|
dragItem: PropTypes.object,
|
|
64
64
|
correct: PropTypes.bool,
|
|
65
|
-
onChange: PropTypes.func
|
|
65
|
+
onChange: PropTypes.func,
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
constructor() {
|
|
69
69
|
super();
|
|
70
70
|
this.state = {
|
|
71
|
-
height: 0
|
|
71
|
+
height: 0,
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -80,20 +80,20 @@ export class BlankContent extends React.Component {
|
|
|
80
80
|
if (JSON.stringify(currentChoice) !== JSON.stringify(prevChoice)) {
|
|
81
81
|
if (!currentChoice) {
|
|
82
82
|
this.setState({
|
|
83
|
-
height: 0
|
|
83
|
+
height: 0,
|
|
84
84
|
});
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
setTimeout(() => {
|
|
88
88
|
this.setState({
|
|
89
|
-
height: this.spanRef.offsetHeight
|
|
89
|
+
height: this.spanRef.offsetHeight,
|
|
90
90
|
});
|
|
91
91
|
}, 300);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
addDraggableFalseAttributes(parent) {
|
|
96
|
-
parent.childNodes.forEach(elem => {
|
|
96
|
+
parent.childNodes.forEach((elem) => {
|
|
97
97
|
if (elem instanceof Element || elem instanceof HTMLDocument) {
|
|
98
98
|
elem.setAttribute('draggable', false);
|
|
99
99
|
}
|
|
@@ -107,7 +107,7 @@ export class BlankContent extends React.Component {
|
|
|
107
107
|
|
|
108
108
|
return (
|
|
109
109
|
<Chip
|
|
110
|
-
ref={ref => {
|
|
110
|
+
ref={(ref) => {
|
|
111
111
|
//eslint-disable-next-line
|
|
112
112
|
this.rootRef = ReactDOM.findDOMNode(ref);
|
|
113
113
|
}}
|
|
@@ -116,9 +116,9 @@ export class BlankContent extends React.Component {
|
|
|
116
116
|
<React.Fragment>
|
|
117
117
|
<span
|
|
118
118
|
className={classnames(classes.chipLabel, isOver && classes.over, {
|
|
119
|
-
[classes.hidden]: draggedLabel
|
|
119
|
+
[classes.hidden]: draggedLabel,
|
|
120
120
|
})}
|
|
121
|
-
ref={ref => {
|
|
121
|
+
ref={(ref) => {
|
|
122
122
|
if (ref) {
|
|
123
123
|
//eslint-disable-next-line
|
|
124
124
|
this.spanRef = ReactDOM.findDOMNode(ref);
|
|
@@ -132,7 +132,7 @@ export class BlankContent extends React.Component {
|
|
|
132
132
|
{draggedLabel && (
|
|
133
133
|
<span
|
|
134
134
|
className={classnames(classes.chipLabel, isOver && classes.over, classes.dragged)}
|
|
135
|
-
ref={ref => {
|
|
135
|
+
ref={(ref) => {
|
|
136
136
|
if (ref) {
|
|
137
137
|
//eslint-disable-next-line
|
|
138
138
|
this.spanRef = ReactDOM.findDOMNode(ref);
|
|
@@ -148,14 +148,14 @@ export class BlankContent extends React.Component {
|
|
|
148
148
|
}
|
|
149
149
|
className={classnames(classes.chip, isOver && classes.over, {
|
|
150
150
|
[classes.correct]: correct !== undefined && correct,
|
|
151
|
-
[classes.incorrect]: correct !== undefined && !correct
|
|
151
|
+
[classes.incorrect]: correct !== undefined && !correct,
|
|
152
152
|
})}
|
|
153
153
|
variant={disabled ? 'outlined' : undefined}
|
|
154
154
|
style={{
|
|
155
|
-
...(this.state.height ? { height: this.state.height } : {})
|
|
155
|
+
...(this.state.height ? { height: this.state.height } : {}),
|
|
156
156
|
}}
|
|
157
157
|
classes={{
|
|
158
|
-
label: isOver && classes.over
|
|
158
|
+
label: isOver && classes.over,
|
|
159
159
|
}}
|
|
160
160
|
/>
|
|
161
161
|
);
|
|
@@ -171,8 +171,8 @@ const connectedBlankContent = useStyles(({ connectDragSource, connectDropTarget,
|
|
|
171
171
|
connectDragSource(
|
|
172
172
|
<span className={classnames(classes.content, isOver && classes.over)}>
|
|
173
173
|
<StyledBlankContent {...props} />
|
|
174
|
-
</span
|
|
175
|
-
)
|
|
174
|
+
</span>,
|
|
175
|
+
),
|
|
176
176
|
);
|
|
177
177
|
});
|
|
178
178
|
|
|
@@ -187,20 +187,20 @@ const tileTarget = {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
return {
|
|
190
|
-
dropped: draggedItem.id !== props.id
|
|
190
|
+
dropped: draggedItem.id !== props.id,
|
|
191
191
|
};
|
|
192
192
|
},
|
|
193
193
|
canDrop(props, monitor) {
|
|
194
194
|
const draggedItem = monitor.getItem();
|
|
195
195
|
|
|
196
196
|
return draggedItem.instanceId === props.instanceId;
|
|
197
|
-
}
|
|
197
|
+
},
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
const DropTile = DropTarget(DRAG_TYPE, tileTarget, (connect, monitor) => ({
|
|
201
201
|
connectDropTarget: connect.dropTarget(),
|
|
202
202
|
isOver: monitor.isOver(),
|
|
203
|
-
dragItem: monitor.getItem()
|
|
203
|
+
dragItem: monitor.getItem(),
|
|
204
204
|
}))(connectedBlankContent);
|
|
205
205
|
|
|
206
206
|
const tileSource = {
|
|
@@ -212,7 +212,7 @@ const tileSource = {
|
|
|
212
212
|
id: props.id,
|
|
213
213
|
choice: props.choice,
|
|
214
214
|
instanceId: props.instanceId,
|
|
215
|
-
fromChoice: true
|
|
215
|
+
fromChoice: true,
|
|
216
216
|
};
|
|
217
217
|
},
|
|
218
218
|
endDrag(props, monitor) {
|
|
@@ -226,12 +226,12 @@ const tileSource = {
|
|
|
226
226
|
props.onChange(props.id, undefined);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
}
|
|
229
|
+
},
|
|
230
230
|
};
|
|
231
231
|
|
|
232
232
|
const DragDropTile = DragSource(DRAG_TYPE, tileSource, (connect, monitor) => ({
|
|
233
233
|
connectDragSource: connect.dragSource(),
|
|
234
|
-
isDragging: monitor.isDragging()
|
|
234
|
+
isDragging: monitor.isDragging(),
|
|
235
235
|
}))(DropTile);
|
|
236
236
|
|
|
237
237
|
export default DragDropTile;
|
|
@@ -4,8 +4,8 @@ import classnames from 'classnames';
|
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import { color } from '@pie-lib/render-ui';
|
|
6
6
|
|
|
7
|
-
const correctStyle = color => ({
|
|
8
|
-
borderColor: `${color} !important
|
|
7
|
+
const correctStyle = (color) => ({
|
|
8
|
+
borderColor: `${color} !important`,
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
export default withStyles(() => ({
|
|
@@ -18,37 +18,37 @@ export default withStyles(() => ({
|
|
|
18
18
|
padding: '10px 20px 10px 10px',
|
|
19
19
|
'&:disabled': {
|
|
20
20
|
opacity: 0.8,
|
|
21
|
-
cursor: 'not-allowed !important'
|
|
21
|
+
cursor: 'not-allowed !important',
|
|
22
22
|
},
|
|
23
23
|
'&:hover': {
|
|
24
24
|
borderColor: color.primary(),
|
|
25
25
|
'&:disabled': {
|
|
26
|
-
borderColor: 'initial'
|
|
27
|
-
}
|
|
26
|
+
borderColor: 'initial',
|
|
27
|
+
},
|
|
28
28
|
},
|
|
29
29
|
'&:focus': {
|
|
30
|
-
borderColor: color.primaryDark()
|
|
31
|
-
}
|
|
30
|
+
borderColor: color.primaryDark(),
|
|
31
|
+
},
|
|
32
32
|
},
|
|
33
33
|
crInput: {
|
|
34
|
-
padding: '8px !important'
|
|
34
|
+
padding: '8px !important',
|
|
35
35
|
},
|
|
36
36
|
correct: correctStyle(color.correct()),
|
|
37
37
|
incorrect: correctStyle(color.incorrect()),
|
|
38
38
|
box: {
|
|
39
|
-
fontSize: 'inherit'
|
|
39
|
+
fontSize: 'inherit',
|
|
40
40
|
},
|
|
41
41
|
outlinedInput: {
|
|
42
42
|
padding: '2px',
|
|
43
43
|
borderRadius: '4px',
|
|
44
44
|
'& fieldset': {
|
|
45
|
-
border: 0
|
|
46
|
-
}
|
|
45
|
+
border: 0,
|
|
46
|
+
},
|
|
47
47
|
},
|
|
48
48
|
notchedOutline: {
|
|
49
|
-
borderColor: color.correct()
|
|
50
|
-
}
|
|
51
|
-
}))(props => {
|
|
49
|
+
borderColor: color.correct(),
|
|
50
|
+
},
|
|
51
|
+
}))((props) => {
|
|
52
52
|
const {
|
|
53
53
|
correct,
|
|
54
54
|
charactersLimit,
|
|
@@ -65,7 +65,7 @@ export default withStyles(() => ({
|
|
|
65
65
|
|
|
66
66
|
if (width) {
|
|
67
67
|
inputProps.style = {
|
|
68
|
-
width: `${width + Math.round(width / 10) + 1}ch
|
|
68
|
+
width: `${width + Math.round(width / 10) + 1}ch`, // added some extra space for capital letters
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -74,14 +74,14 @@ export default withStyles(() => ({
|
|
|
74
74
|
className={classnames({
|
|
75
75
|
[classes.disabledInput]: disabled,
|
|
76
76
|
[classes.box]: isBox,
|
|
77
|
-
[classes.outlinedInput]: true
|
|
77
|
+
[classes.outlinedInput]: true,
|
|
78
78
|
})}
|
|
79
79
|
classes={{
|
|
80
80
|
input: classnames({
|
|
81
81
|
[classes.input]: true,
|
|
82
82
|
[classes[label]]: label,
|
|
83
|
-
[classes.crInput]: isConstructedResponse
|
|
84
|
-
})
|
|
83
|
+
[classes.crInput]: isConstructedResponse,
|
|
84
|
+
}),
|
|
85
85
|
}}
|
|
86
86
|
inputProps={inputProps}
|
|
87
87
|
labelWidth={0}
|
|
@@ -14,10 +14,8 @@ class Dropdown extends React.Component {
|
|
|
14
14
|
onChange: PropTypes.func,
|
|
15
15
|
classes: PropTypes.object,
|
|
16
16
|
correct: PropTypes.bool,
|
|
17
|
-
choices: PropTypes.arrayOf(
|
|
18
|
-
|
|
19
|
-
),
|
|
20
|
-
showCorrectAnswer: PropTypes.bool
|
|
17
|
+
choices: PropTypes.arrayOf(PropTypes.shape({ value: PropTypes.string, label: PropTypes.string })),
|
|
18
|
+
showCorrectAnswer: PropTypes.bool,
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
constructor(props) {
|
|
@@ -25,35 +23,26 @@ class Dropdown extends React.Component {
|
|
|
25
23
|
|
|
26
24
|
this.state = {
|
|
27
25
|
showCheckmark: false,
|
|
28
|
-
open: false
|
|
26
|
+
open: false,
|
|
29
27
|
};
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
showCheckmarkAndOpen = () => {
|
|
33
31
|
this.setState({
|
|
34
32
|
showCheckmark: true,
|
|
35
|
-
open: true
|
|
33
|
+
open: true,
|
|
36
34
|
});
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
hideCheckmarkAndClose = () => {
|
|
40
38
|
this.setState({
|
|
41
39
|
showCheckmark: false,
|
|
42
|
-
open: false
|
|
40
|
+
open: false,
|
|
43
41
|
});
|
|
44
42
|
};
|
|
45
43
|
|
|
46
44
|
render() {
|
|
47
|
-
const {
|
|
48
|
-
classes,
|
|
49
|
-
id,
|
|
50
|
-
correct,
|
|
51
|
-
disabled,
|
|
52
|
-
value,
|
|
53
|
-
onChange,
|
|
54
|
-
choices,
|
|
55
|
-
showCorrectAnswer
|
|
56
|
-
} = this.props;
|
|
45
|
+
const { classes, id, correct, disabled, value, onChange, choices, showCorrectAnswer } = this.props;
|
|
57
46
|
|
|
58
47
|
const { showCheckmark, open } = this.state;
|
|
59
48
|
|
|
@@ -63,7 +52,7 @@ class Dropdown extends React.Component {
|
|
|
63
52
|
root: classes.root,
|
|
64
53
|
icon: classes.icon,
|
|
65
54
|
selectMenu: classes.selectMenu,
|
|
66
|
-
select: classes.select
|
|
55
|
+
select: classes.select,
|
|
67
56
|
}}
|
|
68
57
|
disabled={disabled}
|
|
69
58
|
value={value || ''}
|
|
@@ -73,9 +62,9 @@ class Dropdown extends React.Component {
|
|
|
73
62
|
input={<CorrectInput correct={showCorrectAnswer || correct} />}
|
|
74
63
|
MenuProps={{
|
|
75
64
|
keepMounted: true,
|
|
76
|
-
disablePortal: true
|
|
65
|
+
disablePortal: true,
|
|
77
66
|
}}
|
|
78
|
-
onChange={e => {
|
|
67
|
+
onChange={(e) => {
|
|
79
68
|
onChange(id, e.target.value);
|
|
80
69
|
}}
|
|
81
70
|
>
|
|
@@ -88,7 +77,7 @@ class Dropdown extends React.Component {
|
|
|
88
77
|
<span
|
|
89
78
|
className={classes.label}
|
|
90
79
|
dangerouslySetInnerHTML={{
|
|
91
|
-
__html: c.label
|
|
80
|
+
__html: c.label,
|
|
92
81
|
}}
|
|
93
82
|
/>
|
|
94
83
|
{showCheckmark && (
|
|
@@ -115,57 +104,57 @@ const styles = () => ({
|
|
|
115
104
|
border: `1px solid ${color.text()}`,
|
|
116
105
|
borderRadius: '5px',
|
|
117
106
|
color: color.text(),
|
|
118
|
-
backgroundColor: color.background()
|
|
119
|
-
}
|
|
107
|
+
backgroundColor: color.background(),
|
|
108
|
+
},
|
|
120
109
|
},
|
|
121
110
|
select: {
|
|
122
111
|
'&:focus': {
|
|
123
|
-
borderRadius: '4px'
|
|
124
|
-
}
|
|
112
|
+
borderRadius: '4px',
|
|
113
|
+
},
|
|
125
114
|
},
|
|
126
115
|
selectMenu: {
|
|
127
116
|
backgroundColor: color.background(),
|
|
128
117
|
'&:hover': {
|
|
129
|
-
borderColor: 'initial'
|
|
118
|
+
borderColor: 'initial',
|
|
130
119
|
},
|
|
131
120
|
'&:focus': {
|
|
132
|
-
borderColor: 'initial'
|
|
133
|
-
}
|
|
121
|
+
borderColor: 'initial',
|
|
122
|
+
},
|
|
134
123
|
},
|
|
135
124
|
icon: {
|
|
136
|
-
color: color.text()
|
|
125
|
+
color: color.text(),
|
|
137
126
|
},
|
|
138
127
|
selected: {
|
|
139
128
|
color: `${color.text()} !important`,
|
|
140
129
|
backgroundColor: `${color.background()} !important`,
|
|
141
130
|
'&:hover': {
|
|
142
131
|
color: color.text(),
|
|
143
|
-
backgroundColor: `${color.secondaryLight()} !important
|
|
144
|
-
}
|
|
132
|
+
backgroundColor: `${color.secondaryLight()} !important`,
|
|
133
|
+
},
|
|
145
134
|
},
|
|
146
135
|
menuRoot: {
|
|
147
136
|
color: color.text(),
|
|
148
137
|
backgroundColor: color.background(),
|
|
149
138
|
'&:focus': {
|
|
150
139
|
color: color.text(),
|
|
151
|
-
backgroundColor: color.background()
|
|
140
|
+
backgroundColor: color.background(),
|
|
152
141
|
},
|
|
153
142
|
'&:hover': {
|
|
154
143
|
color: color.text(),
|
|
155
|
-
backgroundColor: color.secondaryLight()
|
|
144
|
+
backgroundColor: color.secondaryLight(),
|
|
156
145
|
},
|
|
157
146
|
boxSizing: 'border-box',
|
|
158
147
|
padding: '25px',
|
|
159
148
|
'&:first-of-type': {
|
|
160
|
-
borderRadius: '3px 3px 0 0'
|
|
149
|
+
borderRadius: '3px 3px 0 0',
|
|
161
150
|
},
|
|
162
151
|
'&:last-of-type': {
|
|
163
|
-
borderRadius: '0 0 3px 3px'
|
|
164
|
-
}
|
|
152
|
+
borderRadius: '0 0 3px 3px',
|
|
153
|
+
},
|
|
165
154
|
},
|
|
166
155
|
label: {
|
|
167
|
-
fontSize: 'max(1rem, 14px)'
|
|
168
|
-
}
|
|
156
|
+
fontSize: 'max(1rem, 14px)',
|
|
157
|
+
},
|
|
169
158
|
});
|
|
170
159
|
|
|
171
160
|
export default withStyles(styles)(Dropdown);
|
package/src/components/input.jsx
CHANGED
|
@@ -12,7 +12,7 @@ const Input = ({
|
|
|
12
12
|
onChange,
|
|
13
13
|
showCorrectAnswer,
|
|
14
14
|
spellCheck,
|
|
15
|
-
width
|
|
15
|
+
width,
|
|
16
16
|
}) => {
|
|
17
17
|
return (
|
|
18
18
|
<CorrectInput
|
|
@@ -25,7 +25,7 @@ const Input = ({
|
|
|
25
25
|
spellCheck={spellCheck}
|
|
26
26
|
isBox={true}
|
|
27
27
|
width={width}
|
|
28
|
-
onChange={e => {
|
|
28
|
+
onChange={(e) => {
|
|
29
29
|
onChange(id, e.target.value);
|
|
30
30
|
}}
|
|
31
31
|
/>
|
|
@@ -39,7 +39,7 @@ Input.propTypes = {
|
|
|
39
39
|
disabled: PropTypes.bool,
|
|
40
40
|
spellCheck: PropTypes.bool,
|
|
41
41
|
correct: PropTypes.bool,
|
|
42
|
-
showCorrectAnswer: PropTypes.bool
|
|
42
|
+
showCorrectAnswer: PropTypes.bool,
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export default Input;
|
|
@@ -2,16 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import Input from './components/input';
|
|
3
3
|
import { withMask } from './with-mask';
|
|
4
4
|
|
|
5
|
-
export default withMask('input', props => (node, data, onChange) => {
|
|
5
|
+
export default withMask('input', (props) => (node, data, onChange) => {
|
|
6
6
|
const dataset = node.data ? node.data.dataset || {} : {};
|
|
7
7
|
if (dataset.component === 'input') {
|
|
8
8
|
const { adjustedLimit, disabled, feedback, showCorrectAnswer, maxLength, spellCheck } = props;
|
|
9
9
|
|
|
10
10
|
// the first answer is the correct one
|
|
11
11
|
const correctAnswer = ((props.choices && dataset && props.choices[dataset.id]) || [])[0];
|
|
12
|
-
const finalValue = showCorrectAnswer
|
|
13
|
-
? correctAnswer && correctAnswer.label
|
|
14
|
-
: data[dataset.id] || '';
|
|
12
|
+
const finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';
|
|
15
13
|
const width = maxLength && maxLength[dataset.id];
|
|
16
14
|
|
|
17
15
|
return (
|
|
@@ -5,12 +5,12 @@ import Choices from './choices';
|
|
|
5
5
|
import Blank from './components/blank';
|
|
6
6
|
import { withMask } from './with-mask';
|
|
7
7
|
|
|
8
|
-
const Masked = withMask('blank', props => (node, data, onChange) => {
|
|
8
|
+
const Masked = withMask('blank', (props) => (node, data, onChange) => {
|
|
9
9
|
const dataset = node.data ? node.data.dataset || {} : {};
|
|
10
10
|
if (dataset.component === 'blank') {
|
|
11
11
|
const { disabled, duplicates, correctResponse, feedback, showCorrectAnswer } = props;
|
|
12
12
|
const choiceId = showCorrectAnswer ? correctResponse[dataset.id] : data[dataset.id];
|
|
13
|
-
const choice = choiceId && props.choices.find(c => c.id === choiceId);
|
|
13
|
+
const choice = choiceId && props.choices.find((c) => c.id === choiceId);
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<Blank
|
|
@@ -31,16 +31,14 @@ export default class DragInTheBlank extends React.Component {
|
|
|
31
31
|
markup: PropTypes.string,
|
|
32
32
|
layout: PropTypes.object,
|
|
33
33
|
choicesPosition: PropTypes.string,
|
|
34
|
-
choices: PropTypes.arrayOf(
|
|
35
|
-
PropTypes.shape({ label: PropTypes.string, value: PropTypes.string })
|
|
36
|
-
),
|
|
34
|
+
choices: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.string, value: PropTypes.string })),
|
|
37
35
|
value: PropTypes.object,
|
|
38
36
|
onChange: PropTypes.func,
|
|
39
37
|
duplicates: PropTypes.bool,
|
|
40
38
|
disabled: PropTypes.bool,
|
|
41
39
|
feedback: PropTypes.object,
|
|
42
40
|
correctResponse: PropTypes.object,
|
|
43
|
-
showCorrectAnswer: PropTypes.bool
|
|
41
|
+
showCorrectAnswer: PropTypes.bool,
|
|
44
42
|
};
|
|
45
43
|
|
|
46
44
|
componentWillReceiveProps() {
|
|
@@ -53,7 +51,7 @@ export default class DragInTheBlank extends React.Component {
|
|
|
53
51
|
renderMath(this.rootRef);
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
getPositionDirection = choicePosition => {
|
|
54
|
+
getPositionDirection = (choicePosition) => {
|
|
57
55
|
let flexDirection;
|
|
58
56
|
|
|
59
57
|
switch (choicePosition) {
|
|
@@ -87,17 +85,17 @@ export default class DragInTheBlank extends React.Component {
|
|
|
87
85
|
correctResponse,
|
|
88
86
|
disabled,
|
|
89
87
|
feedback,
|
|
90
|
-
showCorrectAnswer
|
|
88
|
+
showCorrectAnswer,
|
|
91
89
|
} = this.props;
|
|
92
90
|
|
|
93
91
|
const choicePosition = choicesPosition || 'below';
|
|
94
92
|
const style = {
|
|
95
93
|
display: 'flex',
|
|
96
|
-
flexDirection: this.getPositionDirection(choicePosition)
|
|
94
|
+
flexDirection: this.getPositionDirection(choicePosition),
|
|
97
95
|
};
|
|
98
96
|
|
|
99
97
|
return (
|
|
100
|
-
<div ref={ref => ref && (this.rootRef = ref)} style={style}>
|
|
98
|
+
<div ref={(ref) => ref && (this.rootRef = ref)} style={style}>
|
|
101
99
|
<Choices
|
|
102
100
|
choicePosition={choicePosition}
|
|
103
101
|
duplicates={duplicates}
|
package/src/index.js
CHANGED
|
@@ -4,11 +4,4 @@ import ConstructedResponse from './constructed-response';
|
|
|
4
4
|
import InlineDropdown from './inline-dropdown';
|
|
5
5
|
import componentize from './componentize';
|
|
6
6
|
|
|
7
|
-
export {
|
|
8
|
-
withMask,
|
|
9
|
-
buildLayoutFromMarkup,
|
|
10
|
-
DragInTheBlank,
|
|
11
|
-
ConstructedResponse,
|
|
12
|
-
InlineDropdown,
|
|
13
|
-
componentize
|
|
14
|
-
};
|
|
7
|
+
export { withMask, buildLayoutFromMarkup, DragInTheBlank, ConstructedResponse, InlineDropdown, componentize };
|
package/src/inline-dropdown.jsx
CHANGED
|
@@ -2,12 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import Dropdown from './components/dropdown';
|
|
3
3
|
import { withMask } from './with-mask';
|
|
4
4
|
|
|
5
|
-
export default withMask('dropdown', props => (node, data, onChange) => {
|
|
5
|
+
export default withMask('dropdown', (props) => (node, data, onChange) => {
|
|
6
6
|
const dataset = node.data ? node.data.dataset || {} : {};
|
|
7
7
|
if (dataset.component === 'dropdown') {
|
|
8
8
|
const { choices, disabled, feedback, showCorrectAnswer } = props;
|
|
9
|
-
const correctAnswer =
|
|
10
|
-
choices && choices[dataset.id] && choices[dataset.id].find(c => c.correct);
|
|
9
|
+
const correctAnswer = choices && choices[dataset.id] && choices[dataset.id].find((c) => c.correct);
|
|
11
10
|
const finalChoice = showCorrectAnswer ? correctAnswer && correctAnswer.value : data[dataset.id];
|
|
12
11
|
|
|
13
12
|
return (
|