@pie-element/drawing-response 6.4.1-next.47 → 6.4.1-next.62
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/configure/lib/defaults.js +9 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/root.js +9 -1
- package/configure/lib/root.js.map +1 -1
- package/configure/src/__tests__/__snapshots__/root.test.jsx.snap +11 -0
- package/configure/src/defaults.js +9 -0
- package/configure/src/root.jsx +5 -0
- package/controller/lib/index.js +4 -2
- package/controller/lib/index.js.map +1 -1
- package/controller/src/index.js +2 -1
- package/docs/config-schema.json +80 -0
- package/docs/config-schema.json.md +53 -1
- package/docs/pie-schema.json +25 -0
- package/docs/pie-schema.json.md +17 -0
- package/lib/drawing-response/container.js +56 -5
- package/lib/drawing-response/container.js.map +1 -1
- package/lib/drawing-response/drawable-main.js +15 -5
- package/lib/drawing-response/drawable-main.js.map +1 -1
- package/lib/drawing-response/drawable-palette.js +14 -5
- package/lib/drawing-response/drawable-palette.js.map +1 -1
- package/lib/drawing-response/drawable-text.js +8 -2
- package/lib/drawing-response/drawable-text.js.map +1 -1
- package/lib/drawing-response/index.js +4 -3
- package/lib/drawing-response/index.js.map +1 -1
- package/package.json +3 -2
- package/src/drawing-response/__tests__/__snapshots__/container.test.jsx.snap +30 -30
- package/src/drawing-response/container.jsx +36 -3
- package/src/drawing-response/drawable-main.jsx +8 -4
- package/src/drawing-response/drawable-palette.jsx +7 -3
- package/src/drawing-response/drawable-text.jsx +4 -2
- package/src/drawing-response/index.jsx +11 -1
|
@@ -7,47 +7,47 @@ exports[`Container snapshot renders 1`] = `
|
|
|
7
7
|
fillList={
|
|
8
8
|
Array [
|
|
9
9
|
Object {
|
|
10
|
-
"label": "
|
|
10
|
+
"label": "No fill",
|
|
11
11
|
"value": "transparent",
|
|
12
12
|
},
|
|
13
13
|
Object {
|
|
14
|
-
"label": "
|
|
14
|
+
"label": "Light blue",
|
|
15
15
|
"value": "lightblue",
|
|
16
16
|
},
|
|
17
17
|
Object {
|
|
18
|
-
"label": "
|
|
18
|
+
"label": "Light yellow",
|
|
19
19
|
"value": "lightyellow",
|
|
20
20
|
},
|
|
21
21
|
Object {
|
|
22
|
-
"label": "
|
|
22
|
+
"label": "Red",
|
|
23
23
|
"value": "red",
|
|
24
24
|
},
|
|
25
25
|
Object {
|
|
26
|
-
"label": "
|
|
26
|
+
"label": "Orange",
|
|
27
27
|
"value": "orange",
|
|
28
28
|
},
|
|
29
29
|
Object {
|
|
30
|
-
"label": "
|
|
30
|
+
"label": "Yellow",
|
|
31
31
|
"value": "yellow",
|
|
32
32
|
},
|
|
33
33
|
Object {
|
|
34
|
-
"label": "
|
|
34
|
+
"label": "Violet",
|
|
35
35
|
"value": "violet",
|
|
36
36
|
},
|
|
37
37
|
Object {
|
|
38
|
-
"label": "
|
|
38
|
+
"label": "Blue",
|
|
39
39
|
"value": "blue",
|
|
40
40
|
},
|
|
41
41
|
Object {
|
|
42
|
-
"label": "
|
|
42
|
+
"label": "Green",
|
|
43
43
|
"value": "green",
|
|
44
44
|
},
|
|
45
45
|
Object {
|
|
46
|
-
"label": "
|
|
46
|
+
"label": "White",
|
|
47
47
|
"value": "white",
|
|
48
48
|
},
|
|
49
49
|
Object {
|
|
50
|
-
"label": "
|
|
50
|
+
"label": "Black",
|
|
51
51
|
"value": "black",
|
|
52
52
|
},
|
|
53
53
|
]
|
|
@@ -59,72 +59,72 @@ exports[`Container snapshot renders 1`] = `
|
|
|
59
59
|
outlineList={
|
|
60
60
|
Array [
|
|
61
61
|
Object {
|
|
62
|
-
"label": "
|
|
62
|
+
"label": "Red",
|
|
63
63
|
"value": "red",
|
|
64
64
|
},
|
|
65
65
|
Object {
|
|
66
|
-
"label": "
|
|
66
|
+
"label": "Orange",
|
|
67
67
|
"value": "orange",
|
|
68
68
|
},
|
|
69
69
|
Object {
|
|
70
|
-
"label": "
|
|
70
|
+
"label": "Yellow",
|
|
71
71
|
"value": "yellow",
|
|
72
72
|
},
|
|
73
73
|
Object {
|
|
74
|
-
"label": "
|
|
74
|
+
"label": "Violet",
|
|
75
75
|
"value": "violet",
|
|
76
76
|
},
|
|
77
77
|
Object {
|
|
78
|
-
"label": "
|
|
78
|
+
"label": "Blue",
|
|
79
79
|
"value": "blue",
|
|
80
80
|
},
|
|
81
81
|
Object {
|
|
82
|
-
"label": "
|
|
82
|
+
"label": "Green",
|
|
83
83
|
"value": "green",
|
|
84
84
|
},
|
|
85
85
|
Object {
|
|
86
|
-
"label": "
|
|
86
|
+
"label": "White",
|
|
87
87
|
"value": "white",
|
|
88
88
|
},
|
|
89
89
|
Object {
|
|
90
|
-
"label": "
|
|
90
|
+
"label": "Black",
|
|
91
91
|
"value": "black",
|
|
92
92
|
},
|
|
93
93
|
]
|
|
94
94
|
}
|
|
95
|
-
paintColor="
|
|
95
|
+
paintColor="Red"
|
|
96
96
|
paintList={
|
|
97
97
|
Array [
|
|
98
98
|
Object {
|
|
99
|
-
"label": "
|
|
99
|
+
"label": "Red",
|
|
100
100
|
"value": "red",
|
|
101
101
|
},
|
|
102
102
|
Object {
|
|
103
|
-
"label": "
|
|
103
|
+
"label": "Orange",
|
|
104
104
|
"value": "orange",
|
|
105
105
|
},
|
|
106
106
|
Object {
|
|
107
|
-
"label": "
|
|
107
|
+
"label": "Yellow",
|
|
108
108
|
"value": "yellow",
|
|
109
109
|
},
|
|
110
110
|
Object {
|
|
111
|
-
"label": "
|
|
111
|
+
"label": "Violet",
|
|
112
112
|
"value": "violet",
|
|
113
113
|
},
|
|
114
114
|
Object {
|
|
115
|
-
"label": "
|
|
115
|
+
"label": "Blue",
|
|
116
116
|
"value": "blue",
|
|
117
117
|
},
|
|
118
118
|
Object {
|
|
119
|
-
"label": "
|
|
119
|
+
"label": "Green",
|
|
120
120
|
"value": "green",
|
|
121
121
|
},
|
|
122
122
|
Object {
|
|
123
|
-
"label": "
|
|
123
|
+
"label": "White",
|
|
124
124
|
"value": "white",
|
|
125
125
|
},
|
|
126
126
|
Object {
|
|
127
|
-
"label": "
|
|
127
|
+
"label": "Black",
|
|
128
128
|
"value": "black",
|
|
129
129
|
},
|
|
130
130
|
]
|
|
@@ -244,7 +244,7 @@ exports[`Container snapshot renders 1`] = `
|
|
|
244
244
|
imageUrl="url"
|
|
245
245
|
onSessionChange={[MockFunction]}
|
|
246
246
|
outlineColor="black"
|
|
247
|
-
paintColor="
|
|
247
|
+
paintColor="Red"
|
|
248
248
|
scale={1}
|
|
249
249
|
session={Object {}}
|
|
250
250
|
toolActive={
|
|
@@ -377,7 +377,7 @@ exports[`Container snapshot renders disabled 1`] = `
|
|
|
377
377
|
imageUrl="url"
|
|
378
378
|
onSessionChange={[MockFunction]}
|
|
379
379
|
outlineColor="black"
|
|
380
|
-
paintColor="
|
|
380
|
+
paintColor="Red"
|
|
381
381
|
scale={1}
|
|
382
382
|
session={Object {}}
|
|
383
383
|
toolActive={
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
+
import Translator from '@pie-lib/translator';
|
|
4
5
|
|
|
5
6
|
import constants from './constants';
|
|
6
7
|
import Button from './button';
|
|
@@ -10,6 +11,7 @@ import DrawableText from './drawable-text';
|
|
|
10
11
|
import Icon from './icon';
|
|
11
12
|
|
|
12
13
|
const { tools: TOOLS } = constants;
|
|
14
|
+
const { translator } = Translator;
|
|
13
15
|
|
|
14
16
|
const ROGVAIV = ['red', 'orange', 'yellow', 'violet', 'blue', 'green', 'white', 'black'].map((c) => ({
|
|
15
17
|
value: c,
|
|
@@ -25,6 +27,7 @@ export class Container extends Component {
|
|
|
25
27
|
imageDimensions: PropTypes.object.isRequired,
|
|
26
28
|
imageUrl: PropTypes.string.isRequired,
|
|
27
29
|
backgroundImageEnabled: PropTypes.bool.isRequired,
|
|
30
|
+
language: PropTypes.string,
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
constructor(props) {
|
|
@@ -53,6 +56,30 @@ export class Container extends Component {
|
|
|
53
56
|
};
|
|
54
57
|
}
|
|
55
58
|
|
|
59
|
+
setTranslatedState(language) {
|
|
60
|
+
const translatedROGVAIV = ROGVAIV.map((c) => ({
|
|
61
|
+
value: c.value,
|
|
62
|
+
label: translator.t(`drawingResponse.${c.label}`, { lng: language }),
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
this.setState({
|
|
66
|
+
fillColorList: [
|
|
67
|
+
{ value: 'transparent', label: translator.t('drawingResponse.noFill', { lng: language }), },
|
|
68
|
+
{ value: 'lightblue', label: translator.t('drawingResponse.lightblue', { lng: language }), },
|
|
69
|
+
{ value: 'lightyellow', label: translator.t('drawingResponse.lightyellow', { lng: language }), },
|
|
70
|
+
...translatedROGVAIV,
|
|
71
|
+
],
|
|
72
|
+
paintColor: translator.t('drawingResponse.red', { lng: language }),
|
|
73
|
+
outlineColorList: translatedROGVAIV,
|
|
74
|
+
paintColorList: translatedROGVAIV,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
79
|
+
const { language } = props;
|
|
80
|
+
this.setTranslatedState(language);
|
|
81
|
+
}
|
|
82
|
+
|
|
56
83
|
setDimensions() {
|
|
57
84
|
const checkExist = setInterval(() => {
|
|
58
85
|
try {
|
|
@@ -75,6 +102,9 @@ export class Container extends Component {
|
|
|
75
102
|
}
|
|
76
103
|
|
|
77
104
|
componentDidMount() {
|
|
105
|
+
const { language } = this.props;
|
|
106
|
+
this.setTranslatedState(language);
|
|
107
|
+
|
|
78
108
|
this.setDimensions();
|
|
79
109
|
|
|
80
110
|
this.observer = new MutationObserver((mutations) => {
|
|
@@ -114,13 +144,14 @@ export class Container extends Component {
|
|
|
114
144
|
handleMakeToolActive(tool) {
|
|
115
145
|
const { TextEntry } = this.state;
|
|
116
146
|
const { type } = tool;
|
|
147
|
+
const { language } = this.props;
|
|
117
148
|
|
|
118
149
|
if (type !== 'Text') {
|
|
119
150
|
this.setState({
|
|
120
151
|
toolActive: tool,
|
|
121
152
|
});
|
|
122
153
|
} else {
|
|
123
|
-
TextEntry.addNewTextEntry();
|
|
154
|
+
TextEntry.addNewTextEntry(language);
|
|
124
155
|
// Force update
|
|
125
156
|
this.setState({
|
|
126
157
|
updatedAt: new Date(),
|
|
@@ -147,7 +178,7 @@ export class Container extends Component {
|
|
|
147
178
|
}
|
|
148
179
|
|
|
149
180
|
render() {
|
|
150
|
-
const { classes, disabled, imageUrl, imageDimensions, onSessionChange, session, backgroundImageEnabled } =
|
|
181
|
+
const { classes, disabled, imageUrl, imageDimensions, onSessionChange, session, backgroundImageEnabled, language } =
|
|
151
182
|
this.props;
|
|
152
183
|
const {
|
|
153
184
|
drawableDimensions,
|
|
@@ -176,6 +207,7 @@ export class Container extends Component {
|
|
|
176
207
|
onFillColorChange={(color) => this.handleColorChange('fill', color)}
|
|
177
208
|
onOutlineColorChange={(color) => this.handleColorChange('outline', color)}
|
|
178
209
|
onPaintColorChange={(color) => this.handleColorChange('paint', color)}
|
|
210
|
+
language={language}
|
|
179
211
|
/>
|
|
180
212
|
)}
|
|
181
213
|
|
|
@@ -190,7 +222,7 @@ export class Container extends Component {
|
|
|
190
222
|
key={type}
|
|
191
223
|
disabled={this.checkIfToolIsDisabled(type)}
|
|
192
224
|
onClick={() => this.handleMakeToolActive(tool)}
|
|
193
|
-
label={<Icon path={icon}
|
|
225
|
+
label={<Icon path={icon}/>}
|
|
194
226
|
/>
|
|
195
227
|
);
|
|
196
228
|
})}
|
|
@@ -217,6 +249,7 @@ export class Container extends Component {
|
|
|
217
249
|
toolActive={toolActive}
|
|
218
250
|
TextEntry={TextEntry}
|
|
219
251
|
backgroundImageEnabled={backgroundImageEnabled}
|
|
252
|
+
language={language}
|
|
220
253
|
/>
|
|
221
254
|
</div>
|
|
222
255
|
</div>
|
|
@@ -6,7 +6,9 @@ import isEqual from 'lodash/isEqual';
|
|
|
6
6
|
import classnames from 'classnames';
|
|
7
7
|
import { Layer, Stage } from 'react-konva';
|
|
8
8
|
import { withStyles } from '@material-ui/core/styles';
|
|
9
|
+
import Translator from '@pie-lib/translator';
|
|
9
10
|
|
|
11
|
+
const { translator } = Translator;
|
|
10
12
|
import ImageBackground from './drawable-image';
|
|
11
13
|
import Button from './button';
|
|
12
14
|
import factory from './factory';
|
|
@@ -185,6 +187,7 @@ export class DrawableMain extends React.Component {
|
|
|
185
187
|
backgroundImageEnabled = true,
|
|
186
188
|
toolActive: { type },
|
|
187
189
|
scale,
|
|
190
|
+
language
|
|
188
191
|
} = this.props;
|
|
189
192
|
const { isOver, newDrawable } = this.state;
|
|
190
193
|
|
|
@@ -205,7 +208,7 @@ export class DrawableMain extends React.Component {
|
|
|
205
208
|
stage: this.stage,
|
|
206
209
|
onMouseOverElement: this.onMouseOverElement,
|
|
207
210
|
onMouseOutElement: this.onMouseOutElement,
|
|
208
|
-
scale
|
|
211
|
+
scale
|
|
209
212
|
};
|
|
210
213
|
|
|
211
214
|
let listeners = {};
|
|
@@ -230,8 +233,8 @@ export class DrawableMain extends React.Component {
|
|
|
230
233
|
return (
|
|
231
234
|
<div className={classes.wrapper}>
|
|
232
235
|
<div className={classes.undoControls}>
|
|
233
|
-
<Button disabled={disabled} onClick={this.handleUndo} label=
|
|
234
|
-
<Button disabled={disabled} onClick={this.handleClearAll} label=
|
|
236
|
+
<Button disabled={disabled} onClick={this.handleUndo} label={translator.t('common:undo', { lng: language })} />
|
|
237
|
+
<Button disabled={disabled} onClick={this.handleClearAll} label={translator.t('common:clearAll', { lng: language })} />
|
|
235
238
|
</div>
|
|
236
239
|
<div className={classes.base}>
|
|
237
240
|
{backgroundImageEnabled && imageUrl && (
|
|
@@ -290,7 +293,7 @@ const styles = () => ({
|
|
|
290
293
|
},
|
|
291
294
|
undoControls: {
|
|
292
295
|
marginTop: -43,
|
|
293
|
-
|
|
296
|
+
marginRight: 10,
|
|
294
297
|
},
|
|
295
298
|
});
|
|
296
299
|
|
|
@@ -309,6 +312,7 @@ DrawableMain.propTypes = {
|
|
|
309
312
|
session: PropTypes.object.isRequired,
|
|
310
313
|
backgroundImageEnabled: PropTypes.bool.isRequired,
|
|
311
314
|
scale: PropTypes.number.isRequired,
|
|
315
|
+
language: PropTypes.string,
|
|
312
316
|
};
|
|
313
317
|
|
|
314
318
|
export default withStyles(styles)(DrawableMain);
|
|
@@ -5,6 +5,9 @@ import Select from '@material-ui/core/Select';
|
|
|
5
5
|
import MenuItem from '@material-ui/core/MenuItem';
|
|
6
6
|
import { withStyles } from '@material-ui/core/styles';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
+
import Translator from '@pie-lib/translator';
|
|
9
|
+
|
|
10
|
+
const { translator } = Translator;
|
|
8
11
|
|
|
9
12
|
// TODO: Change Palette so will render inputs and colors dynamically
|
|
10
13
|
class Palette extends React.Component {
|
|
@@ -22,11 +25,11 @@ class Palette extends React.Component {
|
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
render() {
|
|
25
|
-
const { classes, fillColor, outlineColor, fillList, outlineList } = this.props;
|
|
28
|
+
const { classes, fillColor, outlineColor, fillList, outlineList, language } = this.props;
|
|
26
29
|
|
|
27
30
|
return (
|
|
28
31
|
<div className={classes.base}>
|
|
29
|
-
<InputContainer label=
|
|
32
|
+
<InputContainer label={translator.t('drawingResponse.fillColor', { lng: language })} className={classes.input}>
|
|
30
33
|
<Select className={classes.select} onChange={this.onChange('fill')} value={fillColor}>
|
|
31
34
|
{fillList.map(({ value, label }) => (
|
|
32
35
|
<MenuItem
|
|
@@ -43,7 +46,7 @@ class Palette extends React.Component {
|
|
|
43
46
|
</Select>
|
|
44
47
|
</InputContainer>
|
|
45
48
|
|
|
46
|
-
<InputContainer label=
|
|
49
|
+
<InputContainer label={translator.t('drawingResponse.outlineColor', { lng: language })} className={classes.input}>
|
|
47
50
|
<Select className={classes.select} onChange={this.onChange('outline')} value={outlineColor}>
|
|
48
51
|
{outlineList.map(({ value, label }) => (
|
|
49
52
|
<MenuItem key={value} value={value} className={classes.item} style={{ border: `2px solid ${value}` }}>
|
|
@@ -93,6 +96,7 @@ Palette.propTypes = {
|
|
|
93
96
|
onPaintColorChange: PropTypes.func.isRequired,
|
|
94
97
|
outlineColor: PropTypes.string.isRequired,
|
|
95
98
|
outlineList: PropTypes.array.isRequired,
|
|
99
|
+
language: PropTypes.string,
|
|
96
100
|
};
|
|
97
101
|
|
|
98
102
|
export default withStyles(styles)(Palette);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text } from 'react-konva';
|
|
3
|
+
import Translator from '@pie-lib/translator';
|
|
3
4
|
|
|
5
|
+
const { translator } = Translator;
|
|
4
6
|
import Transformer from './drawable-transformer';
|
|
5
7
|
|
|
6
8
|
export const generateId = () => Math.random().toString(36).substring(2) + new Date().getTime().toString(36);
|
|
@@ -30,14 +32,14 @@ export default class TextDrawable {
|
|
|
30
32
|
this.props.forceUpdate();
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
addNewTextEntry = () => {
|
|
35
|
+
addNewTextEntry = (language) => {
|
|
34
36
|
const all = this.all;
|
|
35
37
|
const id = generateId();
|
|
36
38
|
|
|
37
39
|
all.push({
|
|
38
40
|
id: id,
|
|
39
41
|
isDefault: true,
|
|
40
|
-
label: '
|
|
42
|
+
label: translator.t('drawingResponse.onDoubleClick', { lng: language }),
|
|
41
43
|
width: 200,
|
|
42
44
|
x: (all.length + 1) * 5 + 50,
|
|
43
45
|
y: (all.length + 1) * 5 + 50,
|
|
@@ -20,7 +20,16 @@ class DrawingResponseComponent extends React.Component {
|
|
|
20
20
|
|
|
21
21
|
render() {
|
|
22
22
|
const {
|
|
23
|
-
model: {
|
|
23
|
+
model: {
|
|
24
|
+
disabled,
|
|
25
|
+
imageDimensions,
|
|
26
|
+
imageUrl,
|
|
27
|
+
prompt,
|
|
28
|
+
mode,
|
|
29
|
+
teacherInstructions,
|
|
30
|
+
backgroundImageEnabled,
|
|
31
|
+
language
|
|
32
|
+
},
|
|
24
33
|
session,
|
|
25
34
|
onSessionChange,
|
|
26
35
|
classes,
|
|
@@ -54,6 +63,7 @@ class DrawingResponseComponent extends React.Component {
|
|
|
54
63
|
imageUrl={imageUrl}
|
|
55
64
|
backgroundImageEnabled={backgroundImageEnabled}
|
|
56
65
|
disabled={disabled}
|
|
66
|
+
language={language}
|
|
57
67
|
/>
|
|
58
68
|
</div>
|
|
59
69
|
);
|