@pie-element/passage 7.1.2-next.2 → 7.1.2-next.20

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 (49) hide show
  1. package/author.js +2 -0
  2. package/dist/author/common.js +6 -5
  3. package/dist/author/design.js +2 -2
  4. package/dist/author/index.js +2 -2
  5. package/dist/author/passage.js +1 -1
  6. package/dist/browser/assets/Symbola-4c507403.woff2 +0 -0
  7. package/dist/browser/author/index.js +15493 -20147
  8. package/dist/browser/author/index.js.map +1 -1
  9. package/dist/browser/controller/index.js +1 -1
  10. package/dist/browser/controller/index.js.map +1 -1
  11. package/dist/browser/delivery/index.js +3 -3
  12. package/dist/browser/delivery/index.js.map +1 -1
  13. package/dist/browser/{dist-4njad0Sq.js → dist-CYdikT5f.js} +2700 -2721
  14. package/dist/browser/dist-CYdikT5f.js.map +1 -0
  15. package/dist/browser/{dist-BC24ne2o.js → dist-CiWlBjsz.js} +6 -2
  16. package/dist/browser/dist-CiWlBjsz.js.map +1 -0
  17. package/dist/browser/editor-runtime/assets/Symbola-4c507403.woff2 +0 -0
  18. package/dist/browser/editor-runtime/author/index.js +17745 -0
  19. package/dist/browser/editor-runtime/author/index.js.map +1 -0
  20. package/dist/browser/editor-runtime/controller/index.js +64 -0
  21. package/dist/browser/editor-runtime/controller/index.js.map +1 -0
  22. package/dist/browser/editor-runtime/delivery/index.js +117 -0
  23. package/dist/browser/editor-runtime/delivery/index.js.map +1 -0
  24. package/dist/browser/editor-runtime/dist-CiWlBjsz.js +92 -0
  25. package/dist/browser/editor-runtime/dist-CiWlBjsz.js.map +1 -0
  26. package/dist/browser/editor-runtime/dist-VttbX_br.js +9597 -0
  27. package/dist/browser/editor-runtime/dist-VttbX_br.js.map +1 -0
  28. package/dist/browser/editor-runtime/print/index.js +49 -0
  29. package/dist/browser/editor-runtime/print/index.js.map +1 -0
  30. package/dist/browser/editor-runtime/rolldown-runtime-CHQKHQ89.js +32 -0
  31. package/dist/browser/{stimulus-tabs-sQwIoGOW.js → editor-runtime/stimulus-tabs-B90rlG-_.js} +81 -43
  32. package/dist/browser/editor-runtime/stimulus-tabs-B90rlG-_.js.map +1 -0
  33. package/dist/browser/print/index.js +4 -3
  34. package/dist/browser/print/index.js.map +1 -1
  35. package/dist/browser/rolldown-runtime-CWhphoD1.js +32 -0
  36. package/dist/browser/stimulus-tabs-md98WQf6.js +256 -0
  37. package/dist/browser/stimulus-tabs-md98WQf6.js.map +1 -0
  38. package/dist/delivery/index.js +1 -1
  39. package/dist/delivery/stimulus-tabs.d.ts +7 -0
  40. package/dist/delivery/stimulus-tabs.js +69 -32
  41. package/dist/index.iife.js +31 -31
  42. package/module/print.js +15809 -0
  43. package/module/print.js.map +1 -0
  44. package/package.json +43 -22
  45. package/print.js +2 -0
  46. package/dist/browser/dist-4njad0Sq.js.map +0 -1
  47. package/dist/browser/dist-BC24ne2o.js.map +0 -1
  48. package/dist/browser/passage.css +0 -2
  49. package/dist/browser/stimulus-tabs-sQwIoGOW.js.map +0 -1
