@pie-element/multiple-choice 8.17.1-next.0 → 8.17.1-next.5

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/lib/index.js CHANGED
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.isComplete = exports["default"] = void 0;
9
9
 
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
10
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
13
 
12
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -72,6 +74,8 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
72
74
 
73
75
  _this.setAttribute('role', 'region');
74
76
 
77
+ _this.setLangAttribute();
78
+
75
79
  _reactDom["default"].render(element, (0, _assertThisInitialized2["default"])(_this), function () {
76
80
  log('render complete - render math');
77
81
  (0, _mathRenderingAccessible.renderMath)((0, _assertThisInitialized2["default"])(_this));
@@ -113,6 +117,13 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
113
117
  }
114
118
 
115
119
  (0, _createClass2["default"])(MultipleChoice, [{
120
+ key: "setLangAttribute",
121
+ value: function setLangAttribute() {
122
+ var language = this._model && (0, _typeof2["default"])(this._model.language) ? this._model.language : '';
123
+ var lang = language ? language.slice(0, 2) : 'en';
124
+ this.setAttribute('lang', lang);
125
+ }
126
+ }, {
116
127
  key: "model",
117
128
  set: function set(s) {
118
129
  this._model = s;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","isComplete","session","value","length","MultipleChoice","_model","_session","_rerender","element","React","createElement","Main","model","onChoiceChanged","_onChange","bind","setAttribute","choiceMode","ReactDOM","render","leading","trailing","_dispatchResponseChanged","event","CustomEvent","bubbles","composed","detail","complete","component","tagName","toLowerCase","dispatchEvent","_dispatchModelSet","hasModel","undefined","s","data","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,MAAL,CAAYY,UAA9C,EAA0DoB,IAA1D;;AACA,WAAKf,wBAAL;;AACA,WAAKf,SAAL;AACD;;;WAED,6BAAoB;AAClB,WAAKA,SAAL;AACD;;;kDA3FyC+B,W","sourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering-accessible';\nimport { updateSessionValue } from './session-updater';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session) => !!(session && session.value && session.value.length);\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n var element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onChoiceChanged: this._onChange.bind(this),\n });\n\n //TODO: aria-label is set in the _rerender because we need to change it when the model.choiceMode is updated. Consider revisiting the placement of the aria-label setting in the _rerender\n this.setAttribute(\n 'aria-label',\n this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question',\n );\n this.setAttribute('role', 'region');\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n\n this._dispatchResponseChanged = debounce(() => {\n var event = new CustomEvent('session-changed', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n },\n });\n\n this.dispatchEvent(event);\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new CustomEvent('model-set', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n hasModel: this._model !== undefined,\n },\n }),\n );\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n this._dispatchModelSet();\n }\n\n get session() {\n return this._session;\n }\n\n set session(s) {\n this._session = s;\n this._rerender();\n //TODO: remove this session-changed should only be emit on user change\n this._dispatchResponseChanged();\n }\n\n _onChange(data) {\n updateSessionValue(this._session, this._model.choiceMode, data);\n this._dispatchResponseChanged();\n this._rerender();\n }\n\n connectedCallback() {\n this._rerender();\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","isComplete","session","value","length","MultipleChoice","_model","_session","_rerender","element","React","createElement","Main","model","onChoiceChanged","_onChange","bind","setAttribute","choiceMode","setLangAttribute","ReactDOM","render","leading","trailing","_dispatchResponseChanged","event","CustomEvent","bubbles","composed","detail","complete","component","tagName","toLowerCase","dispatchEvent","_dispatchModelSet","hasModel","undefined","language","lang","slice","s","data","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wBAAN,CAAZ;;AAEO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,OAAD;AAAA,SAAa,CAAC,EAAEA,OAAO,IAAIA,OAAO,CAACC,KAAnB,IAA4BD,OAAO,CAACC,KAAR,CAAcC,MAA5C,CAAd;AAAA,CAAnB;;;;IAEcC,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAEA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UAAI,MAAKF,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIE,OAAO,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACtCC,UAAAA,KAAK,EAAE,MAAKP,MAD0B;AAEtCJ,UAAAA,OAAO,EAAE,MAAKK,QAFwB;AAGtCO,UAAAA,eAAe,EAAE,MAAKC,SAAL,CAAeC,IAAf;AAHqB,SAA1B,CAAd,CADgC,CAOhC;;;AACA,cAAKC,YAAL,CACE,YADF,EAE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KAbsB,EAcvB,EAduB,EAevB;AAAEf,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KAfuB,CAAzB;AAhDY;AAiEb;;;;WAED,4BAAmB;AACjB,UAAMe,QAAQ,GAAG,KAAKhC,MAAL,6BAAsB,KAAKA,MAAL,CAAYgC,QAAlC,IAA6C,KAAKhC,MAAL,CAAYgC,QAAzD,GAAoE,EAArF;AACA,UAAMC,IAAI,GAAGD,QAAQ,GAAGA,QAAQ,CAACE,KAAT,CAAe,CAAf,EAAkB,CAAlB,CAAH,GAA0B,IAA/C;AACA,WAAKvB,YAAL,CAAkB,MAAlB,EAA0BsB,IAA1B;AACD;;;SAED,aAAUE,CAAV,EAAa;AACX,WAAKnC,MAAL,GAAcmC,CAAd;;AACA,WAAKjC,SAAL;;AACA,WAAK2B,iBAAL;AACD;;;SAED,eAAc;AACZ,aAAO,KAAK5B,QAAZ;AACD,K;SAED,aAAYkC,CAAZ,EAAe;AACb,WAAKlC,QAAL,GAAgBkC,CAAhB;;AACA,WAAKjC,SAAL,GAFa,CAGb;;;AACA,WAAKgB,wBAAL;AACD;;;WAED,mBAAUkB,IAAV,EAAgB;AACd,8CAAmB,KAAKnC,QAAxB,EAAkC,KAAKD,MAAL,CAAYY,UAA9C,EAA0DwB,IAA1D;;AACA,WAAKlB,wBAAL;;AACA,WAAKhB,SAAL;AACD;;;WAED,6BAAoB;AAClB,WAAKA,SAAL;AACD;;;kDAnGyCmC,W","sourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering-accessible';\nimport { updateSessionValue } from './session-updater';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session) => !!(session && session.value && session.value.length);\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n var element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onChoiceChanged: this._onChange.bind(this),\n });\n\n //TODO: aria-label is set in the _rerender because we need to change it when the model.choiceMode is updated. Consider revisiting the placement of the aria-label setting in the _rerender\n this.setAttribute(\n 'aria-label',\n this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question',\n );\n this.setAttribute('role', 'region');\n\n this.setLangAttribute();\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n\n this._dispatchResponseChanged = debounce(() => {\n var event = new CustomEvent('session-changed', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n },\n });\n\n this.dispatchEvent(event);\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new CustomEvent('model-set', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n hasModel: this._model !== undefined,\n },\n }),\n );\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n this._dispatchModelSet();\n }\n\n get session() {\n return this._session;\n }\n\n set session(s) {\n this._session = s;\n this._rerender();\n //TODO: remove this session-changed should only be emit on user change\n this._dispatchResponseChanged();\n }\n\n _onChange(data) {\n updateSessionValue(this._session, this._model.choiceMode, data);\n this._dispatchResponseChanged();\n this._rerender();\n }\n\n connectedCallback() {\n this._rerender();\n }\n}\n"],"file":"index.js"}
package/module/element.js CHANGED
@@ -9691,6 +9691,7 @@ class MultipleChoice extends HTMLElement {
9691
9691
  });
