@pie-element/passage 7.4.4 → 8.0.0-next.20261002094057

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.
Files changed (109) hide show
  1. package/author.js +2 -0
  2. package/configure.js +2 -0
  3. package/controller.js +1 -0
  4. package/dist/author/common.d.ts +36 -0
  5. package/dist/author/common.js +57 -0
  6. package/dist/author/defaults.d.ts +175 -0
  7. package/dist/author/defaults.js +113 -0
  8. package/dist/author/design.d.ts +28 -0
  9. package/dist/author/design.js +120 -0
  10. package/dist/author/index.d.ts +36 -0
  11. package/dist/author/index.js +66 -0
  12. package/dist/author/passage.d.ts +27 -0
  13. package/dist/author/passage.js +127 -0
  14. package/dist/browser/assets/Symbola-4c507403.woff2 +0 -0
  15. package/dist/browser/author/index.js +34161 -0
  16. package/dist/browser/author/index.js.map +1 -0
  17. package/dist/browser/controller/index.js +64 -0
  18. package/dist/browser/controller/index.js.map +1 -0
  19. package/dist/browser/delivery/index.js +117 -0
  20. package/dist/browser/delivery/index.js.map +1 -0
  21. package/dist/browser/dist-BtyOUh0E.js +9737 -0
  22. package/dist/browser/dist-BtyOUh0E.js.map +1 -0
  23. package/dist/browser/dist-CiWlBjsz.js +92 -0
  24. package/dist/browser/dist-CiWlBjsz.js.map +1 -0
  25. package/dist/browser/editor-runtime/assets/Symbola-4c507403.woff2 +0 -0
  26. package/dist/browser/editor-runtime/author/index.js +17752 -0
  27. package/dist/browser/editor-runtime/author/index.js.map +1 -0
  28. package/dist/browser/editor-runtime/controller/index.js +64 -0
  29. package/dist/browser/editor-runtime/controller/index.js.map +1 -0
  30. package/dist/browser/editor-runtime/delivery/index.js +117 -0
  31. package/dist/browser/editor-runtime/delivery/index.js.map +1 -0
  32. package/dist/browser/editor-runtime/dist-Ba_6pEHz.js +9737 -0
  33. package/dist/browser/editor-runtime/dist-Ba_6pEHz.js.map +1 -0
  34. package/dist/browser/editor-runtime/dist-CiWlBjsz.js +92 -0
  35. package/dist/browser/editor-runtime/dist-CiWlBjsz.js.map +1 -0
  36. package/dist/browser/editor-runtime/print/index.js +51 -0
  37. package/dist/browser/editor-runtime/print/index.js.map +1 -0
  38. package/dist/browser/editor-runtime/rolldown-runtime-CHQKHQ89.js +32 -0
  39. package/dist/browser/editor-runtime/stimulus-tabs-41Y6tEn5.js +256 -0
  40. package/dist/browser/editor-runtime/stimulus-tabs-41Y6tEn5.js.map +1 -0
  41. package/dist/browser/print/index.js +51 -0
  42. package/dist/browser/print/index.js.map +1 -0
  43. package/dist/browser/rolldown-runtime-CWhphoD1.js +32 -0
  44. package/dist/browser/stimulus-tabs-DVM_5xjR.js +256 -0
  45. package/dist/browser/stimulus-tabs-DVM_5xjR.js.map +1 -0
  46. package/dist/controller/defaults.d.ts +23 -0
  47. package/dist/controller/defaults.js +17 -0
  48. package/dist/controller/index.d.ts +18 -0
  49. package/dist/controller/index.js +50 -0
  50. package/dist/delivery/index.d.ts +22 -0
  51. package/dist/delivery/index.js +83 -0
  52. package/dist/delivery/stimulus-tabs.d.ts +28 -0
  53. package/dist/delivery/stimulus-tabs.js +257 -0
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.iife.d.ts +8 -0
  56. package/dist/index.iife.js +145 -0
  57. package/dist/index.js +2 -0
  58. package/dist/print/index.d.ts +15 -0
  59. package/dist/print/index.js +49 -0
  60. package/dist/runtime-support.d.ts +12 -0
  61. package/dist/runtime-support.js +12 -0
  62. package/module/print.js +15919 -1
  63. package/module/print.js.map +1 -0
  64. package/package.json +104 -20
  65. package/print.js +2 -0
  66. package/CHANGELOG.json +0 -227
  67. package/CHANGELOG.md +0 -1552
  68. package/LICENSE.md +0 -5
  69. package/README.md +0 -3
  70. package/configure/CHANGELOG.md +0 -756
  71. package/configure/lib/common.js +0 -74
  72. package/configure/lib/common.js.map +0 -1
  73. package/configure/lib/defaults.js +0 -174
  74. package/configure/lib/defaults.js.map +0 -1
  75. package/configure/lib/design.js +0 -185
  76. package/configure/lib/design.js.map +0 -1
  77. package/configure/lib/index.js +0 -87
  78. package/configure/lib/index.js.map +0 -1
  79. package/configure/lib/passage.js +0 -194
  80. package/configure/lib/passage.js.map +0 -1
  81. package/configure/package.json +0 -23
  82. package/controller/CHANGELOG.json +0 -1
  83. package/controller/CHANGELOG.md +0 -121
  84. package/controller/lib/defaults.js +0 -23
  85. package/controller/lib/defaults.js.map +0 -1
  86. package/controller/lib/index.js +0 -80
  87. package/controller/lib/index.js.map +0 -1
  88. package/controller/package.json +0 -13
  89. package/docs/config-schema.json +0 -1325
  90. package/docs/config-schema.json.md +0 -974
  91. package/docs/demo/config.js +0 -8
  92. package/docs/demo/generate.js +0 -32
  93. package/docs/demo/index.html +0 -1
  94. package/docs/pie-schema.json +0 -775
  95. package/docs/pie-schema.json.md +0 -561
  96. package/lib/index.js +0 -144
  97. package/lib/index.js.map +0 -1
  98. package/lib/print.js +0 -78
  99. package/lib/print.js.map +0 -1
  100. package/lib/stimulus-tabs.js +0 -451
  101. package/lib/stimulus-tabs.js.map +0 -1
  102. package/module/configure.js +0 -1
  103. package/module/controller.js +0 -920
  104. package/module/demo.js +0 -57
  105. package/module/element.js +0 -1
  106. package/module/index.html +0 -21
  107. package/module/manifest.json +0 -14
  108. package/module/print-demo.js +0 -95
  109. package/module/print.html +0 -18
