@pie-element/passage 7.1.2-next.5 → 7.2.0-beta.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/CHANGELOG.json +227 -0
- package/CHANGELOG.md +1473 -0
- package/LICENSE.md +5 -0
- package/README.md +3 -0
- package/configure/CHANGELOG.md +685 -0
- package/configure/lib/common.js +74 -0
- package/configure/lib/common.js.map +1 -0
- package/configure/lib/defaults.js +174 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/design.js +185 -0
- package/configure/lib/design.js.map +1 -0
- package/configure/lib/index.js +87 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/passage.js +194 -0
- package/configure/lib/passage.js.map +1 -0
- package/configure/package.json +23 -0
- package/controller/CHANGELOG.json +1 -0
- package/controller/CHANGELOG.md +113 -0
- package/controller/lib/defaults.js +23 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +80 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +13 -0
- package/docs/config-schema.json +1325 -0
- package/docs/config-schema.json.md +974 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +32 -0
- package/docs/demo/index.html +1 -0
- package/docs/pie-schema.json +775 -0
- package/docs/pie-schema.json.md +561 -0
- package/lib/index.js +144 -0
- package/lib/index.js.map +1 -0
- package/lib/print.js +78 -0
- package/lib/print.js.map +1 -0
- package/lib/stimulus-tabs.js +427 -0
- package/lib/stimulus-tabs.js.map +1 -0
- package/module/configure.js +1 -0
- package/module/controller.js +920 -0
- package/module/demo.js +57 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +10 -0
- package/module/print-demo.js +95 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +19 -86
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/common.d.ts +0 -36
- package/dist/author/common.js +0 -56
- package/dist/author/defaults.d.ts +0 -175
- package/dist/author/defaults.js +0 -113
- package/dist/author/design.d.ts +0 -28
- package/dist/author/design.js +0 -120
- package/dist/author/index.d.ts +0 -36
- package/dist/author/index.js +0 -66
- package/dist/author/passage.d.ts +0 -27
- package/dist/author/passage.js +0 -127
- package/dist/browser/author/index.js +0 -44688
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -64
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -117
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-ByX3voUB.js +0 -9618
- package/dist/browser/dist-ByX3voUB.js.map +0 -1
- package/dist/browser/dist-CeIdmqCq.js +0 -92
- package/dist/browser/dist-CeIdmqCq.js.map +0 -1
- package/dist/browser/passage.css +0 -2
- package/dist/browser/print/index.js +0 -48
- package/dist/browser/print/index.js.map +0 -1
- package/dist/browser/stimulus-tabs-CxiQ79gz.js +0 -218
- package/dist/browser/stimulus-tabs-CxiQ79gz.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -23
- package/dist/controller/defaults.js +0 -17
- package/dist/controller/index.d.ts +0 -18
- package/dist/controller/index.js +0 -50
- package/dist/delivery/index.d.ts +0 -22
- package/dist/delivery/index.js +0 -83
- package/dist/delivery/stimulus-tabs.d.ts +0 -21
- package/dist/delivery/stimulus-tabs.js +0 -220
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -145
- package/dist/index.js +0 -2
- package/dist/print/index.d.ts +0 -15
- package/dist/print/index.js +0 -47
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
package/lib/print.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _client = require("react-dom/client");
|
|
10
|
+
var _lodashEs = require("lodash-es");
|
|
11
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
12
|
+
var _stimulusTabs = _interopRequireDefault(require("./stimulus-tabs"));
|
|
13
|
+
const log = (0, _debug.default)('pie-element:passage:print');
|
|
14
|
+
const checkNullish = value => value !== null && value !== undefined;
|
|
15
|
+
const isEnabled = (value, defaultValue) => checkNullish(value) ? value : defaultValue;
|
|
16
|
+
const preparePrintPassage = (model, opts) => {
|
|
17
|
+
const isInstructor = opts.role === 'instructor';
|
|
18
|
+
|
|
19
|
+
// TODO: also update '../../configure/src/defaults.js' and '../../controller/src/defaults.js' when updating defaultValue
|
|
20
|
+
const teacherInstructionsEnabled = isEnabled(model.teacherInstructionsEnabled, true);
|
|
21
|
+
const titleEnabled = isEnabled(model.titleEnabled, true);
|
|
22
|
+
const authorEnabled = isEnabled(model.authorEnabled, false);
|
|
23
|
+
const subtitleEnabled = isEnabled(model.subtitleEnabled, true);
|
|
24
|
+
const textEnabled = isEnabled(model.textEnabled, true);
|
|
25
|
+
return model.passages.map((passage, index) => ({
|
|
26
|
+
id: index,
|
|
27
|
+
teacherInstructions: isEnabled(passage.teacherInstructionsEnabled, teacherInstructionsEnabled) ? isInstructor && passage.teacherInstructions || '' : '',
|
|
28
|
+
label: passage.title || `Passage ${index + 1}`,
|
|
29
|
+
title: isEnabled(passage.titleEnabled, titleEnabled) ? passage.title || '' : '',
|
|
30
|
+
author: isEnabled(passage.authorEnabled, authorEnabled) ? passage.author || '' : '',
|
|
31
|
+
subtitle: isEnabled(passage.subtitleEnabled, subtitleEnabled) ? passage.subtitle || '' : '',
|
|
32
|
+
text: isEnabled(passage.textEnabled, textEnabled) ? passage.text || '' : ''
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
class PassagePrint extends HTMLElement {
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
this._model = null;
|
|
39
|
+
this._options = null;
|
|
40
|
+
this._session = [];
|
|
41
|
+
this._root = null;
|
|
42
|
+
this._rerender = (0, _lodashEs.debounce)(() => {
|
|
43
|
+
if (this._model && this._session) {
|
|
44
|
+
if (this._model.passages && this._model.passages.length > 0) {
|
|
45
|
+
const printPassage = preparePrintPassage(this._model, this._options);
|
|
46
|
+
const element = /*#__PURE__*/_react.default.createElement(_stimulusTabs.default, {
|
|
47
|
+
disabledTabs: true,
|
|
48
|
+
tabs: printPassage
|
|
49
|
+
});
|
|
50
|
+
if (!this._root) {
|
|
51
|
+
this._root = (0, _client.createRoot)(this);
|
|
52
|
+
}
|
|
53
|
+
this._root.render(element);
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
log('skip');
|
|
57
|
+
}
|
|
58
|
+
}, 50, {
|
|
59
|
+
leading: false,
|
|
60
|
+
trailing: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
set model(s) {
|
|
64
|
+
this._model = s;
|
|
65
|
+
this._rerender();
|
|
66
|
+
}
|
|
67
|
+
set options(o) {
|
|
68
|
+
this._options = o;
|
|
69
|
+
}
|
|
70
|
+
connectedCallback() {}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
if (this._root) {
|
|
73
|
+
this._root.unmount();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.default = PassagePrint;
|
|
78
|
+
//# sourceMappingURL=print.js.map
|
package/lib/print.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","names":["_react","_interopRequireDefault","require","_client","_lodashEs","_debug","_stimulusTabs","log","debug","checkNullish","value","undefined","isEnabled","defaultValue","preparePrintPassage","model","opts","isInstructor","role","teacherInstructionsEnabled","titleEnabled","authorEnabled","subtitleEnabled","textEnabled","passages","map","passage","index","id","teacherInstructions","label","title","author","subtitle","text","PassagePrint","HTMLElement","constructor","_model","_options","_session","_root","_rerender","debounce","length","printPassage","element","React","createElement","StimulusTabs","disabledTabs","tabs","createRoot","render","leading","trailing","s","options","o","connectedCallback","disconnectedCallback","unmount","exports","default"],"sources":["../src/print.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from 'lodash-es';\nimport debug from 'debug';\n\nimport StimulusTabs from './stimulus-tabs';\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":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,aAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,MAAMK,GAAG,GAAG,IAAAC,cAAK,EAAC,2BAA2B,CAAC;AAE9C,MAAMC,YAAY,GAAIC,KAAK,IAAKA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS;AAErE,MAAMC,SAAS,GAAGA,CAACF,KAAK,EAAEG,YAAY,KAAMJ,YAAY,CAACC,KAAK,CAAC,GAAGA,KAAK,GAAGG,YAAa;AAEvF,MAAMC,mBAAmB,GAAGA,CAACC,KAAK,EAAEC,IAAI,KAAK;EAC3C,MAAMC,YAAY,GAAGD,IAAI,CAACE,IAAI,KAAK,YAAY;;EAE/C;EACA,MAAMC,0BAA0B,GAAGP,SAAS,CAACG,KAAK,CAACI,0BAA0B,EAAE,IAAI,CAAC;EACpF,MAAMC,YAAY,GAAGR,SAAS,CAACG,KAAK,CAACK,YAAY,EAAE,IAAI,CAAC;EACxD,MAAMC,aAAa,GAAGT,SAAS,CAACG,KAAK,CAACM,aAAa,EAAE,KAAK,CAAC;EAC3D,MAAMC,eAAe,GAAGV,SAAS,CAACG,KAAK,CAACO,eAAe,EAAE,IAAI,CAAC;EAC9D,MAAMC,WAAW,GAAGX,SAAS,CAACG,KAAK,CAACQ,WAAW,EAAE,IAAI,CAAC;EAEtD,OAAOR,KAAK,CAACS,QAAQ,CAACC,GAAG,CAAC,CAACC,OAAO,E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AG,CAAC,EAAE;UAC3D,MAAMC,YAAY,GAAG/B,mBAAmB,CAAC,IAAI,CAACwB,MAAM,EAAE,IAAI,CAACC,QAAQ,CAAC;UAEpE,MAAMO,OAAO,gBAAGC,cAAK,CAACC,aAAa,CAACC,qBAAY,EAAE;YAChDC,YAAY,EAAE,IAAI;YAClBC,IAAI,EAAEN;UACR,CAAC,CAAC;UAEF,IAAI,CAAC,IAAI,CAACJ,KAAK,EAAE;YACf,IAAI,CAACA,KAAK,GAAG,IAAAW,kBAAU,EAAC,IAAI,CAAC;UAC/B;UACA,IAAI,CAACX,KAAK,CAACY,MAAM,CAACP,OAAO,CAAC;QAC5B;MACF,CAAC,MAAM;QACLvC,GAAG,CAAC,MAAM,CAAC;MACb;IACF,CAAC,EACD,EAAE,EACF;MAAE+C,OAAO,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAK,CACnC,CAAC;EACH;EAEA,IAAIxC,KAAKA,CAACyC,CAAC,EAAE;IACX,IAAI,CAAClB,MAAM,GAAGkB,CAAC;IACf,IAAI,CAACd,SAAS,CAAC,CAAC;EAClB;EAEA,IAAIe,OAAOA,CAACC,CAAC,EAAE;IACb,IAAI,CAACnB,QAAQ,GAAGmB,CAAC;EACnB;EAEAC,iBAAiBA,CAAA,EAAG,CAAC;EAErBC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACnB,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACoB,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAA5B,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _Tabs = _interopRequireDefault(require("@mui/material/Tabs"));
|
|
12
|
+
var _Tab = _interopRequireDefault(require("@mui/material/Tab"));
|
|
13
|
+
var _styles = require("@mui/material/styles");
|
|
14
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
15
|
+
// Must match the breakpoint Quiz Engine passes to the PIE section player for
|
|
16
|
+
// switching from the side-by-side passage/question layout to the tabbed layout.
|
|
17
|
+
// Below (and at) this width the passage tabs scroll with the passage content
|
|
18
|
+
// instead of being locked to the top of the panel, so that they do not lock up
|
|
19
|
+
// space needed for the passage text (WCAG 1.4.10 Reflow, 400% zoom / 320px).
|
|
20
|
+
const STICKY_TABS_BREAKPOINT = 840;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Zoom compensation for the passage selection tabs.
|
|
24
|
+
*
|
|
25
|
+
* The tabs scale naturally with browser zoom up to 200%. Beyond 200%,
|
|
26
|
+
* we shrink their CSS size proportionally so their physical on-screen size
|
|
27
|
+
* freezes at the 200% appearance, leaving more room for passage content
|
|
28
|
+
* in high-zoom / small-window situations.
|
|
29
|
+
* The factor is min(1, 2 / zoom): exactly 1 at zoom <= 200% (component
|
|
30
|
+
* behavior unchanged), shrinking proportionally above that. A lower clamp
|
|
31
|
+
* of 0.4 guards against inflated ratios (docked devtools, browser side
|
|
32
|
+
* panels, window chrome) ever making the tabs unusably small.
|
|
33
|
+
*/
|
|
34
|
+
const MAX_TABS_ZOOM = 2;
|
|
35
|
+
const MIN_ZOOM_COMPENSATION = 0.4;
|
|
36
|
+
|
|
37
|
+
// Per-tab horizontal-space floor in CSS pixels. When the passage container is
|
|
38
|
+
// narrow enough that each tab would have at most this much room
|
|
39
|
+
// (containerWidth <= tabs.length * NUMERIC_LABEL_MIN_WIDTH_PER_TAB), tab labels
|
|
40
|
+
// fall back to "Passage 1", "Passage 2", ... so navigation stays usable instead
|
|
41
|
+
// of being dominated by aggressively truncated titles.
|
|
42
|
+
const NUMERIC_LABEL_MIN_WIDTH_PER_TAB = 170;
|
|
43
|
+
const computeZoomCompensation = () => {
|
|
44
|
+
if (typeof window === 'undefined') return 1;
|
|
45
|
+
const ratio = window.outerWidth / window.innerWidth;
|
|
46
|
+
const zoom = Number.isFinite(ratio) && ratio > 0 ? ratio : 1;
|
|
47
|
+
return Math.max(MIN_ZOOM_COMPENSATION, Math.min(1, MAX_TABS_ZOOM / zoom));
|
|
48
|
+
};
|
|
49
|
+
const PassagesContainer = (0, _styles.styled)('div')({
|
|
50
|
+
flexGrow: 1,
|
|
51
|
+
backgroundColor: _renderUi.color.background(),
|
|
52
|
+
color: _renderUi.color.text(),
|
|
53
|
+
'&:not(.MathJax) table': {
|
|
54
|
+
borderCollapse: 'collapse'
|
|
55
|
+
},
|
|
56
|
+
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
57
|
+
padding: '.6em 1em',
|
|
58
|
+
textAlign: 'left'
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const Passage = (0, _styles.styled)('div')(({
|
|
62
|
+
theme
|
|
63
|
+
}) => ({
|
|
64
|
+
backgroundColor: _renderUi.color.background(),
|
|
65
|
+
color: _renderUi.color.text(),
|
|
66
|
+
padding: theme.spacing(2),
|
|
67
|
+
'& blockquote': {
|
|
68
|
+
background: '#f9f9f9',
|
|
69
|
+
borderLeft: '5px solid #ccc',
|
|
70
|
+
margin: '1.5em 10px',
|
|
71
|
+
padding: '.5em 10px'
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
const PassageTitle = (0, _styles.styled)('div')({
|
|
75
|
+
fontSize: '1.75rem'
|
|
76
|
+
});
|
|
77
|
+
const PassageSubtitle = (0, _styles.styled)('div')({
|
|
78
|
+
fontSize: '1.5rem'
|
|
79
|
+
});
|
|
80
|
+
const PassageAuthor = (0, _styles.styled)('div')({
|
|
81
|
+
fontSize: '1.25rem'
|
|
82
|
+
});
|
|
83
|
+
const TabStyled = (0, _styles.styled)(_Tab.default)(({
|
|
84
|
+
theme
|
|
85
|
+
}) => ({
|
|
86
|
+
background: theme.palette.common.white,
|
|
87
|
+
// replace with color.background() once PD-2801 is DONE
|
|
88
|
+
fontSize: 'inherit',
|
|
89
|
+
fontFamily: 'Roboto, sans-serif',
|
|
90
|
+
color: theme.palette.common.black,
|
|
91
|
+
// remove when PD-2801 is DONE
|
|
92
|
+
borderRadius: `${theme.spacing(2)} ${theme.spacing(2)} 0 0`,
|
|
93
|
+
border: '1px solid #D9DADA',
|
|
94
|
+
borderBottomWidth: 0,
|
|
95
|
+
minHeight: '56px',
|
|
96
|
+
padding: '8px 10px',
|
|
97
|
+
display: 'flex',
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
justifyContent: 'center',
|
|
100
|
+
margin: `0 ${theme.spacing(1)}`,
|
|
101
|
+
textTransform: 'none',
|
|
102
|
+
'.passage-label': {
|
|
103
|
+
display: '-webkit-box',
|
|
104
|
+
WebkitLineClamp: 2,
|
|
105
|
+
WebkitBoxOrient: 'vertical',
|
|
106
|
+
overflow: 'hidden',
|
|
107
|
+
textOverflow: 'ellipsis',
|
|
108
|
+
whiteSpace: 'normal',
|
|
109
|
+
margin: 'auto 0',
|
|
110
|
+
opacity: 0.7
|
|
111
|
+
},
|
|
112
|
+
'&.Mui-selected': {
|
|
113
|
+
color: theme.palette.common.black,
|
|
114
|
+
'.passage-label': {
|
|
115
|
+
opacity: 1
|
|
116
|
+
},
|
|
117
|
+
'.passage-label-underline': {
|
|
118
|
+
backgroundColor: _renderUi.color.tertiary()
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
'&:hover': {
|
|
122
|
+
'.passage-label-underline': {
|
|
123
|
+
backgroundColor: _renderUi.color.tertiaryLight()
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
'& .MuiTouchRipple-root': {
|
|
127
|
+
opacity: 0.7
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
const Underline = (0, _styles.styled)('div')(({
|
|
131
|
+
theme
|
|
132
|
+
}) => ({
|
|
133
|
+
height: '2px',
|
|
134
|
+
width: '100%',
|
|
135
|
+
marginTop: '6px',
|
|
136
|
+
background: theme.palette.common.white // replace with color.background() once PD-2801 is DONE
|
|
137
|
+
}));
|
|
138
|
+
class StimulusTabs extends _react.default.Component {
|
|
139
|
+
constructor(...args) {
|
|
140
|
+
super(...args);
|
|
141
|
+
(0, _defineProperty2.default)(this, "state", {
|
|
142
|
+
activeTab: 0,
|
|
143
|
+
zoomCompensation: computeZoomCompensation(),
|
|
144
|
+
containerWidth: 0
|
|
145
|
+
});
|
|
146
|
+
(0, _defineProperty2.default)(this, "containerRef", /*#__PURE__*/_react.default.createRef());
|
|
147
|
+
(0, _defineProperty2.default)(this, "updateZoomCompensation", () => {
|
|
148
|
+
this.setState({
|
|
149
|
+
zoomCompensation: computeZoomCompensation()
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
(0, _defineProperty2.default)(this, "updateContainerWidth", () => {
|
|
153
|
+
const node = this.containerRef.current;
|
|
154
|
+
if (!node) return;
|
|
155
|
+
const width = node.clientWidth;
|
|
156
|
+
if (width !== this.state.containerWidth) {
|
|
157
|
+
this.setState({
|
|
158
|
+
containerWidth: width
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
(0, _defineProperty2.default)(this, "handleChange", (event, activeTab) => {
|
|
163
|
+
this.setState(() => ({
|
|
164
|
+
activeTab
|
|
165
|
+
}));
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
const tabChangeEvent = new CustomEvent('pie-ui-passage-tabChanged', {
|
|
168
|
+
detail: {
|
|
169
|
+
tab: activeTab
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
window.dispatchEvent(tabChangeEvent);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
(0, _defineProperty2.default)(this, "handleKeyDown", (event, currentTabId) => {
|
|
176
|
+
const {
|
|
177
|
+
key
|
|
178
|
+
} = event;
|
|
179
|
+
const {
|
|
180
|
+
tabs
|
|
181
|
+
} = this.props;
|
|
182
|
+
let newTabIndex = -1;
|
|
183
|
+
const currentIndex = tabs.findIndex(tab => tab.id === currentTabId);
|
|
184
|
+
switch (key) {
|
|
185
|
+
case 'ArrowRight':
|
|
186
|
+
// Move to the next tab
|
|
187
|
+
newTabIndex = (currentIndex + 1) % tabs.length;
|
|
188
|
+
break;
|
|
189
|
+
case 'ArrowLeft':
|
|
190
|
+
// Move to the previous tab
|
|
191
|
+
newTabIndex = (currentIndex - 1 + tabs.length) % tabs.length;
|
|
192
|
+
break;
|
|
193
|
+
// Commented out ArrowDown and ArrowUp for future vertical tab navigation
|
|
194
|
+
// case 'ArrowDown':
|
|
195
|
+
// // Move to the next tab (for vertical alignment)
|
|
196
|
+
// newTabIndex = (currentIndex + 1) % tabs.length;
|
|
197
|
+
// break;
|
|
198
|
+
// case 'ArrowUp':
|
|
199
|
+
// // Move to the previous tab (for vertical alignment)
|
|
200
|
+
// newTabIndex = (currentIndex - 1 + tabs.length) % tabs.length;
|
|
201
|
+
// break;
|
|
202
|
+
case 'Home':
|
|
203
|
+
// Move to the first tab
|
|
204
|
+
newTabIndex = 0;
|
|
205
|
+
break;
|
|
206
|
+
case 'End':
|
|
207
|
+
// Move to the last tab
|
|
208
|
+
newTabIndex = tabs.length - 1;
|
|
209
|
+
break;
|
|
210
|
+
case 'Enter':
|
|
211
|
+
case ' ':
|
|
212
|
+
// Activate the current tab
|
|
213
|
+
newTabIndex = currentIndex;
|
|
214
|
+
break;
|
|
215
|
+
default:
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
if (newTabIndex !== -1) {
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
event.stopPropagation();
|
|
221
|
+
this.handleChange(event, tabs[newTabIndex].id);
|
|
222
|
+
document.getElementById(`button-${tabs[newTabIndex].id}`).focus();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
(0, _defineProperty2.default)(this, "parsedText", (text = '') => {
|
|
226
|
+
// fix imported audio content for Safari PD-1391
|
|
227
|
+
const div = document.createElement('div');
|
|
228
|
+
div.innerHTML = text.replace(/(<br\/>\n)/g, '<br/>');
|
|
229
|
+
const audio = div.querySelector('audio');
|
|
230
|
+
if (audio) {
|
|
231
|
+
const source = document.createElement('source');
|
|
232
|
+
source.setAttribute('type', 'audio/mp3');
|
|
233
|
+
source.setAttribute('src', audio.getAttribute('src'));
|
|
234
|
+
audio.removeAttribute('src');
|
|
235
|
+
audio.appendChild(source);
|
|
236
|
+
}
|
|
237
|
+
return div.innerHTML;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
componentDidMount() {
|
|
241
|
+
if (typeof window === 'undefined') return;
|
|
242
|
+
window.addEventListener('resize', this.updateZoomCompensation);
|
|
243
|
+
if (this.containerRef.current && typeof ResizeObserver !== 'undefined') {
|
|
244
|
+
this.resizeObserver = new ResizeObserver(this.updateContainerWidth);
|
|
245
|
+
this.resizeObserver.observe(this.containerRef.current);
|
|
246
|
+
}
|
|
247
|
+
this.updateContainerWidth();
|
|
248
|
+
}
|
|
249
|
+
componentWillUnmount() {
|
|
250
|
+
if (typeof window === 'undefined') return;
|
|
251
|
+
window.removeEventListener('resize', this.updateZoomCompensation);
|
|
252
|
+
if (this.resizeObserver) {
|
|
253
|
+
this.resizeObserver.disconnect();
|
|
254
|
+
this.resizeObserver = null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
renderInstructions(teacherInstructions, disabledTabs = false) {
|
|
258
|
+
if (!teacherInstructions) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const teacherInstructionsDiv = /*#__PURE__*/_react.default.createElement(_renderUi.PreviewPrompt, {
|
|
262
|
+
tagName: "div",
|
|
263
|
+
className: "prompt",
|
|
264
|
+
defaultClassName: "teacher-instructions",
|
|
265
|
+
prompt: teacherInstructions
|
|
266
|
+
});
|
|
267
|
+
if (disabledTabs) {
|
|
268
|
+
return teacherInstructionsDiv;
|
|
269
|
+
}
|
|
270
|
+
return /*#__PURE__*/_react.default.createElement(_renderUi.Collapsible, {
|
|
271
|
+
labels: {
|
|
272
|
+
hidden: 'Show Teacher Instructions',
|
|
273
|
+
visible: 'Hide Teacher Instructions'
|
|
274
|
+
}
|
|
275
|
+
}, teacherInstructionsDiv);
|
|
276
|
+
}
|
|
277
|
+
renderTab(tab, disabledTabs) {
|
|
278
|
+
const {
|
|
279
|
+
baseHeadingLevel
|
|
280
|
+
} = this.props;
|
|
281
|
+
const clampedLevel = baseHeadingLevel ? Math.min(6, Math.max(1, baseHeadingLevel)) : undefined;
|
|
282
|
+
const TitleTag = baseHeadingLevel ? `h${clampedLevel}` : 'h2'; // default to h2 if no base level is provided - this was the previous behavior
|
|
283
|
+
const textLevel = baseHeadingLevel ? Math.min(6, Math.max(1, clampedLevel + 1)) : undefined; // promote text headings one level above title
|
|
284
|
+
|
|
285
|
+
return /*#__PURE__*/_react.default.createElement(Passage, {
|
|
286
|
+
key: tab.id,
|
|
287
|
+
id: `tabpanel-${tab.id}`,
|
|
288
|
+
role: "tabpanel",
|
|
289
|
+
"aria-labelledby": `button-${tab.id}`
|
|
290
|
+
}, this.renderInstructions(tab.teacherInstructions, disabledTabs), tab.title && /*#__PURE__*/_react.default.createElement(_renderUi.Purpose, {
|
|
291
|
+
purpose: "passage-title"
|
|
292
|
+
}, /*#__PURE__*/_react.default.createElement(TitleTag, null, /*#__PURE__*/_react.default.createElement(PassageTitle, {
|
|
293
|
+
dangerouslySetInnerHTML: {
|
|
294
|
+
__html: this.parsedText(tab.title)
|
|
295
|
+
}
|
|
296
|
+
}))), tab.subtitle && /*#__PURE__*/_react.default.createElement(_renderUi.Purpose, {
|
|
297
|
+
purpose: "passage-subtitle"
|
|
298
|
+
}, /*#__PURE__*/_react.default.createElement(PassageSubtitle, {
|
|
299
|
+
dangerouslySetInnerHTML: {
|
|
300
|
+
__html: this.parsedText(tab.subtitle)
|
|
301
|
+
}
|
|
302
|
+
})), tab.author && /*#__PURE__*/_react.default.createElement(_renderUi.Purpose, {
|
|
303
|
+
purpose: "passage-author"
|
|
304
|
+
}, /*#__PURE__*/_react.default.createElement(PassageAuthor, {
|
|
305
|
+
className: "author",
|
|
306
|
+
dangerouslySetInnerHTML: {
|
|
307
|
+
__html: this.parsedText(tab.author)
|
|
308
|
+
}
|
|
309
|
+
})), tab.text && /*#__PURE__*/_react.default.createElement(_renderUi.Purpose, {
|
|
310
|
+
purpose: "passage-text"
|
|
311
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
312
|
+
key: tab.id,
|
|
313
|
+
className: "text",
|
|
314
|
+
dangerouslySetInnerHTML: {
|
|
315
|
+
__html: baseHeadingLevel ? (0, _renderUi.transformDataHeadings)(tab.text, textLevel) : tab.text
|
|
316
|
+
}
|
|
317
|
+
})));
|
|
318
|
+
}
|
|
319
|
+
render() {
|
|
320
|
+
const {
|
|
321
|
+
model,
|
|
322
|
+
tabs,
|
|
323
|
+
disabledTabs
|
|
324
|
+
} = this.props;
|
|
325
|
+
const {
|
|
326
|
+
activeTab,
|
|
327
|
+
zoomCompensation,
|
|
328
|
+
containerWidth
|
|
329
|
+
} = this.state;
|
|
330
|
+
if (!tabs?.length) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const {
|
|
334
|
+
extraCSSRules
|
|
335
|
+
} = model || {};
|
|
336
|
+
const selectedTab = (tabs || []).find(tab => tab.id === activeTab);
|
|
337
|
+
|
|
338
|
+
// cap each tab at 1/n of the passage container width so a single long
|
|
339
|
+
// title can't push other tabs off-screen. Existing two-line wrap + ellipsis
|
|
340
|
+
// on .passage-label still trims anything that doesn't fit.
|
|
341
|
+
const tabMaxWidth = containerWidth > 0 ? containerWidth / tabs.length : null;
|
|
342
|
+
// When per-tab horizontal space drops to NUMERIC_LABEL_MIN_WIDTH_PER_TAB or
|
|
343
|
+
// less, titles become unreadably truncated; swap to "Passage N" so users
|
|
344
|
+
// can still navigate. Container width is read once layout has settled
|
|
345
|
+
// (>0), so initial render uses real labels.
|
|
346
|
+
const useNumericLabels = containerWidth > 0 && containerWidth <= tabs.length * NUMERIC_LABEL_MIN_WIDTH_PER_TAB;
|
|
347
|
+
return /*#__PURE__*/_react.default.createElement(_renderUi.UiLayout, {
|
|
348
|
+
extraCSSRules: extraCSSRules
|
|
349
|
+
}, /*#__PURE__*/_react.default.createElement(PassagesContainer, {
|
|
350
|
+
className: "passages",
|
|
351
|
+
ref: this.containerRef
|
|
352
|
+
}, disabledTabs || tabs.length === 1 ? tabs.map(tab => this.renderTab(tab, disabledTabs)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Tabs.default, {
|
|
353
|
+
sx: {
|
|
354
|
+
// Below the breakpoint (e.g. WCAG 400% zoom, ~320px viewport)
|
|
355
|
+
// the tabs are in normal flow and scroll with the passage text,
|
|
356
|
+
// so they don't lock up space needed to display the passage.
|
|
357
|
+
position: 'static',
|
|
358
|
+
// Above the breakpoint there is adequate screen space, so the
|
|
359
|
+
// tabs stay locked to the top of the panel while the passage
|
|
360
|
+
// text scrolls beneath them.
|
|
361
|
+
[`@media (min-width: ${STICKY_TABS_BREAKPOINT + 1}px)`]: {
|
|
362
|
+
position: 'sticky',
|
|
363
|
+
top: 0,
|
|
364
|
+
zIndex: 1
|
|
365
|
+
},
|
|
366
|
+
background: 'var(--pie-passage-header-background, rgba(255,255,255,0))',
|
|
367
|
+
color: _renderUi.color.text(),
|
|
368
|
+
fontFamily: 'Roboto, sans-serif',
|
|
369
|
+
// Freeze the tabs' physical size at their 200%-zoom appearance
|
|
370
|
+
// when browser zoom exceeds 200%. The factor is 1 at zoom <= 200%,
|
|
371
|
+
// so behavior below that threshold is unchanged. Using `zoom`
|
|
372
|
+
// (rather than transform: scale) shrinks the layout box itself,
|
|
373
|
+
// so the reclaimed space flows to the passage content below.
|
|
374
|
+
zoom: zoomCompensation,
|
|
375
|
+
'& .MuiTabs-list': {
|
|
376
|
+
backgroundColor: 'var(--pie-passage-header-background, #ffffff)',
|
|
377
|
+
borderBottom: '1px solid #D9DADA'
|
|
378
|
+
},
|
|
379
|
+
'& .MuiTabs-indicator': {
|
|
380
|
+
backgroundColor: _renderUi.color.white(),
|
|
381
|
+
marginBottom: '-1px'
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
value: activeTab,
|
|
385
|
+
onChange: this.handleChange
|
|
386
|
+
}, tabs.map((tab, index) => /*#__PURE__*/_react.default.createElement(TabStyled, {
|
|
387
|
+
key: tab.id,
|
|
388
|
+
id: `button-${tab.id}`,
|
|
389
|
+
sx: tabMaxWidth ? {
|
|
390
|
+
maxWidth: `${tabMaxWidth}px`
|
|
391
|
+
} : undefined,
|
|
392
|
+
label: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_renderUi.Purpose, {
|
|
393
|
+
purpose: "passage-label"
|
|
394
|
+
}, useNumericLabels ? /*#__PURE__*/_react.default.createElement("span", {
|
|
395
|
+
className: "passage-label"
|
|
396
|
+
}, `Passage ${index + 1}`) : /*#__PURE__*/_react.default.createElement("span", {
|
|
397
|
+
className: "passage-label",
|
|
398
|
+
dangerouslySetInnerHTML: {
|
|
399
|
+
__html: this.parsedText(tab.label)
|
|
400
|
+
}
|
|
401
|
+
})), /*#__PURE__*/_react.default.createElement(Underline, {
|
|
402
|
+
className: "passage-label-underline"
|
|
403
|
+
})),
|
|
404
|
+
value: tab.id,
|
|
405
|
+
tabIndex: activeTab === tab.id ? 0 : -1,
|
|
406
|
+
"aria-controls": `tabpanel-${tab.id}`,
|
|
407
|
+
"aria-selected": activeTab === tab.id,
|
|
408
|
+
onKeyDown: event => this.handleKeyDown(event, tab.id)
|
|
409
|
+
}))), selectedTab ? this.renderTab(selectedTab, disabledTabs) : null)));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
StimulusTabs.propTypes = {
|
|
413
|
+
tabs: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
414
|
+
id: _propTypes.default.number.isRequired,
|
|
415
|
+
label: _propTypes.default.string.isRequired,
|
|
416
|
+
title: _propTypes.default.string.isRequired,
|
|
417
|
+
subtitle: _propTypes.default.string,
|
|
418
|
+
author: _propTypes.default.string,
|
|
419
|
+
text: _propTypes.default.string.isRequired,
|
|
420
|
+
teacherInstructions: _propTypes.default.string
|
|
421
|
+
}).isRequired).isRequired,
|
|
422
|
+
disabledTabs: _propTypes.default.bool,
|
|
423
|
+
model: _propTypes.default.object,
|
|
424
|
+
baseHeadingLevel: _propTypes.default.number
|
|
425
|
+
};
|
|
426
|
+
var _default = exports.default = StimulusTabs;
|
|
427
|
+
//# sourceMappingURL=stimulus-tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stimulus-tabs.js","names":["_react","_interopRequireDefault","require","_propTypes","_Tabs","_Tab","_styles","_renderUi","STICKY_TABS_BREAKPOINT","MAX_TABS_ZOOM","MIN_ZOOM_COMPENSATION","NUMERIC_LABEL_MIN_WIDTH_PER_TAB","computeZoomCompensation","window","ratio","outerWidth","innerWidth","zoom","Number","isFinite","Math","max","min","PassagesContainer","styled","flexGrow","backgroundColor","color","background","text","borderCollapse","padding","textAlign","Passage","theme","spacing","borderLeft","margin","PassageTitle","fontSize","PassageSubtitle","PassageAuthor","TabStyled","Tab","palette","common","white","fontFamily","black","borderRadius","border","borderBottomWidth","minHeight","display","alignItems","justifyContent","textTransform","WebkitLineClamp","WebkitBoxOrient","overflow","textOverflow","whiteSpace","opacity","tertiary","tertiaryLight","Underline","height","width","marginTop","StimulusTabs","React","Component","constructor","args","_defineProperty2","default","activeTab","zoomCompensation","containerWidth","createRef","setState","node","containerRef","current","clientWidth","state","event","setTimeout","tabChangeEvent","CustomEvent","detail","tab","dispatchEvent","currentTabId","key","tabs","props","newTabIndex","currentIndex","findIndex","id","length","preventDefault","stopPropagation","handleChange","document","getElementById","focus","div","createElement","innerHTML","replace","audio","querySelector","source","setAttribute","getAttribute","removeAttribute","appendChild","componentDidMount","addEventListener","updateZoomCompensation","ResizeObserver","resizeObserver","updateContainerWidth","observe","componentWillUnmount","removeEventListener","disconnect","renderInstructions","teacherInstructions","disabledTabs","teacherInstructionsDiv","PreviewPrompt","tagName","className","defaultClassName","prompt","Collapsible","labels","hidden","visible","renderTab","baseHeadingLevel","clampedLevel","undefined","TitleTag","textLevel","role","title","Purpose","purpose","dangerouslySetInnerHTML","__html","parsedText","subtitle","author","transformDataHeadings","render","model","extraCSSRules","selectedTab","find","tabMaxWidth","useNumericLabels","UiLayout","ref","map","Fragment","sx","position","top","zIndex","borderBottom","marginBottom","value","onChange","index","maxWidth","label","tabIndex","onKeyDown","handleKeyDown","propTypes","PropTypes","arrayOf","shape","number","isRequired","string","bool","object","_default","exports"],"sources":["../src/stimulus-tabs.jsx"],"sourcesContent":["import 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, color, PreviewPrompt, Purpose, UiLayout, transformDataHeadings } from '@pie-lib/render-ui';\n\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 = 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 = 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 = styled('div')({\n fontSize: '1.75rem',\n});\n\nconst PassageSubtitle = styled('div')({\n fontSize: '1.5rem',\n});\n\nconst PassageAuthor = styled('div')({\n fontSize: '1.25rem',\n});\n\nconst TabStyled = 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: 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\nconst Underline = 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 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 = () => {\n this.setState({ zoomCompensation: computeZoomCompensation() });\n };\n\n updateContainerWidth = () => {\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 = (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 = (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 = (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 backgroundColor: 'var(--pie-passage-header-background, #ffffff)',\n borderBottom: '1px solid #D9DADA',\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":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMM,sBAAsB,GAAG,GAAG;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,CAAC;AACvB,MAAMC,qBAAqB,GAAG,GAAG;;AAEjC;AACA;AACA;AACA;AACA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as t,_dll_react as a,_dll_mui__material as n,_dll_mui__icons_material as i,_dll_react_dom_client as s}from"../../../@pie-lib/shared-module@^5.1.1/module/index.js";import{_dll_pie_lib__config_ui as l}from"../../../@pie-lib/config-module@^4.0.4/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as o}from"../../../@pie-lib/editable-html-module@^7.1.1/module/index.js";var r={};Object.defineProperty(r,"__esModule",{value:!0});class d extends CustomEvent{constructor(e,t=!1){super(d.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}d.TYPE="model.updated";var u=r.ModelUpdatedEvent=d;class c extends CustomEvent{constructor(e,t){super(c.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}c.TYPE="delete.image";var g=r.DeleteImageEvent=c;class p extends CustomEvent{constructor(e){super(p.TYPE,{bubbles:!0,detail:e}),this.handler=e}}p.TYPE="insert.image";var h=r.InsertImageEvent=p;class m extends CustomEvent{constructor(e,t){super(m.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}m.TYPE="delete.sound";var b=r.DeleteSoundEvent=m;class _ extends CustomEvent{constructor(e){super(_.TYPE,{bubbles:!0,detail:e}),this.handler=e}}_.TYPE="insert.sound";var C=r.InsertSoundEvent=_;const E=a,f=e,{styled:x}=t,{Button:S}=n,{Dialog:I}=n,{DialogTitle:v}=n,{DialogContent:P}=n,{DialogContentText:y}=n,{DialogActions:T}=n,{RemoveCircle:R}=i,{AddCircle:q}=i,D=x(({label:e,type:t="add",onClick:a})=>{const n="add"===t?q:R;return E.createElement(S,{color:"primary",size:"small",onClick:a},E.createElement(n,{fontSize:"small",color:"primary",style:{marginRight:4}}),e)})({textDecoration:"underline","&:hover":{textDecoration:"underline",backgroundColor:"transparent"},display:"flex",alignItems:"center"}),k=({content:e,cancel:t,title:a,ok:n,open:i,onOk:s,onCancel:l})=>E.createElement(I,{open:i},E.createElement(v,null,a),E.createElement(P,null,E.createElement(y,null,e)),E.createElement(T,null,s&&E.createElement(S,{onClick:s,color:"primary"},n),l&&E.createElement(S,{onClick:l,color:"primary"},t)));k.propTypes={content:f.string.isRequired,title:f.string.isRequired,cancel:f.string.isRequired,ok:f.string.isRequired,open:f.bool.isRequired,onCancel:f.func.isRequired,onOk:f.func.isRequired};const A=a,M=e,{styled:w}=t,{InputContainer:j}=l,O=o,{ALL_PLUGINS:Y}=o;function L(e){let t,a=e[0],n=1;for(;n<e.length;){const i=e[n],s=e[n+1];if(n+=2,("optionalAccess"===i||"optionalCall"===i)&&null==a)return;"access"===i||"optionalAccess"===i?(t=a,a=s(a)):"call"!==i&&"optionalCall"!==i||(a=s((...e)=>a.call(t,...e)),t=void 0)}return a}const H=w(j)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2),width:"100%"})),W=w("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)}));class z extends A.Component{static __initStatic(){this.propTypes={onModelChanged:M.func.isRequired,model:M.object.isRequired,configuration:M.object.isRequired,imageSupport:M.object.isRequired,passageIndex:M.number.isRequired,uploadSoundSupport:M.object.isRequired}}static __initStatic2(){this.defaultProps={passageIndex:0}}constructor(e){super(e),z.prototype.__init.call(this)}__init(){this.handleChange=(e,t)=>{const{model:a,onModelChanged:n,passageIndex:i}=this.props;if(!a.passages||i<0||i>=a.passages.length)return;const s=[...a.passages];s[i]={...s[i],[e]:t},n({...a,passages:s})}}render(){const{model:e,configuration:t,imageSupport:a,passageIndex:n,uploadSoundSupport:i}=this.props,{maxImageWidth:s={},maxImageHeight:l={},mathMlOptions:o={},baseInputConfiguration:r={},teacherInstructions:d={},title:u={},subtitle:c={},text:g={},author:p={}}=t||{},{errors:h={},passages:m=[],teacherInstructionsEnabled:b,titleEnabled:_,subtitleEnabled:C,authorEnabled:E,textEnabled:f}=e||{},{passages:x}=h||{},{teacherInstructions:S,title:I,subtitle:v,author:P,text:y}=x&&x[n]||{},T=s&&s.prompt,R=l&&l.prompt,q=e=>({...r,...e}),D=(Y||[]).filter(e=>!["math","table","bulleted-list","numbered-list"].includes(e));return A.createElement(A.Fragment,null,b&&A.createElement(H,{label:d.label},A.createElement(O,{activePlugins:Y,markup:m[n].teacherInstructions||"",onChange:e=>this.handleChange("teacherInstructions",e),nonEmpty:!1,error:S,maxImageWidth:s&&s.teacherInstructions||T,maxImageHeight:l&&l.teacherInstructions||R,mathMlOptions:o,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(L([d,"optionalAccess",e=>e.inputConfiguration]))}),S&&A.createElement(W,null,S)),_&&A.createElement(H,{label:u.label},A.createElement(O,{activePlugins:D,markup:m[n].title||"",onChange:e=>this.handleChange("title",e),nonEmpty:!1,error:I,mathMlOptions:o,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(L([u,"optionalAccess",e=>e.inputConfiguration]))}),I&&A.createElement(W,null,I)),C&&A.createElement(H,{label:c.label},A.createElement(O,{activePlugins:D,markup:m[n].subtitle||"",onChange:e=>this.handleChange("subtitle",e),nonEmpty:!1,error:v,mathMlOptions:o,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(L([c,"optionalAccess",e=>e.inputConfiguration]))}),v&&A.createElement(W,null,v)),E&&A.createElement(H,{label:p.label},A.createElement(O,{activePlugins:D,markup:m[n].author||"",onChange:e=>this.handleChange("author",e),nonEmpty:!1,error:P,mathMlOptions:o,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(L([p,"optionalAccess",e=>e.inputConfiguration]))}),P&&A.createElement(W,null,P)),f&&A.createElement(H,{label:g.label},A.createElement(O,{activePlugins:Y,markup:m[n].text||"",onChange:e=>this.handleChange("text",e),imageSupport:a,uploadSoundSupport:i,nonEmpty:!1,error:y,maxImageWidth:s&&s.text||T,maxImageHeight:l&&l.text||R,mathMlOptions:o,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(L([g,"optionalAccess",e=>e.inputConfiguration]))}),y&&A.createElement(W,null,y)))}}z.__initStatic(),z.__initStatic2();const B=a,$=e,{styled:F}=t,{Typography:U}=n,{settings:G}=l,{layout:N}=l,{Panel:J,toggle:K,dropdown:Q}=G,V=F(U)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2)}));class X extends B.Component{static __initStatic(){this.propTypes={onModelChanged:$.func.isRequired,onConfigurationChanged:$.func,model:$.object.isRequired,configuration:$.object.isRequired,imageSupport:$.object.isRequired,uploadSoundSupport:$.object.isRequired,classes:$.object.isRequired}}constructor(e){super(e),X.prototype.__init.call(this),X.prototype.__init2.call(this),X.prototype.__init3.call(this),X.prototype.__init4.call(this),this.state={showConfirmationDialog:!1,indexToRemove:-1}}__init(){this.getInnerText=e=>(e||"").replaceAll(/<[^>]*>/g,"")}__init2(){this.onDelete=(e,t,a)=>{let n=e.passages;n.splice(t,1),a({...e,passages:n}),this.setState({showConfirmationDialog:!1,indexToRemove:-1})}}__init3(){this.removeAdditionalPassage=e=>{const{model:t={},onModelChanged:a}=this.props,{passages:n=[]}=t,{teacherInstructions:i="",title:s="",subtitle:l="",author:o="",text:r=""}=n[e];this.getInnerText(i).trim()||this.getInnerText(s).trim()||this.getInnerText(l).trim()||this.getInnerText(o).trim()||this.getInnerText(r).trim()?this.setState({showConfirmationDialog:!0,indexToRemove:e}):this.onDelete(t,e,a)}}__init4(){this.addAdditionalPassage=()=>{const{model:e,onModelChanged:t}=this.props,a=[...e.passages,{teacherInstructions:"",title:"",subtitle:"",author:"",text:""}];t({...e,passages:a})}}render(){const{model:e,configuration:t,imageSupport:a,onConfigurationChanged:n,onModelChanged:i,uploadSoundSupport:s}=this.props,{settingsPanelDisabled:l,language:o={},languageChoices:r={},teacherInstructions:d={},title:u={},subtitle:c={},text:g={},author:p={},additionalPassage:h={}}=t||{},{extraCSSRules:m,passages:b}=e||{},_={titleEnabled:u&&u.settings&&K(u.label),subtitleEnabled:c&&c.settings&&K(c.label),authorEnabled:p&&p.settings&&K(p.label),textEnabled:g&&g.settings&&K(g.label),"additionalPassage.enabled":h&&h.settings&&K(h.label,!0)},C={teacherInstructionsEnabled:d&&d.settings&&K(d.label),"language.enabled":o&&o.settings&&K(o.label,!0),language:o&&o.settings&&o.enabled&&Q(r.label,r.options)},E=`${h.label} will be deleted`,{indexToRemove:f,showConfirmationDialog:x}=this.state;return B.createElement(N.ConfigLayout,{extraCSSRules:m,hideSettings:l,settings:B.createElement(J,{model:e,configuration:t,onChangeModel:e=>i(e),onChangeConfiguration:e=>n(e),groups:{Settings:_,Properties:C}})},b.map((n,l)=>B.createElement(B.Fragment,{key:l},l>0&&B.createElement(V,{variant:"h5"},h.label),B.createElement(z,{imageSupport:a,uploadSoundSupport:s,model:e,configuration:t,passageIndex:l,onModelChanged:i}),l>0&&h.enabled&&B.createElement(D,{type:"remove",label:`Remove ${h.label}`,onClick:()=>this.removeAdditionalPassage(l)}),0===l&&h.enabled&&b.length<2&&B.createElement(D,{label:`Add ${h.label}`,onClick:this.addAdditionalPassage}))),B.createElement(k,{open:x,title:"Warning",content:E,cancel:"Cancel",ok:"Ok",onCancel:()=>this.setState({showConfirmationDialog:!1}),onOk:()=>this.onDelete(e,f,i)}))}}X.__initStatic();var Z={authorEnabled:!0,passages:[{teacherInstructions:"",title:"",subtitle:"",author:"",text:""}],subtitleEnabled:!0,teacherInstructionsEnabled:!0,textEnabled:!0,titleEnabled:!0},ee={baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!0},blockquote:{disabled:!0},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},settingsPanelDisabled:!1,title:{settings:!0,label:"Title",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0},textAlign:{disabled:!1}},required:!0},subtitle:{settings:!0,label:"Subtitle",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0},textAlign:{disabled:!1}},required:!1},author:{settings:!0,label:"Author",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0}},required:!1},text:{settings:!0,label:"Text",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!1},blockquote:{disabled:!1},textAlign:{disabled:!1}},required:!0},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},maxImageWidth:{teacherInstructions:300,text:300},maxImageHeight:{teacherInstructions:300,text:300},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]},additionalPassage:{settings:!0,label:"Additional Passage",enabled:!1}};const te=a,{createRoot:ae}=s;class ne extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={})=>({...Z,...e})}constructor(){super(),this._root=null,this._model=ne.createDefaultModel(),this._configuration=ee}set model(e){this._model=ne.createDefaultModel(e),this.render()}set configuration(e){this._configuration=e,this.render()}connectedCallback(){this.render()}modelChanged(e){this._model=e,this.dispatchEvent(new u(this._model),!0),this.render()}onConfigurationChanged(e){this._configuration=e,this.render()}insertImage(e){this.dispatchEvent(new h(e))}onDeleteImage(e,t){this.dispatchEvent(new g(e,t))}insertSound(e){this.dispatchEvent(new C(e))}onDeleteSound(e,t){this.dispatchEvent(new b(e,t))}render(){if(this._model){const e=te.createElement(X,{model:this._model,configuration:this._configuration,onModelChanged:this.modelChanged.bind(this),onConfigurationChanged:this.onConfigurationChanged.bind(this),imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(this._root=ae(this)),this._root.render(e)}}disconnectedCallback(){this._root&&this._root.unmount()}}ne.__initStatic();export{ne as default};
|