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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.json +227 -0
  2. package/CHANGELOG.md +1463 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +3 -0
  5. package/configure/CHANGELOG.md +682 -0
  6. package/configure/lib/common.js +74 -0
  7. package/configure/lib/common.js.map +1 -0
  8. package/configure/lib/defaults.js +174 -0
  9. package/configure/lib/defaults.js.map +1 -0
  10. package/configure/lib/design.js +185 -0
  11. package/configure/lib/design.js.map +1 -0
  12. package/configure/lib/index.js +86 -0
  13. package/configure/lib/index.js.map +1 -0
  14. package/configure/lib/passage.js +194 -0
  15. package/configure/lib/passage.js.map +1 -0
  16. package/configure/package.json +23 -0
  17. package/controller/CHANGELOG.json +1 -0
  18. package/controller/CHANGELOG.md +113 -0
  19. package/controller/lib/defaults.js +23 -0
  20. package/controller/lib/defaults.js.map +1 -0
  21. package/controller/lib/index.js +80 -0
  22. package/controller/lib/index.js.map +1 -0
  23. package/controller/package.json +13 -0
  24. package/docs/config-schema.json +1325 -0
  25. package/docs/config-schema.json.md +974 -0
  26. package/docs/demo/config.js +8 -0
  27. package/docs/demo/generate.js +32 -0
  28. package/docs/demo/index.html +1 -0
  29. package/docs/pie-schema.json +775 -0
  30. package/docs/pie-schema.json.md +561 -0
  31. package/lib/index.js +143 -0
  32. package/lib/index.js.map +1 -0
  33. package/lib/print.js +78 -0
  34. package/lib/print.js.map +1 -0
  35. package/lib/stimulus-tabs.js +323 -0
  36. package/lib/stimulus-tabs.js.map +1 -0
  37. package/module/configure.js +1 -0
  38. package/module/controller.js +920 -0
  39. package/module/demo.js +57 -0
  40. package/module/element.js +1 -0
  41. package/module/index.html +21 -0
  42. package/module/manifest.json +10 -0
  43. package/module/print-demo.js +95 -0
  44. package/module/print.html +18 -0
  45. package/module/print.js +1 -0
  46. package/package.json +19 -86
  47. package/configure.js +0 -2
  48. package/controller.js +0 -1
  49. package/dist/author/common.d.ts +0 -36
  50. package/dist/author/common.js +0 -56
  51. package/dist/author/defaults.d.ts +0 -175
  52. package/dist/author/defaults.js +0 -113
  53. package/dist/author/design.d.ts +0 -28
  54. package/dist/author/design.js +0 -120
  55. package/dist/author/index.d.ts +0 -36
  56. package/dist/author/index.js +0 -66
  57. package/dist/author/passage.d.ts +0 -27
  58. package/dist/author/passage.js +0 -127
  59. package/dist/browser/author/index.js +0 -38785
  60. package/dist/browser/author/index.js.map +0 -1
  61. package/dist/browser/controller/index.js +0 -64
  62. package/dist/browser/controller/index.js.map +0 -1
  63. package/dist/browser/delivery/index.js +0 -117
  64. package/dist/browser/delivery/index.js.map +0 -1
  65. package/dist/browser/dist-4njad0Sq.js +0 -9618
  66. package/dist/browser/dist-4njad0Sq.js.map +0 -1
  67. package/dist/browser/dist-BC24ne2o.js +0 -88
  68. package/dist/browser/dist-BC24ne2o.js.map +0 -1
  69. package/dist/browser/passage.css +0 -2
  70. package/dist/browser/print/index.js +0 -48
  71. package/dist/browser/print/index.js.map +0 -1
  72. package/dist/browser/stimulus-tabs-sQwIoGOW.js +0 -218
  73. package/dist/browser/stimulus-tabs-sQwIoGOW.js.map +0 -1
  74. package/dist/controller/defaults.d.ts +0 -23
  75. package/dist/controller/defaults.js +0 -17
  76. package/dist/controller/index.d.ts +0 -18
  77. package/dist/controller/index.js +0 -50
  78. package/dist/delivery/index.d.ts +0 -22
  79. package/dist/delivery/index.js +0 -83
  80. package/dist/delivery/stimulus-tabs.d.ts +0 -21
  81. package/dist/delivery/stimulus-tabs.js +0 -220
  82. package/dist/index.d.ts +0 -1
  83. package/dist/index.iife.d.ts +0 -8
  84. package/dist/index.iife.js +0 -145
  85. package/dist/index.js +0 -2
  86. package/dist/print/index.d.ts +0 -15
  87. package/dist/print/index.js +0 -47
  88. package/dist/runtime-support.d.ts +0 -12
  89. package/dist/runtime-support.js +0 -12
