@pie-element/passage 7.1.1-next.11 → 7.1.2-next.0
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/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/author/common.d.ts +36 -0
- package/dist/author/common.js +56 -0
- package/dist/author/defaults.d.ts +175 -0
- package/dist/author/defaults.js +113 -0
- package/dist/author/design.d.ts +28 -0
- package/dist/author/design.js +120 -0
- package/dist/author/index.d.ts +36 -0
- package/dist/author/index.js +66 -0
- package/dist/author/passage.d.ts +27 -0
- package/dist/author/passage.js +127 -0
- package/dist/browser/author/index.js +39774 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/controller/index.js +64 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/debounce-CUPmq2t-.js +86 -0
- package/dist/browser/debounce-CUPmq2t-.js.map +1 -0
- package/dist/browser/delivery/index.js +117 -0
- package/dist/browser/delivery/index.js.map +1 -0
- package/dist/browser/dist-C_PfhNd9.js +9602 -0
- package/dist/browser/dist-C_PfhNd9.js.map +1 -0
- package/dist/browser/isEmpty-xEtDXvJL.js +143 -0
- package/dist/browser/isEmpty-xEtDXvJL.js.map +1 -0
- package/dist/browser/isObjectLike-qb18ZQkj.js +38 -0
- package/dist/browser/isObjectLike-qb18ZQkj.js.map +1 -0
- package/dist/browser/passage.css +2 -0
- package/dist/browser/print/index.js +48 -0
- package/dist/browser/print/index.js.map +1 -0
- package/dist/browser/stimulus-tabs-CMox8txJ.js +218 -0
- package/dist/browser/stimulus-tabs-CMox8txJ.js.map +1 -0
- package/dist/controller/defaults.d.ts +23 -0
- package/dist/controller/defaults.js +17 -0
- package/dist/controller/index.d.ts +18 -0
- package/dist/controller/index.js +50 -0
- package/dist/delivery/index.d.ts +22 -0
- package/dist/delivery/index.js +83 -0
- package/dist/delivery/stimulus-tabs.d.ts +21 -0
- package/dist/delivery/stimulus-tabs.js +220 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +145 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTrim.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/debounce.js +50 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js +21 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSymbol.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/now.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/toNumber.js +19 -0
- package/dist/print/index.d.ts +15 -0
- package/dist/print/index.js +47 -0
- package/package.json +83 -19
- package/CHANGELOG.json +0 -227
- package/CHANGELOG.md +0 -1452
- package/LICENSE.md +0 -5
- package/README.md +0 -3
- package/configure/CHANGELOG.md +0 -672
- package/configure/lib/common.js +0 -74
- package/configure/lib/common.js.map +0 -1
- package/configure/lib/defaults.js +0 -174
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/design.js +0 -185
- package/configure/lib/design.js.map +0 -1
- package/configure/lib/index.js +0 -86
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/passage.js +0 -194
- package/configure/lib/passage.js.map +0 -1
- package/configure/package.json +0 -23
- package/controller/CHANGELOG.json +0 -1
- package/controller/CHANGELOG.md +0 -109
- package/controller/lib/defaults.js +0 -23
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -80
- package/controller/lib/index.js.map +0 -1
- package/controller/package.json +0 -13
- package/docs/config-schema.json +0 -1325
- package/docs/config-schema.json.md +0 -974
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -32
- package/docs/demo/index.html +0 -1
- package/docs/pie-schema.json +0 -775
- package/docs/pie-schema.json.md +0 -561
- package/lib/index.js +0 -143
- package/lib/index.js.map +0 -1
- package/lib/print.js +0 -78
- package/lib/print.js.map +0 -1
- package/lib/stimulus-tabs.js +0 -323
- package/lib/stimulus-tabs.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -920
- package/module/demo.js +0 -57
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -10
- package/module/print-demo.js +0 -95
- package/module/print.html +0 -18
- package/module/print.js +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Et as e, S as t } from "../dist-C_PfhNd9.js";
|
|
2
|
+
import { t as n } from "../stimulus-tabs-CMox8txJ.js";
|
|
3
|
+
import { t as r } from "../debounce-CUPmq2t-.js";
|
|
4
|
+
import i from "react";
|
|
5
|
+
import { createRoot as a } from "react-dom/client";
|
|
6
|
+
var o = (0, (/* @__PURE__ */ e(t(), 1)).default)("pie-element:passage:print"), s = (e) => e != null, c = (e, t) => s(e) ? e : t, l = (e, t) => {
|
|
7
|
+
let n = t.role === "instructor", r = c(e.teacherInstructionsEnabled, !0), i = c(e.titleEnabled, !0), a = c(e.authorEnabled, !1), o = c(e.subtitleEnabled, !0), s = c(e.textEnabled, !0);
|
|
8
|
+
return e.passages.map((e, t) => ({
|
|
9
|
+
id: t,
|
|
10
|
+
teacherInstructions: c(e.teacherInstructionsEnabled, r) && n && e.teacherInstructions || "",
|
|
11
|
+
label: e.title || `Passage ${t + 1}`,
|
|
12
|
+
title: c(e.titleEnabled, i) && e.title || "",
|
|
13
|
+
author: c(e.authorEnabled, a) && e.author || "",
|
|
14
|
+
subtitle: c(e.subtitleEnabled, o) && e.subtitle || "",
|
|
15
|
+
text: c(e.textEnabled, s) && e.text || ""
|
|
16
|
+
}));
|
|
17
|
+
}, u = class extends HTMLElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(), this._model = null, this._options = null, this._session = [], this._root = null, this._rerender = r(() => {
|
|
20
|
+
if (this._model && this._session) {
|
|
21
|
+
if (this._model.passages && this._model.passages.length > 0) {
|
|
22
|
+
let e = l(this._model, this._options), t = i.createElement(n, {
|
|
23
|
+
disabledTabs: !0,
|
|
24
|
+
tabs: e
|
|
25
|
+
});
|
|
26
|
+
this._root ||= a(this), this._root.render(t);
|
|
27
|
+
}
|
|
28
|
+
} else o("skip");
|
|
29
|
+
}, 50, {
|
|
30
|
+
leading: !1,
|
|
31
|
+
trailing: !0
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
set model(e) {
|
|
35
|
+
this._model = e, this._rerender();
|
|
36
|
+
}
|
|
37
|
+
set options(e) {
|
|
38
|
+
this._options = e;
|
|
39
|
+
}
|
|
40
|
+
connectedCallback() {}
|
|
41
|
+
disconnectedCallback() {
|
|
42
|
+
this._root && this._root.unmount();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { u as default };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/print/index.tsx"],"sourcesContent":["// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/passage/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 'lodash-es';\nimport debug from 'debug';\n\nimport StimulusTabs from '../delivery/stimulus-tabs.js';\n\nconst log = debug('pie-element:passage:print');\n\nconst checkNullish = (value) => value !== null && value !== undefined;\n\nconst isEnabled = (value, defaultValue) => (checkNullish(value) ? value : defaultValue);\n\nconst preparePrintPassage = (model, opts) => {\n const isInstructor = opts.role === 'instructor';\n\n // TODO: also update '../../configure/src/defaults.js' and '../../controller/src/defaults.js' when updating defaultValue\n const teacherInstructionsEnabled = isEnabled(model.teacherInstructionsEnabled, true);\n const titleEnabled = isEnabled(model.titleEnabled, true);\n const authorEnabled = isEnabled(model.authorEnabled, false);\n const subtitleEnabled = isEnabled(model.subtitleEnabled, true);\n const textEnabled = isEnabled(model.textEnabled, true);\n\n return model.passages.map((passage, index) => ({\n id: index,\n teacherInstructions: isEnabled(passage.teacherInstructionsEnabled, teacherInstructionsEnabled)\n ? (isInstructor && passage.teacherInstructions) || ''\n : '',\n label: passage.title || `Passage ${index + 1}`,\n title: isEnabled(passage.titleEnabled, titleEnabled) ? passage.title || '' : '',\n author: isEnabled(passage.authorEnabled, authorEnabled) ? passage.author || '' : '',\n subtitle: isEnabled(passage.subtitleEnabled, subtitleEnabled) ? passage.subtitle || '' : '',\n text: isEnabled(passage.textEnabled, textEnabled) ? passage.text || '' : '',\n }));\n};\n\nexport default class PassagePrint extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._options = null;\n this._session = [];\n this._root = null;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n if (this._model.passages && this._model.passages.length > 0) {\n const printPassage = preparePrintPassage(this._model, this._options);\n\n const element = React.createElement(StimulusTabs, {\n disabledTabs: true,\n tabs: printPassage,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n set options(o) {\n this._options = o;\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,2BAA2B,GAEvC,KAAgB,MAAU,KAAU,MAEpC,KAAa,GAAO,MAAkB,EAAa,CAAK,IAAI,IAAQ,GAEpE,KAAuB,GAAO,MAAS;CAC3C,IAAM,IAAe,EAAK,SAAS,cAG7B,IAA6B,EAAU,EAAM,4BAA4B,EAAI,GAC7E,IAAe,EAAU,EAAM,cAAc,EAAI,GACjD,IAAgB,EAAU,EAAM,eAAe,EAAK,GACpD,IAAkB,EAAU,EAAM,iBAAiB,EAAI,GACvD,IAAc,EAAU,EAAM,aAAa,EAAI;CAErD,OAAO,EAAM,SAAS,KAAK,GAAS,OAAW;EAC7C,IAAI;EACJ,qBAAqB,EAAU,EAAQ,4BAA4B,CAA0B,KACxF,KAAgB,EAAQ,uBACzB;EACJ,OAAO,EAAQ,SAAS,WAAW,IAAQ;EAC3C,OAAO,EAAU,EAAQ,cAAc,CAAY,KAAI,EAAQ,SAAc;EAC7E,QAAQ,EAAU,EAAQ,eAAe,CAAa,KAAI,EAAQ,UAAe;EACjF,UAAU,EAAU,EAAQ,iBAAiB,CAAe,KAAI,EAAQ,YAAiB;EACzF,MAAM,EAAU,EAAQ,aAAa,CAAW,KAAI,EAAQ,QAAa;CAC3E,EAAE;AACJ,GAEqB,IAArB,cAA0C,YAAY;CACpD,cAAc;EAOZ,AANA,MAAM,GACN,KAAK,SAAS,MACd,KAAK,WAAW,MAChB,KAAK,WAAW,CAAC,GACjB,KAAK,QAAQ,MAEb,KAAK,YAAY,QACT;GACJ,IAAI,KAAK,UAAU,KAAK;QAClB,KAAK,OAAO,YAAY,KAAK,OAAO,SAAS,SAAS,GAAG;KAC3D,IAAM,IAAe,EAAoB,KAAK,QAAQ,KAAK,QAAQ,GAE7D,IAAU,EAAM,cAAc,GAAc;MAChD,cAAc;MACd,MAAM;KACR,CAAC;KAKD,AAHA,AACE,KAAK,UAAQ,EAAW,IAAI,GAE9B,KAAK,MAAM,OAAO,CAAO;IAC3B;UAEA,EAAI,MAAM;EAEd,GACA,IACA;GAAE,SAAS;GAAO,UAAU;EAAK,CACnC;CACF;CAEA,IAAI,MAAM,GAAG;EAEX,AADA,KAAK,SAAS,GACd,KAAK,UAAU;CACjB;CAEA,IAAI,QAAQ,GAAG;EACb,KAAK,WAAW;CAClB;CAEA,oBAAoB,CAAC;CAErB,uBAAuB;EACrB,AAAI,KAAK,SACP,KAAK,MAAM,QAAQ;CAEvB;AACF"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { A as e, Et as t, M as n, N as r, a as i, b as a, et as o, h as s, o as c, s as l, t as u, xt as d } from "./dist-C_PfhNd9.js";
|
|
2
|
+
import f from "react";
|
|
3
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
4
|
+
//#region src/delivery/stimulus-tabs.tsx
|
|
5
|
+
var g = /* @__PURE__ */ t(d(), 1);
|
|
6
|
+
function _(e) {
|
|
7
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
8
|
+
}
|
|
9
|
+
function v(e, t) {
|
|
10
|
+
return !e || _(e) ? e : _(e.default) ? e.default : t && _(e[t]) ? e[t] : t && _(e[t]?.default) ? e[t].default : e;
|
|
11
|
+
}
|
|
12
|
+
var y = v(s, "UiLayout") || v(T.UiLayout, "UiLayout"), b = v(c, "Purpose") || v(T.Purpose, "Purpose"), x = v(l, "PreviewPrompt") || v(T.PreviewPrompt, "PreviewPrompt"), S = v(a, "Collapsible") || v(T.Collapsible, "Collapsible"), C = u, w = C.default, T = w && typeof w == "object" ? w : C, E = o("div")({
|
|
13
|
+
flexGrow: 1,
|
|
14
|
+
backgroundColor: e.background(),
|
|
15
|
+
color: e.text(),
|
|
16
|
+
"&:not(.MathJax) table": { borderCollapse: "collapse" },
|
|
17
|
+
"&:not(.MathJax) table td, &:not(.MathJax) table th": {
|
|
18
|
+
padding: ".6em 1em",
|
|
19
|
+
textAlign: "left"
|
|
20
|
+
}
|
|
21
|
+
}), D = o("div")(({ theme: t }) => ({
|
|
22
|
+
backgroundColor: e.background(),
|
|
23
|
+
color: e.text(),
|
|
24
|
+
padding: t.spacing(2),
|
|
25
|
+
"& blockquote": {
|
|
26
|
+
background: "#f9f9f9",
|
|
27
|
+
borderLeft: "5px solid #ccc",
|
|
28
|
+
margin: "1.5em 10px",
|
|
29
|
+
padding: ".5em 10px"
|
|
30
|
+
}
|
|
31
|
+
})), O = o("div")({ fontSize: "1.75rem" }), k = o("div")({ fontSize: "1.5rem" }), A = o("div")({ fontSize: "1.25rem" }), j = o(n)(({ theme: e }) => ({
|
|
32
|
+
background: e.palette.common.white,
|
|
33
|
+
fontSize: "inherit",
|
|
34
|
+
fontFamily: "Roboto, sans-serif",
|
|
35
|
+
color: e.palette.common.black,
|
|
36
|
+
borderRadius: `${e.spacing(2)} ${e.spacing(2)} 0 0`,
|
|
37
|
+
border: "1px solid #D9DADA",
|
|
38
|
+
borderBottomWidth: 0,
|
|
39
|
+
minHeight: "56px",
|
|
40
|
+
padding: "8px 10px",
|
|
41
|
+
display: "flex",
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
justifyContent: "center",
|
|
44
|
+
margin: `0 ${e.spacing(1)}`,
|
|
45
|
+
textTransform: "none",
|
|
46
|
+
".passage-label": {
|
|
47
|
+
display: "-webkit-box",
|
|
48
|
+
WebkitLineClamp: 2,
|
|
49
|
+
WebkitBoxOrient: "vertical",
|
|
50
|
+
overflow: "hidden",
|
|
51
|
+
textOverflow: "ellipsis",
|
|
52
|
+
whiteSpace: "normal",
|
|
53
|
+
margin: "auto 0",
|
|
54
|
+
opacity: .7
|
|
55
|
+
},
|
|
56
|
+
"&.Mui-selected": {
|
|
57
|
+
color: e.palette.common.black,
|
|
58
|
+
".passage-label": { opacity: 1 },
|
|
59
|
+
".passage-label-underline": { backgroundColor: "#146EB3" }
|
|
60
|
+
},
|
|
61
|
+
"&:hover": { ".passage-label-underline": { backgroundColor: "#D0E2F0" } },
|
|
62
|
+
"& .MuiTouchRipple-root": { opacity: .7 }
|
|
63
|
+
})), M = o("div")(({ theme: e }) => ({
|
|
64
|
+
height: "2px",
|
|
65
|
+
width: "100%",
|
|
66
|
+
marginTop: "6px",
|
|
67
|
+
background: e.palette.common.white
|
|
68
|
+
})), N = class extends f.Component {
|
|
69
|
+
state = { activeTab: 0 };
|
|
70
|
+
handleChange = (e, t) => {
|
|
71
|
+
this.setState(() => ({ activeTab: t })), setTimeout(() => {
|
|
72
|
+
let e = new CustomEvent("pie-ui-passage-tabChanged", { detail: { tab: t } });
|
|
73
|
+
window.dispatchEvent(e);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
handleKeyDown = (e, t) => {
|
|
77
|
+
let { key: n } = e, { tabs: r } = this.props, i = -1, a = r.findIndex((e) => e.id === t);
|
|
78
|
+
switch (n) {
|
|
79
|
+
case "ArrowRight":
|
|
80
|
+
i = (a + 1) % r.length;
|
|
81
|
+
break;
|
|
82
|
+
case "ArrowLeft":
|
|
83
|
+
i = (a - 1 + r.length) % r.length;
|
|
84
|
+
break;
|
|
85
|
+
case "Home":
|
|
86
|
+
i = 0;
|
|
87
|
+
break;
|
|
88
|
+
case "End":
|
|
89
|
+
i = r.length - 1;
|
|
90
|
+
break;
|
|
91
|
+
case "Enter":
|
|
92
|
+
case " ":
|
|
93
|
+
i = a;
|
|
94
|
+
break;
|
|
95
|
+
default: break;
|
|
96
|
+
}
|
|
97
|
+
i !== -1 && (e.preventDefault(), e.stopPropagation(), this.handleChange(e, r[i].id), document.getElementById(`button-${r[i].id}`).focus());
|
|
98
|
+
};
|
|
99
|
+
parsedText = (e = "") => {
|
|
100
|
+
let t = document.createElement("div");
|
|
101
|
+
t.innerHTML = e.replace(/(<br\/>\n)/g, "<br/>");
|
|
102
|
+
let n = t.querySelector("audio");
|
|
103
|
+
if (n) {
|
|
104
|
+
let e = document.createElement("source");
|
|
105
|
+
e.setAttribute("type", "audio/mp3"), e.setAttribute("src", n.getAttribute("src")), n.removeAttribute("src"), n.appendChild(e);
|
|
106
|
+
}
|
|
107
|
+
return t.innerHTML;
|
|
108
|
+
};
|
|
109
|
+
renderInstructions(e, t = !1) {
|
|
110
|
+
if (!e) return;
|
|
111
|
+
let n = /* @__PURE__ */ m(x, {
|
|
112
|
+
tagName: "div",
|
|
113
|
+
className: "prompt",
|
|
114
|
+
defaultClassName: "teacher-instructions",
|
|
115
|
+
prompt: e
|
|
116
|
+
});
|
|
117
|
+
return t ? n : /* @__PURE__ */ m(S, {
|
|
118
|
+
labels: {
|
|
119
|
+
hidden: "Show Teacher Instructions",
|
|
120
|
+
visible: "Hide Teacher Instructions"
|
|
121
|
+
},
|
|
122
|
+
children: n
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
renderTab(e, t) {
|
|
126
|
+
let { baseHeadingLevel: n } = this.props, r = n ? Math.min(6, Math.max(1, n)) : void 0, a = n ? `h${r}` : "h2", o = n ? Math.min(6, Math.max(1, r + 1)) : void 0;
|
|
127
|
+
return /* @__PURE__ */ h(D, {
|
|
128
|
+
id: `tabpanel-${e.id}`,
|
|
129
|
+
role: "tabpanel",
|
|
130
|
+
"aria-labelledby": `button-${e.id}`,
|
|
131
|
+
children: [
|
|
132
|
+
this.renderInstructions(e.teacherInstructions, t),
|
|
133
|
+
e.title && /* @__PURE__ */ m(b, {
|
|
134
|
+
purpose: "passage-title",
|
|
135
|
+
children: /* @__PURE__ */ m(a, { children: /* @__PURE__ */ m(O, { dangerouslySetInnerHTML: { __html: this.parsedText(e.title) } }) })
|
|
136
|
+
}),
|
|
137
|
+
e.subtitle && /* @__PURE__ */ m(b, {
|
|
138
|
+
purpose: "passage-subtitle",
|
|
139
|
+
children: /* @__PURE__ */ m(k, { dangerouslySetInnerHTML: { __html: this.parsedText(e.subtitle) } })
|
|
140
|
+
}),
|
|
141
|
+
e.author && /* @__PURE__ */ m(b, {
|
|
142
|
+
purpose: "passage-author",
|
|
143
|
+
children: /* @__PURE__ */ m(A, {
|
|
144
|
+
className: "author",
|
|
145
|
+
dangerouslySetInnerHTML: { __html: this.parsedText(e.author) }
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
e.text && /* @__PURE__ */ m(b, {
|
|
149
|
+
purpose: "passage-text",
|
|
150
|
+
children: /* @__PURE__ */ m("div", {
|
|
151
|
+
className: "text",
|
|
152
|
+
dangerouslySetInnerHTML: { __html: n ? i(e.text, o) : e.text }
|
|
153
|
+
}, e.id)
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
}, e.id);
|
|
157
|
+
}
|
|
158
|
+
render() {
|
|
159
|
+
let { model: t, tabs: n, disabledTabs: i } = this.props, { activeTab: a } = this.state;
|
|
160
|
+
if (!n?.length) return;
|
|
161
|
+
let { extraCSSRules: o } = t || {}, s = (n || []).find((e) => e.id === a);
|
|
162
|
+
return /* @__PURE__ */ m(y, {
|
|
163
|
+
extraCSSRules: o,
|
|
164
|
+
children: /* @__PURE__ */ m(E, {
|
|
165
|
+
className: "passages",
|
|
166
|
+
children: i || n.length === 1 ? n.map((e) => this.renderTab(e, i)) : /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(r, {
|
|
167
|
+
sx: {
|
|
168
|
+
position: "sticky",
|
|
169
|
+
top: 0,
|
|
170
|
+
background: e.background(),
|
|
171
|
+
color: e.text(),
|
|
172
|
+
fontFamily: "Roboto, sans-serif",
|
|
173
|
+
"& .MuiTabs-list": { borderBottom: "1px solid #D9DADA" },
|
|
174
|
+
"& .MuiTabs-indicator": {
|
|
175
|
+
backgroundColor: "#ffffff",
|
|
176
|
+
marginBottom: "-1px"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
value: a,
|
|
180
|
+
onChange: this.handleChange,
|
|
181
|
+
children: n.map((e) => /* @__PURE__ */ m(j, {
|
|
182
|
+
id: `button-${e.id}`,
|
|
183
|
+
label: /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(b, {
|
|
184
|
+
purpose: "passage-label",
|
|
185
|
+
children: /* @__PURE__ */ m("span", {
|
|
186
|
+
className: "passage-label",
|
|
187
|
+
dangerouslySetInnerHTML: { __html: this.parsedText(e.label) }
|
|
188
|
+
})
|
|
189
|
+
}), /* @__PURE__ */ m(M, { className: "passage-label-underline" })] }),
|
|
190
|
+
value: e.id,
|
|
191
|
+
tabIndex: a === e.id ? 0 : -1,
|
|
192
|
+
"aria-controls": `tabpanel-${e.id}`,
|
|
193
|
+
"aria-selected": a === e.id,
|
|
194
|
+
onKeyDown: (t) => this.handleKeyDown(t, e.id)
|
|
195
|
+
}, e.id))
|
|
196
|
+
}), s ? this.renderTab(s, i) : null] })
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
N.propTypes = {
|
|
202
|
+
tabs: g.default.arrayOf(g.default.shape({
|
|
203
|
+
id: g.default.number.isRequired,
|
|
204
|
+
label: g.default.string.isRequired,
|
|
205
|
+
title: g.default.string.isRequired,
|
|
206
|
+
subtitle: g.default.string,
|
|
207
|
+
author: g.default.string,
|
|
208
|
+
text: g.default.string.isRequired,
|
|
209
|
+
teacherInstructions: g.default.string
|
|
210
|
+
}).isRequired).isRequired,
|
|
211
|
+
disabledTabs: g.default.bool,
|
|
212
|
+
model: g.default.object,
|
|
213
|
+
baseHeadingLevel: g.default.number
|
|
214
|
+
};
|
|
215
|
+
//#endregion
|
|
216
|
+
export { N as t };
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=stimulus-tabs-CMox8txJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stimulus-tabs-CMox8txJ.js","names":[],"sources":["../../src/delivery/stimulus-tabs.tsx"],"sourcesContent":["// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/passage/src/stimulus-tabs.jsx\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 PropTypes from 'prop-types';\nimport Tabs from '@mui/material/Tabs';\nimport Tab from '@mui/material/Tab';\nimport { styled } from '@mui/material/styles';\nimport { Collapsible as CollapsibleImport, color, PreviewPrompt as PreviewPromptImport, Purpose as PurposeImport, UiLayout as UiLayoutImport, transformDataHeadings } from '@pie-lib/render-ui';\n\nfunction isRenderableReactInteropType(value: any) {\n return (\n typeof value === 'function' ||\n (typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')\n );\n}\n\nfunction unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {\n if (!maybeSymbol) return maybeSymbol;\n if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;\n if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;\n if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {\n return maybeSymbol[namedExport];\n }\n if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {\n return maybeSymbol[namedExport].default;\n }\n return maybeSymbol;\n}\nconst UiLayout = unwrapReactInteropSymbol(UiLayoutImport, 'UiLayout') || unwrapReactInteropSymbol(renderUi.UiLayout, 'UiLayout');\nconst Purpose = unwrapReactInteropSymbol(PurposeImport, 'Purpose') || unwrapReactInteropSymbol(renderUi.Purpose, 'Purpose');\nconst PreviewPrompt = unwrapReactInteropSymbol(PreviewPromptImport, 'PreviewPrompt') || unwrapReactInteropSymbol(renderUi.PreviewPrompt, 'PreviewPrompt');\nconst Collapsible = unwrapReactInteropSymbol(CollapsibleImport, 'Collapsible') || unwrapReactInteropSymbol(renderUi.Collapsible, 'Collapsible');\nimport * as RenderUiNamespace from '@pie-lib/render-ui';\nconst renderUiNamespaceAny = RenderUiNamespace as any;\nconst renderUiDefaultMaybe = renderUiNamespaceAny['default'];\nconst renderUi =\n renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'\n ? renderUiDefaultMaybe\n : renderUiNamespaceAny;\nconst PassagesContainer: any = styled('div')({\n flexGrow: 1,\n backgroundColor: color.background(),\n color: color.text(),\n '&:not(.MathJax) table': {\n borderCollapse: 'collapse',\n },\n '&:not(.MathJax) table td, &:not(.MathJax) table th': {\n padding: '.6em 1em',\n textAlign: 'left',\n },\n});\n\nconst Passage: any = styled('div')(({ theme }) => ({\n backgroundColor: color.background(),\n color: color.text(),\n padding: theme.spacing(2),\n '& blockquote': {\n background: '#f9f9f9',\n borderLeft: '5px solid #ccc',\n margin: '1.5em 10px',\n padding: '.5em 10px',\n },\n}));\n\nconst PassageTitle: any = styled('div')({\n fontSize: '1.75rem',\n});\n\nconst PassageSubtitle: any = styled('div')({\n fontSize: '1.5rem',\n});\n\nconst PassageAuthor: any = styled('div')({\n fontSize: '1.25rem',\n});\n\nconst TabStyled: any = styled(Tab)(({ theme }) => ({\n background: theme.palette.common.white, // replace with color.background() once PD-2801 is DONE\n fontSize: 'inherit',\n fontFamily: 'Roboto, sans-serif',\n color: theme.palette.common.black, // remove when PD-2801 is DONE\n borderRadius: `${theme.spacing(2)} ${theme.spacing(2)} 0 0`,\n border: '1px solid #D9DADA',\n borderBottomWidth: 0,\n minHeight: '56px',\n padding: '8px 10px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n margin: `0 ${theme.spacing(1)}`,\n textTransform: 'none',\n\n '.passage-label': {\n display: '-webkit-box',\n WebkitLineClamp: 2,\n WebkitBoxOrient: 'vertical',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'normal',\n margin: 'auto 0',\n opacity: 0.7,\n },\n\n '&.Mui-selected': {\n color: theme.palette.common.black,\n '.passage-label': {\n opacity: 1,\n },\n '.passage-label-underline': {\n backgroundColor: '#146EB3',\n },\n },\n\n '&:hover': {\n '.passage-label-underline': {\n backgroundColor: '#D0E2F0',\n },\n },\n\n '& .MuiTouchRipple-root': {\n opacity: 0.7,\n },\n}));\n\nconst Underline: any = styled('div')(({ theme }) => ({\n height: '2px',\n width: '100%',\n marginTop: '6px',\n background: theme.palette.common.white, // replace with color.background() once PD-2801 is DONE\n}));\n\nclass StimulusTabs extends React.Component {\n state = {\n activeTab: 0,\n };\n\n handleChange: any = (event, activeTab) => {\n this.setState(() => ({ activeTab }));\n\n setTimeout(() => {\n const tabChangeEvent = new CustomEvent('pie-ui-passage-tabChanged', {\n detail: { tab: activeTab },\n });\n\n window.dispatchEvent(tabChangeEvent);\n });\n };\n\n handleKeyDown: any = (event, currentTabId) => {\n const { key } = event;\n const { tabs } = this.props;\n\n let newTabIndex = -1;\n const currentIndex = tabs.findIndex((tab) => tab.id === currentTabId);\n\n switch (key) {\n case 'ArrowRight':\n // Move to the next tab\n newTabIndex = (currentIndex + 1) % tabs.length;\n break;\n case 'ArrowLeft':\n // Move to the previous tab\n newTabIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n break;\n // Commented out ArrowDown and ArrowUp for future vertical tab navigation\n // case 'ArrowDown':\n // // Move to the next tab (for vertical alignment)\n // newTabIndex = (currentIndex + 1) % tabs.length;\n // break;\n // case 'ArrowUp':\n // // Move to the previous tab (for vertical alignment)\n // newTabIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n // break;\n case 'Home':\n // Move to the first tab\n newTabIndex = 0;\n break;\n case 'End':\n // Move to the last tab\n newTabIndex = tabs.length - 1;\n break;\n case 'Enter':\n case ' ':\n // Activate the current tab\n newTabIndex = currentIndex;\n break;\n default:\n break;\n }\n\n if (newTabIndex !== -1) {\n event.preventDefault();\n event.stopPropagation();\n this.handleChange(event, tabs[newTabIndex].id);\n document.getElementById(`button-${tabs[newTabIndex].id}`).focus();\n }\n };\n\n parsedText: any = (text = '') => {\n // fix imported audio content for Safari PD-1391\n const div = document.createElement('div');\n div.innerHTML = text.replace(/(<br\\/>\\n)/g, '<br/>');\n\n const audio = div.querySelector('audio');\n\n if (audio) {\n const source = document.createElement('source');\n\n source.setAttribute('type', 'audio/mp3');\n source.setAttribute('src', audio.getAttribute('src'));\n\n audio.removeAttribute('src');\n audio.appendChild(source);\n }\n\n return div.innerHTML;\n };\n\n renderInstructions(teacherInstructions, disabledTabs = false) {\n if (!teacherInstructions) {\n return;\n }\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n if (disabledTabs) {\n return teacherInstructionsDiv;\n }\n\n return (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n );\n }\n\n renderTab(tab, disabledTabs) {\n const { baseHeadingLevel } = this.props;\n const clampedLevel = baseHeadingLevel ? Math.min(6, Math.max(1, baseHeadingLevel)) : undefined;\n const TitleTag = baseHeadingLevel ? `h${clampedLevel}` : 'h2'; // default to h2 if no base level is provided - this was the previous behavior\n const textLevel = baseHeadingLevel ? Math.min(6, Math.max(1, clampedLevel + 1)) : undefined; // promote text headings one level above title\n\n return (\n <Passage key={tab.id} id={`tabpanel-${tab.id}`} role=\"tabpanel\" aria-labelledby={`button-${tab.id}`}>\n {this.renderInstructions(tab.teacherInstructions, disabledTabs)}\n\n {tab.title && (\n <Purpose purpose=\"passage-title\">\n <TitleTag>\n <PassageTitle dangerouslySetInnerHTML={{ __html: this.parsedText(tab.title) }} />\n </TitleTag>\n </Purpose>\n )}\n\n {tab.subtitle && (\n <Purpose purpose=\"passage-subtitle\">\n <PassageSubtitle dangerouslySetInnerHTML={{ __html: this.parsedText(tab.subtitle) }} />\n </Purpose>\n )}\n\n {tab.author && (\n <Purpose purpose=\"passage-author\">\n <PassageAuthor className=\"author\" dangerouslySetInnerHTML={{ __html: this.parsedText(tab.author) }} />\n </Purpose>\n )}\n\n {tab.text && (\n <Purpose purpose=\"passage-text\">\n <div key={tab.id} className=\"text\" dangerouslySetInnerHTML={{ __html: baseHeadingLevel ? transformDataHeadings(tab.text, textLevel) : tab.text }} />\n </Purpose>\n )}\n </Passage>\n );\n }\n\n render() {\n const { model, tabs, disabledTabs } = this.props;\n const { activeTab } = this.state;\n\n if (!tabs?.length) {\n return;\n }\n\n const { extraCSSRules } = model || {};\n const selectedTab = (tabs || []).find((tab) => tab.id === activeTab);\n\n return (\n <UiLayout extraCSSRules={extraCSSRules}>\n <PassagesContainer className=\"passages\">\n {disabledTabs || tabs.length === 1 ? (\n tabs.map((tab) => this.renderTab(tab, disabledTabs))\n ) : (\n <>\n <Tabs\n sx={{\n position: 'sticky',\n top: 0,\n background: color.background(),\n color: color.text(),\n fontFamily: 'Roboto, sans-serif',\n '& .MuiTabs-list': {\n borderBottom: '1px solid #D9DADA',\n },\n '& .MuiTabs-indicator': {\n backgroundColor: '#ffffff',\n marginBottom: '-1px',\n },\n }}\n value={activeTab}\n onChange={this.handleChange}\n >\n {tabs.map((tab) => (\n <TabStyled\n key={tab.id}\n id={`button-${tab.id}`}\n label={\n <>\n <Purpose purpose=\"passage-label\">\n <span\n className=\"passage-label\"\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.label) }}\n />\n </Purpose>\n <Underline className=\"passage-label-underline\" />\n </>\n }\n value={tab.id}\n tabIndex={activeTab === tab.id ? 0 : -1}\n aria-controls={`tabpanel-${tab.id}`}\n aria-selected={activeTab === tab.id}\n onKeyDown={(event) => this.handleKeyDown(event, tab.id)}\n />\n ))}\n </Tabs>\n {selectedTab ? this.renderTab(selectedTab, disabledTabs) : null}\n </>\n )}\n </PassagesContainer>\n </UiLayout>\n );\n }\n}\n\nStimulusTabs.propTypes = {\n tabs: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.number.isRequired,\n label: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string,\n author: PropTypes.string,\n text: PropTypes.string.isRequired,\n teacherInstructions: PropTypes.string,\n }).isRequired,\n ).isRequired,\n disabledTabs: PropTypes.bool,\n model: PropTypes.object,\n baseHeadingLevel: PropTypes.number,\n};\n\nexport default StimulusTabs;\n"],"mappings":";;;;;AAiBA,SAAS,EAA6B,GAAY;CAChD,OACE,OAAO,KAAU,cAChB,OAAO,KAAU,cAAY,KAAkB,OAAO,EAAM,YAAa;AAE9E;AAEA,SAAS,EAAyB,GAAkB,GAAsB;CAUxE,OATI,CAAC,KACD,EAA6B,CAAW,IAAU,IAClD,EAA6B,EAAY,OAAO,IAAU,EAAY,UACtE,KAAe,EAA6B,EAAY,EAAY,IAC/D,EAAY,KAEjB,KAAe,EAA6B,EAAY,IAAc,OAAO,IACxE,EAAY,GAAa,UAE3B;AACT;AACA,IAAM,IAAW,EAAyB,GAAgB,UAAU,KAAK,EAAyB,EAAS,UAAU,UAAU,GACzH,IAAU,EAAyB,GAAe,SAAS,KAAK,EAAyB,EAAS,SAAS,SAAS,GACpH,IAAgB,EAAyB,GAAqB,eAAe,KAAK,EAAyB,EAAS,eAAe,eAAe,GAClJ,IAAc,EAAyB,GAAmB,aAAa,KAAK,EAAyB,EA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c,EAAI,KAAK,IAAI;MACrC,iBAAe,YAAY,EAAI;MAC/B,iBAAe,MAAc,EAAI;MACjC,YAAY,MAAU,KAAK,cAAc,GAAO,EAAI,EAAE;KACvD,GAlBM,EAAI,EAkBV,CACF;IACG,CAAA,GACL,IAAc,KAAK,UAAU,GAAa,CAAY,IAAI,IAC3D,EAAA,CAAA;GAEa,CAAA;EACX,CAAA;CAEd;AACF;AAEA,EAAa,YAAY;CACvB,MAAM,EAAA,QAAU,QACd,EAAA,QAAU,MAAM;EACd,IAAI,EAAA,QAAU,OAAO;EACrB,OAAO,EAAA,QAAU,OAAO;EACxB,OAAO,EAAA,QAAU,OAAO;EACxB,UAAU,EAAA,QAAU;EACpB,QAAQ,EAAA,QAAU;EAClB,MAAM,EAAA,QAAU,OAAO;EACvB,qBAAqB,EAAA,QAAU;CACjC,CAAC,EAAE,UACL,EAAE;CACF,cAAc,EAAA,QAAU;CACxB,OAAO,EAAA,QAAU;CACjB,kBAAkB,EAAA,QAAU;AAC9B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/passage/controller/src/defaults.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: {
|
|
10
|
+
authorEnabled: boolean;
|
|
11
|
+
passages: {
|
|
12
|
+
teacherInstructions: string;
|
|
13
|
+
title: string;
|
|
14
|
+
subtitle: string;
|
|
15
|
+
author: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}[];
|
|
18
|
+
subtitleEnabled: boolean;
|
|
19
|
+
teacherInstructionsEnabled: boolean;
|
|
20
|
+
textEnabled: boolean;
|
|
21
|
+
titleEnabled: boolean;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/controller/defaults.ts
|
|
2
|
+
var e = {
|
|
3
|
+
authorEnabled: !1,
|
|
4
|
+
passages: [{
|
|
5
|
+
teacherInstructions: "",
|
|
6
|
+
title: "",
|
|
7
|
+
subtitle: "",
|
|
8
|
+
author: "",
|
|
9
|
+
text: ""
|
|
10
|
+
}],
|
|
11
|
+
subtitleEnabled: !0,
|
|
12
|
+
teacherInstructionsEnabled: !0,
|
|
13
|
+
textEnabled: !0,
|
|
14
|
+
titleEnabled: !0
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/passage/controller/src/index.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createDefaultModel(model?: {}): Promise<unknown>;
|
|
10
|
+
export declare const normalize: (question: any) => any;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {*} question
|
|
14
|
+
* @param {*} session
|
|
15
|
+
* @param {*} env
|
|
16
|
+
*/
|
|
17
|
+
export declare function model(question: any, session: any, env: any): Promise<any>;
|
|
18
|
+
export declare const validate: (model?: {}, config?: {}) => {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import e from "../node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js";
|
|
2
|
+
import t from "./defaults.js";
|
|
3
|
+
//#region src/controller/index.ts
|
|
4
|
+
var n = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), r = (e) => e != null, i = (e, t) => r(e) ? e : t;
|
|
5
|
+
function a(e = {}) {
|
|
6
|
+
return new Promise((n) => {
|
|
7
|
+
n({
|
|
8
|
+
...t,
|
|
9
|
+
...e
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
var o = (e) => ({
|
|
14
|
+
...t,
|
|
15
|
+
...e
|
|
16
|
+
}), s = (e, t) => {
|
|
17
|
+
let { role: n, mode: r } = t;
|
|
18
|
+
return n === "instructor" && (r === "view" || r === "evaluate") && e || "";
|
|
19
|
+
};
|
|
20
|
+
async function c(e, t, r) {
|
|
21
|
+
let a = o(e), c = a.passages.map((e, t) => ({
|
|
22
|
+
teacherInstructions: i(e.teacherInstructionsEnabled, a.teacherInstructionsEnabled) ? s(e.teacherInstructions, r) : "",
|
|
23
|
+
label: n(e.title) ? e.title : `Passage ${t + 1}`,
|
|
24
|
+
title: i(e.titleEnabled, a.titleEnabled) && e.title || "",
|
|
25
|
+
subtitle: i(e.subtitleEnabled, a.subtitleEnabled) && e.subtitle || "",
|
|
26
|
+
author: i(e.authorEnabled, a.authorEnabled) && e.author || "",
|
|
27
|
+
text: i(e.textEnabled, a.textEnabled) && e.text || ""
|
|
28
|
+
}));
|
|
29
|
+
return {
|
|
30
|
+
...a,
|
|
31
|
+
passages: c
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var l = (t = {}, r = {}) => {
|
|
35
|
+
let i = {}, a = {};
|
|
36
|
+
return (t.passages || []).forEach((t, i) => {
|
|
37
|
+
let o = {};
|
|
38
|
+
[
|
|
39
|
+
"teacherInstructions",
|
|
40
|
+
"title",
|
|
41
|
+
"subtitle",
|
|
42
|
+
"author",
|
|
43
|
+
"text"
|
|
44
|
+
].forEach((e) => {
|
|
45
|
+
r[e]?.required && !n(t[e]) && (o[e] = "This field is required.");
|
|
46
|
+
}), e(o) || (a[i] = o);
|
|
47
|
+
}), e(a) || (i.passages = a), i;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { a as createDefaultModel, c as model, o as normalize, l as validate };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/passage/src/index.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
export default class PiePassage extends HTMLElement {
|
|
10
|
+
constructor();
|
|
11
|
+
setLangAttribute(): void;
|
|
12
|
+
_scheduleMathRender: any;
|
|
13
|
+
_initMathObserver(): void;
|
|
14
|
+
_disconnectMathObserver(): void;
|
|
15
|
+
set model(s: any);
|
|
16
|
+
set session(s: any);
|
|
17
|
+
connectedCallback(): void;
|
|
18
|
+
_render(): void;
|
|
19
|
+
_initPlayerObserver(): void;
|
|
20
|
+
_disconnectPlayerObserver(): void;
|
|
21
|
+
disconnectedCallback(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import e from "./stimulus-tabs.js";
|
|
2
|
+
import { ModelSetEvent as t } from "@pie-element/shared-player-events";
|
|
3
|
+
import { renderMath as n } from "@pie-element/shared-math-rendering-mathjax";
|
|
4
|
+
import r from "react";
|
|
5
|
+
import { createRoot as i } from "react-dom/client";
|
|
6
|
+
//#region src/delivery/index.ts
|
|
7
|
+
function a(e) {
|
|
8
|
+
let t = e.closest("pie-player") || e.closest("pie-item-player");
|
|
9
|
+
if (t) {
|
|
10
|
+
let e = t.baseHeadingLevel;
|
|
11
|
+
e ??= t.getAttribute("base-heading-level") ?? t.getAttribute("baseheadinglevel");
|
|
12
|
+
let n = parseInt(e, 10);
|
|
13
|
+
if (Number.isFinite(n) && n >= 1 && n <= 6) return n;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
var o = class extends HTMLElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(), this._model = { passages: [] }, this._session = null, this._root = null, this._mathObserver = null, this._mathRenderPending = !1, this._playerObserver = null;
|
|
19
|
+
}
|
|
20
|
+
setLangAttribute() {
|
|
21
|
+
let e = this._model && typeof this._model.language ? this._model.language : "", t = e ? e.slice(0, 2) : "en";
|
|
22
|
+
this.setAttribute("lang", t);
|
|
23
|
+
}
|
|
24
|
+
_scheduleMathRender = () => {
|
|
25
|
+
this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
|
|
26
|
+
this._mathObserver && this._mathObserver.disconnect(), n(this), this._mathRenderPending = !1, setTimeout(() => {
|
|
27
|
+
this._mathObserver && this._mathObserver.observe(this, {
|
|
28
|
+
childList: !0,
|
|
29
|
+
subtree: !0
|
|
30
|
+
});
|
|
31
|
+
}, 50);
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
_initMathObserver() {
|
|
35
|
+
this._mathObserver || (this._mathObserver = new MutationObserver(this._scheduleMathRender), this._mathObserver.observe(this, {
|
|
36
|
+
childList: !0,
|
|
37
|
+
subtree: !0
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
_disconnectMathObserver() {
|
|
41
|
+
this._mathObserver &&= (this._mathObserver.disconnect(), null);
|
|
42
|
+
}
|
|
43
|
+
set model(e) {
|
|
44
|
+
this._model = e, this.dispatchEvent(new t(this.tagName.toLowerCase(), this._session, !!this._model)), this.setLangAttribute(), this._render();
|
|
45
|
+
}
|
|
46
|
+
set session(e) {
|
|
47
|
+
this._session = e;
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
this.setAttribute("aria-label", "Passage"), this.setAttribute("role", "region"), this._initMathObserver(), this._initPlayerObserver(), this._render();
|
|
51
|
+
}
|
|
52
|
+
_render() {
|
|
53
|
+
let { passages: t = [] } = this._model;
|
|
54
|
+
if (this._model.passages.length > 0) {
|
|
55
|
+
let n = t.map((e, t) => ({
|
|
56
|
+
id: t,
|
|
57
|
+
...e
|
|
58
|
+
})), o = r.createElement(e, {
|
|
59
|
+
tabs: n,
|
|
60
|
+
model: this._model,
|
|
61
|
+
baseHeadingLevel: a(this)
|
|
62
|
+
});
|
|
63
|
+
this._root ||= i(this), this._root.render(o), this._initMathObserver();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_initPlayerObserver() {
|
|
67
|
+
let e = this.closest("pie-player") || this.closest("pie-item-player");
|
|
68
|
+
e && (this._playerObserver = new MutationObserver(() => {
|
|
69
|
+
this._render();
|
|
70
|
+
}), this._playerObserver.observe(e, {
|
|
71
|
+
attributes: !0,
|
|
72
|
+
attributeFilter: ["base-heading-level"]
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
_disconnectPlayerObserver() {
|
|
76
|
+
this._playerObserver &&= (this._playerObserver.disconnect(), null);
|
|
77
|
+
}
|
|
78
|
+
disconnectedCallback() {
|
|
79
|
+
this._disconnectMathObserver(), this._disconnectPlayerObserver(), this._root && this._root.unmount();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { o as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/passage/src/stimulus-tabs.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
declare class StimulusTabs extends React.Component {
|
|
11
|
+
state: {
|
|
12
|
+
activeTab: number;
|
|
13
|
+
};
|
|
14
|
+
handleChange: any;
|
|
15
|
+
handleKeyDown: any;
|
|
16
|
+
parsedText: any;
|
|
17
|
+
renderInstructions(teacherInstructions: any, disabledTabs?: boolean): React.JSX.Element | undefined;
|
|
18
|
+
renderTab(tab: any, disabledTabs: any): React.JSX.Element;
|
|
19
|
+
render(): React.JSX.Element | undefined;
|
|
20
|
+
}
|
|
21
|
+
export default StimulusTabs;
|