@pie-element/explicit-constructed-response 7.3.6-next.4 → 7.3.6-next.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.
@@ -8,7 +8,7 @@
8
8
  "@material-ui/core": "^3.9.2",
9
9
  "@material-ui/icons": "^3.0.1",
10
10
  "@pie-framework/pie-configure-events": "^1.3.0",
11
- "@pie-lib/pie-toolbox": "2.9.5",
11
+ "@pie-lib/pie-toolbox": "2.10.0",
12
12
  "classnames": "^2.2.6",
13
13
  "debug": "^3.1.0",
14
14
  "lodash": "^4.17.15",
@@ -8,7 +8,7 @@
8
8
  "author": "",
9
9
  "license": "ISC",
10
10
  "dependencies": {
11
- "@pie-lib/pie-toolbox": "2.9.5",
11
+ "@pie-lib/pie-toolbox": "2.10.0",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15",
14
14
  "type-of": "^2.0.1"
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.3.4/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.4/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.3.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.5/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
package/module/element.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_framework__mathquill, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.3.4/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.4/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_framework__mathquill, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.3.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.5/module/index.js";
3
3
  function _mergeNamespaces(n, m) {
4
4
  m.forEach(function (e) {
5
5
  e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
@@ -140560,7 +140560,7 @@ const require$$11$s = _dll_prop_types;
140560
140560
  }
140561
140561
  _this = _super.call.apply(_super, [this].concat(args));
140562
140562
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "parsedText", function (text) {
140563
- var autoplayAudioEnabled = _this.props.autoplayAudioEnabled;
140563
+ var customAudioButton = _this.props.customAudioButton;
140564
140564
  var div = document.createElement('div');
140565
140565
  div.innerHTML = text;
140566
140566
  var audio = div.querySelector('audio');
@@ -140569,25 +140569,101 @@ const require$$11$s = _dll_prop_types;
140569
140569
  source.setAttribute('type', 'audio/mp3');
140570
140570
  source.setAttribute('src', audio.getAttribute('src'));
140571
140571
  audio.removeAttribute('src');
140572
- if (autoplayAudioEnabled) {
140573
- audio.setAttribute('autoplay', 'autoplay');
140574
- }
140572
+ audio.setAttribute('id', 'pie-prompt-audio-player');
140575
140573
  audio.appendChild(source);
140574
+ if (customAudioButton) {
140575
+ audio.style.display = 'none';
140576
+ var playButton = document.createElement('div');
140577
+ playButton.id = 'play-audio-button';
140578
+ Object.assign(playButton.style, {
140579
+ cursor: 'pointer',
140580
+ display: 'block',
140581
+ width: '128px',
140582
+ height: '128px',
140583
+ backgroundImage: ("url(").concat(customAudioButton.pauseImage, ")"),
140584
+ backgroundSize: 'cover',
140585
+ borderRadius: '50%',
140586
+ border: '1px solid #326295'
140587
+ });
140588
+ audio.parentNode.insertBefore(playButton, audio);
140589
+ }
140576
140590
  }
140577
140591
  return div.innerHTML;
140578
140592
  });
140579
140593
  return _this;
140580
140594
  }
