@pie-element/drag-in-the-blank 6.6.2-next.31 → 6.6.2-next.37

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.
@@ -155,6 +155,16 @@
155
155
  "type": "number",
156
156
  "title": "fontSizeFactor"
157
157
  },
158
+ "autoplayAudioEnabled": {
159
+ "description": "Indicates if the audio for the prompt should autoplay",
160
+ "type": "boolean",
161
+ "title": "autoplayAudioEnabled"
162
+ },
163
+ "completeAudioEnabled": {
164
+ "description": "Indicates if the audio should reach the end before the item can be marked as 'complete'",
165
+ "type": "boolean",
166
+ "title": "completeAudioEnabled"
167
+ },
158
168
  "id": {
159
169
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
160
170
  "type": "string",
@@ -117,6 +117,14 @@ Supported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX
117
117
 
118
118
  Indicates font size adjustment factor
119
119
 
120
+ # `autoplayAudioEnabled` (boolean)
121
+
122
+ Indicates if the audio for the prompt should autoplay
123
+
124
+ # `completeAudioEnabled` (boolean)
125
+
126
+ Indicates if the audio should reach the end before the item can be marked as 'complete'
127
+
120
128
  # `id` (string, required)
121
129
 
122
130
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
package/lib/index.js CHANGED
@@ -37,7 +37,15 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
37
37
 
38
38
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
39
39
 
40
- var isComplete = function isComplete(session, model) {
40
+ var isComplete = function isComplete(session, model, audioComplete) {
41
+ var _ref = model || {},
42
+ autoplayAudioEnabled = _ref.autoplayAudioEnabled,
43
+ completeAudioEnabled = _ref.completeAudioEnabled;
44
+
45
+ if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {
46
+ return false;
47
+ }
48
+
41
49
  if (!session || !session.value) {
42
50
  return false;
43
51
  }
@@ -73,7 +81,7 @@ var DragInTheBlank = /*#__PURE__*/function (_HTMLElement) {
73
81
  }
74
82
  });
75
83
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "dispatchChangedEvent", function () {
76
- _this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(_this.tagName.toLowerCase(), isComplete(_this._session)));
84
+ _this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(_this.tagName.toLowerCase(), isComplete(_this._session, _this._model, _this.audioComplete)));
77
85
  });
78
86
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeSession", function (value) {
79
87
  _this.session.value = value;
@@ -85,6 +93,7 @@ var DragInTheBlank = /*#__PURE__*/function (_HTMLElement) {
85
93
  });
86
94
  _this._model = null;
87
95
  _this._session = null;
96
+ _this.audioComplete = false;
88
97
  return _this;
89
98
  }
90
99
 
@@ -92,7 +101,7 @@ var DragInTheBlank = /*#__PURE__*/function (_HTMLElement) {
92
101
  key: "model",
93
102
  set: function set(m) {
94
103
  this._model = m;
95
- this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), isComplete(this._session), !!this._model));
104
+ this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete), !!this._model));
96
105
 
97
106
  this._render();
98
107
  }
@@ -106,10 +115,107 @@ var DragInTheBlank = /*#__PURE__*/function (_HTMLElement) {
106
115
 
107
116
  this._render();
108
117
  }