@@ -0,0 +1,256 @@
1
+ import { i as e } from "./rolldown-runtime-CWhphoD1.js";
2
+ import { A as t, M as n, N as r, Q as i, a, b as o, h as s, o as c, s as l, t as u, wt as d } from "./dist-CYdikT5f.js";
3
+ import f from "react";
4
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
5
+ //#region src/delivery/stimulus-tabs.tsx
6
+ var g = /* @__PURE__ */ e(d(), 1);
7
+ function _(e) {
8
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
9
+ }
10
+ function v(e, t) {
11
+ return !e || _(e) ? e : _(e.default) ? e.default : t && _(e[t]) ? e[t] : t && _(e[t]?.default) ? e[t].default : e;
12
+ }
13
+ 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(o, "Collapsible") || v(T.Collapsible, "Collapsible"), C = u, w = C.default, T = w && typeof w == "object" ? w : C, E = 2, D = .4, O = 170, k = () => {
14
+ if (typeof window > "u") return 1;
15
+ let e = window.outerWidth / window.innerWidth;
16
+ return Math.max(D, Math.min(1, E / (Number.isFinite(e) && e > 0 ? e : 1)));
17
+ }, A = i("div")({
18
+ flexGrow: 1,
19
+ backgroundColor: t.background(),
20
+ color: t.text(),
21
+ "&:not(.MathJax) table": { borderCollapse: "collapse" },
22
+ "&:not(.MathJax) table td, &:not(.MathJax) table th": {
23
+ padding: ".6em 1em",
24
+ textAlign: "left"
25
+ }
26
+ }), j = i("div")(({ theme: e }) => ({
27
+ backgroundColor: t.background(),
28
+ color: t.text(),
29
+ padding: e.spacing(2),
30
+ "& blockquote": {
31
+ background: "#f9f9f9",
32
+ borderLeft: "5px solid #ccc",
33
+ margin: "1.5em 10px",
34
+ padding: ".5em 10px"
35
+ }
36
+ })), M = i("div")({ fontSize: "1.75rem" }), N = i("div")({ fontSize: "1.5rem" }), P = i("div")({ fontSize: "1.25rem" }), F = i(n)(({ theme: e }) => ({
37
+ background: t.background(),
38
+ fontSize: "inherit",
39
+ fontFamily: "Roboto, sans-serif",
40
+ color: t.text(),
41
+ borderRadius: `${e.spacing(2)} ${e.spacing(2)} 0 0`,
42
+ border: `1px solid ${t.borderGray()}`,
43
+ borderBottomWidth: 0,
44
+ minHeight: "56px",
45
+ padding: "8px 10px",
46
+ display: "flex",
47
+ alignItems: "center",
48
+ justifyContent: "center",
49
+ margin: `0 ${e.spacing(1)}`,
50
+ textTransform: "none",
51
+ ".passage-label": {
52
+ display: "-webkit-box",
53
+ WebkitLineClamp: 2,
54
+ WebkitBoxOrient: "vertical",
55
+ overflow: "hidden",
56
+ textOverflow: "ellipsis",
57
+ whiteSpace: "normal",
58
+ margin: "auto 0",
59
+ opacity: .7
60
+ },
61
+ "&.Mui-selected": {
62
+ color: t.text(),
63
+ ".passage-label": { opacity: 1 },
64
+ ".passage-label-underline": { backgroundColor: t.tertiary() }
65
+ },
66
+ "&:hover": { ".passage-label-underline": { backgroundColor: t.tertiaryLight() } },
67
+ "& .MuiTouchRipple-root": { opacity: .7 }
68
+ })), I = i("div")(() => ({
69
+ height: "2px",
70
+ width: "100%",
71
+ marginTop: "6px",
72
+ background: t.background()
73
+ })), L = class extends f.Component {
74
+ state = {
75
+ activeTab: 0,
76
+ zoomCompensation: k(),
77
+ containerWidth: 0
78
+ };
79
+ containerRef = f.createRef();
80
+ componentDidMount() {
81
+ 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());
82
+ }
83
+ componentWillUnmount() {
84
+ typeof window > "u" || (window.removeEventListener("resize", this.updateZoomCompensation), this.resizeObserver &&= (this.resizeObserver.disconnect(), null));
85
+ }
86
+ updateZoomCompensation = () => {
87
+ this.setState({ zoomCompensation: k() });
88
+ };
89
+ updateContainerWidth = () => {
90
+ let e = this.containerRef.current;
91
+ if (!e) return;
92
+ let t = e.clientWidth;
93
+ t !== this.state.containerWidth && this.setState({ containerWidth: t });
94
+ };
95
+ handleChange = (e, t) => {
96
+ this.setState(() => ({ activeTab: t })), setTimeout(() => {
97
+ let e = new CustomEvent("pie-ui-passage-tabChanged", { detail: { tab: t } });
98
+ window.dispatchEvent(e);
99
+ });
100
+ };
101
+ handleKeyDown = (e, t) => {
102
+ let { key: n } = e, { tabs: r } = this.props, i = -1, a = r.findIndex((e) => e.id === t);
103
+ switch (n) {
104
+ case "ArrowRight":
105
+ i = (a + 1) % r.length;
106
+ break;
107
+ case "ArrowLeft":
108
+ i = (a - 1 + r.length) % r.length;
109
+ break;
110
+ case "Home":
111
+ i = 0;
112
+ break;
113
+ case "End":
114
+ i = r.length - 1;
115
+ break;
116
+ case "Enter":
117
+ case " ":
118
+ i = a;
119
+ break;
120
+ default: break;
121
+ }
122
+ i !== -1 && (e.preventDefault(), e.stopPropagation(), this.handleChange(e, r[i].id), document.getElementById(`button-${r[i].id}`).focus());
123
+ };
124
+ parsedText = (e = "") => {
125
+ let t = document.createElement("div");
126
+ t.innerHTML = e.replace(/(<br\/>\n)/g, "<br/>");
127
+ let n = t.querySelector("audio");
128
+ if (n) {
129
+ let e = document.createElement("source");
130
+ e.setAttribute("type", "audio/mp3"), e.setAttribute("src", n.getAttribute("src")), n.removeAttribute("src"), n.appendChild(e);
131
+ }
132
+ return t.innerHTML;
133
+ };
134
+ renderInstructions(e, t = !1) {
135
+ if (!e) return;
136
+ let n = /* @__PURE__ */ m(x, {
137
+ tagName: "div",
138
+ className: "prompt",
139
+ defaultClassName: "teacher-instructions",
140
+ prompt: e
141
+ });
142
+ return t ? n : /* @__PURE__ */ m(S, {
143
+ labels: {
144
+ hidden: "Show Teacher Instructions",
145
+ visible: "Hide Teacher Instructions"
146
+ },
147
+ children: n
148
+ });
149
+ }
150
+ renderTab(e, t) {
151
+ let { baseHeadingLevel: n } = this.props, r = n ? Math.min(6, Math.max(1, n)) : void 0, i = n ? `h${r}` : "h2", o = n ? Math.min(6, Math.max(1, r + 1)) : void 0;
152
+ return /* @__PURE__ */ h(j, {
153
+ id: `tabpanel-${e.id}`,
154
+ role: "tabpanel",
155
+ "aria-labelledby": `button-${e.id}`,
156
+ children: [
157
+ this.renderInstructions(e.teacherInstructions, t),
158
+ e.title && /* @__PURE__ */ m(b, {
159
+ purpose: "passage-title",
160
+ children: /* @__PURE__ */ m(i, { children: /* @__PURE__ */ m(M, { dangerouslySetInnerHTML: { __html: this.parsedText(e.title) } }) })
161
+ }),
162
+ e.subtitle && /* @__PURE__ */ m(b, {
163
+ purpose: "passage-subtitle",
164
+ children: /* @__PURE__ */ m(N, { dangerouslySetInnerHTML: { __html: this.parsedText(e.subtitle) } })
165
+ }),
166
+ e.author && /* @__PURE__ */ m(b, {
167
+ purpose: "passage-author",
168
+ children: /* @__PURE__ */ m(P, {
169
+ className: "author",
170
+ dangerouslySetInnerHTML: { __html: this.parsedText(e.author) }
171
+ })
172
+ }),
173
+ e.text && /* @__PURE__ */ m(b, {
174
+ purpose: "passage-text",
175
+ children: /* @__PURE__ */ m("div", {
176
+ className: "text",
177
+ dangerouslySetInnerHTML: { __html: n ? a(e.text, o) : e.text }
178
+ }, e.id)
179
+ })
180
+ ]
181
+ }, e.id);
182
+ }
183
+ render() {
184
+ let { model: e, tabs: n, disabledTabs: i } = this.props, { activeTab: a, zoomCompensation: o, containerWidth: s } = this.state;
185
+ if (!n?.length) return;
186
+ let { extraCSSRules: c } = e || {}, l = (n || []).find((e) => e.id === a), u = s > 0 ? s / n.length : null, d = s > 0 && s <= n.length * O;
187
+ return /* @__PURE__ */ m(y, {
188
+ extraCSSRules: c,
189
+ children: /* @__PURE__ */ m(A, {
190
+ className: "passages",
191
+ ref: this.containerRef,
192
+ children: i || n.length === 1 ? n.map((e) => this.renderTab(e, i)) : /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(r, {
193
+ sx: {
194
+ position: "static",
195
+ "@media (min-width: 841px)": {
196
+ position: "sticky",
197
+ top: 0,
198
+ zIndex: 1
199
+ },
200
+ background: "var(--pie-passage-header-background, rgba(255,255,255,0))",
201
+ color: t.text(),
202
+ fontFamily: "Roboto, sans-serif",
203
+ zoom: o,
204
+ "& .MuiTabs-list": {
205
+ backgroundColor: `var(--pie-passage-header-background, ${t.backgroundDark()})`,
206
+ borderBottom: `1px solid ${t.borderGray()}`
207
+ },
208
+ "& .MuiTabs-indicator": {
209
+ backgroundColor: t.white(),
210
+ marginBottom: "-1px"
211
+ }
212
+ },
213
+ value: a,
214
+ onChange: this.handleChange,
215
+ children: n.map((e, t) => /* @__PURE__ */ m(F, {
216
+ id: `button-${e.id}`,
217
+ sx: u ? { maxWidth: `${u}px` } : void 0,
218
+ label: /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(b, {
219
+ purpose: "passage-label",
220
+ children: d ? /* @__PURE__ */ m("span", {
221
+ className: "passage-label",
222
+ children: `Passage ${t + 1}`
223
+ }) : /* @__PURE__ */ m("span", {
224
+ className: "passage-label",
225
+ dangerouslySetInnerHTML: { __html: this.parsedText(e.label) }
226
+ })
227
+ }), /* @__PURE__ */ m(I, { className: "passage-label-underline" })] }),
228
+ value: e.id,
229
+ tabIndex: a === e.id ? 0 : -1,
230
+ "aria-controls": `tabpanel-${e.id}`,
231
+ "aria-selected": a === e.id,
232
+ onKeyDown: (t) => this.handleKeyDown(t, e.id)
233
+ }, e.id))
234
+ }), l ? this.renderTab(l, i) : null] })
235
+ })
236
+ });
237
+ }
238
+ };
239
+ L.propTypes = {
240
+ tabs: g.default.arrayOf(g.default.shape({
241
+ id: g.default.number.isRequired,
242
+ label: g.default.string.isRequired,
243
+ title: g.default.string.isRequired,
244
+ subtitle: g.default.string,
245
+ author: g.default.string,
246
+ text: g.default.string.isRequired,
247
+ teacherInstructions: g.default.string
248
+ }).isRequired).isRequired,
249
+ disabledTabs: g.default.bool,
250
+ model: g.default.object,
251
+ baseHeadingLevel: g.default.number
252
+ };
253
+ //#endregion
254
+ export { L as t };
255
+
256
+ //# sourceMappingURL=stimulus-tabs-md98WQf6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stimulus-tabs-md98WQf6.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;\n// Must match the breakpoint Quiz Engine passes to the PIE section player for\n// switching from the side-by-side passage/question layout to the tabbed layout.\n// Below (and at) this width the passage tabs scroll with the passage content\n// instead of being locked to the top of the panel, so that they do not lock up\n// space needed for the passage text (WCAG 1.4.10 Reflow, 400% zoom / 320px).\nconst STICKY_TABS_BREAKPOINT = 840;\n\n/**\n * Zoom compensation for the passage selection tabs.\n *\n * The tabs scale naturally with browser zoom up to 200%. Beyond 200%,\n * we shrink their CSS size proportionally so their physical on-screen size\n * freezes at the 200% appearance, leaving more room for passage content\n * in high-zoom / small-window situations.\n * The factor is min(1, 2 / zoom): exactly 1 at zoom <= 200% (component\n * behavior unchanged), shrinking proportionally above that. A lower clamp\n * of 0.4 guards against inflated ratios (docked devtools, browser side\n * panels, window chrome) ever making the tabs unusably small.\n */\nconst MAX_TABS_ZOOM = 2;\nconst MIN_ZOOM_COMPENSATION = 0.4;\n\n// Per-tab horizontal-space floor in CSS pixels. When the passage container is\n// narrow enough that each tab would have at most this much room\n// (containerWidth <= tabs.length * NUMERIC_LABEL_MIN_WIDTH_PER_TAB), tab labels\n// fall back to \"Passage 1\", \"Passage 2\", ... so navigation stays usable instead\n// of being dominated by aggressively truncated titles.\nconst NUMERIC_LABEL_MIN_WIDTH_PER_TAB = 170;\n\nconst computeZoomCompensation = () => {\n if (typeof window === 'undefined') return 1;\n const ratio = window.outerWidth / window.innerWidth;\n const zoom = Number.isFinite(ratio) && ratio > 0 ? ratio : 1;\n return Math.max(MIN_ZOOM_COMPENSATION, Math.min(1, MAX_TABS_ZOOM / zoom));\n};\n\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 /*\n * The tab carries the colour of the panel it opens, which is what makes it read as a\n * tab rather than a button, and it has to be the themed panel colour: MUI's palette\n * does not follow `--pie-*`, so `common.white` here left the tab white on every color\n * scheme while the passage body beneath it went dark. The comment this replaces gated\n * the change on PD-2801, which is about OT's `color-contrast` class -- the mechanism\n * pie-theme superseded, and blocked since 2023.\n */\n background: color.background(),\n fontSize: 'inherit',\n fontFamily: 'Roboto, sans-serif',\n color: color.text(),\n borderRadius: `${theme.spacing(2)} ${theme.spacing(2)} 0 0`,\n /*\n * `--pie-border-gray` is stepped to the 3:1 non-text minimum in every scheme. The\n * literal it replaces measured about 1.2:1 against the dark schemes' surfaces, so the\n * tab outline -- the only thing separating an unselected tab from the strip -- was\n * invisible there.\n */\n border: `1px solid ${color.borderGray()}`,\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: color.text(),\n '.passage-label': {\n opacity: 1,\n },\n '.passage-label-underline': {\n backgroundColor: color.tertiary(),\n },\n },\n\n '&:hover': {\n '.passage-label-underline': {\n backgroundColor: color.tertiaryLight(),\n },\n },\n\n '& .MuiTouchRipple-root': {\n opacity: 0.7,\n },\n}));\n\n/*\n * The selection indicator, one per tab. Unselected it has to disappear into the tab, so it\n * paints the tab's own background rather than a fixed white; selected it becomes\n * `--pie-tertiary`, which every scheme sets.\n */\nconst Underline: any = styled('div')(() => ({\n height: '2px',\n width: '100%',\n marginTop: '6px',\n background: color.background(),\n}));\n\nclass StimulusTabs extends React.Component {\n state = {\n activeTab: 0,\n zoomCompensation: computeZoomCompensation(),\n containerWidth: 0,\n };\n\n containerRef = React.createRef();\n\n componentDidMount() {\n if (typeof window === 'undefined') return;\n window.addEventListener('resize', this.updateZoomCompensation);\n\n if (this.containerRef.current && typeof ResizeObserver !== 'undefined') {\n this.resizeObserver = new ResizeObserver(this.updateContainerWidth);\n this.resizeObserver.observe(this.containerRef.current);\n }\n\n this.updateContainerWidth();\n }\n\n componentWillUnmount() {\n if (typeof window === 'undefined') return;\n window.removeEventListener('resize', this.updateZoomCompensation);\n\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n this.resizeObserver = null;\n }\n }\n\n updateZoomCompensation: any = () => {\n this.setState({ zoomCompensation: computeZoomCompensation() });\n };\n\n updateContainerWidth: any = () => {\n const node = this.containerRef.current;\n if (!node) return;\n const width = node.clientWidth;\n if (width !== this.state.containerWidth) {\n this.setState({ containerWidth: width });\n }\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, zoomCompensation, containerWidth } = 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 // cap each tab at 1/n of the passage container width so a single long\n // title can't push other tabs off-screen. Existing two-line wrap + ellipsis\n // on .passage-label still trims anything that doesn't fit.\n const tabMaxWidth = containerWidth > 0 ? containerWidth / tabs.length : null;\n // When per-tab horizontal space drops to NUMERIC_LABEL_MIN_WIDTH_PER_TAB or\n // less, titles become unreadably truncated; swap to \"Passage N\" so users\n // can still navigate. Container width is read once layout has settled\n // (>0), so initial render uses real labels.\n const useNumericLabels =\n containerWidth > 0 && containerWidth <= tabs.length * NUMERIC_LABEL_MIN_WIDTH_PER_TAB;\n\n return (\n <UiLayout extraCSSRules={extraCSSRules}>\n <PassagesContainer className=\"passages\" ref={this.containerRef}>\n {disabledTabs || tabs.length === 1 ? (\n tabs.map((tab) => this.renderTab(tab, disabledTabs))\n ) : (\n <>\n <Tabs\n sx={{\n // Below the breakpoint (e.g. WCAG 400% zoom, ~320px viewport)\n // the tabs are in normal flow and scroll with the passage text,\n // so they don't lock up space needed to display the passage.\n position: 'static',\n // Above the breakpoint there is adequate screen space, so the\n // tabs stay locked to the top of the panel while the passage\n // text scrolls beneath them.\n [`@media (min-width: ${STICKY_TABS_BREAKPOINT + 1}px)`]: {\n position: 'sticky',\n top: 0,\n zIndex: 1,\n },\n background: 'var(--pie-passage-header-background, rgba(255,255,255,0))',\n color: color.text(),\n fontFamily: 'Roboto, sans-serif',\n // Freeze the tabs' physical size at their 200%-zoom appearance\n // when browser zoom exceeds 200%. The factor is 1 at zoom <= 200%,\n // so behavior below that threshold is unchanged. Using `zoom`\n // (rather than transform: scale) shrinks the layout box itself,\n // so the reclaimed space flows to the passage content below.\n zoom: zoomCompensation,\n '& .MuiTabs-list': {\n /*\n * The strip behind the tabs. A host that has opted into\n * `--pie-passage-header-background` keeps its own colour on every\n * scheme -- Knowledge Checks' pale green-blue is deliberate and is not\n * a scheme's business to override. With no host colour the fallback has\n * to be a theme token rather than a white literal, or the strip stays\n * white over a dark passage body.\n */\n backgroundColor: `var(--pie-passage-header-background, ${color.backgroundDark()})`,\n borderBottom: `1px solid ${color.borderGray()}`,\n },\n '& .MuiTabs-indicator': {\n backgroundColor: color.white(),\n marginBottom: '-1px',\n },\n }}\n value={activeTab}\n onChange={this.handleChange}\n >\n {tabs.map((tab, index) => (\n <TabStyled\n key={tab.id}\n id={`button-${tab.id}`}\n sx={tabMaxWidth ? { maxWidth: `${tabMaxWidth}px` } : undefined}\n label={\n <>\n <Purpose purpose=\"passage-label\">\n {useNumericLabels ? (\n <span className=\"passage-label\">{`Passage ${index + 1}`}</span>\n ) : (\n <span\n className=\"passage-label\"\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.label) }}\n />\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,EAAY,EAAE,OAAO,IACxE,EAAY,EAAY,CAAC,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,EAAS,aAAa,aAAa,GAExI,IAAuB,GACvB,IAAuB,EAAqB,SAC5C,IACJ,KAAwB,OAAO,KAAyB,WACpD,IACA,GAoBA,IAAgB,GAChB,IAAwB,IAOxB,IAAkC,KAElC,UAAgC;CACpC,IAAI,OAAO,SAAW,KAAa,OAAO;CAC1C,IAAM,IAAQ,OAAO,aAAa,OAAO;CAEzC,OAAO,KAAK,IAAI,GAAuB,KAAK,IAAI,GAAG,KADtC,OAAO,SAAS,CAAK,KAAK,IAAQ,IAAI,I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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,CAAC,CAAC,UACL,CAAC,CAAC;CACF,cAAc,EAAA,QAAU;CACxB,OAAO,EAAA,QAAU;CACjB,kBAAkB,EAAA,QAAU;AAC9B"}
@@ -76,7 +76,7 @@ var o = class extends HTMLElement {
76
76
  this._playerObserver &&= (this._playerObserver.disconnect(), null);
77
77
  }
