@pie-element/drawing-response 3.7.2 → 3.7.3-next.1008

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/configure/CHANGELOG.md +117 -0
  3. package/configure/lib/defaults.js +18 -3
  4. package/configure/lib/defaults.js.map +1 -1
  5. package/configure/lib/image-container.js +23 -14
  6. package/configure/lib/image-container.js.map +1 -1
  7. package/configure/lib/index.js +3 -9
  8. package/configure/lib/index.js.map +1 -1
  9. package/configure/lib/root.js +44 -11
  10. package/configure/lib/root.js.map +1 -1
  11. package/configure/package.json +3 -3
  12. package/configure/src/__tests__/__snapshots__/image-container.test.jsx.snap +3 -2
  13. package/configure/src/__tests__/__snapshots__/root.test.jsx.snap +22 -14
  14. package/configure/src/defaults.js +17 -2
  15. package/configure/src/image-container.jsx +71 -45
  16. package/configure/src/index.js +0 -6
  17. package/configure/src/root.jsx +53 -24
  18. package/controller/CHANGELOG.md +24 -0
  19. package/controller/lib/index.js +13 -9
  20. package/controller/lib/index.js.map +1 -1
  21. package/controller/package.json +1 -1
  22. package/controller/src/__tests__/index.test.js +18 -9
  23. package/controller/src/index.js +4 -1
  24. package/docs/config-schema.json +79 -0
  25. package/docs/config-schema.json.md +61 -1
  26. package/docs/demo/generate.js +2 -0
  27. package/docs/pie-schema.json +43 -0
  28. package/docs/pie-schema.json.md +35 -0
  29. package/lib/drawing-response/container.js +65 -15
  30. package/lib/drawing-response/container.js.map +1 -1
  31. package/lib/drawing-response/drawable-circle.js +1 -1
  32. package/lib/drawing-response/drawable-circle.js.map +1 -1
  33. package/lib/drawing-response/drawable-eraser.js +1 -1
  34. package/lib/drawing-response/drawable-eraser.js.map +1 -1
  35. package/lib/drawing-response/drawable-free-path.js +1 -1
  36. package/lib/drawing-response/drawable-free-path.js.map +1 -1
  37. package/lib/drawing-response/drawable-helper.js.map +1 -1
  38. package/lib/drawing-response/drawable-image.js +1 -0
  39. package/lib/drawing-response/drawable-image.js.map +1 -1
  40. package/lib/drawing-response/drawable-line.js +1 -1
  41. package/lib/drawing-response/drawable-line.js.map +1 -1
  42. package/lib/drawing-response/drawable-main.js +37 -14
  43. package/lib/drawing-response/drawable-main.js.map +1 -1
  44. package/lib/drawing-response/drawable-palette.js +1 -1
  45. package/lib/drawing-response/drawable-palette.js.map +1 -1
  46. package/lib/drawing-response/drawable-rectangle.js +1 -1
  47. package/lib/drawing-response/drawable-rectangle.js.map +1 -1
  48. package/lib/drawing-response/drawable-text.js +15 -5
  49. package/lib/drawing-response/drawable-text.js.map +1 -1
  50. package/lib/drawing-response/drawable-transformer.js +1 -1
  51. package/lib/drawing-response/drawable-transformer.js.map +1 -1
  52. package/lib/drawing-response/index.js +9 -9
  53. package/lib/drawing-response/index.js.map +1 -1
  54. package/lib/index.js +4 -1
  55. package/lib/index.js.map +1 -1
  56. package/package.json +4 -4
  57. package/src/drawing-response/__tests__/__snapshots__/container.test.jsx.snap +18 -130
  58. package/src/drawing-response/__tests__/__snapshots__/drawing-main.test.jsx.snap +26 -2
  59. package/src/drawing-response/__tests__/container.test.jsx +7 -0
  60. package/src/drawing-response/__tests__/drawing-main.test.jsx +2 -1
  61. package/src/drawing-response/container.jsx +55 -15
  62. package/src/drawing-response/drawable-image.jsx +1 -0
  63. package/src/drawing-response/drawable-main.jsx +39 -15
  64. package/src/drawing-response/drawable-text.jsx +7 -1
  65. package/src/drawing-response/index.jsx +6 -4
  66. package/src/index.js +5 -0
  67. package/module/configure.js +0 -1099
  68. package/module/controller.js +0 -66
  69. package/module/demo.js +0 -38
  70. package/module/element.js +0 -1893
  71. package/module/index.html +0 -16
  72. package/module/manifest.json +0 -14
