@pie-element/multiple-choice 13.3.5-next.6 → 13.3.5-next.8

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.
@@ -1,5 +1,5 @@
1
- import { F as e, M as t, Vt as n } from "../Radio-xWBQ-YBe.js";
2
- import { t as r } from "../main-wyY_k9tD.js";
1
+ import { F as e, M as t, Vt as n } from "../Radio-B-Cd30zs.js";
2
+ import { t as r } from "../main-CSCv3-uB.js";
3
3
  import { c as i, l as a } from "../dist-CHbLnyuX.js";
4
4
  import o from "react";
5
5
  import { createRoot as s } from "react-dom/client";
@@ -7,16 +7,16 @@ import { EnableAudioAutoplayImage as o } from "@pie-lib/render-ui";
7
7
  import { createRoot as s } from "react-dom/client";
8
8
  import { debounce as c } from "@pie-element/shared-lodash";
9
9
  import l from "debug";
10
- import { ModelSetEvent as u, SessionChangedEvent as d } from "@pie-element/shared-player-events";
11
- import { renderMath as f } from "@pie-element/shared-math-rendering-mathjax";
10
+ import { ModelSetEvent as u, SessionChangedEvent as d, createSessionNotifier as f, flushSessionNotifiers as p } from "@pie-element/shared-player-events";
11
+ import { renderMath as m } from "@pie-element/shared-math-rendering-mathjax";
12
12
  //#region src/delivery/index.ts
