@pie-element/hotspot 10.0.0-beta.0 → 10.0.0-next.0

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 (61) hide show
  1. package/CHANGELOG.md +0 -11
  2. package/configure/CHANGELOG.md +0 -11
  3. package/configure/lib/defaults.js +3 -0
  4. package/configure/lib/defaults.js.map +1 -1
  5. package/configure/lib/hotspot-circle.js +0 -1
  6. package/configure/lib/hotspot-circle.js.map +1 -1
  7. package/configure/lib/hotspot-drawable.js +5 -5
  8. package/configure/lib/hotspot-drawable.js.map +1 -1
  9. package/configure/lib/hotspot-polygon.js +1 -2
  10. package/configure/lib/hotspot-polygon.js.map +1 -1
  11. package/configure/lib/hotspot-rectangle.js +0 -1
  12. package/configure/lib/hotspot-rectangle.js.map +1 -1
  13. package/configure/lib/root.js +4 -4
  14. package/configure/lib/root.js.map +1 -1
  15. package/configure/lib/utils.js +2 -3
  16. package/configure/lib/utils.js.map +1 -1
  17. package/configure/package.json +8 -8
  18. package/configure/src/__tests__/DeleteWidget.test.jsx +366 -0
  19. package/configure/src/__tests__/button.test.jsx +198 -0
  20. package/configure/src/__tests__/hotspot-circle.test.jsx +259 -0
  21. package/configure/src/__tests__/hotspot-palette.test.jsx +71 -0
  22. package/configure/src/__tests__/image-konva.test.jsx +226 -0
  23. package/configure/src/defaults.js +1 -0
  24. package/configure/src/hotspot-circle.jsx +0 -1
  25. package/configure/src/hotspot-drawable.jsx +1 -1
  26. package/configure/src/hotspot-polygon.jsx +0 -1
  27. package/configure/src/hotspot-rectangle.jsx +0 -1
  28. package/configure/src/root.jsx +1 -1
  29. package/configure/src/utils.js +1 -1
  30. package/controller/CHANGELOG.md +0 -11
  31. package/controller/lib/index.js +2 -2
  32. package/controller/lib/index.js.map +1 -1
  33. package/controller/lib/utils.js +3 -5
  34. package/controller/lib/utils.js.map +1 -1
  35. package/controller/package.json +3 -3
  36. package/controller/src/index.js +1 -1
  37. package/controller/src/utils.js +1 -2
  38. package/lib/hotspot/circle.js +1 -2
  39. package/lib/hotspot/circle.js.map +1 -1
  40. package/lib/hotspot/polygon.js +0 -1
  41. package/lib/hotspot/polygon.js.map +1 -1
  42. package/lib/hotspot/rectangle.js +0 -1
  43. package/lib/hotspot/rectangle.js.map +1 -1
  44. package/package.json +10 -10
  45. package/src/hotspot/__tests__/circle.test.jsx +464 -0
  46. package/src/hotspot/__tests__/container.test.jsx +546 -0
  47. package/src/hotspot/__tests__/image-konva-tooltip.test.jsx +510 -0
  48. package/src/hotspot/__tests__/polygon.test.jsx +502 -0
  49. package/src/hotspot/__tests__/rectangle.test.jsx +418 -0
  50. package/src/hotspot/circle.jsx +0 -1
  51. package/src/hotspot/polygon.jsx +0 -1
  52. package/src/hotspot/rectangle.jsx +0 -1
  53. package/configure/node_modules/debug/CHANGELOG.md +0 -395
  54. package/configure/node_modules/debug/LICENSE +0 -19
  55. package/configure/node_modules/debug/README.md +0 -437
  56. package/configure/node_modules/debug/node.js +0 -1
  57. package/configure/node_modules/debug/package.json +0 -51
  58. package/configure/node_modules/debug/src/browser.js +0 -180
  59. package/configure/node_modules/debug/src/common.js +0 -249
  60. package/configure/node_modules/debug/src/index.js +0 -12
  61. package/configure/node_modules/debug/src/node.js +0 -177