118
+ }, {
119
+ key: "_createAudioInfoToast",
120
+ value: function _createAudioInfoToast() {
121
+ var info = document.createElement('div');
122
+ info.id = 'play-audio-info';
123
+ Object.assign(info.style, {
124
+ position: 'absolute',
125
+ top: 0,
126
+ width: '100%',
127
+ height: '100%',
128
+ display: 'flex',
129
+ justifyContent: 'center',
130
+ alignItems: 'center',
131
+ background: 'white',
132
+ zIndex: '1000'
133
+ });
134
+ var img = document.createElement('img');
135
+ img.src = 'https://student.assessment.renaissance.com/ce/quizenginecap/assets/img/playAppsSel.gif';
136
+ img.alt = 'Click anywhere to enable audio autoplay';
137
+ img.width = 500;
138
+ img.height = 300;
139
+ info.appendChild(img);
140
+ return info;
141
+ }
109
142
  }, {
110
143
  key: "connectedCallback",
111
144
  value: function connectedCallback() {
145
+ var _this2 = this;
146
+
112
147
  this._render();
148
+
149
+ if (this._model && !this._model.autoplayAudioEnabled) {
150
+ return;
151
+ } // Observation: audio in Chrome will have the autoplay attribute,
152
+ // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
153
+ // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
154
+
155
+
156
+ var observer = new MutationObserver(function (mutationsList, observer) {
157
+ mutationsList.forEach(function (mutation) {
158
+ if (mutation.type === 'childList') {
159
+ var audio = _this2.querySelector('audio');
160
+
161
+ var isInsidePrompt = audio && audio.closest('#preview-prompt');
162
+ if (audio && !isInsidePrompt) return;
163
+ if (!audio) return;
164
+
165
+ var info = _this2._createAudioInfoToast();
166
+
167
+ var container = _this2.querySelector('[class*="main"]');
168
+
169
+ var enableAudio = function enableAudio() {
170
+ if (_this2.querySelector('#play-audio-info')) {
171
+ audio.play();
172
+ container.removeChild(info);
173
+ }
174
+
175
+ document.removeEventListener('click', enableAudio);
176
+ }; // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
177
+ // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
178
+
179
+
180
+ setTimeout(function () {
181
+ if (audio.paused && !_this2.querySelector('#play-audio-info')) {
182
+ // add info message as a toast to enable audio playback
183
+ container.appendChild(info);
184
+ document.addEventListener('click', enableAudio);
185
+ } else {
186
+ document.removeEventListener('click', enableAudio);
187
+ }
188
+ }, 500); // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
189
+
190
+ var handlePlaying = function handlePlaying() {
191
+ var info = _this2.querySelector('#play-audio-info');
192
+
193
+ if (info) {
194
+ _this2.removeChild(info);
195
+ }
196
+
197
+ audio.removeEventListener('playing', handlePlaying);
198
+ };
199
+
200
+ audio.addEventListener('playing', handlePlaying); // we need to listen for the ended event to update the isComplete state
201
+
202
+ var handleEnded = function handleEnded() {
203
+ _this2.audioComplete = true;
204
+
205
+ _this2.dispatchChangedEvent();
206
+
207
+ audio.removeEventListener('ended', handleEnded);
208
+ };
209
+
210
+ audio.addEventListener('ended', handleEnded);
211
+ observer.disconnect();
212
+ }
213
+ });
214
+ });
215
+ observer.observe(this, {
216
+ childList: true,
217
+ subtree: true
218
+ });
113
219
  }
114
220
  }]);
