@pie-element/hotspot 6.3.2-next.18 → 6.3.2-next.22

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 (51) hide show
  1. package/configure/lib/DeleteWidget.js +19 -14
  2. package/configure/lib/DeleteWidget.js.map +1 -1
  3. package/configure/lib/buttons/circle.js +1 -1
  4. package/configure/lib/buttons/circle.js.map +1 -1
  5. package/configure/lib/defaults.js +2 -1
  6. package/configure/lib/defaults.js.map +1 -1
  7. package/configure/lib/hotspot-circle.js +229 -0
  8. package/configure/lib/hotspot-circle.js.map +1 -0
  9. package/configure/lib/hotspot-container.js +18 -7
  10. package/configure/lib/hotspot-container.js.map +1 -1
  11. package/configure/lib/hotspot-drawable.js +41 -14
  12. package/configure/lib/hotspot-drawable.js.map +1 -1
  13. package/configure/lib/hotspot-polygon.js +1 -2
  14. package/configure/lib/hotspot-polygon.js.map +1 -1
  15. package/configure/lib/hotspot-rectangle.js +0 -1
  16. package/configure/lib/hotspot-rectangle.js.map +1 -1
  17. package/configure/lib/index.js +8 -1
  18. package/configure/lib/index.js.map +1 -1
  19. package/configure/lib/shapes/circle.js +29 -10
  20. package/configure/lib/shapes/circle.js.map +1 -1
  21. package/configure/lib/utils.js +14 -1
  22. package/configure/lib/utils.js.map +1 -1
  23. package/configure/src/DeleteWidget.jsx +16 -8
  24. package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +25 -0
  25. package/configure/src/__tests__/__snapshots__/hotspot-drawable.test.js.snap +0 -9
  26. package/configure/src/__tests__/__snapshots__/root.test.js.snap +18 -0
  27. package/configure/src/__tests__/hotspot-container.test.js +58 -3
  28. package/configure/src/__tests__/root.test.js +17 -0
  29. package/configure/src/__tests__/utils.test.js +18 -3
  30. package/configure/src/buttons/circle.jsx +1 -1
  31. package/configure/src/defaults.js +1 -0
  32. package/configure/src/hotspot-circle.jsx +145 -0
  33. package/configure/src/hotspot-container.jsx +13 -6
  34. package/configure/src/hotspot-drawable.jsx +26 -16
  35. package/configure/src/hotspot-polygon.jsx +1 -8
  36. package/configure/src/hotspot-rectangle.jsx +1 -9
  37. package/configure/src/index.js +3 -2
  38. package/configure/src/shapes/circle.js +21 -9
  39. package/configure/src/utils.js +12 -0
  40. package/controller/lib/index.js +8 -3
  41. package/controller/lib/index.js.map +1 -1
  42. package/controller/src/index.js +16 -6
  43. package/lib/hotspot/circle.js +191 -0
  44. package/lib/hotspot/circle.js.map +1 -0
  45. package/lib/hotspot/container.js +34 -2
  46. package/lib/hotspot/container.js.map +1 -1
  47. package/lib/hotspot/index.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/hotspot/circle.jsx +141 -0
  50. package/src/hotspot/container.jsx +31 -1
  51. package/src/hotspot/index.jsx +1 -1
@@ -35,6 +35,8 @@ var _rectangle = _interopRequireDefault(require("./rectangle"));
35
35
 
36
36
  var _polygon = _interopRequireDefault(require("./polygon"));
37
37
 
38
+ var _circle = _interopRequireDefault(require("./circle"));
39
+
38
40
  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); }; }
39
41
 
40
42
  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; } }
@@ -100,8 +102,12 @@ var Container = /*#__PURE__*/function (_React$Component) {
100
102
  outlineColor = _this$props.outlineColor,
101
103
  onSelectChoice = _this$props.onSelectChoice,
102
104
  _this$props$shapes = _this$props.shapes,
103
- rectangles = _this$props$shapes.rectangles,
104
- polygons = _this$props$shapes.polygons,
105
+ _this$props$shapes$re = _this$props$shapes.rectangles,
106
+ rectangles = _this$props$shapes$re === void 0 ? [] : _this$props$shapes$re,
107
+ _this$props$shapes$po = _this$props$shapes.polygons,
108
+ polygons = _this$props$shapes$po === void 0 ? [] : _this$props$shapes$po,
109
+ _this$props$shapes$ci = _this$props$shapes.circles,
110
+ circles = _this$props$shapes$ci === void 0 ? [] : _this$props$shapes$ci,
105
111
  SCALE = _this$props.scale,
106
112
  strokeWidth = _this$props.strokeWidth,
107
113
  showCorrect = _this$props.showCorrect;
@@ -180,6 +186,32 @@ var Container = /*#__PURE__*/function (_React$Component) {
180
186
  markAsCorrect: markAsCorrect,
181
187
  showCorrectEnabled: showCorrect
182
188
  });