@@ -1 +1 @@
1
- {"version":3,"file":"polygon.js","names":["_react","_interopRequireDefault","require","_propTypes","_reactKonva","_imageKonvaTooltip","_icons","PolygonComponent","React","Component","constructor","props","_defineProperty2","default","points","x","map","y","minX","Math","min","apply","maxX","max","minY","maxY","parsedPoints","forEach","push","e","onClick","id","selected","disabled","cancelBubble","selector","document","body","style","cursor","setState","hovered","isCorrect","markAsCorrect","outlineColor","showCorrectEnabled","strokeWidth","state","render","hotspotColor","isEvaluateMode","hoverOutlineColor","evaluateText","scale","selectedHotspotColor","outlineColorParsed","getEvaluateOutlineColor","outlineWidth","getOutlineWidth","pointsParsed","parsePointsForKonva","center","getPolygonCenter","iconX","iconY","iconSrc","faCorrect","faWrong","useHoveredStyle","xValues","filter","_","index","yValues","rectX","rectY","rectWidth","rectHeight","createElement","Group","scaleX","scaleY","Rect","width","height","stroke","Line","closed","fill","handleClick","onTap","draggable","onMouseLeave","handleMouseLeave","onMouseEnter","handleMouseEnter","opacity","position","src","tooltip","propTypes","PropTypes","string","isRequired","bool","func","array","number","defaultProps","_default","exports"],"sources":["../../src/hotspot/polygon.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Line, Group, Rect } from 'react-konva';\nimport ImageComponent from './image-konva-tooltip';\nimport { faCorrect, faWrong } from './icons';\n\nclass PolygonComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n hovered: false,\n };\n }\n\n getPolygonCenter = (points) => {\n const x = points.map(({ x }) => x);\n const y = points.map(({ y }) => y);\n const minX = Math.min.apply(null, x);\n const maxX = Math.max.apply(null, x);\n const minY = Math.min.apply(null, y);\n const maxY = Math.max.apply(null, y);\n return [(minX + maxX) / 2, (minY + maxY) / 2];\n };\n\n parsePointsForKonva = (points) => {\n const parsedPoints = [];\n points.forEach(({ x, y }) => {\n parsedPoints.push(x);\n parsedPoints.push(y);\n });\n return parsedPoints;\n };\n\n handleClick = (e) => {\n const { onClick, id, selected, disabled } = this.props;\n\n if (!disabled) {\n e.cancelBubble = true;\n onClick({ id, selected: !selected, selector: 'Mouse' });\n }\n };\n\n handleMouseEnter = () => {\n const { disabled } = this.props;\n\n if (!disabled) {\n document.body.style.cursor = 'pointer';\n }\n this.setState({ hovered: true });\n };\n\n handleMouseLeave = () => {\n document.body.style.cursor = 'default';\n this.setState({ hovered: false });\n };\n\n getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>\n markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';\n\n getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>\n markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;\n\n render() {\n const {\n hotspotColor,\n isCorrect,\n isEvaluateMode,\n hoverOutlineColor,\n outlineColor,\n selected,\n points,\n evaluateText,\n strokeWidth,\n scale,\n markAsCorrect,\n selectedHotspotColor,\n showCorrectEnabled,\n } = this.props;\n\n const { hovered } = this.state;\n\n const outlineColorParsed = isEvaluateMode\n ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)\n : outlineColor;\n const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);\n\n const pointsParsed = this.parsePointsForKonva(points);\n const center = this.getPolygonCenter(points);\n const iconX = center[0];\n const iconY = center[1];\n\n // \"Show Correct Answer\" Enabled:\n // - Correctly Selected: white checkmark in green circle\n // - Correctly Not Selected: none\n // - Incorrectly Selected: none\n // - Incorrectly Not Selected: white checkmark in green circle\n // \"Show Correct Answer\" Disabled:\n // - Correctly Selected:\n // - white checkmark in green circle\n // - heavy outline, as on “Gather”\n // - Correctly Not Selected: none\n // - Incorrectly Selected:\n // - white \"X\" in red circle\n // - heavy outline around the selection should appear in red\n // - Incorrectly Not Selected: white \"X\" in red circle\n let iconSrc;\n\n if (showCorrectEnabled) {\n if ((selected && isCorrect) || (!selected && !isCorrect)) {\n iconSrc = faCorrect;\n }\n } else {\n if (selected) {\n if (isCorrect) {\n iconSrc = faCorrect;\n } else {\n iconSrc = faWrong;\n }\n } else if (!isCorrect) {\n iconSrc = faWrong;\n }\n }\n const useHoveredStyle = hovered && hoverOutlineColor;\n\n const xValues = pointsParsed.filter((_, index) => index % 2 === 0); // Even indices are x-coordinates\n const yValues = pointsParsed.filter((_, index) => index % 2 !== 0); // Odd indices are y-coordinates\n\n const minX = Math.min(...xValues);\n const maxX = Math.max(...xValues);\n const minY = Math.min(...yValues);\n const maxY = Math.max(...yValues);\n\n const rectX = minX;\n const rectY = minY;\n const rectWidth = maxX - minX;\n const rectHeight = maxY - minY;\n\n return (\n <Group scaleX={scale} scaleY={scale}>\n {useHoveredStyle && (\n <Rect\n x={rectX}\n y={rectY}\n width={rectWidth}\n height={rectHeight}\n stroke={selected ? 'transparent' : hoverOutlineColor}\n strokeWidth={strokeWidth}\n />\n )}\n <Line\n points={pointsParsed}\n closed={true}\n fill={selected && selectedHotspotColor? selectedHotspotColor : hotspotColor}\n onClick={this.handleClick}\n onTap={this.handleClick}\n draggable={false}\n stroke={useHoveredStyle && !selected ? 'transparent' : outlineColorParsed}\n strokeWidth={useHoveredStyle && !selected ? 0 : outlineWidth}\n onMouseLeave={this.handleMouseLeave}\n onMouseEnter={this.handleMouseEnter}\n opacity={0.5}\n cursor='pointer'\n position='relative'\n />\n {isEvaluateMode && iconSrc ? <ImageComponent src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}\n </Group>\n );\n }\n}\n\nPolygonComponent.propTypes = {\n hotspotColor: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n isCorrect: PropTypes.bool.isRequired,\n isEvaluateMode: PropTypes.bool.isRequired,\n hoverOutlineColor: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n onClick: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n points: PropTypes.array.isRequired,\n selected: PropTypes.bool.isRequired,\n evaluateText: PropTypes.string,\n selectedHotspotColor: PropTypes.string,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n markAsCorrect: PropTypes.bool.isRequired,\n showCorrectEnabled: PropTypes.bool.isRequired,\n};\n\nPolygonComponent.defaultProps = {\n evaluateText: null,\n strokeWidth: 5,\n scale: 1,\n};\n\nexport default PolygonComponent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,gBAAgB,SAASC,cAAK,CAACC,SAAS,CAAC;EAC7CC,WAAWA,CAACC,KAA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,YAAY,EAAEiD,kBAAS,CAACC,MAAM;EAC9BhD,oBAAoB,EAAE+C,kBAAS,CAACC,MAAM;EACtCxD,WAAW,EAAEuD,kBAAS,CAACM,MAAM;EAC7BtD,KAAK,EAAEgD,kBAAS,CAACM,MAAM;EACvBhE,aAAa,EAAE0D,kBAAS,CAACG,IAAI,CAACD,UAAU;EACxC1D,kBAAkB,EAAEwD,kBAAS,CAACG,IAAI,CAACD;AACrC,CAAC;AAEDhG,gBAAgB,CAACqG,YAAY,GAAG;EAC9BxD,YAAY,EAAE,IAAI;EAClBN,WAAW,EAAE,CAAC;EACdO,KAAK,EAAE;AACT,CAAC;AAAC,IAAAwD,QAAA,GAAAC,OAAA,CAAAjG,OAAA,GAEaN,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"polygon.js","names":["_react","_interopRequireDefault","require","_propTypes","_reactKonva","_imageKonvaTooltip","_icons","PolygonComponent","React","Component","constructor","props","_defineProperty2","default","points","x","map","y","minX","Math","min","apply","maxX","max","minY","maxY","parsedPoints","forEach","push","e","onClick","id","selected","disabled","cancelBubble","selector","document","body","style","cursor","setState","hovered","isCorrect","markAsCorrect","outlineColor","showCorrectEnabled","strokeWidth","state","render","hotspotColor","isEvaluateMode","hoverOutlineColor","evaluateText","scale","selectedHotspotColor","outlineColorParsed","getEvaluateOutlineColor","outlineWidth","getOutlineWidth","pointsParsed","parsePointsForKonva","center","getPolygonCenter","iconX","iconY","iconSrc","faCorrect","faWrong","useHoveredStyle","xValues","filter","_","index","yValues","rectX","rectY","rectWidth","rectHeight","createElement","Group","scaleX","scaleY","Rect","width","height","stroke","Line","closed","fill","handleClick","onTap","draggable","onMouseLeave","handleMouseLeave","onMouseEnter","handleMouseEnter","position","src","tooltip","propTypes","PropTypes","string","isRequired","bool","func","array","number","defaultProps","_default","exports"],"sources":["../../src/hotspot/polygon.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Line, Group, Rect } from 'react-konva';\nimport ImageComponent from './image-konva-tooltip';\nimport { faCorrect, faWrong } from './icons';\n\nclass PolygonComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n hovered: false,\n };\n }\n\n getPolygonCenter = (points) => {\n const x = points.map(({ x }) => x);\n const y = points.map(({ y }) => y);\n const minX = Math.min.apply(null, x);\n const maxX = Math.max.apply(null, x);\n const minY = Math.min.apply(null, y);\n const maxY = Math.max.apply(null, y);\n return [(minX + maxX) / 2, (minY + maxY) / 2];\n };\n\n parsePointsForKonva = (points) => {\n const parsedPoints = [];\n points.forEach(({ x, y }) => {\n parsedPoints.push(x);\n parsedPoints.push(y);\n });\n return parsedPoints;\n };\n\n handleClick = (e) => {\n const { onClick, id, selected, disabled } = this.props;\n\n if (!disabled) {\n e.cancelBubble = true;\n onClick({ id, selected: !selected, selector: 'Mouse' });\n }\n };\n\n handleMouseEnter = () => {\n const { disabled } = this.props;\n\n if (!disabled) {\n document.body.style.cursor = 'pointer';\n }\n this.setState({ hovered: true });\n };\n\n handleMouseLeave = () => {\n document.body.style.cursor = 'default';\n this.setState({ hovered: false });\n };\n\n getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>\n markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';\n\n getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>\n markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;\n\n render() {\n const {\n hotspotColor,\n isCorrect,\n isEvaluateMode,\n hoverOutlineColor,\n outlineColor,\n selected,\n points,\n evaluateText,\n strokeWidth,\n scale,\n markAsCorrect,\n selectedHotspotColor,\n showCorrectEnabled,\n } = this.props;\n\n const { hovered } = this.state;\n\n const outlineColorParsed = isEvaluateMode\n ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)\n : outlineColor;\n const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);\n\n const pointsParsed = this.parsePointsForKonva(points);\n const center = this.getPolygonCenter(points);\n const iconX = center[0];\n const iconY = center[1];\n\n // \"Show Correct Answer\" Enabled:\n // - Correctly Selected: white checkmark in green circle\n // - Correctly Not Selected: none\n // - Incorrectly Selected: none\n // - Incorrectly Not Selected: white checkmark in green circle\n // \"Show Correct Answer\" Disabled:\n // - Correctly Selected:\n // - white checkmark in green circle\n // - heavy outline, as on “Gather”\n // - Correctly Not Selected: none\n // - Incorrectly Selected:\n // - white \"X\" in red circle\n // - heavy outline around the selection should appear in red\n // - Incorrectly Not Selected: white \"X\" in red circle\n let iconSrc;\n\n if (showCorrectEnabled) {\n if ((selected && isCorrect) || (!selected && !isCorrect)) {\n iconSrc = faCorrect;\n }\n } else {\n if (selected) {\n if (isCorrect) {\n iconSrc = faCorrect;\n } else {\n iconSrc = faWrong;\n }\n } else if (!isCorrect) {\n iconSrc = faWrong;\n }\n }\n const useHoveredStyle = hovered && hoverOutlineColor;\n\n const xValues = pointsParsed.filter((_, index) => index % 2 === 0); // Even indices are x-coordinates\n const yValues = pointsParsed.filter((_, index) => index % 2 !== 0); // Odd indices are y-coordinates\n\n const minX = Math.min(...xValues);\n const maxX = Math.max(...xValues);\n const minY = Math.min(...yValues);\n const maxY = Math.max(...yValues);\n\n const rectX = minX;\n const rectY = minY;\n const rectWidth = maxX - minX;\n const rectHeight = maxY - minY;\n\n return (\n <Group scaleX={scale} scaleY={scale}>\n {useHoveredStyle && (\n <Rect\n x={rectX}\n y={rectY}\n width={rectWidth}\n height={rectHeight}\n stroke={selected ? 'transparent' : hoverOutlineColor}\n strokeWidth={strokeWidth}\n />\n )}\n <Line\n points={pointsParsed}\n closed={true}\n fill={selected && selectedHotspotColor? selectedHotspotColor : hotspotColor}\n onClick={this.handleClick}\n onTap={this.handleClick}\n draggable={false}\n stroke={useHoveredStyle && !selected ? 'transparent' : outlineColorParsed}\n strokeWidth={useHoveredStyle && !selected ? 0 : outlineWidth}\n onMouseLeave={this.handleMouseLeave}\n onMouseEnter={this.handleMouseEnter}\n cursor='pointer'\n position='relative'\n />\n {isEvaluateMode && iconSrc ? <ImageComponent src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}\n </Group>\n );\n }\n}\n\nPolygonComponent.propTypes = {\n hotspotColor: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n isCorrect: PropTypes.bool.isRequired,\n isEvaluateMode: PropTypes.bool.isRequired,\n hoverOutlineColor: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n onClick: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n points: PropTypes.array.isRequired,\n selected: PropTypes.bool.isRequired,\n evaluateText: PropTypes.string,\n selectedHotspotColor: PropTypes.string,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n markAsCorrect: PropTypes.bool.isRequired,\n showCorrectEnabled: PropTypes.bool.isRequired,\n};\n\nPolygonComponent.defaultProps = {\n evaluateText: null,\n strokeWidth: 5,\n scale: 1,\n};\n\nexport default PolygonComponent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,gBAAgB,SAASC,cAAK,CAACC,SAAS,CAAC;EAC7CC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,4BAMKC,MAAM,IAAK;MAC7B,MAAMC,CAAC,GAAGD,MAAM,CAACE,GAAG,CAAC,CAAC;QAAED;MAAE,CAAC,KAAKA,CAAC,CAAC;MAClC,MAAME,CAAC,GAAGH,MAAM,CAACE,GAAG,CAAC,CAAC;QAAEC;MAAE,CAAC,KAAKA,CAAC,CAAC;MAClC,MAAMC,IAAI,GAAGC,IAAI,CAACC,GAAG,CAACC,KAAK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,CAAC;EACdO,KAAK,EAAE;AACT,CAAC;AAAC,IAAAuD,QAAA,GAAAC,OAAA,CAAAhG,OAAA,GAEaN,gBAAgB","ignoreList":[]}
@@ -135,7 +135,6 @@ class RectComponent extends _react.default.Component {
135
135
  strokeWidth: useHoveredStyle && !selected ? 0 : outlineWidth,
136
136
  onMouseLeave: this.handleMouseLeave,
137
137
  onMouseEnter: this.handleMouseEnter,
138
- opacity: 0.5,
139
138
  cursor: "pointer"
140
139
  }), isEvaluateMode && iconSrc ? /*#__PURE__*/_react.default.createElement(_imageKonvaTooltip.default, {
141
140
  src: iconSrc,
@@ -1 +1 @@
1
- {"version":3,"file":"rectangle.js","names":["_react","_interopRequireDefault","require","_propTypes","_reactKonva","_imageKonvaTooltip","_icons","RectComponent","React","Component","constructor","props","_defineProperty2","default","e","onClick","id","selected","disabled","cancelBubble","selector","document","body","style","cursor","setState","hovered","isCorrect","markAsCorrect","outlineColor","showCorrectEnabled","strokeWidth","state","render","height","hotspotColor","hoverOutlineColor","selectedHotspotColor","isEvaluateMode","width","x","y","evaluateText","scale","outlineColorParsed","getEvaluateOutlineColor","outlineWidth","getOutlineWidth","iconX","iconY","iconSrc","faCorrect","faWrong","useHoveredStyle","createElement","Group","scaleX","scaleY","Rect","stroke","listening","fill","handleClick","onTap","draggable","onMouseLeave","handleMouseLeave","onMouseEnter","handleMouseEnter","opacity","src","tooltip","propTypes","PropTypes","number","isRequired","string","oneOfType","bool","func","defaultProps","_default","exports"],"sources":["../../src/hotspot/rectangle.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Rect, Group } from 'react-konva';\nimport ImageComponent from './image-konva-tooltip';\nimport { faCorrect, faWrong } from './icons';\n\nclass RectComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n hovered: false,\n };\n }\n\n handleClick = (e) => {\n const { onClick, id, selected, disabled } = this.props;\n\n if (!disabled) {\n e.cancelBubble = true;\n onClick({ id, selected: !selected, selector: 'Mouse' });\n }\n };\n\n handleMouseEnter = () => {\n const { disabled } = this.props;\n\n if (!disabled) {\n document.body.style.cursor = 'pointer';\n }\n this.setState({ hovered: true });\n };\n\n handleMouseLeave = () => {\n document.body.style.cursor = 'default';\n this.setState({ hovered: false });\n };\n\n getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>\n markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';\n\n getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>\n markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;\n\n render() {\n const {\n height,\n hotspotColor,\n hoverOutlineColor,\n selectedHotspotColor,\n isCorrect,\n isEvaluateMode,\n outlineColor,\n selected,\n width,\n x,\n y,\n evaluateText,\n strokeWidth,\n scale,\n markAsCorrect,\n showCorrectEnabled,\n } = this.props;\n\n const outlineColorParsed = isEvaluateMode\n ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)\n : outlineColor;\n\n const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);\n\n const iconX = x + width / 2 - 10;\n const iconY = y + height / 2 - 10;\n\n // \"Show Correct Answer\" Enabled:\n // - Correctly Selected: white checkmark in green circle\n // - Correctly Not Selected: none\n // - Incorrectly Selected: none\n // - Incorrectly Not Selected: white checkmark in green circle\n // \"Show Correct Answer\" Disabled:\n // - Correctly Selected:\n // - white checkmark in green circle\n // - heavy outline, as on “Gather”\n // - Correctly Not Selected: none\n // - Incorrectly Selected:\n // - white \"X\" in red circle\n // - heavy outline around the selection should appear in red\n // - Incorrectly Not Selected: white \"X\" in red circle\n let iconSrc;\n\n if (showCorrectEnabled) {\n if ((selected && isCorrect) || (!selected && !isCorrect)) {\n iconSrc = faCorrect;\n }\n } else {\n if (selected) {\n if (isCorrect) {\n iconSrc = faCorrect;\n } else {\n iconSrc = faWrong;\n }\n } else if (!isCorrect) {\n iconSrc = faWrong;\n }\n }\n\n const { hovered } = this.state;\n const useHoveredStyle = hovered && hoverOutlineColor;\n\n return (\n <Group scaleX={scale} scaleY={scale}>\n {useHoveredStyle && (\n <Rect\n x={x}\n y={y}\n width={width}\n height={height}\n stroke={selected ? 'transparent' : hoverOutlineColor}\n strokeWidth={strokeWidth}\n listening={false}\n />\n )}\n <Rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill={selected && selectedHotspotColor ? selectedHotspotColor : hotspotColor}\n onClick={this.handleClick}\n onTap={this.handleClick}\n draggable={false}\n stroke={useHoveredStyle && !selected ? 'transparent' : outlineColorParsed}\n strokeWidth={useHoveredStyle && !selected ? 0 : outlineWidth}\n onMouseLeave={this.handleMouseLeave}\n onMouseEnter={this.handleMouseEnter}\n opacity={0.5}\n cursor=\"pointer\"\n />\n {isEvaluateMode && iconSrc ? <ImageComponent src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}\n </Group>\n );\n }\n}\n\nRectComponent.propTypes = {\n height: PropTypes.number.isRequired,\n hotspotColor: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n isCorrect: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),\n isEvaluateMode: PropTypes.bool.isRequired,\n hoverOutlineColor: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n onClick: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n selected: PropTypes.bool.isRequired,\n width: PropTypes.number.isRequired,\n x: PropTypes.number.isRequired,\n y: PropTypes.number.isRequired,\n evaluateText: PropTypes.string,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n selectedHotspotColor: PropTypes.string,\n markAsCorrect: PropTypes.bool.isRequired,\n showCorrectEnabled: PropTypes.bool.isRequired,\n};\n\nRectComponent.defaultProps = {\n isCorrect: false,\n evaluateText: null,\n strokeWidth: 5,\n scale: 1,\n};\n\nexport default RectComponent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,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AM;EACvBrC,oBAAoB,EAAEoC,kBAAS,CAACG,MAAM;EACtChD,aAAa,EAAE6C,kBAAS,CAACK,IAAI,CAACH,UAAU;EACxC7C,kBAAkB,EAAE2C,kBAAS,CAACK,IAAI,CAACH;AACrC,CAAC;AAEDpE,aAAa,CAACyE,YAAY,GAAG;EAC3BrD,SAAS,EAAE,KAAK;EAChBe,YAAY,EAAE,IAAI;EAClBX,WAAW,EAAE,CAAC;EACdY,KAAK,EAAE;AACT,CAAC;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAArE,OAAA,GAEaN,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"rectangle.js","names":["_react","_interopRequireDefault","require","_propTypes","_reactKonva","_imageKonvaTooltip","_icons","RectComponent","React","Component","constructor","props","_defineProperty2","default","e","onClick","id","selected","disabled","cancelBubble","selector","document","body","style","cursor","setState","hovered","isCorrect","markAsCorrect","outlineColor","showCorrectEnabled","strokeWidth","state","render","height","hotspotColor","hoverOutlineColor","selectedHotspotColor","isEvaluateMode","width","x","y","evaluateText","scale","outlineColorParsed","getEvaluateOutlineColor","outlineWidth","getOutlineWidth","iconX","iconY","iconSrc","faCorrect","faWrong","useHoveredStyle","createElement","Group","scaleX","scaleY","Rect","stroke","listening","fill","handleClick","onTap","draggable","onMouseLeave","handleMouseLeave","onMouseEnter","handleMouseEnter","src","tooltip","propTypes","PropTypes","number","isRequired","string","oneOfType","bool","func","defaultProps","_default","exports"],"sources":["../../src/hotspot/rectangle.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Rect, Group } from 'react-konva';\nimport ImageComponent from './image-konva-tooltip';\nimport { faCorrect, faWrong } from './icons';\n\nclass RectComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n hovered: false,\n };\n }\n\n handleClick = (e) => {\n const { onClick, id, selected, disabled } = this.props;\n\n if (!disabled) {\n e.cancelBubble = true;\n onClick({ id, selected: !selected, selector: 'Mouse' });\n }\n };\n\n handleMouseEnter = () => {\n const { disabled } = this.props;\n\n if (!disabled) {\n document.body.style.cursor = 'pointer';\n }\n this.setState({ hovered: true });\n };\n\n handleMouseLeave = () => {\n document.body.style.cursor = 'default';\n this.setState({ hovered: false });\n };\n\n getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>\n markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';\n\n getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>\n markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;\n\n render() {\n const {\n height,\n hotspotColor,\n hoverOutlineColor,\n selectedHotspotColor,\n isCorrect,\n isEvaluateMode,\n outlineColor,\n selected,\n width,\n x,\n y,\n evaluateText,\n strokeWidth,\n scale,\n markAsCorrect,\n showCorrectEnabled,\n } = this.props;\n\n const outlineColorParsed = isEvaluateMode\n ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)\n : outlineColor;\n\n const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);\n\n const iconX = x + width / 2 - 10;\n const iconY = y + height / 2 - 10;\n\n // \"Show Correct Answer\" Enabled:\n // - Correctly Selected: white checkmark in green circle\n // - Correctly Not Selected: none\n // - Incorrectly Selected: none\n // - Incorrectly Not Selected: white checkmark in green circle\n // \"Show Correct Answer\" Disabled:\n // - Correctly Selected:\n // - white checkmark in green circle\n // - heavy outline, as on “Gather”\n // - Correctly Not Selected: none\n // - Incorrectly Selected:\n // - white \"X\" in red circle\n // - heavy outline around the selection should appear in red\n // - Incorrectly Not Selected: white \"X\" in red circle\n let iconSrc;\n\n if (showCorrectEnabled) {\n if ((selected && isCorrect) || (!selected && !isCorrect)) {\n iconSrc = faCorrect;\n }\n } else {\n if (selected) {\n if (isCorrect) {\n iconSrc = faCorrect;\n } else {\n iconSrc = faWrong;\n }\n } else if (!isCorrect) {\n iconSrc = faWrong;\n }\n }\n\n const { hovered } = this.state;\n const useHoveredStyle = hovered && hoverOutlineColor;\n\n return (\n <Group scaleX={scale} scaleY={scale}>\n {useHoveredStyle && (\n <Rect\n x={x}\n y={y}\n width={width}\n height={height}\n stroke={selected ? 'transparent' : hoverOutlineColor}\n strokeWidth={strokeWidth}\n listening={false}\n />\n )}\n <Rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill={selected && selectedHotspotColor ? selectedHotspotColor : hotspotColor}\n onClick={this.handleClick}\n onTap={this.handleClick}\n draggable={false}\n stroke={useHoveredStyle && !selected ? 'transparent' : outlineColorParsed}\n strokeWidth={useHoveredStyle && !selected ? 0 : outlineWidth}\n onMouseLeave={this.handleMouseLeave}\n onMouseEnter={this.handleMouseEnter}\n cursor=\"pointer\"\n />\n {isEvaluateMode && iconSrc ? <ImageComponent src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}\n </Group>\n );\n }\n}\n\nRectComponent.propTypes = {\n height: PropTypes.number.isRequired,\n hotspotColor: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n isCorrect: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),\n isEvaluateMode: PropTypes.bool.isRequired,\n hoverOutlineColor: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n onClick: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n selected: PropTypes.bool.isRequired,\n width: PropTypes.number.isRequired,\n x: PropTypes.number.isRequired,\n y: PropTypes.number.isRequired,\n evaluateText: PropTypes.string,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n selectedHotspotColor: PropTypes.string,\n markAsCorrect: PropTypes.bool.isRequired,\n showCorrectEnabled: PropTypes.bool.isRequired,\n};\n\nRectComponent.defaultProps = {\n isCorrect: false,\n evaluateText: null,\n strokeWidth: 5,\n scale: 1,\n};\n\nexport default RectComponent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE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AAa,EAAE4C,kBAAS,CAACK,IAAI,CAACH,UAAU;EACxC5C,kBAAkB,EAAE0C,kBAAS,CAACK,IAAI,CAACH;AACrC,CAAC;AAEDnE,aAAa,CAACwE,YAAY,GAAG;EAC3BpD,SAAS,EAAE,KAAK;EAChBe,YAAY,EAAE,IAAI;EAClBX,WAAW,EAAE,CAAC;EACdY,KAAK,EAAE;AACT,CAAC;AAAC,IAAAqC,QAAA,GAAAC,OAAA,CAAApE,OAAA,GAEaN,aAAa","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/hotspot",
3
- "version": "10.0.0-beta.0",
3
+ "version": "10.0.0-next.0+67da381",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -12,19 +12,19 @@
12
12
  "@mui/icons-material": "^7.3.4",
13
13
  "@mui/material": "^7.3.4",
14
14
  "@pie-framework/pie-player-events": "^0.1.0",
15
- "@pie-lib/correct-answer-toggle": "2.25.4-next.0",
16
- "@pie-lib/math-rendering": "3.22.3-next.0",
17
- "@pie-lib/render-ui": "4.35.4-next.0",
18
- "@pie-lib/test-utils": "0.22.3-next.0",
15
+ "@pie-lib/correct-answer-toggle": "3.1.1-next.1",
16
+ "@pie-lib/math-rendering": "4.1.1-next.1",
17
+ "@pie-lib/render-ui": "5.1.1-next.1",
18
+ "@pie-lib/test-utils": "1.1.1-next.1",
19
19
  "konva": "8.3.0",
20
- "prop-types": "^15.6.1",
21
- "react": "18.2.0",
22
- "react-dom": "18.2.0",
23
- "react-konva": "18.1.0"
20
+ "prop-types": "^15.8.1",
21
+ "react": "18.3.1",
22
+ "react-dom": "18.3.1",
23
+ "react-konva": "^18.2.14"
24
24
  },
