@pie-element/multiple-choice 14.0.6 → 14.0.7-next.20261019062545

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.
Files changed (34) hide show
  1. package/dist/browser/{Radio-DS22zl1y.js → Radio-Dj4zrLS0.js} +865 -741
  2. package/dist/browser/{Radio-DS22zl1y.js.map → Radio-Dj4zrLS0.js.map} +1 -1
  3. package/dist/browser/author/index.js +6300 -6300
  4. package/dist/browser/author/index.js.map +1 -1
  5. package/dist/browser/controller/index.js +1 -1
  6. package/dist/browser/delivery/index.js +77 -73
  7. package/dist/browser/delivery/index.js.map +1 -1
  8. package/dist/browser/editor-runtime/{Radio-CMqZPx3h.js → Radio-B45MfQhQ.js} +865 -741
  9. package/dist/browser/editor-runtime/{Radio-CMqZPx3h.js.map → Radio-B45MfQhQ.js.map} +1 -1
  10. package/dist/browser/editor-runtime/author/index.js +1640 -1640
  11. package/dist/browser/editor-runtime/author/index.js.map +1 -1
  12. package/dist/browser/editor-runtime/controller/index.js +1 -1
  13. package/dist/browser/editor-runtime/delivery/index.js +77 -73
  14. package/dist/browser/editor-runtime/delivery/index.js.map +1 -1
  15. package/dist/browser/{main-OV2y7QCe.js → editor-runtime/main-BvJ9mP7v.js} +300 -299
  16. package/dist/browser/editor-runtime/main-BvJ9mP7v.js.map +1 -0
  17. package/dist/browser/{mathjax-DqXi3q4c-B13HrHzz.js → editor-runtime/mathjax-DqXi3q4c-Y_jZvcuO.js} +2 -2
  18. package/dist/browser/editor-runtime/{mathjax-DqXi3q4c-DnkUutjP.js.map → mathjax-DqXi3q4c-Y_jZvcuO.js.map} +1 -1
  19. package/dist/browser/editor-runtime/print/index.js +5 -5
  20. package/dist/browser/{editor-runtime/main-Cg61UvOA.js → main-DUfYqu6k.js} +299 -298
  21. package/dist/browser/main-DUfYqu6k.js.map +1 -0
  22. package/dist/browser/{editor-runtime/mathjax-DqXi3q4c-DnkUutjP.js → mathjax-DqXi3q4c-D_oxb28N.js} +2 -2
  23. package/dist/browser/{mathjax-DqXi3q4c-B13HrHzz.js.map → mathjax-DqXi3q4c-D_oxb28N.js.map} +1 -1
  24. package/dist/browser/print/index.js +5 -5
  25. package/dist/delivery/index.js +39 -35
  26. package/dist/index.iife.js +21 -21
  27. package/dist/schemas/configuration.schema.json +1 -1
  28. package/dist/schemas/model.schema.json +1 -1
  29. package/dist/schemas/session.schema.json +1 -1
  30. package/module/print.js +3338 -3322
  31. package/module/print.js.map +1 -1
  32. package/package.json +14 -14
  33. package/dist/browser/editor-runtime/main-Cg61UvOA.js.map +0 -1
  34. package/dist/browser/main-OV2y7QCe.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { H as e, K as t, M as n, U as r, tn as i } from "../Radio-DS22zl1y.js";
2
- import { t as a } from "../main-OV2y7QCe.js";
1
+ import { G as e, J as t, M as n, U as r, rn as i } from "../Radio-Dj4zrLS0.js";
2
+ import { t as a } from "../main-DUfYqu6k.js";
3
3
  import { a as o, p as s } from "../dist-DL6MQNxd.js";
4
4
  import c from "react";
5
5
  import { createRoot as l } from "react-dom/client";