@@ -0,0 +1,257 @@
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 = 2, T = .4, E = 170, D = () => {
17
+ if (typeof window > "u") return 1;
18
+ let e = window.outerWidth / window.innerWidth;
19
+ return Math.max(T, Math.min(1, w / (Number.isFinite(e) && e > 0 ? e : 1)));
20
+ }, O = i("div")({
21
+ flexGrow: 1,
22
+ backgroundColor: u.background(),
23
+ color: u.text(),
24
+ "&:not(.MathJax) table": { borderCollapse: "collapse" },
25
+ "&:not(.MathJax) table td, &:not(.MathJax) table th": {
26
+ padding: ".6em 1em",
27
+ textAlign: "left"
28
+ }
29
+ }), k = i("div")(({ theme: e }) => ({
30
+ backgroundColor: u.background(),
31
+ color: u.text(),
32
+ padding: e.spacing(2),
33
+ "& blockquote": {
34
+ background: "#f9f9f9",
35
+ borderLeft: "5px solid #ccc",
36
+ margin: "1.5em 10px",
37
+ padding: ".5em 10px"
38
+ }
39
+ })), A = i("div")({ fontSize: "1.75rem" }), j = i("div")({ fontSize: "1.5rem" }), M = i("div")({ fontSize: "1.25rem" }), N = i(r)(({ theme: e }) => ({
40
+ background: u.background(),
41
+ fontSize: "inherit",
42
+ fontFamily: "Roboto, sans-serif",
43
+ color: u.text(),
44
+ borderRadius: `${e.spacing(2)} ${e.spacing(2)} 0 0`,
45
+ border: `1px solid ${u.borderGray()}`,
46
+ borderBottomWidth: 0,
47
+ minHeight: "56px",
48
+ padding: "8px 10px",
49
+ display: "flex",
50
+ alignItems: "center",
51
+ justifyContent: "center",
52
+ margin: `0 ${e.spacing(1)}`,
53
+ textTransform: "none",
54
+ ".passage-label": {
55
+ display: "-webkit-box",
56
+ WebkitLineClamp: 2,
57
+ WebkitBoxOrient: "vertical",
58
+ overflow: "hidden",
59
+ textOverflow: "ellipsis",
60
+ whiteSpace: "normal",
61
+ margin: "auto 0",
62
+ opacity: .7
63
+ },
64
+ "&.Mui-selected": {
65
+ color: u.text(),
66
+ ".passage-label": { opacity: 1 },
67
+ ".passage-label-underline": { backgroundColor: u.tertiary() }
68
+ },
69
+ "&:hover": { ".passage-label-underline": { backgroundColor: u.tertiaryLight() } },
70
+ "& .MuiTouchRipple-root": { opacity: .7 }
71
+ })), P = i("div")(() => ({
72
+ height: "2px",
73
+ width: "100%",
74
+ marginTop: "6px",
75
+ background: u.background()
76
+ })), F = class extends e.Component {
77
+ state = {
78
+ activeTab: 0,
79
+ zoomCompensation: D(),
80
+ containerWidth: 0
81
+ };
82
+ containerRef = e.createRef();
83
+ componentDidMount() {
84
+ typeof window > "u" || (window.addEventListener("resize", this.updateZoomCompensation), this.containerRef.current && typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(this.updateContainerWidth), this.resizeObserver.observe(this.containerRef.current)), this.updateContainerWidth());
85
+ }
86
+ componentWillUnmount() {
87
+ typeof window > "u" || (window.removeEventListener("resize", this.updateZoomCompensation), this.resizeObserver &&= (this.resizeObserver.disconnect(), null));
88
+ }
89
+ updateZoomCompensation = () => {
90
+ this.setState({ zoomCompensation: D() });
91
+ };
92
+ updateContainerWidth = () => {
93
+ let e = this.containerRef.current;
94
+ if (!e) return;
95
+ let t = e.clientWidth;
96
+ t !== this.state.containerWidth && this.setState({ containerWidth: t });
97
+ };
98
+ handleChange = (e, t) => {
99
+ this.setState(() => ({ activeTab: t })), setTimeout(() => {
100
+ let e = new CustomEvent("pie-ui-passage-tabChanged", { detail: { tab: t } });
101
+ window.dispatchEvent(e);
102
+ });
103
+ };
104
+ handleKeyDown = (e, t) => {
105
+ let { key: n } = e, { tabs: r } = this.props, i = -1, a = r.findIndex((e) => e.id === t);
106
+ switch (n) {
107
+ case "ArrowRight":
108
+ i = (a + 1) % r.length;
109
+ break;
110
+ case "ArrowLeft":
111
+ i = (a - 1 + r.length) % r.length;
112
+ break;
113
+ case "Home":
114
+ i = 0;
115
+ break;
116
+ case "End":
117
+ i = r.length - 1;
118
+ break;
119
+ case "Enter":
120
+ case " ":
121
+ i = a;
122
+ break;
123
+ default: break;
124
+ }
125
+ i !== -1 && (e.preventDefault(), e.stopPropagation(), this.handleChange(e, r[i].id), document.getElementById(`button-${r[i].id}`).focus());
126
+ };
127
+ parsedText = (e = "") => {
128
+ let t = document.createElement("div");
129
+ t.innerHTML = e.replace(/(<br\/>\n)/g, "<br/>");
130
+ let n = t.querySelector("audio");
131
+ if (n) {
132
+ let e = document.createElement("source");
133
+ e.setAttribute("type", "audio/mp3"), e.setAttribute("src", n.getAttribute("src")), n.removeAttribute("src"), n.appendChild(e);
134
+ }
135
+ return t.innerHTML;
136
+ };
137
+ renderInstructions(e, t = !1) {
138
+ if (!e) return;
139
+ let n = /* @__PURE__ */ p(y, {
140
+ tagName: "div",
141
+ className: "prompt",
142
+ defaultClassName: "teacher-instructions",
143
+ prompt: e
144
+ });
145
+ return t ? n : /* @__PURE__ */ p(b, {
146
+ labels: {
147
+ hidden: "Show Teacher Instructions",
148
+ visible: "Hide Teacher Instructions"
149
+ },
150
+ children: n
151
+ });
152
+ }
153
+ renderTab(e, t) {
154
+ 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;
155
+ return /* @__PURE__ */ m(k, {
156
+ id: `tabpanel-${e.id}`,
157
+ role: "tabpanel",
158
+ "aria-labelledby": `button-${e.id}`,
159
+ children: [
160
+ this.renderInstructions(e.teacherInstructions, t),
161
+ e.title && /* @__PURE__ */ p(v, {
162
+ purpose: "passage-title",
163
+ children: /* @__PURE__ */ p(i, { children: /* @__PURE__ */ p(A, { dangerouslySetInnerHTML: { __html: this.parsedText(e.title) } }) })
164
+ }),
165
+ e.subtitle && /* @__PURE__ */ p(v, {
166
+ purpose: "passage-subtitle",
167
+ children: /* @__PURE__ */ p(j, { dangerouslySetInnerHTML: { __html: this.parsedText(e.subtitle) } })
168
+ }),
169
+ e.author && /* @__PURE__ */ p(v, {
170
+ purpose: "passage-author",
171
+ children: /* @__PURE__ */ p(M, {
172
+ className: "author",
173
+ dangerouslySetInnerHTML: { __html: this.parsedText(e.author) }
174
+ })
175
+ }),
176
+ e.text && /* @__PURE__ */ p(v, {
177
+ purpose: "passage-text",
178
+ children: /* @__PURE__ */ p("div", {
179
+ className: "text",
180
+ dangerouslySetInnerHTML: { __html: n ? d(e.text, a) : e.text }
181
+ }, e.id)
182
+ })
183
+ ]
184
+ }, e.id);
185
+ }
186
+ render() {
187
+ let { model: e, tabs: t, disabledTabs: r } = this.props, { activeTab: i, zoomCompensation: a, containerWidth: o } = this.state;
188
+ if (!t?.length) return;
189
+ let { extraCSSRules: s } = e || {}, c = (t || []).find((e) => e.id === i), l = o > 0 ? o / t.length : null, d = o > 0 && o <= t.length * E;
190
+ return /* @__PURE__ */ p(_, {
191
+ extraCSSRules: s,
192
+ children: /* @__PURE__ */ p(O, {
193
+ className: "passages",
194
+ ref: this.containerRef,
195
+ children: r || t.length === 1 ? t.map((e) => this.renderTab(e, r)) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(n, {
196
+ sx: {
197
+ position: "static",
198
+ "@media (min-width: 841px)": {
199
+ position: "sticky",
200
+ top: 0,
201
+ zIndex: 1
202
+ },
203
+ background: "var(--pie-passage-header-background, rgba(255,255,255,0))",
204
+ color: u.text(),
205
+ fontFamily: "Roboto, sans-serif",
206
+ zoom: a,
207
+ "& .MuiTabs-list": {
208
+ backgroundColor: `var(--pie-passage-header-background, ${u.backgroundDark()})`,
209
+ borderBottom: `1px solid ${u.borderGray()}`
210
+ },
211
+ "& .MuiTabs-indicator": {
212
+ backgroundColor: u.white(),
213
+ marginBottom: "-1px"
214
+ }
215
+ },
216
+ value: i,
217
+ onChange: this.handleChange,
218
+ children: t.map((e, t) => /* @__PURE__ */ p(N, {
219
+ id: `button-${e.id}`,
220
+ sx: l ? { maxWidth: `${l}px` } : void 0,
221
+ label: /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(v, {
222
+ purpose: "passage-label",
223
+ children: d ? /* @__PURE__ */ p("span", {
224
+ className: "passage-label",
225
+ children: `Passage ${t + 1}`
226
+ }) : /* @__PURE__ */ p("span", {
227
+ className: "passage-label",
228
+ dangerouslySetInnerHTML: { __html: this.parsedText(e.label) }
229
+ })
230
+ }), /* @__PURE__ */ p(P, { className: "passage-label-underline" })] }),
231
+ value: e.id,
232
+ tabIndex: i === e.id ? 0 : -1,
233
+ "aria-controls": `tabpanel-${e.id}`,
234
+ "aria-selected": i === e.id,
235
+ onKeyDown: (t) => this.handleKeyDown(t, e.id)
236
+ }, e.id))
237
+ }), c ? this.renderTab(c, r) : null] })
238
+ })
239
+ });
240
+ }
241
+ };
242
+ F.propTypes = {
243
+ tabs: t.arrayOf(t.shape({
244
+ id: t.number.isRequired,
245
+ label: t.string.isRequired,
246
+ title: t.string.isRequired,
247
+ subtitle: t.string,
248
+ author: t.string,
249
+ text: t.string.isRequired,
250
+ teacherInstructions: t.string
251
+ }).isRequired).isRequired,
252
+ disabledTabs: t.bool,
253
+ model: t.object,
254
+ baseHeadingLevel: t.number
255
+ };
256
+ //#endregion
257
+ export { F as default };
@@ -0,0 +1 @@
1
+ export { default } from './delivery/index.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * IIFE entry point for passage element
3
+ * This file is only used for IIFE builds and includes auto-registration
4
+ *
5
+ * @sync-generated - Auto-generated during sync from pie-elements
6
+ */
7
+ import Element from './index.js';
8
+ export default Element;