@pie-element/hotspot 11.3.2-beta.5 → 11.3.2-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/configure/CHANGELOG.md +4 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +4 -0
- package/controller/package.json +1 -1
- package/package.json +2 -2
- package/configure/lib/DeleteWidget.js +0 -64
- package/configure/lib/DeleteWidget.js.map +0 -1
- package/configure/lib/button.js +0 -42
- package/configure/lib/button.js.map +0 -1
- package/configure/lib/buttons/circle.js +0 -33
- package/configure/lib/buttons/circle.js.map +0 -1
- package/configure/lib/buttons/polygon.js +0 -39
- package/configure/lib/buttons/polygon.js.map +0 -1
- package/configure/lib/buttons/rectangle.js +0 -39
- package/configure/lib/buttons/rectangle.js.map +0 -1
- package/configure/lib/defaults.js +0 -155
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/hotspot-circle.js +0 -192
- package/configure/lib/hotspot-circle.js.map +0 -1
- package/configure/lib/hotspot-container.js +0 -320
- package/configure/lib/hotspot-container.js.map +0 -1
- package/configure/lib/hotspot-drawable.js +0 -519
- package/configure/lib/hotspot-drawable.js.map +0 -1
- package/configure/lib/hotspot-palette.js +0 -107
- package/configure/lib/hotspot-palette.js.map +0 -1
- package/configure/lib/hotspot-polygon.js +0 -293
- package/configure/lib/hotspot-polygon.js.map +0 -1
- package/configure/lib/hotspot-rectangle.js +0 -190
- package/configure/lib/hotspot-rectangle.js.map +0 -1
- package/configure/lib/icons.js +0 -7
- package/configure/lib/icons.js.map +0 -1
- package/configure/lib/image-konva.js +0 -66
- package/configure/lib/image-konva.js.map +0 -1
- package/configure/lib/index.js +0 -198
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/root.js +0 -331
- package/configure/lib/root.js.map +0 -1
- package/configure/lib/shapes/circle.js +0 -84
- package/configure/lib/shapes/circle.js.map +0 -1
- package/configure/lib/shapes/index.js +0 -50
- package/configure/lib/shapes/index.js.map +0 -1
- package/configure/lib/shapes/polygon.js +0 -82
- package/configure/lib/shapes/polygon.js.map +0 -1
- package/configure/lib/shapes/rectagle.js +0 -84
- package/configure/lib/shapes/rectagle.js.map +0 -1
- package/configure/lib/shapes/utils.js +0 -21
- package/configure/lib/shapes/utils.js.map +0 -1
- package/configure/lib/upload-control.js +0 -41
- package/configure/lib/upload-control.js.map +0 -1
- package/configure/lib/utils.js +0 -185
- package/configure/lib/utils.js.map +0 -1
- package/controller/lib/defaults.js +0 -33
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -342
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -32
- package/controller/lib/utils.js.map +0 -1
- package/lib/hotspot/circle.js +0 -160
- package/lib/hotspot/circle.js.map +0 -1
- package/lib/hotspot/container.js +0 -291
- package/lib/hotspot/container.js.map +0 -1
- package/lib/hotspot/icons.js +0 -8
- package/lib/hotspot/icons.js.map +0 -1
- package/lib/hotspot/image-konva-tooltip.js +0 -86
- package/lib/hotspot/image-konva-tooltip.js.map +0 -1
- package/lib/hotspot/index.js +0 -174
- package/lib/hotspot/index.js.map +0 -1
- package/lib/hotspot/polygon.js +0 -207
- package/lib/hotspot/polygon.js.map +0 -1
- package/lib/hotspot/rectangle.js +0 -178
- package/lib/hotspot/rectangle.js.map +0 -1
- package/lib/index.js +0 -214
- package/lib/index.js.map +0 -1
- package/lib/session-updater.js +0 -42
- package/lib/session-updater.js.map +0 -1
package/lib/hotspot/polygon.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
var _reactKonva = require("react-konva");
|
|
12
|
-
var _imageKonvaTooltip = _interopRequireDefault(require("./image-konva-tooltip"));
|
|
13
|
-
var _icons = require("./icons");
|
|
14
|
-
class PolygonComponent extends _react.default.Component {
|
|
15
|
-
constructor(props) {
|
|
16
|
-
super(props);
|
|
17
|
-
(0, _defineProperty2.default)(this, "getPolygonCenter", points => {
|
|
18
|
-
const x = points.map(({
|
|
19
|
-
x
|
|
20
|
-
}) => x);
|
|
21
|
-
const y = points.map(({
|
|
22
|
-
y
|
|
23
|
-
}) => y);
|
|
24
|
-
const minX = Math.min.apply(null, x);
|
|
25
|
-
const maxX = Math.max.apply(null, x);
|
|
26
|
-
const minY = Math.min.apply(null, y);
|
|
27
|
-
const maxY = Math.max.apply(null, y);
|
|
28
|
-
return [(minX + maxX) / 2, (minY + maxY) / 2];
|
|
29
|
-
});
|
|
30
|
-
(0, _defineProperty2.default)(this, "parsePointsForKonva", points => {
|
|
31
|
-
const parsedPoints = [];
|
|
32
|
-
points.forEach(({
|
|
33
|
-
x,
|
|
34
|
-
y
|
|
35
|
-
}) => {
|
|
36
|
-
parsedPoints.push(x);
|
|
37
|
-
parsedPoints.push(y);
|
|
38
|
-
});
|
|
39
|
-
return parsedPoints;
|
|
40
|
-
});
|
|
41
|
-
(0, _defineProperty2.default)(this, "handleClick", e => {
|
|
42
|
-
const {
|
|
43
|
-
onClick,
|
|
44
|
-
id,
|
|
45
|
-
selected,
|
|
46
|
-
disabled
|
|
47
|
-
} = this.props;
|
|
48
|
-
if (!disabled) {
|
|
49
|
-
e.cancelBubble = true;
|
|
50
|
-
onClick({
|
|
51
|
-
id,
|
|
52
|
-
selected: !selected,
|
|
53
|
-
selector: 'Mouse'
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
(0, _defineProperty2.default)(this, "handleMouseEnter", () => {
|
|
58
|
-
const {
|
|
59
|
-
disabled
|
|
60
|
-
} = this.props;
|
|
61
|
-
if (!disabled) {
|
|
62
|
-
document.body.style.cursor = 'pointer';
|
|
63
|
-
}
|
|
64
|
-
this.setState({
|
|
65
|
-
hovered: true
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
(0, _defineProperty2.default)(this, "handleMouseLeave", () => {
|
|
69
|
-
document.body.style.cursor = 'default';
|
|
70
|
-
this.setState({
|
|
71
|
-
hovered: false
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
(0, _defineProperty2.default)(this, "getEvaluateOutlineColor", (isCorrect, markAsCorrect, outlineColor) => markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red');
|
|
75
|
-
(0, _defineProperty2.default)(this, "getOutlineWidth", (showCorrectEnabled, selected, markAsCorrect, strokeWidth) => markAsCorrect || !markAsCorrect && !showCorrectEnabled && selected ? strokeWidth : 0);
|
|
76
|
-
this.state = {
|
|
77
|
-
hovered: false
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
render() {
|
|
81
|
-
const {
|
|
82
|
-
hotspotColor,
|
|
83
|
-
isCorrect,
|
|
84
|
-
isEvaluateMode,
|
|
85
|
-
hoverOutlineColor,
|
|
86
|
-
outlineColor,
|
|
87
|
-
selected,
|
|
88
|
-
focused,
|
|
89
|
-
points,
|
|
90
|
-
evaluateText,
|
|
91
|
-
strokeWidth,
|
|
92
|
-
scale,
|
|
93
|
-
markAsCorrect,
|
|
94
|
-
selectedHotspotColor,
|
|
95
|
-
showCorrectEnabled
|
|
96
|
-
} = this.props;
|
|
97
|
-
const {
|
|
98
|
-
hovered
|
|
99
|
-
} = this.state;
|
|
100
|
-
const outlineColorParsed = isEvaluateMode ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor) : outlineColor;
|
|
101
|
-
const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);
|
|
102
|
-
const pointsParsed = this.parsePointsForKonva(points);
|
|
103
|
-
const center = this.getPolygonCenter(points);
|
|
104
|
-
const iconX = center[0];
|
|
105
|
-
const iconY = center[1];
|
|
106
|
-
|
|
107
|
-
// "Show Correct Answer" Enabled:
|
|
108
|
-
// - Correctly Selected: white checkmark in green circle
|
|
109
|
-
// - Correctly Not Selected: none
|
|
110
|
-
// - Incorrectly Selected: none
|
|
111
|
-
// - Incorrectly Not Selected: white checkmark in green circle
|
|
112
|
-
// "Show Correct Answer" Disabled:
|
|
113
|
-
// - Correctly Selected:
|
|
114
|
-
// - white checkmark in green circle
|
|
115
|
-
// - heavy outline, as on “Gather”
|
|
116
|
-
// - Correctly Not Selected: none
|
|
117
|
-
// - Incorrectly Selected:
|
|
118
|
-
// - white "X" in red circle
|
|
119
|
-
// - heavy outline around the selection should appear in red
|
|
120
|
-
// - Incorrectly Not Selected: white "X" in red circle
|
|
121
|
-
let iconSrc;
|
|
122
|
-
if (showCorrectEnabled) {
|
|
123
|
-
if (selected && isCorrect || !selected && !isCorrect) {
|
|
124
|
-
iconSrc = _icons.faCorrect;
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
if (selected) {
|
|
128
|
-
if (isCorrect) {
|
|
129
|
-
iconSrc = _icons.faCorrect;
|
|
130
|
-
} else {
|
|
131
|
-
iconSrc = _icons.faWrong;
|
|
132
|
-
}
|
|
133
|
-
} else if (!isCorrect) {
|
|
134
|
-
iconSrc = _icons.faWrong;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const useHoveredStyle = (hovered || focused) && hoverOutlineColor;
|
|
138
|
-
const xValues = pointsParsed.filter((_, index) => index % 2 === 0); // Even indices are x-coordinates
|
|
139
|
-
const yValues = pointsParsed.filter((_, index) => index % 2 !== 0); // Odd indices are y-coordinates
|
|
140
|
-
|
|
141
|
-
const minX = Math.min(...xValues);
|
|
142
|
-
const maxX = Math.max(...xValues);
|
|
143
|
-
const minY = Math.min(...yValues);
|
|
144
|
-
const maxY = Math.max(...yValues);
|
|
145
|
-
const rectX = minX;
|
|
146
|
-
const rectY = minY;
|
|
147
|
-
const rectWidth = maxX - minX;
|
|
148
|
-
const rectHeight = maxY - minY;
|
|
149
|
-
return /*#__PURE__*/_react.default.createElement(_reactKonva.Group, {
|
|
150
|
-
scaleX: scale,
|
|
151
|
-
scaleY: scale,
|
|
152
|
-
onMouseEnter: this.handleMouseEnter,
|
|
153
|
-
onMouseLeave: this.handleMouseLeave
|
|
154
|
-
}, /*#__PURE__*/_react.default.createElement(_reactKonva.Line, {
|
|
155
|
-
points: pointsParsed,
|
|
156
|
-
closed: true,
|
|
157
|
-
fill: selected && selectedHotspotColor ? selectedHotspotColor : hotspotColor,
|
|
158
|
-
onClick: this.handleClick,
|
|
159
|
-
onTap: this.handleClick,
|
|
160
|
-
draggable: false,
|
|
161
|
-
stroke: useHoveredStyle && !selected ? 'transparent' : outlineColorParsed,
|
|
162
|
-
strokeWidth: useHoveredStyle && !selected ? 0 : outlineWidth,
|
|
163
|
-
cursor: "pointer",
|
|
164
|
-
position: "relative"
|
|
165
|
-
}), useHoveredStyle && /*#__PURE__*/_react.default.createElement(_reactKonva.Rect, {
|
|
166
|
-
x: rectX,
|
|
167
|
-
y: rectY,
|
|
168
|
-
width: rectWidth,
|
|
169
|
-
height: rectHeight,
|
|
170
|
-
stroke: hoverOutlineColor,
|
|
171
|
-
strokeWidth: strokeWidth,
|
|
172
|
-
listening: false
|
|
173
|
-
}), isEvaluateMode && iconSrc ? /*#__PURE__*/_react.default.createElement(_imageKonvaTooltip.default, {
|
|
174
|
-
src: iconSrc,
|
|
175
|
-
x: iconX,
|
|
176
|
-
y: iconY,
|
|
177
|
-
tooltip: evaluateText
|
|
178
|
-
}) : null);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
PolygonComponent.propTypes = {
|
|
182
|
-
hotspotColor: _propTypes.default.string.isRequired,
|
|
183
|
-
id: _propTypes.default.string.isRequired,
|
|
184
|
-
isCorrect: _propTypes.default.bool.isRequired,
|
|
185
|
-
isEvaluateMode: _propTypes.default.bool.isRequired,
|
|
186
|
-
hoverOutlineColor: _propTypes.default.string,
|
|
187
|
-
disabled: _propTypes.default.bool.isRequired,
|
|
188
|
-
focused: _propTypes.default.bool,
|
|
189
|
-
onClick: _propTypes.default.func.isRequired,
|
|
190
|
-
outlineColor: _propTypes.default.string.isRequired,
|
|
191
|
-
points: _propTypes.default.array.isRequired,
|
|
192
|
-
selected: _propTypes.default.bool.isRequired,
|
|
193
|
-
evaluateText: _propTypes.default.string,
|
|
194
|
-
selectedHotspotColor: _propTypes.default.string,
|
|
195
|
-
strokeWidth: _propTypes.default.number,
|
|
196
|
-
scale: _propTypes.default.number,
|
|
197
|
-
markAsCorrect: _propTypes.default.bool.isRequired,
|
|
198
|
-
showCorrectEnabled: _propTypes.default.bool.isRequired
|
|
199
|
-
};
|
|
200
|
-
PolygonComponent.defaultProps = {
|
|
201
|
-
evaluateText: null,
|
|
202
|
-
focused: false,
|
|
203
|
-
strokeWidth: 5,
|
|
204
|
-
scale: 1
|
|
205
|
-
};
|
|
206
|
-
var _default = exports.default = PolygonComponent;
|
|
207
|
-
//# sourceMappingURL=polygon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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","focused","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","onMouseEnter","handleMouseEnter","onMouseLeave","handleMouseLeave","Line","closed","fill","handleClick","onTap","draggable","stroke","position","Rect","width","height","listening","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 focused,\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 || focused) && 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} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>\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 cursor=\"pointer\"\n position=\"relative\"\n />\n {useHoveredStyle && (\n <Rect\n x={rectX}\n y={rectY}\n width={rectWidth}\n height={rectHeight}\n stroke={hoverOutlineColor}\n strokeWidth={strokeWidth}\n listening={false}\n />\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 focused: PropTypes.bool,\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 focused: false,\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,CA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CAACG,IAAI,CAACD,UAAU;EACnCnD,YAAY,EAAEiD,kBAAS,CAACC,MAAM;EAC9BhD,oBAAoB,EAAE+C,kBAAS,CAACC,MAAM;EACtCzD,WAAW,EAAEwD,kBAAS,CAACM,MAAM;EAC7BtD,KAAK,EAAEgD,kBAAS,CAACM,MAAM;EACvBjE,aAAa,EAAE2D,kBAAS,CAACG,IAAI,CAACD,UAAU;EACxC3D,kBAAkB,EAAEyD,kBAAS,CAACG,IAAI,CAACD;AACrC,CAAC;AAEDjG,gBAAgB,CAACsG,YAAY,GAAG;EAC9BxD,YAAY,EAAE,IAAI;EAClBD,OAAO,EAAE,KAAK;EACdN,WAAW,EAAE,CAAC;EACdQ,KAAK,EAAE;AACT,CAAC;AAAC,IAAAwD,QAAA,GAAAC,OAAA,CAAAlG,OAAA,GAEaN,gBAAgB","ignoreList":[]}
|
package/lib/hotspot/rectangle.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
var _reactKonva = require("react-konva");
|
|
12
|
-
var _imageKonvaTooltip = _interopRequireDefault(require("./image-konva-tooltip"));
|
|
13
|
-
var _icons = require("./icons");
|
|
14
|
-
class RectComponent extends _react.default.Component {
|
|
15
|
-
constructor(props) {
|
|
16
|
-
super(props);
|
|
17
|
-
(0, _defineProperty2.default)(this, "handleClick", e => {
|
|
18
|
-
const {
|
|
19
|
-
onClick,
|
|
20
|
-
id,
|
|
21
|
-
selected,
|
|
22
|
-
disabled
|
|
23
|
-
} = this.props;
|
|
24
|
-
if (!disabled) {
|
|
25
|
-
e.cancelBubble = true;
|
|
26
|
-
onClick({
|
|
27
|
-
id,
|
|
28
|
-
selected: !selected,
|
|
29
|
-
selector: 'Mouse'
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
(0, _defineProperty2.default)(this, "handleMouseEnter", () => {
|
|
34
|
-
const {
|
|
35
|
-
disabled
|
|
36
|
-
} = this.props;
|
|
37
|
-
if (!disabled) {
|
|
38
|
-
document.body.style.cursor = 'pointer';
|
|
39
|
-
}
|
|
40
|
-
this.setState({
|
|
41
|
-
hovered: true
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
(0, _defineProperty2.default)(this, "handleMouseLeave", () => {
|
|
45
|
-
document.body.style.cursor = 'default';
|
|
46
|
-
this.setState({
|
|
47
|
-
hovered: false
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
(0, _defineProperty2.default)(this, "getEvaluateOutlineColor", (isCorrect, markAsCorrect, outlineColor) => markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red');
|
|
51
|
-
(0, _defineProperty2.default)(this, "getOutlineWidth", (showCorrectEnabled, selected, markAsCorrect, strokeWidth) => markAsCorrect || !markAsCorrect && !showCorrectEnabled && selected ? strokeWidth : 0);
|
|
52
|
-
this.state = {
|
|
53
|
-
hovered: false
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
render() {
|
|
57
|
-
const {
|
|
58
|
-
height,
|
|
59
|
-
hotspotColor,
|
|
60
|
-
hoverOutlineColor,
|
|
61
|
-
selectedHotspotColor,
|
|
62
|
-
isCorrect,
|
|
63
|
-
isEvaluateMode,
|
|
64
|
-
outlineColor,
|
|
65
|
-
selected,
|
|
66
|
-
focused,
|
|
67
|
-
width,
|
|
68
|
-
x,
|
|
69
|
-
y,
|
|
70
|
-
evaluateText,
|
|
71
|
-
strokeWidth,
|
|
72
|
-
scale,
|
|
73
|
-
markAsCorrect,
|
|
74
|
-
showCorrectEnabled
|
|
75
|
-
} = this.props;
|
|
76
|
-
const {
|
|
77
|
-
hovered
|
|
78
|
-
} = this.state;
|
|
79
|
-
const outlineColorParsed = isEvaluateMode ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor) : outlineColor;
|
|
80
|
-
const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);
|
|
81
|
-
const iconX = x + width / 2 - 10;
|
|
82
|
-
const iconY = y + height / 2 - 10;
|
|
83
|
-
|
|
84
|
-
// "Show Correct Answer" Enabled:
|
|
85
|
-
// - Correctly Selected: white checkmark in green circle
|
|
86
|
-
// - Correctly Not Selected: none
|
|
87
|
-
// - Incorrectly Selected: none
|
|
88
|
-
// - Incorrectly Not Selected: white checkmark in green circle
|
|
89
|
-
// "Show Correct Answer" Disabled:
|
|
90
|
-
// - Correctly Selected:
|
|
91
|
-
// - white checkmark in green circle
|
|
92
|
-
// - heavy outline, as on “Gather”
|
|
93
|
-
// - Correctly Not Selected: none
|
|
94
|
-
// - Incorrectly Selected:
|
|
95
|
-
// - white "X" in red circle
|
|
96
|
-
// - heavy outline around the selection should appear in red
|
|
97
|
-
// - Incorrectly Not Selected: white "X" in red circle
|
|
98
|
-
let iconSrc;
|
|
99
|
-
if (showCorrectEnabled) {
|
|
100
|
-
if (selected && isCorrect || !selected && !isCorrect) {
|
|
101
|
-
iconSrc = _icons.faCorrect;
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
if (selected) {
|
|
105
|
-
if (isCorrect) {
|
|
106
|
-
iconSrc = _icons.faCorrect;
|
|
107
|
-
} else {
|
|
108
|
-
iconSrc = _icons.faWrong;
|
|
109
|
-
}
|
|
110
|
-
} else if (!isCorrect) {
|
|
111
|
-
iconSrc = _icons.faWrong;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const useHoveredStyle = (hovered || focused) && hoverOutlineColor;
|
|
115
|
-
return /*#__PURE__*/_react.default.createElement(_reactKonva.Group, {
|
|
116
|
-
scaleX: scale,
|
|
117
|
-
scaleY: scale,
|
|
118
|
-
onMouseLeave: this.handleMouseLeave,
|
|
119
|
-
onMouseEnter: this.handleMouseEnter
|
|
120
|
-
}, /*#__PURE__*/_react.default.createElement(_reactKonva.Rect, {
|
|
121
|
-
x: x,
|
|
122
|
-
y: y,
|
|
123
|
-
width: width,
|
|
124
|
-
height: height,
|
|
125
|
-
fill: selected && selectedHotspotColor ? selectedHotspotColor : hotspotColor,
|
|
126
|
-
onClick: this.handleClick,
|
|
127
|
-
onTap: this.handleClick,
|
|
128
|
-
draggable: false,
|
|
129
|
-
stroke: useHoveredStyle && !selected ? 'transparent' : outlineColorParsed,
|
|
130
|
-
strokeWidth: useHoveredStyle && !selected ? 0 : outlineWidth,
|
|
131
|
-
cursor: "pointer"
|
|
132
|
-
}), useHoveredStyle && /*#__PURE__*/_react.default.createElement(_reactKonva.Rect, {
|
|
133
|
-
x: x,
|
|
134
|
-
y: y,
|
|
135
|
-
width: width,
|
|
136
|
-
height: height,
|
|
137
|
-
stroke: hoverOutlineColor,
|
|
138
|
-
strokeWidth: strokeWidth,
|
|
139
|
-
listening: false
|
|
140
|
-
}), isEvaluateMode && iconSrc ? /*#__PURE__*/_react.default.createElement(_imageKonvaTooltip.default, {
|
|
141
|
-
src: iconSrc,
|
|
142
|
-
x: iconX,
|
|
143
|
-
y: iconY,
|
|
144
|
-
tooltip: evaluateText
|
|
145
|
-
}) : null);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
RectComponent.propTypes = {
|
|
149
|
-
height: _propTypes.default.number.isRequired,
|
|
150
|
-
hotspotColor: _propTypes.default.string.isRequired,
|
|
151
|
-
id: _propTypes.default.string.isRequired,
|
|
152
|
-
isCorrect: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
|
|
153
|
-
isEvaluateMode: _propTypes.default.bool.isRequired,
|
|
154
|
-
hoverOutlineColor: _propTypes.default.string,
|
|
155
|
-
disabled: _propTypes.default.bool.isRequired,
|
|
156
|
-
focused: _propTypes.default.bool,
|
|
157
|
-
onClick: _propTypes.default.func.isRequired,
|
|
158
|
-
outlineColor: _propTypes.default.string.isRequired,
|
|
159
|
-
selected: _propTypes.default.bool.isRequired,
|
|
160
|
-
width: _propTypes.default.number.isRequired,
|
|
161
|
-
x: _propTypes.default.number.isRequired,
|
|
162
|
-
y: _propTypes.default.number.isRequired,
|
|
163
|
-
evaluateText: _propTypes.default.string,
|
|
164
|
-
strokeWidth: _propTypes.default.number,
|
|
165
|
-
scale: _propTypes.default.number,
|
|
166
|
-
selectedHotspotColor: _propTypes.default.string,
|
|
167
|
-
markAsCorrect: _propTypes.default.bool.isRequired,
|
|
168
|
-
showCorrectEnabled: _propTypes.default.bool.isRequired
|
|
169
|
-
};
|
|
170
|
-
RectComponent.defaultProps = {
|
|
171
|
-
isCorrect: false,
|
|
172
|
-
evaluateText: null,
|
|
173
|
-
focused: false,
|
|
174
|
-
strokeWidth: 5,
|
|
175
|
-
scale: 1
|
|
176
|
-
};
|
|
177
|
-
var _default = exports.default = RectComponent;
|
|
178
|
-
//# sourceMappingURL=rectangle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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","focused","width","x","y","evaluateText","scale","outlineColorParsed","getEvaluateOutlineColor","outlineWidth","getOutlineWidth","iconX","iconY","iconSrc","faCorrect","faWrong","useHoveredStyle","createElement","Group","scaleX","scaleY","onMouseLeave","handleMouseLeave","onMouseEnter","handleMouseEnter","Rect","fill","handleClick","onTap","draggable","stroke","listening","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 focused,\n width,\n x,\n y,\n evaluateText,\n strokeWidth,\n scale,\n markAsCorrect,\n showCorrectEnabled,\n } = this.props;\n const { hovered } = this.state;\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 useHoveredStyle = (hovered || focused) && hoverOutlineColor;\n\n return (\n <Group scaleX={scale} scaleY={scale} onMouseLeave={this.handleMouseLeave} onMouseEnter={this.handleMouseEnter}>\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 cursor=\"pointer\"\n />\n {useHoveredStyle && (\n <Rect\n x={x}\n y={y}\n width={width}\n height={height}\n stroke={hoverOutlineColor}\n strokeWidth={strokeWidth}\n listening={false}\n />\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 focused: PropTypes.bool,\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 focused: false,\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,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,aAAa,SAASC,cAAK,CAACC,SAAS,CAAC;EAC1CC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,uBAMAC,CAAC,IAAK;MACnB,MAAM;QAAEC,OAAO;QAAEC,EAAE;QAAEC,QAAQ;QAAEC;MAAS,CAAC,GAAG,IAAI,CAACP,KAAK;MAEtD,IAAI,CAACO,QAAQ,EAAE;QACbJ,CAAC,CAACK,YAAY,GAAG,IAAI;QACrBJ,OAAO,CAAC;UAAEC,EAAE;UAAEC,QAAQ,EAAE,CAACA,QAAQ;UAAEG,QAAQ,EAAE;QAAQ,CAAC,CAAC;MACzD;IACF,CAAC;IAAA,IAAAR,gBAAA,CAAAC,OAAA,4BAEkB,MAAM;MACvB,MAAM;QAAEK;MAAS,CAAC,GAAG,IAAI,CAACP,KAAK;MAE/B,IAAI,CAACO,QAAQ,EAAE;QACbG,QAAQ,CAACC,IAAI,CAACC,KAAK,CAACC,MAAM,GAAG,SAAS;MACxC;MACA,IAAI,CAACC,QAAQ,CAAC;QAAEC,OAAO,EAAE;MAAK,CAAC,CAAC;IAClC,CAAC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4C,kBAAS,CAACG,MAAM,CAACD,UAAU;EACzC1D,QAAQ,EAAEwD,kBAAS,CAACK,IAAI,CAACH,UAAU;EACnCnC,KAAK,EAAEiC,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClClC,CAAC,EAAEgC,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC9BjC,CAAC,EAAE+B,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC9BhC,YAAY,EAAE8B,kBAAS,CAACG,MAAM;EAC9B7C,WAAW,EAAE0C,kBAAS,CAACC,MAAM;EAC7B9B,KAAK,EAAE6B,kBAAS,CAACC,MAAM;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;EAChBgB,YAAY,EAAE,IAAI;EAClBJ,OAAO,EAAE,KAAK;EACdR,WAAW,EAAE,CAAC;EACda,KAAK,EAAE;AACT,CAAC;AAAC,IAAAqC,QAAA,GAAAC,OAAA,CAAArE,OAAA,GAEaN,aAAa","ignoreList":[]}
|
package/lib/index.js
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _client = require("react-dom/client");
|
|
10
|
-
var _mathRendering = require("@pie-lib/math-rendering");
|
|
11
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
12
|
-
var _piePlayerEvents = require("@pie-framework/pie-player-events");
|
|
13
|
-
var _hotspot = _interopRequireDefault(require("./hotspot"));
|
|
14
|
-
var _sessionUpdater = require("./session-updater");
|
|
15
|
-
class Hotspot extends HTMLElement {
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
this._model = null;
|
|
19
|
-
this._session = null;
|
|
20
|
-
this._audioInitialized = false;
|
|
21
|
-
this.audioComplete = false;
|
|
22
|
-
this._root = null;
|
|
23
|
-
}
|
|
24
|
-
set model(m) {
|
|
25
|
-
this._model = m;
|
|
26
|
-
this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
|
|
27
|
-
this._audioInitialized = false;
|
|
28
|
-
this._render();
|
|
29
|
-
}
|
|
30
|
-
isComplete() {
|
|
31
|
-
if (!this._session || !this._session.answers) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
const {
|
|
35
|
-
autoplayAudioEnabled,
|
|
36
|
-
completeAudioEnabled
|
|
37
|
-
} = this._model || {};
|
|
38
|
-
const elementContext = this;
|
|
39
|
-
|
|
40
|
-
// check audio completion if audio settings are enabled and audio actually exists
|
|
41
|
-
if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {
|
|
42
|
-
if (elementContext) {
|
|
43
|
-
const audio = elementContext.querySelector('audio');
|
|
44
|
-
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
45
|
-
|
|
46
|
-
// only require audio completion if audio exists and is inside the prompt
|
|
47
|
-
if (audio && isInsidePrompt) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (!Array.isArray(this._session.answers)) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return this._session.answers.length > 0;
|
|
56
|
-
}
|
|
57
|
-
set session(s) {
|
|
58
|
-
if (s && !s.answers) {
|
|
59
|
-
s.answers = [];
|
|
60
|
-
}
|
|
61
|
-
this._session = s;
|
|
62
|
-
this._render();
|
|
63
|
-
}
|
|
64
|
-
get session() {
|
|
65
|
-
return this._session;
|
|
66
|
-
}
|
|
67
|
-
onSelectChoice(data) {
|
|
68
|
-
(0, _sessionUpdater.updateSessionValue)(this._session, this._model, data);
|
|
69
|
-
this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
70
|
-
this._render();
|
|
71
|
-
}
|
|
72
|
-
_createAudioInfoToast() {
|
|
73
|
-
const info = document.createElement('div');
|
|
74
|
-
info.id = 'play-audio-info';
|
|
75
|
-
Object.assign(info.style, {
|
|
76
|
-
position: 'absolute',
|
|
77
|
-
top: 0,
|
|
78
|
-
width: '100%',
|
|
79
|
-
height: '100%',
|
|
80
|
-
display: 'flex',
|
|
81
|
-
justifyContent: 'center',
|
|
82
|
-
alignItems: 'center',
|
|
83
|
-
background: 'white',
|
|
84
|
-
zIndex: '1000',
|
|
85
|
-
cursor: 'pointer'
|
|
86
|
-
});
|
|
87
|
-
const img = document.createElement('img');
|
|
88
|
-
img.src = _renderUi.EnableAudioAutoplayImage;
|
|
89
|
-
img.alt = 'Click anywhere to enable audio autoplay';
|
|
90
|
-
img.width = 500;
|
|
91
|
-
img.height = 300;
|
|
92
|
-
info.appendChild(img);
|
|
93
|
-
return info;
|
|
94
|
-
}
|
|
95
|
-
connectedCallback() {
|
|
96
|
-
this._render();
|
|
97
|
-
|
|
98
|
-
// Observation: audio in Chrome will have the autoplay attribute,
|
|
99
|
-
// while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
|
|
100
|
-
// This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
|
|
101
|
-
const observer = new MutationObserver((mutationsList, observer) => {
|
|
102
|
-
mutationsList.forEach(mutation => {
|
|
103
|
-
if (mutation.type === 'childList') {
|
|
104
|
-
if (this._audioInitialized) return;
|
|
105
|
-
const audio = this.querySelector('audio');
|
|
106
|
-
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
107
|
-
if (!this._model) return;
|
|
108
|
-
if (!this._model.autoplayAudioEnabled) return;
|
|
109
|
-
if (audio && !isInsidePrompt) return;
|
|
110
|
-
if (!audio) return;
|
|
111
|
-
const info = this._createAudioInfoToast();
|
|
112
|
-
const container = this.querySelector('#main-container');
|
|
113
|
-
const enableAudio = () => {
|
|
114
|
-
if (this.querySelector('#play-audio-info')) {
|
|
115
|
-
audio.play();
|
|
116
|
-
container.removeChild(info);
|
|
117
|
-
}
|
|
118
|
-
document.removeEventListener('click', enableAudio);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
|
|
122
|
-
// FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
|
|
123
|
-
setTimeout(() => {
|
|
124
|
-
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
125
|
-
// add info message as a toast to enable audio playback
|
|
126
|
-
container.appendChild(info);
|
|
127
|
-
document.addEventListener('click', enableAudio);
|
|
128
|
-
} else {
|
|
129
|
-
document.removeEventListener('click', enableAudio);
|
|
130
|
-
}
|
|
131
|
-
}, 500);
|
|
132
|
-
|
|
133
|
-
// we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
|
|
134
|
-
const handlePlaying = () => {
|
|
135
|
-
//timestamp when auto-played audio started playing
|
|
136
|
-
(0, _sessionUpdater.updateSessionMetadata)(this._session, {
|
|
137
|
-
audioStartTime: new Date().getTime()
|
|
138
|
-
});
|
|
139
|
-
const info = this.querySelector('#play-audio-info');
|
|
140
|
-
if (info) {
|
|
141
|
-
container.removeChild(info);
|
|
142
|
-
}
|
|
143
|
-
audio.removeEventListener('playing', handlePlaying);
|
|
144
|
-
};
|
|
145
|
-
audio.addEventListener('playing', handlePlaying);
|
|
146
|
-
|
|
147
|
-
// we need to listen for the ended event to update the isComplete state
|
|
148
|
-
const handleEnded = () => {
|
|
149
|
-
//timestamp when auto-played audio completed playing
|
|
150
|
-
(0, _sessionUpdater.updateSessionMetadata)(this._session, {
|
|
151
|
-
audioEndTime: new Date().getTime()
|
|
152
|
-
});
|
|
153
|
-
let {
|
|
154
|
-
audioStartTime,
|
|
155
|
-
audioEndTime,
|
|
156
|
-
waitTime
|
|
157
|
-
} = this._session;
|
|
158
|
-
if (!waitTime && audioStartTime && audioEndTime) {
|
|
159
|
-
// waitTime is elapsed time the user waited for auto-played audio to finish
|
|
160
|
-
this._session.waitTime = audioEndTime - audioStartTime;
|
|
161
|
-
}
|
|
162
|
-
this.audioComplete = true;
|
|
163
|
-
this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
164
|
-
audio.removeEventListener('ended', handleEnded);
|
|
165
|
-
};
|
|
166
|
-
audio.addEventListener('ended', handleEnded);
|
|
167
|
-
|
|
168
|
-
// store references to remove later
|
|
169
|
-
this._audio = audio;
|
|
170
|
-
this._handlePlaying = handlePlaying;
|
|
171
|
-
this._handleEnded = handleEnded;
|
|
172
|
-
this._enableAudio = enableAudio;
|
|
173
|
-
// set to true to prevent multiple initializations
|
|
174
|
-
this._audioInitialized = true;
|
|
175
|
-
observer.disconnect();
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
observer.observe(this, {
|
|
180
|
-
childList: true,
|
|
181
|
-
subtree: true
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
_render() {
|
|
185
|
-
if (this._model && this._session) {
|
|
186
|
-
const el = /*#__PURE__*/_react.default.createElement(_hotspot.default, {
|
|
187
|
-
model: this._model,
|
|
188
|
-
session: this._session,
|
|
189
|
-
onSelectChoice: this.onSelectChoice.bind(this)
|
|
190
|
-
});
|
|
191
|
-
if (!this._root) {
|
|
192
|
-
this._root = (0, _client.createRoot)(this);
|
|
193
|
-
}
|
|
194
|
-
this._root.render(el);
|
|
195
|
-
queueMicrotask(() => {
|
|
196
|
-
(0, _mathRendering.renderMath)(this);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
disconnectedCallback() {
|
|
201
|
-
document.removeEventListener('click', this._enableAudio);
|
|
202
|
-
if (this._audio) {
|
|
203
|
-
this._audio.removeEventListener('playing', this._handlePlaying);
|
|
204
|
-
this._audio.removeEventListener('ended', this._handleEnded);
|
|
205
|
-
this._audio = null;
|
|
206
|
-
}
|
|
207
|
-
if (this._root) {
|
|
208
|
-
this._root.unmount();
|
|
209
|
-
this._root = null;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
exports.default = Hotspot;
|
|
214
|
-
//# sourceMappingURL=index.js.map
|