140581
140595
  (0, _createClass2["default"])(PreviewPrompt, [{
140596
+ key: "addCustomAudioButtonControls",
140597
+ value: function addCustomAudioButtonControls() {
140598
+ var _this$props = this.props, autoplayAudioEnabled = _this$props.autoplayAudioEnabled, customAudioButton = _this$props.customAudioButton;
140599
+ var playButton = document.getElementById('play-audio-button');
140600
+ var audio = document.getElementById('pie-prompt-audio-player');
140601
+ if (autoplayAudioEnabled && audio) {
140602
+ audio.play().then(function () {
140603
+ if (playButton && customAudioButton) {
140604
+ audio.addEventListener('ended', handleAudioEnded);
140605
+ }
140606
+ })["catch"](function (error) {
140607
+ console.error('Error playing audio', error);
140608
+ });
140609
+ }
140610
+ if (!playButton || !audio || !customAudioButton) return;
140611
+ var handlePlayClick = function handlePlayClick() {
140612
+ if (!audio.paused) return;
140613
+ if (playButton.style.backgroundImage.includes(customAudioButton.pauseImage)) return;
140614
+ audio.play();
140615
+ };
140616
+ var handleAudioEnded = function handleAudioEnded() {
140617
+ playButton.style.backgroundImage = ("url(").concat(customAudioButton.playImage, ")");
140618
+ };
140619
+ var handleAudioPlay = function handleAudioPlay() {
140620
+ Object.assign(playButton.style, {
140621
+ backgroundImage: ("url(").concat(customAudioButton.pauseImage, ")"),
140622
+ border: '1px solid #ccc'
140623
+ });
140624
+ };
140625
+ var handleAudioPause = function handleAudioPause() {
140626
+ Object.assign(playButton.style, {
140627
+ backgroundImage: ("url(").concat(customAudioButton.playImage, ")"),
140628
+ border: '1px solid #326295'
140629
+ });
140630
+ };
140631
+ playButton.addEventListener('click', handlePlayClick);
140632
+ audio.addEventListener('play', handleAudioPlay);
140633
+ audio.addEventListener('pause', handleAudioPause);
140634
+ audio.addEventListener('ended', handleAudioEnded);
140635
+ this._handlePlayClick = handlePlayClick;
140636
+ this._handleAudioPlay = handleAudioPlay;
140637
+ this._handleAudioPause = handleAudioPause;
140638
+ this._handleAudioEnded = handleAudioEnded;
140639
+ }
140640
+ }, {
140641
+ key: "removeCustomAudioButtonListeners",
140642
+ value: function removeCustomAudioButtonListeners() {
140643
+ var playButton = document.getElementById('play-audio-button');
140644
+ var audio = document.querySelector('audio');
140645
+ if (!playButton || !audio) return;
140646
+ playButton.removeEventListener('click', this._handlePlayClick);
140647
+ audio.removeEventListener('play', this._handleAudioPlay);
140648
+ audio.removeEventListener('pause', this._handleAudioPause);
140649
+ audio.removeEventListener('ended', this._handleAudioEnded);
140650
+ }
140651
+ }, {
140582
140652
  key: "componentDidMount",
140583
140653
  value: function componentDidMount() {
140584
140654
  this.alignImages();
140655
+ this.addCustomAudioButtonControls();
140585
140656
  }
140586
140657
  }, {
140587
140658
  key: "componentDidUpdate",
140588
140659
  value: function componentDidUpdate() {
140589
140660
  this.alignImages();
140590
140661
  }
140662
+ }, {
140663
+ key: "componentWillUnmount",
140664
+ value: function componentWillUnmount() {
140665
+ this.removeCustomAudioButtonListeners();
140666
+ }
140591
140667
  }, {
140592
140668
  key: "alignImages",
140593
140669
  value: function alignImages() {
@@ -140622,7 +140698,7 @@ const require$$11$s = _dll_prop_types;
140622
140698
  }, {
140623
140699
  key: "render",
140624
140700
  value: function render() {
140625
- var _this$props = this.props, prompt = _this$props.prompt, classes = _this$props.classes, tagName = _this$props.tagName, className = _this$props.className, onClick = _this$props.onClick, defaultClassName = _this$props.defaultClassName;
140701
+ var _this$props2 = this.props, prompt = _this$props2.prompt, classes = _this$props2.classes, tagName = _this$props2.tagName, className = _this$props2.className, onClick = _this$props2.onClick, defaultClassName = _this$props2.defaultClassName;
140626
140702
  var CustomTag = tagName || 'div';
140627
140703
  var legendClass = tagName === 'legend' ? 'legend' : '';
140628
140704
  var customClasses = ("").concat(classes.promptTable, " ").concat(classes[className] || '', " ").concat(defaultClassName || '', " ").concat(classes[legendClass] || '');
@@ -140646,7 +140722,11 @@ const require$$11$s = _dll_prop_types;
140646
140722
  className: _propTypes["default"].string,
140647
140723
  onClick: _propTypes["default"].func,
140648
140724
  defaultClassName: _propTypes["default"].string,
140649
- autoplayAudioEnabled: _propTypes["default"].bool
140725
+ autoplayAudioEnabled: _propTypes["default"].bool,
140726
+ customAudioButton: {
140727
+ playImage: _propTypes["default"].string,
140728
+ pauseImage: _propTypes["default"].string
140729
+ }
140650
140730
  });
140651
140731
  (0, _defineProperty2["default"])(PreviewPrompt, "defaultProps", {
140652
140732
  onClick: function onClick() {}
@@ -4,11 +4,11 @@
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-math-rendering-module",
7
- "version": "3.3.4"
7
+ "version": "3.3.5"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/pie-toolbox-module",
11
- "version": "5.10.4"
11
+ "version": "5.10.5"
12
12
  }
13
13
  ]
14
14
  }
package/module/print.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_framework__mathquill, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.3.4/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.4/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_framework__mathquill, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.3.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.5/module/index.js";
3
3
  function _mergeNamespaces(n, m) {
4
4
  m.forEach(function (e) {
5
5
  e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
@@ -140523,7 +140523,7 @@ const require$$11$s = _dll_prop_types;
140523
140523
  }
140524
140524
  _this = _super.call.apply(_super, [this].concat(args));
140525
140525
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "parsedText", function (text) {
140526
- var autoplayAudioEnabled = _this.props.autoplayAudioEnabled;
140526
+ var customAudioButton = _this.props.customAudioButton;
140527
140527
  var div = document.createElement('div');
140528
140528
  div.innerHTML = text;
140529
140529
  var audio = div.querySelector('audio');
@@ -140532,25 +140532,101 @@ const require$$11$s = _dll_prop_types;
140532
140532
  source.setAttribute('type', 'audio/mp3');
140533
140533
  source.setAttribute('src', audio.getAttribute('src'));
140534
140534
  audio.removeAttribute('src');
140535
- if (autoplayAudioEnabled) {
140536
- audio.setAttribute('autoplay', 'autoplay');
140537
- }
140535
+ audio.setAttribute('id', 'pie-prompt-audio-player');
140538
140536
  audio.appendChild(source);
140537
+ if (customAudioButton) {
140538
+ audio.style.display = 'none';
140539
+ var playButton = document.createElement('div');
140540
+ playButton.id = 'play-audio-button';
140541
+ Object.assign(playButton.style, {
140542
+ cursor: 'pointer',
140543
+ display: 'block',
140544
+ width: '128px',
140545
+ height: '128px',
140546
+ backgroundImage: ("url(").concat(customAudioButton.pauseImage, ")"),
140547
+ backgroundSize: 'cover',
140548
+ borderRadius: '50%',
140549
+ border: '1px solid #326295'
140550
+ });
140551
+ audio.parentNode.insertBefore(playButton, audio);
140552
+ }
140539
140553
  }
140540
140554
  return div.innerHTML;
140541
140555
  });
140542
140556
  return _this;
140543
140557
  }
140544
140558
  (0, _createClass2["default"])(PreviewPrompt, [{
140559
+ key: "addCustomAudioButtonControls",
140560
+ value: function addCustomAudioButtonControls() {
140561
+ var _this$props = this.props, autoplayAudioEnabled = _this$props.autoplayAudioEnabled, customAudioButton = _this$props.customAudioButton;
140562
+ var playButton = document.getElementById('play-audio-button');
140563
+ var audio = document.getElementById('pie-prompt-audio-player');
140564
+ if (autoplayAudioEnabled && audio) {
140565
+ audio.play().then(function () {
140566
+ if (playButton && customAudioButton) {
140567
+ audio.addEventListener('ended', handleAudioEnded);
140568
+ }
140569
+ })["catch"](function (error) {
140570
+ console.error('Error playing audio', error);
140571
+ });
140572
+ }
140573
+ if (!playButton || !audio || !customAudioButton) return;
140574
+ var handlePlayClick = function handlePlayClick() {
140575
+ if (!audio.paused) return;
140576
+ if (playButton.style.backgroundImage.includes(customAudioButton.pauseImage)) return;
140577
+ audio.play();
140578
+ };
140579
+ var handleAudioEnded = function handleAudioEnded() {
140580
+ playButton.style.backgroundImage = ("url(").concat(customAudioButton.playImage, ")");
140581
+ };
140582
+ var handleAudioPlay = function handleAudioPlay() {
140583
+ Object.assign(playButton.style, {
140584
+ backgroundImage: ("url(").concat(customAudioButton.pauseImage, ")"),
140585
+ border: '1px solid #ccc'
140586
+ });
140587
+ };
140588
+ var handleAudioPause = function handleAudioPause() {
140589
+ Object.assign(playButton.style, {
140590
+ backgroundImage: ("url(").concat(customAudioButton.playImage, ")"),
140591
+ border: '1px solid #326295'
140592
+ });
140593
+ };
140594
+ playButton.addEventListener('click', handlePlayClick);
140595
+ audio.addEventListener('play', handleAudioPlay);
140596
+ audio.addEventListener('pause', handleAudioPause);
140597
+ audio.addEventListener('ended', handleAudioEnded);
140598
+ this._handlePlayClick = handlePlayClick;
140599
+ this._handleAudioPlay = handleAudioPlay;
140600
+ this._handleAudioPause = handleAudioPause;
140601
+ this._handleAudioEnded = handleAudioEnded;
140602
+ }
140603
+ }, {
140604
+ key: "removeCustomAudioButtonListeners",
140605
+ value: function removeCustomAudioButtonListeners() {
140606
+ var playButton = document.getElementById('play-audio-button');
140607
+ var audio = document.querySelector('audio');
140608
+ if (!playButton || !audio) return;
140609
+ playButton.removeEventListener('click', this._handlePlayClick);
140610
+ audio.removeEventListener('play', this._handleAudioPlay);
140611
+ audio.removeEventListener('pause', this._handleAudioPause);
140612
+ audio.removeEventListener('ended', this._handleAudioEnded);
140613
+ }
140614
+ }, {
140545
140615
  key: "componentDidMount",
140546
140616
  value: function componentDidMount() {
140547
140617
  this.alignImages();
140618
+ this.addCustomAudioButtonControls();
140548
140619
  }
140549
140620
  }, {
140550
140621
  key: "componentDidUpdate",
140551
140622
  value: function componentDidUpdate() {
140552
140623
  this.alignImages();
140553
140624
  }
140625
+ }, {
140626
+ key: "componentWillUnmount",
140627
+ value: function componentWillUnmount() {
140628
+ this.removeCustomAudioButtonListeners();
140629
+ }
140554
140630
  }, {
140555
140631
  key: "alignImages",
140556
140632
  value: function alignImages() {
@@ -140585,7 +140661,7 @@ const require$$11$s = _dll_prop_types;
140585
140661
  }, {
140586
140662
  key: "render",
140587
140663
  value: function render() {
140588
- var _this$props = this.props, prompt = _this$props.prompt, classes = _this$props.classes, tagName = _this$props.tagName, className = _this$props.className, onClick = _this$props.onClick, defaultClassName = _this$props.defaultClassName;
140664
+ var _this$props2 = this.props, prompt = _this$props2.prompt, classes = _this$props2.classes, tagName = _this$props2.tagName, className = _this$props2.className, onClick = _this$props2.onClick, defaultClassName = _this$props2.defaultClassName;
140589
140665
  var CustomTag = tagName || 'div';
140590
140666
  var legendClass = tagName === 'legend' ? 'legend' : '';
140591
140667
  var customClasses = ("").concat(classes.promptTable, " ").concat(classes[className] || '', " ").concat(defaultClassName || '', " ").concat(classes[legendClass] || '');
@@ -140609,7 +140685,11 @@ const require$$11$s = _dll_prop_types;
140609
140685
  className: _propTypes["default"].string,
140610
140686
  onClick: _propTypes["default"].func,
140611
140687
  defaultClassName: _propTypes["default"].string,
140612
- autoplayAudioEnabled: _propTypes["default"].bool
140688
+ autoplayAudioEnabled: _propTypes["default"].bool,
140689
+ customAudioButton: {
140690
+ playImage: _propTypes["default"].string,
140691
+ pauseImage: _propTypes["default"].string
140692
+ }
140613
140693
  });
140614
140694
  (0, _defineProperty2["default"])(PreviewPrompt, "defaultProps", {
140615
140695
  onClick: function onClick() {}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "7.3.6-next.4+dd3fde7ef",
7
+ "version": "7.3.6-next.6+843584110",
8
8
  "description": "",
9
9
  "scripts": {
10
10
  "postpublish": "../../scripts/postpublish"
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@material-ui/core": "^3.9.2",
14
14
  "@pie-framework/pie-player-events": "^0.1.0",
15
- "@pie-lib/pie-toolbox": "2.9.5",
15
+ "@pie-lib/pie-toolbox": "2.10.0",
16
16
  "classnames": "^2.2.5",
17
17
  "lodash": "^4.17.10",
18
18
  "prop-types": "^15.6.1",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "author": "",
23
23
  "license": "ISC",
24
- "gitHead": "dd3fde7ef95879ed17976bb057963dae43a601df",
24
+ "gitHead": "843584110d234c09778612f3c9607ec3c7531900",
25
25
  "main": "lib/index.js",
26
26
  "module": "src/index.js",
27
27
  "exports": {