@pie-element/select-text 13.1.2-next.5 → 13.1.2-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.
@@ -1,6 +1,6 @@
1
- import { b as e, c as t, g as n } from "../dist-NxgaOEGc.js";
2
- import { w as r } from "../Check-hYJSLKBP.js";
3
- import { t as i } from "../main-nEorTqht.js";
1
+ import { b as e, c as t, g as n } from "../dist-BamN0-DG.js";
2
+ import { C as r } from "../Check-CmcAwXkY.js";
3
+ import { t as i } from "../main-DFPODQm1.js";
4
4
  import a from "react";
5
5
  import { createRoot as o } from "react-dom/client";
6
6
  var s = (0, (/* @__PURE__ */ e(n(), 1)).default)("pie-element:select-text:print"), c = (e, t) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/print/index.tsx"],"sourcesContent":["// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/select-text/src/print.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\n\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from '@pie-element/shared-lodash';\nimport Main from '../delivery/main.js';\nimport { renderMath } from '@pie-element/shared-math-rendering-mathjax';\nimport debug from 'debug';\n\nconst log = debug('pie-element:select-text:print');\n\n/**\n * Live in same package as main element - so we can access some of the shared comps!\n *\n * - update pslb to build print if src/print.js is there\n * - update demo el\n * - get configure/controller building\n */\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.rationale = instr && model.rationaleEnabled !== false ? model.rationale : undefined;\n model.showTeacherInstructions = instr;\n model.alwaysShowCorrect = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n model.disabled = true;\n model.animationsDisabled = true;\n model.highlightChoices = true;\n model.feedback = undefined;\n\n return model;\n};\n\nexport default class SelectTextPrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = {};\n this._session.selectedTokens = [];\n this._root = null;\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: { selectedTokens: [] },\n onSelectionChange: () => {},\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n queueMicrotask(() => {\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 set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;AAiBA,IAAM,KAAA,IAAA,wBAAA,GAAA,SAAY,+BAA+B,GAU3C,KAAqB,GAAO,MAAS;CACzC,IAAM,IAAQ,EAAK,SAAS;CAe5B,OAbA,EAAM,SAAS,EAAM,kBAAkB,KAAuB,KAAA,IAAf,EAAM,QACrD,EAAM,sBACJ,KAAS,EAAM,+BAA+B,KAAQ,EAAM,sBAAsB,KAAA,GACpF,EAAM,YAAY,KAAS,EAAM,qBAAqB,KAAQ,EAAM,YAAY,KAAA,GAChF,EAAM,0BAA0B,GAChC,EAAM,oBAAoB,GAC1B,EAAM,OAAO,IAAQ,aAAa,EAAM,MAExC,EAAM,WAAW,IACjB,EAAM,qBAAqB,IAC3B,EAAM,mBAAmB,IACzB,EAAM,WAAW,KAAA,GAEV;AACT,GAEqB,IAArB,cAA6C,YAAY;CACvD,cAAc;EAOZ,AANA,MAAM,GACN,KAAK,WAAW,MAChB,KAAK,SAAS,MACd,KAAK,WAAW,CAAC,GACjB,KAAK,SAAS,iBAAiB,CAAC,GAChC,KAAK,QAAQ,MACb,KAAK,YAAY,QACT;GACJ,IAAI,KAAK,UAAU,KAAK,UAAU;IAChC,IAAM,IAAa,EAAkB,KAAK,QAAQ,KAAK,QAAQ,GAEzD,IACJ,KAAK,YACL,EAAM,cAAc,GAAM;KACxB,OAAO;KACP,SAAS,EAAE,gBAAgB,CAAC,EAAE;KAC9B,yBAAyB,CAAC;IAC5B,CAAC;IAMH,AAJA,AACE,KAAK,UAAQ,EAAW,IAAI,GAE9B,KAAK,MAAM,OAAO,CAAO,GACzB,qBAAqB;KAEnB,AADA,EAAI,+BAA+B,GACnC,EAAW,IAAI;IACjB,CAAC;GACH,OACE,EAAI,MAAM;EAEd,GACA,IACA;GAAE,SAAS;GAAO,UAAU;EAAK,CACnC;CACF;CACA,IAAI,QAAQ,GAAG;EACb,KAAK,WAAW;CAClB;CAEA,IAAI,MAAM,GAAG;EAEX,AADA,KAAK,SAAS,GACd,KAAK,UAAU;CACjB;CAEA,oBAAoB,CAAC;CAErB,uBAAuB;EACrB,AAAI,KAAK,SACP,KAAK,MAAM,QAAQ;CAEvB;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/print/index.tsx"],"sourcesContent":["// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/select-text/src/print.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\n\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from '@pie-element/shared-lodash';\nimport Main from '../delivery/main.js';\nimport { renderMath } from '@pie-element/shared-math-rendering-mathjax';\nimport debug from 'debug';\n\nconst log = debug('pie-element:select-text:print');\n\n/**\n * Live in same package as main element - so we can access some of the shared comps!\n *\n * - update pslb to build print if src/print.js is there\n * - update demo el\n * - get configure/controller building\n */\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.rationale = instr && model.rationaleEnabled !== false ? model.rationale : undefined;\n model.showTeacherInstructions = instr;\n model.alwaysShowCorrect = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n model.disabled = true;\n model.animationsDisabled = true;\n model.highlightChoices = true;\n model.feedback = undefined;\n\n return model;\n};\n\nexport default class SelectTextPrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = {};\n this._session.selectedTokens = [];\n this._root = null;\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: { selectedTokens: [] },\n onSelectionChange: () => {},\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n queueMicrotask(() => {\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 set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;AAiBA,IAAM,KAAA,IAAA,wBAAA,EAAA,CAAA,QAAA,CAAY,+BAA+B,GAU3C,KAAqB,GAAO,MAAS;CACzC,IAAM,IAAQ,EAAK,SAAS;CAe5B,OAbA,EAAM,SAAS,EAAM,kBAAkB,KAAuB,KAAA,IAAf,EAAM,QACrD,EAAM,sBACJ,KAAS,EAAM,+BAA+B,KAAQ,EAAM,sBAAsB,KAAA,GACpF,EAAM,YAAY,KAAS,EAAM,qBAAqB,KAAQ,EAAM,YAAY,KAAA,GAChF,EAAM,0BAA0B,GAChC,EAAM,oBAAoB,GAC1B,EAAM,OAAO,IAAQ,aAAa,EAAM,MAExC,EAAM,WAAW,IACjB,EAAM,qBAAqB,IAC3B,EAAM,mBAAmB,IACzB,EAAM,WAAW,KAAA,GAEV;AACT,GAEqB,IAArB,cAA6C,YAAY;CACvD,cAAc;EAOZ,AANA,MAAM,GACN,KAAK,WAAW,MAChB,KAAK,SAAS,MACd,KAAK,WAAW,CAAC,GACjB,KAAK,SAAS,iBAAiB,CAAC,GAChC,KAAK,QAAQ,MACb,KAAK,YAAY,QACT;GACJ,IAAI,KAAK,UAAU,KAAK,UAAU;IAChC,IAAM,IAAa,EAAkB,KAAK,QAAQ,KAAK,QAAQ,GAEzD,IACJ,KAAK,YACL,EAAM,cAAc,GAAM;KACxB,OAAO;KACP,SAAS,EAAE,gBAAgB,CAAC,EAAE;KAC9B,yBAAyB,CAAC;IAC5B,CAAC;IAMH,AAJA,AACE,KAAK,UAAQ,EAAW,IAAI,GAE9B,KAAK,MAAM,OAAO,CAAO,GACzB,qBAAqB;KAEnB,AADA,EAAI,+BAA+B,GACnC,EAAW,IAAI;IACjB,CAAC;GACH,OACE,EAAI,MAAM;EAEd,GACA,IACA;GAAE,SAAS;GAAO,UAAU;EAAK,CACnC;CACF;CACA,IAAI,QAAQ,GAAG;EACb,KAAK,WAAW;CAClB;CAEA,IAAI,MAAM,GAAG;EAEX,AADA,KAAK,SAAS,GACd,KAAK,UAAU;CACjB;CAEA,oBAAoB,CAAC;CAErB,uBAAuB;EACrB,AAAI,KAAK,SACP,KAAK,MAAM,QAAQ;CAEvB;AACF"}