@@ -10,8 +10,8 @@ var u = (0, (/* @__PURE__ */ i(t(), 1)).default)("pie-element:multiple-choice:pr
10
10
  constructor() {
11
11
  super(), this._options = null, this._model = null, this._session = [], this._root = null, this._rerender = o(() => {
12
12
  if (this._model && this._session) {
13
- if (!e(this._model.language)) {
14
- r(this._model.language).then(() => this._rerender());
13
+ if (!r(this._model.language)) {
14
+ e(this._model.language).then(() => this._rerender());
15
15
  return;
16
16
  }
17
17
  let t = d(this._model, this._options), i = this._options && c.createElement(a, {
@@ -44,7 +44,7 @@ var u = (0, (/* @__PURE__ */ i(t(), 1)).default)("pie-element:multiple-choice:pr
44
44
  }
45
45
  }, p = Object.freeze({
46
46
  name: "@pie-element/multiple-choice",
47
- version: "14.0.6"
47
+ version: "14.0.7-next.20261019062545"
48
48
  });
49
49
  //#endregion
50
50
  export { f as default, p as piePackage };
@@ -5,27 +5,27 @@ import { updateSessionMetadata as r, updateSessionValue as i } from "./session-u
5
5
  import a from "react";
6
6
  import * as o from "@pie-lib/render-ui";
7
7
  import { EnableAudioAutoplayImage as s, createUniqueId as c } from "@pie-lib/render-ui";
8
- import { isLocaleReady as l, loadLocale as u, stampElementLanguage as d } from "@pie-element/shared-i18n";
9
- import { createRoot as f } from "react-dom/client";
10
- import { debounce as p } from "@pie-element/shared-lodash";
11
- import m from "debug";
12
- import { ModelSetEvent as h, SessionChangedEvent as g, createSessionNotifier as _, flushSessionNotifiers as v } from "@pie-element/shared-player-events";
13
- import { renderMath as y } from "@pie-element/shared-math-rendering-mathjax";
14
- import { autoplayAudioOn as b, promptAudioPending as x, trackPromptAudioFailure as S } from "@pie-element/shared-utils";
8
+ import { isLocaleReady as l, loadLocale as u, stampElementLanguage as d, subscribeInterfaceLocale as f } from "@pie-element/shared-i18n";
9
+ import { createRoot as p } from "react-dom/client";
10
+ import { debounce as m } from "@pie-element/shared-lodash";
11
+ import h from "debug";
12
+ import { ModelSetEvent as g, SessionChangedEvent as _, createSessionNotifier as v, flushSessionNotifiers as y } from "@pie-element/shared-player-events";
13
+ import { renderMath as b } from "@pie-element/shared-math-rendering-mathjax";
14
+ import { autoplayAudioOn as x, promptAudioPending as S, trackPromptAudioFailure as C } from "@pie-element/shared-utils";
15
15
  //#region src/delivery/index.ts
16
- function C(e) {
16
+ function w(e) {
17
17
  return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
18
18
  }
19
- function w(e, t) {
20
- return !e || C(e) ? e : C(e.default) ? e.default : t && C(e[t]) ? e[t] : t && C(e[t]?.default) ? e[t].default : e;
19
+ function T(e, t) {
20
+ return !e || w(e) ? e : w(e.default) ? e.default : t && w(e[t]) ? e[t] : t && w(e[t]?.default) ? e[t].default : e;
21
21
  }
22
- var T = o, E = T.default, D = E && typeof E == "object" ? E : T, O = w(s, "EnableAudioAutoplayImage") || w(D.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), k = m("pie-ui:multiple-choice"), A = (e, n, r, i) => {
22
+ var E = o, D = E.default, O = D && typeof D == "object" ? D : E, k = T(s, "EnableAudioAutoplayImage") || T(O.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), A = h("pie-ui:multiple-choice"), j = (e, n, r, i) => {
23
23
  let { completeAudioEnabled: a } = n || {};
24
- if (a && x(i, e, r) || !e || !e.value) return !1;
24
+ if (a && S(i, e, r) || !e || !e.value) return !1;
25
25
  let { choiceMode: o, minSelections: s = 1, maxSelections: c } = n || {}, l = e.value.length || 0;
26
26
  return o === "radio" ? !!l : !(l < s || t(l, c));
27
27
  };
28
- function j(e) {
28
+ function M(e) {
29
29
  let t = e.closest("pie-player") || e.closest("pie-item-player");
30
30
  if (!t) return {
31
31
  baseHeadingLevel: void 0,
@@ -40,20 +40,21 @@ function j(e) {
40
40
  includeSrHeading: o == null || o !== !1 && o !== "false"
41
41
  };
42
42
  }
43
- function M(e) {
44
- let t = j(e);
43
+ function N(e) {
44
+ let t = M(e);
45
45
  return {
46
46
  baseHeadingLevel: e._baseHeadingLevel === void 0 ? t.baseHeadingLevel : e._baseHeadingLevel,
47
47
  includeSrHeading: e._includeSrHeading === void 0 ? t.includeSrHeading : e._includeSrHeading
48
48
  };
49
49
  }
50
- var N = class extends HTMLElement {
50
+ var P = class extends HTMLElement {
51
51
  static pieSupports = Object.freeze(["answer-masking"]);
52
52
  constructor() {
53
- super(), this._model = null, this._session = null, this._eliminatedChoices = /* @__PURE__ */ new Set(), this._options = null, this.audioComplete = !1, this._boundHandleKeyDown = this.handleKeyDown.bind(this), this._keyboardEventsEnabled = !1, this._audioInitialized = !1, this._root = null, this._mathObserver = null, this._mathRenderPending = !1, this._rerender = p(() => {
53
+ super(), this._model = null, this._session = null, this._eliminatedChoices = /* @__PURE__ */ new Set(), this._options = null, this.audioComplete = !1, this._boundHandleKeyDown = this.handleKeyDown.bind(this), this._keyboardEventsEnabled = !1, this._audioInitialized = !1, this._root = null, this._mathObserver = null, this._mathRenderPending = !1, this._interfaceLocale = null, this._disconnectInterfaceLocale = null, this._rerender = m(() => {
54
54
  if (this._model && this._session) {
55
- if (!l(this._model.language)) {
56
- u(this._model.language).then(() => this._rerender());
55
+ let r = this._interfaceLocale ?? this._model.language;
56
+ if (!l(r)) {
57
+ u(r).then(() => this._rerender());
57
58
  return;
58
59
  }
59
60
  var t = a.createElement(n, {
@@ -63,18 +64,19 @@ var N = class extends HTMLElement {
63
64
  onChoiceChanged: this._onChange.bind(this),
64
65
  onShowCorrectToggle: this.onShowCorrectToggle.bind(this),
65
66
  eliminatedChoices: [...this._eliminatedChoices],
66
- ...M(this)
67
+ language: r,
68
+ ...N(this)
67
69
  });
68
- let r = e.forLocale(this._model.language);
69
- this.setAttribute("aria-label", r.t(this._model.choiceMode === "radio" ? "multipleChoiceQuestion" : "multipleCorrectAnswerQuestion")), this.setAttribute("role", "region"), d(this, this._model.language), this._initMathObserver(), this._root ||= f(this), this._root.render(t), this._model.keyboardEventsEnabled === !0 && !this._keyboardEventsEnabled && this.enableKeyboardEvents();
70
- } else k("skip");
70
+ let i = e.forLocale(r);
71
+ this.setAttribute("aria-label", i.t(this._model.choiceMode === "radio" ? "multipleChoiceQuestion" : "multipleCorrectAnswerQuestion")), this.setAttribute("role", "region"), d(this, this._model.language), this._initMathObserver(), this._root ||= p(this), this._root.render(t), this._model.keyboardEventsEnabled === !0 && !this._keyboardEventsEnabled && this.enableKeyboardEvents();
72
+ } else A("skip");
71
73
  }, 50, {
72
74
  leading: !1,
73
75
  trailing: !0
74
- }), this._sessionNotifier = _(this, () => {
75
- this.dispatchEvent(new g(this.tagName.toLowerCase(), A(this._session, this._model, this.audioComplete, this)));
76
- }), this._dispatchResponseChanged = () => this._sessionNotifier.notify(), this._dispatchModelSet = p(() => {
77
- this.dispatchEvent(new h(this.tagName.toLowerCase(), A(this._session, this._model, this.audioComplete, this), this._model !== void 0));
76
+ }), this._sessionNotifier = v(this, () => {
77
+ this.dispatchEvent(new _(this.tagName.toLowerCase(), j(this._session, this._model, this.audioComplete, this)));
78
+ }), this._dispatchResponseChanged = () => this._sessionNotifier.notify(), this._dispatchModelSet = m(() => {
79
+ this.dispatchEvent(new g(this.tagName.toLowerCase(), j(this._session, this._model, this.audioComplete, this), this._model !== void 0));
78
80
  }, 50, {
79
81
  leading: !1,
80
82
  trailing: !0
@@ -82,7 +84,7 @@ var N = class extends HTMLElement {
82
84
  }
83
85
  _scheduleMathRender = () => {
84
86
  this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
85
- this._mathObserver && this._mathObserver.disconnect(), k("render complete - render math"), y(this), this._mathRenderPending = !1, setTimeout(() => {
87
+ this._mathObserver && this._mathObserver.disconnect(), A("render complete - render math"), b(this), this._mathRenderPending = !1, setTimeout(() => {
86
88
  this._mathObserver && this._mathObserver.observe(this, {
87
89
  childList: !0,
88
90
  subtree: !0
@@ -100,7 +102,7 @@ var N = class extends HTMLElement {
100
102
  this._mathObserver &&= (this._mathObserver.disconnect(), null);
101
103
  }
102
104
  onShowCorrectToggle() {
103
- y(this);
105
+ b(this);
104
106
  }
105
107
  set model(e) {
106
108
  this._model = e, this._rerender(), this._audioInitialized = !1, this._dispatchModelSet();
@@ -163,16 +165,18 @@ var N = class extends HTMLElement {
163
165
  cursor: "pointer"
164
166
  });
165
167
  let t = document.createElement("img");
166
- return t.src = O, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
168
+ return t.src = k, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
167
169
  }
168
170
  connectedCallback() {
169
- this._initMathObserver(), this._initPlayerObserver(), this._rerender(), new MutationObserver((e, t) => {
171
+ this._initMathObserver(), this._initPlayerObserver(), this._disconnectInterfaceLocale ||= f(this, (e) => {
172
+ e?.locale && e.locale !== this._interfaceLocale && (this._interfaceLocale = e.locale, this._rerender());
173
+ }), this._rerender(), new MutationObserver((e, t) => {
170
174
  e.forEach((e) => {
171
175
  if (e.type === "childList") {
172
176
  if (this._audioInitialized) return;
173
177
  let e = this.querySelector("audio"), n = e && e.closest(".preview-prompt");
174
178
  if (!this._model) return;
175
- let { completeAudioEnabled: i } = this._model, a = b(this._model);
179
+ let { completeAudioEnabled: i } = this._model, a = x(this._model);
176
180
  if (!a && !i || e && !n || !e) return;
177
181
  let o = this._createAudioInfoToast(), s = this.querySelector(".main-container"), c = () => {
178
182
  this.querySelector(".play-audio-info") && (e.play(), s.removeChild(o)), document.removeEventListener("click", c);
@@ -189,7 +193,7 @@ var N = class extends HTMLElement {
189
193
  let u = () => {
190
194
  r(this._session, { audioEndTime: (/* @__PURE__ */ new Date()).getTime() }), this.audioComplete = !0, this._dispatchResponseChanged(), e.removeEventListener("ended", u);
191
195
  };
192
- e.addEventListener("ended", u), this._stopTrackingAudioFailure = S(e, () => this._dispatchResponseChanged()), this._audio = e, this._handlePlaying = l, this._handleEnded = u, this._enableAudio = c, this._audioInitialized = !0, t.disconnect();
196
+ e.addEventListener("ended", u), this._stopTrackingAudioFailure = C(e, () => this._dispatchResponseChanged()), this._audio = e, this._handlePlaying = l, this._handleEnded = u, this._enableAudio = c, this._audioInitialized = !0, t.disconnect();
193
197
  }
194
198
  });
195
199
  }).observe(this, {
@@ -218,7 +222,7 @@ var N = class extends HTMLElement {
218
222
  this._playerObserver &&= (this._playerObserver.disconnect(), null);
219
223
  }
220
224
  disconnectedCallback() {
221
- v(this), this._disconnectMathObserver(), this._disconnectPlayerObserver(), this._keyboardEventsEnabled &&= (window.removeEventListener("keydown", this._boundHandleKeyDown), !1), document.removeEventListener("click", this._enableAudio), this._audio &&= (this._audio.removeEventListener("playing", this._handlePlaying), this._audio.removeEventListener("ended", this._handleEnded), this._stopTrackingAudioFailure?.(), null), this._rerender.cancel(), this._root &&= (this._root.unmount(), null);
225
+ y(this), this._disconnectInterfaceLocale?.(), this._disconnectInterfaceLocale = null, this._disconnectMathObserver(), this._disconnectPlayerObserver(), this._keyboardEventsEnabled &&= (window.removeEventListener("keydown", this._boundHandleKeyDown), !1), document.removeEventListener("click", this._enableAudio), this._audio &&= (this._audio.removeEventListener("playing", this._handlePlaying), this._audio.removeEventListener("ended", this._handleEnded), this._stopTrackingAudioFailure?.(), null), this._rerender.cancel(), this._root &&= (this._root.unmount(), null);
222
226
  }
223
227
  handleKeyDown(e) {
224
228
  if (!this._model || !this._session) return;
@@ -238,4 +242,4 @@ var N = class extends HTMLElement {
238
242
  }
239
243
  };
240
244
  //#endregion
241
- export { N as default, A as isComplete };
245
+ export { P as default, j as isComplete };