@pie-element/passage 6.0.0-next.0 → 6.0.0-next.43
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/configure/package.json +5 -5
- package/controller/lib/index.js +3 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/lib/print.js +2 -2
- package/lib/print.js.map +1 -1
- package/lib/stimulus-tabs.js +2 -13
- package/lib/stimulus-tabs.js.map +1 -1
- package/module/configure.js +1 -1
- package/module/controller.js +443 -295
- package/module/element.js +1 -1
- package/module/manifest.json +1 -1
- package/module/print.js +1 -1
- package/package.json +4 -4
package/module/element.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_dll_pie_lib__math_rendering as e}from"../../../@pie-lib/math-rendering-module@^4.0.
|
|
1
|
+
import{_dll_pie_lib__math_rendering as e}from"../../../@pie-lib/math-rendering-module@^4.0.5/module/index.js";import{_dll_react_dom as t,_dll_react as s,_dll_prop_types as n,_dll_mui__material as a,_dll_mui__material_styles as i,_dll_pie_lib__render_ui as r}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";var o={};Object.defineProperty(o,"__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=o.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",o.SessionChangedEvent=d;var h,u=t;h=u.createRoot,u.hydrateRoot;const p=s,m=n,{Tabs:b}=a,{Tab:g}=a,{styled:_}=i,{Collapsible:E}=r,{color:T}=r,{PreviewPrompt:x}=r,{Purpose:v}=r,{UiLayout:y}=r;const f=_("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"}),S=_("div")({fontSize:"1.5rem"}),M=_("div")({fontSize:"1.25rem"}),w=_(g)(({theme:e})=>({background:e.palette.common.white,fontSize:"inherit",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:n}=this.props;let a=-1;const i=n.findIndex(e=>e.id===t);switch(s){case"ArrowRight":a=(i+1)%n.length;break;case"ArrowLeft":a=(i-1+n.length)%n.length;break;case"Home":a=0;break;case"End":a=n.length-1;break;case"Enter":case" ":a=i}-1!==a&&(e.preventDefault(),this.handleChange(e,n[a].id),document.getElementById(`button-${n[a].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(v,{purpose:"passage-title"},p.createElement(k,{dangerouslySetInnerHTML:{__html:this.parsedText(e.title)}})),e.subtitle&&p.createElement(v,{purpose:"passage-subtitle"},p.createElement(S,{dangerouslySetInnerHTML:{__html:this.parsedText(e.subtitle)}}))),e.author&&p.createElement(v,{purpose:"passage-author"},p.createElement(M,{className:"author",dangerouslySetInnerHTML:{__html:this.parsedText(e.author)}})),e.text&&p.createElement(v,{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:n}=this.state;if(!function(e){let t,s=e[0],n=1;for(;n<e.length;){const a=e[n],i=e[n+1];if(n+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=i(s)):"call"!==a&&"optionalCall"!==a||(s=i((...e)=>s.call(t,...e)),t=void 0)}return s}([t,"optionalAccess",e=>e.length]))return;const{extraCSSRules:a}=e||{},i=(t||[]).find(e=>e.id===n);return p.createElement(y,{extraCSSRules:a},p.createElement(f,{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()},value:n,onChange:this.handleChange},t.map(e=>p.createElement(w,{key:e.id,id:`button-${e.id}`,label:p.createElement(v,{purpose:"passage-label"},p.createElement("span",{dangerouslySetInnerHTML:{__html:this.parsedText(e.label)}})),value:e.id,tabIndex:n===e.id?0:-1,"aria-controls":`tabpanel-${e.id}`,"aria-selected":n===e.id,onFocus:()=>this.handleChange(null,e.id),onKeyDown:t=>this.handleKeyDown(t,e.id)}))),i?this.renderTab(i,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=h(this)),this._root.render(s),queueMicrotask(()=>{I(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{R as default};
|
package/module/manifest.json
CHANGED
package/module/print.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_dll_react_dom as e,_dll_react as t,_dll_prop_types as
|
|
1
|
+
import{_dll_react_dom as e,_dll_react as t,_dll_prop_types as s,_dll_mui__material as a,_dll_mui__material_styles as n,_dll_pie_lib__render_ui as i,_dll_lodash as r,_dll_debug as l}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";var o,d=e;o=d.createRoot,d.hydrateRoot;const c=t,u=s,{Tabs:h}=a,{Tab:p}=a,{styled:b}=n,{Collapsible:m}=i,{color:g}=i,{PreviewPrompt:_}=i,{Purpose:E}=i,{UiLayout:x}=i;const T=b("div")({flexGrow:1,backgroundColor:g.background(),color:g.text(),"&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:".6em 1em",textAlign:"left"}}),y=b("div")(({theme:e})=>({backgroundColor:g.background(),color:g.text(),padding:e.spacing(2)})),f=b("div")({fontSize:"1.75rem"}),v=b("div")({fontSize:"1.5rem"}),k=b("div")({fontSize:"1.25rem"}),C=b(p)(({theme:e})=>({background:e.palette.common.white,fontSize:"inherit",color:e.palette.common.black}));class I extends c.Component{constructor(...e){super(...e),I.prototype.__init.call(this),I.prototype.__init2.call(this),I.prototype.__init3.call(this),I.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 i=a.findIndex(e=>e.id===t);switch(s){case"ArrowRight":n=(i+1)%a.length;break;case"ArrowLeft":n=(i-1+a.length)%a.length;break;case"Home":n=0;break;case"End":n=a.length-1;break;case"Enter":case" ":n=i}-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=c.createElement(_,{tagName:"div",className:"prompt",defaultClassName:"teacher-instructions",prompt:e});return t?s:c.createElement(m,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},s)}renderTab(e,t){return c.createElement(y,{key:e.id,id:`tabpanel-${e.id}`,role:"tabpanel","aria-labelledby":`button-${e.id}`},this.renderInstructions(e.teacherInstructions,t),(e.title||e.subtitle)&&c.createElement("h2",null,e.title&&c.createElement(E,{purpose:"passage-title"},c.createElement(f,{dangerouslySetInnerHTML:{__html:this.parsedText(e.title)}})),e.subtitle&&c.createElement(E,{purpose:"passage-subtitle"},c.createElement(v,{dangerouslySetInnerHTML:{__html:this.parsedText(e.subtitle)}}))),e.author&&c.createElement(E,{purpose:"passage-author"},c.createElement(k,{className:"author",dangerouslySetInnerHTML:{__html:this.parsedText(e.author)}})),e.text&&c.createElement(E,{purpose:"passage-text"},c.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],i=e[a+1];if(a+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=i(s)):"call"!==n&&"optionalCall"!==n||(s=i((...e)=>s.call(t,...e)),t=void 0)}return s}([t,"optionalAccess",e=>e.length]))return;const{extraCSSRules:n}=e||{},i=(t||[]).find(e=>e.id===a);return c.createElement(x,{extraCSSRules:n},c.createElement(T,{className:"passages"},s||1===t.length?t.map(e=>this.renderTab(e,s)):c.createElement(c.Fragment,null,c.createElement(h,{sx:{position:"sticky",top:0,background:g.background(),color:g.text()},value:a,onChange:this.handleChange},t.map(e=>c.createElement(C,{key:e.id,id:`button-${e.id}`,label:c.createElement(E,{purpose:"passage-label"},c.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)}))),i?this.renderTab(i,s):null)))}}I.propTypes={tabs:u.arrayOf(u.shape({id:u.number.isRequired,label:u.string.isRequired,title:u.string.isRequired,subtitle:u.string,author:u.string,text:u.string.isRequired,teacherInstructions:u.string}).isRequired).isRequired,disabledTabs:u.bool,model:u.object};const S=t,{debounce:w}=r,M=l("pie-element:passage:print"),R=(e,t)=>(e=>null!=e)(e)?e:t;class A extends HTMLElement{constructor(){super(),this._model=null,this._options=null,this._session=[],this._root=null,this._rerender=w(()=>{if(this._model&&this._session){if(this._model.passages&&this._model.passages.length>0){const e=((e,t)=>{const s="instructor"===t.role,a=R(e.teacherInstructionsEnabled,!0),n=R(e.titleEnabled,!0),i=R(e.authorEnabled,!1),r=R(e.subtitleEnabled,!0),l=R(e.textEnabled,!0);return e.passages.map((e,t)=>({id:t,teacherInstructions:R(e.teacherInstructionsEnabled,a)&&s&&e.teacherInstructions||"",label:e.title||`Passage ${t+1}`,title:R(e.titleEnabled,n)&&e.title||"",author:R(e.authorEnabled,i)&&e.author||"",subtitle:R(e.subtitleEnabled,r)&&e.subtitle||"",text:R(e.textEnabled,l)&&e.text||""}))})(this._model,this._options),t=S.createElement(I,{disabledTabs:!0,tabs:e});this._root||(this._root=o(this)),this._root.render(t)}}else M("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{A as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/passage",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.43+4249fa78f",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
16
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
17
|
-
"@pie-lib/math-rendering": "4.1.1-next.
|
|
18
|
-
"@pie-lib/render-ui": "5.1.1-next.
|
|
17
|
+
"@pie-lib/math-rendering": "4.1.1-next.0",
|
|
18
|
+
"@pie-lib/render-ui": "5.1.1-next.0",
|
|
19
19
|
"prop-types": "^15.8.1",
|
|
20
20
|
"react": "18.3.1",
|
|
21
21
|
"react-dom": "18.3.1"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "4249fa78fc423ef0a8c89002b8f937c42b3478ea",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"postpublish": "../../scripts/postpublish"
|
|
26
26
|
},
|