78
78
  disconnectedCallback() {
79
- this._disconnectMathObserver(), this._disconnectPlayerObserver(), this._root && this._root.unmount();
79
+ this._disconnectMathObserver(), this._disconnectPlayerObserver(), this._root &&= (this._root.unmount(), null);
80
80
  }
81
81
  };
82
82
  //#endregion
@@ -10,7 +10,14 @@ import React from 'react';
10
10
  declare class StimulusTabs extends React.Component {
11
11
  state: {
12
12
  activeTab: number;
13
+ zoomCompensation: number;
14
+ containerWidth: number;
13
15
  };
16
+ containerRef: React.RefObject<unknown>;
17
+ componentDidMount(): void;
18
+ componentWillUnmount(): void;
19
+ updateZoomCompensation: any;
20
+ updateContainerWidth: any;
14
21
  handleChange: any;
15
22
  handleKeyDown: any;
16
23
  parsedText: any;
@@ -13,7 +13,11 @@ function h(e) {
13
13
  function g(e, t) {
14
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
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")({
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")({
17
21
  flexGrow: 1,
18
22
  backgroundColor: u.background(),
19
23
  color: u.text(),
@@ -22,7 +26,7 @@ var _ = g(l, "UiLayout") || g(C.UiLayout, "UiLayout"), v = g(c, "Purpose") || g(
22
26
  padding: ".6em 1em",
23
27
  textAlign: "left"
24
28
  }
25
- }), T = i("div")(({ theme: e }) => ({
29
+ }), k = i("div")(({ theme: e }) => ({
26
30
  backgroundColor: u.background(),
27
31
  color: u.text(),
28
32
  padding: e.spacing(2),
@@ -32,13 +36,13 @@ var _ = g(l, "UiLayout") || g(C.UiLayout, "UiLayout"), v = g(c, "Purpose") || g(
32
36
  margin: "1.5em 10px",
33
37
  padding: ".5em 10px"
34
38
  }
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,
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(),
37
41
  fontSize: "inherit",
38
42
  fontFamily: "Roboto, sans-serif",
39
- color: e.palette.common.black,
43
+ color: u.text(),
40
44
  borderRadius: `${e.spacing(2)} ${e.spacing(2)} 0 0`,
41
- border: "1px solid #D9DADA",
45
+ border: `1px solid ${u.borderGray()}`,
42
46
  borderBottomWidth: 0,
43
47
  minHeight: "56px",
44
48
  padding: "8px 10px",
@@ -58,19 +62,39 @@ var _ = g(l, "UiLayout") || g(C.UiLayout, "UiLayout"), v = g(c, "Purpose") || g(
58
62
  opacity: .7
59
63
  },
60
64
  "&.Mui-selected": {
61
- color: e.palette.common.black,
65
+ color: u.text(),
62
66
  ".passage-label": { opacity: 1 },
63
- ".passage-label-underline": { backgroundColor: "#146EB3" }
67
+ ".passage-label-underline": { backgroundColor: u.tertiary() }
64
68
  },
65
- "&:hover": { ".passage-label-underline": { backgroundColor: "#D0E2F0" } },
69
+ "&:hover": { ".passage-label-underline": { backgroundColor: u.tertiaryLight() } },
66
70
  "& .MuiTouchRipple-root": { opacity: .7 }
67
- })), A = i("div")(({ theme: e }) => ({
71
+ })), P = i("div")(() => ({
68
72
  height: "2px",
69
73
  width: "100%",
70
74
  marginTop: "6px",
71
- background: e.palette.common.white
72
- })), j = class extends e.Component {
73
- state = { activeTab: 0 };
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
+ };
74
98
  handleChange = (e, t) => {
75
99
  this.setState(() => ({ activeTab: t })), setTimeout(() => {
76
100
  let e = new CustomEvent("pie-ui-passage-tabChanged", { detail: { tab: t } });
@@ -128,7 +152,7 @@ var _ = g(l, "UiLayout") || g(C.UiLayout, "UiLayout"), v = g(c, "Purpose") || g(
128
152
  }
129
153
  renderTab(e, t) {
130
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;
131
- return /* @__PURE__ */ m(T, {
155
+ return /* @__PURE__ */ m(k, {
132
156
  id: `tabpanel-${e.id}`,
133
157
  role: "tabpanel",
134
158
  "aria-labelledby": `button-${e.id}`,
@@ -136,15 +160,15 @@ var _ = g(l, "UiLayout") || g(C.UiLayout, "UiLayout"), v = g(c, "Purpose") || g(
136
160
  this.renderInstructions(e.teacherInstructions, t),
137
161
  e.title && /* @__PURE__ */ p(v, {
138
162
  purpose: "passage-title",
139
- children: /* @__PURE__ */ p(i, { children: /* @__PURE__ */ p(E, { dangerouslySetInnerHTML: { __html: this.parsedText(e.title) } }) })
163
+ children: /* @__PURE__ */ p(i, { children: /* @__PURE__ */ p(A, { dangerouslySetInnerHTML: { __html: this.parsedText(e.title) } }) })
140
164
  }),
141
165
  e.subtitle && /* @__PURE__ */ p(v, {
142
166
  purpose: "passage-subtitle",
143
- children: /* @__PURE__ */ p(D, { dangerouslySetInnerHTML: { __html: this.parsedText(e.subtitle) } })
167
+ children: /* @__PURE__ */ p(j, { dangerouslySetInnerHTML: { __html: this.parsedText(e.subtitle) } })
144
168
  }),
145
169
  e.author && /* @__PURE__ */ p(v, {
146
170
  purpose: "passage-author",
147
- children: /* @__PURE__ */ p(O, {
171
+ children: /* @__PURE__ */ p(M, {
148
172
  className: "author",
149
173
  dangerouslySetInnerHTML: { __html: this.parsedText(e.author) }
150
174
  })
@@ -160,49 +184,62 @@ var _ = g(l, "UiLayout") || g(C.UiLayout, "UiLayout"), v = g(c, "Purpose") || g(
160
184
  }, e.id);
161
185
  }
162
186
  render() {
163
- let { model: e, tabs: t, disabledTabs: r } = this.props, { activeTab: i } = this.state;
187
+ let { model: e, tabs: t, disabledTabs: r } = this.props, { activeTab: i, zoomCompensation: a, containerWidth: o } = this.state;
164
188
  if (!t?.length) return;
165
- let { extraCSSRules: a } = e || {}, o = (t || []).find((e) => e.id === i);
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;
166
190
  return /* @__PURE__ */ p(_, {
167
- extraCSSRules: a,
168
- children: /* @__PURE__ */ p(w, {
191
+ extraCSSRules: s,
192
+ children: /* @__PURE__ */ p(O, {
169
193
  className: "passages",
194
+ ref: this.containerRef,
170
195
  children: r || t.length === 1 ? t.map((e) => this.renderTab(e, r)) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(n, {
171
196
  sx: {
172
- position: "sticky",
173
- top: 0,
174
- background: u.background(),
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))",
175
204
  color: u.text(),
176
205
  fontFamily: "Roboto, sans-serif",
177
- "& .MuiTabs-list": { borderBottom: "1px solid #D9DADA" },
206
+ zoom: a,
207
+ "& .MuiTabs-list": {
208
+ backgroundColor: `var(--pie-passage-header-background, ${u.backgroundDark()})`,
209
+ borderBottom: `1px solid ${u.borderGray()}`
210
+ },
178
211
  "& .MuiTabs-indicator": {
179
- backgroundColor: "#ffffff",
212
+ backgroundColor: u.white(),
180
213
  marginBottom: "-1px"
181
214
  }
182
215
  },
183
216
  value: i,
184
217
  onChange: this.handleChange,
185
- children: t.map((e) => /* @__PURE__ */ p(k, {
218
+ children: t.map((e, t) => /* @__PURE__ */ p(N, {
186
219
  id: `button-${e.id}`,
220
+ sx: l ? { maxWidth: `${l}px` } : void 0,
187
221
  label: /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(v, {
188
222
  purpose: "passage-label",
189
- children: /* @__PURE__ */ p("span", {
223
+ children: d ? /* @__PURE__ */ p("span", {
224
+ className: "passage-label",
225
+ children: `Passage ${t + 1}`
226
+ }) : /* @__PURE__ */ p("span", {
190
227
  className: "passage-label",
191
228
  dangerouslySetInnerHTML: { __html: this.parsedText(e.label) }
192
229
  })
193
- }), /* @__PURE__ */ p(A, { className: "passage-label-underline" })] }),
230
+ }), /* @__PURE__ */ p(P, { className: "passage-label-underline" })] }),
194
231
  value: e.id,
195
232
  tabIndex: i === e.id ? 0 : -1,
196
233
  "aria-controls": `tabpanel-${e.id}`,
197
234
  "aria-selected": i === e.id,
198
235
  onKeyDown: (t) => this.handleKeyDown(t, e.id)
199
236
  }, e.id))
200
- }), o ? this.renderTab(o, r) : null] })
237
+ }), c ? this.renderTab(c, r) : null] })
201
238
  })
202
239
  });
203
240
  }
204
241
  };
205
- j.propTypes = {
242
+ F.propTypes = {
206
243
  tabs: t.arrayOf(t.shape({
207
244
  id: t.number.isRequired,
208
245
  label: t.string.isRequired,
@@ -217,4 +254,4 @@ j.propTypes = {
217
254
  baseHeadingLevel: t.number
218
255
  };
219
256
  //#endregion
220
- export { j as default };
257
+ export { F as default };