@pie-element/drawing-response 10.3.4-next.3 → 11.0.0-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 +0 -11
- package/configure/CHANGELOG.md +0 -11
- package/configure/lib/button.js +23 -47
- package/configure/lib/button.js.map +1 -1
- package/configure/lib/defaults.js +2 -3
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/image-container.js +238 -327
- package/configure/lib/image-container.js.map +1 -1
- package/configure/lib/index.js +115 -182
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +195 -261
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +9 -7
- package/configure/src/__tests__/image-container.test.jsx +101 -37
- package/configure/src/__tests__/index.test.js +27 -5
- package/configure/src/__tests__/root.test.jsx +37 -21
- package/configure/src/button.jsx +14 -24
- package/configure/src/image-container.jsx +73 -77
- package/configure/src/index.js +12 -2
- package/configure/src/root.jsx +25 -26
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +39 -65
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/lib/drawing-response/button.js +35 -60
- package/lib/drawing-response/button.js.map +1 -1
- package/lib/drawing-response/constants.js +2 -3
- package/lib/drawing-response/constants.js.map +1 -1
- package/lib/drawing-response/container.js +270 -351
- package/lib/drawing-response/container.js.map +1 -1
- package/lib/drawing-response/drawable-circle.js +65 -104
- package/lib/drawing-response/drawable-circle.js.map +1 -1
- package/lib/drawing-response/drawable-eraser.js +50 -86
- package/lib/drawing-response/drawable-eraser.js.map +1 -1
- package/lib/drawing-response/drawable-free-path.js +56 -97
- package/lib/drawing-response/drawable-free-path.js.map +1 -1
- package/lib/drawing-response/drawable-helper.js +16 -28
- package/lib/drawing-response/drawable-helper.js.map +1 -1
- package/lib/drawing-response/drawable-image.js +30 -49
- package/lib/drawing-response/drawable-image.js.map +1 -1
- package/lib/drawing-response/drawable-line.js +60 -99
- package/lib/drawing-response/drawable-line.js.map +1 -1
- package/lib/drawing-response/drawable-main.js +273 -345
- package/lib/drawing-response/drawable-main.js.map +1 -1
- package/lib/drawing-response/drawable-palette.js +123 -166
- package/lib/drawing-response/drawable-palette.js.map +1 -1
- package/lib/drawing-response/drawable-rectangle.js +65 -104
- package/lib/drawing-response/drawable-rectangle.js.map +1 -1
- package/lib/drawing-response/drawable-text.js +201 -313
- package/lib/drawing-response/drawable-text.js.map +1 -1
- package/lib/drawing-response/drawable-transformer.js +36 -79
- package/lib/drawing-response/drawable-transformer.js.map +1 -1
- package/lib/drawing-response/factory.js +6 -19
- package/lib/drawing-response/factory.js.map +1 -1
- package/lib/drawing-response/icon.js +8 -24
- package/lib/drawing-response/icon.js.map +1 -1
- package/lib/drawing-response/index.js +74 -116
- package/lib/drawing-response/index.js.map +1 -1
- package/lib/index.js +51 -102
- package/lib/index.js.map +1 -1
- package/package.json +13 -12
- package/src/__tests__/drawing-index-test.jsx +90 -27
- package/src/drawing-response/__tests__/container.test.jsx +56 -36
- package/src/drawing-response/__tests__/drawing-main.test.jsx +158 -139
- package/src/drawing-response/button.jsx +23 -34
- package/src/drawing-response/container.jsx +39 -40
- package/src/drawing-response/drawable-image.jsx +17 -20
- package/src/drawing-response/drawable-main.jsx +67 -60
- package/src/drawing-response/drawable-palette.jsx +48 -54
- package/src/drawing-response/drawable-text.jsx +26 -38
- package/src/drawing-response/index.jsx +21 -20
- package/src/index.js +17 -2
- package/configure/src/__tests__/__snapshots__/image-container.test.jsx.snap +0 -45
- package/configure/src/__tests__/__snapshots__/root.test.jsx.snap +0 -185
- package/esm/configure.js +0 -16151
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -814
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -54130
- package/esm/element.js.map +0 -1
- package/esm/package.json +0 -3
- package/src/__tests__/__snapshots__/drawing-index-test.jsx.snap +0 -23
- package/src/drawing-response/__tests__/__snapshots__/container.test.jsx.snap +0 -396
- package/src/drawing-response/__tests__/__snapshots__/drawing-main.test.jsx.snap +0 -247
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { color, Collapsible, PreviewPrompt, UiLayout } from '@pie-lib/render-ui';
|
|
4
|
-
import {
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
5
|
|
|
6
6
|
import Container from './container';
|
|
7
7
|
|
|
8
|
+
const StyledUiLayout = styled(UiLayout)({
|
|
9
|
+
color: color.text(),
|
|
10
|
+
backgroundColor: color.background(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const StyledCollapsible = styled(Collapsible)(({ theme }) => ({
|
|
14
|
+
marginBottom: theme.spacing(2),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
const ErrorDiv = styled('div')({
|
|
18
|
+
color: color.text(),
|
|
19
|
+
backgroundColor: color.background(),
|
|
20
|
+
});
|
|
21
|
+
|
|
8
22
|
class DrawingResponseComponent extends React.Component {
|
|
9
23
|
constructor(props) {
|
|
10
24
|
super(props);
|
|
@@ -33,25 +47,23 @@ class DrawingResponseComponent extends React.Component {
|
|
|
33
47
|
},
|
|
34
48
|
session,
|
|
35
49
|
onSessionChange,
|
|
36
|
-
classes,
|
|
37
50
|
} = this.props;
|
|
38
51
|
const { hasError, errorMessage } = this.state;
|
|
39
52
|
const isEvaluateMode = mode === 'evaluate';
|
|
40
53
|
|
|
41
54
|
return hasError ? (
|
|
42
|
-
<
|
|
55
|
+
<ErrorDiv>An error occured: {errorMessage}</ErrorDiv>
|
|
43
56
|
) : (
|
|
44
|
-
<
|
|
57
|
+
<StyledUiLayout extraCSSRules={extraCSSRules}>
|
|
45
58
|
{teacherInstructions && (
|
|
46
|
-
<
|
|
47
|
-
className={classes.collapsible}
|
|
59
|
+
<StyledCollapsible
|
|
48
60
|
labels={{
|
|
49
61
|
hidden: 'Show Teacher Instructions',
|
|
50
62
|
visible: 'Hide Teacher Instructions',
|
|
51
63
|
}}
|
|
52
64
|
>
|
|
53
65
|
<PreviewPrompt prompt={teacherInstructions} />
|
|
54
|
-
</
|
|
66
|
+
</StyledCollapsible>
|
|
55
67
|
)}
|
|
56
68
|
|
|
57
69
|
{prompt && <PreviewPrompt tagName="span" prompt={prompt} />}
|
|
@@ -66,26 +78,15 @@ class DrawingResponseComponent extends React.Component {
|
|
|
66
78
|
disabled={disabled}
|
|
67
79
|
language={language}
|
|
68
80
|
/>
|
|
69
|
-
</
|
|
81
|
+
</StyledUiLayout>
|
|
70
82
|
);
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
DrawingResponseComponent.propTypes = {
|
|
75
|
-
classes: PropTypes.object,
|
|
76
87
|
model: PropTypes.object.isRequired,
|
|
77
88
|
onSessionChange: PropTypes.func.isRequired,
|
|
78
89
|
session: PropTypes.object.isRequired,
|
|
79
90
|
};
|
|
80
91
|
|
|
81
|
-
|
|
82
|
-
main: {
|
|
83
|
-
color: color.text(),
|
|
84
|
-
backgroundColor: color.background(),
|
|
85
|
-
},
|
|
86
|
-
collapsible: {
|
|
87
|
-
marginBottom: theme.spacing.unit * 2,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
export default withStyles(styles)(DrawingResponseComponent);
|
|
92
|
+
export default DrawingResponseComponent;
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import isEmpty from 'lodash/isEmpty';
|
|
4
4
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
5
5
|
import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';
|
|
@@ -7,6 +7,11 @@ import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-ev
|
|
|
7
7
|
import DrawingResponseComponent from './drawing-response';
|
|
8
8
|
|
|
9
9
|
export default class DrawingResponse extends HTMLElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this._root = null;
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
set model(m) {
|
|
11
16
|
this._model = m;
|
|
12
17
|
|
|
@@ -49,9 +54,19 @@ export default class DrawingResponse extends HTMLElement {
|
|
|
49
54
|
onSessionChange: this.sessionChanged,
|
|
50
55
|
});
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
if (!this._root) {
|
|
58
|
+
this._root = createRoot(this);
|
|
59
|
+
}
|
|
60
|
+
this._root.render(el);
|
|
61
|
+
queueMicrotask(() => {
|
|
53
62
|
renderMath(this);
|
|
54
63
|
});
|
|
55
64
|
}
|
|
56
65
|
}
|
|
66
|
+
|
|
67
|
+
disconnectedCallback() {
|
|
68
|
+
if (this._root) {
|
|
69
|
+
this._root.unmount();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
57
72
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`ImageContainer snapshot renders 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
className="undefined "
|
|
7
|
-
onDragExit={[Function]}
|
|
8
|
-
onDragLeave={[Function]}
|
|
9
|
-
onDragOver={[Function]}
|
|
10
|
-
onDrop={[Function]}
|
|
11
|
-
>
|
|
12
|
-
<div>
|
|
13
|
-
<div>
|
|
14
|
-
<WithStyles(RawButton)
|
|
15
|
-
label="Replace Image"
|
|
16
|
-
onClick={[Function]}
|
|
17
|
-
/>
|
|
18
|
-
<input
|
|
19
|
-
accept="image/*"
|
|
20
|
-
onChange={[Function]}
|
|
21
|
-
type="file"
|
|
22
|
-
/>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
<div>
|
|
26
|
-
<div>
|
|
27
|
-
<img
|
|
28
|
-
alt=""
|
|
29
|
-
height="auto"
|
|
30
|
-
onLoad={[Function]}
|
|
31
|
-
src="url"
|
|
32
|
-
style={
|
|
33
|
-
Object {
|
|
34
|
-
"maxHeight": "auto",
|
|
35
|
-
"maxWidth": "100%",
|
|
36
|
-
"width": undefined,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/>
|
|
40
|
-
<div />
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
`;
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Root snapshot renders 1`] = `
|
|
4
|
-
<ConfigLayout
|
|
5
|
-
dimensions={Object {}}
|
|
6
|
-
hideSettings={false}
|
|
7
|
-
settings={
|
|
8
|
-
<Panel
|
|
9
|
-
configuration={
|
|
10
|
-
Object {
|
|
11
|
-
"backgroundImage": Object {
|
|
12
|
-
"label": "Background Image",
|
|
13
|
-
"settings": true,
|
|
14
|
-
},
|
|
15
|
-
"baseInputConfiguration": Object {
|
|
16
|
-
"audio": Object {
|
|
17
|
-
"disabled": false,
|
|
18
|
-
},
|
|
19
|
-
"image": Object {
|
|
20
|
-
"disabled": false,
|
|
21
|
-
},
|
|
22
|
-
"separateParagraphs": Object {
|
|
23
|
-
"disabled": true,
|
|
24
|
-
},
|
|
25
|
-
"showParagraphs": Object {
|
|
26
|
-
"disabled": false,
|
|
27
|
-
},
|
|
28
|
-
"textAlign": Object {
|
|
29
|
-
"disabled": true,
|
|
30
|
-
},
|
|
31
|
-
"video": Object {
|
|
32
|
-
"disabled": false,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
"language": Object {
|
|
36
|
-
"enabled": false,
|
|
37
|
-
"label": "Specify Language",
|
|
38
|
-
"settings": false,
|
|
39
|
-
},
|
|
40
|
-
"languageChoices": Object {
|
|
41
|
-
"label": "Language Choices",
|
|
42
|
-
"options": Array [],
|
|
43
|
-
},
|
|
44
|
-
"mathMlOptions": Object {
|
|
45
|
-
"mmlEditing": false,
|
|
46
|
-
"mmlOutput": false,
|
|
47
|
-
},
|
|
48
|
-
"maxImageHeight": Object {
|
|
49
|
-
"prompt": 300,
|
|
50
|
-
"teacherInstructions": 300,
|
|
51
|
-
},
|
|
52
|
-
"maxImageWidth": Object {
|
|
53
|
-
"prompt": 300,
|
|
54
|
-
"teacherInstructions": 300,
|
|
55
|
-
},
|
|
56
|
-
"prompt": Object {
|
|
57
|
-
"inputConfiguration": Object {
|
|
58
|
-
"audio": Object {
|
|
59
|
-
"disabled": false,
|
|
60
|
-
},
|
|
61
|
-
"image": Object {
|
|
62
|
-
"disabled": false,
|
|
63
|
-
},
|
|
64
|
-
"video": Object {
|
|
65
|
-
"disabled": false,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
"label": "Prompt",
|
|
69
|
-
"required": false,
|
|
70
|
-
"settings": true,
|
|
71
|
-
},
|
|
72
|
-
"settingsPanelDisabled": false,
|
|
73
|
-
"spellCheck": Object {
|
|
74
|
-
"enabled": true,
|
|
75
|
-
"label": "Spellcheck",
|
|
76
|
-
"settings": false,
|
|
77
|
-
},
|
|
78
|
-
"teacherInstructions": Object {
|
|
79
|
-
"inputConfiguration": Object {
|
|
80
|
-
"audio": Object {
|
|
81
|
-
"disabled": false,
|
|
82
|
-
},
|
|
83
|
-
"image": Object {
|
|
84
|
-
"disabled": false,
|
|
85
|
-
},
|
|
86
|
-
"video": Object {
|
|
87
|
-
"disabled": false,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
"label": "Teacher Instructions",
|
|
91
|
-
"required": false,
|
|
92
|
-
"settings": true,
|
|
93
|
-
},
|
|
94
|
-
"withRubric": Object {
|
|
95
|
-
"label": "Add Rubric",
|
|
96
|
-
"settings": false,
|
|
97
|
-
},
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
groups={
|
|
101
|
-
Object {
|
|
102
|
-
"Properties": Object {
|
|
103
|
-
"rubricEnabled": false,
|
|
104
|
-
"spellCheckEnabled": false,
|
|
105
|
-
"teacherInstructionsEnabled": undefined,
|
|
106
|
-
},
|
|
107
|
-
"Settings": Object {
|
|
108
|
-
"backgroundImageEnabled": undefined,
|
|
109
|
-
"language": false,
|
|
110
|
-
"language.enabled": false,
|
|
111
|
-
"promptEnabled": undefined,
|
|
112
|
-
},
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
model={
|
|
116
|
-
Object {
|
|
117
|
-
"imageDimensions": Object {
|
|
118
|
-
"height": 100,
|
|
119
|
-
"width": 100,
|
|
120
|
-
},
|
|
121
|
-
"imageUrl": "",
|
|
122
|
-
"prompt": "Test Prompt",
|
|
123
|
-
"promptEnabled": true,
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
onChangeConfiguration={[MockFunction]}
|
|
127
|
-
onChangeModel={[MockFunction]}
|
|
128
|
-
/>
|
|
129
|
-
}
|
|
130
|
-
>
|
|
131
|
-
<Component
|
|
132
|
-
label="Item Stem"
|
|
133
|
-
>
|
|
134
|
-
<EditableHtml
|
|
135
|
-
languageCharactersProps={
|
|
136
|
-
Array [
|
|
137
|
-
Object {
|
|
138
|
-
"language": "spanish",
|
|
139
|
-
},
|
|
140
|
-
Object {
|
|
141
|
-
"language": "special",
|
|
142
|
-
},
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
markup="Test Prompt"
|
|
146
|
-
mathMlOptions={
|
|
147
|
-
Object {
|
|
148
|
-
"mmlEditing": false,
|
|
149
|
-
"mmlOutput": false,
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
maxImageHeight={300}
|
|
153
|
-
maxImageWidth={300}
|
|
154
|
-
onChange={[Function]}
|
|
155
|
-
pluginProps={
|
|
156
|
-
Object {
|
|
157
|
-
"audio": Object {
|
|
158
|
-
"disabled": false,
|
|
159
|
-
},
|
|
160
|
-
"image": Object {
|
|
161
|
-
"disabled": false,
|
|
162
|
-
},
|
|
163
|
-
"separateParagraphs": Object {
|
|
164
|
-
"disabled": true,
|
|
165
|
-
},
|
|
166
|
-
"showParagraphs": Object {
|
|
167
|
-
"disabled": false,
|
|
168
|
-
},
|
|
169
|
-
"textAlign": Object {
|
|
170
|
-
"disabled": true,
|
|
171
|
-
},
|
|
172
|
-
"video": Object {
|
|
173
|
-
"disabled": false,
|
|
174
|
-
},
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
toolbarOpts={
|
|
178
|
-
Object {
|
|
179
|
-
"position": "bottom",
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
/>
|
|
183
|
-
</Component>
|
|
184
|
-
</ConfigLayout>
|
|
185
|
-
`;
|