package/module/demo.js ADDED
@@ -0,0 +1,57 @@
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&#8217;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
+ });
@@ -0,0 +1 @@
1
+ import{_dll_pie_lib__math_rendering as e}from"../../../@pie-lib/math-rendering-module@^5.0.9/module/index.js";import{_dll_react as t,_dll_prop_types as s,_dll_mui__material as i,_dll_mui__material_styles as a,_dll_pie_lib__render_ui as r,_dll_react_dom_client as n}from"../../../@pie-lib/shared-module@^5.2.4/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 d=o.ModelSetEvent=l;class c extends CustomEvent{constructor(e,t){super(c.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}c.TYPE="session-changed",o.SessionChangedEvent=c;const h=t,p=s,{Tabs:m}=i,{Tab:b}=i,{styled:u}=a,{Collapsible:g}=r,{color:_}=r,{PreviewPrompt:v}=r,{Purpose:x}=r,{UiLayout:y}=r,{transformDataHeadings:f}=r;const E=u("div")({flexGrow:1,backgroundColor:_.background(),color:_.text(),"&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:".6em 1em",textAlign:"left"}}),T=u("div")(({theme:e})=>({backgroundColor:_.background(),color:_.text(),padding:e.spacing(2),"& blockquote":{background:"#f9f9f9",borderLeft:"5px solid #ccc",margin:"1.5em 10px",padding:".5em 10px"}})),M=u("div")({fontSize:"1.75rem"}),O=u("div")({fontSize:"1.5rem"}),k=u("div")({fontSize:"1.25rem"}),C=u(b)(({theme:e})=>({background:e.palette.common.white,fontSize:"inherit",fontFamily:"Roboto, sans-serif",color:e.palette.common.black,borderRadius:`${e.spacing(2)} ${e.spacing(2)} 0 0`,border:"1px solid #D9DADA",borderBottomWidth:0,minHeight:"56px",padding:"8px 10px",display:"flex",alignItems:"center",justifyContent:"center",margin:`0 ${e.spacing(1)}`,textTransform:"none",".passage-label":{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal",margin:"auto 0",opacity:.7},"&.Mui-selected":{color:e.palette.common.black,".passage-label":{opacity:1},".passage-label-underline":{backgroundColor:"#146EB3"}},"&:hover":{".passage-label-underline":{backgroundColor:"#D0E2F0"}},"& .MuiTouchRipple-root":{opacity:.7}})),w=u("div")(({theme:e})=>({height:"2px",width:"100%",marginTop:"6px",background:e.palette.common.white}));class A extends h.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:i}=this.props;let a=-1;const r=i.findIndex(e=>e.id===t);switch(s){case"ArrowRight":a=(r+1)%i.length;break;case"ArrowLeft":a=(r-1+i.length)%i.length;break;case"Home":a=0;break;case"End":a=i.length-1;break;case"Enter":case" ":a=r}-1!==a&&(e.preventDefault(),e.stopPropagation(),this.handleChange(e,i[a].id),document.getElementById(`button-${i[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=h.createElement(v,{tagName:"div",className:"prompt",defaultClassName:"teacher-instructions",prompt:e});return t?s:h.createElement(g,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},s)}renderTab(e,t){const{baseHeadingLevel:s}=this.props,i=s?Math.min(6,Math.max(1,s)):void 0,a=s?`h${i}`:"h2",r=s?Math.min(6,Math.max(1,i+1)):void 0;return h.createElement(T,{key:e.id,id:`tabpanel-${e.id}`,role:"tabpanel","aria-labelledby":`button-${e.id}`},this.renderInstructions(e.teacherInstructions,t),e.title&&h.createElement(x,{purpose:"passage-title"},h.createElement(a,null,h.createElement(M,{dangerouslySetInnerHTML:{__html:this.parsedText(e.title)}}))),e.subtitle&&h.createElement(x,{purpose:"passage-subtitle"},h.createElement(O,{dangerouslySetInnerHTML:{__html:this.parsedText(e.subtitle)}})),e.author&&h.createElement(x,{purpose:"passage-author"},h.createElement(k,{className:"author",dangerouslySetInnerHTML:{__html:this.parsedText(e.author)}})),e.text&&h.createElement(x,{purpose:"passage-text"},h.createElement("div",{key:e.id,className:"text",dangerouslySetInnerHTML:{__html:s?f(e.text,r):e.text}})))}render(){const{model:e,tabs:t,disabledTabs:s}=this.props,{activeTab:i}=this.state;if(!function(e){let t,s=e[0],i=1;for(;i<e.length;){const a=e[i],r=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==s)return;"access"===a||"optionalAccess"===a?(t=s,s=r(s)):"call"!==a&&"optionalCall"!==a||(s=r((...e)=>s.call(t,...e)),t=void 0)}return s}([t,"optionalAccess",e=>e.length]))return;const{extraCSSRules:a}=e||{},r=(t||[]).find(e=>e.id===i);return h.createElement(y,{extraCSSRules:a},h.createElement(E,{className:"passages"},s||1===t.length?t.map(e=>this.renderTab(e,s)):h.createElement(h.Fragment,null,h.createElement(m,{sx:{position:"sticky",top:0,background:_.background(),color:_.text(),fontFamily:"Roboto, sans-serif","& .MuiTabs-list":{borderBottom:"1px solid #D9DADA"},"& .MuiTabs-indicator":{backgroundColor:"#ffffff",marginBottom:"-1px"}},value:i,onChange:this.handleChange},t.map(e=>h.createElement(C,{key:e.id,id:`button-${e.id}`,label:h.createElement(h.Fragment,null,h.createElement(x,{purpose:"passage-label"},h.createElement("span",{className:"passage-label",dangerouslySetInnerHTML:{__html:this.parsedText(e.label)}})),h.createElement(w,{className:"passage-label-underline"})),value:e.id,tabIndex:i===e.id?0:-1,"aria-controls":`tabpanel-${e.id}`,"aria-selected":i===e.id,onKeyDown:t=>this.handleKeyDown(t,e.id)}))),r?this.renderTab(r,s):null)))}}A.propTypes={tabs:p.arrayOf(p.shape({id:p.number.isRequired,label:p.string.isRequired,title:p.string.isRequired,subtitle:p.string,author:p.string,text:p.string.isRequired,teacherInstructions:p.string}).isRequired).isRequired,disabledTabs:p.bool,model:p.object,baseHeadingLevel:p.number};const{renderMath:L}=e,R=t,{createRoot:S}=n;function P(e){const t=e.closest("pie-player")||e.closest("pie-item-player");if(t){let e=t.baseHeadingLevel;null==e&&(s=t.getAttribute("base-heading-level"),i=()=>t.getAttribute("baseheadinglevel"),e=null!=s?s:i());const a=parseInt(e,10);if(Number.isFinite(a)&&a>=1&&a<=6)return a}var s,i}class H extends HTMLElement{constructor(){super(),H.prototype.__init.call(this),this._model={passages:[]},this._session=null,this._root=null,this._mathObserver=null,this._mathRenderPending=!1,this._playerObserver=null}setLangAttribute(){const e=this._model&&(this._model.language,1)?this._model.language:"",t=e?e.slice(0,2):"en";this.setAttribute("lang",t)}__init(){this._scheduleMathRender=()=>{this._mathRenderPending||(this._mathRenderPending=!0,requestAnimationFrame(()=>{this._mathObserver&&this._mathObserver.disconnect(),L(this),this._mathRenderPending=!1,setTimeout(()=>{this._mathObserver&&this._mathObserver.observe(this,{childList:!0,subtree:!0})},50)}))}}_initMathObserver(){this._mathObserver||(this._mathObserver=new MutationObserver(this._scheduleMathRender),this._mathObserver.observe(this,{childList:!0,subtree:!0}))}_disconnectMathObserver(){this._mathObserver&&(this._mathObserver.disconnect(),this._mathObserver=null)}set model(e){this._model=e,this.dispatchEvent(new d(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._initMathObserver(),this._initPlayerObserver(),this._render()}_render(){const{passages:e=[]}=this._model;if(this._model.passages.length>0){const t=e.map((e,t)=>({id:t,...e})),s=R.createElement(A,{tabs:t,model:this._model,baseHeadingLevel:P(this)});this._root||(this._root=S(this)),this._root.render(s),this._initMathObserver()}}_initPlayerObserver(){const e=this.closest("pie-player")||this.closest("pie-item-player");e&&(this._playerObserver=new MutationObserver(()=>{this._render()}),this._playerObserver.observe(e,{attributes:!0,attributeFilter:["base-heading-level"]}))}_disconnectPlayerObserver(){this._playerObserver&&(this._playerObserver.disconnect(),this._playerObserver=null)}disconnectedCallback(){this._disconnectMathObserver(),this._disconnectPlayerObserver(),this._root&&this._root.unmount()}}export{H as default};
@@ -0,0 +1,21 @@
1
+
2
+ <!doctype html>
3
+ <html>
4
+ <head>
5
+ <title>@pie-element/passage@7.1.1</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>
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@pie-element/passage",
3
+ "version": "7.1.1",
4
+ "modules": [
5
+ {
6
+ "name": "@pie-lib/shared-module",
7
+ "version": "^5.2.4"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,95 @@
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&#8217;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
+ });
@@ -0,0 +1,18 @@
1
+
2
+ <!doctype html>
3
+ <html>
4
+ <head>
5
+ <title>@pie-element/passage@7.1.1</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>
@@ -0,0 +1 @@
1
+ import{_dll_react as e,_dll_prop_types as t,_dll_mui__material as n,_dll_mui__material_styles as a,_dll_pie_lib__render_ui as r,_dll_debug as i,_dll_react_dom_client as o}from"../../../@pie-lib/shared-module@^5.2.4/module/index.js";var s="object"==typeof global&&global&&global.Object===Object&&global,l="object"==typeof self&&self&&self.Object===Object&&self,c=s||l||Function("return this")(),u=c.Symbol,d=Object.prototype,p=d.hasOwnProperty,b=d.toString,h=u?u.toStringTag:void 0;var m=Object.prototype.toString;var g=u?u.toStringTag:void 0;function f(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":g&&g in Object(e)?function(e){var t=p.call(e,h),n=e[h];try{e[h]=void 0;var a=!0}catch(e){}var r=b.call(e);return a&&(t?e[h]=n:delete e[h]),r}(e):function(e){return m.call(e)}(e)}var v=/\s/;var x=/^\s+/;function y(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&v.test(e.charAt(t)););return t}(e)+1).replace(x,""):e}function _(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var E=/^[-+]0x[0-9a-f]+$/i,T=/^0b[01]+$/i,k=/^0o[0-7]+$/i,C=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]"==f(e)}(e))return NaN;if(_(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=_(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=y(e);var n=T.test(e);return n||k.test(e)?C(e.slice(2),n?2:8):E.test(e)?NaN:+e}var S=function(){return c.Date.now()},M=Math.max,I=Math.min;function j(e,t,n){var a,r,i,o,s,l,c=0,u=!1,d=!1,p=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function b(t){var n=a,i=r;return a=r=void 0,c=t,o=e.apply(i,n)}function h(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=i}function m(){var e=S();if(h(e))return g(e);s=setTimeout(m,function(e){var n=t-(e-l);return d?I(n,i-(e-c)):n}(e))}function g(e){return s=void 0,p&&a?b(e):(a=r=void 0,o)}function f(){var e=S(),n=h(e);if(a=arguments,r=this,l=e,n){if(void 0===s)return function(e){return c=e,s=setTimeout(m,t),u?b(e):o}(l);if(d)return clearTimeout(s),s=setTimeout(m,t),b(l)}return void 0===s&&(s=setTimeout(m,t)),o}return t=w(t)||0,_(n)&&(u=!!n.leading,i=(d="maxWait"in n)?M(w(n.maxWait)||0,t):i,p="trailing"in n?!!n.trailing:p),f.cancel=function(){void 0!==s&&clearTimeout(s),c=0,a=l=r=s=void 0},f.flush=function(){return void 0===s?o:g(S())},f}const A=e,H=t,{Tabs:L}=n,{Tab:R}=n,{styled:D}=a,{Collapsible:N}=r,{color:O}=r,{PreviewPrompt:$}=r,{Purpose:q}=r,{UiLayout:B}=r,{transformDataHeadings:F}=r;const P=D("div")({flexGrow:1,backgroundColor:O.background(),color:O.text(),"&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:".6em 1em",textAlign:"left"}}),W=D("div")(({theme:e})=>({backgroundColor:O.background(),color:O.text(),padding:e.spacing(2),"& blockquote":{background:"#f9f9f9",borderLeft:"5px solid #ccc",margin:"1.5em 10px",padding:".5em 10px"}})),z=D("div")({fontSize:"1.75rem"}),J=D("div")({fontSize:"1.5rem"}),K=D("div")({fontSize:"1.25rem"}),U=D(R)(({theme:e})=>({background:e.palette.common.white,fontSize:"inherit",fontFamily:"Roboto, sans-serif",color:e.palette.common.black,borderRadius:`${e.spacing(2)} ${e.spacing(2)} 0 0`,border:"1px solid #D9DADA",borderBottomWidth:0,minHeight:"56px",padding:"8px 10px",display:"flex",alignItems:"center",justifyContent:"center",margin:`0 ${e.spacing(1)}`,textTransform:"none",".passage-label":{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal",margin:"auto 0",opacity:.7},"&.Mui-selected":{color:e.palette.common.black,".passage-label":{opacity:1},".passage-label-underline":{backgroundColor:"#146EB3"}},"&:hover":{".passage-label-underline":{backgroundColor:"#D0E2F0"}},"& .MuiTouchRipple-root":{opacity:.7}})),G=D("div")(({theme:e})=>({height:"2px",width:"100%",marginTop:"6px",background:e.palette.common.white}));class Q extends A.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:a}=this.props;let r=-1;const i=a.findIndex(e=>e.id===t);switch(n){case"ArrowRight":r=(i+1)%a.length;break;case"ArrowLeft":r=(i-1+a.length)%a.length;break;case"Home":r=0;break;case"End":r=a.length-1;break;case"Enter":case" ":r=i}-1!==r&&(e.preventDefault(),e.stopPropagation(),this.handleChange(e,a[r].id),document.getElementById(`button-${a[r].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=A.createElement($,{tagName:"div",className:"prompt",defaultClassName:"teacher-instructions",prompt:e});return t?n:A.createElement(N,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},n)}renderTab(e,t){const{baseHeadingLevel:n}=this.props,a=n?Math.min(6,Math.max(1,n)):void 0,r=n?`h${a}`:"h2",i=n?Math.min(6,Math.max(1,a+1)):void 0;return A.createElement(W,{key:e.id,id:`tabpanel-${e.id}`,role:"tabpanel","aria-labelledby":`button-${e.id}`},this.renderInstructions(e.teacherInstructions,t),e.title&&A.createElement(q,{purpose:"passage-title"},A.createElement(r,null,A.createElement(z,{dangerouslySetInnerHTML:{__html:this.parsedText(e.title)}}))),e.subtitle&&A.createElement(q,{purpose:"passage-subtitle"},A.createElement(J,{dangerouslySetInnerHTML:{__html:this.parsedText(e.subtitle)}})),e.author&&A.createElement(q,{purpose:"passage-author"},A.createElement(K,{className:"author",dangerouslySetInnerHTML:{__html:this.parsedText(e.author)}})),e.text&&A.createElement(q,{purpose:"passage-text"},A.createElement("div",{key:e.id,className:"text",dangerouslySetInnerHTML:{__html:n?F(e.text,i):e.text}})))}render(){const{model:e,tabs:t,disabledTabs:n}=this.props,{activeTab:a}=this.state;if(!function(e){let t,n=e[0],a=1;for(;a<e.length;){const r=e[a],i=e[a+1];if(a+=2,("optionalAccess"===r||"optionalCall"===r)&&null==n)return;"access"===r||"optionalAccess"===r?(t=n,n=i(n)):"call"!==r&&"optionalCall"!==r||(n=i((...e)=>n.call(t,...e)),t=void 0)}return n}([t,"optionalAccess",e=>e.length]))return;const{extraCSSRules:r}=e||{},i=(t||[]).find(e=>e.id===a);return A.createElement(B,{extraCSSRules:r},A.createElement(P,{className:"passages"},n||1===t.length?t.map(e=>this.renderTab(e,n)):A.createElement(A.Fragment,null,A.createElement(L,{sx:{position:"sticky",top:0,background:O.background(),color:O.text(),fontFamily:"Roboto, sans-serif","& .MuiTabs-list":{borderBottom:"1px solid #D9DADA"},"& .MuiTabs-indicator":{backgroundColor:"#ffffff",marginBottom:"-1px"}},value:a,onChange:this.handleChange},t.map(e=>A.createElement(U,{key:e.id,id:`button-${e.id}`,label:A.createElement(A.Fragment,null,A.createElement(q,{purpose:"passage-label"},A.createElement("span",{className:"passage-label",dangerouslySetInnerHTML:{__html:this.parsedText(e.label)}})),A.createElement(G,{className:"passage-label-underline"})),value:e.id,tabIndex:a===e.id?0:-1,"aria-controls":`tabpanel-${e.id}`,"aria-selected":a===e.id,onKeyDown:t=>this.handleKeyDown(t,e.id)}))),i?this.renderTab(i,n):null)))}}Q.propTypes={tabs:H.arrayOf(H.shape({id:H.number.isRequired,label:H.string.isRequired,title:H.string.isRequired,subtitle:H.string,author:H.string,text:H.string.isRequired,teacherInstructions:H.string}).isRequired).isRequired,disabledTabs:H.bool,model:H.object,baseHeadingLevel:H.number};const V=e,{createRoot:X}=o,Y=i("pie-element:passage:print"),Z=(e,t)=>(e=>null!=e)(e)?e:t;class ee extends HTMLElement{constructor(){super(),this._model=null,this._options=null,this._session=[],this._root=null,this._rerender=j(()=>{if(this._model&&this._session){if(this._model.passages&&this._model.passages.length>0){const e=((e,t)=>{const n="instructor"===t.role,a=Z(e.teacherInstructionsEnabled,!0),r=Z(e.titleEnabled,!0),i=Z(e.authorEnabled,!1),o=Z(e.subtitleEnabled,!0),s=Z(e.textEnabled,!0);return e.passages.map((e,t)=>({id:t,teacherInstructions:Z(e.teacherInstructionsEnabled,a)&&n&&e.teacherInstructions||"",label:e.title||`Passage ${t+1}`,title:Z(e.titleEnabled,r)&&e.title||"",author:Z(e.authorEnabled,i)&&e.author||"",subtitle:Z(e.subtitleEnabled,o)&&e.subtitle||"",text:Z(e.textEnabled,s)&&e.text||""}))})(this._model,this._options),t=V.createElement(Q,{disabledTabs:!0,tabs:e});this._root||(this._root=X(this)),this._root.render(t)}}else Y("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{ee as default};
package/package.json CHANGED
@@ -1,100 +1,33 @@
1
1
  {
2
2
  "name": "@pie-element/passage",
3
- "version": "7.1.2-next.2",
3
+ "repository": "pie-framework/pie-elements",
4
+ "version": "7.1.2",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
4
8
  "description": "",
9
+ "author": "pie framework developers",
10
+ "license": "ISC",
5
11
  "dependencies": {
6
12
  "@emotion/react": "^11.14.0",
7
13
  "@emotion/style": "^0.8.0",
8
14
  "@mui/icons-material": "^7.3.4",
9
15
  "@mui/material": "^7.3.4",
10
- "@pie-lib/render-ui": "6.1.1-next.37",
16
+ "@pie-framework/pie-player-events": "^0.1.0",
17
+ "@pie-lib/math-rendering": "5.0.2",
18
+ "@pie-lib/render-ui": "6.1.1",
11
19
  "prop-types": "^15.8.1",
12
- "@pie-lib/config-ui": "13.0.4-next.30",
13
- "@pie-element/shared-configure-events": "0.1.0",
14
- "@pie-lib/editable-html-tip-tap": "2.1.2-next.30",
15
- "@pie-element/shared-lodash": "0.1.1-next.0",
16
- "@pie-element/shared-player-events": "0.1.0",
17
- "@pie-element/shared-math-rendering-mathjax": "0.1.1-next.0",
18
- "debug": "^4.4.3"
19
- },
20
- "peerDependencies": {
21
- "react": "^18.0.0",
22
- "react-dom": "^18.0.0"
23
- },
24
- "exports": {
25
- ".": {
26
- "types": "./dist/index.d.ts",
27
- "default": "./dist/index.js"
28
- },
29
- "./delivery": {
30
- "types": "./dist/delivery/index.d.ts",
31
- "default": "./dist/delivery/index.js"
32
- },
33
- "./browser/delivery": {
34
- "default": "./dist/browser/delivery/index.js"
35
- },
36
- "./author": {
37
- "types": "./dist/author/index.d.ts",
38
- "default": "./dist/author/index.js"
39
- },
40
- "./browser/author": {
41
- "default": "./dist/browser/author/index.js"
42
- },
43
- "./configure": {
44
- "types": "./dist/author/index.d.ts",
45
- "default": "./dist/author/index.js"
46
- },
47
- "./controller": {
48
- "types": "./dist/controller/index.d.ts",
49
- "default": "./dist/controller/index.js"
50
- },
51
- "./controller.js": {
52
- "types": "./dist/controller/index.d.ts",
53
- "default": "./dist/controller/index.js"
54
- },
55
- "./browser/controller": {
56
- "default": "./dist/browser/controller/index.js"
57
- },
58
- "./print": {
59
- "types": "./dist/print/index.d.ts",
60
- "default": "./dist/print/index.js"
61
- },
62
- "./browser/print": {
63
- "default": "./dist/browser/print/index.js"
64
- },
65
- "./runtime-support": {
66
- "types": "./dist/runtime-support.d.ts",
67
- "default": "./dist/runtime-support.js"
68
- }
69
- },
70
- "type": "module",
71
- "main": "./dist/index.js",
72
- "types": "./dist/index.d.ts",
73
- "files": [
74
- "configure.js",
75
- "controller.js",
76
- "dist"
77
- ],
78
- "sideEffects": false,
79
- "devDependencies": {
80
- "vite": "^8.0.1",
81
- "typescript": "^5.9.3",
82
- "@vitejs/plugin-react": "^6.0.1",
83
- "@types/react": "^18.2.0",
84
- "@types/react-dom": "^18.2.0"
20
+ "react": "18.3.1",
21
+ "react-dom": "18.3.1"
85
22
  },
23
+ "gitHead": "206ff17a94e8e197744d059f97ad2b9a1bc9145d",
86
24
  "scripts": {
87
- "build": "bun x vite build && bun x vite build --config ../../../tools/vite/element-browser.config.ts && bun x vite build --config vite.config.iife.ts && bun x tsc --emitDeclarationOnly",
88
- "dev": "bun x vite",
89
- "demo": "bun x vite --mode demo",
90
- "test": "bun x vitest run"
25
+ "postpublish": "../../scripts/postpublish"
91
26
  },
92
- "pie": {
93
- "controller": "@pie-element/passage/controller",
94
- "configure": "@pie-element/passage/configure",
95
- "browserSharedDependencies": {
96
- "react": "18.2.0",
97
- "react-dom": "18.2.0"
98
- }
27
+ "main": "lib/index.js",
28
+ "module": "src/index.js",
29
+ "exports": {
30
+ ".": "./src/index.js",
31
+ "./print": "./src/print.js"
99
32
  }
100
33
  }
package/configure.js DELETED
@@ -1,2 +0,0 @@
1
- export { default } from './dist/author/index.js';
2
- export * from './dist/author/index.js';
package/controller.js DELETED
@@ -1 +0,0 @@
1
- export * from './dist/controller/index.js';
@@ -1,36 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/passage/configure/src/common.jsx
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import React from 'react';
10
- import PropTypes from 'prop-types';
11
- export declare const RemoveAddButton: ({ label, type, onClick }: {
12
- label: any;
13
- type?: string | undefined;
14
- onClick: any;
15
- }) => React.JSX.Element;
16
- export declare const PassageButton: any;
17
- export declare const ConfirmationDialog: {
18
- ({ content, cancel, title, ok, open, onOk, onCancel }: {
19
- content: any;
20
- cancel: any;
21
- title: any;
22
- ok: any;
23
- open: any;
24
- onOk: any;
25
- onCancel: any;
26
- }): React.JSX.Element;
27
- propTypes: {
28
- content: PropTypes.Validator<string>;
29
- title: PropTypes.Validator<string>;
30
- cancel: PropTypes.Validator<string>;
31
- ok: PropTypes.Validator<string>;
32
- open: PropTypes.Validator<boolean>;
33
- onCancel: PropTypes.Validator<(...args: any[]) => any>;
34
- onOk: PropTypes.Validator<(...args: any[]) => any>;
35
- };
36
- };
@@ -1,56 +0,0 @@
1
- import "react";
2
- import e from "prop-types";
3
- import { styled as t } from "@mui/material/styles";
4
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
5
- import { Button as i } from "@mui/material";
6
- import a from "@mui/icons-material/RemoveCircle";
7
- import o from "@mui/icons-material/AddCircle";
8
- import s from "@mui/material/Dialog";
9
- import c from "@mui/material/DialogTitle";
10
- import l from "@mui/material/DialogContent";
11
- import u from "@mui/material/DialogContentText";
12
- import d from "@mui/material/DialogActions";
13
- var f = t(({ label: e, type: t = "add", onClick: s }) => /* @__PURE__ */ r(i, {
14
- color: "primary",
15
- size: "small",
16
- onClick: s,
17
- children: [/* @__PURE__ */ n(t === "add" ? o : a, {
18
- fontSize: "small",
19
- color: "primary",
20
- style: { marginRight: 4 }
21
- }), e]
22
- }))({
23
- textDecoration: "underline",
24
- "&:hover": {
25
- textDecoration: "underline",
26
- backgroundColor: "transparent"
27
- },
28
- display: "flex",
29
- alignItems: "center"
30
- }), p = ({ content: e, cancel: t, title: a, ok: o, open: f, onOk: p, onCancel: m }) => /* @__PURE__ */ r(s, {
31
- open: f,
32
- children: [
33
- /* @__PURE__ */ n(c, { children: a }),
34
- /* @__PURE__ */ n(l, { children: /* @__PURE__ */ n(u, { children: e }) }),
35
- /* @__PURE__ */ r(d, { children: [p && /* @__PURE__ */ n(i, {
36
- onClick: p,
37
- color: "primary",
38
- children: o
39
- }), m && /* @__PURE__ */ n(i, {
40
- onClick: m,
41
- color: "primary",
42
- children: t
43
- })] })
44
- ]
45
- });
46
- p.propTypes = {
47
- content: e.string.isRequired,
48
- title: e.string.isRequired,
49
- cancel: e.string.isRequired,
50
- ok: e.string.isRequired,
51
- open: e.bool.isRequired,
52
- onCancel: e.func.isRequired,
53
- onOk: e.func.isRequired
54
- };
55
- //#endregion
56
- export { p as ConfirmationDialog, f as PassageButton };
@@ -1,175 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/passage/configure/src/defaults.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- declare const _default: {
10
- model: {
11
- authorEnabled: boolean;
12
- passages: {
13
- teacherInstructions: string;
14
- title: string;
15
- subtitle: string;
16
- author: string;
17
- text: string;
18
- }[];
19
- subtitleEnabled: boolean;
20
- teacherInstructionsEnabled: boolean;
21
- textEnabled: boolean;
22
- titleEnabled: boolean;
23
- };
24
- configuration: {
25
- baseInputConfiguration: {
26
- audio: {
27
- disabled: boolean;
28
- };
29
- video: {
30
- disabled: boolean;
31
- };
32
- image: {
33
- disabled: boolean;
34
- };
35
- h3: {
36
- disabled: boolean;
37
- };
38
- blockquote: {
39
- disabled: boolean;
40
- };
41
- textAlign: {
42
- disabled: boolean;
43
- };
44
- showParagraphs: {
45
- disabled: boolean;
46
- };
47
- separateParagraphs: {
48
- disabled: boolean;
49
- };
50
- };
51
- settingsPanelDisabled: boolean;
52
- title: {
53
- settings: boolean;
54
- label: string;
55
- inputConfiguration: {
56
- audio: {
57
- disabled: boolean;
58
- };
59
- video: {
60
- disabled: boolean;
61
- };
62
- image: {
63
- disabled: boolean;
64
- };
65
- textAlign: {
66
- disabled: boolean;
67
- };
68
- };
69
- required: boolean;
70
- };
71
- subtitle: {
72
- settings: boolean;
73
- label: string;
74
- inputConfiguration: {
75
- audio: {
76
- disabled: boolean;
77
- };
78
- video: {
79
- disabled: boolean;
80
- };
81
- image: {
82
- disabled: boolean;
83
- };
84
- textAlign: {
85
- disabled: boolean;
86
- };
87
- };
88
- required: boolean;
89
- };
90
- author: {
91
- settings: boolean;
92
- label: string;
93
- inputConfiguration: {
94
- audio: {
95
- disabled: boolean;
96
- };
97
- video: {
98
- disabled: boolean;
99
- };
100
- image: {
101
- disabled: boolean;
102
- };
103
- };
104
- required: boolean;
105
- };
106
- text: {
107
- settings: boolean;
108
- label: string;
109
- inputConfiguration: {
110
- audio: {
111
- disabled: boolean;
112
- };
113
- video: {
114
- disabled: boolean;
115
- };
116
- image: {
117
- disabled: boolean;
118
- };
119
- h3: {
120
- disabled: boolean;
121
- };
122
- blockquote: {
123
- disabled: boolean;
124
- };
125
- textAlign: {
126
- disabled: boolean;
127
- };
128
- };
129
- required: boolean;
130
- };
131
- teacherInstructions: {
132
- settings: boolean;
133
- label: string;
134
- inputConfiguration: {
135
- audio: {
136
- disabled: boolean;
137
- };
138
- video: {
139
- disabled: boolean;
140
- };
141
- image: {
142
- disabled: boolean;
143
- };
144
- };
145
- required: boolean;
146
- };
147
- maxImageWidth: {
148
- teacherInstructions: number;
149
- text: number;
150
- };
151
- maxImageHeight: {
152
- teacherInstructions: number;
153
- text: number;
154
- };
155
- mathMlOptions: {
156
- mmlOutput: boolean;
157
- mmlEditing: boolean;
158
- };
159
- language: {
160
- settings: boolean;
161
- label: string;
162
- enabled: boolean;
163
- };
164
- languageChoices: {
165
- label: string;
166
- options: never[];
167
- };
168
- additionalPassage: {
169
- settings: boolean;
170
- label: string;
171
- enabled: boolean;
172
- };
173
- };
174
- };
175
- export default _default;