@pie-element/ebsr 14.2.2-next.1 → 14.2.2-next.3

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,18 +1,19 @@
1
- import e from "./main.js";
2
- import t from "./defaults.js";
3
- import { defaults as n } from "@pie-element/shared-lodash";
4
- import r from "react";
5
- import { createRoot as i } from "react-dom/client";
6
- import { ModelUpdatedEvent as a } from "@pie-element/shared-configure-events";
7
- import o from "@pie-element/multiple-choice/author";
1
+ import { EBSR_MULTIPLE_CHOICE_CONFIGURE_TAG as e } from "../private-tags.js";
2
+ import t from "./main.js";
3
+ import n from "./defaults.js";
4
+ import { defaults as r } from "@pie-element/shared-lodash";
5
+ import i from "react";
6
+ import { createRoot as a } from "react-dom/client";
7
+ import { ModelUpdatedEvent as o } from "@pie-element/shared-configure-events";
8
+ import s from "@pie-element/multiple-choice/author";
8
9
  //#region src/author/index.ts
9
- var s = a.TYPE, c = "ebsr-multiple-choice-configure", l = class extends o {};
10
- customElements.get(c) || customElements.define(c, l);
11
- var u = (e, r) => ({
12
- configuration: n(e, t.configuration),
13
- model: r
14
- }), { model: d } = t || {}, f = class n extends HTMLElement {
15
- static createDefaultModel = ({ partA: e = {}, partB: t = {}, ...n } = {}, r = d) => ({
10
+ var c = o.TYPE, l = e, u = class extends s {};
11
+ customElements.get(l) || customElements.define(l, u);
12
+ var d = (e, t) => ({
13
+ configuration: r(e, n.configuration),
14
+ model: t
15
+ }), { model: f } = n || {}, p = class e extends HTMLElement {
16
+ static createDefaultModel = ({ partA: e = {}, partB: t = {}, ...n } = {}, r = f) => ({
16
17
  ...r,
17
18
  ...n,
18
19
  partA: {
@@ -27,22 +28,22 @@ var u = (e, r) => ({
27
28
  }
28
29
  });
29
30
  constructor() {
30
- super(), this._root = null, this._model = n.createDefaultModel(), this._configuration = t.configuration, this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
31
+ super(), this._root = null, this._model = e.createDefaultModel(), this._configuration = n.configuration, this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
31
32
  }
32
- set model(e) {
33
- this._model = n.createDefaultModel(e, this._model), this._render();
33
+ set model(t) {
34
+ this._model = e.createDefaultModel(t, this._model), this._render();
34
35
  }
35
36
  dispatchModelUpdated(e) {
36
37
  let t = !!e;
37
- this.dispatchEvent(new a(this._model, t));
38
+ this.dispatchEvent(new o(this._model, t));
38
39
  }
39
- onModelChanged = (e, t) => {
40
- this._model = n.createDefaultModel(e, this._model), this.dispatchModelUpdated(t), this._render();
40
+ onModelChanged = (t, n) => {
41
+ this._model = e.createDefaultModel(t, this._model), this.dispatchModelUpdated(n), this._render();
41
42
  };
42
43
  set configuration(e) {
43
- let n = u(e, this._model), r = {
44
- ...t.configuration,
45
- ...n.configuration
44
+ let t = d(e, this._model), r = {
45
+ ...n.configuration,
46
+ ...t.configuration
46
47
  };
47
48
  this._configuration = r, r?.language?.enabled ? r?.languageChoices?.options?.length && (this._model.language = r?.languageChoices.options[0].value) : r.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
48
49
  value: this._model.language,
@@ -50,29 +51,30 @@ var u = (e, r) => ({
50
51
  })) : delete this._model.language, this._render();
51
52
  }
52
53
  onConfigurationChanged(e) {
53
- this._configuration = u(e, this._model).configuration, this._model && this.onModelChanged(this._model), this._render();
54
+ this._configuration = d(e, this._model).configuration, this._model && this.onModelChanged(this._model), this._render();
54
55
  }
55
56
  onModelUpdated = (e) => {
56
57
  if (e.target === this) return;
57
58
  e.preventDefault(), e.stopImmediatePropagation();
58
59
  let t = e.target && e.target.getAttribute("id");
59
- t && (e.update && (this._model[`part${t}`] = e.update), this.dispatchEvent(new a(this._model)));
60
+ t && (e.update && (this._model[`part${t}`] = e.update), this.dispatchEvent(new o(this._model)));
60
61
  };
61
62
  connectedCallback() {
62
- this.addEventListener(s, this.onModelUpdated), this._render();
63
+ this.addEventListener(c, this.onModelUpdated), this._render();
63
64
  }
64
65
  _render() {
65
- let t = r.createElement(e, {
66
+ let e = i.createElement(t, {
66
67
  model: this._model,
67
68
  configuration: this._configuration,
69
+ multipleChoiceTagName: l,
68
70
  onModelChanged: this.onModelChanged,
69
71
  onConfigurationChanged: this.onConfigurationChanged
70
72
  });
71
- this._root ||= i(this), this._root.render(t);
73
+ this._root ||= a(this), this._root.render(e);
72
74
  }
73
75
  disconnectedCallback() {
74
- this.removeEventListener(s, this.onModelUpdated), this._root && this._root.unmount();
76
+ this.removeEventListener(c, this.onModelUpdated), this._root && this._root.unmount();
75
77
  }
76
78
  };
77
79
  //#endregion
78
- export { f as default };
80
+ export { p as default };
@@ -12,6 +12,7 @@ export declare class Main extends React.Component {
12
12
  static propTypes: {
13
13
  configuration: PropTypes.Requireable<object>;
14
14
  model: PropTypes.Requireable<object>;
15
+ multipleChoiceTagName: PropTypes.Requireable<string>;
15
16
  onModelChanged: PropTypes.Requireable<(...args: any[]) => any>;
16
17
  onConfigurationChanged: PropTypes.Requireable<(...args: any[]) => any>;
17
18
  };
@@ -1,18 +1,20 @@
1
- import e from "react";
2
- import t from "prop-types";
3
- import { layout as n, settings as r } from "@pie-lib/config-ui";
4
- import { styled as i } from "@mui/material/styles";
5
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
1
+ import { EBSR_MULTIPLE_CHOICE_CONFIGURE_TAG as e } from "../private-tags.js";
2
+ import t from "react";
3
+ import n from "prop-types";
4
+ import { layout as r, settings as i } from "@pie-lib/config-ui";
5
+ import { styled as a } from "@mui/material/styles";
6
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
7
  //#region src/author/main.tsx
7
- var { Panel: s, toggle: c, radio: l, dropdown: u } = r, d = i("div")(({ theme: e }) => ({ paddingBottom: e.spacing(2) })), f = i("div")(({ theme: e }) => ({
8
+ var { Panel: c, toggle: l, radio: u, dropdown: d } = i, f = a("div")(({ theme: e }) => ({ paddingBottom: e.spacing(2) })), p = a("div")(({ theme: e }) => ({
8
9
  flex: 1,
9
10
  height: e.spacing(2.5)
10
- })), p = class extends e.Component {
11
+ })), m = class extends t.Component {
11
12
  static propTypes = {
12
- configuration: t.object,
13
- model: t.object,
14
- onModelChanged: t.func,
15
- onConfigurationChanged: t.func
13
+ configuration: n.object,
14
+ model: n.object,
15
+ multipleChoiceTagName: n.string,
16
+ onModelChanged: n.func,
17
+ onConfigurationChanged: n.func
16
18
  };
17
19
  removeExtraChoices = (e) => {
18
20
  let t = !1;
@@ -23,93 +25,93 @@ var { Panel: s, toggle: c, radio: l, dropdown: u } = r, d = i("div")(({ theme: e
23
25
  return t === "partA.choiceMode" && e.partA.choiceMode === "radio" ? (e.partA.choices = this.removeExtraChoices(e.partA.choices), n(e, !0)) : t === "partB.choiceMode" && e.partB.choiceMode === "radio" ? (e.partB.choices = this.removeExtraChoices(e.partB.choices), n(e, !0)) : n(e);
24
26
  };
25
27
  render() {
26
- let { model: e, configuration: t, onConfigurationChanged: r } = this.props, { partLabelType: i, partA: p, partB: m, extraCSSRules: h } = e, { contentDimensions: g = {}, partA: _ = {}, partB: v = {}, partialScoring: y = {}, settingsPanelDisabled: b, scoringType: x = {}, language: S = {}, languageChoices: C = {}, ...w } = t, { feedback: T = {}, choiceMode: E = {}, choicePrefix: D = {}, lockChoiceOrder: O = {}, prompt: k = {}, teacherInstructions: A = {}, studentInstructions: j = {}, choicesLayout: M = {}, gridColumns: N = {}, rationale: P = {}, spellCheck: F = {} } = _ || {}, { feedback: I = {}, choiceMode: L = {}, choicePrefix: R = {}, lockChoiceOrder: z = {}, prompt: B = {}, teacherInstructions: V = {}, studentInstructions: H = {}, choicesLayout: U = {}, gridColumns: W = {}, rationale: G = {}, spellCheck: K = {} } = v || {}, q = (i || "Numbers") === "Numbers", J = `Part ${q ? "1" : "A"}`, Y = `Part ${q ? "2" : "B"}`, X = {
27
- partA: p.choices && p.choices.length ? Array.from({ length: p.choices.length }, (e, t) => `${t + 1}`) : [],
28
- partB: m.choices && m.choices.length ? Array.from({ length: m.choices.length }, (e, t) => `${t + 1}`) : []
29
- }, Z = {
30
- partLabels: w.partLabels.settings && c(w.partLabels.label),
31
- partLabelType: e.partLabels && u("", ["Numbers", "Letters"]),
32
- partialScoring: y.settings && c(y.label),
33
- scoringType: x.settings && l(x.label, ["auto", "rubric"]),
34
- "language.enabled": S.settings && c(S.label, !0),
35
- language: S.settings && S.enabled && u(C.label, C.options)
36
- }, Q = {
37
- "partA.choiceMode": E.settings && l(E.label, ["checkbox", "radio"]),
38
- "partA.choicePrefix": D.settings && l(D.label, ["numbers", "letters"]),
39
- "partA.lockChoiceOrder": O.settings && c(O.label),
40
- "partA.choicesLayout": M.settings && u(M.label, [
28
+ let { model: t, configuration: n, multipleChoiceTagName: i = e, onConfigurationChanged: a } = this.props, m = i, { partLabelType: h, partA: g, partB: _, extraCSSRules: v } = t, { contentDimensions: ee = {}, partA: y = {}, partB: b = {}, partialScoring: x = {}, settingsPanelDisabled: S, scoringType: C = {}, language: w = {}, languageChoices: T = {}, ...E } = n, { feedback: D = {}, choiceMode: O = {}, choicePrefix: k = {}, lockChoiceOrder: A = {}, prompt: j = {}, teacherInstructions: M = {}, studentInstructions: N = {}, choicesLayout: P = {}, gridColumns: F = {}, rationale: I = {}, spellCheck: L = {} } = y || {}, { feedback: R = {}, choiceMode: z = {}, choicePrefix: B = {}, lockChoiceOrder: V = {}, prompt: H = {}, teacherInstructions: U = {}, studentInstructions: W = {}, choicesLayout: G = {}, gridColumns: K = {}, rationale: q = {}, spellCheck: J = {} } = b || {}, Y = (h || "Numbers") === "Numbers", X = `Part ${Y ? "1" : "A"}`, Z = `Part ${Y ? "2" : "B"}`, Q = {
29
+ partA: g.choices && g.choices.length ? Array.from({ length: g.choices.length }, (e, t) => `${t + 1}`) : [],
30
+ partB: _.choices && _.choices.length ? Array.from({ length: _.choices.length }, (e, t) => `${t + 1}`) : []
31
+ }, $ = {
32
+ partLabels: E.partLabels.settings && l(E.partLabels.label),
33
+ partLabelType: t.partLabels && d("", ["Numbers", "Letters"]),
34
+ partialScoring: x.settings && l(x.label),
35
+ scoringType: C.settings && u(C.label, ["auto", "rubric"]),
36
+ "language.enabled": w.settings && l(w.label, !0),
37
+ language: w.settings && w.enabled && d(T.label, T.options)
38
+ }, te = {
39
+ "partA.choiceMode": O.settings && u(O.label, ["checkbox", "radio"]),
40
+ "partA.choicePrefix": k.settings && u(k.label, ["numbers", "letters"]),
41
+ "partA.lockChoiceOrder": A.settings && l(A.label),
42
+ "partA.choicesLayout": P.settings && d(P.label, [
41
43
  "vertical",
42
44
  "grid",
43
45
  "horizontal"
44
46
  ]),
45
- "partA.gridColumns": M.settings && p.choicesLayout === "grid" && X.partA.length > 0 && u(N.label, X.partA)
46
- }, $ = {
47
- "partA.feedbackEnabled": T.settings && c(T.label),
48
- "partA.promptEnabled": k.settings && c(k.label),
49
- "partA.teacherInstructionsEnabled": A.settings && c(A.label),
50
- "partA.studentInstructionsEnabled": j.settings && c(j.label),
51
- "partA.rationaleEnabled": P.settings && c(P.label),
52
- "partA.spellCheckEnabled": F.settings && c(F.label)
53
- }, ee = {
54
- "partB.choiceMode": L.settings && l(L.label, ["checkbox", "radio"]),
55
- "partB.choicePrefix": R.settings && l(R.label, ["numbers", "letters"]),
56
- "partB.lockChoiceOrder": z.settings && c(z.label),
57
- "partB.choicesLayout": U.settings && u(U.label, [
47
+ "partA.gridColumns": P.settings && g.choicesLayout === "grid" && Q.partA.length > 0 && d(F.label, Q.partA)
48
+ }, ne = {
49
+ "partA.feedbackEnabled": D.settings && l(D.label),
50
+ "partA.promptEnabled": j.settings && l(j.label),
51
+ "partA.teacherInstructionsEnabled": M.settings && l(M.label),
52
+ "partA.studentInstructionsEnabled": N.settings && l(N.label),
53
+ "partA.rationaleEnabled": I.settings && l(I.label),
54
+ "partA.spellCheckEnabled": L.settings && l(L.label)
55
+ }, re = {
56
+ "partB.choiceMode": z.settings && u(z.label, ["checkbox", "radio"]),
57
+ "partB.choicePrefix": B.settings && u(B.label, ["numbers", "letters"]),
58
+ "partB.lockChoiceOrder": V.settings && l(V.label),
59
+ "partB.choicesLayout": G.settings && d(G.label, [
58
60
  "vertical",
59
61
  "grid",
60
62
  "horizontal"
61
63
  ]),
62
- "partB.gridColumns": U.settings && m.choicesLayout === "grid" && X.partB.length > 0 && u(W.label, X.partB)
63
- }, te = {
64
- "partB.feedbackEnabled": I.settings && c(I.label),
65
- "partB.promptEnabled": B.settings && c(B.label),
66
- "partB.teacherInstructionsEnabled": V.settings && c(V.label),
67
- "partB.studentInstructionsEnabled": H.settings && c(H.label),
68
- "partB.rationaleEnabled": G.settings && c(G.label),
69
- "partB.spellCheckEnabled": K.settings && c(K.label)
64
+ "partB.gridColumns": G.settings && _.choicesLayout === "grid" && Q.partB.length > 0 && d(K.label, Q.partB)
65
+ }, ie = {
66
+ "partB.feedbackEnabled": R.settings && l(R.label),
67
+ "partB.promptEnabled": H.settings && l(H.label),
68
+ "partB.teacherInstructionsEnabled": U.settings && l(U.label),
69
+ "partB.studentInstructionsEnabled": W.settings && l(W.label),
70
+ "partB.rationaleEnabled": q.settings && l(q.label),
71
+ "partB.spellCheckEnabled": J.settings && l(J.label)
70
72
  };
71
- return /* @__PURE__ */ o(n.ConfigLayout, {
72
- extraCSSRules: h,
73
- dimensions: g,
74
- hideSettings: b,
75
- settings: /* @__PURE__ */ a(s, {
76
- model: e,
73
+ return /* @__PURE__ */ s(r.ConfigLayout, {
74
+ extraCSSRules: v,
75
+ dimensions: ee,
76
+ hideSettings: S,
77
+ settings: /* @__PURE__ */ o(c, {
78
+ model: t,
77
79
  onChangeModel: this.onModelChanged,
78
- configuration: t,
79
- onChangeConfiguration: r,
80
+ configuration: n,
81
+ onChangeConfiguration: a,
80
82
  groups: {
81
- "Settings for both": Z,
82
- [`Settings ${J}`]: Q,
83
- [`Properties ${J}`]: $,
84
- [`Settings ${Y}`]: ee,
85
- [`Properties ${Y}`]: te
83
+ "Settings for both": $,
84
+ [`Settings ${X}`]: te,
85
+ [`Properties ${X}`]: ne,
86
+ [`Settings ${Z}`]: re,
87
+ [`Properties ${Z}`]: ie
86
88
  }
87
89
  }),
88
90
  children: [
89
- e.partLabels && /* @__PURE__ */ a(d, { children: J }),
90
- /* @__PURE__ */ a("ebsr-multiple-choice-configure", {
91
+ t.partLabels && /* @__PURE__ */ o(f, { children: X }),
92
+ /* @__PURE__ */ o(m, {
91
93
  id: "A",
92
94
  ref: (e) => {
93
95
  e && (this.partA = e, this.partA._model = {
94
96
  ...this.props.model.partA,
95
97
  errors: this.props.model.errors && this.props.model.errors.partA || {}
96
98
  }, this.partA.configuration = {
97
- ..._,
98
- ...w
99
+ ...y,
100
+ ...E
99
101
  });
100
102
  }
101
103
  }, "partA"),
102
- /* @__PURE__ */ a(f, {}),
103
- e.partLabels && /* @__PURE__ */ a(d, { children: Y }),
104
- /* @__PURE__ */ a("ebsr-multiple-choice-configure", {
104
+ /* @__PURE__ */ o(p, {}),
105
+ t.partLabels && /* @__PURE__ */ o(f, { children: Z }),
106
+ /* @__PURE__ */ o(m, {
105
107
  id: "B",
106
108
  ref: (e) => {
107
109
  e && (this.partB = e, this.partB._model = {
108
110
  ...this.props.model.partB,
109
111
  errors: this.props.model.errors && this.props.model.errors.partB || {}
110
112
  }, this.partB.configuration = {
111
- ...v,
112
- ...w
113
+ ...b,
114
+ ...E
113
115
  });
114
116
  }
115
117
  }, "partB")
@@ -118,4 +120,4 @@ var { Panel: s, toggle: c, radio: l, dropdown: u } = r, d = i("div")(({ theme: e
118
120
  }
119
121
  };
120
122
  //#endregion
121
- export { p as default };
123
+ export { m as default };