25
25
  "author": "pie framework developers",
26
26
  "license": "ISC",
27
- "gitHead": "152071b68dd68e003f320561a30f681987f50b65",
27
+ "gitHead": "67da3818d2af966110c6e85f6e8e238b79515eb2",
28
28
  "scripts": {
29
29
  "postpublish": "../../scripts/postpublish"
30
30
  },
@@ -0,0 +1,464 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import Konva from 'konva';
4
+ import CircleComponent from '../circle';
5
+
6
+ Konva.isBrowser = false;
7
+
8
+ jest.mock('react-konva', () => {
9
+ const React = require('react');
10
+ return {
11
+ Circle: ({ onClick, onTap, onMouseEnter, onMouseLeave, ...props }) => {
12
+ const handleClick = (e) => {
13
+ if (onClick) onClick(e);
14
+ if (onTap) onTap(e);
15
+ };
16
+ return React.createElement('div', {
17
+ 'data-testid': 'circle',
18
+ onClick: handleClick,
19
+ onMouseEnter,
20
+ onMouseLeave,
21
+ ...props,
22
+ });
23
+ },
24
+ Rect: (props) => React.createElement('div', { 'data-testid': 'rect', ...props }),
25
+ Group: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'group', ...props }, children),
26
+ };
27
+ });
28
+
29
+ jest.mock('../image-konva-tooltip', () => {
30
+ return function ImageComponent({ src, x, y, tooltip }) {
31
+ return <div data-testid="icon-image" data-src={src} data-x={x} data-y={y} data-tooltip={tooltip} />;
32
+ };
33
+ });
34
+
35
+ describe('CircleComponent', () => {
36
+ let defaultProps;
37
+
38
+ beforeEach(() => {
39
+ defaultProps = {
40
+ id: 'circle1',
41
+ x: 50,
42
+ y: 50,
43
+ radius: 30,
44
+ hotspotColor: '#FF0000',
45
+ selectedHotspotColor: '#00FF00',
46
+ outlineColor: '#0000FF',
47
+ hoverOutlineColor: '#FFFF00',
48
+ selected: false,
49
+ isCorrect: false,
50
+ isEvaluateMode: false,
51
+ disabled: false,
52
+ onClick: jest.fn(),
53
+ strokeWidth: 5,
54
+ scale: 1,
55
+ markAsCorrect: false,
56
+ showCorrectEnabled: false,
57
+ };
58
+ });
59
+
60
+ afterEach(() => {
61
+ document.body.style.cursor = 'default';
62
+ });
63
+
64
+ describe('rendering', () => {
65
+ it('should render without crashing', () => {
66
+ const { container } = render(<CircleComponent {...defaultProps} />);
67
+ expect(container).toBeTruthy();
68
+ });
69
+
70
+ it('should render with correct position and radius', () => {
71
+ const { getByTestId } = render(<CircleComponent {...defaultProps} />);
72
+ const circle = getByTestId('circle');
73
+
74
+ expect(circle).toHaveAttribute('x', '50');
75
+ expect(circle).toHaveAttribute('y', '50');
76
+ expect(circle).toHaveAttribute('radius', '30');
77
+ });
78
+
79
+ it('should render with hotspot color when not selected', () => {
80
+ const { getByTestId } = render(<CircleComponent {...defaultProps} />);
81
+ const circle = getByTestId('circle');
82
+
83
+ expect(circle).toHaveAttribute('fill', '#FF0000');
84
+ });
85
+
86
+ it('should render with selected color when selected', () => {
87
+ const { getByTestId } = render(<CircleComponent {...defaultProps} selected={true} />);
88
+ const circle = getByTestId('circle');
89
+
90
+ expect(circle).toHaveAttribute('fill', '#00FF00');
91
+ });
92
+
93
+ it('should apply scale transform', () => {
94
+ const { getByTestId } = render(<CircleComponent {...defaultProps} scale={2.0} />);
95
+ const group = getByTestId('group');
96
+
97
+ expect(group).toHaveAttribute('scaleX', '2');
98
+ expect(group).toHaveAttribute('scaleY', '2');
99
+ });
100
+
101
+ it('should render with default scale of 1', () => {
102
+ const { getByTestId } = render(<CircleComponent {...defaultProps} />);
103
+ const group = getByTestId('group');
104
+
105
+ expect(group).toHaveAttribute('scaleX', '1');
106
+ expect(group).toHaveAttribute('scaleY', '1');
107
+ });
108
+ });
109
+
110
+ describe('interactions', () => {
111
+ it('should call onClick when clicked', () => {
112
+ const onClick = jest.fn();
113
+ const { getByTestId } = render(<CircleComponent {...defaultProps} onClick={onClick} />);
114
+ const circle = getByTestId('circle');
115
+
116
+ fireEvent.click(circle);
117
+
118
+ expect(onClick).toHaveBeenCalledWith({
119
+ id: 'circle1',
120
+ selected: true,
121
+ selector: 'Mouse',
122
+ });
123
+ });
124
+
125
+ it('should toggle selection state on click', () => {
126
+ const onClick = jest.fn();
127
+ const { getByTestId, rerender } = render(<CircleComponent {...defaultProps} onClick={onClick} selected={false} />);
128
+ const circle = getByTestId('circle');
129
+
130
+ fireEvent.click(circle);
131
+
132
+ expect(onClick).toHaveBeenCalledWith({
133
+ id: 'circle1',
134
+ selected: true,
135
+ selector: 'Mouse',
136
+ });
137
+
138
+ rerender(<CircleComponent {...defaultProps} onClick={onClick} selected={true} />);
139
+
140
+ const circleAfter = getByTestId('circle');
141
+ fireEvent.click(circleAfter);
142
+
143
+ expect(onClick).toHaveBeenCalledWith({
144
+ id: 'circle1',
145
+ selected: false,
146
+ selector: 'Mouse',
147
+ });
148
+ });
149
+
150
+ it('should not call onClick when disabled', () => {
151
+ const onClick = jest.fn();
152
+ const { getByTestId } = render(<CircleComponent {...defaultProps} onClick={onClick} disabled={true} />);
153
+ const circle = getByTestId('circle');
154
+
155
+ fireEvent.click(circle);
156
+
157
+ expect(onClick).not.toHaveBeenCalled();
158
+ });
159
+
160
+ it('should change cursor to pointer on mouse enter when not disabled', () => {
161
+ const { getByTestId } = render(<CircleComponent {...defaultProps} />);
162
+ const circle = getByTestId('circle');
163
+
164
+ fireEvent.mouseEnter(circle);
165
+
166
+ expect(document.body.style.cursor).toBe('pointer');
167
+ });
168
+
169
+ it('should not change cursor when disabled', () => {
170
+ const { getByTestId } = render(<CircleComponent {...defaultProps} disabled={true} />);
171
+ const circle = getByTestId('circle');
172
+
173
+ fireEvent.mouseEnter(circle);
174
+
175
+ expect(document.body.style.cursor).toBe('default');
176
+ });
177
+
178
+ it('should reset cursor to default on mouse leave', () => {
179
+ const { getByTestId } = render(<CircleComponent {...defaultProps} />);
180
+ const circle = getByTestId('circle');
181
+
182
+ fireEvent.mouseEnter(circle);
183
+ fireEvent.mouseLeave(circle);
184
+
185
+ expect(document.body.style.cursor).toBe('default');
186
+ });
187
+ });
188
+
189
+ describe('hover styling', () => {
190
+ it('should show hover rect when hoverOutlineColor is provided', () => {
191
+ const { container, getByTestId } = render(<CircleComponent {...defaultProps} hoverOutlineColor="#FFFF00" />);
192
+ const circle = getByTestId('circle');
193
+
194
+ fireEvent.mouseEnter(circle);
195
+
196
+ const rects = container.querySelectorAll('[data-testid="rect"]');
197
+ expect(rects.length).toBeGreaterThan(0);
198
+ });
199
+
200
+ it('should render hover rect with correct dimensions based on radius', () => {
201
+ const { container, getByTestId } = render(
202
+ <CircleComponent
203
+ {...defaultProps}
204
+ x={50}
205
+ y={50}
206
+ radius={30}
207
+ hoverOutlineColor="#FFFF00"
208
+ />
209
+ );
210
+ const circle = getByTestId('circle');
211
+
212
+ fireEvent.mouseEnter(circle);
213
+
214
+ const rect = container.querySelector('[data-testid="rect"]');
215
+ if (rect) {
216
+ // Rect should be positioned at (x - radius, y - radius) with width/height = radius * 2
217
+ expect(rect).toHaveAttribute('x', '20'); // 50 - 30
218
+ expect(rect).toHaveAttribute('y', '20'); // 50 - 30
219
+ expect(rect).toHaveAttribute('width', '60'); // 30 * 2
220
+ expect(rect).toHaveAttribute('height', '60'); // 30 * 2
221
+ }
222
+ });
223
+
224
+ it('should show transparent stroke when selected and hovering', () => {
225
+ const { container, getByTestId } = render(
226
+ <CircleComponent {...defaultProps} selected={true} hoverOutlineColor="#FFFF00" />
227
+ );
228
+ const circle = getByTestId('circle');
229
+
230
+ fireEvent.mouseEnter(circle);
231
+
232
+ const rect = container.querySelector('[data-testid="rect"]');
233
+ if (rect) {
234
+ expect(rect).toHaveAttribute('stroke', 'transparent');
235
+ }
236
+ });
237
+ });
238
+
239
+ describe('evaluate mode', () => {
240
+ it('should show correct icon when correctly selected in evaluate mode', () => {
241
+ const { getByTestId } = render(
242
+ <CircleComponent
243
+ {...defaultProps}
244
+ isEvaluateMode={true}
245
+ selected={true}
246
+ isCorrect={true}
247
+ showCorrectEnabled={false}
248
+ />
249
+ );
250
+
251
+ const icon = getByTestId('icon-image');
252
+ expect(icon).toBeInTheDocument();
253
+ });
254
+
255
+ it('should show wrong icon when incorrectly selected in evaluate mode', () => {
256
+ const { getByTestId } = render(
257
+ <CircleComponent
258
+ {...defaultProps}
259
+ isEvaluateMode={true}
260
+ selected={true}
261
+ isCorrect={false}
262
+ showCorrectEnabled={false}
263
+ />
264
+ );
265
+
266
+ const icon = getByTestId('icon-image');
267
+ expect(icon).toBeInTheDocument();
268
+ });
269
+
270
+ it('should show wrong icon when incorrectly not selected', () => {
271
+ const { getByTestId } = render(
272
+ <CircleComponent
273
+ {...defaultProps}
274
+ isEvaluateMode={true}
275
+ selected={false}
276
+ isCorrect={false}
277
+ showCorrectEnabled={false}
278
+ />
279
+ );
280
+
281
+ const icon = getByTestId('icon-image');
282
+ expect(icon).toBeInTheDocument();
283
+ });
284
+
285
+ it('should not show icon when correctly not selected in evaluate mode', () => {
286
+ const { queryByTestId } = render(
287
+ <CircleComponent
288
+ {...defaultProps}
289
+ isEvaluateMode={true}
290
+ selected={false}
291
+ isCorrect={true}
292
+ showCorrectEnabled={false}
293
+ />
294
+ );
295
+
296
+ const icon = queryByTestId('icon-image');
297
+ expect(icon).not.toBeInTheDocument();
298
+ });
299
+
300
+ it('should show correct icon for showCorrect mode when correctly selected', () => {
301
+ const { getByTestId } = render(
302
+ <CircleComponent
303
+ {...defaultProps}
304
+ isEvaluateMode={true}
305
+ selected={true}
306
+ isCorrect={true}
307
+ showCorrectEnabled={true}
308
+ />
309
+ );
310
+
311
+ const icon = getByTestId('icon-image');
312
+ expect(icon).toBeInTheDocument();
313
+ });
314
+
315
+ it('should show correct icon for showCorrect mode when incorrectly not selected', () => {
316
+ const { getByTestId } = render(
317
+ <CircleComponent
318
+ {...defaultProps}
319
+ isEvaluateMode={true}
320
+ selected={false}
321
+ isCorrect={false}
322
+ showCorrectEnabled={true}
323
+ />
324
+ );
325
+
326
+ const icon = getByTestId('icon-image');
327
+ expect(icon).toBeInTheDocument();
328
+ });
329
+
330
+ it('should not show icon in showCorrect mode when correctly not selected', () => {
331
+ const { queryByTestId } = render(
332
+ <CircleComponent
333
+ {...defaultProps}
334
+ isEvaluateMode={true}
335
+ selected={false}
336
+ isCorrect={true}
337
+ showCorrectEnabled={true}
338
+ />
339
+ );
340
+
341
+ const icon = queryByTestId('icon-image');
342
+ expect(icon).not.toBeInTheDocument();
343
+ });
344
+
345
+ it('should not show icon in showCorrect mode when incorrectly selected', () => {
346
+ const { queryByTestId } = render(
347
+ <CircleComponent
348
+ {...defaultProps}
349
+ isEvaluateMode={true}
350
+ selected={true}
351
+ isCorrect={false}
352
+ showCorrectEnabled={true}
353
+ />
354
+ );
355
+
356
+ const icon = queryByTestId('icon-image');
357
+ expect(icon).not.toBeInTheDocument();
358
+ });
359
+
360
+ it('should show green outline when markAsCorrect is true', () => {
361
+ const { getByTestId } = render(
362
+ <CircleComponent
363
+ {...defaultProps}
364
+ isEvaluateMode={true}
365
+ markAsCorrect={true}
366
+ />
367
+ );
368
+
369
+ const circle = getByTestId('circle');
370
+ expect(circle).toHaveAttribute('stroke', 'green');
371
+ });
372
+
373
+ it('should show red outline when incorrect and not markAsCorrect', () => {
374
+ const { getByTestId } = render(
375
+ <CircleComponent
376
+ {...defaultProps}
377
+ isEvaluateMode={true}
378
+ isCorrect={false}
379
+ markAsCorrect={false}
380
+ />
381
+ );
382
+
383
+ const circle = getByTestId('circle');
384
+ expect(circle).toHaveAttribute('stroke', 'red');
385
+ });
386
+
387
+ it('should display evaluate text in tooltip', () => {
388
+ const { getByTestId } = render(
389
+ <CircleComponent
390
+ {...defaultProps}
391
+ isEvaluateMode={true}
392
+ selected={true}
393
+ isCorrect={true}
394
+ evaluateText="Great job!"
395
+ showCorrectEnabled={false}
396
+ />
397
+ );
398
+
399
+ const icon = getByTestId('icon-image');
400
+ expect(icon).toHaveAttribute('data-tooltip', 'Great job!');
401
+ });
402
+ });
403
+
404
+ describe('icon positioning', () => {
405
+ it('should position icon at center of circle minus offset', () => {
406
+ const { getByTestId } = render(
407
+ <CircleComponent
408
+ {...defaultProps}
409
+ x={100}
410
+ y={100}
411
+ radius={30}
412
+ isEvaluateMode={true}
413
+ selected={true}
414
+ isCorrect={true}
415
+ showCorrectEnabled={false}
416
+ />
417
+ );
418
+
419
+ const icon = getByTestId('icon-image');
420
+ // Icon should be at x - 10, y - 10
421
+ expect(icon).toHaveAttribute('data-x', '90');
422
+ expect(icon).toHaveAttribute('data-y', '90');
423
+ });
424
+ });
425
+
426
+ describe('edge cases', () => {
427
+ it('should handle very small radius', () => {
428
+ const { getByTestId } = render(
429
+ <CircleComponent
430
+ {...defaultProps}
431
+ radius={5}
432
+ />
433
+ );
434
+
435
+ const circle = getByTestId('circle');
436
+ expect(circle).toHaveAttribute('radius', '5');
437
+ });
438
+
439
+ it('should handle very large radius', () => {
440
+ const { getByTestId } = render(
441
+ <CircleComponent
442
+ {...defaultProps}
443
+ radius={200}
444
+ />
445
+ );
446
+
447
+ const circle = getByTestId('circle');
448
+ expect(circle).toHaveAttribute('radius', '200');
449
+ });
450
+
451
+ it('should handle different scale values', () => {
452
+ const { getByTestId } = render(
453
+ <CircleComponent
454
+ {...defaultProps}
455
+ scale={0.5}
456
+ />
457
+ );
458
+
459
+ const group = getByTestId('group');
460
+ expect(group).toHaveAttribute('scaleX', '0.5');
461
+ expect(group).toHaveAttribute('scaleY', '0.5');
462
+ });
463
+ });
464
+ });