189
+ }), circles.map(function (shape) {
190
+ var selected = _this2.isSelected(shape);
191
+
192
+ var isCorrect = isEvaluateMode ? _this2.correctness(shape.correct, selected) : undefined;
193
+ var evaluateText = isEvaluateMode ? _this2.getEvaluateText(shape.correct, selected) : null;
194
+ var markAsCorrect = !!(isEvaluateMode && showCorrect && shape.correct);
195
+ return /*#__PURE__*/_react["default"].createElement(_circle["default"], {
196
+ classes: classes,
197
+ scale: SCALE,
198
+ isEvaluateMode: isEvaluateMode,
199
+ isCorrect: isCorrect,
200
+ evaluateText: evaluateText,
201
+ disabled: disabled,
202
+ selected: selected,
203
+ radius: shape.radius,
204
+ hotspotColor: hotspotColor,
205
+ id: shape.id,
206
+ key: shape.id,
207
+ onClick: onSelectChoice,
208
+ outlineColor: outlineColor,
209
+ x: shape.x,
210
+ y: shape.y,
211
+ strokeWidth: strokeWidth,
212
+ markAsCorrect: markAsCorrect,
213
+ showCorrectEnabled: showCorrect
214
+ });
183
215
  }))));
184
216
  }
185
217
  }]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hotspot/container.jsx"],"names":["Container","isCorrect","isChecked","selected","shape","selectedShape","props","session","answers","filter","answer","id","classes","dimensions","withProp","width","heightProp","height","disabled","hotspotColor","imageUrl","isEvaluateMode","outlineColor","onSelectChoice","shapes","rectangles","polygons","SCALE","scale","strokeWidth","showCorrect","base","padding","imageContainer","image","maxWidth","maxHeight","stage","map","isSelected","correctness","correct","undefined","evaluateText","getEvaluateText","markAsCorrect","x","y","polygon","points","React","Component","styles","theme","marginTop","spacing","unit","marginBottom","position","background","palette","common","white","border","alignItems","display","justifyContent","left","top","resize","borderBottom","color","borderRight","bottom","cursor","right","propTypes","PropTypes","object","isRequired","bool","string","func","number","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;IAEaA,S;;;;;;;;;;;;;;;oGAMG,UAACC,SAAD,EAAYC,SAAZ;AAAA,aAA2BD,SAAS,GAAGC,SAAH,GAAe,CAACA,SAApD;AAAA,K;wGAEI,UAACD,SAAD,EAAYE,QAAZ,EAAyB;AACzC,UAAIA,QAAQ,IAAIF,SAAhB,EAA2B;AACzB,eAAO,qBAAP;AACD;;AAED,UAAIE,QAAQ,IAAI,CAACF,SAAjB,EAA4B;AAC1B,eAAO,gCAAP;AACD;;AAED,UAAI,CAACE,QAAD,IAAaF,SAAjB,EAA4B;AAC1B,eAAO,4BAAP;AACD;;AAED,aAAO,IAAP;AACD,K;;;;;;WArBD,oBAAWG,KAAX,EAAkB;AAChB,UAAMC,aAAa,GAAG,KAAKC,KAAL,CAAWC,OAAX,CAAmBC,OAAnB,CAA2BC,MAA3B,CAAkC,UAACC,MAAD;AAAA,eAAYA,MAAM,CAACC,EAAP,KAAcP,KAAK,CAACO,EAAhC;AAAA,OAAlC,EAAsE,CAAtE,CAAtB;AACA,aAAO,CAAC,CAACN,aAAT;AACD;;;WAoBD,kBAAS;AAAA;;AACP,wBAaI,KAAKC,KAbT;AAAA,UACEM,OADF,eACEA,OADF;AAAA,8CAEEC,UAFF;AAAA,UAEuBC,QAFvB,yBAEgBC,KAFhB;AAAA,UAEyCC,UAFzC,yBAEiCC,MAFjC;AAAA,UAGEC,QAHF,eAGEA,QAHF;AAAA,UAIE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,sBAAUG,IAAV,CAAeD,UAHL;AAIpB5D,EAAAA,YAAY,EAAE0D,sBAAUI,MAAV,CAAiBF,UAJX;AAKpB3D,EAAAA,QAAQ,EAAEyD,sBAAUI,MAAV,CAAiBF,UALP;AAMpB1D,EAAAA,cAAc,EAAEwD,sBAAUG,IAAV,CAAeD,UANX;AAOpBxD,EAAAA,cAAc,EAAEsD,sBAAUK,IAAV,CAAeH,UAPX;AAQpBzD,EAAAA,YAAY,EAAEuD,sBAAUI,MAAV,CAAiBF,UARX;AASpBxE,EAAAA,OAAO,EAAEsE,sBAAUC,MAAV,CAAiBC,UATN;AAUpBvD,EAAAA,MAAM,EAAEqD,sBAAUC,MAAV,CAAiBC,UAVL;AAWpBlD,EAAAA,WAAW,EAAEgD,sBAAUM,MAXH;AAYpBvD,EAAAA,KAAK,EAAEiD,sBAAUM,MAZG;AAapBrD,EAAAA,WAAW,EAAE+C,sBAAUG;AAbH,CAAtB;AAgBAhF,SAAS,CAACoF,YAAV,GAAyB;AACvBxD,EAAAA,KAAK,EAAE;AADgB,CAAzB;;eAIe,wBAAWwB,MAAX,EAAmBpD,SAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Layer, Stage } from 'react-konva';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/pie-toolbox/render-ui';\n\nimport Rectangle from './rectangle';\nimport Polygon from './polygon';\n\nexport class Container extends React.Component {\n isSelected(shape) {\n const selectedShape = this.props.session.answers.filter((answer) => answer.id === shape.id)[0];\n return !!selectedShape;\n }\n\n correctness = (isCorrect, isChecked) => (isCorrect ? isChecked : !isChecked);\n\n getEvaluateText = (isCorrect, selected) => {\n if (selected && isCorrect) {\n return 'Correctly\\nselected';\n }\n\n if (selected && !isCorrect) {\n return 'Should not have\\nbeen selected';\n }\n\n if (!selected && isCorrect) {\n return 'Should have\\nbeen selected';\n }\n\n return null;\n };\n\n render() {\n const {\n classes,\n dimensions: { width: withProp, height: heightProp },\n disabled,\n hotspotColor,\n imageUrl,\n isEvaluateMode,\n outlineColor,\n onSelectChoice,\n shapes: { rectangles, polygons },\n scale: SCALE,\n strokeWidth,\n showCorrect,\n } = this.props;\n\n const width = withProp * SCALE;\n const height = heightProp * SCALE;\n\n return (\n <div className={classes.base} style={{ padding: strokeWidth / 2 }}>\n {imageUrl ? (\n <div className={classes.imageContainer}>\n <img\n alt=\"hotspot-image\"\n className={classes.image}\n height=\"auto\"\n src={imageUrl}\n style={{ width, height, maxWidth: width, maxHeight: height }}\n />\n </div>\n ) : null}\n\n <Stage\n className={classes.stage}\n height={height + strokeWidth}\n width={width + strokeWidth}\n x={strokeWidth / 2}\n y={strokeWidth / 2}\n >\n <Layer>\n {rectangles.map((shape) => {\n const selected = this.isSelected(shape);\n const isCorrect = isEvaluateMode ? this.correctness(shape.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(shape.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && shape.correct);\n\n return (\n <Rectangle\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n height={shape.height}\n hotspotColor={hotspotColor}\n id={shape.id}\n key={shape.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n width={shape.width}\n x={shape.x}\n y={shape.y}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n {polygons.map((polygon) => {\n const selected = this.isSelected(polygon);\n const isCorrect = isEvaluateMode ? this.correctness(polygon.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(polygon.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && polygon.correct);\n\n return (\n <Polygon\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={!!isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n hotspotColor={hotspotColor}\n id={polygon.id}\n key={polygon.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n points={polygon.points}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n </Layer>\n </Stage>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n base: {\n marginTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n position: 'relative',\n background: theme.palette.common.white,\n border: `${theme.spacing.unit}px solid ${theme.palette.common.white}`,\n width: 'fit-content',\n },\n image: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center',\n },\n imageContainer: {\n position: 'relative',\n width: 'fit-content',\n },\n stage: {\n left: 0,\n top: 0,\n position: 'absolute',\n },\n resize: {\n borderBottom: `1px solid ${color.disabled()}`,\n borderRight: `1px solid ${color.disabled()}`,\n bottom: '-10px',\n cursor: 'se-resize',\n height: '10px',\n position: 'absolute',\n right: '-10px',\n width: '10px',\n },\n});\n\nContainer.propTypes = {\n classes: PropTypes.object.isRequired,\n dimensions: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n hotspotColor: PropTypes.string.isRequired,\n imageUrl: PropTypes.string.isRequired,\n isEvaluateMode: PropTypes.bool.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n session: PropTypes.object.isRequired,\n shapes: PropTypes.object.isRequired,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n showCorrect: PropTypes.bool,\n};\n\nContainer.defaultProps = {\n scale: 1,\n};\n\nexport default withStyles(styles)(Container);\n"],"file":"container.js"}
