@pie-element/drawing-response 4.6.0 → 4.6.1-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.
Files changed (53) hide show
  1. package/configure/package.json +3 -3
  2. package/controller/package.json +1 -1
  3. package/package.json +5 -4
  4. package/configure/lib/button.js +0 -61
  5. package/configure/lib/button.js.map +0 -1
  6. package/configure/lib/defaults.js +0 -56
  7. package/configure/lib/defaults.js.map +0 -1
  8. package/configure/lib/image-container.js +0 -364
  9. package/configure/lib/image-container.js.map +0 -1
  10. package/configure/lib/index.js +0 -188
  11. package/configure/lib/index.js.map +0 -1
  12. package/configure/lib/root.js +0 -256
  13. package/configure/lib/root.js.map +0 -1
  14. package/controller/lib/defaults.js +0 -16
  15. package/controller/lib/defaults.js.map +0 -1
  16. package/controller/lib/index.js +0 -84
  17. package/controller/lib/index.js.map +0 -1
  18. package/lib/drawing-response/button.js +0 -74
  19. package/lib/drawing-response/button.js.map +0 -1
  20. package/lib/drawing-response/constants.js +0 -44
  21. package/lib/drawing-response/constants.js.map +0 -1
  22. package/lib/drawing-response/container.js +0 -342
  23. package/lib/drawing-response/container.js.map +0 -1
  24. package/lib/drawing-response/drawable-circle.js +0 -119
  25. package/lib/drawing-response/drawable-circle.js.map +0 -1
  26. package/lib/drawing-response/drawable-eraser.js +0 -100
  27. package/lib/drawing-response/drawable-eraser.js.map +0 -1
  28. package/lib/drawing-response/drawable-free-path.js +0 -112
  29. package/lib/drawing-response/drawable-free-path.js.map +0 -1
  30. package/lib/drawing-response/drawable-helper.js +0 -46
  31. package/lib/drawing-response/drawable-helper.js.map +0 -1
  32. package/lib/drawing-response/drawable-image.js +0 -60
  33. package/lib/drawing-response/drawable-image.js.map +0 -1
  34. package/lib/drawing-response/drawable-line.js +0 -114
  35. package/lib/drawing-response/drawable-line.js.map +0 -1
  36. package/lib/drawing-response/drawable-main.js +0 -406
  37. package/lib/drawing-response/drawable-main.js.map +0 -1
  38. package/lib/drawing-response/drawable-palette.js +0 -174
  39. package/lib/drawing-response/drawable-palette.js.map +0 -1
  40. package/lib/drawing-response/drawable-rectangle.js +0 -119
  41. package/lib/drawing-response/drawable-rectangle.js.map +0 -1
  42. package/lib/drawing-response/drawable-text.js +0 -378
  43. package/lib/drawing-response/drawable-text.js.map +0 -1
  44. package/lib/drawing-response/drawable-transformer.js +0 -95
  45. package/lib/drawing-response/drawable-transformer.js.map +0 -1
  46. package/lib/drawing-response/factory.js +0 -35
  47. package/lib/drawing-response/factory.js.map +0 -1
  48. package/lib/drawing-response/icon.js +0 -71
  49. package/lib/drawing-response/icon.js.map +0 -1
  50. package/lib/drawing-response/index.js +0 -125
  51. package/lib/drawing-response/index.js.map +0 -1
  52. package/lib/index.js +0 -118
  53. package/lib/index.js.map +0 -1