@@ -53,7 +53,7 @@ var s = class extends HTMLElement {
53
53
  }
54
54
  }
55
55
  disconnectedCallback() {
56
- this._root && this._root.unmount();
56
+ this._root &&= (this._root.unmount(), null);
57
57
  }
58
58
  };
59
59
  //#endregion
@@ -17,6 +17,8 @@ export declare class Main extends React.Component {
17
17
  static defaultProps: {};
18
18
  constructor(props: any);
19
19
  UNSAFE_componentWillReceiveProps(nextProps: any): void;
20
+ componentDidMount(): void;
21
+ componentDidUpdate(): void;
20
22
  toggleShowCorrect: any;
21
23
  correctAnswer: any;
22
24
  render(): React.JSX.Element;
@@ -1,36 +1,38 @@
1
1
  import e from "./utils.js";
2
2
  import t from "react";
3
- import n from "prop-types";
4
- import { Legend as r, TextSelect as i } from "@pie-lib/text-select";
5
- import a from "@pie-lib/correct-answer-toggle";
6
- import * as o from "@pie-lib/render-ui";
7
- import { Collapsible as s, Feedback as c, PreviewPrompt as l, UiLayout as u, color as d, hasMedia as f, hasText as p } from "@pie-lib/render-ui";
8
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
9
- import { styled as g } from "@mui/material/styles";
10
- import _ from "debug";
3
+ import n from "react-dom";
4
+ import r from "prop-types";
5
+ import { Legend as i, TextSelect as a } from "@pie-lib/text-select";
6
+ import o from "@pie-lib/correct-answer-toggle";
7
+ import * as s from "@pie-lib/render-ui";
8
+ import { Collapsible as c, Feedback as l, PreviewPrompt as u, UiLayout as d, color as f, hasMedia as p, hasText as m } from "@pie-lib/render-ui";
9
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
10
+ import { renderMath as _ } from "@pie-element/shared-math-rendering-mathjax";
11
+ import { styled as v } from "@mui/material/styles";
12
+ import y from "debug";
11
13
  //#region src/delivery/main.tsx
12
- function v(e) {
14
+ function b(e) {
13
15
  return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
14
16
  }
15
- function y(e, t) {
16
- return !e || v(e) ? e : v(e.default) ? e.default : t && v(e[t]) ? e[t] : t && v(e[t]?.default) ? e[t].default : e;
17
+ function x(e, t) {
18
+ return !e || b(e) ? e : b(e.default) ? e.default : t && b(e[t]) ? e[t] : t && b(e[t]?.default) ? e[t].default : e;
17
19
  }
18
- var b = y(u, "UiLayout") || y(E.UiLayout, "UiLayout"), x = y(l, "PreviewPrompt") || y(E.PreviewPrompt, "PreviewPrompt"), S = y(s, "Collapsible") || y(E.Collapsible, "Collapsible"), C = y(c, "Feedback") || y(E.Feedback, "Feedback"), w = o, T = w.default, E = T && typeof T == "object" ? T : w, D = _("@pie-ui:select-text"), O = g(b)({
19
- color: d.text(),
20
- backgroundColor: d.background()
21
- }), k = g(i)(({ theme: e }) => ({
20
+ var S = x(d, "UiLayout") || x(O.UiLayout, "UiLayout"), C = x(u, "PreviewPrompt") || x(O.PreviewPrompt, "PreviewPrompt"), w = x(c, "Collapsible") || x(O.Collapsible, "Collapsible"), T = x(l, "Feedback") || x(O.Feedback, "Feedback"), E = s, D = E.default, O = D && typeof D == "object" ? D : E, k = y("@pie-ui:select-text"), A = v(S)({
21
+ color: f.text(),
22
+ backgroundColor: f.background()
23
+ }), j = v(a)(({ theme: e }) => ({
22
24
  marginBottom: e.spacing(1),
23
25
  marginTop: e.spacing(2),
24
26
  whiteSpace: "normal"
25
- })), A = g("div")(({ theme: e }) => ({
27
+ })), M = v("div")(({ theme: e }) => ({
26
28
  verticalAlign: "middle",
27
29
  marginBottom: e.spacing(1)
28
- })), j = g(S)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), M = {
29
- model: n.object,
30
- session: n.object,
31
- onSelectionChange: n.func.isRequired
32
- }, N = class extends t.Component {
33
- static propTypes = M;
30
+ })), N = v(w)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), P = {
31
+ model: r.object,
32
+ session: r.object,
33
+ onSelectionChange: r.func.isRequired
34
+ }, F = class extends t.Component {
35
+ static propTypes = P;
34
36
  static defaultProps = {};
35
37
  constructor(t) {
36
38
  super(t), this.state = {
@@ -44,6 +46,12 @@ var b = y(u, "UiLayout") || y(E.UiLayout, "UiLayout"), x = y(l, "PreviewPrompt")
44
46
  model: e(t.model)
45
47
  });
46
48
  }
49
+ componentDidMount() {
50
+ _(n.findDOMNode(this));
51
+ }
52
+ componentDidUpdate() {
53
+ _(n.findDOMNode(this));
54
+ }
47
55
  toggleShowCorrect = () => {
48
56
  this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });
49
57
  };