1
+ {"version":3,"sources":["../../src/hotspot/container.jsx"],"names":["Container","isCorrect","isChecked","selected","shape","selectedShape","props","session","answers","filter","answer","id","classes","dimensions","withProp","width","heightProp","height","disabled","hotspotColor","imageUrl","isEvaluateMode","outlineColor","onSelectChoice","shapes","rectangles","polygons","circles","SCALE","scale","strokeWidth","showCorrect","base","padding","imageContainer","image","maxWidth","maxHeight","stage","map","isSelected","correctness","correct","undefined","evaluateText","getEvaluateText","markAsCorrect","x","y","polygon","points","radius","React","Component","styles","theme","marginTop","spacing","unit","marginBottom","position","background","palette","common","white","border","alignItems","display","justifyContent","left","top","resize","borderBottom","color","borderRight","bottom","cursor","right","propTypes","PropTypes","object","isRequired","bool","string","func","number","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;IAEaA,S;;;;;;;;;;;;;;;oGAMG,UAACC,SAAD,EAAYC,SAAZ;AAAA,aAA2BD,SAAS,GAAGC,SAAH,GAAe,CAACA,SAApD;AAAA,K;wGAEI,UAACD,SAAD,EAAYE,QAAZ,EAAyB;AACzC,UAAIA,QAAQ,IAAIF,SAAhB,EAA2B;AACzB,eAAO,qBAAP;AACD;;AAED,UAAIE,QAAQ,IAAI,CAACF,SAAjB,EAA4B;AAC1B,eAAO,gCAAP;AACD;;AAED,UAAI,CAACE,QAAD,IAAaF,SAAjB,EAA4B;AAC1B,eAAO,4BAAP;AACD;;AAED,aAAO,IAAP;AACD,K;;;;;;WArBD,oBAAWG,KAAX,EAAkB;AAChB,UAAMC,aAAa,GAAG,KAAKC,KAAL,CAAWC,OAAX,CAAmBC,OAAnB,CAA2BC,MAA3B,CAAkC,UAACC,MAAD;AAAA,eAAYA,MAAM,CAACC,EAAP,KAAcP,KAAK,CAACO,EAAhC;AAAA,OAAlC,EAAsE,CAAtE,CAAtB;AACA,aAAO,CAAC,CAACN,aAAT;AACD;;;WAoBD,kBAAS;AAAA;;AACP,wBAaI,KAAKC,KAbT;AAAA,UACEM,OADF,eACEA,OADF;AAAA,8CAEEC,UAFF;AAAA,UAEuBC,QAFvB,yBAEgBC,KAFhB;AAAA,UAEyCC,UAFzC,yBAEiCC,MAFjC;AAAA,UAGEC,QAHF,eAGEA,QAHF;AAAA,UAIEC,YAJF,eAIEA,YAJF;AAAA,UAKEC,QALF,eAKEA,QALF;AA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AAUG,IAAV,CAAeD,UAHL;AAIpB9D,EAAAA,YAAY,EAAE4D,sBAAUI,MAAV,CAAiBF,UAJX;AAKpB7D,EAAAA,QAAQ,EAAE2D,sBAAUI,MAAV,CAAiBF,UALP;AAMpB5D,EAAAA,cAAc,EAAE0D,sBAAUG,IAAV,CAAeD,UANX;AAOpB1D,EAAAA,cAAc,EAAEwD,sBAAUK,IAAV,CAAeH,UAPX;AAQpB3D,EAAAA,YAAY,EAAEyD,sBAAUI,MAAV,CAAiBF,UARX;AASpB1E,EAAAA,OAAO,EAAEwE,sBAAUC,MAAV,CAAiBC,UATN;AAUpBzD,EAAAA,MAAM,EAAEuD,sBAAUC,MAAV,CAAiBC,UAVL;AAWpBnD,EAAAA,WAAW,EAAEiD,sBAAUM,MAXH;AAYpBxD,EAAAA,KAAK,EAAEkD,sBAAUM,MAZG;AAapBtD,EAAAA,WAAW,EAAEgD,sBAAUG;AAbH,CAAtB;AAgBAlF,SAAS,CAACsF,YAAV,GAAyB;AACvBzD,EAAAA,KAAK,EAAE;AADgB,CAAzB;;eAIe,wBAAWyB,MAAX,EAAmBtD,SAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Layer, Stage } from 'react-konva';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/pie-toolbox/render-ui';\n\nimport Rectangle from './rectangle';\nimport Polygon from './polygon';\nimport Circle from './circle';\n\nexport class Container extends React.Component {\n isSelected(shape) {\n const selectedShape = this.props.session.answers.filter((answer) => answer.id === shape.id)[0];\n return !!selectedShape;\n }\n\n correctness = (isCorrect, isChecked) => (isCorrect ? isChecked : !isChecked);\n\n getEvaluateText = (isCorrect, selected) => {\n if (selected && isCorrect) {\n return 'Correctly\\nselected';\n }\n\n if (selected && !isCorrect) {\n return 'Should not have\\nbeen selected';\n }\n\n if (!selected && isCorrect) {\n return 'Should have\\nbeen selected';\n }\n\n return null;\n };\n\n render() {\n const {\n classes,\n dimensions: { width: withProp, height: heightProp },\n disabled,\n hotspotColor,\n imageUrl,\n isEvaluateMode,\n outlineColor,\n onSelectChoice,\n shapes: { rectangles = [], polygons = [], circles = [] },\n scale: SCALE,\n strokeWidth,\n showCorrect,\n } = this.props;\n\n const width = withProp * SCALE;\n const height = heightProp * SCALE;\n\n return (\n <div className={classes.base} style={{ padding: strokeWidth / 2 }}>\n {imageUrl ? (\n <div className={classes.imageContainer}>\n <img\n alt=\"hotspot-image\"\n className={classes.image}\n height=\"auto\"\n src={imageUrl}\n style={{ width, height, maxWidth: width, maxHeight: height }}\n />\n </div>\n ) : null}\n\n <Stage\n className={classes.stage}\n height={height + strokeWidth}\n width={width + strokeWidth}\n x={strokeWidth / 2}\n y={strokeWidth / 2}\n >\n <Layer>\n {rectangles.map((shape) => {\n const selected = this.isSelected(shape);\n const isCorrect = isEvaluateMode ? this.correctness(shape.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(shape.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && shape.correct);\n\n return (\n <Rectangle\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n height={shape.height}\n hotspotColor={hotspotColor}\n id={shape.id}\n key={shape.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n width={shape.width}\n x={shape.x}\n y={shape.y}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n {polygons.map((polygon) => {\n const selected = this.isSelected(polygon);\n const isCorrect = isEvaluateMode ? this.correctness(polygon.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(polygon.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && polygon.correct);\n\n return (\n <Polygon\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={!!isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n hotspotColor={hotspotColor}\n id={polygon.id}\n key={polygon.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n points={polygon.points}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n {circles.map((shape) => {\n const selected = this.isSelected(shape);\n const isCorrect = isEvaluateMode ? this.correctness(shape.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(shape.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && shape.correct);\n\n return (\n <Circle\n classes={classes}\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n radius={shape.radius}\n hotspotColor={hotspotColor}\n id={shape.id}\n key={shape.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n x={shape.x}\n y={shape.y}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n </Layer>\n </Stage>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n base: {\n marginTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n position: 'relative',\n background: theme.palette.common.white,\n border: `${theme.spacing.unit}px solid ${theme.palette.common.white}`,\n width: 'fit-content',\n },\n image: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center',\n },\n imageContainer: {\n position: 'relative',\n width: 'fit-content',\n },\n stage: {\n left: 0,\n top: 0,\n position: 'absolute',\n },\n resize: {\n borderBottom: `1px solid ${color.disabled()}`,\n borderRight: `1px solid ${color.disabled()}`,\n bottom: '-10px',\n cursor: 'se-resize',\n height: '10px',\n position: 'absolute',\n right: '-10px',\n width: '10px',\n },\n});\n\nContainer.propTypes = {\n classes: PropTypes.object.isRequired,\n dimensions: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n hotspotColor: PropTypes.string.isRequired,\n imageUrl: PropTypes.string.isRequired,\n isEvaluateMode: PropTypes.bool.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n session: PropTypes.object.isRequired,\n shapes: PropTypes.object.isRequired,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n showCorrect: PropTypes.bool,\n};\n\nContainer.defaultProps = {\n scale: 1,\n};\n\nexport default withStyles(styles)(Container);\n"],"file":"container.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hotspot/index.jsx"],"names":["HotspotComponent","props","showCorrect","state","setState","observer","scale","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","disconnect","session","model","disabled","imageUrl","prompt","mode","multipleCorrect","shapes","outlineColor","hotspotColor","dimensions","rationale","teacherInstructions","strokeWidth","responseCorrect","language","onSelectChoice","classes","isEvaluateMode","showCorrectAnswerToggle","main","hidden","visible","collapsible","onToggle","bind","React","Component","propTypes","PropTypes","object","isRequired","func","defaultProps","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEMA,gB;;;;;AACJ,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,iGA2CR,YAAM;AACf,UAAQC,WAAR,GAAwB,MAAKC,KAA7B,CAAQD,WAAR;;AACA,YAAKE,QAAL,CAAc;AAAEF,QAAAA,WAAW,EAAE,CAACA;AAAhB,OAAd;AACD,KA9CkB;AAEjB,UAAKC,KAAL,GAAa;AACXD,MAAAA,WAAW,EAAE,KADF;AAEXG,MAAAA,QAAQ,EAAE,IAFC;AAGXC,MAAAA,KAAK,EAAE;AAHI,KAAb;AAFiB;AAOlB;;;;WAED,6BAAoB;AAAA;;AAClB,WAAKD,QAAL,GAAgB,IAAIE,gBAAJ,CAAqB,UAACC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bf,EAAAA,cAAc,EAAEa,sBAAUG,IAAV,CAAeD,UAHJ;AAI3B/B,EAAAA,OAAO,EAAE6B,sBAAUC,MAAV,CAAiBC;AAJC,CAA7B;AAOA1D,gBAAgB,CAAC4D,YAAjB,GAAgC;AAC9BhB,EAAAA,OAAO,EAAE;AADqB,CAAhC;;AAIA,IAAMiB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBf,IAAAA,IAAI,EAAE;AACJgB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFb,KADmB;AAKzBhB,IAAAA,WAAW,EAAE;AACXiB,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADxB,KALY;AAQzBtC,IAAAA,MAAM,EAAE;AACNuC,MAAAA,QAAQ,EAAE;AADJ;AARiB,GAAZ;AAAA,CAAf;;eAae,wBAAWT,MAAX,EAAmB7D,gBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {CorrectAnswerToggle} from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { color, Collapsible, hasText, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport Container from './container';\n\nclass HotspotComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n showCorrect: false,\n observer: null,\n scale: 1,\n };\n }\n\n componentDidMount() {\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\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\n if (target) {\n this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });\n }\n }\n\n componentWillUnmount() {\n this.observer?.disconnect();\n }\n\n onToggle = () => {\n const { showCorrect } = this.state;\n this.setState({ showCorrect: !showCorrect });\n };\n\n render() {\n const {\n session,\n model: {\n disabled,\n imageUrl,\n prompt,\n mode,\n multipleCorrect,\n shapes,\n outlineColor,\n hotspotColor,\n dimensions,\n rationale,\n teacherInstructions,\n strokeWidth,\n responseCorrect,\n language,\n },\n onSelectChoice,\n classes,\n } = this.props;\n const { showCorrect } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n\n return (\n <div className={classes.main}>\n {teacherInstructions && hasText(teacherInstructions) && (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt className=\"prompt\" prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n {prompt && <PreviewPrompt className=\"prompt\" prompt={prompt} />}\n\n {showCorrectAnswerToggle && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n language={language}\n />\n )}\n\n {imageUrl ? (\n <Container\n isEvaluateMode={isEvaluateMode}\n session={session}\n dimensions={dimensions}\n imageUrl={imageUrl}\n hotspotColor={hotspotColor}\n multipleCorrect={multipleCorrect}\n outlineColor={outlineColor}\n onSelectChoice={onSelectChoice}\n shapes={shapes}\n disabled={disabled}\n strokeWidth={strokeWidth}\n scale={this.state.scale}\n showCorrect={showCorrect}\n />\n ) : null}\n\n {rationale && hasText(rationale) && (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt className=\"prompt\" prompt={rationale} />\n </Collapsible>\n )}\n </div>\n );\n }\n}\n\nHotspotComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n session: PropTypes.object.isRequired,\n};\n\nHotspotComponent.defaultProps = {\n classes: {},\n};\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n fontSize: 'inherit',\n },\n});\n\nexport default withStyles(styles)(HotspotComponent);\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/hotspot/index.jsx"],"names":["HotspotComponent","props","showCorrect","state","setState","observer","scale","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","disconnect","session","model","disabled","imageUrl","prompt","mode","multipleCorrect","shapes","outlineColor","hotspotColor","dimensions","rationale","teacherInstructions","strokeWidth","responseCorrect","language","onSelectChoice","classes","isEvaluateMode","showCorrectAnswerToggle","main","hidden","visible","collapsible","onToggle","bind","React","Component","propTypes","PropTypes","object","isRequired","func","defaultProps","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEMA,gB;;;;;AACJ,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,iGA2CR,YAAM;AACf,UAAQC,WAAR,GAAwB,MAAKC,KAA7B,CAAQD,WAAR;;AACA,YAAKE,QAAL,CAAc;AAAEF,QAAAA,WAAW,EAAE,CAACA;AAAhB,OAAd;AACD,KA9CkB;AAEjB,UAAKC,KAAL,GAAa;AACXD,MAAAA,WAAW,EAAE,KADF;AAEXG,MAAAA,QAAQ,EAAE,IAFC;AAGXC,MAAAA,KAAK,EAAE;AAHI,KAAb;AAFiB;AAOlB;;;;WAED,6BAAoB;AAAA;;AAClB,WAAKD,QAAL,GAAgB,IAAIE,gBAAJ,CA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FG;AAG3Bf,EAAAA,cAAc,EAAEa,sBAAUG,IAAV,CAAeD,UAHJ;AAI3B/B,EAAAA,OAAO,EAAE6B,sBAAUC,MAAV,CAAiBC;AAJC,CAA7B;AAOA1D,gBAAgB,CAAC4D,YAAjB,GAAgC;AAC9BhB,EAAAA,OAAO,EAAE;AADqB,CAAhC;;AAIA,IAAMiB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBf,IAAAA,IAAI,EAAE;AACJgB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFb,KADmB;AAKzBhB,IAAAA,WAAW,EAAE;AACXiB,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADxB,KALY;AAQzBtC,IAAAA,MAAM,EAAE;AACNuC,MAAAA,QAAQ,EAAE;AADJ;AARiB,GAAZ;AAAA,CAAf;;eAae,wBAAWT,MAAX,EAAmB7D,gBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { color, Collapsible, hasText, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport Container from './container';\n\nclass HotspotComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n showCorrect: false,\n observer: null,\n scale: 1,\n };\n }\n\n componentDidMount() {\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\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\n if (target) {\n this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });\n }\n }\n\n componentWillUnmount() {\n this.observer?.disconnect();\n }\n\n onToggle = () => {\n const { showCorrect } = this.state;\n this.setState({ showCorrect: !showCorrect });\n };\n\n render() {\n const {\n session,\n model: {\n disabled,\n imageUrl,\n prompt,\n mode,\n multipleCorrect,\n shapes,\n outlineColor,\n hotspotColor,\n dimensions,\n rationale,\n teacherInstructions,\n strokeWidth,\n responseCorrect,\n language,\n },\n onSelectChoice,\n classes,\n } = this.props;\n const { showCorrect } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n\n return (\n <div className={classes.main}>\n {teacherInstructions && hasText(teacherInstructions) && (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt className=\"prompt\" prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n {prompt && <PreviewPrompt className=\"prompt\" prompt={prompt} />}\n\n {showCorrectAnswerToggle && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n language={language}\n />\n )}\n\n {imageUrl ? (\n <Container\n isEvaluateMode={isEvaluateMode}\n session={session}\n dimensions={dimensions}\n imageUrl={imageUrl}\n hotspotColor={hotspotColor}\n multipleCorrect={multipleCorrect}\n outlineColor={outlineColor}\n onSelectChoice={onSelectChoice}\n shapes={shapes}\n disabled={disabled}\n strokeWidth={strokeWidth}\n scale={this.state.scale}\n showCorrect={showCorrect}\n />\n ) : null}\n\n {rationale && hasText(rationale) && (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt className=\"prompt\" prompt={rationale} />\n </Collapsible>\n )}\n </div>\n );\n }\n}\n\nHotspotComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n session: PropTypes.object.isRequired,\n};\n\nHotspotComponent.defaultProps = {\n classes: {},\n};\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n fontSize: 'inherit',\n },\n});\n\nexport default withStyles(styles)(HotspotComponent);\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/hotspot",
3
- "version": "6.3.2-next.18+30411b18c",
3
+ "version": "6.3.2-next.22+e23b434da",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "author": "pie framework developers",
20
20
  "license": "ISC",
21
- "gitHead": "30411b18c999aaa5f917055fc0b5d87bab289f68",
21
+ "gitHead": "e23b434da8b2c92880360239a1abb65b5e13de64",
22
22
  "scripts": {
23
23
  "postpublish": "../../scripts/postpublish"
24
24
  },
@@ -0,0 +1,141 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Circle, Group } from 'react-konva';
4
+ import { withStyles } from '@material-ui/core/styles';
5
+ import { ImageComponent } from '@pie-lib/pie-toolbox/icons';
6
+ import { faCorrect, faWrong } from './icons';
7
+
8
+ class CircleComponent extends React.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ }
12
+
13
+ handleClick = (e) => {
14
+ const { onClick, id, selected, disabled } = this.props;
15
+
16
+ if (!disabled) {
17
+ e.cancelBubble = true;
18
+ onClick({ id, selected: !selected });
19
+ }
20
+ };
21
+
22
+ handleMouseEnter = () => {
23
+ const { disabled } = this.props;
24
+
25
+ if (!disabled) {
26
+ document.body.style.cursor = 'pointer';
27
+ }
28
+ };
29
+
30
+ handleMouseLeave = () => {
31
+ document.body.style.cursor = 'default';
32
+ };
33
+
34
+ getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>
35
+ markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';
36
+
37
+ getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>
38
+ markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;
39
+
40
+ render() {
41
+ const {
42
+ classes,
43
+ radius,
44
+ hotspotColor,
45
+ isCorrect,
46
+ isEvaluateMode,
47
+ outlineColor,
48
+ selected,
49
+ x,
50
+ y,
51
+ evaluateText,
52
+ strokeWidth,
53
+ scale,
54
+ markAsCorrect,
55
+ showCorrectEnabled,
56
+ } = this.props;
57
+
58
+ const outlineColorParsed = isEvaluateMode
59
+ ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)
60
+ : outlineColor;
61
+
62
+ const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);
63
+
64
+ const iconX = x - 10;
65
+ const iconY = y - 10; // Adjust position for the icon
66
+
67
+ let iconSrc;
68
+ if (showCorrectEnabled) {
69
+ if ((selected && isCorrect) || (!selected && !isCorrect)) {
70
+ iconSrc = faCorrect;
71
+ }
72
+ } else {
73
+ if (selected) {
74
+ if (isCorrect) {
75
+ iconSrc = faCorrect;
76
+ } else {
77
+ iconSrc = faWrong;
78
+ }
79
+ } else if (!isCorrect) {
80
+ iconSrc = faWrong;
81
+ }
82
+ }
83
+
84
+ return (
85
+ <Group scaleX={scale} scaleY={scale}>
86
+ <Circle
87
+ classes={classes.base}
88
+ radius={radius}
89
+ fill={hotspotColor}
90
+ onClick={this.handleClick}
91
+ onTap={this.handleClick}
92
+ draggable={false}
93
+ stroke={outlineColorParsed}
94
+ strokeWidth={outlineWidth}
95
+ onMouseLeave={this.handleMouseLeave}
96
+ onMouseEnter={this.handleMouseEnter}
97
+ x={x}
98
+ y={y}
99
+ />
100
+ {isEvaluateMode && iconSrc ? <ImageComponent src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}
101
+ </Group>
102
+ );
103
+ }
104
+ }
105
+
106
+ const styles = () => ({
107
+ base: {
108
+ cursor: 'pointer',
109
+ opacity: 0.5,
110
+ position: 'relative',
111
+ },
112
+ });
113
+
114
+ CircleComponent.propTypes = {
115
+ classes: PropTypes.object.isRequired,
116
+ radius: PropTypes.number.isRequired,
117
+ hotspotColor: PropTypes.string.isRequired,
118
+ id: PropTypes.string.isRequired,
119
+ isCorrect: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
120
+ isEvaluateMode: PropTypes.bool.isRequired,
121
+ disabled: PropTypes.bool.isRequired,
122
+ onClick: PropTypes.func.isRequired,
123
+ outlineColor: PropTypes.string.isRequired,
124
+ selected: PropTypes.bool.isRequired,
125
+ x: PropTypes.number.isRequired,
126
+ y: PropTypes.number.isRequired,
127
+ evaluateText: PropTypes.string,
128
+ strokeWidth: PropTypes.number,
129
+ scale: PropTypes.number,
130
+ markAsCorrect: PropTypes.bool.isRequired,
131
+ showCorrectEnabled: PropTypes.bool.isRequired,
132
+ };
133
+
134
+ CircleComponent.defaultProps = {
135
+ isCorrect: false,
136
+ evaluateText: null,
137
+ strokeWidth: 5,
138
+ scale: 1,
139
+ };
140
+
141
+ export default withStyles(styles)(CircleComponent);
@@ -6,6 +6,7 @@ import { color } from '@pie-lib/pie-toolbox/render-ui';
6
6
 
