@pie-element/passage 7.1.0-next.28 → 7.1.1-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/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/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 +56 -19
- package/CHANGELOG.json +0 -227
- package/CHANGELOG.md +0 -1440
- package/LICENSE.md +0 -5
- package/README.md +0 -3
- package/configure/CHANGELOG.md +0 -665
- 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 -105
- 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 -319
- 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,127 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { styled as n } from "@mui/material/styles";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
import { InputContainer as a } from "@pie-lib/config-ui";
|
|
6
|
+
import o, { ALL_PLUGINS as s } from "@pie-lib/editable-html-tip-tap";
|
|
7
|
+
//#region src/author/passage.tsx
|
|
8
|
+
var c = n(a)(({ theme: e }) => ({
|
|
9
|
+
paddingTop: e.spacing(2),
|
|
10
|
+
marginBottom: e.spacing(2),
|
|
11
|
+
width: "100%"
|
|
12
|
+
})), l = n("div")(({ theme: e }) => ({
|
|
13
|
+
fontSize: e.typography.fontSize - 2,
|
|
14
|
+
color: e.palette.error.main,
|
|
15
|
+
paddingTop: e.spacing(1)
|
|
16
|
+
})), u = class extends e.Component {
|
|
17
|
+
static propTypes = {
|
|
18
|
+
onModelChanged: t.func.isRequired,
|
|
19
|
+
model: t.object.isRequired,
|
|
20
|
+
configuration: t.object.isRequired,
|
|
21
|
+
imageSupport: t.object.isRequired,
|
|
22
|
+
passageIndex: t.number.isRequired,
|
|
23
|
+
uploadSoundSupport: t.object.isRequired
|
|
24
|
+
};
|
|
25
|
+
static defaultProps = { passageIndex: 0 };
|
|
26
|
+
constructor(e) {
|
|
27
|
+
super(e);
|
|
28
|
+
}
|
|
29
|
+
handleChange = (e, t) => {
|
|
30
|
+
let { model: n, onModelChanged: r, passageIndex: i } = this.props;
|
|
31
|
+
if (!n.passages || i < 0 || i >= n.passages.length) return;
|
|
32
|
+
let a = [...n.passages];
|
|
33
|
+
a[i] = {
|
|
34
|
+
...a[i],
|
|
35
|
+
[e]: t
|
|
36
|
+
}, r({
|
|
37
|
+
...n,
|
|
38
|
+
passages: a
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
render() {
|
|
42
|
+
let { model: t, configuration: n, imageSupport: a, passageIndex: u, uploadSoundSupport: d } = this.props, { maxImageWidth: f = {}, maxImageHeight: p = {}, mathMlOptions: m = {}, baseInputConfiguration: h = {}, teacherInstructions: g = {}, title: _ = {}, subtitle: v = {}, text: y = {}, author: b = {} } = n || {}, { errors: x = {}, passages: S = [], teacherInstructionsEnabled: C, titleEnabled: w, subtitleEnabled: T, authorEnabled: E, textEnabled: D } = t || {}, { passages: O } = x || {}, { teacherInstructions: k, title: A, subtitle: j, author: M, text: N } = O && O[u] || {}, P = f && f.prompt, F = p && p.prompt, I = (e) => ({
|
|
43
|
+
...h,
|
|
44
|
+
...e
|
|
45
|
+
}), L = (s || []).filter((e) => ![
|
|
46
|
+
"math",
|
|
47
|
+
"table",
|
|
48
|
+
"bulleted-list",
|
|
49
|
+
"numbered-list"
|
|
50
|
+
].includes(e));
|
|
51
|
+
return /* @__PURE__ */ i(e.Fragment, { children: [
|
|
52
|
+
C && /* @__PURE__ */ i(c, {
|
|
53
|
+
label: g.label,
|
|
54
|
+
children: [/* @__PURE__ */ r(o, {
|
|
55
|
+
activePlugins: s,
|
|
56
|
+
markup: S[u].teacherInstructions || "",
|
|
57
|
+
onChange: (e) => this.handleChange("teacherInstructions", e),
|
|
58
|
+
nonEmpty: !1,
|
|
59
|
+
error: k,
|
|
60
|
+
maxImageWidth: f && f.teacherInstructions || P,
|
|
61
|
+
maxImageHeight: p && p.teacherInstructions || F,
|
|
62
|
+
mathMlOptions: m,
|
|
63
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
64
|
+
pluginProps: I(g?.inputConfiguration)
|
|
65
|
+
}), k && /* @__PURE__ */ r(l, { children: k })]
|
|
66
|
+
}),
|
|
67
|
+
w && /* @__PURE__ */ i(c, {
|
|
68
|
+
label: _.label,
|
|
69
|
+
children: [/* @__PURE__ */ r(o, {
|
|
70
|
+
activePlugins: L,
|
|
71
|
+
markup: S[u].title || "",
|
|
72
|
+
onChange: (e) => this.handleChange("title", e),
|
|
73
|
+
nonEmpty: !1,
|
|
74
|
+
error: A,
|
|
75
|
+
mathMlOptions: m,
|
|
76
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
77
|
+
pluginProps: I(_?.inputConfiguration)
|
|
78
|
+
}), A && /* @__PURE__ */ r(l, { children: A })]
|
|
79
|
+
}),
|
|
80
|
+
T && /* @__PURE__ */ i(c, {
|
|
81
|
+
label: v.label,
|
|
82
|
+
children: [/* @__PURE__ */ r(o, {
|
|
83
|
+
activePlugins: L,
|
|
84
|
+
markup: S[u].subtitle || "",
|
|
85
|
+
onChange: (e) => this.handleChange("subtitle", e),
|
|
86
|
+
nonEmpty: !1,
|
|
87
|
+
error: j,
|
|
88
|
+
mathMlOptions: m,
|
|
89
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
90
|
+
pluginProps: I(v?.inputConfiguration)
|
|
91
|
+
}), j && /* @__PURE__ */ r(l, { children: j })]
|
|
92
|
+
}),
|
|
93
|
+
E && /* @__PURE__ */ i(c, {
|
|
94
|
+
label: b.label,
|
|
95
|
+
children: [/* @__PURE__ */ r(o, {
|
|
96
|
+
activePlugins: L,
|
|
97
|
+
markup: S[u].author || "",
|
|
98
|
+
onChange: (e) => this.handleChange("author", e),
|
|
99
|
+
nonEmpty: !1,
|
|
100
|
+
error: M,
|
|
101
|
+
mathMlOptions: m,
|
|
102
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
103
|
+
pluginProps: I(b?.inputConfiguration)
|
|
104
|
+
}), M && /* @__PURE__ */ r(l, { children: M })]
|
|
105
|
+
}),
|
|
106
|
+
D && /* @__PURE__ */ i(c, {
|
|
107
|
+
label: y.label,
|
|
108
|
+
children: [/* @__PURE__ */ r(o, {
|
|
109
|
+
activePlugins: s,
|
|
110
|
+
markup: S[u].text || "",
|
|
111
|
+
onChange: (e) => this.handleChange("text", e),
|
|
112
|
+
imageSupport: a,
|
|
113
|
+
uploadSoundSupport: d,
|
|
114
|
+
nonEmpty: !1,
|
|
115
|
+
error: N,
|
|
116
|
+
maxImageWidth: f && f.text || P,
|
|
117
|
+
maxImageHeight: p && p.text || F,
|
|
118
|
+
mathMlOptions: m,
|
|
119
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
120
|
+
pluginProps: I(y?.inputConfiguration)
|
|
121
|
+
}), N && /* @__PURE__ */ r(l, { children: N })]
|
|
122
|
+
})
|
|
123
|
+
] });
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
//#endregion
|
|
127
|
+
export { u as default };
|
|
@@ -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;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import n from "@mui/material/Tabs";
|
|
4
|
+
import r from "@mui/material/Tab";
|
|
5
|
+
import { styled as i } from "@mui/material/styles";
|
|
6
|
+
import * as a from "@pie-lib/render-ui";
|
|
7
|
+
import { Collapsible as o, PreviewPrompt as s, Purpose as c, UiLayout as l, color as u, transformDataHeadings as d } from "@pie-lib/render-ui";
|
|
8
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
9
|
+
//#region src/delivery/stimulus-tabs.tsx
|
|
10
|
+
function h(e) {
|
|
11
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
12
|
+
}
|
|
13
|
+
function g(e, t) {
|
|
14
|
+
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;
|
|
15
|
+
}
|
|
16
|
+
var _ = g(l, "UiLayout") || g(C.UiLayout, "UiLayout"), v = g(c, "Purpose") || g(C.Purpose, "Purpose"), y = g(s, "PreviewPrompt") || g(C.PreviewPrompt, "PreviewPrompt"), b = g(o, "Collapsible") || g(C.Collapsible, "Collapsible"), x = a, S = x.default, C = S && typeof S == "object" ? S : x, w = i("div")({
|
|
17
|
+
flexGrow: 1,
|
|
18
|
+
backgroundColor: u.background(),
|
|
19
|
+
color: u.text(),
|
|
20
|
+
"&:not(.MathJax) table": { borderCollapse: "collapse" },
|
|
21
|
+
"&:not(.MathJax) table td, &:not(.MathJax) table th": {
|
|
22
|
+
padding: ".6em 1em",
|
|
23
|
+
textAlign: "left"
|
|
24
|
+
}
|
|
25
|
+
}), T = i("div")(({ theme: e }) => ({
|
|
26
|
+
backgroundColor: u.background(),
|
|
27
|
+
color: u.text(),
|
|
28
|
+
padding: e.spacing(2),
|
|
29
|
+
"& blockquote": {
|
|
30
|
+
background: "#f9f9f9",
|
|
31
|
+
borderLeft: "5px solid #ccc",
|
|
32
|
+
margin: "1.5em 10px",
|
|
33
|
+
padding: ".5em 10px"
|
|
34
|
+
}
|
|
35
|
+
})), E = i("div")({ fontSize: "1.75rem" }), D = i("div")({ fontSize: "1.5rem" }), O = i("div")({ fontSize: "1.25rem" }), k = i(r)(({ theme: e }) => ({
|
|
36
|
+
background: e.palette.common.white,
|
|
37
|
+
fontSize: "inherit",
|
|
38
|
+
fontFamily: "Roboto, sans-serif",
|
|
39
|
+
color: e.palette.common.black,
|
|
40
|
+
borderRadius: `${e.spacing(2)} ${e.spacing(2)} 0 0`,
|
|
41
|
+
border: "1px solid #D9DADA",
|
|
42
|
+
borderBottomWidth: 0,
|
|
43
|
+
minHeight: "56px",
|
|
44
|
+
padding: "8px 10px",
|
|
45
|
+
display: "flex",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
justifyContent: "center",
|
|
48
|
+
margin: `0 ${e.spacing(1)}`,
|
|
49
|
+
textTransform: "none",
|
|
50
|
+
".passage-label": {
|
|
51
|
+
display: "-webkit-box",
|
|
52
|
+
WebkitLineClamp: 2,
|
|
53
|
+
WebkitBoxOrient: "vertical",
|
|
54
|
+
overflow: "hidden",
|
|
55
|
+
textOverflow: "ellipsis",
|
|
56
|
+
whiteSpace: "normal",
|
|
57
|
+
margin: "auto 0",
|
|
58
|
+
opacity: .7
|
|
59
|
+
},
|
|
60
|
+
"&.Mui-selected": {
|
|
61
|
+
color: e.palette.common.black,
|
|
62
|
+
".passage-label": { opacity: 1 },
|
|
63
|
+
".passage-label-underline": { backgroundColor: "#146EB3" }
|
|
64
|
+
},
|
|
65
|
+
"&:hover": { ".passage-label-underline": { backgroundColor: "#D0E2F0" } },
|
|
66
|
+
"& .MuiTouchRipple-root": { opacity: .7 }
|
|
67
|
+
})), A = i("div")(({ theme: e }) => ({
|
|
68
|
+
height: "2px",
|
|
69
|
+
width: "100%",
|
|
70
|
+
marginTop: "6px",
|
|
71
|
+
background: e.palette.common.white
|
|
72
|
+
})), j = class extends e.Component {
|
|
73
|
+
state = { activeTab: 0 };
|
|
74
|
+
handleChange = (e, t) => {
|
|
75
|
+
this.setState(() => ({ activeTab: t })), setTimeout(() => {
|
|
76
|
+
let e = new CustomEvent("pie-ui-passage-tabChanged", { detail: { tab: t } });
|
|
77
|
+
window.dispatchEvent(e);
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
handleKeyDown = (e, t) => {
|
|
81
|
+
let { key: n } = e, { tabs: r } = this.props, i = -1, a = r.findIndex((e) => e.id === t);
|
|
82
|
+
switch (n) {
|
|
83
|
+
case "ArrowRight":
|
|
84
|
+
i = (a + 1) % r.length;
|
|
85
|
+
break;
|
|
86
|
+
case "ArrowLeft":
|
|
87
|
+
i = (a - 1 + r.length) % r.length;
|
|
88
|
+
break;
|
|
89
|
+
case "Home":
|
|
90
|
+
i = 0;
|
|
91
|
+
break;
|
|
92
|
+
case "End":
|
|
93
|
+
i = r.length - 1;
|
|
94
|
+
break;
|
|
95
|
+
case "Enter":
|
|
96
|
+
case " ":
|
|
97
|
+
i = a;
|
|
98
|
+
break;
|
|
99
|
+
default: break;
|
|
100
|
+
}
|
|
101
|
+
i !== -1 && (e.preventDefault(), e.stopPropagation(), this.handleChange(e, r[i].id), document.getElementById(`button-${r[i].id}`).focus());
|
|
102
|
+
};
|
|
103
|
+
parsedText = (e = "") => {
|
|
104
|
+
let t = document.createElement("div");
|
|
105
|
+
t.innerHTML = e.replace(/(<br\/>\n)/g, "<br/>");
|
|
106
|
+
let n = t.querySelector("audio");
|
|
107
|
+
if (n) {
|
|
108
|
+
let e = document.createElement("source");
|
|
109
|
+
e.setAttribute("type", "audio/mp3"), e.setAttribute("src", n.getAttribute("src")), n.removeAttribute("src"), n.appendChild(e);
|
|
110
|
+
}
|
|
111
|
+
return t.innerHTML;
|
|
112
|
+
};
|
|
113
|
+
renderInstructions(e, t = !1) {
|
|
114
|
+
if (!e) return;
|
|
115
|
+
let n = /* @__PURE__ */ p(y, {
|
|
116
|
+
tagName: "div",
|
|
117
|
+
className: "prompt",
|
|
118
|
+
defaultClassName: "teacher-instructions",
|
|
119
|
+
prompt: e
|
|
120
|
+
});
|
|
121
|
+
return t ? n : /* @__PURE__ */ p(b, {
|
|
122
|
+
labels: {
|
|
123
|
+
hidden: "Show Teacher Instructions",
|
|
124
|
+
visible: "Hide Teacher Instructions"
|
|
125
|
+
},
|
|
126
|
+
children: n
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
renderTab(e, t) {
|
|
130
|
+
let { baseHeadingLevel: n } = this.props, r = n ? Math.min(6, Math.max(1, n)) : void 0, i = n ? `h${r}` : "h2", a = n ? Math.min(6, Math.max(1, r + 1)) : void 0;
|
|
131
|
+
return /* @__PURE__ */ m(T, {
|
|
132
|
+
id: `tabpanel-${e.id}`,
|
|
133
|
+
role: "tabpanel",
|
|
134
|
+
"aria-labelledby": `button-${e.id}`,
|
|
135
|
+
children: [
|
|
136
|
+
this.renderInstructions(e.teacherInstructions, t),
|
|
137
|
+
e.title && /* @__PURE__ */ p(v, {
|
|
138
|
+
purpose: "passage-title",
|
|
139
|
+
children: /* @__PURE__ */ p(i, { children: /* @__PURE__ */ p(E, { dangerouslySetInnerHTML: { __html: this.parsedText(e.title) } }) })
|
|
140
|
+
}),
|
|
141
|
+
e.subtitle && /* @__PURE__ */ p(v, {
|
|
142
|
+
purpose: "passage-subtitle",
|
|
143
|
+
children: /* @__PURE__ */ p(D, { dangerouslySetInnerHTML: { __html: this.parsedText(e.subtitle) } })
|
|
144
|
+
}),
|
|
145
|
+
e.author && /* @__PURE__ */ p(v, {
|
|
146
|
+
purpose: "passage-author",
|
|
147
|
+
children: /* @__PURE__ */ p(O, {
|
|
148
|
+
className: "author",
|
|
149
|
+
dangerouslySetInnerHTML: { __html: this.parsedText(e.author) }
|
|
150
|
+
})
|
|
151
|
+
}),
|
|
152
|
+
e.text && /* @__PURE__ */ p(v, {
|
|
153
|
+
purpose: "passage-text",
|
|
154
|
+
children: /* @__PURE__ */ p("div", {
|
|
155
|
+
className: "text",
|
|
156
|
+
dangerouslySetInnerHTML: { __html: n ? d(e.text, a) : e.text }
|
|
157
|
+
}, e.id)
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
}, e.id);
|
|
161
|
+
}
|
|
162
|
+
render() {
|
|
163
|
+
let { model: e, tabs: t, disabledTabs: r } = this.props, { activeTab: i } = this.state;
|
|
164
|
+
if (!t?.length) return;
|
|
165
|
+
let { extraCSSRules: a } = e || {}, o = (t || []).find((e) => e.id === i);
|
|
166
|
+
return /* @__PURE__ */ p(_, {
|
|
167
|
+
extraCSSRules: a,
|
|
168
|
+
children: /* @__PURE__ */ p(w, {
|
|
169
|
+
className: "passages",
|
|
170
|
+
children: r || t.length === 1 ? t.map((e) => this.renderTab(e, r)) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(n, {
|
|
171
|
+
sx: {
|
|
172
|
+
position: "sticky",
|
|
173
|
+
top: 0,
|
|
174
|
+
background: u.background(),
|
|
175
|
+
color: u.text(),
|
|
176
|
+
fontFamily: "Roboto, sans-serif",
|
|
177
|
+
"& .MuiTabs-list": { borderBottom: "1px solid #D9DADA" },
|
|
178
|
+
"& .MuiTabs-indicator": {
|
|
179
|
+
backgroundColor: "#ffffff",
|
|
180
|
+
marginBottom: "-1px"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
value: i,
|
|
184
|
+
onChange: this.handleChange,
|
|
185
|
+
children: t.map((e) => /* @__PURE__ */ p(k, {
|
|
186
|
+
id: `button-${e.id}`,
|
|
187
|
+
label: /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(v, {
|
|
188
|
+
purpose: "passage-label",
|
|
189
|
+
children: /* @__PURE__ */ p("span", {
|
|
190
|
+
className: "passage-label",
|
|
191
|
+
dangerouslySetInnerHTML: { __html: this.parsedText(e.label) }
|
|
192
|
+
})
|
|
193
|
+
}), /* @__PURE__ */ p(A, { className: "passage-label-underline" })] }),
|
|
194
|
+
value: e.id,
|
|
195
|
+
tabIndex: i === e.id ? 0 : -1,
|
|
196
|
+
"aria-controls": `tabpanel-${e.id}`,
|
|
197
|
+
"aria-selected": i === e.id,
|
|
198
|
+
onKeyDown: (t) => this.handleKeyDown(t, e.id)
|
|
199
|
+
}, e.id))
|
|
200
|
+
}), o ? this.renderTab(o, r) : null] })
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
j.propTypes = {
|
|
206
|
+
tabs: t.arrayOf(t.shape({
|
|
207
|
+
id: t.number.isRequired,
|
|
208
|
+
label: t.string.isRequired,
|
|
209
|
+
title: t.string.isRequired,
|
|
210
|
+
subtitle: t.string,
|
|
211
|
+
author: t.string,
|
|
212
|
+
text: t.string.isRequired,
|
|
213
|
+
teacherInstructions: t.string
|
|
214
|
+
}).isRequired).isRequired,
|
|
215
|
+
disabledTabs: t.bool,
|
|
216
|
+
model: t.object,
|
|
217
|
+
baseHeadingLevel: t.number
|
|
218
|
+
};
|
|
219
|
+
//#endregion
|
|
220
|
+
export { j as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './delivery/index.js';
|