13
- function p(e) {
13
+ function h(e) {
14
14
  return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
15
15
  }
16
- function m(e, t) {
17
- return !e || p(e) ? e : p(e.default) ? e.default : t && p(e[t]) ? e[t] : t && p(e[t]?.default) ? e[t].default : e;
16
+ function g(e, t) {
17
+ return !e || h(e) ? e : h(e.default) ? e.default : t && h(e[t]) ? e[t] : t && h(e[t]?.default) ? e[t].default : e;
18
18
  }
19
- var h = m(o, "EnableAudioAutoplayImage") || m(v.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), g = a, _ = g.default, v = _ && typeof _ == "object" ? _ : g, y = l("pie-ui:multiple-choice"), b = (t, n, r, i) => {
19
+ var _ = g(o, "EnableAudioAutoplayImage") || g(b.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), v = a, y = v.default, b = y && typeof y == "object" ? y : v, x = l("pie-ui:multiple-choice"), S = (t, n, r, i) => {
20
20
  let { autoplayAudioEnabled: a, completeAudioEnabled: o } = n || {};
21
21
  if (a && o && !r && i) {
22
22
  let e = i.querySelector("audio"), t = e && e.closest(".preview-prompt");
@@ -26,7 +26,7 @@ var h = m(o, "EnableAudioAutoplayImage") || m(v.EnableAudioAutoplayImage, "Enabl
26
26
  let { choiceMode: s, minSelections: c = 1, maxSelections: l } = n || {}, u = t.value.length || 0;
27
27
  return s === "radio" ? !!u : !(u < c || e(u, l));
28
28
  };
29
- function x(e) {
29
+ function C(e) {
30
30
  let t = e.closest("pie-player") || e.closest("pie-item-player");
31
31
  if (!t) return {
32
32
  baseHeadingLevel: void 0,
@@ -41,14 +41,14 @@ function x(e) {
41
41
  includeSrHeading: o == null || o !== !1 && o !== "false"
42
42
  };
43
43
  }
44
- function S(e) {
45
- let t = x(e);
44
+ function w(e) {
45
+ let t = C(e);
46
46
  return {
47
47
  baseHeadingLevel: e._baseHeadingLevel === void 0 ? t.baseHeadingLevel : e._baseHeadingLevel,
48
48
  includeSrHeading: e._includeSrHeading === void 0 ? t.includeSrHeading : e._includeSrHeading
49
49
  };
50
50
  }
51
- var C = class extends HTMLElement {
51
+ var T = class extends HTMLElement {
52
52
  constructor() {
53
53
  super(), this._model = null, this._session = null, 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 = c(() => {
54
54
  if (this._model && this._session) {
@@ -58,17 +58,17 @@ var C = class extends HTMLElement {
58
58
  options: this._options,
59
59
  onChoiceChanged: this._onChange.bind(this),
60
60
  onShowCorrectToggle: this.onShowCorrectToggle.bind(this),
61
- ...S(this)
61
+ ...w(this)
62
62
  });
63
63
  this.setAttribute("aria-label", this._model.choiceMode === "radio" ? "Multiple Choice Question" : "Multiple Correct Answer Question"), this.setAttribute("role", "region"), this.setLangAttribute(), this._initMathObserver(), this._root ||= s(this), this._root.render(e), this._model.keyboardEventsEnabled === !0 && !this._keyboardEventsEnabled && this.enableKeyboardEvents();
64
- } else y("skip");
64
+ } else x("skip");
65
65
  }, 50, {
66
66
  leading: !1,
67
67
  trailing: !0
68
- }), this._dispatchResponseChanged = c(() => {
69
- this.dispatchEvent(new d(this.tagName.toLowerCase(), b(this._session, this._model, this.audioComplete, this)));
70
- }), this._dispatchModelSet = c(() => {
71
- this.dispatchEvent(new u(this.tagName.toLowerCase(), b(this._session, this._model, this.audioComplete, this), this._model !== void 0));
68
+ }), this._sessionNotifier = f(this, () => {
69
+ this.dispatchEvent(new d(this.tagName.toLowerCase(), S(this._session, this._model, this.audioComplete, this)));
70
+ }), this._dispatchResponseChanged = () => this._sessionNotifier.notify(), this._dispatchModelSet = c(() => {
71
+ this.dispatchEvent(new u(this.tagName.toLowerCase(), S(this._session, this._model, this.audioComplete, this), this._model !== void 0));
72
72
  }, 50, {
73
73
  leading: !1,
74
74
  trailing: !0
@@ -76,7 +76,7 @@ var C = class extends HTMLElement {
76
76
  }
77
77
  _scheduleMathRender = () => {
78
78
  this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
79
- this._mathObserver && this._mathObserver.disconnect(), y("render complete - render math"), f(this), this._mathRenderPending = !1, setTimeout(() => {
79
+ this._mathObserver && this._mathObserver.disconnect(), x("render complete - render math"), m(this), this._mathRenderPending = !1, setTimeout(() => {
80
80
  this._mathObserver && this._mathObserver.observe(this, {
81
81
  childList: !0,
82
82
  subtree: !0
@@ -94,7 +94,7 @@ var C = class extends HTMLElement {
94
94
  this._mathObserver &&= (this._mathObserver.disconnect(), null);
95
95
  }
96
96
  onShowCorrectToggle() {
97
- f(this);
97
+ m(this);
98
98
  }
99
99
  setLangAttribute() {
100
100
  let e = this._model && typeof this._model.language ? this._model.language : "", t = e ? e.slice(0, 2) : "en";
@@ -139,7 +139,7 @@ var C = class extends HTMLElement {
139
139
  cursor: "pointer"
140
140
  });
141
141
  let t = document.createElement("img");
142
- return t.src = h, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
142
+ return t.src = _, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
143
143
  }
144
144
  connectedCallback() {
145
145
  this._initMathObserver(), this._initPlayerObserver(), this._rerender(), new MutationObserver((e, t) => {
@@ -192,7 +192,7 @@ var C = class extends HTMLElement {
192
192
  this._playerObserver &&= (this._playerObserver.disconnect(), null);
193
193
  }
194
194
  disconnectedCallback() {
195
- 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), null), this._root &&= (this._root.unmount(), null);
195
+ p(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), null), this._root &&= (this._root.unmount(), null);
196
196
  }
197
197
  handleKeyDown(e) {
198
198
  if (!this._model || !this._session) return;
@@ -212,4 +212,4 @@ var C = class extends HTMLElement {
212
212
  }
213
213
  };
214
214
  //#endregion
215
- export { C as default, b as isComplete };
215
+ export { T as default, S as isComplete };