@pie-element/passage 6.1.0-next.0 → 6.1.1-next.1
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.md +628 -1618
- package/configure/CHANGELOG.md +139 -542
- package/configure/package.json +3 -3
- package/controller/package.json +1 -1
- package/package.json +5 -8
- package/module/configure.js +0 -1
- package/module/controller.js +0 -920
- package/module/demo.js +0 -57
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -10
- package/module/print-demo.js +0 -95
- package/module/print.html +0 -18
- package/module/print.js +0 -1
package/module/demo.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import Configure from './configure.js';
|
|
2
|
-
import Element from './element.js';
|
|
3
|
-
import * as controller from './controller.js';
|
|
4
|
-
|
|
5
|
-
var generate = {};
|
|
6
|
-
|
|
7
|
-
generate.model = (id, element) => ({
|
|
8
|
-
id,
|
|
9
|
-
element,
|
|
10
|
-
passages: [
|
|
11
|
-
{
|
|
12
|
-
teacherInstructions: 'Teacher instructions for first tab',
|
|
13
|
-
title: 'Hope Is the Thing with Feathers',
|
|
14
|
-
subtitle: 'from <em>The Complete Poems of Emily Dickinson</em>',
|
|
15
|
-
author: 'by Emily Dickinson',
|
|
16
|
-
text: '<p><font style="visibility:hidden">00000</font>Hope is the thing with feathers<br /><font style="visibility:hidden">00000</font>That perches in the soul,<br /><font style="visibility:hidden">00000</font>And sings the tune without the words,<br /><font style="visibility:hidden">00000</font>And never stops at all,</p><p>5<font style="visibility:hidden">0000</font>And sweetest in the gale is heard;<br /><font style="visibility:hidden">00000</font>And sore must be the storm<br /><font style="visibility:hidden">00000</font>That could abash the little bird<br /><font style="visibility:hidden">00000</font>That kept so many warm.</p><p><font style="visibility:hidden">00000</font>I’ve heard it in the chillest land,<br />10<font style="visibility:hidden">000</font>And on the strangest sea;<br /><font style="visibility:hidden">00000</font>Yet, never, in extremity,<br /><font style="visibility:hidden">00000</font>It asked a crumb of me.</p>',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
title: 'Ineskeen Road, July Evening',
|
|
20
|
-
text: `The bicycles go by in twos and threes -<br/>
|
|
21
|
-
There's a dance in Billy Brennan's barn tonight,<br/>
|
|
22
|
-
And there's the half-talk code of mysteries<br/>
|
|
23
|
-
And the wink-and-elbow language of delight.<br/>
|
|
24
|
-
Half-past eight and there is not a spot<br/>
|
|
25
|
-
Upon a mile of road, no shadow thrown<br/>
|
|
26
|
-
That might turn out a man or woman, not<br/>
|
|
27
|
-
A footfall tapping secrecies of stone. <br/>
|
|
28
|
-
<p/>
|
|
29
|
-
I have what every poet hates in spite<br/>
|
|
30
|
-
Of all the solemn talk of contemplation.<br/>
|
|
31
|
-
Oh, Alexander Selkirk knew the plight<br/>
|
|
32
|
-
Of being king and government and nation.<br/>
|
|
33
|
-
A road, a mile of kingdom. I am king<br/>
|
|
34
|
-
Of banks and stones and every blooming thing.<br/>
|
|
35
|
-
`,
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const { model } = generate;
|
|
41
|
-
|
|
42
|
-
var config = {
|
|
43
|
-
elements: {
|
|
44
|
-
'passage-element': '../..',
|
|
45
|
-
},
|
|
46
|
-
models: [model('1', 'passage-element')],
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
//Note: demo-el is a custom element loaded in the markup.
|
|
50
|
-
customElements.whenDefined("demo-el").then(() => {
|
|
51
|
-
config.models.forEach((m) => {
|
|
52
|
-
const de = document.createElement("demo-el");
|
|
53
|
-
document.body.appendChild(de);
|
|
54
|
-
de.def = { tagName: m.element, Element, Configure, controller };
|
|
55
|
-
de.model = m;
|
|
56
|
-
});
|
|
57
|
-
});
|
package/module/element.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_dll_pie_lib__math_rendering as e}from"../../../@pie-lib/math-rendering-module@^4.0.7/module/index.js";import{_dll_react_dom as t,_dll_react as s,_dll_prop_types as a,_dll_mui__material as n,_dll_mui__material_styles as o,_dll_pie_lib__render_ui as i}from"../../../@pie-lib/shared-module@^4.0.1/module/index.js";var r={};Object.defineProperty(r,"__esModule",{value:!0});class l extends CustomEvent{constructor(e,t,s){super(l.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:s}}),this.component=e,this.complete=t}}l.TYPE="model-set";var c=r.ModelSetEvent=l;class d extends CustomEvent{constructor(e,t){super(d.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}d.TYPE="session-changed",r.SessionChangedEvent=d;var u,h=t;u=h.createRoot,h.hydrateRoot;const p=s,m=a,{Tabs:b}=n,{Tab:g}=n,{styled:_}=o,{Collapsible:E}=i,{color:T}=i,{PreviewPrompt:x}=i,{Purpose:y}=i,{UiLayout:f}=i;const v=_("div")({flexGrow:1,backgroundColor:T.background(),color:T.text(),"&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:".6em 1em",textAlign:"left"}}),C=_("div")(({theme:e})=>({backgroundColor:T.background(),color:T.text(),padding:e.spacing(2)})),k=_("div")({fontSize:"1.75rem"}),M=_("div")({fontSize:"1.5rem"}),S=_("div")({fontSize:"1.25rem"}),w=_(g)(({theme:e})=>({background:e.palette.common.white,fontSize:"inherit",fontFamily:"Roboto, sans-serif",opacity:.7,color:e.palette.common.black,"&.Mui-selected":{opacity:1,color:e.palette.common.black}}));class A extends p.Component{constructor(...e){super(...e),A.prototype.__init.call(this),A.prototype.__init2.call(this),A.prototype.__init3.call(this),A.prototype.__init4.call(this)}__init(){this.state={activeTab:0}}__init2(){this.handleChange=(e,t)=>{this.setState(()=>({activeTab:t})),setTimeout(()=>{const e=new CustomEvent("pie-ui-passage-tabChanged",{detail:{tab:t}});window.dispatchEvent(e)})}}__init3(){this.handleKeyDown=(e,t)=>{const{key:s}=e,{tabs:a}=this.props;let n=-1;const o=a.findIndex(e=>e.id===t);switch(s){case"ArrowRight":n=(o+1)%a.length;break;case"ArrowLeft":n=(o-1+a.length)%a.length;break;case"Home":n=0;break;case"End":n=a.length-1;break;case"Enter":case" ":n=o}-1!==n&&(e.preventDefault(),this.handleChange(e,a[n].id),document.getElementById(`button-${a[n].id}`).focus())}}__init4(){this.parsedText=(e="")=>{const t=document.createElement("div");t.innerHTML=e.replace(/(<br\/>\n)/g,"<br/>");const s=t.querySelector("audio");if(s){const e=document.createElement("source");e.setAttribute("type","audio/mp3"),e.setAttribute("src",s.getAttribute("src")),s.removeAttribute("src"),s.appendChild(e)}return t.innerHTML}}renderInstructions(e,t=!1){if(!e)return;const s=p.createElement(x,{tagName:"div",className:"prompt",defaultClassName:"teacher-instructions",prompt:e});return t?s:p.createElement(E,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},s)}renderTab(e,t){return p.createElement(C,{key:e.id,id:`tabpanel-${e.id}`,role:"tabpanel","aria-labelledby":`button-${e.id}`},this.renderInstructions(e.teacherInstructions,t),(e.title||e.subtitle)&&p.createElement("h2",null,e.title&&p.createElement(y,{purpose:"passage-title"},p.createElement(k,{dangerouslySetInnerHTML:{__html:this.parsedText(e.title)}})),e.subtitle&&p.createElement(y,{purpose:"passage-subtitle"},p.createElement(M,{dangerouslySetInnerHTML:{__html:this.parsedText(e.subtitle)}}))),e.author&&p.createElement(y,{purpose:"passage-author"},p.createElement(S,{className:"author",dangerouslySetInnerHTML:{__html:this.parsedText(e.author)}})),e.text&&p.createElement(y,{purpose:"passage-text"},p.createElement("div",{key:e.id,className:"text",dangerouslySetInnerHTML:{__html:this.parsedText(e.text)}})))}render(){const{model:e,tabs:t,disabledTabs:s}=this.props,{activeTab:a}=this.state;if(!function(e){let t,s=e[0],a=1;for(;a<e.length;){const n=e[a],o=e[a+1];if(a+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}([t,"optionalAccess",e=>e.length]))return;const{extraCSSRules:n}=e||{},o=(t||[]).find(e=>e.id===a);return p.createElement(f,{extraCSSRules:n},p.createElement(v,{className:"passages"},s||1===t.length?t.map(e=>this.renderTab(e,s)):p.createElement(p.Fragment,null,p.createElement(b,{sx:{position:"sticky",top:0,background:T.background(),color:T.text(),fontFamily:"Roboto, sans-serif","& .MuiTabs-indicator":{backgroundColor:"#f50057"}},value:a,onChange:this.handleChange},t.map(e=>p.createElement(w,{key:e.id,id:`button-${e.id}`,label:p.createElement(y,{purpose:"passage-label"},p.createElement("span",{dangerouslySetInnerHTML:{__html:this.parsedText(e.label)}})),value:e.id,tabIndex:a===e.id?0:-1,"aria-controls":`tabpanel-${e.id}`,"aria-selected":a===e.id,onFocus:()=>this.handleChange(null,e.id),onKeyDown:t=>this.handleKeyDown(t,e.id)}))),o?this.renderTab(o,s):null)))}}A.propTypes={tabs:m.arrayOf(m.shape({id:m.number.isRequired,label:m.string.isRequired,title:m.string.isRequired,subtitle:m.string,author:m.string,text:m.string.isRequired,teacherInstructions:m.string}).isRequired).isRequired,disabledTabs:m.bool,model:m.object};const{renderMath:I}=e,L=s;class R extends HTMLElement{constructor(){super(),this._model={passages:[]},this._session=null,this._root=null}setLangAttribute(){const e=this._model&&(this._model.language,1)?this._model.language:"",t=e?e.slice(0,2):"en";this.setAttribute("lang",t)}set model(e){this._model=e,this.dispatchEvent(new c(this.tagName.toLowerCase(),this._session,!!this._model)),this.setLangAttribute(),this._render()}set session(e){this._session=e}connectedCallback(){this.setAttribute("aria-label","Passage"),this.setAttribute("role","region"),this._render()}_render(){const{passages:e=[]}=this._model;if(this._model.passages.length>0){const t=e.map((e,t)=>({id:t,...e})),s=L.createElement(A,{tabs:t});this._root||(this._root=u(this)),this._root.render(s),queueMicrotask(()=>{I(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{R as default};
|
package/module/index.html
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<title>@pie-element/passage@6.1.0-next.0</title>
|
|
6
|
-
<script
|
|
7
|
-
type="module"
|
|
8
|
-
src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
|
|
9
|
-
|
|
10
|
-
<link
|
|
11
|
-
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
12
|
-
rel="stylesheet"
|
|
13
|
-
/>
|
|
14
|
-
<style>
|
|
15
|
-
html, body {
|
|
16
|
-
font-family: 'Roboto', sans-serif;
|
|
17
|
-
}
|
|
18
|
-
</style>
|
|
19
|
-
<script type="module" src="./demo.js"></script>
|
|
20
|
-
</head>
|
|
21
|
-
</html>
|
package/module/manifest.json
DELETED
package/module/print-demo.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import PrintElement from './print.js';
|
|
2
|
-
|
|
3
|
-
var generate = {};
|
|
4
|
-
|
|
5
|
-
generate.model = (id, element) => ({
|
|
6
|
-
id,
|
|
7
|
-
element,
|
|
8
|
-
passages: [
|
|
9
|
-
{
|
|
10
|
-
teacherInstructions: 'Teacher instructions for first tab',
|
|
11
|
-
title: 'Hope Is the Thing with Feathers',
|
|
12
|
-
subtitle: 'from <em>The Complete Poems of Emily Dickinson</em>',
|
|
13
|
-
author: 'by Emily Dickinson',
|
|
14
|
-
text: '<p><font style="visibility:hidden">00000</font>Hope is the thing with feathers<br /><font style="visibility:hidden">00000</font>That perches in the soul,<br /><font style="visibility:hidden">00000</font>And sings the tune without the words,<br /><font style="visibility:hidden">00000</font>And never stops at all,</p><p>5<font style="visibility:hidden">0000</font>And sweetest in the gale is heard;<br /><font style="visibility:hidden">00000</font>And sore must be the storm<br /><font style="visibility:hidden">00000</font>That could abash the little bird<br /><font style="visibility:hidden">00000</font>That kept so many warm.</p><p><font style="visibility:hidden">00000</font>I’ve heard it in the chillest land,<br />10<font style="visibility:hidden">000</font>And on the strangest sea;<br /><font style="visibility:hidden">00000</font>Yet, never, in extremity,<br /><font style="visibility:hidden">00000</font>It asked a crumb of me.</p>',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
title: 'Ineskeen Road, July Evening',
|
|
18
|
-
text: `The bicycles go by in twos and threes -<br/>
|
|
19
|
-
There's a dance in Billy Brennan's barn tonight,<br/>
|
|
20
|
-
And there's the half-talk code of mysteries<br/>
|
|
21
|
-
And the wink-and-elbow language of delight.<br/>
|
|
22
|
-
Half-past eight and there is not a spot<br/>
|
|
23
|
-
Upon a mile of road, no shadow thrown<br/>
|
|
24
|
-
That might turn out a man or woman, not<br/>
|
|
25
|
-
A footfall tapping secrecies of stone. <br/>
|
|
26
|
-
<p/>
|
|
27
|
-
I have what every poet hates in spite<br/>
|
|
28
|
-
Of all the solemn talk of contemplation.<br/>
|
|
29
|
-
Oh, Alexander Selkirk knew the plight<br/>
|
|
30
|
-
Of being king and government and nation.<br/>
|
|
31
|
-
A road, a mile of kingdom. I am king<br/>
|
|
32
|
-
Of banks and stones and every blooming thing.<br/>
|
|
33
|
-
`,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const { model } = generate;
|
|
39
|
-
|
|
40
|
-
var config = {
|
|
41
|
-
elements: {
|
|
42
|
-
'passage-element': '../..',
|
|
43
|
-
},
|
|
44
|
-
models: [model('1', 'passage-element')],
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// new init - just shows off print!
|
|
48
|
-
|
|
49
|
-
const init = async () => {
|
|
50
|
-
console.log('define the element...');
|
|
51
|
-
await Promise.all(
|
|
52
|
-
config.models.map(async (m) => {
|
|
53
|
-
try {
|
|
54
|
-
const printTag = `${m.element}-print`;
|
|
55
|
-
if (customElements.get(printTag)) {
|
|
56
|
-
return true;
|
|
57
|
-
} else {
|
|
58
|
-
customElements.define(printTag, PrintElement);
|
|
59
|
-
await customElements.whenDefined(printTag);
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
} catch (e) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
console.log('now apply the model...');
|
|
69
|
-
config.models.forEach((m) => {
|
|
70
|
-
const printTag = `${m.element}-print`;
|
|
71
|
-
const h3s = document.createElement('h3');
|
|
72
|
-
h3s.textContent = 'student mode';
|
|
73
|
-
document.body.appendChild(h3s);
|
|
74
|
-
const de = document.createElement(printTag);
|
|
75
|
-
document.body.appendChild(de);
|
|
76
|
-
de.options = {};
|
|
77
|
-
de.model = m;
|
|
78
|
-
|
|
79
|
-
const h3 = document.createElement('h3');
|
|
80
|
-
h3.textContent = 'instructor mode';
|
|
81
|
-
document.body.appendChild(h3);
|
|
82
|
-
const instr = document.createElement(printTag);
|
|
83
|
-
document.body.appendChild(instr);
|
|
84
|
-
instr.options = { mode: 'instructor' };
|
|
85
|
-
instr.model = JSON.parse(JSON.stringify(m));
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
init()
|
|
90
|
-
.then(() => {
|
|
91
|
-
console.log('ready');
|
|
92
|
-
})
|
|
93
|
-
.catch((e) => {
|
|
94
|
-
console.error(e);
|
|
95
|
-
});
|
package/module/print.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<title>@pie-element/passage@6.1.0-next.0</title>
|
|
6
|
-
<link
|
|
7
|
-
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
8
|
-
rel="stylesheet"
|
|
9
|
-
/>
|
|
10
|
-
<style>
|
|
11
|
-
html, body {
|
|
12
|
-
font-family: 'Roboto', sans-serif;
|
|
13
|
-
}
|
|
14
|
-
</style>
|
|
15
|
-
<script type="module" src="./print-demo.js"></script>
|
|
16
|
-
</head>
|
|
17
|
-
<body></body>
|
|
18
|
-
</html>
|
package/module/print.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_dll_react_dom as e,_dll_react as t,_dll_prop_types as n,_dll_mui__material as r,_dll_mui__material_styles as a,_dll_pie_lib__render_ui as i,_dll_debug as o}from"../../../@pie-lib/shared-module@^4.0.1/module/index.js";var s,l=e;s=l.createRoot,l.hydrateRoot;var c="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,d=c||u||Function("return this")(),h=d.Symbol,p=Object.prototype,b=p.hasOwnProperty,m=p.toString,f=h?h.toStringTag:void 0;var g=Object.prototype.toString;var v=h?h.toStringTag:void 0;function y(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":v&&v in Object(e)?function(e){var t=b.call(e,f),n=e[f];try{e[f]=void 0;var r=!0}catch(e){}var a=m.call(e);return r&&(t?e[f]=n:delete e[f]),a}(e):function(e){return g.call(e)}(e)}var _=/\s/;var E=/^\s+/;function T(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&_.test(e.charAt(t)););return t}(e)+1).replace(E,""):e}function x(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var k=/^[-+]0x[0-9a-f]+$/i,S=/^0b[01]+$/i,C=/^0o[0-7]+$/i,I=parseInt;function w(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==y(e)}(e))return NaN;if(x(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=x(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=T(e);var n=S.test(e);return n||C.test(e)?I(e.slice(2),n?2:8):k.test(e)?NaN:+e}var j=function(){return d.Date.now()},M=Math.max,R=Math.min;function A(e,t,n){var r,a,i,o,s,l,c=0,u=!1,d=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function p(t){var n=r,i=a;return r=a=void 0,c=t,o=e.apply(i,n)}function b(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=i}function m(){var e=j();if(b(e))return f(e);s=setTimeout(m,function(e){var n=t-(e-l);return d?R(n,i-(e-c)):n}(e))}function f(e){return s=void 0,h&&r?p(e):(r=a=void 0,o)}function g(){var e=j(),n=b(e);if(r=arguments,a=this,l=e,n){if(void 0===s)return function(e){return c=e,s=setTimeout(m,t),u?p(e):o}(l);if(d)return clearTimeout(s),s=setTimeout(m,t),p(l)}return void 0===s&&(s=setTimeout(m,t)),o}return t=w(t)||0,x(n)&&(u=!!n.leading,i=(d="maxWait"in n)?M(w(n.maxWait)||0,t):i,h="trailing"in n?!!n.trailing:h),g.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=a=s=void 0},g.flush=function(){return void 0===s?o:f(j())},g}const N=t,O=n,{Tabs:H}=r,{Tab:L}=r,{styled:$}=a,{Collapsible:q}=i,{color:D}=i,{PreviewPrompt:F}=i,{Purpose:P}=i,{UiLayout:z}=i;const J=$("div")({flexGrow:1,backgroundColor:D.background(),color:D.text(),"&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:".6em 1em",textAlign:"left"}}),K=$("div")(({theme:e})=>({backgroundColor:D.background(),color:D.text(),padding:e.spacing(2)})),U=$("div")({fontSize:"1.75rem"}),W=$("div")({fontSize:"1.5rem"}),B=$("div")({fontSize:"1.25rem"}),G=$(L)(({theme:e})=>({background:e.palette.common.white,fontSize:"inherit",fontFamily:"Roboto, sans-serif",opacity:.7,color:e.palette.common.black,"&.Mui-selected":{opacity:1,color:e.palette.common.black}}));class Q extends N.Component{constructor(...e){super(...e),Q.prototype.__init.call(this),Q.prototype.__init2.call(this),Q.prototype.__init3.call(this),Q.prototype.__init4.call(this)}__init(){this.state={activeTab:0}}__init2(){this.handleChange=(e,t)=>{this.setState(()=>({activeTab:t})),setTimeout(()=>{const e=new CustomEvent("pie-ui-passage-tabChanged",{detail:{tab:t}});window.dispatchEvent(e)})}}__init3(){this.handleKeyDown=(e,t)=>{const{key:n}=e,{tabs:r}=this.props;let a=-1;const i=r.findIndex(e=>e.id===t);switch(n){case"ArrowRight":a=(i+1)%r.length;break;case"ArrowLeft":a=(i-1+r.length)%r.length;break;case"Home":a=0;break;case"End":a=r.length-1;break;case"Enter":case" ":a=i}-1!==a&&(e.preventDefault(),this.handleChange(e,r[a].id),document.getElementById(`button-${r[a].id}`).focus())}}__init4(){this.parsedText=(e="")=>{const t=document.createElement("div");t.innerHTML=e.replace(/(<br\/>\n)/g,"<br/>");const n=t.querySelector("audio");if(n){const e=document.createElement("source");e.setAttribute("type","audio/mp3"),e.setAttribute("src",n.getAttribute("src")),n.removeAttribute("src"),n.appendChild(e)}return t.innerHTML}}renderInstructions(e,t=!1){if(!e)return;const n=N.createElement(F,{tagName:"div",className:"prompt",defaultClassName:"teacher-instructions",prompt:e});return t?n:N.createElement(q,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},n)}renderTab(e,t){return N.createElement(K,{key:e.id,id:`tabpanel-${e.id}`,role:"tabpanel","aria-labelledby":`button-${e.id}`},this.renderInstructions(e.teacherInstructions,t),(e.title||e.subtitle)&&N.createElement("h2",null,e.title&&N.createElement(P,{purpose:"passage-title"},N.createElement(U,{dangerouslySetInnerHTML:{__html:this.parsedText(e.title)}})),e.subtitle&&N.createElement(P,{purpose:"passage-subtitle"},N.createElement(W,{dangerouslySetInnerHTML:{__html:this.parsedText(e.subtitle)}}))),e.author&&N.createElement(P,{purpose:"passage-author"},N.createElement(B,{className:"author",dangerouslySetInnerHTML:{__html:this.parsedText(e.author)}})),e.text&&N.createElement(P,{purpose:"passage-text"},N.createElement("div",{key:e.id,className:"text",dangerouslySetInnerHTML:{__html:this.parsedText(e.text)}})))}render(){const{model:e,tabs:t,disabledTabs:n}=this.props,{activeTab:r}=this.state;if(!function(e){let t,n=e[0],r=1;for(;r<e.length;){const a=e[r],i=e[r+1];if(r+=2,("optionalAccess"===a||"optionalCall"===a)&&null==n)return;"access"===a||"optionalAccess"===a?(t=n,n=i(n)):"call"!==a&&"optionalCall"!==a||(n=i((...e)=>n.call(t,...e)),t=void 0)}return n}([t,"optionalAccess",e=>e.length]))return;const{extraCSSRules:a}=e||{},i=(t||[]).find(e=>e.id===r);return N.createElement(z,{extraCSSRules:a},N.createElement(J,{className:"passages"},n||1===t.length?t.map(e=>this.renderTab(e,n)):N.createElement(N.Fragment,null,N.createElement(H,{sx:{position:"sticky",top:0,background:D.background(),color:D.text(),fontFamily:"Roboto, sans-serif","& .MuiTabs-indicator":{backgroundColor:"#f50057"}},value:r,onChange:this.handleChange},t.map(e=>N.createElement(G,{key:e.id,id:`button-${e.id}`,label:N.createElement(P,{purpose:"passage-label"},N.createElement("span",{dangerouslySetInnerHTML:{__html:this.parsedText(e.label)}})),value:e.id,tabIndex:r===e.id?0:-1,"aria-controls":`tabpanel-${e.id}`,"aria-selected":r===e.id,onFocus:()=>this.handleChange(null,e.id),onKeyDown:t=>this.handleKeyDown(t,e.id)}))),i?this.renderTab(i,n):null)))}}Q.propTypes={tabs:O.arrayOf(O.shape({id:O.number.isRequired,label:O.string.isRequired,title:O.string.isRequired,subtitle:O.string,author:O.string,text:O.string.isRequired,teacherInstructions:O.string}).isRequired).isRequired,disabledTabs:O.bool,model:O.object};const V=t,X=o("pie-element:passage:print"),Y=(e,t)=>(e=>null!=e)(e)?e:t;class Z extends HTMLElement{constructor(){super(),this._model=null,this._options=null,this._session=[],this._root=null,this._rerender=A(()=>{if(this._model&&this._session){if(this._model.passages&&this._model.passages.length>0){const e=((e,t)=>{const n="instructor"===t.role,r=Y(e.teacherInstructionsEnabled,!0),a=Y(e.titleEnabled,!0),i=Y(e.authorEnabled,!1),o=Y(e.subtitleEnabled,!0),s=Y(e.textEnabled,!0);return e.passages.map((e,t)=>({id:t,teacherInstructions:Y(e.teacherInstructionsEnabled,r)&&n&&e.teacherInstructions||"",label:e.title||`Passage ${t+1}`,title:Y(e.titleEnabled,a)&&e.title||"",author:Y(e.authorEnabled,i)&&e.author||"",subtitle:Y(e.subtitleEnabled,o)&&e.subtitle||"",text:Y(e.textEnabled,s)&&e.text||""}))})(this._model,this._options),t=V.createElement(Q,{disabledTabs:!0,tabs:e});this._root||(this._root=s(this)),this._root.render(t)}}else X("skip")},50,{leading:!1,trailing:!0})}set model(e){this._model=e,this._rerender()}set options(e){this._options=e}connectedCallback(){}disconnectedCallback(){this._root&&this._root.unmount()}}export{Z as default};
|