@pie-element/drag-in-the-blank 10.1.2-next.2 → 10.1.2
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.json +1042 -0
- package/CHANGELOG.md +2183 -0
- package/LICENSE.md +5 -0
- package/README.md +1 -0
- package/configure/CHANGELOG.json +652 -0
- package/configure/CHANGELOG.md +1883 -0
- package/configure/lib/choice.js +137 -0
- package/configure/lib/choice.js.map +1 -0
- package/configure/lib/choices.js +319 -0
- package/configure/lib/choices.js.map +1 -0
- package/configure/lib/defaults.js +169 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +144 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +440 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/markupUtils.js +83 -0
- package/configure/lib/markupUtils.js.map +1 -0
- package/configure/package.json +25 -0
- package/configure/utils.js +17 -0
- package/controller/CHANGELOG.json +457 -0
- package/controller/CHANGELOG.md +1284 -0
- package/controller/lib/defaults.js +24 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +251 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +39 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +16 -0
- package/docs/config-schema.json +2580 -0
- package/docs/config-schema.json.md +1905 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +41 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +10 -0
- package/docs/pie-schema.json +1181 -0
- package/docs/pie-schema.json.md +853 -0
- package/lib/index.js +206 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +126 -0
- package/lib/main.js.map +1 -0
- package/package.json +22 -87
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/choice.d.ts +0 -22
- package/dist/author/choice.js +0 -88
- package/dist/author/choices.d.ts +0 -41
- package/dist/author/choices.js +0 -172
- package/dist/author/defaults.d.ts +0 -171
- package/dist/author/defaults.js +0 -123
- package/dist/author/index.d.ts +0 -42
- package/dist/author/index.js +0 -92
- package/dist/author/main.d.ts +0 -36
- package/dist/author/main.js +0 -301
- package/dist/author/markupUtils.d.ts +0 -17
- package/dist/author/markupUtils.js +0 -38
- package/dist/author/utils.d.ts +0 -9
- package/dist/author/utils.js +0 -7
- package/dist/browser/author/index.js +0 -39603
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -176
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -3414
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-BkH5WSi5.js +0 -121
- package/dist/browser/dist-BkH5WSi5.js.map +0 -1
- package/dist/browser/drag-in-the-blank.css +0 -2
- package/dist/browser/drag-provider-D0fyq5lq.js +0 -10946
- package/dist/browser/drag-provider-D0fyq5lq.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -26
- package/dist/controller/defaults.js +0 -20
- package/dist/controller/index.d.ts +0 -41
- package/dist/controller/index.js +0 -104
- package/dist/controller/utils.d.ts +0 -16
- package/dist/controller/utils.js +0 -14
- package/dist/delivery/index.d.ts +0 -21
- package/dist/delivery/index.js +0 -105
- package/dist/delivery/main.d.ts +0 -28
- package/dist/delivery/main.js +0 -83
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -152
- package/dist/index.js +0 -2
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
package/lib/index.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isComplete = exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _client = require("react-dom/client");
|
|
11
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
12
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
13
|
+
var _piePlayerEvents = require("@pie-framework/pie-player-events");
|
|
14
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
15
|
+
const isComplete = (session, model, audioComplete, elementContext) => {
|
|
16
|
+
const {
|
|
17
|
+
autoplayAudioEnabled,
|
|
18
|
+
completeAudioEnabled,
|
|
19
|
+
responseAreasToBeFilled
|
|
20
|
+
} = model || {};
|
|
21
|
+
if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {
|
|
22
|
+
if (elementContext) {
|
|
23
|
+
const audio = elementContext.querySelector('audio');
|
|
24
|
+
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
25
|
+
|
|
26
|
+
// only require audio completion if audio exists and is inside the prompt
|
|
27
|
+
if (audio && isInsidePrompt) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (!session || !session.value) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const filledResponseAreas = Object.values(session.value || {}).filter(val => !!val).length;
|
|
36
|
+
return filledResponseAreas >= responseAreasToBeFilled;
|
|
37
|
+
};
|
|
38
|
+
exports.isComplete = isComplete;
|
|
39
|
+
class DragInTheBlank extends HTMLElement {
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
(0, _defineProperty2.default)(this, "_render", () => {
|
|
43
|
+
if (this._model && this._session) {
|
|
44
|
+
let elem = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
45
|
+
model: this._model,
|
|
46
|
+
value: this._session.value,
|
|
47
|
+
onChange: this.changeSession
|
|
48
|
+
});
|
|
49
|
+
if (!this._root) {
|
|
50
|
+
this._root = (0, _client.createRoot)(this);
|
|
51
|
+
}
|
|
52
|
+
this._root.render(elem);
|
|
53
|
+
setTimeout(() => (0, _mathRendering.renderMath)(this), 0);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
(0, _defineProperty2.default)(this, "dispatchChangedEvent", () => {
|
|
57
|
+
this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete, this)));
|
|
58
|
+
});
|
|
59
|
+
(0, _defineProperty2.default)(this, "changeSession", value => {
|
|
60
|
+
this.session.value = value;
|
|
61
|
+
this.session.selector = 'Mouse';
|
|
62
|
+
this.dispatchChangedEvent();
|
|
63
|
+
this._render();
|
|
64
|
+
});
|
|
65
|
+
this._model = null;
|
|
66
|
+
this._session = null;
|
|
67
|
+
this._audioInitialized = false;
|
|
68
|
+
this.audioComplete = false;
|
|
69
|
+
this._root = null;
|
|
70
|
+
}
|
|
71
|
+
set model(m) {
|
|
72
|
+
this._model = m;
|
|
73
|
+
this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete, this), !!this._model));
|
|
74
|
+
// reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio
|
|
75
|
+
this._audioInitialized = false;
|
|
76
|
+
this._render();
|
|
77
|
+
}
|
|
78
|
+
set session(s) {
|
|
79
|
+
this._session = s;
|
|
80
|
+
this._render();
|
|
81
|
+
}
|
|
82
|
+
get session() {
|
|
83
|
+
return this._session;
|
|
84
|
+
}
|
|
85
|
+
_createAudioInfoToast() {
|
|
86
|
+
const info = document.createElement('div');
|
|
87
|
+
info.id = 'play-audio-info';
|
|
88
|
+
Object.assign(info.style, {
|
|
89
|
+
position: 'absolute',
|
|
90
|
+
top: 0,
|
|
91
|
+
width: '100%',
|
|
92
|
+
height: '100%',
|
|
93
|
+
display: 'flex',
|
|
94
|
+
justifyContent: 'center',
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
background: 'white',
|
|
97
|
+
zIndex: '1000',
|
|
98
|
+
cursor: 'pointer'
|
|
99
|
+
});
|
|
100
|
+
const img = document.createElement('img');
|
|
101
|
+
img.src = _renderUi.EnableAudioAutoplayImage;
|
|
102
|
+
img.alt = 'Click anywhere to enable audio autoplay';
|
|
103
|
+
img.width = 500;
|
|
104
|
+
img.height = 300;
|
|
105
|
+
info.appendChild(img);
|
|
106
|
+
return info;
|
|
107
|
+
}
|
|
108
|
+
connectedCallback() {
|
|
109
|
+
this._render();
|
|
110
|
+
|
|
111
|
+
// Observation: audio in Chrome will have the autoplay attribute,
|
|
112
|
+
// while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
|
|
113
|
+
// This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
|
|
114
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
115
|
+
mutationsList.forEach(mutation => {
|
|
116
|
+
if (mutation.type === 'childList') {
|
|
117
|
+
if (this._audioInitialized) return;
|
|
118
|
+
const audio = this.querySelector('audio');
|
|
119
|
+
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
120
|
+
if (!this._model) return;
|
|
121
|
+
if (!this._model.autoplayAudioEnabled) return;
|
|
122
|
+
if (audio && !isInsidePrompt) return;
|
|
123
|
+
if (!audio) return;
|
|
124
|
+
const info = this._createAudioInfoToast();
|
|
125
|
+
const container = this.querySelector('#main-container');
|
|
126
|
+
const enableAudio = () => {
|
|
127
|
+
if (this.querySelector('#play-audio-info')) {
|
|
128
|
+
audio.play();
|
|
129
|
+
container.removeChild(info);
|
|
130
|
+
}
|
|
131
|
+
document.removeEventListener('click', enableAudio);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
|
|
135
|
+
// FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
138
|
+
// add info message as a toast to enable audio playback
|
|
139
|
+
container.appendChild(info);
|
|
140
|
+
document.addEventListener('click', enableAudio);
|
|
141
|
+
} else {
|
|
142
|
+
document.removeEventListener('click', enableAudio);
|
|
143
|
+
}
|
|
144
|
+
}, 500);
|
|
145
|
+
|
|
146
|
+
// we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
|
|
147
|
+
const handlePlaying = () => {
|
|
148
|
+
//timestamp when auto-played audio started playing
|
|
149
|
+
this._session.audioStartTime = this._session.audioStartTime || new Date().getTime();
|
|
150
|
+
const info = this.querySelector('#play-audio-info');
|
|
151
|
+
if (info) {
|
|
152
|
+
container.removeChild(info);
|
|
153
|
+
}
|
|
154
|
+
audio.removeEventListener('playing', handlePlaying);
|
|
155
|
+
};
|
|
156
|
+
audio.addEventListener('playing', handlePlaying);
|
|
157
|
+
|
|
158
|
+
// we need to listen for the ended event to update the isComplete state
|
|
159
|
+
const handleEnded = () => {
|
|
160
|
+
//timestamp when auto-played audio completed playing
|
|
161
|
+
this._session.audioEndTime = this._session.audioEndTime || new Date().getTime();
|
|
162
|
+
let {
|
|
163
|
+
audioStartTime,
|
|
164
|
+
audioEndTime,
|
|
165
|
+
waitTime
|
|
166
|
+
} = this._session;
|
|
167
|
+
if (!waitTime && audioStartTime && audioEndTime) {
|
|
168
|
+
// waitTime is elapsed time the user waited for auto-played audio to finish
|
|
169
|
+
this._session.waitTime = audioEndTime - audioStartTime;
|
|
170
|
+
}
|
|
171
|
+
this.audioComplete = true;
|
|
172
|
+
this.dispatchChangedEvent();
|
|
173
|
+
audio.removeEventListener('ended', handleEnded);
|
|
174
|
+
};
|
|
175
|
+
audio.addEventListener('ended', handleEnded);
|
|
176
|
+
|
|
177
|
+
// store references to remove later
|
|
178
|
+
this._audio = audio;
|
|
179
|
+
this._handlePlaying = handlePlaying;
|
|
180
|
+
this._handleEnded = handleEnded;
|
|
181
|
+
this._enableAudio = enableAudio;
|
|
182
|
+
// set to true to prevent multiple initializations
|
|
183
|
+
this._audioInitialized = true;
|
|
184
|
+
observer.disconnect();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
observer.observe(this, {
|
|
189
|
+
childList: true,
|
|
190
|
+
subtree: true
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
disconnectedCallback() {
|
|
194
|
+
document.removeEventListener('click', this._enableAudio);
|
|
195
|
+
if (this._audio) {
|
|
196
|
+
this._audio.removeEventListener('playing', this._handlePlaying);
|
|
197
|
+
this._audio.removeEventListener('ended', this._handleEnded);
|
|
198
|
+
this._audio = null;
|
|
199
|
+
}
|
|
200
|
+
if (this._root) {
|
|
201
|
+
this._root.unmount();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.default = DragInTheBlank;
|
|
206
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_mathRendering","_renderUi","_piePlayerEvents","_main","isComplete","session","model","audioComplete","elementContext","autoplayAudioEnabled","completeAudioEnabled","responseAreasToBeFilled","audio","querySelector","isInsidePrompt","closest","value","filledResponseAreas","Object","values","filter","val","length","exports","DragInTheBlank","HTMLElement","constructor","_defineProperty2","default","_model","_session","elem","React","createElement","Main","onChange","changeSession","_root","createRoot","render","setTimeout","renderMath","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","selector","dispatchChangedEvent","_render","_audioInitialized","m","ModelSetEvent","s","_createAudioInfoToast","info","document","id","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","observer","MutationObserver","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","paused","addEventListener","handlePlaying","audioStartTime","Date","getTime","handleEnded","audioEndTime","waitTime","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","disconnectedCallback","unmount"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport Main from './main';\n\nexport const isComplete = (session, model, audioComplete, elementContext) => {\n const { autoplayAudioEnabled, completeAudioEnabled, responseAreasToBeFilled } = model || {};\n\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n const filledResponseAreas = Object.values(session.value || {}).filter((val) => !!val).length;\n\n return filledResponseAreas >= responseAreasToBeFilled;\n};\n\nexport default class DragInTheBlank extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._audioInitialized = false;\n this.audioComplete = false;\n this._root = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n !!this._model,\n ),\n );\n // reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio\n this._audioInitialized = false;\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n model: this._model,\n value: this._session.value,\n onChange: this.changeSession,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(elem);\n setTimeout(() => renderMath(this), 0);\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(\n new SessionChangedEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n ),\n );\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.session.selector = 'Mouse';\n\n this.dispatchChangedEvent();\n this._render();\n };\n\n _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer',\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._render();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n if (this._audioInitialized) return;\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n //timestamp when auto-played audio started playing\n this._session.audioStartTime = this._session.audioStartTime || new Date().getTime();\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n //timestamp when auto-played audio completed playing\n this._session.audioEndTime = this._session.audioEndTime || new Date().getTime();\n\n let { audioStartTime, audioEndTime, waitTime } = this._session;\n if (!waitTime && audioStartTime && audioEndTime) {\n // waitTime is elapsed time the user waited for auto-played audio to finish\n this._session.waitTime = audioEndTime - audioStartTime;\n }\n\n this.audioComplete = true;\n this.dispatchChangedEvent();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n // set to true to prevent multiple initializations\n this._audioInitialized = true;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEO,MAAMM,UAAU,GAAGA,CAACC,OAAO,EAAEC,KAAK,EAAEC,aAAa,EAAEC,cAAc,KAAK;EAC3E,MAAM;IAAEC,oBAAoB;IAAEC,oBAAoB;IAAEC;EAAwB,CAAC,GAAGL,KAAK,IAAI,CAAC,CAAC;EAE3F,IAAIG,oBAAoB,IAAIC,oBAAoB,IAAI,CAACH,aAAa,EAAE;IAClE,IAAIC,cAAc,EAAE;MAClB,MAAMI,KAAK,GAAGJ,cAAc,CAACK,aAAa,CAAC,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IACrBhD,QAAQ,CAAC8B,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAACa,YAAY,CAAC;IAExD,IAAI,IAAI,CAACH,MAAM,EAAE;MACf,IAAI,CAACA,MAAM,CAACV,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAACW,cAAc,CAAC;MAC/D,IAAI,CAACD,MAAM,CAACV,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAACY,YAAY,CAAC;MAC3D,IAAI,CAACF,MAAM,GAAG,IAAI;IACpB;IAEA,IAAI,IAAI,CAAC1D,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACmE,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACjF,OAAA,CAAAK,OAAA,GAAAJ,cAAA","ignoreList":[]}
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.Main = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _correctAnswerToggle = _interopRequireDefault(require("@pie-lib/correct-answer-toggle"));
|
|
13
|
+
var _maskMarkup = require("@pie-lib/mask-markup");
|
|
14
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
15
|
+
var _styles = require("@mui/material/styles");
|
|
16
|
+
const StyledUiLayout = (0, _styles.styled)(_renderUi.UiLayout)({
|
|
17
|
+
color: _renderUi.color.text(),
|
|
18
|
+
backgroundColor: _renderUi.color.background(),
|
|
19
|
+
'& tr > td': {
|
|
20
|
+
color: _renderUi.color.text()
|
|
21
|
+
},
|
|
22
|
+
position: 'relative'
|
|
23
|
+
});
|
|
24
|
+
const StyledCollapsible = (0, _styles.styled)(_renderUi.Collapsible)(({
|
|
25
|
+
theme
|
|
26
|
+
}) => ({
|
|
27
|
+
marginBottom: theme.spacing(2)
|
|
28
|
+
}));
|
|
29
|
+
const StyledRationale = (0, _styles.styled)(_renderUi.Collapsible)(({
|
|
30
|
+
theme
|
|
31
|
+
}) => ({
|
|
32
|
+
marginTop: theme.spacing(2)
|
|
33
|
+
}));
|
|
34
|
+
class Main extends _react.default.Component {
|
|
35
|
+
constructor(...args) {
|
|
36
|
+
super(...args);
|
|
37
|
+
(0, _defineProperty2.default)(this, "state", {
|
|
38
|
+
showCorrectAnswer: false
|
|
39
|
+
});
|
|
40
|
+
(0, _defineProperty2.default)(this, "toggleShowCorrect", () => {
|
|
41
|
+
this.setState({
|
|
42
|
+
showCorrectAnswer: !this.state.showCorrectAnswer
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
47
|
+
const {
|
|
48
|
+
model: nextModel
|
|
49
|
+
} = nextProps;
|
|
50
|
+
if (nextModel && !nextModel.correctResponse && this.state.showCorrectAnswer !== false) {
|
|
51
|
+
this.setState({
|
|
52
|
+
showCorrectAnswer: false
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
const {
|
|
58
|
+
showCorrectAnswer
|
|
59
|
+
} = this.state;
|
|
60
|
+
const {
|
|
61
|
+
model,
|
|
62
|
+
onChange,
|
|
63
|
+
value
|
|
64
|
+
} = this.props;
|
|
65
|
+
const {
|
|
66
|
+
extraCSSRules,
|
|
67
|
+
prompt,
|
|
68
|
+
mode,
|
|
69
|
+
language,
|
|
70
|
+
fontSizeFactor,
|
|
71
|
+
autoplayAudioEnabled,
|
|
72
|
+
customAudioButton
|
|
73
|
+
} = model;
|
|
74
|
+
const modelWithValue = {
|
|
75
|
+
...model,
|
|
76
|
+
value
|
|
77
|
+
};
|
|
78
|
+
const showCorrectAnswerToggle = mode === 'evaluate';
|
|
79
|
+
const showRationale = model.rationale && ((0, _renderUi.hasText)(model.rationale) || (0, _renderUi.hasMedia)(model.rationale));
|
|
80
|
+
const showTeacherInstructions = model.teacherInstructions && ((0, _renderUi.hasText)(model.teacherInstructions) || (0, _renderUi.hasMedia)(model.teacherInstructions));
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(StyledUiLayout, {
|
|
82
|
+
extraCSSRules: extraCSSRules,
|
|
83
|
+
id: 'main-container',
|
|
84
|
+
fontSizeFactor: fontSizeFactor
|
|
85
|
+
}, showTeacherInstructions && /*#__PURE__*/_react.default.createElement(StyledCollapsible, {
|
|
86
|
+
labels: {
|
|
87
|
+
hidden: 'Show Teacher Instructions',
|
|
88
|
+
visible: 'Hide Teacher Instructions'
|
|
89
|
+
}
|
|
90
|
+
}, /*#__PURE__*/_react.default.createElement(_renderUi.PreviewPrompt, {
|
|
91
|
+
prompt: model.teacherInstructions
|
|
92
|
+
})), prompt && /*#__PURE__*/_react.default.createElement(_renderUi.PreviewPrompt, {
|
|
93
|
+
className: "prompt",
|
|
94
|
+
prompt: prompt,
|
|
95
|
+
autoplayAudioEnabled: autoplayAudioEnabled,
|
|
96
|
+
customAudioButton: customAudioButton
|
|
97
|
+
}), /*#__PURE__*/_react.default.createElement(_correctAnswerToggle.default, {
|
|
98
|
+
show: showCorrectAnswerToggle,
|
|
99
|
+
toggled: showCorrectAnswer,
|
|
100
|
+
onToggle: this.toggleShowCorrect,
|
|
101
|
+
language: language
|
|
102
|
+
}), /*#__PURE__*/_react.default.createElement(_maskMarkup.DragInTheBlank, (0, _extends2.default)({}, modelWithValue, {
|
|
103
|
+
onChange: onChange,
|
|
104
|
+
showCorrectAnswer: showCorrectAnswer
|
|
105
|
+
})), showRationale && /*#__PURE__*/_react.default.createElement(StyledRationale, {
|
|
106
|
+
labels: {
|
|
107
|
+
hidden: 'Show Rationale',
|
|
108
|
+
visible: 'Hide Rationale'
|
|
109
|
+
}
|
|
110
|
+
}, /*#__PURE__*/_react.default.createElement(_renderUi.PreviewPrompt, {
|
|
111
|
+
prompt: model.rationale
|
|
112
|
+
})));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.Main = Main;
|
|
116
|
+
(0, _defineProperty2.default)(Main, "propTypes", {
|
|
117
|
+
model: _propTypes.default.object,
|
|
118
|
+
value: _propTypes.default.object,
|
|
119
|
+
feedback: _propTypes.default.object,
|
|
120
|
+
onChange: _propTypes.default.func
|
|
121
|
+
});
|
|
122
|
+
(0, _defineProperty2.default)(Main, "defaultProps", {
|
|
123
|
+
value: {}
|
|
124
|
+
});
|
|
125
|
+
var _default = exports.default = Main;
|
|
126
|
+
//# sourceMappingURL=main.js.map
|
package/lib/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_correctAnswerToggle","_maskMarkup","_renderUi","_styles","StyledUiLayout","styled","UiLayout","color","text","backgroundColor","background","position","StyledCollapsible","Collapsible","theme","marginBottom","spacing","StyledRationale","marginTop","Main","React","Component","constructor","args","_defineProperty2","default","showCorrectAnswer","setState","state","UNSAFE_componentWillReceiveProps","nextProps","model","nextModel","correctResponse","render","onChange","value","props","extraCSSRules","prompt","mode","language","fontSizeFactor","autoplayAudioEnabled","customAudioButton","modelWithValue","showCorrectAnswerToggle","showRationale","rationale","hasText","hasMedia","showTeacherInstructions","teacherInstructions","createElement","id","labels","hidden","visible","PreviewPrompt","className","show","toggled","onToggle","toggleShowCorrect","DragInTheBlank","_extends2","exports","PropTypes","object","feedback","func","_default"],"sources":["../src/main.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport { DragInTheBlank } from '@pie-lib/mask-markup';\nimport { color, Collapsible, hasText, hasMedia, PreviewPrompt, UiLayout } from '@pie-lib/render-ui';\nimport { styled } from '@mui/material/styles';\n\nconst StyledUiLayout = styled(UiLayout)({\n color: color.text(),\n backgroundColor: color.background(),\n '& tr > td': {\n color: color.text(),\n },\n position: 'relative',\n});\n\nconst StyledCollapsible = styled(Collapsible)(({ theme }) => ({\n marginBottom: theme.spacing(2),\n}));\n\nconst StyledRationale = styled(Collapsible)(({ theme }) => ({\n marginTop: theme.spacing(2),\n}));\n\nexport class Main extends React.Component {\n static propTypes = {\n model: PropTypes.object,\n value: PropTypes.object,\n feedback: PropTypes.object,\n onChange: PropTypes.func,\n };\n\n static defaultProps = {\n value: {},\n };\n\n state = {\n showCorrectAnswer: false,\n };\n\n toggleShowCorrect = () => {\n this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const { model: nextModel } = nextProps;\n\n if (nextModel && !nextModel.correctResponse && this.state.showCorrectAnswer !== false) {\n this.setState({ showCorrectAnswer: false });\n }\n }\n\n render() {\n const { showCorrectAnswer } = this.state;\n const { model, onChange, value } = this.props;\n const { extraCSSRules, prompt, mode, language, fontSizeFactor, autoplayAudioEnabled, customAudioButton } = model;\n const modelWithValue = { ...model, value };\n const showCorrectAnswerToggle = mode === 'evaluate';\n\n const showRationale = model.rationale && (hasText(model.rationale) || hasMedia(model.rationale));\n const showTeacherInstructions =\n model.teacherInstructions && (hasText(model.teacherInstructions) || hasMedia(model.teacherInstructions));\n\n return (\n <StyledUiLayout\n extraCSSRules={extraCSSRules}\n id={'main-container'}\n fontSizeFactor={fontSizeFactor}\n >\n {showTeacherInstructions && (\n <StyledCollapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n >\n <PreviewPrompt prompt={model.teacherInstructions} />\n </StyledCollapsible>\n )}\n\n {prompt && (\n <PreviewPrompt\n className=\"prompt\"\n prompt={prompt}\n autoplayAudioEnabled={autoplayAudioEnabled}\n customAudioButton={customAudioButton}\n />\n )}\n\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n language={language}\n />\n\n <DragInTheBlank {...modelWithValue} onChange={onChange} showCorrectAnswer={showCorrectAnswer} />\n\n {showRationale && (\n <StyledRationale labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt prompt={model.rationale} />\n </StyledRationale>\n )}\n </StyledUiLayout>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,oBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEA,MAAMM,cAAc,GAAG,IAAAC,cAAM,EAACC,kBAAQ,CAAC,CAAC;EACtCC,KAAK,EAAEA,eAAK,CAACC,IAAI,CAAC,CAAC;EACnBC,eAAe,EAAEF,eAAK,CAACG,UAAU,CAAC,CAAC;EACnC,WAAW,EAAE;IACXH,KAAK,EAAEA,eAAK,CAACC,IAAI,CAAC;EACpB,CAAC;EACDG,QAAQ,EAAE;AACZ,CAAC,CAAC;AAEF,MAAMC,iBAAiB,GAAG,IAAAP,cAAM,EAACQ,qBAAW,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC5DC,YAAY,EAAED,KAAK,CAACE,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,MAAMC,eAAe,GAAG,IAAAZ,cAAM,EAACQ,qBAAW,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC1DI,SAAS,EAAEJ,KAAK,CAACE,OAAO,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEI,MAAMG,IAAI,SAASC,cAAK,CAAC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EC,MAAM,EAAE,gBAAgB;QAAEC,OAAO,EAAE;MAAiB;IAAE,gBAC/E7D,MAAA,CAAA6B,OAAA,CAAA4B,aAAA,CAACnD,SAAA,CAAAwD,aAAa;MAACnB,MAAM,EAAER,KAAK,CAACiB;IAAU,CAAE,CAC1B,CAEL,CAAC;EAErB;AACF;AAACkB,OAAA,CAAA/C,IAAA,GAAAA,IAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EA/EYN,IAAI,eACI;EACjBY,KAAK,EAAEoC,kBAAS,CAACC,MAAM;EACvBhC,KAAK,EAAE+B,kBAAS,CAACC,MAAM;EACvBC,QAAQ,EAAEF,kBAAS,CAACC,MAAM;EAC1BjC,QAAQ,EAAEgC,kBAAS,CAACG;AACtB,CAAC;AAAA,IAAA9C,gBAAA,CAAAC,OAAA,EANUN,IAAI,kBAQO;EACpBiB,KAAK,EAAE,CAAC;AACV,CAAC;AAAA,IAAAmC,QAAA,GAAAL,OAAA,CAAAzC,OAAA,GAuEYN,IAAI","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,98 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/drag-in-the-blank",
|
|
3
|
-
"
|
|
3
|
+
"repository": "pie-framework/pie-elements",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"version": "10.1.2",
|
|
4
8
|
"description": "",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postpublish": "../../scripts/postpublish"
|
|
11
|
+
},
|
|
5
12
|
"dependencies": {
|
|
6
13
|
"@emotion/react": "^11.14.0",
|
|
7
14
|
"@emotion/style": "^0.8.0",
|
|
8
15
|
"@mui/icons-material": "^7.3.4",
|
|
9
16
|
"@mui/material": "^7.3.4",
|
|
10
|
-
"@pie-
|
|
11
|
-
"@pie-lib/
|
|
12
|
-
"@pie-lib/
|
|
13
|
-
"@pie-lib/
|
|
17
|
+
"@pie-framework/pie-player-events": "^0.1.0",
|
|
18
|
+
"@pie-lib/correct-answer-toggle": "4.0.3",
|
|
19
|
+
"@pie-lib/drag": "4.0.3",
|
|
20
|
+
"@pie-lib/mask-markup": "3.0.6",
|
|
21
|
+
"@pie-lib/math-rendering": "5.0.2",
|
|
22
|
+
"@pie-lib/render-ui": "6.1.1",
|
|
23
|
+
"lodash-es": "^4.17.23",
|
|
14
24
|
"prop-types": "^15.8.1",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"@pie-lib/config-ui": "13.0.4-next.30",
|
|
18
|
-
"@pie-element/shared-math-rendering-mathjax": "0.1.1-next.0",
|
|
19
|
-
"@pie-element/shared-configure-events": "0.1.0",
|
|
20
|
-
"debug": "^4.4.3",
|
|
21
|
-
"@pie-element/shared-lodash": "0.1.1-next.0",
|
|
22
|
-
"@pie-element/shared-controller-utils": "0.1.1-next.1",
|
|
23
|
-
"@pie-element/shared-player-events": "0.1.0"
|
|
24
|
-
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"react": "^18.0.0",
|
|
27
|
-
"react-dom": "^18.0.0"
|
|
28
|
-
},
|
|
29
|
-
"exports": {
|
|
30
|
-
".": {
|
|
31
|
-
"types": "./dist/index.d.ts",
|
|
32
|
-
"default": "./dist/index.js"
|
|
33
|
-
},
|
|
34
|
-
"./delivery": {
|
|
35
|
-
"types": "./dist/delivery/index.d.ts",
|
|
36
|
-
"default": "./dist/delivery/index.js"
|
|
37
|
-
},
|
|
38
|
-
"./browser/delivery": {
|
|
39
|
-
"default": "./dist/browser/delivery/index.js"
|
|
40
|
-
},
|
|
41
|
-
"./author": {
|
|
42
|
-
"types": "./dist/author/index.d.ts",
|
|
43
|
-
"default": "./dist/author/index.js"
|
|
44
|
-
},
|
|
45
|
-
"./browser/author": {
|
|
46
|
-
"default": "./dist/browser/author/index.js"
|
|
47
|
-
},
|
|
48
|
-
"./configure": {
|
|
49
|
-
"types": "./dist/author/index.d.ts",
|
|
50
|
-
"default": "./dist/author/index.js"
|
|
51
|
-
},
|
|
52
|
-
"./controller": {
|
|
53
|
-
"types": "./dist/controller/index.d.ts",
|
|
54
|
-
"default": "./dist/controller/index.js"
|
|
55
|
-
},
|
|
56
|
-
"./controller.js": {
|
|
57
|
-
"types": "./dist/controller/index.d.ts",
|
|
58
|
-
"default": "./dist/controller/index.js"
|
|
59
|
-
},
|
|
60
|
-
"./browser/controller": {
|
|
61
|
-
"default": "./dist/browser/controller/index.js"
|
|
62
|
-
},
|
|
63
|
-
"./runtime-support": {
|
|
64
|
-
"types": "./dist/runtime-support.d.ts",
|
|
65
|
-
"default": "./dist/runtime-support.js"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"type": "module",
|
|
69
|
-
"main": "./dist/index.js",
|
|
70
|
-
"types": "./dist/index.d.ts",
|
|
71
|
-
"files": [
|
|
72
|
-
"configure.js",
|
|
73
|
-
"controller.js",
|
|
74
|
-
"dist"
|
|
75
|
-
],
|
|
76
|
-
"sideEffects": false,
|
|
77
|
-
"devDependencies": {
|
|
78
|
-
"vite": "^8.0.1",
|
|
79
|
-
"typescript": "^5.9.3",
|
|
80
|
-
"@vitejs/plugin-react": "^6.0.1",
|
|
81
|
-
"@types/react": "^18.2.0",
|
|
82
|
-
"@types/react-dom": "^18.2.0"
|
|
83
|
-
},
|
|
84
|
-
"scripts": {
|
|
85
|
-
"build": "bun x vite build && bun x vite build --config ../../../tools/vite/element-browser.config.ts && bun x vite build --config vite.config.iife.ts && bun x tsc --emitDeclarationOnly",
|
|
86
|
-
"dev": "bun x vite",
|
|
87
|
-
"demo": "bun x vite --mode demo",
|
|
88
|
-
"test": "bun x vitest run"
|
|
25
|
+
"react": "18.3.1",
|
|
26
|
+
"react-dom": "18.3.1"
|
|
89
27
|
},
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"react-dom": "18.2.0"
|
|
96
|
-
}
|
|
97
|
-
}
|
|
28
|
+
"author": "",
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"gitHead": "206ff17a94e8e197744d059f97ad2b9a1bc9145d",
|
|
31
|
+
"main": "lib/index.js",
|
|
32
|
+
"module": "src/index.js"
|
|
98
33
|
}
|
package/configure.js
DELETED
package/controller.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/controller/index.js';
|
package/dist/author/choice.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/drag-in-the-blank/configure/src/choice.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
export declare const BlankContent: {
|
|
12
|
-
(props: any): React.JSX.Element;
|
|
13
|
-
propTypes: {
|
|
14
|
-
choice: PropTypes.Validator<object>;
|
|
15
|
-
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
|
-
onRemoveChoice: PropTypes.Validator<(...args: any[]) => any>;
|
|
17
|
-
error: PropTypes.Requireable<boolean>;
|
|
18
|
-
instanceId: PropTypes.Requireable<string>;
|
|
19
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export default BlankContent;
|
package/dist/author/choice.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { choiceIsEmpty as e } from "./markupUtils.js";
|
|
2
|
-
import "react";
|
|
3
|
-
import t from "prop-types";
|
|
4
|
-
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
-
import { styled as i } from "@mui/material/styles";
|
|
6
|
-
import { useDraggable as a } from "@dnd-kit/core";
|
|
7
|
-
import o from "@mui/icons-material/MoreVert";
|
|
8
|
-
import s from "@mui/icons-material/Delete";
|
|
9
|
-
//#region src/author/choice.tsx
|
|
10
|
-
var c = ({ style: e }) => /* @__PURE__ */ r("span", {
|
|
11
|
-
style: e,
|
|
12
|
-
children: [/* @__PURE__ */ n(o, { style: { margin: "0 -16px" } }), /* @__PURE__ */ n(o, {})]
|
|
13
|
-
});
|
|
14
|
-
c.propTypes = { style: t.object };
|
|
15
|
-
var l = i("div", { shouldForwardProp: (e) => !["error", "isDragging"].includes(e) })(({ theme: e, error: t }) => ({
|
|
16
|
-
display: "inline-flex",
|
|
17
|
-
minWidth: "178px",
|
|
18
|
-
minHeight: "36px",
|
|
19
|
-
background: e.palette.common.white,
|
|
20
|
-
boxSizing: "border-box",
|
|
21
|
-
borderRadius: "3px",
|
|
22
|
-
overflow: "hidden",
|
|
23
|
-
position: "relative",
|
|
24
|
-
padding: "8px 35px 8px 35px",
|
|
25
|
-
cursor: "grab",
|
|
26
|
-
border: `1px solid ${t ? "#f44336" : "#C0C3CF"}`,
|
|
27
|
-
"& img": { display: "flex" },
|
|
28
|
-
"& p": { margin: 0 },
|
|
29
|
-
"& mjx-frac": { fontSize: "120% !important" }
|
|
30
|
-
})), u = i(s)(({ theme: e }) => ({
|
|
31
|
-
position: "absolute",
|
|
32
|
-
top: "6px",
|
|
33
|
-
right: "0",
|
|
34
|
-
color: e.palette.grey[500],
|
|
35
|
-
zIndex: 2,
|
|
36
|
-
"&:hover": {
|
|
37
|
-
cursor: "pointer",
|
|
38
|
-
color: e.palette.common.black
|
|
39
|
-
}
|
|
40
|
-
})), d = (t) => {
|
|
41
|
-
let { choice: i, onClick: o, onRemoveChoice: s, error: d, instanceId: f, disabled: p } = t, { attributes: m, listeners: h, setNodeRef: g, isDragging: _ } = a({
|
|
42
|
-
id: `choice-${i.id}-${f || "default"}`,
|
|
43
|
-
data: {
|
|
44
|
-
type: "drag-in-the-blank-choice",
|
|
45
|
-
id: i.id,
|
|
46
|
-
value: i,
|
|
47
|
-
instanceId: f
|
|
48
|
-
},
|
|
49
|
-
disabled: p || e(i)
|
|
50
|
-
}), v = (t) => {
|
|
51
|
-
if (e(i)) {
|
|
52
|
-
t.preventDefault(), alert("You need to define a value for an answer choice before it can be associated with a response area.");
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
return /* @__PURE__ */ r(l, {
|
|
57
|
-
ref: g,
|
|
58
|
-
error: d,
|
|
59
|
-
isDragging: _,
|
|
60
|
-
onClick: o,
|
|
61
|
-
...m,
|
|
62
|
-
...h,
|
|
63
|
-
onDragStart: v,
|
|
64
|
-
children: [
|
|
65
|
-
/* @__PURE__ */ n(c, { style: {
|
|
66
|
-
position: "absolute",
|
|
67
|
-
top: "6px",
|
|
68
|
-
left: "15px",
|
|
69
|
-
color: "#9e9e9e",
|
|
70
|
-
zIndex: 2
|
|
71
|
-
} }),
|
|
72
|
-
/* @__PURE__ */ n("span", { dangerouslySetInnerHTML: { __html: i.value } }),
|
|
73
|
-
/* @__PURE__ */ n(u, { onClick: (e) => {
|
|
74
|
-
e.preventDefault(), e.stopPropagation(), s(e);
|
|
75
|
-
} })
|
|
76
|
-
]
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
d.propTypes = {
|
|
80
|
-
choice: t.object.isRequired,
|
|
81
|
-
onClick: t.func,
|
|
82
|
-
onRemoveChoice: t.func.isRequired,
|
|
83
|
-
error: t.bool,
|
|
84
|
-
instanceId: t.string,
|
|
85
|
-
disabled: t.bool
|
|
86
|
-
};
|
|
87
|
-
//#endregion
|
|
88
|
-
export { d as default };
|