@@ -52,56 +60,57 @@ var b = y(u, "UiLayout") || y(E.UiLayout, "UiLayout"), x = y(l, "PreviewPrompt")
52
60
  return e.tokens.filter((e) => e.correct);
53
61
  };
54
62
  render() {
55
- let { session: e, onSelectionChange: t } = this.props, { showCorrectAnswer: n, model: i } = this.state, { env: o, extraCSSRules: s } = i, { mode: c } = o || {}, l = n ? this.correctAnswer() : e.selectedTokens, u = i.rationale && (p(i.rationale) || f(i.rationale)), d = i.teacherInstructions && (p(i.teacherInstructions) || f(i.teacherInstructions));
56
- return D("[render] selectedTokens:", l), /* @__PURE__ */ h(O, {
63
+ let { session: e, onSelectionChange: t } = this.props, { showCorrectAnswer: n, model: r } = this.state, { env: a, extraCSSRules: s } = r, { mode: c } = a || {}, l = n ? this.correctAnswer() : e.selectedTokens, u = r.rationale && (m(r.rationale) || p(r.rationale)), d = r.teacherInstructions && (m(r.teacherInstructions) || p(r.teacherInstructions));
64
+ return k("[render] selectedTokens:", l), /* @__PURE__ */ g(A, {
57
65
  extraCSSRules: s,
58
66
  children: [
59
- d && (i.animationsDisabled ? /* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.teacherInstructions }) }) : /* @__PURE__ */ m(j, {
67
+ d && (r.animationsDisabled ? /* @__PURE__ */ h(M, { children: /* @__PURE__ */ h(C, { prompt: r.teacherInstructions }) }) : /* @__PURE__ */ h(N, {
60
68
  labels: {
61
69
  hidden: "Show Teacher Instructions",
62
70
  visible: "Hide Teacher Instructions"
63
71
  },
64
- children: /* @__PURE__ */ m(x, { prompt: i.teacherInstructions })
72
+ children: /* @__PURE__ */ h(C, { prompt: r.teacherInstructions })
65
73
  })),
66
- /* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.prompt }) }),
67
- !i.alwaysShowCorrect && /* @__PURE__ */ m(a, {
68
- show: i.disabled && i.incorrect,
74
+ /* @__PURE__ */ h(M, { children: /* @__PURE__ */ h(C, { prompt: r.prompt }) }),
75
+ !r.alwaysShowCorrect && /* @__PURE__ */ h(o, {
76
+ show: r.disabled && r.incorrect,
69
77
  toggled: n,
70
78
  onToggle: this.toggleShowCorrect,
71
- language: i.language
79
+ language: r.language
72
80
  }),
73
- /* @__PURE__ */ m(k, {
74
- disabled: i.disabled,
75
- text: i.text,
76
- tokens: i.tokens,
81
+ /* @__PURE__ */ h(j, {
82
+ disabled: r.disabled,
83
+ text: r.text,
84
+ tokens: r.tokens,
77
85
  selectedTokens: l,
78
86
  onChange: (e) => {
79
- t(e.map((e) => i.tokens.find(({ start: t, end: n }) => e.start === t && e.end === n) || e));
87
+ let n = e.map((e) => r.tokens.find(({ start: t, end: n }) => e.start === t && e.end === n) || e);
88
+ t(n);
80
89
  },
81
- highlightChoices: i.highlightChoices,
82
- maxNoOfSelections: i.maxSelections,
83
- animationsDisabled: i.animationsDisabled
90
+ highlightChoices: r.highlightChoices,
91
+ maxNoOfSelections: r.maxSelections,
92
+ animationsDisabled: r.animationsDisabled
84
93
  }),
85
- c === "evaluate" && /* @__PURE__ */ m(r, {
86
- language: i.language,
94
+ c === "evaluate" && /* @__PURE__ */ h(i, {
95
+ language: r.language,
87
96
  showOnlyCorrect: n
88
97
  }),
89
- u && (i.animationsDisabled ? /* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.rationale }) }) : /* @__PURE__ */ m(j, {
98
+ u && (r.animationsDisabled ? /* @__PURE__ */ h(M, { children: /* @__PURE__ */ h(C, { prompt: r.rationale }) }) : /* @__PURE__ */ h(N, {
90
99
  labels: {
91
100
  hidden: "Show Rationale",
92
101
  visible: "Hide Rationale"
93
102
  },
94
- children: /* @__PURE__ */ m(x, { prompt: i.rationale })
103
+ children: /* @__PURE__ */ h(C, { prompt: r.rationale })
95
104
  })),
96
- i.correctness && i.feedback && !n && /* @__PURE__ */ m(C, {
97
- correctness: i.correctness,
98
- feedback: i.feedback
105
+ r.correctness && r.feedback && !n && /* @__PURE__ */ h(T, {
106
+ correctness: r.correctness,
107
+ feedback: r.feedback
99
108
  })
100
109
  ]
101
110
  });
102
111
  }
103
- }, P = class extends t.Component {
104
- static propTypes = M;
112
+ }, I = class extends t.Component {
113
+ static propTypes = P;
105
114
  constructor(e) {
106
115
  super(e), this.state = {
107
116
  model: e.model,
@@ -125,7 +134,7 @@ var b = y(u, "UiLayout") || y(E.UiLayout, "UiLayout"), x = y(l, "PreviewPrompt")
125
134
  };
126
135
  render() {
127
136
  let { model: e, session: t } = this.state;
128
- return /* @__PURE__ */ m(N, {
137
+ return /* @__PURE__ */ h(F, {
129
138
  model: e,
130
139
  session: t,
131
140
  onSelectionChange: this.change
@@ -133,4 +142,4 @@ var b = y(u, "UiLayout") || y(E.UiLayout, "UiLayout"), x = y(l, "PreviewPrompt")
133
142
  }
134
143
  };
135
144
  //#endregion
136
- export { P as default };
145
+ export { F as Main, I as default };