7
7
  import Rectangle from './rectangle';
8
8
  import Polygon from './polygon';
9
+ import Circle from './circle';
9
10
 
10
11
  export class Container extends React.Component {
11
12
  isSelected(shape) {
@@ -41,7 +42,7 @@ export class Container extends React.Component {
41
42
  isEvaluateMode,
42
43
  outlineColor,
43
44
  onSelectChoice,
44
- shapes: { rectangles, polygons },
45
+ shapes: { rectangles = [], polygons = [], circles = [] },
45
46
  scale: SCALE,
46
47
  strokeWidth,
47
48
  showCorrect,
@@ -127,6 +128,35 @@ export class Container extends React.Component {
127
128
  />
128
129
  );
129
130
  })}
131
+ {circles.map((shape) => {
132
+ const selected = this.isSelected(shape);
133
+ const isCorrect = isEvaluateMode ? this.correctness(shape.correct, selected) : undefined;
134
+ const evaluateText = isEvaluateMode ? this.getEvaluateText(shape.correct, selected) : null;
135
+ const markAsCorrect = !!(isEvaluateMode && showCorrect && shape.correct);
136
+
137
+ return (
138
+ <Circle
139
+ classes={classes}
140
+ scale={SCALE}
141
+ isEvaluateMode={isEvaluateMode}
142
+ isCorrect={isCorrect}
143
+ evaluateText={evaluateText}
144
+ disabled={disabled}
145
+ selected={selected}
146
+ radius={shape.radius}
147
+ hotspotColor={hotspotColor}
148
+ id={shape.id}
149
+ key={shape.id}
150
+ onClick={onSelectChoice}
151
+ outlineColor={outlineColor}
152
+ x={shape.x}
153
+ y={shape.y}
154
+ strokeWidth={strokeWidth}
155
+ markAsCorrect={markAsCorrect}
156
+ showCorrectEnabled={showCorrect}
157
+ />
158
+ );
159
+ })}
130
160
  </Layer>
131
161
  </Stage>
132
162
  </div>
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import {CorrectAnswerToggle} from '@pie-lib/pie-toolbox/correct-answer-toggle';
3
+ import { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';
4
4
  import { color, Collapsible, hasText, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';
5
5
  import { withStyles } from '@material-ui/core/styles';
6
6