9692
9692
  this.setAttribute('aria-label', this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question');
9693
9693
  this.setAttribute('role', 'region');
9694
+ this.setLangAttribute();
9694
9695
  ReactDOM.render(element, this, () => {
9695
9696
  log('render complete - render math');
9696
9697
  renderMath(this);
@@ -9728,6 +9729,11 @@ class MultipleChoice extends HTMLElement {
9728
9729
  trailing: true
9729
9730
  });
9730
9731
  }
9732
+ setLangAttribute() {
9733
+ const language = this._model && typeof this._model.language ? this._model.language : '';
9734
+ const lang = language ? language.slice(0, 2) : 'en';
9735
+ this.setAttribute('lang', lang);
9736
+ }
9731
9737
  set model(s) {
9732
9738
  this._model = s;
9733
9739
  this._rerender();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice",
3
3
  "repository": "pie-framework/pie-elements",
4
- "version": "8.17.1-next.0+ce4977a7a",
4
+ "version": "8.17.1-next.5+13679356e",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -18,7 +18,7 @@
18
18
  "react-test-renderer": "^16.3.2",
19
19
  "react-transition-group": "^2.3.1"
20
20
  },
21
- "gitHead": "ce4977a7a30f00151e885e5c41b69d6e3a5ee571",
21
+ "gitHead": "13679356ec1bc148cb4629364e415bb60cd77ec3",
22
22
  "scripts": {
23
23
  "postpublish": "../../scripts/postpublish"
24
24
  },