115
221
  return DragInTheBlank;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["isComplete","session","model","value","Object","values","some","DragInTheBlank","_model","_session","elem","React","createElement","Main","onChange","changeSession","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","selector","dispatchChangedEvent","_render","m","ModelSetEvent","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEO,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,OAAD,EAAUC,KAAV,EAAoB;AAC5C,MAAI,CAACD,OAAD,IAAY,CAACA,OAAO,CAACE,KAAzB,EAAgC;AAC9B,WAAO,KAAP;AACD;;AAED,SAAOC,MAAM,CAACC,MAAP,CAAcJ,OAAO,CAACE,KAAR,IAAiB,EAA/B,EAAmCG,IAAnC,CAAwC,UAACH,KAAD;AAAA,WAAW,CAAC,CAACA,KAAb;AAAA,GAAxC,CAAP;AACD,CANM;;;;IAQcI,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AADY,gGAsBJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCX,UAAAA,KAAK,EAAE,MAAKM,MADuB;AAEnCL,UAAAA,KAAK,EAAE,MAAKM,QAAL,CAAcN,KAFc;AAGnCW,UAAAA,QAAQ,EAAE,MAAKC;AAHoB,SAA1B,CAAX;;AAMAC,6BAASC,MAAT,CAAgBP,IAAhB,kDAA4B,YAAM;AAChC;AACD,SAFD;AAGD;AACF,KAlCa;AAAA,6GAoCS,YAAM;AAC3B,YAAKQ,aAAL,CAAmB,IAAIC,oCAAJ,CAAwB,MAAKC,OAAL,CAAaC,WAAb,EAAxB,EAAoDrB,UAAU,CAAC,MAAKS,QAAN,CAA9D,CAAnB;AACD,KAtCa;AAAA,sGAwCE,UAACN,KAAD,EAAW;AACzB,YAAKF,OAAL,CAAaE,KAAb,GAAqBA,KAArB;AACA,YAAKF,OAAL,CAAaqB,QAAb,GAAwB,OAAxB;;AAEA,YAAKC,oBAAL;;AACA,YAAKC,OAAL;AACD,KA9Ca;AAEZ,UAAKhB,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAHY;AAIb;;;;SAED,aAAUgB,CAAV,EAAa;AACX,WAAKjB,MAAL,GAAciB,CAAd;AACA,WAAKP,aAAL,CAAmB,IAAIQ,8BAAJ,CAAkB,KAAKN,OAAL,CAAaC,WAAb,EAAlB,EAA8CrB,UAAU,CAAC,KAAKS,QAAN,CAAxD,EAAyE,CAAC,CAAC,KAAKD,MAAhF,CAAnB;;AAEA,WAAKgB,OAAL;AACD;;;SAOD,eAAc;AACZ,aAAO,KAAKf,QAAZ;AACD,K;SAPD,aAAYkB,CAAZ,EAAe;AACb,WAAKlB,QAAL,GAAgBkB,CAAhB;;AACA,WAAKH,OAAL;AACD;;;WAgCD,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;kDAnDyCI,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport Main from './main';\n\nexport const isComplete = (session, model) => {\n if (!session || !session.value) {\n return false;\n }\n\n return Object.values(session.value || {}).some((value) => !!value);\n};\n\nexport default class DragInTheBlank extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), isComplete(this._session), !!this._model));\n\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 ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(this._session)));\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 connectedCallback() {\n this._render();\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["isComplete","session","model","audioComplete","autoplayAudioEnabled","completeAudioEnabled","value","Object","values","some","DragInTheBlank","_model","_session","elem","React","createElement","Main","onChange","changeSession","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","selector","dispatchChangedEvent","_render","m","ModelSetEvent","s","info","document","id","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","img","src","alt","appendChild","observer","MutationObserver","mutationsList","forEach","mutation","type","audio","querySelector","isInsidePrompt","closest","_createAudioInfoToast","container","enableAudio","play","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","handleEnded","disconnect","observe","childList","subtree","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEO,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,OAAD,EAAUC,KAAV,EAAiBC,aAAjB,E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AAN,IAAgB,CAAC,MAAI,CAACV,aAAL,CAAmB,kBAAnB,CAArB,EAA6D;AAC3D;AACAI,gBAAAA,SAAS,CAACZ,WAAV,CAAsBjB,IAAtB;AACAC,gBAAAA,QAAQ,CAACmC,gBAAT,CAA0B,OAA1B,EAAmCN,WAAnC;AACD,eAJD,MAIO;AACL7B,gBAAAA,QAAQ,CAACgC,mBAAT,CAA6B,OAA7B,EAAsCH,WAAtC;AACD;AACF,aARS,EAQP,GARO,CAAV,CApBiC,CA8BjC;;AACA,gBAAMO,aAAa,GAAG,SAAhBA,aAAgB,GAAM;AAC1B,kBAAMrC,IAAI,GAAG,MAAI,CAACyB,aAAL,CAAmB,kBAAnB,CAAb;;AAEA,kBAAIzB,IAAJ,EAAU;AACR,gBAAA,MAAI,CAACgC,WAAL,CAAiBhC,IAAjB;AACD;;AAEDwB,cAAAA,KAAK,CAACS,mBAAN,CAA0B,SAA1B,EAAqCI,aAArC;AACD,aARD;;AAUAb,YAAAA,KAAK,CAACY,gBAAN,CAAuB,SAAvB,EAAkCC,aAAlC,EAzCiC,CA2CjC;;AACA,gBAAMC,WAAW,GAAG,SAAdA,WAAc,GAAM;AACxB,cAAA,MAAI,CAAClE,aAAL,GAAqB,IAArB;;AACA,cAAA,MAAI,CAACuB,oBAAL;;AACA6B,cAAAA,KAAK,CAACS,mBAAN,CAA0B,OAA1B,EAAmCK,WAAnC;AACD,aAJD;;AAMAd,YAAAA,KAAK,CAACY,gBAAN,CAAuB,OAAvB,EAAgCE,WAAhC;AAEApB,YAAAA,QAAQ,CAACqB,UAAT;AACD;AACF,SAvDD;AAwDD,OAzDgB,CAAjB;AA2DArB,MAAAA,QAAQ,CAACsB,OAAT,CAAiB,IAAjB,EAAuB;AAAEC,QAAAA,SAAS,EAAE,IAAb;AAAmBC,QAAAA,OAAO,EAAE;AAA5B,OAAvB;AACD;;;kDAlJyCC,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport Main from './main';\n\nexport const isComplete = (session, model, audioComplete) => {\n const { autoplayAudioEnabled, completeAudioEnabled } = model || {};\n\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n return false;\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n return Object.values(session.value || {}).some((value) => !!value);\n};\n\nexport default class DragInTheBlank extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this.audioComplete = false;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete), !!this._model));\n\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 ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete)));\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 });\n\n const img = document.createElement('img');\n img.src = 'https://student.assessment.renaissance.com/ce/quizenginecap/assets/img/playAppsSel.gif';\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 if (this._model && !this._model.autoplayAudioEnabled) {\n return;\n }\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 const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('[class*=\"main\"]');\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 const info = this.querySelector('#play-audio-info');\n\n if (info) {\n this.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 this.audioComplete = true;\n this.dispatchChangedEvent();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n}\n"],"file":"index.js"}