@@ -1,74 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- var _styles = require("@material-ui/core/styles");
15
-
16
- var _classnames = _interopRequireDefault(require("classnames"));
17
-
18
- var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
19
-
20
- var RawButton = function RawButton(_ref) {
21
- var classes = _ref.classes,
22
- className = _ref.className,
23
- label = _ref.label,
24
- onClick = _ref.onClick,
25
- disabled = _ref.disabled,
26
- title = _ref.title;
27
- return /*#__PURE__*/_react["default"].createElement(_Button["default"], {
28
- title: title,
29
- onClick: onClick,
30
- disabled: disabled,
31
- className: (0, _classnames["default"])(classes.addButton, className),
32
- size: "small",
33
- variant: "contained",
34
- color: "default"
35
- }, label);
36
- };
37
-
38
- RawButton.propTypes = {
39
- classes: _propTypes["default"].object.isRequired,
40
- className: _propTypes["default"].string,
41
- disabled: _propTypes["default"].bool,
42
- label: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object]),
43
- onClick: _propTypes["default"].func,
44
- title: _propTypes["default"].string
45
- };
46
- RawButton.defaultProps = {
47
- className: '',
48
- disabled: false,
49
- label: 'Add',
50
- onClick: function onClick() {},
51
- title: ''
52
- };
53
-
54
- var styles = function styles() {
55
- return {
56
- addButton: {
57
- fontSize: '0.9em',
58
- marginLeft: 8,
59
- minWidth: 32,
60
- height: 32,
61
- '& span': {
62
- '& svg': {
63
- width: '1.3em !important',
64
- height: '1.3em !important'
65
- }
66
- }
67
- }
68
- };
69
- };
70
-
71
- var ButtonStyled = (0, _styles.withStyles)(styles)(RawButton);
72
- var _default = ButtonStyled;
73
- exports["default"] = _default;
74
- //# sourceMappingURL=button.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/drawing-response/button.jsx"],"names":["RawButton","classes","className","label","onClick","disabled","title","addButton","propTypes","PropTypes","object","isRequired","string","bool","oneOfType","func","defaultProps","styles","fontSize","marginLeft","minWidth","height","width","ButtonStyled"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,SAAS,GAAG,SAAZA,SAAY;AAAA,MAAGC,OAAH,QAAGA,OAAH;AAAA,MAAYC,SAAZ,QAAYA,SAAZ;AAAA,MAAuBC,KAAvB,QAAuBA,KAAvB;AAAA,MAA8BC,OAA9B,QAA8BA,OAA9B;AAAA,MAAuCC,QAAvC,QAAuCA,QAAvC;AAAA,MAAiDC,KAAjD,QAAiDA,KAAjD;AAAA,sBAChB,gCAAC,kBAAD;AACE,IAAA,KAAK,EAAEA,KADT;AAEE,IAAA,OAAO,EAAEF,OAFX;AAGE,IAAA,QAAQ,EAAEC,QAHZ;AAIE,IAAA,SAAS,EAAE,4BAAWJ,OAAO,CAACM,SAAnB,EAA8BL,SAA9B,CAJb;AAKE,IAAA,IAAI,EAAC,OALP;AAME,IAAA,OAAO,EAAC,WANV;AAOE,IAAA,KAAK,EAAC;AAPR,KASGC,KATH,CADgB;AAAA,CAAlB;;AAcAH,SAAS,CAACQ,SAAV,GAAsB;AACpBP,EAAAA,OAAO,EAAEQ,sBAAUC,MAAV,CAAiBC,UADN;AAEpBT,EAAAA,SAAS,EAAEO,sBAAUG,MAFD;AAGpBP,EAAAA,QAAQ,EAAEI,sBAAUI,IAHA;AAIpBV,EAAAA,KAAK,EAAEM,sBAAUK,SAAV,CAAoB,CAACL,sBAAUG,MAAX,EAAmBH,sBAAUC,MAA7B,CAApB,CAJa;AAKpBN,EAAAA,OAAO,EAAEK,sBAAUM,IALC;AAMpBT,EAAAA,KAAK,EAAEG,sBAAUG;AANG,CAAtB;AASAZ,SAAS,CAACgB,YAAV,GAAyB;AACvBd,EAAAA,SAAS,EAAE,EADY;AAEvBG,EAAAA,QAAQ,EAAE,KAFa;AAGvBF,EAAAA,KAAK,EAAE,KAHgB;AAIvBC,EAAAA,OAAO,EAAE,mBAAM,CAAE,CAJM;AAKvBE,EAAAA,KAAK,EAAE;AALgB,CAAzB;;AAQA,IAAMW,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO;AACpBV,IAAAA,SAAS,EAAE;AACTW,MAAAA,QAAQ,EAAE,OADD;AAETC,MAAAA,UAAU,EAAE,CAFH;AAGTC,MAAAA,QAAQ,EAAE,EAHD;AAITC,MAAAA,MAAM,EAAE,EAJC;AAMT,gBAAU;AACR,iBAAS;AACPC,UAAAA,KAAK,EAAE,kBADA;AAEPD,UAAAA,MAAM,EAAE;AAFD;AADD;AAND;AADS,GAAP;AAAA,CAAf;;AAgBA,IAAME,YAAY,GAAG,wBAAWN,MAAX,EAAmBjB,SAAnB,CAArB;eAEeuB,Y","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport Button from '@material-ui/core/Button';\n\nconst RawButton = ({ classes, className, label, onClick, disabled, title }) => (\n <Button\n title={title}\n onClick={onClick}\n disabled={disabled}\n className={classNames(classes.addButton, className)}\n size=\"small\"\n variant=\"contained\"\n color=\"default\"\n >\n {label}\n </Button>\n);\n\nRawButton.propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n disabled: PropTypes.bool,\n label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n onClick: PropTypes.func,\n title: PropTypes.string,\n};\n\nRawButton.defaultProps = {\n className: '',\n disabled: false,\n label: 'Add',\n onClick: () => {},\n title: '',\n};\n\nconst styles = () => ({\n addButton: {\n fontSize: '0.9em',\n marginLeft: 8,\n minWidth: 32,\n height: 32,\n\n '& span': {\n '& svg': {\n width: '1.3em !important',\n height: '1.3em !important',\n },\n },\n },\n});\n\nconst ButtonStyled = withStyles(styles)(RawButton);\n\nexport default ButtonStyled;\n"],"file":"button.js"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _default = {
8
- tools: [{
9
- type: 'Select',
10
- label: 'Select',
11
- icon: 'mdiCursorDefault'
12
- }, {
13
- type: 'FreePathDrawable',
14
- label: 'Free Draw',
15
- icon: 'mdiPencil'
16
- }, {
17
- type: 'LineDrawable',
18
- label: 'Line',
19
- icon: 'mdiMinus'
20
- }, {
21
- type: 'RectangleDrawable',
22
- label: 'Rectangle',
23
- icon: 'mdiRectangle'
24
- }, {
25
- type: 'CircleDrawable',
26
- label: 'Circle',
27
- icon: 'mdiCircle'
28
- }, {
29
- type: 'Text',
30
- label: 'Text Entry',
31
- icon: 'mdiFormatColorText'
32
- }, {
33
- // ,{
34
- // type: 'PaintBucket',
35
- // label: 'Paint Bucket',
36
- // icon: 'mdiFormatColorFill'
37
- // },
38
- type: 'EraserDrawable',
39
- label: 'Eraser',
40
- icon: 'mdiEraser'
41
- }]
42
- };
43
- exports["default"] = _default;
44
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/drawing-response/constants.js"],"names":["tools","type","label","icon"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KAAK,EAAE,CACL;AACEC,IAAAA,IAAI,EAAE,QADR;AAEEC,IAAAA,KAAK,EAAE,QAFT;AAGEC,IAAAA,IAAI,EAAE;AAHR,GADK,EAML;AACEF,IAAAA,IAAI,EAAE,kBADR;AAEEC,IAAAA,KAAK,EAAE,WAFT;AAGEC,IAAAA,IAAI,EAAE;AAHR,GANK,EAWL;AACEF,IAAAA,IAAI,EAAE,cADR;AAEEC,IAAAA,KAAK,EAAE,MAFT;AAGEC,IAAAA,IAAI,EAAE;AAHR,GAXK,EAgBL;AACEF,IAAAA,IAAI,EAAE,mBADR;AAEEC,IAAAA,KAAK,EAAE,WAFT;AAGEC,IAAAA,IAAI,EAAE;AAHR,GAhBK,EAqBL;AACEF,IAAAA,IAAI,EAAE,gBADR;AAEEC,IAAAA,KAAK,EAAE,QAFT;AAGEC,IAAAA,IAAI,EAAE;AAHR,GArBK,EA0BL;AACEF,IAAAA,IAAI,EAAE,MADR;AAEEC,IAAAA,KAAK,EAAE,YAFT;AAGEC,IAAAA,IAAI,EAAE;AAHR,GA1BK,EA+BL;AACE;AACA;AACA;AACA;AACA;AACAF,IAAAA,IAAI,EAAE,gBANR;AAOEC,IAAAA,KAAK,EAAE,QAPT;AAQEC,IAAAA,IAAI,EAAE;AARR,GA/BK;AADM,C","sourcesContent":["export default {\n tools: [\n {\n type: 'Select',\n label: 'Select',\n icon: 'mdiCursorDefault',\n },\n {\n type: 'FreePathDrawable',\n label: 'Free Draw',\n icon: 'mdiPencil',\n },\n {\n type: 'LineDrawable',\n label: 'Line',\n icon: 'mdiMinus',\n },\n {\n type: 'RectangleDrawable',\n label: 'Rectangle',\n icon: 'mdiRectangle',\n },\n {\n type: 'CircleDrawable',\n label: 'Circle',\n icon: 'mdiCircle',\n },\n {\n type: 'Text',\n label: 'Text Entry',\n icon: 'mdiFormatColorText',\n },\n {\n // ,{\n // type: 'PaintBucket',\n // label: 'Paint Bucket',\n // icon: 'mdiFormatColorFill'\n // },\n type: 'EraserDrawable',\n label: 'Eraser',\n icon: 'mdiEraser',\n },\n ],\n};\n"],"file":"constants.js"}
@@ -1,342 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = exports.Container = void 0;
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
-
22
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
23
-
24
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
25
-
26
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
-
28
- var _react = _interopRequireWildcard(require("react"));
29
-
30
- var _propTypes = _interopRequireDefault(require("prop-types"));
31
-
32
- var _styles = require("@material-ui/core/styles");
33
-
34
- var _constants = _interopRequireDefault(require("./constants"));
35
-
36
- var _button = _interopRequireDefault(require("./button"));
37
-
38
- var _drawablePalette = _interopRequireDefault(require("./drawable-palette"));
39
-
40
- var _drawableMain = _interopRequireDefault(require("./drawable-main"));
41
-
42
- var _drawableText = _interopRequireDefault(require("./drawable-text"));
43
-
44
- var _icon = _interopRequireDefault(require("./icon"));
45
-
46
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
47
-
48
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
49
-
50
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
51
-
52
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
-
54
- var TOOLS = _constants["default"].tools;
55
- var ROGVAIV = ['red', 'orange', 'yellow', 'violet', 'blue', 'green', 'white', 'black'].map(function (c) {
56
- return {
57
- value: c,
58
- label: c
59
- };
60
- });
61
-
62
- var Container = /*#__PURE__*/function (_Component) {
63
- (0, _inherits2["default"])(Container, _Component);
64
-
65
- var _super = _createSuper(Container);
66
-
67
- function Container(props) {
68
- var _this;
69
-
70
- (0, _classCallCheck2["default"])(this, Container);
71
- _this = _super.call(this, props);
72
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "checkIfToolIsDisabled", function (type) {
73
- if (_this.props.disabled) return true;
74
- var toolActive = _this.state.toolActive; // Text will never be disabled since on each "Text Entry" click a new text is added
75
-
76
- if (type === 'Text') {
77
- return false;
78
- }
79
-
80
- return type === toolActive.type;
81
- });
82
- var TextEntry = new _drawableText["default"]();
83
- _this.state = {
84
- scale: 1,
85
- drawableDimensions: {
86
- height: 0,
87
- width: 0
88
- },
89
- toolActive: TOOLS[0],
90
- fillColor: 'white',
91
- fillColorList: [{
92
- value: 'transparent',
93
- label: 'no fill'
94
- }, {
95
- value: 'lightblue',
96
- label: 'light blue'
97
- }, {
98
- value: 'lightyellow',
99
- label: 'light yellow'
100
- }].concat((0, _toConsumableArray2["default"])(ROGVAIV)),
101
- outlineColor: 'black',
102
- outlineColorList: ROGVAIV,
103
- paintColor: 'red',
104
- paintColorList: ROGVAIV,
105
- TextEntry: TextEntry
106
- };
107
- return _this;
108
- }
109
-
110
- (0, _createClass2["default"])(Container, [{
111
- key: "setDimensions",
112
- value: function setDimensions() {
113
- var _this2 = this;
114
-
115
- var checkExist = setInterval(function () {
116
- try {
117
- var _this2$drawable$getBo = _this2.drawable.getBoundingClientRect(),
118
- height = _this2$drawable$getBo.height,
119
- width = _this2$drawable$getBo.width;
120
-
121
- if (height !== 0 && width !== 0) {
122
- _this2.setState({
123
- drawableDimensions: {
124
- height: height,
125
- width: width
126
- }
127
- });
128
- }
129
- } catch (e) {
130
- // eslint-disable-next-line no-console
131
- console.warn('setDimensions Error: ', e);
132
- } finally {
133
- clearInterval(checkExist);
134
- }
135
- }, 100);
136
- }
137
- }, {
138
- key: "componentDidMount",
139
- value: function componentDidMount() {
140
- var _this3 = this;
141
-
142
- this.setDimensions();
143
- this.observer = new MutationObserver(function (mutations) {
144
- mutations.forEach(function () {
145
- var _document$getElementB, _document$getElementB2;
146
-
147
- var target = (_document$getElementB = document.getElementById('question-container')) === null || _document$getElementB === void 0 ? void 0 : (_document$getElementB2 = _document$getElementB.style) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.cssText;
148
- var zoom = target === null || target === void 0 ? void 0 : target.substring(target.indexOf('--pie-zoom') + 11, target.lastIndexOf('%'));
149
- var zoomParsed = zoom === null || zoom === void 0 ? void 0 : zoom.replace(/\s/g, '');
150
-
151
- if (zoomParsed) {
152
- var newScale = parseFloat(zoomParsed) / 100;
153
-
154
- if (newScale !== _this3.state.scale) {
155
- _this3.setState({
156
- scale: parseFloat(zoomParsed) / 100
157
- });
158
- }
159
- } else if (!zoomParsed && _this3.state.scale !== 1) {
160
- _this3.setState({
161
- scale: 1
162
- });
163
- }
164
- });
165
- });
166
- var target = document.getElementById('question-container');
167
-
168
- if (target) {
169
- this.observer.observe(target, {
170
- attributes: true,
171
- attributeFilter: ['style']
172
- });
173
- }
174
- }
175
- }, {
176
- key: "componentWillUnmount",
177
- value: function componentWillUnmount() {
178
- var _this$observer;
179
-
180
- var TextEntry = this.state.TextEntry;
181
- TextEntry.removeEventListeners();
182
- (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.disconnect();
183
- }
184
- }, {
185
- key: "handleMakeToolActive",
186
- value: function handleMakeToolActive(tool) {
187
- var TextEntry = this.state.TextEntry;
188
- var type = tool.type;
189
-
190
- if (type !== 'Text') {
191
- this.setState({
192
- toolActive: tool
193
- });
194
- } else {
195
- TextEntry.addNewTextEntry(); // Force update
196
-
197
- this.setState({
198
- updatedAt: new Date()
199
- });
200
- }
201
- }
202
- }, {
203
- key: "handleColorChange",
204
- value: function handleColorChange(type, color) {
205
- var cType = "".concat(type, "Color");
206
- this.setState((0, _defineProperty2["default"])({}, cType, color));
207
- }
208
- }, {
209
- key: "render",
210
- value: function render() {
211
- var _this4 = this;
212
-
213
- var _this$props = this.props,
214
- classes = _this$props.classes,
215
- disabled = _this$props.disabled,
216
- imageUrl = _this$props.imageUrl,
217
- imageDimensions = _this$props.imageDimensions,
218
- onSessionChange = _this$props.onSessionChange,
219
- session = _this$props.session,
220
- backgroundImageEnabled = _this$props.backgroundImageEnabled;
221
- var _this$state = this.state,
222
- drawableDimensions = _this$state.drawableDimensions,
223
- toolActive = _this$state.toolActive,
224
- fillColor = _this$state.fillColor,
225
- fillColorList = _this$state.fillColorList,
226
- outlineColor = _this$state.outlineColor,
227
- outlineColorList = _this$state.outlineColorList,
228
- paintColor = _this$state.paintColor,
229
- paintColorList = _this$state.paintColorList,
230
- TextEntry = _this$state.TextEntry;
231
- var heightToUse = drawableDimensions.height * this.state.scale;
232
- return /*#__PURE__*/_react["default"].createElement("div", {
233
- className: classes.base
234
- }, !disabled && /*#__PURE__*/_react["default"].createElement(_drawablePalette["default"], {
235
- fillColor: fillColor,
236
- fillList: fillColorList,
237
- outlineColor: outlineColor,
238
- outlineList: outlineColorList,
239
- paintColor: paintColor,
240
- paintList: paintColorList,
241
- onFillColorChange: function onFillColorChange(color) {
242
- return _this4.handleColorChange('fill', color);
243
- },
244
- onOutlineColorChange: function onOutlineColorChange(color) {
245
- return _this4.handleColorChange('outline', color);
246
- },
247
- onPaintColorChange: function onPaintColorChange(color) {
248
- return _this4.handleColorChange('paint', color);
249
- }
250
- }), /*#__PURE__*/_react["default"].createElement("div", {
251
- className: classes.box
252
- }, /*#__PURE__*/_react["default"].createElement("div", {
253
- className: classes.toolbar
254
- }, TOOLS.map(function (tool) {
255
- var type = tool.type,
256
- label = tool.label,
257
- icon = tool.icon;
258
- return /*#__PURE__*/_react["default"].createElement(_button["default"], {
259
- title: label,
260
- key: type,
261
- disabled: _this4.checkIfToolIsDisabled(type),
262
- onClick: function onClick() {
263
- return _this4.handleMakeToolActive(tool);
264
- },
265
- label: /*#__PURE__*/_react["default"].createElement(_icon["default"], {
266
- path: icon
267
- })
268
- });
269
- })), /*#__PURE__*/_react["default"].createElement("div", {
270
- ref: function ref(drawable) {
271
- _this4.drawable = drawable;
272
- },
273
- className: classes.drawableHeight,
274
- style: {
275
- height: heightToUse,
276
- maxHeight: heightToUse
277
- }
278
- }, /*#__PURE__*/_react["default"].createElement(_drawableMain["default"], {
279
- scale: this.state.scale,
280
- session: session,
281
- disabled: disabled,
282
- onSessionChange: onSessionChange,
283
- fillColor: fillColor,
284
- outlineColor: outlineColor,
285
- paintColor: paintColor,
286
- imageUrl: imageUrl,
287
- drawableDimensions: drawableDimensions,
288
- imageDimensions: imageDimensions,
289
- toolActive: toolActive,
290
- TextEntry: TextEntry,
291
- backgroundImageEnabled: backgroundImageEnabled
292
- }))));
293
- }
294
- }]);
295
- return Container;
296
- }(_react.Component);
297
-
298
- exports.Container = Container;
299
- (0, _defineProperty2["default"])(Container, "propTypes", {
300
- classes: _propTypes["default"].object.isRequired,
301
- disabled: _propTypes["default"].bool,
302
- session: _propTypes["default"].object.isRequired,
303
- onSessionChange: _propTypes["default"].func.isRequired,
304
- imageDimensions: _propTypes["default"].object.isRequired,
305
- imageUrl: _propTypes["default"].string.isRequired,
306
- backgroundImageEnabled: _propTypes["default"].bool.isRequired
307
- });
308
-
309
- var styles = function styles(theme) {
310
- return {
311
- base: {
312
- marginTop: theme.spacing.unit * 2
313
- },
314
- box: {
315
- border: '1px solid #E0E1E6',
316
- borderRadius: '5px',
317
- marginTop: theme.spacing.unit * 2,
318
- backgroundColor: '#ECEDF1'
319
- },
320
- drawableHeight: {
321
- minHeight: 350,
322
- backgroundColor: '#fff'
323
- },
324
- toolbar: {
325
- borderBottom: '1px solid #E0E1E6',
326
- borderTopLeftRadius: '5px',
327
- borderTopRightRadius: '5px',
328
- padding: '12px 8px 4px',
329
- boxSizing: 'border-box',
330
- maxWidth: 'calc(100% - 163px)',
331
- // 163px is the width set on undoControls
332
- '& button': {
333
- marginBottom: '8px'
334
- }
335
- }
336
- };
337
- };
338
-
339
- var _default = (0, _styles.withStyles)(styles)(Container);
340
-
341
- exports["default"] = _default;
342
- //# sourceMappingURL=container.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/drawing-response/container.jsx"],"names":["TOOLS","constants","tools","ROGVAIV","map","c","value","label","Container","props","type","disabled","toolActive","state","TextEntry","DrawableText","scale","drawableDimensions","height","width","fillColor","fillColorList","outlineColor","outlineColorList","paintColor","paintColorList","checkExist","setInterval","drawable","getBoundingClientRect","setState","e","console","warn","clearInterval","setDimensions","observer","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","removeEventListeners","disconnect","tool","addNewTextEntry","updatedAt","Date","color","cType","classes","imageUrl","imageDimensions","onSessionChange","session","backgroundImageEnabled","heightToUse","base","handleColorChange","box","toolbar","icon","checkIfToolIsDisabled","handleMakeToolActive","drawableHeight","maxHeight","Component","PropTypes","object","isRequired","bool","func","string","styles","theme","marginTop","spacing","unit","border","borderRadius","backgroundColor","minHeight","borderBottom","borderTopLeftRadius","borderTopRightRadius","padding","boxSizing","maxWidth","marginBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAeA,KAAf,GAAyBC,qBAAzB,CAAQC,KAAR;AAEA,IAAMC,OAAO,GAAG,CAAC,KAAD,EAAQ,QAAR,EAAkB,QAAlB,EAA4B,QAA5B,EAAsC,MAAtC,EAA8C,OAA9C,EAAuD,OAAvD,EAAgE,OAAhE,EAAyEC,GAAzE,CAA6E,UAACC,CAAD;AAAA,SAAQ;AACnGC,IAAAA,KAAK,EAAED,CAD4F;AAEnGE,IAAAA,KAAK,EAAEF;AAF4F,GAAR;AAAA,CAA7E,CAAhB;;IAKaG,S;;;;;AAWX,qBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,8GAqGK,UAACC,IAAD,EAAU;AAChC,UAAI,MAAKD,KAAL,CAAWE,QAAf,EAAyB,OAAO,IAAP;AAEzB,UAAQC,UAAR,GAAuB,MAAKC,KAA5B,CAAQD,U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MPC,MAAAA,QAAQ,EAAE,oBANH;AAMyB;AAChC,kBAAY;AACVC,QAAAA,YAAY,EAAE;AADJ;AAPL;AAdgB,GAAZ;AAAA,CAAf;;eA2Be,wBAAWf,MAAX,EAAmB/E,SAAnB,C","sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport constants from './constants';\nimport Button from './button';\nimport DrawablePalette from './drawable-palette';\nimport DrawableMain from './drawable-main';\nimport DrawableText from './drawable-text';\nimport Icon from './icon';\n\nconst { tools: TOOLS } = constants;\n\nconst ROGVAIV = ['red', 'orange', 'yellow', 'violet', 'blue', 'green', 'white', 'black'].map((c) => ({\n value: c,\n label: c,\n}));\n\nexport class Container extends Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n disabled: PropTypes.bool,\n session: PropTypes.object.isRequired,\n onSessionChange: PropTypes.func.isRequired,\n imageDimensions: PropTypes.object.isRequired,\n imageUrl: PropTypes.string.isRequired,\n backgroundImageEnabled: PropTypes.bool.isRequired,\n };\n\n constructor(props) {\n super(props);\n const TextEntry = new DrawableText();\n\n this.state = {\n scale: 1,\n drawableDimensions: {\n height: 0,\n width: 0,\n },\n toolActive: TOOLS[0],\n fillColor: 'white',\n fillColorList: [\n { value: 'transparent', label: 'no fill' },\n { value: 'lightblue', label: 'light blue' },\n { value: 'lightyellow', label: 'light yellow' },\n ...ROGVAIV,\n ],\n outlineColor: 'black',\n outlineColorList: ROGVAIV,\n paintColor: 'red',\n paintColorList: ROGVAIV,\n TextEntry,\n };\n }\n\n setDimensions() {\n const checkExist = setInterval(() => {\n try {\n const { height, width } = this.drawable.getBoundingClientRect();\n if (height !== 0 && width !== 0) {\n this.setState({\n drawableDimensions: {\n height,\n width,\n },\n });\n }\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn('setDimensions Error: ', e);\n } finally {\n clearInterval(checkExist);\n }\n }, 100);\n }\n\n componentDidMount() {\n this.setDimensions();\n\n this.observer = new MutationObserver((mutations) => {\n mutations.forEach(() => {\n const target = document.getElementById('question-container')?.style?.cssText;\n const zoom = target?.substring(target.indexOf('--pie-zoom') + 11, target.lastIndexOf('%'));\n const zoomParsed = zoom?.replace(/\\s/g, '');\n\n if (zoomParsed) {\n const newScale = parseFloat(zoomParsed) / 100;\n if (newScale !== this.state.scale) {\n this.setState({\n scale: parseFloat(zoomParsed) / 100,\n });\n }\n } else if (!zoomParsed && this.state.scale !== 1) {\n this.setState({\n scale: 1,\n });\n }\n });\n });\n\n const target = document.getElementById('question-container');\n if (target) {\n this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });\n }\n }\n\n componentWillUnmount() {\n const { TextEntry } = this.state;\n\n TextEntry.removeEventListeners();\n this.observer?.disconnect();\n }\n\n handleMakeToolActive(tool) {\n const { TextEntry } = this.state;\n const { type } = tool;\n\n if (type !== 'Text') {\n this.setState({\n toolActive: tool,\n });\n } else {\n TextEntry.addNewTextEntry();\n // Force update\n this.setState({\n updatedAt: new Date(),\n });\n }\n }\n\n checkIfToolIsDisabled = (type) => {\n if (this.props.disabled) return true;\n\n const { toolActive } = this.state;\n // Text will never be disabled since on each \"Text Entry\" click a new text is added\n if (type === 'Text') {\n return false;\n }\n return type === toolActive.type;\n };\n\n handleColorChange(type, color) {\n const cType = `${type}Color`;\n this.setState({\n [cType]: color,\n });\n }\n\n render() {\n const { classes, disabled, imageUrl, imageDimensions, onSessionChange, session, backgroundImageEnabled } =\n this.props;\n const {\n drawableDimensions,\n toolActive,\n fillColor,\n fillColorList,\n outlineColor,\n outlineColorList,\n paintColor,\n paintColorList,\n TextEntry,\n } = this.state;\n\n const heightToUse = drawableDimensions.height * this.state.scale;\n\n return (\n <div className={classes.base}>\n {!disabled && (\n <DrawablePalette\n fillColor={fillColor}\n fillList={fillColorList}\n outlineColor={outlineColor}\n outlineList={outlineColorList}\n paintColor={paintColor}\n paintList={paintColorList}\n onFillColorChange={(color) => this.handleColorChange('fill', color)}\n onOutlineColorChange={(color) => this.handleColorChange('outline', color)}\n onPaintColorChange={(color) => this.handleColorChange('paint', color)}\n />\n )}\n\n <div className={classes.box}>\n <div className={classes.toolbar}>\n {TOOLS.map((tool) => {\n const { type, label, icon } = tool;\n\n return (\n <Button\n title={label}\n key={type}\n disabled={this.checkIfToolIsDisabled(type)}\n onClick={() => this.handleMakeToolActive(tool)}\n label={<Icon path={icon} />}\n />\n );\n })}\n </div>\n\n <div\n ref={(drawable) => {\n this.drawable = drawable;\n }}\n className={classes.drawableHeight}\n style={{ height: heightToUse, maxHeight: heightToUse }}\n >\n <DrawableMain\n scale={this.state.scale}\n session={session}\n disabled={disabled}\n onSessionChange={onSessionChange}\n fillColor={fillColor}\n outlineColor={outlineColor}\n paintColor={paintColor}\n imageUrl={imageUrl}\n drawableDimensions={drawableDimensions}\n imageDimensions={imageDimensions}\n toolActive={toolActive}\n TextEntry={TextEntry}\n backgroundImageEnabled={backgroundImageEnabled}\n />\n </div>\n </div>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n base: {\n marginTop: theme.spacing.unit * 2,\n },\n box: {\n border: '1px solid #E0E1E6',\n borderRadius: '5px',\n marginTop: theme.spacing.unit * 2,\n backgroundColor: '#ECEDF1',\n },\n drawableHeight: {\n minHeight: 350,\n backgroundColor: '#fff',\n },\n toolbar: {\n borderBottom: '1px solid #E0E1E6',\n borderTopLeftRadius: '5px',\n borderTopRightRadius: '5px',\n padding: '12px 8px 4px',\n boxSizing: 'border-box',\n maxWidth: 'calc(100% - 163px)', // 163px is the width set on undoControls\n '& button': {\n marginBottom: '8px',\n },\n },\n});\n\nexport default withStyles(styles)(Container);\n"],"file":"container.js"}
@@ -1,119 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
- var _react = _interopRequireDefault(require("react"));
25
-
26
- var _reactKonva = require("react-konva");
27
-
28
- var _drawableHelper = _interopRequireDefault(require("./drawable-helper"));
29
-
30
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
31
-
32
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
-
34
- var CircleDrawable = /*#__PURE__*/function (_DrawableHelper) {
35
- (0, _inherits2["default"])(CircleDrawable, _DrawableHelper);
36
-
37
- var _super = _createSuper(CircleDrawable);
38
-
39
- function CircleDrawable(_props) {
40
- var _this;
41
-
42
- (0, _classCallCheck2["default"])(this, CircleDrawable);
43
- _this = _super.call(this, _props, CircleDrawable.TYPE);
44
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDragEnd", function (props, event) {
45
- var deltaX = _this.startx - event.target.getX();
46
- var deltaY = _this.starty - event.target.getY();
47
- _this.startx = event.target.getX();
48
- _this.starty = event.target.getY();
49
- _this.x = _this.x - deltaX;
50
- _this.y = _this.y - deltaY;
51
- props.handleSessionChange();
52
- });
53
- var startx = _props.startx,
54
- starty = _props.starty,
55
- x = _props.x,
56
- y = _props.y;
57
- _this.startx = startx;
58
- _this.starty = starty;
59
- _this.x = x || startx;
60
- _this.y = y || starty;
61
- var dx = _this.startx - _this.x;
62
- var dy = _this.starty - _this.y;
63
- _this.radius = Math.sqrt(dx * dx + dy * dy);
64
- return _this;
65
- }
66
-
67
- (0, _createClass2["default"])(CircleDrawable, [{
68
- key: "registerMovement",
69
- value: function registerMovement(x, y) {
70
- this.x = x;
71
- this.y = y;
72
- var dx = this.startx - this.x;
73
- var dy = this.starty - this.y;
74
- this.radius = Math.sqrt(dx * dx + dy * dy);
75
- }
76
- }, {
77
- key: "handleOnClick",
78
- value: function handleOnClick(props) {
79
- var paint = props.paint,
80
- paintColor = props.paintColor,
81
- forceUpdate = props.forceUpdate;
82
-
83
- if (paint) {
84
- this.paintColor = paintColor;
85
- forceUpdate();
86
- }
87
- }
88
- }, {
89
- key: "render",
90
- value: function render(props) {
91
- var _this2 = this;
92
-
93
- var draggable = props.draggable,
94
- key = props.key,
95
- onMouseOverElement = props.onMouseOverElement,
96
- onMouseOutElement = props.onMouseOutElement;
97
- return /*#__PURE__*/_react["default"].createElement(_reactKonva.Circle, {
98
- key: key,
99
- draggable: draggable,
100
- radius: this.radius,
101
- x: this.startx,
102
- y: this.starty,
103
- fill: this.paintColor || this.fillColor,
104
- onClick: function onClick() {
105
- return _this2.handleOnClick(props);
106
- },
107
- onDragEnd: this.handleDragEnd.bind(this, props),
108
- onMouseEnter: onMouseOverElement,
109
- onMouseLeave: onMouseOutElement,
110
- stroke: this.outlineColor
111
- });
112
- }
113
- }]);
114
- return CircleDrawable;
115
- }(_drawableHelper["default"]);
116
-
117
- exports["default"] = CircleDrawable;
118
- (0, _defineProperty2["default"])(CircleDrawable, "TYPE", 'CircleDrawable');
119
- //# sourceMappingURL=drawable-circle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/drawing-response/drawable-circle.jsx"],"names":["CircleDrawable","props","TYPE","event","deltaX","startx","target","getX","deltaY","starty","getY","x","y","handleSessionChange","dx","dy","radius","Math","sqrt","paint","paintColor","forceUpdate","draggable","key","onMouseOverElement","onMouseOutElement","fillColor","handleOnClick","handleDragEnd","bind","outlineColor","DrawableHelper"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;IAEqBA,c;;;;;AAEnB,0BAAYC,MAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,MAAN,EAAaD,cAAc,CAACE,IAA5B;AADiB,sGAkCH,UAACD,KAAD,EAAQE,KAAR,EAAkB;AAChC,UAAMC,MAAM,GAAG,MAAKC,MAAL,GAAcF,KAAK,CAACG,MAAN,CAAaC,IAAb,EAA7B;AACA,UAAMC,MAAM,GAAG,MAAKC,MAAL,GAAcN,KAAK,CAACG,MAAN,CAAaI,IAAb,EAA7B;AAEA,YAAKL,MAAL,GAAcF,KAAK,CAACG,MAAN,CAAaC,IAAb,EAAd;AACA,YAAKE,MAAL,GAAcN,KAAK,CAACG,MAAN,CAAaI,IAAb,EAAd;AAEA,YAAKC,CAAL,GAAS,MAAKA,CAAL,GAASP,MAAlB;AACA,YAAKQ,CAAL,GAAS,MAAKA,CAAL,GAASJ,MAAlB;AAEAP,MAAAA,KAAK,CAACY,mBAAN;AACD,KA7CkB;AAEjB,QAAQR,MAAR,GAAiCJ,MAAjC,CAAQI,MAAR;AAAA,QAAgBI,MAAhB,GAAiCR,MAAjC,CAAgBQ,MAAhB;AAAA,QAAwBE,CAAxB,GAAiCV,MAAjC,CAAwBU,CAAxB;AAAA,QAA2BC,CAA3B,GAAiCX,MAAjC,CAA2BW,CAA3B;AAEA,UAAKP,MAAL,GAAcA,MAAd;AACA,UAAKI,MAAL,GAAcA,MAAd;AACA,UAAKE,CAAL,GAAS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QAAA,SAAS,EAAED,SAFb;AAGE,QAAA,MAAM,EAAE,KAAKN,MAHf;AAIE,QAAA,CAAC,EAAE,KAAKX,MAJV;AAKE,QAAA,CAAC,EAAE,KAAKI,MALV;AAME,QAAA,IAAI,EAAE,KAAKW,UAAL,IAAmB,KAAKM,SANhC;AAOE,QAAA,OAAO,EAAE;AAAA,iBAAM,MAAI,CAACC,aAAL,CAAmB1B,KAAnB,CAAN;AAAA,SAPX;AAQE,QAAA,SAAS,EAAE,KAAK2B,aAAL,CAAmBC,IAAnB,CAAwB,IAAxB,EAA8B5B,KAA9B,CARb;AASE,QAAA,YAAY,EAAEuB,kBAThB;AAUE,QAAA,YAAY,EAAEC,iBAVhB;AAWE,QAAA,MAAM,EAAE,KAAKK;AAXf,QADF;AAeD;;;EAnEyCC,0B;;;iCAAvB/B,c,UACL,gB","sourcesContent":["import React from 'react';\nimport { Circle } from 'react-konva';\n\nimport DrawableHelper from './drawable-helper';\n\nexport default class CircleDrawable extends DrawableHelper {\n static TYPE = 'CircleDrawable';\n constructor(props) {\n super(props, CircleDrawable.TYPE);\n const { startx, starty, x, y } = props;\n\n this.startx = startx;\n this.starty = starty;\n this.x = x || startx;\n this.y = y || starty;\n\n const dx = this.startx - this.x;\n const dy = this.starty - this.y;\n\n this.radius = Math.sqrt(dx * dx + dy * dy);\n }\n\n registerMovement(x, y) {\n this.x = x;\n this.y = y;\n\n const dx = this.startx - this.x;\n const dy = this.starty - this.y;\n\n this.radius = Math.sqrt(dx * dx + dy * dy);\n }\n\n handleOnClick(props) {\n const { paint, paintColor, forceUpdate } = props;\n\n if (paint) {\n this.paintColor = paintColor;\n forceUpdate();\n }\n }\n\n handleDragEnd = (props, event) => {\n const deltaX = this.startx - event.target.getX();\n const deltaY = this.starty - event.target.getY();\n\n this.startx = event.target.getX();\n this.starty = event.target.getY();\n\n this.x = this.x - deltaX;\n this.y = this.y - deltaY;\n\n props.handleSessionChange();\n };\n\n render(props) {\n const { draggable, key, onMouseOverElement, onMouseOutElement } = props;\n\n return (\n <Circle\n key={key}\n draggable={draggable}\n radius={this.radius}\n x={this.startx}\n y={this.starty}\n fill={this.paintColor || this.fillColor}\n onClick={() => this.handleOnClick(props)}\n onDragEnd={this.handleDragEnd.bind(this, props)}\n onMouseEnter={onMouseOverElement}\n onMouseLeave={onMouseOutElement}\n stroke={this.outlineColor}\n />\n );\n }\n}\n"],"file":"drawable-circle.js"}