package/module/element.js DELETED
@@ -1,1893 +0,0 @@
1
- import {_dll_prop_types, _dll_material_ui__core_styles, _dll_react, _dll_material_ui__core, _dll_pie_lib__render_ui, _dll_lodash, _dll_react_dom, _dll_pie_lib__math_rendering, _dll_pie_framework__pie_player_events} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
2
- import {_dll_react_konva} from "../../../@pie-ui/shared-konva@^2.5.17/module/index.js";
3
- var constants = {
4
- tools: [{
5
- type: 'Select',
6
- label: 'Select',
7
- icon: 'mdiCursorDefault'
8
- }, {
9
- type: 'FreePathDrawable',
10
- label: 'Free Draw',
11
- icon: 'mdiPencil'
12
- }, {
13
- type: 'LineDrawable',
14
- label: 'Line',
15
- icon: 'mdiMinus'
16
- }, {
17
- type: 'RectangleDrawable',
18
- label: 'Rectangle',
19
- icon: 'mdiRectangle'
20
- }, {
21
- type: 'CircleDrawable',
22
- label: 'Circle',
23
- icon: 'mdiCircle'
24
- }, {
25
- type: 'Text',
26
- label: 'Text Entry',
27
- icon: 'mdiFormatColorText'
28
- }, {
29
- type: 'EraserDrawable',
30
- label: 'Eraser',
31
- icon: 'mdiEraser'
32
- }]
33
- };
34
- function unwrapExports(x) {
35
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
36
- }
37
- function createCommonjsModule(fn, module) {
38
- return (module = {
39
- exports: {}
40
- }, fn(module, module.exports), module.exports);
41
- }
42
- var classnames = createCommonjsModule(function (module) {
43
- (function () {
44
- var hasOwn = ({}).hasOwnProperty;
45
- function classNames() {
46
- var classes = [];
47
- for (var i = 0; i < arguments.length; i++) {
48
- var arg = arguments[i];
49
- if (!arg) continue;
50
- var argType = typeof arg;
51
- if (argType === 'string' || argType === 'number') {
52
- classes.push(arg);
53
- } else if (Array.isArray(arg) && arg.length) {
54
- var inner = classNames.apply(null, arg);
55
- if (inner) {
56
- classes.push(inner);
57
- }
58
- } else if (argType === 'object') {
59
- for (var key in arg) {
60
- if (hasOwn.call(arg, key) && arg[key]) {
61
- classes.push(key);
62
- }
63
- }
64
- }
65
- }
66
- return classes.join(' ');
67
- }
68
- if (module.exports) {
69
- classNames.default = classNames;
70
- module.exports = classNames;
71
- } else {
72
- window.classNames = classNames;
73
- }
74
- })();
75
- });
76
- const React = _dll_react;
77
- const PropTypes = _dll_prop_types;
78
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
79
- const {Button: Button} = _dll_material_ui__core;
80
- const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/button.jsx";
81
- const RawButton = ({classes, className, label, onClick, disabled, title}) => React.createElement(Button, {
82
- title: title,
83
- onClick: onClick,
84
- disabled: disabled,
85
- className: classnames(classes.addButton, className),
86
- size: "small",
87
- variant: "contained",
88
- color: "default",
89
- __self: undefined,
90
- __source: {
91
- fileName: _jsxFileName,
92
- lineNumber: 8
93
- }
94
- }, label);
95
- RawButton.propTypes = {
96
- classes: PropTypes.object.isRequired,
97
- className: PropTypes.string,
98
- disabled: PropTypes.bool,
99
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
100
- onClick: PropTypes.func,
101
- title: PropTypes.string
102
- };
103
- RawButton.defaultProps = {
104
- className: '',
105
- disabled: false,
106
- label: 'Add',
107
- onClick: () => {},
108
- title: ''
109
- };
110
- const styles = () => ({
111
- addButton: {
112
- fontSize: '0.9em',
113
- marginLeft: 8,
114
- minWidth: 32,
115
- height: 32,
116
- '& span': {
117
- '& svg': {
118
- width: '1.3em !important',
119
- height: '1.3em !important'
120
- }
121
- }
122
- }
123
- });
124
- const ButtonStyled = withStyles(styles)(RawButton);
125
- const React$1 = _dll_react;
126
- const PropTypes$1 = _dll_prop_types;
127
- const {InputContainer: InputContainer} = _dll_pie_lib__render_ui;
128
- const {Select: Select} = _dll_material_ui__core;
129
- const {MenuItem: MenuItem} = _dll_material_ui__core;
130
- const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
131
- const _jsxFileName$1 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-palette.jsx";
132
- class Palette extends React$1.Component {
133
- constructor(...args) {
134
- super(...args);
135
- Palette.prototype.__init.call(this);
136
- }
137
- __init() {
138
- this.onChange = name => event => {
139
- const {value} = event.target;
140
- const {onFillColorChange, onOutlineColorChange, onPaintColorChange} = this.props;
141
- if (name === 'fill') {
142
- onFillColorChange(value);
143
- } else if (name === 'outline') {
144
- onOutlineColorChange(value);
145
- } else {
146
- onPaintColorChange(value);
147
- }
148
- };
149
- }
150
- render() {
151
- const {classes, fillColor, outlineColor, fillList, outlineList} = this.props;
152
- return React$1.createElement('div', {
153
- className: classes.base,
154
- __self: this,
155
- __source: {
156
- fileName: _jsxFileName$1,
157
- lineNumber: 37
158
- }
159
- }, React$1.createElement(InputContainer, {
160
- label: "Fill Color",
161
- className: classes.input,
162
- __self: this,
163
- __source: {
164
- fileName: _jsxFileName$1,
165
- lineNumber: 38
166
- }
167
- }, React$1.createElement(Select, {
168
- className: classes.select,
169
- onChange: this.onChange('fill'),
170
- value: fillColor,
171
- __self: this,
172
- __source: {
173
- fileName: _jsxFileName$1,
174
- lineNumber: 39
175
- }
176
- }, fillList.map(({value, label}) => React$1.createElement(MenuItem, {
177
- key: value,
178
- value: value,
179
- className: classes.item,
180
- style: {
181
- backgroundColor: value
182
- },
183
- __self: this,
184
- __source: {
185
- fileName: _jsxFileName$1,
186
- lineNumber: 45
187
- }
188
- }, label)))), React$1.createElement(InputContainer, {
189
- label: "Outline Color",
190
- className: classes.input,
191
- __self: this,
192
- __source: {
193
- fileName: _jsxFileName$1,
194
- lineNumber: 57
195
- }
196
- }, React$1.createElement(Select, {
197
- className: classes.select,
198
- onChange: this.onChange('outline'),
199
- value: outlineColor,
200
- __self: this,
201
- __source: {
202
- fileName: _jsxFileName$1,
203
- lineNumber: 58
204
- }
205
- }, outlineList.map(({value, label}) => React$1.createElement(MenuItem, {
206
- key: value,
207
- value: value,
208
- className: classes.item,
209
- style: {
210
- border: `2px solid ${value}`
211
- },
212
- __self: this,
213
- __source: {
214
- fileName: _jsxFileName$1,
215
- lineNumber: 64
216
- }
217
- }, label)))));
218
- }
219
- }
220
- const styles$1 = theme => ({
221
- base: {
222
- marginTop: theme.spacing.unit * 2,
223
- display: 'flex'
224
- },
225
- input: {
226
- flex: 1,
227
- fontSize: 'inherit',
228
- width: '90%'
229
- },
230
- item: {
231
- borderRadius: '2px',
232
- fontSize: 'inherit',
233
- height: '22px',
234
- marginLeft: theme.spacing.unit * 2,
235
- marginRight: theme.spacing.unit * 2,
236
- marginTop: theme.spacing.unit * 2
237
- },
238
- select: {
239
- fontSize: 'inherit',
240
- transform: 'translate(0%, 40%)'
241
- }
242
- });
243
- Palette.propTypes = {
244
- classes: PropTypes$1.object.isRequired,
245
- fillColor: PropTypes$1.string.isRequired,
246
- fillList: PropTypes$1.array.isRequired,
247
- onFillColorChange: PropTypes$1.func.isRequired,
248
- onOutlineColorChange: PropTypes$1.func.isRequired,
249
- onPaintColorChange: PropTypes$1.func.isRequired,
250
- outlineColor: PropTypes$1.string.isRequired,
251
- outlineList: PropTypes$1.array.isRequired
252
- };
253
- var DrawablePalette = withStyles$1(styles$1)(Palette);
254
- const React$2 = _dll_react;
255
- const PropTypes$2 = _dll_prop_types;
256
- const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
257
- const _jsxFileName$2 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-image.jsx";
258
- const DrawableImage = ({classes, url, dimensions: {height, width}}) => React$2.createElement('div', {
259
- className: classes.imageContainer,
260
- __self: undefined,
261
- __source: {
262
- fileName: _jsxFileName$2,
263
- lineNumber: 6
264
- }
265
- }, React$2.createElement('img', {
266
- className: classes.image,
267
- src: url,
268
- style: {
269
- height,
270
- maxWidth: width,
271
- maxHeight: 350,
272
- width
273
- },
274
- __self: undefined,
275
- __source: {
276
- fileName: _jsxFileName$2,
277
- lineNumber: 7
278
- }
279
- }));
280
- const styles$2 = () => ({
281
- image: {
282
- alignItems: 'center',
283
- display: 'flex',
284
- justifyContent: 'center'
285
- },
286
- imageContainer: {
287
- position: 'relative',
288
- width: 'fit-content'
289
- }
290
- });
291
- DrawableImage.propTypes = {
292
- classes: PropTypes$2.object.isRequired,
293
- dimensions: PropTypes$2.object.isRequired,
294
- url: PropTypes$2.string.isRequired
295
- };
296
- var ImageBackground = withStyles$2(styles$2)(DrawableImage);
297
- class DrawableHelper {
298
- constructor(props, type) {
299
- const {startx, starty, fillColor, outlineColor, createdAt} = props;
300
- this.startx = startx;
301
- this.starty = starty;
302
- this.createdAt = createdAt;
303
- this.fillColor = fillColor;
304
- this.outlineColor = outlineColor;
305
- this.type = type;
306
- }
307
- toJson() {
308
- const base = JSON.parse(JSON.stringify(this));
309
- return base;
310
- }
311
- }
312
- const React$3 = _dll_react;
313
- const {Line: Line} = _dll_react_konva;
314
- const _jsxFileName$3 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-free-path.jsx";
315
- class FreePathDrawable extends DrawableHelper {
316
- static __initStatic() {
317
- this.TYPE = 'FreePathDrawable';
318
- }
319
- constructor(props) {
320
- super(props, FreePathDrawable.TYPE);
321
- FreePathDrawable.prototype.__init.call(this);
322
- const {startx, starty, points, posX, posY} = props;
323
- this.points = points || [startx, starty];
324
- this.posX = posX || 0;
325
- this.posY = posY || 0;
326
- }
327
- registerMovement(x, y) {
328
- this.points = [...this.points, x, y];
329
- }
330
- handleOnClick(props) {
331
- const {paint, paintColor, forceUpdate} = props;
332
- if (paint) {
333
- this.paintColor = paintColor;
334
- forceUpdate();
335
- }
336
- }
337
- __init() {
338
- this.handleDragEnd = (props, event) => {
339
- this.posX = event.target.getX();
340
- this.posY = event.target.getY();
341
- props.handleSessionChange();
342
- };
343
- }
344
- render(props) {
345
- const {draggable, key, onMouseOverElement, onMouseOutElement} = props;
346
- return React$3.createElement(Line, {
347
- key: key,
348
- draggable: draggable,
349
- tension: 0,
350
- bezier: true,
351
- points: this.points,
352
- fill: this.paintColor || this.fillColor,
353
- onClick: () => this.handleOnClick(props),
354
- onDragEnd: this.handleDragEnd.bind(this, props),
355
- onMouseEnter: onMouseOverElement,
356
- onMouseLeave: onMouseOutElement,
357
- stroke: this.paintColor || this.outlineColor,
358
- x: this.posX,
359
- y: this.posY,
360
- __self: this,
361
- __source: {
362
- fileName: _jsxFileName$3,
363
- lineNumber: 42
364
- }
365
- });
366
- }
367
- }
368
- FreePathDrawable.__initStatic();
369
- const React$4 = _dll_react;
370
- const {Arrow: Arrow} = _dll_react_konva;
371
- const _jsxFileName$4 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-line.jsx";
372
- class LineDrawable extends DrawableHelper {
373
- static __initStatic() {
374
- this.TYPE = 'LineDrawable';
375
- }
376
- constructor(props) {
377
- super(props, LineDrawable.TYPE);
378
- LineDrawable.prototype.__init.call(this);
379
- const {startx, starty, x, y, posX, posY} = props;
380
- this.x = x || startx;
381
- this.y = y || starty;
382
- this.posX = posX || 0;
383
- this.posY = posY || 0;
384
- }
385
- registerMovement(x, y) {
386
- this.x = x;
387
- this.y = y;
388
- }
389
- handleOnClick(props) {
390
- const {paint, paintColor, forceUpdate} = props;
391
- if (paint) {
392
- this.paintColor = paintColor;
393
- forceUpdate();
394
- }
395
- }
396
- __init() {
397
- this.handleDragEnd = (props, event) => {
398
- this.posX = event.target.getX();
399
- this.posY = event.target.getY();
400
- props.handleSessionChange();
401
- };
402
- }
403
- render(props) {
404
- const {draggable, key, onMouseOverElement, onMouseOutElement} = props;
405
- const points = [this.startx, this.starty, this.x, this.y];
406
- return React$4.createElement(Arrow, {
407
- key: key,
408
- draggable: draggable,
409
- points: points,
410
- fill: this.paintColor || this.outlineColor,
411
- onClick: () => this.handleOnClick(props),
412
- stroke: this.paintColor || this.outlineColor,
413
- onDragEnd: this.handleDragEnd.bind(this, props),
414
- onMouseEnter: onMouseOverElement,
415
- onMouseLeave: onMouseOutElement,
416
- x: this.posX,
417
- y: this.posY,
418
- pointerWidth: 0,
419
- pointerLength: 0,
420
- __self: this,
421
- __source: {
422
- fileName: _jsxFileName$4,
423
- lineNumber: 45
424
- }
425
- });
426
- }
427
- }
428
- LineDrawable.__initStatic();
429
- const React$5 = _dll_react;
430
- const {Rect: Rect} = _dll_react_konva;
431
- const _jsxFileName$5 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-rectangle.jsx";
432
- class RectangleDrawable extends DrawableHelper {
433
- static __initStatic() {
434
- this.TYPE = 'RectangleDrawable';
435
- }
436
- constructor(props) {
437
- super(props, RectangleDrawable.TYPE);
438
- RectangleDrawable.prototype.__init.call(this);
439
- const {startx, starty, x, y} = props;
440
- this.startx = startx;
441
- this.starty = starty;
442
- this.x = x || startx;
443
- this.y = y || starty;
444
- this.width = x - startx || 0;
445
- this.height = y - starty || 0;
446
- }
447
- registerMovement(x, y) {
448
- this.x = x;
449
- this.y = y;
450
- this.width = this.x - this.startx;
451
- this.height = this.y - this.starty;
452
- }
453
- handleOnClick(props) {
454
- const {paint, paintColor, forceUpdate} = props;
455
- if (paint) {
456
- this.paintColor = paintColor;
457
- forceUpdate();
458
- }
459
- }
460
- __init() {
461
- this.handleDragEnd = (props, event) => {
462
- const deltaX = this.startx - event.target.getX();
463
- const deltaY = this.starty - event.target.getY();
464
- this.startx = event.target.getX();
465
- this.starty = event.target.getY();
466
- this.x = this.x - deltaX;
467
- this.y = this.y - deltaY;
468
- props.handleSessionChange();
469
- };
470
- }
471
- render(props) {
472
- const {draggable, key, onMouseOverElement, onMouseOutElement} = props;
473
- return React$5.createElement(Rect, {
474
- key: key,
475
- height: this.height,
476
- width: this.width,
477
- fill: this.paintColor || this.fillColor,
478
- onClick: () => this.handleOnClick(props),
479
- onDragEnd: this.handleDragEnd.bind(this, props),
480
- onMouseEnter: onMouseOverElement,
481
- onMouseLeave: onMouseOutElement,
482
- stroke: this.outlineColor,
483
- draggable: draggable,
484
- strokeWidth: 2,
485
- x: this.startx,
486
- y: this.starty,
487
- __self: this,
488
- __source: {
489
- fileName: _jsxFileName$5,
490
- lineNumber: 52
491
- }
492
- });
493
- }
494
- }
495
- RectangleDrawable.__initStatic();
496
- const React$6 = _dll_react;
497
- const {Circle: Circle} = _dll_react_konva;
498
- const _jsxFileName$6 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-circle.jsx";
499
- class CircleDrawable extends DrawableHelper {
500
- static __initStatic() {
501
- this.TYPE = 'CircleDrawable';
502
- }
503
- constructor(props) {
504
- super(props, CircleDrawable.TYPE);
505
- CircleDrawable.prototype.__init.call(this);
506
- const {startx, starty, x, y} = props;
507
- this.startx = startx;
508
- this.starty = starty;
509
- this.x = x || startx;
510
- this.y = y || starty;
511
- const dx = this.startx - this.x;
512
- const dy = this.starty - this.y;
513
- this.radius = Math.sqrt(dx * dx + dy * dy);
514
- }
515
- registerMovement(x, y) {
516
- this.x = x;
517
- this.y = y;
518
- const dx = this.startx - this.x;
519
- const dy = this.starty - this.y;
520
- this.radius = Math.sqrt(dx * dx + dy * dy);
521
- }
522
- handleOnClick(props) {
523
- const {paint, paintColor, forceUpdate} = props;
524
- if (paint) {
525
- this.paintColor = paintColor;
526
- forceUpdate();
527
- }
528
- }
529
- __init() {
530
- this.handleDragEnd = (props, event) => {
531
- const deltaX = this.startx - event.target.getX();
532
- const deltaY = this.starty - event.target.getY();
533
- this.startx = event.target.getX();
534
- this.starty = event.target.getY();
535
- this.x = this.x - deltaX;
536
- this.y = this.y - deltaY;
537
- props.handleSessionChange();
538
- };
539
- }
540
- render(props) {
541
- const {draggable, key, onMouseOverElement, onMouseOutElement} = props;
542
- return React$6.createElement(Circle, {
543
- key: key,
544
- draggable: draggable,
545
- radius: this.radius,
546
- x: this.startx,
547
- y: this.starty,
548
- fill: this.paintColor || this.fillColor,
549
- onClick: () => this.handleOnClick(props),
550
- onDragEnd: this.handleDragEnd.bind(this, props),
551
- onMouseEnter: onMouseOverElement,
552
- onMouseLeave: onMouseOutElement,
553
- stroke: this.outlineColor,
554
- __self: this,
555
- __source: {
556
- fileName: _jsxFileName$6,
557
- lineNumber: 59
558
- }
559
- });
560
- }
561
- }
562
- CircleDrawable.__initStatic();
563
- const React$7 = _dll_react;
564
- const {Line: Line$1} = _dll_react_konva;
565
- const _jsxFileName$7 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-eraser.jsx";
566
- class EraserDrawable extends DrawableHelper {
567
- static __initStatic() {
568
- this.TYPE = 'EraserDrawable';
569
- }
570
- constructor(props) {
571
- super(props, EraserDrawable.TYPE);
572
- EraserDrawable.prototype.__init.call(this);
573
- const {startx, starty, points, posX, posY} = props;
574
- this.points = points || [startx, starty];
575
- this.posX = posX || 0;
576
- this.posY = posY || 0;
577
- }
578
- registerMovement(x, y) {
579
- this.points = [...this.points, x, y];
580
- }
581
- __init() {
582
- this.handleDragEnd = (props, event) => {
583
- this.posX = event.target.getX();
584
- this.posY = event.target.getY();
585
- props.handleSessionChange();
586
- };
587
- }
588
- render(props) {
589
- const {draggable, key, onMouseOverElement, onMouseOutElement} = props;
590
- return React$7.createElement(Line$1, {
591
- key: key,
592
- draggable: draggable,
593
- globalCompositeOperation: "destination-out",
594
- tension: 0,
595
- bezier: true,
596
- points: this.points,
597
- onDragEnd: this.handleDragEnd.bind(this, props),
598
- onMouseEnter: onMouseOverElement,
599
- onMouseLeave: onMouseOutElement,
600
- strokeStyle: "#df4b26",
601
- lineJoin: "round",
602
- lineWidth: "5",
603
- fill: "white",
604
- stroke: "white",
605
- strokeWidth: 5,
606
- x: this.posX,
607
- y: this.posY,
608
- __self: this,
609
- __source: {
610
- fileName: _jsxFileName$7,
611
- lineNumber: 32
612
- }
613
- });
614
- }
615
- }
616
- EraserDrawable.__initStatic();
617
- const DRAWABLES = [FreePathDrawable, LineDrawable, RectangleDrawable, CircleDrawable, EraserDrawable];
618
- var factory = (type, props) => {
619
- const T = DRAWABLES.find(D => D.TYPE === type);
620
- if (T) {
621
- return new T(props);
622
- }
623
- throw new Error(`Can't find drawable for type: ${type} and props: ${JSON.stringify(props)}`);
624
- };
625
- const React$8 = _dll_react;
626
- const PropTypes$3 = _dll_prop_types;
627
- const {omit: omit} = _dll_lodash;
628
- const {cloneDeep: cloneDeep} = _dll_lodash;
629
- const {isEqual: isEqual} = _dll_lodash;
630
- const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
631
- const {Layer: Layer} = _dll_react_konva;
632
- const {Stage: Stage} = _dll_react_konva;
633
- const _jsxFileName$8 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-main.jsx";
634
- class DrawableMain extends React$8.Component {
635
- constructor(props) {
636
- super(props);
637
- DrawableMain.prototype.__init.call(this);
638
- DrawableMain.prototype.__init2.call(this);
639
- DrawableMain.prototype.__init3.call(this);
640
- DrawableMain.prototype.__init4.call(this);
641
- DrawableMain.prototype.__init5.call(this);
642
- DrawableMain.prototype.__init6.call(this);
643
- DrawableMain.prototype.__init7.call(this);
644
- DrawableMain.prototype.__init8.call(this);
645
- DrawableMain.prototype.__init9.call(this);
646
- this.state = {
647
- drawables: [],
648
- newDrawable: [],
649
- textIsSelected: false
650
- };
651
- }
652
- UNSAFE_componentWillReceiveProps(nextProps) {
653
- if (nextProps.session) {
654
- const {TextEntry} = nextProps;
655
- const {drawables: currentDrawables} = this.state;
656
- if (nextProps.session.drawables) {
657
- const newDrawables = cloneDeep(nextProps.session.drawables);
658
- const drawablesString = JSON.stringify(currentDrawables);
659
- const sessionDrawableString = JSON.stringify((newDrawables || []).map(drawable => omit(drawable, 'type')));
660
- if (drawablesString !== sessionDrawableString) {
661
- const drawableArray = nextProps.session.drawables;
662
- this.setState({
663
- drawables: drawableArray.map(drawable => factory(drawable.type, drawable))
664
- });
665
- }
666
- const currentTexts = TextEntry.all.map(text => ({
667
- ...text,
668
- ...TextEntry[`text_${text.id}`] && TextEntry[`text_${text.id}`].attrs,
669
- value: TextEntry[`textarea_${text.id}`] && TextEntry[`textarea_${text.id}`].value
670
- }));
671
- if (!isEqual(currentTexts, nextProps.session.texts)) {
672
- TextEntry.setAll(nextProps.session.texts || []);
673
- }
674
- }
675
- } else {
676
- this.handleSessionChange();
677
- }
678
- }
679
- __init() {
680
- this.handleSessionChange = () => {
681
- const {onSessionChange, session, TextEntry} = this.props;
682
- const {drawables} = this.state;
683
- const newSession = {
684
- drawables: drawables.map(d => d.toJson()),
685
- texts: TextEntry.all.map(text => ({
686
- ...text,
687
- ...TextEntry[`text_${text.id}`] && TextEntry[`text_${text.id}`].attrs,
688
- value: TextEntry[`textarea_${text.id}`] && TextEntry[`textarea_${text.id}`].value
689
- }))
690
- };
691
- if (!isEqual(newSession, session)) {
692
- onSessionChange({
693
- ...session,
694
- ...newSession
695
- });
696
- }
697
- };
698
- }
699
- __init2() {
700
- this.onMouseOverElement = () => this.setState({
701
- isOver: true
702
- });
703
- }
704
- __init3() {
705
- this.onMouseOutElement = () => this.setState({
706
- isOver: false
707
- });
708
- }
709
- __init4() {
710
- this.handleMouseDown = e => {
711
- const {newDrawable, textIsSelected} = this.state;
712
- const {toolActive, fillColor, outlineColor} = this.props;
713
- if (newDrawable.length === 0 && !textIsSelected) {
714
- const {x, y} = e.target.getStage().getPointerPosition();
715
- const newDrawable = factory(toolActive.type, {
716
- startx: x,
717
- starty: y,
718
- fillColor,
719
- outlineColor,
720
- createdAt: new Date()
721
- });
722
- this.setState({
723
- newDrawable: [newDrawable]
724
- });
725
- }
726
- };
727
- }
728
- __init5() {
729
- this.handleMouseUp = e => {
730
- const {newDrawable, drawables} = this.state;
731
- if (newDrawable.length === 1) {
732
- const {x, y} = e.target.getStage().getPointerPosition();
733
- const drawableToAdd = newDrawable[0];
734
- drawableToAdd.registerMovement(x, y);
735
- drawables.push(drawableToAdd);
736
- this.setState({
737
- newDrawable: [],
738
- drawables
739
- }, this.handleSessionChange.bind(this, drawableToAdd));
740
- }
741
- };
742
- }
743
- __init6() {
744
- this.handleMouseMove = e => {
745
- const {newDrawable} = this.state;
746
- if (newDrawable.length === 1) {
747
- const {x, y} = e.target.getStage().getPointerPosition();
748
- const updatedNewDrawable = newDrawable[0];
749
- updatedNewDrawable.registerMovement(x, y);
750
- this.setState({
751
- newDrawable: [updatedNewDrawable]
752
- });
753
- }
754
- };
755
- }
756
- __init7() {
757
- this.handleUndo = () => {
758
- const {drawables} = this.state;
759
- const {TextEntry} = this.props;
760
- const newDrawables = [...drawables];
761
- const allData = [...drawables, ...TextEntry.all];
762
- allData.sort((a, b) => new Date(a.createdAt) - new Date(b.createdAt));
763
- const lastElement = allData[allData.length - 1];
764
- if (lastElement.type === 'text-entry') {
765
- TextEntry.all.pop();
766
- this.setState({
767
- updatedAt: new Date()
768
- }, this.handleSessionChange);
769
- } else {
770
- newDrawables.pop();
771
- this.setState({
772
- drawables: newDrawables
773
- }, this.handleSessionChange);
774
- }
775
- };
776
- }
777
- __init8() {
778
- this.handleClearAll = () => {
779
- const {TextEntry} = this.props;
780
- TextEntry.all = [];
781
- this.setState({
782
- drawables: [],
783
- updatedAt: new Date()
784
- }, this.handleSessionChange);
785
- };
786
- }
787
- __init9() {
788
- this.toggleTextSelected = textIsSelected => this.setState({
789
- textIsSelected
790
- });
791
- }
792
- render() {
793
- const {classes, disabled, drawableDimensions, fillColor, imageDimensions, imageUrl, paintColor, outlineColor, TextEntry, toolActive: {type}} = this.props;
794
- const {isOver, newDrawable} = this.state;
795
- const draggable = type === 'Select';
796
- const paint = type === 'PaintBucket';
797
- const drawables = [...this.state.drawables, ...this.state.newDrawable];
798
- const drawableProps = {
799
- draggable: draggable && !disabled,
800
- disabled,
801
- paint,
802
- fillColor,
803
- forceUpdate: () => this.setState({
804
- updatedAt: new Date()
805
- }),
806
- paintColor,
807
- outlineColor,
808
- toggleTextSelected: this.toggleTextSelected,
809
- handleSessionChange: this.handleSessionChange,
810
- stage: this.stage,
811
- onMouseOverElement: this.onMouseOverElement,
812
- onMouseOutElement: this.onMouseOutElement
813
- };
814
- let listeners = {};
815
- if (!disabled) {
816
- listeners = {
817
- onMouseUp: this.handleMouseUp,
818
- onMouseMove: this.handleMouseMove
819
- };
820
- if (!draggable) {
821
- listeners.onMouseDown = this.handleMouseDown;
822
- }
823
- }
824
- return React$8.createElement('div', {
825
- __self: this,
826
- __source: {
827
- fileName: _jsxFileName$8,
828
- lineNumber: 225
829
- }
830
- }, React$8.createElement('div', {
831
- className: classes.undoControls,
832
- __self: this,
833
- __source: {
834
- fileName: _jsxFileName$8,
835
- lineNumber: 226
836
- }
837
- }, React$8.createElement(ButtonStyled, {
838
- disabled: disabled,
839
- onClick: this.handleUndo,
840
- label: "Undo",
841
- __self: this,
842
- __source: {
843
- fileName: _jsxFileName$8,
844
- lineNumber: 227
845
- }
846
- }), React$8.createElement(ButtonStyled, {
847
- disabled: disabled,
848
- onClick: this.handleClearAll,
849
- label: "Clear all",
850
- __self: this,
851
- __source: {
852
- fileName: _jsxFileName$8,
853
- lineNumber: 228
854
- }
855
- })), React$8.createElement('div', {
856
- className: classes.base,
857
- __self: this,
858
- __source: {
859
- fileName: _jsxFileName$8,
860
- lineNumber: 230
861
- }
862
- }, imageUrl && React$8.createElement(ImageBackground, {
863
- dimensions: imageDimensions,
864
- url: imageUrl,
865
- __self: this,
866
- __source: {
867
- fileName: _jsxFileName$8,
868
- lineNumber: 232
869
- }
870
- }), TextEntry.renderTextareas(), React$8.createElement(Stage, {
871
- ref: ref => {
872
- this.stage = ref;
873
- },
874
- className: classnames(classes.stage, {
875
- [classes.active]: draggable && (isOver || newDrawable && newDrawable.length === 1)
876
- }),
877
- height: drawableDimensions.height,
878
- width: drawableDimensions.width,
879
- ...listeners,
880
- __self: this,
881
- __source: {
882
- fileName: _jsxFileName$8,
883
- lineNumber: 237
884
- }
885
- }, React$8.createElement(Layer, {
886
- ref: ref => {
887
- this.layer = ref;
888
- },
889
- __self: this,
890
- __source: {
891
- fileName: _jsxFileName$8,
892
- lineNumber: 250
893
- }
894
- }, drawables.map((drawable, key) => drawable.render({
895
- ...drawableProps,
896
- key
897
- })), TextEntry.render(drawableProps)))));
898
- }
899
- }
900
- const styles$3 = () => ({
901
- base: {
902
- position: 'relative',
903
- width: '100%'
904
- },
905
- stage: {
906
- left: 0,
907
- position: 'absolute',
908
- top: 0
909
- },
910
- active: {
911
- cursor: 'pointer'
912
- },
913
- undoControls: {
914
- float: 'right',
915
- marginTop: -43,
916
- width: 163
917
- }
918
- });
919
- DrawableMain.propTypes = {
920
- classes: PropTypes$3.object.isRequired,
921
- disabled: PropTypes$3.bool,
922
- drawableDimensions: PropTypes$3.object.isRequired,
923
- imageDimensions: PropTypes$3.object.isRequired,
924
- fillColor: PropTypes$3.string.isRequired,
925
- onSessionChange: PropTypes$3.func.isRequired,
926
- paintColor: PropTypes$3.string.isRequired,
927
- outlineColor: PropTypes$3.string.isRequired,
928
- imageUrl: PropTypes$3.string.isRequired,
929
- TextEntry: PropTypes$3.object.isRequired,
930
- toolActive: PropTypes$3.object.isRequired,
931
- session: PropTypes$3.object.isRequired
932
- };
933
- var DrawableMain$1 = withStyles$3(styles$3)(DrawableMain);
934
- const React$9 = _dll_react;
935
- const PropTypes$4 = _dll_prop_types;
936
- const {Transformer: Transformer} = _dll_react_konva;
937
- const _jsxFileName$9 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-transformer.jsx";
938
- class TransformerComponent extends React$9.Component {
939
- componentDidMount() {
940
- this.checkNode();
941
- }
942
- componentDidUpdate() {
943
- this.checkNode();
944
- }
945
- checkNode() {
946
- const stage = this.transformer.getStage();
947
- const {selectedShapeName} = this.props;
948
- const selectedNode = stage.findOne(`.${selectedShapeName}`);
949
- if (selectedNode === this.transformer.node()) {
950
- return;
951
- }
952
- if (selectedNode) {
953
- this.transformer.attachTo(selectedNode);
954
- } else {
955
- this.transformer.detach();
956
- }
957
- this.transformer.getLayer().batchDraw();
958
- }
959
- render() {
960
- return React$9.createElement(Transformer, {
961
- ref: node => {
962
- this.transformer = node;
963
- },
964
- enabledAnchors: ['middle-left', 'middle-right'],
965
- ...this.props,
966
- __self: this,
967
- __source: {
968
- fileName: _jsxFileName$9,
969
- lineNumber: 37
970
- }
971
- });
972
- }
973
- }
974
- TransformerComponent.propTypes = {
975
- selectedShapeName: PropTypes$4.string.isRequired
976
- };
977
- const React$a = _dll_react;
978
- const {Text: Text} = _dll_react_konva;
979
- const _jsxFileName$a = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/drawable-text.jsx";
980
- const generateId = () => Math.random().toString(36).substring(2) + new Date().getTime().toString(36);
981
- class TextDrawable {
982
- static getTextareaNode(id) {
983
- return `textarea_${id}`;
984
- }
985
- static getTextNode(id) {
986
- return `text_${id}`;
987
- }
988
- static getTransformerNode(id) {
989
- return `transformer_${id}`;
990
- }
991
- constructor(props) {
992
- TextDrawable.prototype.__init.call(this);
993
- TextDrawable.prototype.__init2.call(this);
994
- TextDrawable.prototype.__init3.call(this);
995
- TextDrawable.prototype.__init4.call(this);
996
- TextDrawable.prototype.__init5.call(this);
997
- TextDrawable.prototype.__init6.call(this);
998
- TextDrawable.prototype.__init7.call(this);
999
- TextDrawable.prototype.__init8.call(this);
1000
- this.all = props && props.all || [];
1001
- this.eventListenersDetachArray = [];
1002
- }
1003
- __init() {
1004
- this.removeEventListeners = () => this.eventListenersDetachArray.forEach(fn => fn());
1005
- }
1006
- __init2() {
1007
- this.setAll = all => {
1008
- this.all = all;
1009
- this.props.forceUpdate();
1010
- };
1011
- }
1012
- __init3() {
1013
- this.addNewTextEntry = () => {
1014
- const all = this.all;
1015
- const id = generateId();
1016
- all.push({
1017
- id: id,
1018
- isDefault: true,
1019
- label: 'Double click to edit this text. Press Enter to submit.',
1020
- width: 200,
1021
- x: (all.length + 1) * 5 + 50,
1022
- y: (all.length + 1) * 5 + 50,
1023
- textVisible: true,
1024
- transformerVisible: true,
1025
- textareaVisible: false,
1026
- createdAt: new Date(),
1027
- type: 'text-entry'
1028
- });
1029
- this.props.handleSessionChange();
1030
- };
1031
- }
1032
- showOnlyTextNodes() {
1033
- this.all.map(item => {
1034
- item.textVisible = true;
1035
- item.transformerVisible = false;
1036
- item.textareaVisible = false;
1037
- });
1038
- }
1039
- toggleTextarea(id, value) {
1040
- this.all = this.all.map(item => {
1041
- if (item.id === id) {
1042
- return {
1043
- ...item,
1044
- textVisible: !value,
1045
- transformerVisible: !value,
1046
- textareaVisible: value
1047
- };
1048
- }
1049
- return item;
1050
- });
1051
- this.props.forceUpdate();
1052
- }
1053
- initializeDefault(id, isDefault) {
1054
- if (isDefault) {
1055
- const current = this.all.filter(item => item.id === id)[0];
1056
- current.isDefault = false;
1057
- }
1058
- }
1059
- saveValue(id, textNode, textareaNode) {
1060
- if (textareaNode.value) {
1061
- textNode.text(textareaNode.value);
1062
- } else {
1063
- this.all = this.all.filter(text => text.id !== id);
1064
- this.props.forceUpdate();
1065
- }
1066
- this.props.handleSessionChange();
1067
- }
1068
- __init4() {
1069
- this.handleMouseDown = () => this.props.toggleTextSelected(true);
1070
- }
1071
- __init5() {
1072
- this.handleMouseUp = () => this.props.toggleTextSelected(false);
1073
- }
1074
- __init6() {
1075
- this.handleClick = (e, id) => {
1076
- const current = this.all.filter(item => item.id === id)[0];
1077
- current.transformerVisible = true;
1078
- this.props.forceUpdate();
1079
- };
1080
- }
1081
- __init7() {
1082
- this.handleDblClick = (e, text) => {
1083
- const {id, isDefault} = text;
1084
- this.toggleTextarea(id, true);
1085
- const textNode = this[TextDrawable.getTextNode(id)];
1086
- const textareaNode = this[TextDrawable.getTextareaNode(id)];
1087
- const areaPosition = textNode._lastPos;
1088
- textareaNode.value = isDefault ? '' : textNode.text();
1089
- textareaNode.style.position = 'absolute';
1090
- textareaNode.style.top = areaPosition.y + 'px';
1091
- textareaNode.style.left = areaPosition.x + 'px';
1092
- textareaNode.style.width = textNode.width() - textNode.padding() * 2 + 'px';
1093
- textareaNode.style.height = textNode.height() - textNode.padding() * 2 + 5 + 'px';
1094
- textareaNode.style.fontSize = textNode.fontSize() + 'px';
1095
- textareaNode.style.border = 'none';
1096
- textareaNode.style.padding = '0px';
1097
- textareaNode.style.margin = '0px';
1098
- textareaNode.style.overflow = 'hidden';
1099
- textareaNode.style.background = 'none';
1100
- textareaNode.style.outline = 'none';
1101
- textareaNode.style.resize = 'none';
1102
- textareaNode.style.lineHeight = textNode.lineHeight();
1103
- textareaNode.style.fontFamily = textNode.fontFamily();
1104
- textareaNode.style.transformOrigin = 'left top';
1105
- textareaNode.style.textAlign = textNode.align();
1106
- textareaNode.style.color = textNode.fill();
1107
- let rotation = textNode.rotation();
1108
- let transform = '';
1109
- if (rotation) {
1110
- transform += 'rotateZ(' + rotation + 'deg)';
1111
- }
1112
- let px = 0;
1113
- const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
1114
- if (isFirefox) {
1115
- px += 2 + Math.round(textNode.fontSize() / 20);
1116
- }
1117
- transform += 'translateY(-' + px + 'px)';
1118
- textareaNode.style.transform = transform;
1119
- textareaNode.style.height = 'auto';
1120
- textareaNode.style.height = textareaNode.scrollHeight + 3 + 'px';
1121
- textareaNode.focus();
1122
- const keyDownHandler = e => {
1123
- if (e.keyCode === 13 && !e.shiftKey) {
1124
- this.toggleTextarea(id, false);
1125
- this.saveValue(id, textNode, textareaNode);
1126
- }
1127
- if (e.keyCode === 27) {
1128
- this.toggleTextarea(id, false);
1129
- }
1130
- };
1131
- textareaNode.addEventListener('keydown', keyDownHandler);
1132
- this.eventListenersDetachArray.push(() => textareaNode.removeEventListener('keydown', keyDownHandler));
1133
- const blurHandler = () => {
1134
- this.showOnlyTextNodes();
1135
- this.saveValue(id, textNode, textareaNode);
1136
- };
1137
- textareaNode.addEventListener('blur', blurHandler);
1138
- this.eventListenersDetachArray.push(() => textareaNode.removeEventListener('blur', blurHandler));
1139
- this.initializeDefault(id, isDefault);
1140
- this.props.forceUpdate();
1141
- };
1142
- }
1143
- __init8() {
1144
- this.handleTransform = (e, textNode) => {
1145
- this[textNode].setAttrs({
1146
- width: this[textNode].width() * this[textNode].scaleX(),
1147
- scaleX: 1
1148
- });
1149
- };
1150
- }
1151
- renderTextareas() {
1152
- return this.all.map(text => {
1153
- const {id, textareaVisible} = text;
1154
- const textareaNode = `textarea_${id}`;
1155
- return React$a.createElement('textarea', {
1156
- key: textareaNode,
1157
- ref: textarea => {
1158
- this[textareaNode] = textarea;
1159
- },
1160
- style: {
1161
- display: `${textareaVisible ? 'block' : 'none'}`
1162
- },
1163
- __self: this,
1164
- __source: {
1165
- fileName: _jsxFileName$a,
1166
- lineNumber: 206
1167
- }
1168
- });
1169
- });
1170
- }
1171
- setInitialProps(props) {
1172
- if (!this.props) {
1173
- this.props = props;
1174
- }
1175
- }
1176
- render(props) {
1177
- this.setInitialProps(props);
1178
- if (props.stage) {
1179
- const newStage = props.stage;
1180
- if (newStage !== this.stage) {
1181
- const stageClickHandler = e => {
1182
- if (e.target !== this.stage) {
1183
- return;
1184
- }
1185
- this.showOnlyTextNodes();
1186
- this.props.forceUpdate();
1187
- };
1188
- newStage.on('click', stageClickHandler);
1189
- this.eventListenersDetachArray.push(() => newStage.off('click', stageClickHandler));
1190
- }
1191
- this.stage = newStage;
1192
- }
1193
- return this.all.map(text => {
1194
- const {id, label, x, y, width, textVisible, rotation, transformerVisible} = text;
1195
- const textNode = `text_${id}`;
1196
- const transformerNode = `transformer_${id}`;
1197
- let extraProps = {};
1198
- if (!props.disabled) {
1199
- extraProps = {
1200
- onClick: e => this.handleClick(e, id),
1201
- onDblClick: e => this.handleDblClick(e, text),
1202
- onTransform: e => this.handleTransform(e, textNode),
1203
- onTransformEnd: this.props.handleSessionChange,
1204
- onMouseDown: this.handleMouseDown,
1205
- onMouseUp: this.handleMouseUp,
1206
- onDragEnd: this.props.handleSessionChange,
1207
- onMouseEnter: this.props.onMouseOverElement,
1208
- onMouseLeave: this.props.onMouseOutElement
1209
- };
1210
- }
1211
- if (rotation) {
1212
- extraProps.rotation = rotation;
1213
- }
1214
- return [React$a.createElement(Text, {
1215
- key: id,
1216
- bubbles: true,
1217
- id: id,
1218
- ref: text => {
1219
- this[textNode] = text;
1220
- },
1221
- text: text.text || label,
1222
- name: textNode,
1223
- x: x,
1224
- y: y,
1225
- width: width,
1226
- draggable: !props.disabled,
1227
- visible: textVisible,
1228
- fontSize: 16,
1229
- ...extraProps,
1230
- __self: this,
1231
- __source: {
1232
- fileName: _jsxFileName$a,
1233
- lineNumber: 285
1234
- }
1235
- }), transformerVisible && React$a.createElement(TransformerComponent, {
1236
- key: `transformer_${id}`,
1237
- ref: text => {
1238
- this[transformerNode] = text;
1239
- },
1240
- selectedShapeName: textNode,
1241
- onMouseDown: this.handleMouseDown,
1242
- onMouseUp: this.handleMouseUp,
1243
- __self: this,
1244
- __source: {
1245
- fileName: _jsxFileName$a,
1246
- lineNumber: 303
1247
- }
1248
- })];
1249
- });
1250
- }
1251
- }
1252
- const require$$0 = _dll_prop_types;
1253
- const require$$1 = _dll_react;
1254
- var Icon = createCommonjsModule(function (module) {
1255
- module.exports = (function (e) {
1256
- var t = {};
1257
- function r(n) {
1258
- if (t[n]) return t[n].exports;
1259
- var o = t[n] = {
1260
- i: n,
1261
- l: !1,
1262
- exports: {}
1263
- };
1264
- return (e[n].call(o.exports, o, o.exports, r), o.l = !0, o.exports);
1265
- }
1266
- return (r.m = e, r.c = t, r.d = function (e, t, n) {
1267
- r.o(e, t) || Object.defineProperty(e, t, {
1268
- enumerable: !0,
1269
- get: n
1270
- });
1271
- }, r.r = function (e) {
1272
- ("undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
1273
- value: "Module"
1274
- }), Object.defineProperty(e, "__esModule", {
1275
- value: !0
1276
- }));
1277
- }, r.t = function (e, t) {
1278
- if ((1 & t && (e = r(e)), 8 & t)) return e;
1279
- if (4 & t && "object" == typeof e && e && e.__esModule) return e;
1280
- var n = Object.create(null);
1281
- if ((r.r(n), Object.defineProperty(n, "default", {
1282
- enumerable: !0,
1283
- value: e
1284
- }), 2 & t && "string" != typeof e)) for (var o in e) r.d(n, o, (function (t) {
1285
- return e[t];
1286
- }).bind(null, o));
1287
- return n;
1288
- }, r.n = function (e) {
1289
- var t = e && e.__esModule ? function () {
1290
- return e.default;
1291
- } : function () {
1292
- return e;
1293
- };
1294
- return (r.d(t, "a", t), t);
1295
- }, r.o = function (e, t) {
1296
- return Object.prototype.hasOwnProperty.call(e, t);
1297
- }, r.p = "", r(r.s = 2));
1298
- })([function (e, t) {
1299
- e.exports = require$$0;
1300
- }, function (e, t) {
1301
- e.exports = require$$1;
1302
- }, function (e, t, r) {
1303
- r.r(t);
1304
- var n = r(1), o = r(0), l = function () {
1305
- return (l = Object.assign || (function (e) {
1306
- for (var t, r = 1, n = arguments.length; r < n; r++) for (var o in t = arguments[r]) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
1307
- return e;
1308
- })).apply(this, arguments);
1309
- }, i = function (e, t) {
1310
- var r = {};
1311
- for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
1312
- if (null != e && "function" == typeof Object.getOwnPropertySymbols) {
1313
- var o = 0;
1314
- for (n = Object.getOwnPropertySymbols(e); o < n.length; o++) t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
1315
- }
1316
- return r;
1317
- }, a = 0, s = n.forwardRef(function (e, t) {
1318
- var r = e.title, o = void 0 === r ? null : r, s = e.description, c = void 0 === s ? null : s, u = e.size, p = void 0 === u ? null : u, f = e.color, d = void 0 === f ? "currentColor" : f, y = e.horizontal, v = void 0 === y ? null : y, b = e.vertical, m = void 0 === b ? null : b, h = e.rotate, g = void 0 === h ? null : h, O = e.spin, w = void 0 === O ? null : O, j = e.style, z = void 0 === j ? {} : j, E = e.children, P = i(e, ["title", "description", "size", "color", "horizontal", "vertical", "rotate", "spin", "style", "children"]);
1319
- a++;
1320
- var S, x = null !== w && w, _ = n.Children.map(E, function (e) {
1321
- var t = e;
1322
- !0 !== x && (x = !0 === (null === w ? t.props.spin : w));
1323
- var r = t.props.size;
1324
- "number" == typeof p && "number" == typeof t.props.size && (r = t.props.size / p);
1325
- var o = {
1326
- size: r,
1327
- color: null === d ? t.props.color : d,
1328
- horizontal: null === v ? t.props.horizontal : v,
1329
- vertical: null === m ? t.props.vertical : m,
1330
- rotate: null === g ? t.props.rotate : g,
1331
- spin: null === w ? t.props.spin : w,
1332
- inStack: !0
1333
- };
1334
- return n.cloneElement(t, o);
1335
- });
1336
- null !== p && (z.width = "string" == typeof p ? p : 1.5 * p + "rem");
1337
- var k, T = "stack_labelledby_" + a, q = "stack_describedby_" + a;
1338
- if (o) S = c ? T + " " + q : T; else if ((k = "presentation", c)) throw new Error("title attribute required when description is set");
1339
- return n.createElement("svg", l({
1340
- ref: t,
1341
- viewBox: "0 0 24 24",
1342
- style: z,
1343
- role: k,
1344
- "aria-labelledby": S
1345
- }, P), o && n.createElement("title", {
1346
- id: T
1347
- }, o), c && n.createElement("desc", {
1348
- id: q
1349
- }, c), x && n.createElement("style", null, "@keyframes spin { to { transform: rotate(360deg) } }", "@keyframes spin-inverse { to { transform: rotate(-360deg) } }"), _);
1350
- });
1351
- (s.displayName = "Stack", s.propTypes = {
1352
- size: o.oneOfType([o.number, o.string]),
1353
- color: o.string,
1354
- horizontal: o.bool,
1355
- vertical: o.bool,
1356
- rotate: o.number,
1357
- spin: o.oneOfType([o.bool, o.number]),
1358
- children: o.oneOfType([o.arrayOf(o.node), o.node]).isRequired,
1359
- className: o.string,
1360
- style: o.object
1361
- }, s.defaultProps = {
1362
- size: null,
1363
- color: null,
1364
- horizontal: null,
1365
- vertical: null,
1366
- rotate: null,
1367
- spin: null
1368
- });
1369
- var c = s;
1370
- (r.d(t, "Icon", function () {
1371
- return d;
1372
- }), r.d(t, "Stack", function () {
1373
- return c;
1374
- }));
1375
- var u = function () {
1376
- return (u = Object.assign || (function (e) {
1377
- for (var t, r = 1, n = arguments.length; r < n; r++) for (var o in t = arguments[r]) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
1378
- return e;
1379
- })).apply(this, arguments);
1380
- }, p = function (e, t) {
1381
- var r = {};
1382
- for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
1383
- if (null != e && "function" == typeof Object.getOwnPropertySymbols) {
1384
- var o = 0;
1385
- for (n = Object.getOwnPropertySymbols(e); o < n.length; o++) t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
1386
- }
1387
- return r;
1388
- }, f = 0, d = n.forwardRef(function (e, t) {
1389
- var r = e.path, o = e.title, l = void 0 === o ? null : o, i = e.description, a = void 0 === i ? null : i, s = e.size, c = void 0 === s ? null : s, d = e.color, y = void 0 === d ? "currentColor" : d, v = e.horizontal, b = void 0 !== v && v, m = e.vertical, h = void 0 !== m && m, g = e.rotate, O = void 0 === g ? 0 : g, w = e.spin, j = void 0 !== w && w, z = e.style, E = void 0 === z ? {} : z, P = e.inStack, S = void 0 !== P && P, x = p(e, ["path", "title", "description", "size", "color", "horizontal", "vertical", "rotate", "spin", "style", "inStack"]);
1390
- f++;
1391
- var _ = {}, k = [];
1392
- (null !== c && (S ? k.push("scale(" + c + ")") : (E.width = "string" == typeof c ? c : 1.5 * c + "rem", E.height = E.width)), b && k.push("scaleX(-1)"), h && k.push("scaleY(-1)"), 0 !== O && k.push("rotate(" + O + "deg)"), null !== y && (_.fill = y));
1393
- var T = n.createElement("path", u({
1394
- d: r,
1395
- style: _
1396
- }, S ? x : {})), q = T;
1397
- k.length > 0 && (E.transform = k.join(" "), E.transformOrigin = "center", S && (q = n.createElement("g", {
1398
- style: E
1399
- }, T, n.createElement("rect", {
1400
- width: "24",
1401
- height: "24",
1402
- fill: "transparent"
1403
- }))));
1404
- var M, C = q, I = !0 === j || "number" != typeof j ? 2 : j, N = !S && (b || h);
1405
- if ((I < 0 && (N = !N), j && (C = n.createElement("g", {
1406
- style: {
1407
- animation: "spin" + (N ? "-inverse" : "") + " linear " + Math.abs(I) + "s infinite",
1408
- transformOrigin: "center"
1409
- }
1410
- }, q, !(b || h || 0 !== O) && n.createElement("rect", {
1411
- width: "24",
1412
- height: "24",
1413
- fill: "transparent"
1414
- }))), S)) return C;
1415
- var R, B = "icon_labelledby_" + f, X = "icon_describedby_" + f;
1416
- if (l) M = a ? B + " " + X : B; else if ((R = "presentation", a)) throw new Error("title attribute required when description is set");
1417
- return n.createElement("svg", u({
1418
- ref: t,
1419
- viewBox: "0 0 24 24",
1420
- style: E,
1421
- role: R,
1422
- "aria-labelledby": M
1423
- }, x), l && n.createElement("title", {
1424
- id: B
1425
- }, l), a && n.createElement("desc", {
1426
- id: X
1427
- }, a), !S && j && (N ? n.createElement("style", null, "@keyframes spin-inverse { to { transform: rotate(-360deg) } }") : n.createElement("style", null, "@keyframes spin { to { transform: rotate(360deg) } }")), C);
1428
- });
1429
- (d.displayName = "Icon", d.propTypes = {
1430
- path: o.string.isRequired,
1431
- size: o.oneOfType([o.number, o.string]),
1432
- color: o.string,
1433
- horizontal: o.bool,
1434
- vertical: o.bool,
1435
- rotate: o.number,
1436
- spin: o.oneOfType([o.bool, o.number]),
1437
- style: o.object,
1438
- inStack: o.bool,
1439
- className: o.string
1440
- }, d.defaultProps = {
1441
- size: null,
1442
- color: "currentColor",
1443
- horizontal: !1,
1444
- vertical: !1,
1445
- rotate: 0,
1446
- spin: !1
1447
- });
1448
- t.default = d;
1449
- }]);
1450
- });
1451
- var Icon$1 = unwrapExports(Icon);
1452
- var mdiCircle = "M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z";
1453
- var mdiCursorDefault = "M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z";
1454
- var mdiEraser = "M16.24,3.56L21.19,8.5C21.97,9.29 21.97,10.55 21.19,11.34L12,20.53C10.44,22.09 7.91,22.09 6.34,20.53L2.81,17C2.03,16.21 2.03,14.95 2.81,14.16L13.41,3.56C14.2,2.78 15.46,2.78 16.24,3.56M4.22,15.58L7.76,19.11C8.54,19.9 9.8,19.9 10.59,19.11L14.12,15.58L9.17,10.63L4.22,15.58Z";
1455
- var mdiFormatColorFill = "M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z";
1456
- var mdiFormatColorText = "M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z";
1457
- var mdiMinus = "M19,13H5V11H19V13Z";
1458
- var mdiPencil = "M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z";
1459
- var mdiRectangle = "M4,6V19H20V6H4Z";
1460
- const React$b = _dll_react;
1461
- const PropTypes$5 = _dll_prop_types;
1462
- const _jsxFileName$b = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/icon.jsx";
1463
- const IconWrapper = ({path}) => {
1464
- let iconPath;
1465
- switch (path) {
1466
- case 'mdiPencil':
1467
- iconPath = mdiPencil;
1468
- break;
1469
- case 'mdiMinus':
1470
- iconPath = mdiMinus;
1471
- break;
1472
- case 'mdiCircle':
1473
- iconPath = mdiCircle;
1474
- break;
1475
- case 'mdiRectangle':
1476
- iconPath = mdiRectangle;
1477
- break;
1478
- case 'mdiFormatColorText':
1479
- iconPath = mdiFormatColorText;
1480
- break;
1481
- case 'mdiFormatColorFill':
1482
- iconPath = mdiFormatColorFill;
1483
- break;
1484
- case 'mdiEraser':
1485
- iconPath = mdiEraser;
1486
- break;
1487
- default:
1488
- iconPath = mdiCursorDefault;
1489
- break;
1490
- }
1491
- return React$b.createElement(Icon$1, {
1492
- path: iconPath,
1493
- size: 0.8,
1494
- rotate: 180,
1495
- horizontal: true,
1496
- vertical: true,
1497
- color: "#2B3963",
1498
- __self: undefined,
1499
- __source: {
1500
- fileName: _jsxFileName$b,
1501
- lineNumber: 38
1502
- }
1503
- });
1504
- };
1505
- IconWrapper.propTypes = {
1506
- path: PropTypes$5.string.isRequired
1507
- };
1508
- const React$c = _dll_react;
1509
- const {Component: Component} = _dll_react;
1510
- const PropTypes$6 = _dll_prop_types;
1511
- const {withStyles: withStyles$4} = _dll_material_ui__core_styles;
1512
- const _jsxFileName$c = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/container.jsx";
1513
- const {tools: TOOLS} = constants;
1514
- const ROGVAIV = ['red', 'orange', 'yellow', 'violet', 'blue', 'green', 'white', 'black'].map(c => ({
1515
- value: c,
1516
- label: c
1517
- }));
1518
- class Container extends Component {
1519
- static __initStatic() {
1520
- this.propTypes = {
1521
- classes: PropTypes$6.object.isRequired,
1522
- disabled: PropTypes$6.bool,
1523
- session: PropTypes$6.object.isRequired,
1524
- onSessionChange: PropTypes$6.func.isRequired,
1525
- imageDimensions: PropTypes$6.object.isRequired,
1526
- imageUrl: PropTypes$6.string.isRequired
1527
- };
1528
- }
1529
- constructor(props) {
1530
- super(props);
1531
- Container.prototype.__init.call(this);
1532
- const TextEntry = new TextDrawable();
1533
- this.state = {
1534
- drawableDimensions: {
1535
- height: 0,
1536
- width: 0
1537
- },
1538
- toolActive: TOOLS[0],
1539
- fillColor: 'white',
1540
- fillColorList: [{
1541
- value: 'transparent',
1542
- label: 'no fill'
1543
- }, {
1544
- value: 'lightblue',
1545
- label: 'lightblue'
1546
- }, {
1547
- value: 'lightyellow',
1548
- label: 'lightyellow'
1549
- }, ...ROGVAIV],
1550
- outlineColor: 'black',
1551
- outlineColorList: ROGVAIV,
1552
- paintColor: 'red',
1553
- paintColorList: ROGVAIV,
1554
- TextEntry
1555
- };
1556
- }
1557
- setDimensions() {
1558
- const checkExist = setInterval(() => {
1559
- try {
1560
- const {height, width} = this.drawable.getBoundingClientRect();
1561
- if (height !== 0 && width !== 0) {
1562
- this.setState({
1563
- drawableDimensions: {
1564
- height,
1565
- width
1566
- }
1567
- });
1568
- }
1569
- } catch (e) {
1570
- console.warn('setDimensions Error: ', e);
1571
- } finally {
1572
- clearInterval(checkExist);
1573
- }
1574
- }, 100);
1575
- }
1576
- componentDidMount() {
1577
- this.setDimensions();
1578
- }
1579
- componentWillUnmount() {
1580
- const {TextEntry} = this.state;
1581
- TextEntry.removeEventListeners();
1582
- }
1583
- handleMakeToolActive(tool) {
1584
- const {TextEntry} = this.state;
1585
- const {type} = tool;
1586
- if (type !== 'Text') {
1587
- this.setState({
1588
- toolActive: tool
1589
- });
1590
- } else {
1591
- TextEntry.addNewTextEntry();
1592
- this.setState({
1593
- updatedAt: new Date()
1594
- });
1595
- }
1596
- }
1597
- __init() {
1598
- this.checkIfToolIsDisabled = type => {
1599
- if (this.props.disabled) return true;
1600
- const {toolActive} = this.state;
1601
- if (type === 'Text') {
1602
- return false;
1603
- }
1604
- return type === toolActive.type;
1605
- };
1606
- }
1607
- handleColorChange(type, color) {
1608
- const cType = `${type}Color`;
1609
- this.setState({
1610
- [cType]: color
1611
- });
1612
- }
1613
- render() {
1614
- const {classes, disabled, imageUrl, imageDimensions, onSessionChange, session} = this.props;
1615
- const {drawableDimensions, toolActive, fillColor, fillColorList, outlineColor, outlineColorList, paintColor, paintColorList, TextEntry} = this.state;
1616
- return React$c.createElement('div', {
1617
- className: classes.base,
1618
- __self: this,
1619
- __source: {
1620
- fileName: _jsxFileName$c,
1621
- lineNumber: 149
1622
- }
1623
- }, React$c.createElement(DrawablePalette, {
1624
- fillColor: fillColor,
1625
- fillList: fillColorList,
1626
- outlineColor: outlineColor,
1627
- outlineList: outlineColorList,
1628
- paintColor: paintColor,
1629
- paintList: paintColorList,
1630
- onFillColorChange: color => this.handleColorChange('fill', color),
1631
- onOutlineColorChange: color => this.handleColorChange('outline', color),
1632
- onPaintColorChange: color => this.handleColorChange('paint', color),
1633
- __self: this,
1634
- __source: {
1635
- fileName: _jsxFileName$c,
1636
- lineNumber: 150
1637
- }
1638
- }), React$c.createElement('div', {
1639
- className: classes.box,
1640
- __self: this,
1641
- __source: {
1642
- fileName: _jsxFileName$c,
1643
- lineNumber: 164
1644
- }
1645
- }, React$c.createElement('div', {
1646
- className: classes.toolbar,
1647
- __self: this,
1648
- __source: {
1649
- fileName: _jsxFileName$c,
1650
- lineNumber: 165
1651
- }
1652
- }, React$c.createElement('div', {
1653
- __self: this,
1654
- __source: {
1655
- fileName: _jsxFileName$c,
1656
- lineNumber: 166
1657
- }
1658
- }, TOOLS.map(tool => {
1659
- const {type, label, icon} = tool;
1660
- return React$c.createElement(ButtonStyled, {
1661
- title: label,
1662
- key: type,
1663
- disabled: this.checkIfToolIsDisabled(type),
1664
- onClick: () => this.handleMakeToolActive(tool),
1665
- label: React$c.createElement(IconWrapper, {
1666
- path: icon,
1667
- __self: this,
1668
- __source: {
1669
- fileName: _jsxFileName$c,
1670
- lineNumber: 176
1671
- }
1672
- }),
1673
- __self: this,
1674
- __source: {
1675
- fileName: _jsxFileName$c,
1676
- lineNumber: 171
1677
- }
1678
- });
1679
- }))), React$c.createElement('div', {
1680
- ref: drawable => {
1681
- this.drawable = drawable;
1682
- },
1683
- className: classes.drawableHeight,
1684
- __self: this,
1685
- __source: {
1686
- fileName: _jsxFileName$c,
1687
- lineNumber: 183
1688
- }
1689
- }, React$c.createElement(DrawableMain$1, {
1690
- session: session,
1691
- disabled: disabled,
1692
- onSessionChange: onSessionChange,
1693
- fillColor: fillColor,
1694
- outlineColor: outlineColor,
1695
- paintColor: paintColor,
1696
- imageUrl: imageUrl,
1697
- drawableDimensions: drawableDimensions,
1698
- imageDimensions: imageDimensions,
1699
- toolActive: toolActive,
1700
- TextEntry: TextEntry,
1701
- __self: this,
1702
- __source: {
1703
- fileName: _jsxFileName$c,
1704
- lineNumber: 189
1705
- }
1706
- }))));
1707
- }
1708
- }
1709
- Container.__initStatic();
1710
- const styles$4 = theme => ({
1711
- base: {
1712
- marginTop: theme.spacing.unit * 2
1713
- },
1714
- box: {
1715
- border: '1px solid #E0E1E6',
1716
- borderRadius: '5px',
1717
- marginTop: theme.spacing.unit * 2
1718
- },
1719
- drawableHeight: {
1720
- minHeight: 350
1721
- },
1722
- toolbar: {
1723
- backgroundColor: '#ECEDF1',
1724
- borderBottom: '1px solid #E0E1E6',
1725
- borderTopLeftRadius: '5px',
1726
- borderTopRightRadius: '5px',
1727
- display: 'flex',
1728
- justifyContent: 'space-between',
1729
- padding: '12px 8px'
1730
- }
1731
- });
1732
- var Container$1 = withStyles$4(styles$4)(Container);
1733
- const React$d = _dll_react;
1734
- const PropTypes$7 = _dll_prop_types;
1735
- const {Typography: Typography} = _dll_material_ui__core;
1736
- const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
1737
- const {withStyles: withStyles$5} = _dll_material_ui__core_styles;
1738
- const _jsxFileName$d = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/drawing-response/src/drawing-response/index.jsx";
1739
- class DrawingResponseComponent extends React$d.Component {
1740
- constructor(props) {
1741
- super(props);
1742
- this.state = {
1743
- showCorrect: false,
1744
- hasError: false
1745
- };
1746
- }
1747
- static getDerivedStateFromError(error) {
1748
- return {
1749
- hasError: true,
1750
- errorMessage: error.message
1751
- };
1752
- }
1753
- render() {
1754
- const {model: {disabled, imageDimensions, imageUrl, prompt, mode, teacherInstructions}, session, onSessionChange, classes} = this.props;
1755
- const {hasError, errorMessage} = this.state;
1756
- const isEvaluateMode = mode === 'evaluate';
1757
- return hasError ? React$d.createElement('div', {
1758
- __self: this,
1759
- __source: {
1760
- fileName: _jsxFileName$d,
1761
- lineNumber: 40
1762
- }
1763
- }, "An error occured: ", errorMessage) : React$d.createElement('div', {
1764
- __self: this,
1765
- __source: {
1766
- fileName: _jsxFileName$d,
1767
- lineNumber: 42
1768
- }
1769
- }, teacherInstructions && React$d.createElement('div', {
1770
- style: {
1771
- margin: '16px 0'
1772
- },
1773
- __self: this,
1774
- __source: {
1775
- fileName: _jsxFileName$d,
1776
- lineNumber: 44
1777
- }
1778
- }, React$d.createElement(Collapsible, {
1779
- labels: {
1780
- hidden: 'Show Teacher Instructions',
1781
- visible: 'Hide Teacher Instructions'
1782
- },
1783
- __self: this,
1784
- __source: {
1785
- fileName: _jsxFileName$d,
1786
- lineNumber: 45
1787
- }
1788
- }, React$d.createElement('div', {
1789
- dangerouslySetInnerHTML: {
1790
- __html: teacherInstructions
1791
- },
1792
- __self: this,
1793
- __source: {
1794
- fileName: _jsxFileName$d,
1795
- lineNumber: 51
1796
- }
1797
- }))), React$d.createElement('br', {
1798
- __self: this,
1799
- __source: {
1800
- fileName: _jsxFileName$d,
1801
- lineNumber: 55
1802
- }
1803
- }), React$d.createElement(Typography, {
1804
- className: classes.prompt,
1805
- __self: this,
1806
- __source: {
1807
- fileName: _jsxFileName$d,
1808
- lineNumber: 57
1809
- }
1810
- }, React$d.createElement('span', {
1811
- dangerouslySetInnerHTML: {
1812
- __html: prompt
1813
- },
1814
- __self: this,
1815
- __source: {
1816
- fileName: _jsxFileName$d,
1817
- lineNumber: 58
1818
- }
1819
- })), React$d.createElement(Container$1, {
1820
- session: session,
1821
- onSessionChange: onSessionChange,
1822
- isEvaluateMode: isEvaluateMode,
1823
- imageDimensions: imageDimensions,
1824
- imageUrl: imageUrl,
1825
- disabled: disabled,
1826
- __self: this,
1827
- __source: {
1828
- fileName: _jsxFileName$d,
1829
- lineNumber: 61
1830
- }
1831
- }));
1832
- }
1833
- }
1834
- DrawingResponseComponent.propTypes = {
1835
- classes: PropTypes$7.object,
1836
- model: PropTypes$7.object.isRequired,
1837
- onSessionChange: PropTypes$7.func.isRequired,
1838
- session: PropTypes$7.object.isRequired
1839
- };
1840
- const styles$5 = () => ({
1841
- prompt: {
1842
- fontSize: 'inherit'
1843
- }
1844
- });
1845
- var DrawingResponseComponent$1 = withStyles$5(styles$5)(DrawingResponseComponent);
1846
- const React$e = _dll_react;
1847
- const ReactDOM = _dll_react_dom;
1848
- const {isEmpty: isEmpty} = _dll_lodash;
1849
- const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
1850
- const {ModelSetEvent: ModelSetEvent} = _dll_pie_framework__pie_player_events;
1851
- const {SessionChangedEvent: SessionChangedEvent} = _dll_pie_framework__pie_player_events;
1852
- class DrawingResponse extends HTMLElement {
1853
- constructor(...args) {
1854
- super(...args);
1855
- DrawingResponse.prototype.__init.call(this);
1856
- }
1857
- set model(m) {
1858
- this._model = m;
1859
- this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
1860
- this._render();
1861
- }
1862
- isComplete() {
1863
- return this._session && (!isEmpty(this._session.drawables) || !isEmpty(this._session.texts));
1864
- }
1865
- __init() {
1866
- this.sessionChanged = update => {
1867
- this._session.drawables = update.drawables;
1868
- this._session.texts = update.texts;
1869
- this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
1870
- this._render();
1871
- };
1872
- }
1873
- set session(s) {
1874
- this._session = s;
1875
- this._render();
1876
- }
1877
- connectedCallback() {
1878
- this._render();
1879
- }
1880
- _render() {
1881
- if (this._model && this._session) {
1882
- const el = React$e.createElement(DrawingResponseComponent$1, {
1883
- model: this._model,
1884
- session: this._session,
1885
- onSessionChange: this.sessionChanged
1886
- });
1887
- ReactDOM.render(el, this, () => {
1888
- renderMath(this);
1889
- });
1890
- }
1891
- }
1892
- }
1893
- export default DrawingResponse;