package/lib/main.js CHANGED
@@ -86,13 +86,16 @@ var Main = /*#__PURE__*/function (_React$Component) {
86
86
  prompt = model.prompt,
87
87
  mode = model.mode,
88
88
  language = model.language,
89
- fontSizeFactor = model.fontSizeFactor;
89
+ fontSizeFactor = model.fontSizeFactor,
90
+ autoplayAudioEnabled = model.autoplayAudioEnabled;
90
91
 
91
92
  var modelWithValue = _objectSpread(_objectSpread({}, model), {}, {
92
93
  value: value
93
94
  });
94
95
 
95
- var showCorrectAnswerToggle = mode === 'evaluate';
96
+ var showCorrectAnswerToggle = mode === 'evaluate'; // Safari, Firefox, and Edge do not support autoplay audio smoothly in our use case
97
+
98
+ var addAutoplayAudio = autoplayAudioEnabled && !(/Safari|Firefox|Edg/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));
96
99
  return /*#__PURE__*/_react["default"].createElement(_renderUi.UiLayout, {
97
100
  extraCSSRules: extraCSSRules,
98
101
  className: classes.mainContainer,
@@ -106,7 +109,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
106
109
  }, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
107
110
  prompt: model.teacherInstructions
108
111
  })), prompt && /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
109
- prompt: prompt
112
+ className: "prompt",
113
+ prompt: prompt,
114
+ autoplayAudioEnabled: addAutoplayAudio
110
115
  }), /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle.CorrectAnswerToggle, {
111
116
  show: showCorrectAnswerToggle,
112
117
  toggled: showCorrectAnswer,
@@ -148,7 +153,8 @@ var styles = function styles(theme) {
148
153
  backgroundColor: _renderUi.color.background(),
149
154
  '& tr > td': {
150
155
  color: _renderUi.color.text()
151
- }
156
+ },
157
+ position: 'relative'
152
158
  },
153
159
  collapsible: {
154
160
  marginBottom: theme.spacing.unit * 2
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.js"],"names":["DraggableDragInTheBlank","DragInTheBlank","Main","showCorrectAnswer","setState","state","props","model","onChange","value","classes","extraCSSRules","prompt","mode","language","fontSizeFactor","modelWithValue","showCorrectAnswerToggle","mainContainer","teacherInstructions","collapsible","hidden","visible","toggleShowCorrect","rationale","React","Component","PropTypes","object","feedback","func","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","marginTop"],"mappings":";;;;;;;;;;;;;;;;;;;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AAAA,KAAK,EAAEA,gBAAMC,IAAN,EADM;AAEbC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFJ;AAGb,mBAAa;AACXH,QAAAA,KAAK,EAAEA,gBAAMC,IAAN;AADI;AAHA,KADU;AAQzBd,IAAAA,WAAW,EAAE;AACXiB,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADxB,KARY;AAWzBf,IAAAA,SAAS,EAAE;AACTgB,MAAAA,SAAS,EAAER,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADvB;AAXc,GAAZ;AAAA,CAAf;;eAgBe,wBAAWR,MAAX,EAAmB7B,IAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {CorrectAnswerToggle} from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { DragInTheBlank } from '@pie-lib/pie-toolbox/mask-markup';\nimport { withDragContext } from '@pie-lib/pie-toolbox/drag';\nimport { color, Collapsible, hasText, PreviewPrompt, UiLayout } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst DraggableDragInTheBlank = withDragContext(DragInTheBlank);\n\nexport class Main extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\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 render() {\n const { showCorrectAnswer } = this.state;\n const { model, onChange, value, classes } = this.props;\n const { extraCSSRules, prompt, mode, language, fontSizeFactor } = model;\n const modelWithValue = { ...model, value };\n const showCorrectAnswerToggle = mode === 'evaluate';\n\n return (\n <UiLayout extraCSSRules={extraCSSRules} className={classes.mainContainer} fontSizeFactor={fontSizeFactor}>\n {model.teacherInstructions && hasText(model.teacherInstructions) && (\n <Collapsible\n className={classes.collapsible}\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n >\n <PreviewPrompt prompt={model.teacherInstructions} />\n </Collapsible>\n )}\n\n {prompt && <PreviewPrompt prompt={prompt} />}\n\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n language={language}\n />\n\n <DraggableDragInTheBlank {...modelWithValue} onChange={onChange} showCorrectAnswer={showCorrectAnswer} />\n\n {model.rationale && hasText(model.rationale) && (\n <Collapsible className={classes.rationale} labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt prompt={model.rationale} />\n </Collapsible>\n )}\n </UiLayout>\n );\n }\n}\n\nconst styles = (theme) => ({\n mainContainer: {\n color: color.text(),\n backgroundColor: color.background(),\n '& tr > td': {\n color: color.text(),\n },\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n rationale: {\n marginTop: theme.spacing.unit * 2,\n },\n});\n\nexport default withStyles(styles)(Main);\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.js"],"names":["DraggableDragInTheBlank","DragInTheBlank","Main","showCorrectAnswer","setState","state","props","model","onChange","value","classes","extraCSSRules","prompt","mode","language","fontSizeFactor","autoplayAudioEnabled","modelWithValue","showCorrectAnswerToggle","addAutoplayAudio","test","navigator","userAgent","mainContainer","teacherInstructions","collapsible","hidden","visible","toggleShowCorrect","rationale","React","Component","PropTypes","object","feedback","func","styles","theme","color","text","backgroundColor","background","position","marginBottom","spacing","unit","marginTop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,uBAAuB,GAAG,2BAAgBC,0BAAhB,CAAhC;;IAEaC,I;;;;;;;;;;;;;;;8FAaH;AACNC,MAAAA,iBAAiB,EAAE;AADb,K;0GAIY,YAAM;AACxB,YAAKC,QAAL,CAAc;AAAED,Q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SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBd,IAAAA,aAAa,EAAE;AACbe,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADM;AAEbC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFJ;AAGb,mBAAa;AACXH,QAAAA,KAAK,EAAEA,gBAAMC,IAAN;AADI,OAHA;AAMbG,MAAAA,QAAQ,EAAE;AANG,KADU;AASzBjB,IAAAA,WAAW,EAAE;AACXkB,MAAAA,YAAY,EAAEN,KAAK,CAACO,OAAN,CAAcC,IAAd,GAAqB;AADxB,KATY;AAYzBhB,IAAAA,SAAS,EAAE;AACTiB,MAAAA,SAAS,EAAET,KAAK,CAACO,OAAN,CAAcC,IAAd,GAAqB;AADvB;AAZc,GAAZ;AAAA,CAAf;;eAiBe,wBAAWT,MAAX,EAAmBlC,IAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {CorrectAnswerToggle} from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { DragInTheBlank } from '@pie-lib/pie-toolbox/mask-markup';\nimport { withDragContext } from '@pie-lib/pie-toolbox/drag';\nimport { color, Collapsible, hasText, PreviewPrompt, UiLayout } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst DraggableDragInTheBlank = withDragContext(DragInTheBlank);\n\nexport class Main extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\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 render() {\n const { showCorrectAnswer } = this.state;\n const { model, onChange, value, classes } = this.props;\n const { extraCSSRules, prompt, mode, language, fontSizeFactor, autoplayAudioEnabled } = model;\n const modelWithValue = { ...model, value };\n const showCorrectAnswerToggle = mode === 'evaluate';\n // Safari, Firefox, and Edge do not support autoplay audio smoothly in our use case\n const addAutoplayAudio = autoplayAudioEnabled && !(/Safari|Firefox|Edg/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));\n\n return (\n <UiLayout extraCSSRules={extraCSSRules} className={classes.mainContainer} fontSizeFactor={fontSizeFactor}>\n {model.teacherInstructions && hasText(model.teacherInstructions) && (\n <Collapsible\n className={classes.collapsible}\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n >\n <PreviewPrompt prompt={model.teacherInstructions} />\n </Collapsible>\n )}\n\n {prompt && <PreviewPrompt className=\"prompt\" prompt={prompt} autoplayAudioEnabled={addAutoplayAudio} />}\n\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n language={language}\n />\n\n <DraggableDragInTheBlank {...modelWithValue} onChange={onChange} showCorrectAnswer={showCorrectAnswer} />\n\n {model.rationale && hasText(model.rationale) && (\n <Collapsible className={classes.rationale} labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt prompt={model.rationale} />\n </Collapsible>\n )}\n </UiLayout>\n );\n }\n}\n\nconst styles = (theme) => ({\n mainContainer: {\n color: color.text(),\n backgroundColor: color.background(),\n '& tr > td': {\n color: color.text(),\n },\n position: 'relative'\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n rationale: {\n marginTop: theme.spacing.unit * 2,\n },\n});\n\nexport default withStyles(styles)(Main);\n"],"file":"main.js"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "6.6.2-next.31+96093f50c",
7
+ "version": "6.6.2-next.37+bad3964ad",
8
8
  "description": "",
9
9
  "scripts": {
10
10
  "postpublish": "../../scripts/postpublish"
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "author": "",
23
23
  "license": "ISC",
24
- "gitHead": "96093f50c5b6a903bd67b0a84c8033fb99304d83",
24
+ "gitHead": "bad3964ad2249d589641fe51c401c73d8bd11e2e",
25
25
  "main": "lib/index.js",
26
26
  "module": "src/index.js"
27
27
  }