@pie-element/passage 1.7.6 → 1.7.7
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 +8 -0
- package/lib/stimulus-tabs.js +5 -1
- package/lib/stimulus-tabs.js.map +1 -1
- package/module/demo.js +63 -0
- package/module/element.js +341 -0
- package/module/index.html +21 -0
- package/module/manifest.json +10 -0
- package/module/print-demo.js +92 -0
- package/module/print.html +18 -0
- package/module/print.js +308 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.7.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage@1.7.6...@pie-element/passage@1.7.7) (2022-03-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/passage
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [1.7.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage@1.7.4...@pie-element/passage@1.7.5) (2021-12-13)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/passage
|
package/lib/stimulus-tabs.js
CHANGED
|
@@ -63,6 +63,9 @@ var styles = function styles() {
|
|
|
63
63
|
borderBottom: "2px solid ".concat(_renderUi.color.secondary()),
|
|
64
64
|
width: 'fit-content',
|
|
65
65
|
marginBottom: '6px'
|
|
66
|
+
},
|
|
67
|
+
buttonContainer: {
|
|
68
|
+
background: 'white'
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
};
|
|
@@ -176,7 +179,8 @@ var StimulusTabs = /*#__PURE__*/function (_React$Component) {
|
|
|
176
179
|
className: classes.root
|
|
177
180
|
}, /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
|
|
178
181
|
classes: {
|
|
179
|
-
root: classes.stickyTabs
|
|
182
|
+
root: classes.stickyTabs,
|
|
183
|
+
flexContainer: classes.buttonContainer
|
|
180
184
|
},
|
|
181
185
|
value: activeTab,
|
|
182
186
|
onChange: this.handleChange
|
package/lib/stimulus-tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/stimulus-tabs.jsx"],"names":["styles","root","flexGrow","backgroundColor","color","background","text","tab","fontSize","stickyTabs","paddingBottom","position","top","title","textTransform","padding","borderBottom","secondary","width","marginBottom","TabContainer","props","multiple","children","propTypes","PropTypes","node","isRequired","bool","StimulusTabs","activeTab","event","setState","setTimeout","tabChangeEvent","CustomEvent","detail","window","dispatchEvent","div","document","createElement","innerHTML","replace","audio","querySelector","source","setAttribute","getAttribute","removeAttribute","appendChild","classes","tabs","disabledTabs","state","length","map","id","__html","parsedText","handleChange","whiteSpace","React","Component","object","arrayOf","shape","number","string"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS;AAAA,SAAgB;AAC7BC,IAAAA,IAAI,EAAE;AACJC,MAAAA,QAAQ,EAAE,CADN;AAEJC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN,EAFb;AAGJD,MAAAA,KAAK,EAAEA,gBAAME,IAAN;AAHH,KADuB;AAM7BC,IAAAA,GAAG,EAAE;AACHC,MAAAA,QAAQ,EAAE;AADP,KANwB;AAS7BC,IAAAA,UAAU,EAAE;AACVJ,MAAAA,UAAU,EAAED,gBAAMC,UAAN,EADF;AAEVK,MAAAA,aAAa,EAAE,MAFL;AAGVC,MAAAA,QAAQ,EAAE,QAHA;AAIVC,MAAAA,GAAG,EAAE;AAJK,KATiB;AAe7BC,IAAAA,KAAK,EAAE;AACLC,MAAAA,aAAa,EAAE,WADV;AAELC,MAAAA,OAAO,EAAE,UAFJ;AAGLC,MAAAA,YAAY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EAAElD,GAAG,CAACkD,EADX;AAEE,YAAA,uBAAuB,EAAE;AAAEC,cAAAA,MAAM,EAAE,MAAI,CAACC,UAAL,CAAgBpD,GAAG,CAACD,IAApB;AAAV;AAF3B,YADF,CADF,CADF,GAUI,IAXI;AAAA,SAAT,CAvBH,CApBF;AA2DD,OA5DD,MA4DO,IAAI8C,IAAI,IAAIA,IAAI,CAAC,CAAD,CAAhB,EAAqB;AAC1B,4BACE;AAAK,UAAA,SAAS,EAAC,SAAf;AAAyB,UAAA,KAAK,EAAE;AAAES,YAAAA,UAAU,EAAE;AAAd;AAAhC,wBACE,gCAAC,YAAD,qBACE;AAAK,UAAA,SAAS,EAAC,MAAf;AAAsB,UAAA,uBAAuB,EAAE;AAAEH,YAAAA,MAAM,EAAE,KAAKC,UAAL,CAAgBP,IAAI,CAAC,CAAD,CAAJ,CAAQ9C,IAAxB;AAAV;AAA/C,UADF,CADF,CADF;AAOD;AACF;;;EA9GwBwD,kBAAMC,S;;AAiHjClC,YAAY,CAACL,SAAb,GAAyB;AACvB2B,EAAAA,OAAO,EAAE1B,sBAAUuC,MAAV,CAAiBrC,UADH;AAEvByB,EAAAA,IAAI,EAAE3B,sBAAUwC,OAAV,CACJxC,sBAAUyC,KAAV,CAAgB;AACdT,IAAAA,EAAE,EAAEhC,sBAAU0C,MAAV,CAAiBxC,UADP;AAEdd,IAAAA,KAAK,EAAEY,sBAAU2C,MAAV,CAAiBzC,UAFV;AAGdrB,IAAAA,IAAI,EAAEmB,sBAAU2C,MAAV,CAAiBzC;AAHT,GAAhB,EAIGA,UALC,EAMJA,UARqB;AASvB0B,EAAAA,YAAY,EAAE5B,sBAAUG;AATD,CAAzB;;eAYe,wBAAW5B,MAAX,EAAmB6B,YAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Tabs from '@material-ui/core/Tabs';\nimport Tab from '@material-ui/core/Tab';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport { color, Purpose } from '@pie-lib/render-ui';\nimport classNames from 'classnames';\n\nconst styles = (/*theme*/) => ({\n root: {\n flexGrow: 1,\n backgroundColor: color.background(),\n color: color.text(),\n },\n tab: {\n fontSize: '0.8125em',\n },\n stickyTabs: {\n background: color.background(),\n paddingBottom: '20px',\n position: 'sticky',\n top: 0,\n },\n title: {\n textTransform: 'uppercase',\n padding: '6px 24px',\n borderBottom: `2px solid ${color.secondary()}`,\n width: 'fit-content',\n marginBottom: '6px'\n }\n});\n\nfunction TabContainer(props) {\n const padding = props.multiple ? '0 24px 24px 24px' : '24px';\n\n return (\n <Typography\n component=\"div\"\n style={{\n padding,\n fontSize: '0.875em',\n backgroundColor: color.background(),\n color: color.text(),\n }}\n >\n {props.children}\n </Typography>\n );\n}\n\nTabContainer.propTypes = {\n children: PropTypes.node.isRequired,\n multiple: PropTypes.bool,\n};\n\nclass StimulusTabs extends React.Component {\n state = {\n activeTab: 0,\n };\n\n handleChange = (event, activeTab) => {\n this.setState(() => ({ activeTab }));\n setTimeout(() => {\n const tabChangeEvent = new CustomEvent('pie-ui-passage-tabChanged', {\n detail: {\n tab: activeTab,\n },\n });\n\n window.dispatchEvent(tabChangeEvent);\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 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 render() {\n const { classes, tabs, disabledTabs } = this.props;\n const { activeTab } = this.state;\n\n if (tabs && tabs.length > 1) {\n return disabledTabs ? (\n <div className=\"passages\">\n {tabs.map(tab =>\n <div key={tab.id} className={`passage-${tab.id}`}>\n <TabContainer multiple >\n <div\n className={classNames(classes.title, 'title')}\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.title) }}\n />\n <Purpose purpose=\"passage-text\">\n <div\n className=\"text\"\n key={tab.id}\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.text) }}\n />\n </Purpose>\n </TabContainer>\n </div>)}\n </div>\n ) : (\n <div className={classes.root}>\n <Tabs\n classes={{\n root: classes.stickyTabs,\n }}\n value={activeTab}\n onChange={this.handleChange}\n >\n {tabs.map((tab) => (\n <Tab\n className={classes.tab}\n key={tab.id}\n label={\n <Purpose purpose=\"passage-title\">\n <span\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.title) }}\n />\n </Purpose>\n }\n value={tab.id}\n />\n ))}\n </Tabs>\n {tabs.map((tab) =>\n activeTab === tab.id ? (\n <TabContainer multiple key={tab.id}>\n <Purpose purpose=\"passage-text\">\n <div\n key={tab.id}\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.text) }}\n />\n </Purpose>\n </TabContainer>\n\n ) : null\n )}\n </div>\n );\n\n } else if (tabs && tabs[0]) {\n return (\n <div className=\"passage\" style={{ whiteSpace: 'break-spaces' }} >\n <TabContainer>\n <div className=\"text\" dangerouslySetInnerHTML={{ __html: this.parsedText(tabs[0].text) }} />\n </TabContainer>\n </div>\n );\n }\n }\n}\n\nStimulusTabs.propTypes = {\n classes: PropTypes.object.isRequired,\n tabs: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.number.isRequired,\n title: PropTypes.string.isRequired,\n text: PropTypes.string.isRequired,\n }).isRequired\n ).isRequired,\n disabledTabs: PropTypes.bool\n};\n\nexport default withStyles(styles)(StimulusTabs);\n"],"file":"stimulus-tabs.js"}
|
|
1
|
+
{"version":3,"sources":["../src/stimulus-tabs.jsx"],"names":["styles","root","flexGrow","backgroundColor","color","background","text","tab","fontSize","stickyTabs","paddingBottom","position","top","title","textTransform","padding","borderBottom","secondary","width","marginBottom","buttonContainer","TabContainer","props","multiple","children","propTypes","PropTypes","node","isRequired","bool","StimulusTabs","activeTab","event","setState","setTimeout","tabChangeEvent","CustomEvent","detail","window","dispatchEvent","div","document","createElement","innerHTML","replace","audio","querySelector","source","setAttribute","getAttribute","removeAttribute","appendChild","classes","tabs","disabledTabs","state","length","map","id","__html","parsedText","flexContainer","handleChange","whiteSpace","React","Component","object","arrayOf","shape","number","string"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS;AAAA,SAAgB;AAC7BC,IAAAA,IAAI,EAAE;AACJC,MAAAA,QAAQ,EAAE,CADN;AAEJC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN,EAFb;AAGJD,MAAAA,KAAK,EAAEA,gBAAME,IAAN;AAHH,KADuB;AAM7BC,IAAAA,GAAG,EAAE;AACHC,MAAAA,QAAQ,EAAE;AADP,KANwB;AAS7BC,IAAAA,UAAU,EAAE;AACVJ,MAAAA,UAAU,EAAED,gBAAMC,UAAN,EADF;AAEVK,MAAAA,aAAa,EAAE,MAFL;AAGVC,MAAAA,QAAQ,EAAE,QAHA;AAIVC,MAAAA,GAAG,EAAE;AAJK,KATiB;AAe7BC,IAAAA,KAAK,EAAE;AACLC,MAAAA,aAAa,EAAE,WADV;AAELC,MAAAA,OAAO,EAAE,UAFJ;AAGLC,MAAAA,YAAY,sBAAeZ,gBAAMa,SAAN,EAAf,CAHP;AAILC,MAAAA,KAAK,EAAE,aAJF;AAKLC,MAAAA,YAAY,EAAE;AALT,KAfsB;AAsB7BC,IAAAA,eAAe,EAAE;AACff,MAAAA,UAAU,EAAE;AADG;AAtBY,GAAhB;AAAA,CAAf;;AA2BA,SAASgB,YAAT,CAAsBC,KAAtB,EAA6B;AAC3B,MAAMP,OAAO,GAAGO,KAAK,CAACC,QAAN,GAAiB,kBAAjB,GAAsC,MAAtD;AAEA,sBACE,gCAAC,sBAAD;AACE,IAAA,SAAS,EAAC,KADZ;AAEE,IAAA,KAAK,EAAE;AACLR,MAAAA,OAAO,EAAPA,O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f;AAAyB,UAAA,KAAK,EAAE;AAAEU,YAAAA,UAAU,EAAE;AAAd;AAAhC,wBACE,gCAAC,YAAD,qBACE;AAAK,UAAA,SAAS,EAAC,MAAf;AAAsB,UAAA,uBAAuB,EAAE;AAAEJ,YAAAA,MAAM,EAAE,KAAKC,UAAL,CAAgBP,IAAI,CAAC,CAAD,CAAJ,CAAQ/C,IAAxB;AAAV;AAA/C,UADF,CADF,CADF;AAOD;AACF;;;EA/GwB0D,kBAAMC,S;;AAkHjCnC,YAAY,CAACL,SAAb,GAAyB;AACvB2B,EAAAA,OAAO,EAAE1B,sBAAUwC,MAAV,CAAiBtC,UADH;AAEvByB,EAAAA,IAAI,EAAE3B,sBAAUyC,OAAV,CACJzC,sBAAU0C,KAAV,CAAgB;AACdV,IAAAA,EAAE,EAAEhC,sBAAU2C,MAAV,CAAiBzC,UADP;AAEdf,IAAAA,KAAK,EAAEa,sBAAU4C,MAAV,CAAiB1C,UAFV;AAGdtB,IAAAA,IAAI,EAAEoB,sBAAU4C,MAAV,CAAiB1C;AAHT,GAAhB,EAIGA,UALC,EAMJA,UARqB;AASvB0B,EAAAA,YAAY,EAAE5B,sBAAUG;AATD,CAAzB;;eAYe,wBAAW7B,MAAX,EAAmB8B,YAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Tabs from '@material-ui/core/Tabs';\nimport Tab from '@material-ui/core/Tab';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport { color, Purpose } from '@pie-lib/render-ui';\nimport classNames from 'classnames';\n\nconst styles = (/*theme*/) => ({\n root: {\n flexGrow: 1,\n backgroundColor: color.background(),\n color: color.text(),\n },\n tab: {\n fontSize: '0.8125em',\n },\n stickyTabs: {\n background: color.background(),\n paddingBottom: '20px',\n position: 'sticky',\n top: 0,\n },\n title: {\n textTransform: 'uppercase',\n padding: '6px 24px',\n borderBottom: `2px solid ${color.secondary()}`,\n width: 'fit-content',\n marginBottom: '6px'\n },\n buttonContainer: {\n background: 'white'\n }\n});\n\nfunction TabContainer(props) {\n const padding = props.multiple ? '0 24px 24px 24px' : '24px';\n\n return (\n <Typography\n component=\"div\"\n style={{\n padding,\n fontSize: '0.875em',\n backgroundColor: color.background(),\n color: color.text(),\n }}\n >\n {props.children}\n </Typography>\n );\n}\n\nTabContainer.propTypes = {\n children: PropTypes.node.isRequired,\n multiple: PropTypes.bool,\n};\n\nclass StimulusTabs extends React.Component {\n state = {\n activeTab: 0,\n };\n\n handleChange = (event, activeTab) => {\n this.setState(() => ({ activeTab }));\n setTimeout(() => {\n const tabChangeEvent = new CustomEvent('pie-ui-passage-tabChanged', {\n detail: {\n tab: activeTab,\n },\n });\n\n window.dispatchEvent(tabChangeEvent);\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 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 render() {\n const { classes, tabs, disabledTabs } = this.props;\n const { activeTab } = this.state;\n\n if (tabs && tabs.length > 1) {\n return disabledTabs ? (\n <div className=\"passages\">\n {tabs.map(tab =>\n <div key={tab.id} className={`passage-${tab.id}`}>\n <TabContainer multiple >\n <div\n className={classNames(classes.title, 'title')}\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.title) }}\n />\n <Purpose purpose=\"passage-text\">\n <div\n className=\"text\"\n key={tab.id}\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.text) }}\n />\n </Purpose>\n </TabContainer>\n </div>)}\n </div>\n ) : (\n <div className={classes.root}>\n <Tabs\n classes={{\n root: classes.stickyTabs,\n flexContainer: classes.buttonContainer\n }}\n value={activeTab}\n onChange={this.handleChange}\n >\n {tabs.map((tab) => (\n <Tab\n className={classes.tab}\n key={tab.id}\n label={\n <Purpose purpose=\"passage-title\">\n <span\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.title) }}\n />\n </Purpose>\n }\n value={tab.id}\n />\n ))}\n </Tabs>\n {tabs.map((tab) =>\n activeTab === tab.id ? (\n <TabContainer multiple key={tab.id}>\n <Purpose purpose=\"passage-text\">\n <div\n key={tab.id}\n dangerouslySetInnerHTML={{ __html: this.parsedText(tab.text) }}\n />\n </Purpose>\n </TabContainer>\n\n ) : null\n )}\n </div>\n );\n\n } else if (tabs && tabs[0]) {\n return (\n <div className=\"passage\" style={{ whiteSpace: 'break-spaces' }} >\n <TabContainer>\n <div className=\"text\" dangerouslySetInnerHTML={{ __html: this.parsedText(tabs[0].text) }} />\n </TabContainer>\n </div>\n );\n }\n }\n}\n\nStimulusTabs.propTypes = {\n classes: PropTypes.object.isRequired,\n tabs: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.number.isRequired,\n title: PropTypes.string.isRequired,\n text: PropTypes.string.isRequired,\n }).isRequired\n ).isRequired,\n disabledTabs: PropTypes.bool\n};\n\nexport default withStyles(styles)(StimulusTabs);\n"],"file":"stimulus-tabs.js"}
|
package/module/demo.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Element from './element.js';
|
|
2
|
+
|
|
3
|
+
var generate = {};
|
|
4
|
+
|
|
5
|
+
generate.model = (id, element) => ({
|
|
6
|
+
id,
|
|
7
|
+
element,
|
|
8
|
+
passages: [
|
|
9
|
+
{
|
|
10
|
+
title: 'Hope Is the Thing with Feathers',
|
|
11
|
+
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><p><span class="no-number">"Hope is the Thing With Feathers" by Emily Dickinson, from <em>The Complete Poems of Emily Dickinson</em>. In the public domain.</span></p>'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
title: 'Ineskeen Road, July Evening',
|
|
15
|
+
text: `The bicycles go by in twos and threes -<br/>
|
|
16
|
+
There's a dance in Billy Brennan's barn tonight,<br/>
|
|
17
|
+
And there's the half-talk code of mysteries<br/>
|
|
18
|
+
And the wink-and-elbow language of delight.<br/>
|
|
19
|
+
Half-past eight and there is not a spot<br/>
|
|
20
|
+
Upon a mile of road, no shadow thrown<br/>
|
|
21
|
+
That might turn out a man or woman, not<br/>
|
|
22
|
+
A footfall tapping secrecies of stone. <br/>
|
|
23
|
+
<p/>
|
|
24
|
+
I have what every poet hates in spite<br/>
|
|
25
|
+
Of all the solemn talk of contemplation.<br/>
|
|
26
|
+
Oh, Alexander Selkirk knew the plight<br/>
|
|
27
|
+
Of being king and government and nation.<br/>
|
|
28
|
+
A road, a mile of kingdom. I am king<br/>
|
|
29
|
+
Of banks and stones and every blooming thing.<br/>
|
|
30
|
+
`
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const { model } = generate;
|
|
36
|
+
|
|
37
|
+
var config = {
|
|
38
|
+
elements: {
|
|
39
|
+
'passage-element': '../..'
|
|
40
|
+
},
|
|
41
|
+
models: [model('1', 'passage-element')]
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// configure
|
|
45
|
+
class Configure extends HTMLElement{}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// controller
|
|
49
|
+
const controller = {
|
|
50
|
+
model: (q) => Promise.resolve(q),
|
|
51
|
+
outcome: (q) => Promise.resolve(q)
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
//Note: demo-el is a custom element loaded in the markup.
|
|
56
|
+
customElements.whenDefined("demo-el").then(() => {
|
|
57
|
+
config.models.forEach((m) => {
|
|
58
|
+
const de = document.createElement("demo-el");
|
|
59
|
+
document.body.appendChild(de);
|
|
60
|
+
de.def = { tagName: m.element, Element, Configure, controller };
|
|
61
|
+
de.model = m;
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_classnames, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.8/module/index.js";
|
|
2
|
+
var lib = {};
|
|
3
|
+
Object.defineProperty(lib, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
class ModelSetEvent extends CustomEvent {
|
|
7
|
+
constructor(component, complete, hasModel) {
|
|
8
|
+
super(ModelSetEvent.TYPE, {
|
|
9
|
+
bubbles: true,
|
|
10
|
+
composed: true,
|
|
11
|
+
detail: {
|
|
12
|
+
complete,
|
|
13
|
+
component,
|
|
14
|
+
hasModel
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
this.component = component;
|
|
18
|
+
this.complete = complete;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
ModelSetEvent.TYPE = 'model-set';
|
|
22
|
+
var ModelSetEvent_1 = lib.ModelSetEvent = ModelSetEvent;
|
|
23
|
+
class SessionChangedEvent extends CustomEvent {
|
|
24
|
+
constructor(component, complete) {
|
|
25
|
+
super(SessionChangedEvent.TYPE, {
|
|
26
|
+
bubbles: true,
|
|
27
|
+
composed: true,
|
|
28
|
+
detail: {
|
|
29
|
+
complete,
|
|
30
|
+
component
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
this.component = component;
|
|
34
|
+
this.complete = complete;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
SessionChangedEvent.TYPE = 'session-changed';
|
|
38
|
+
lib.SessionChangedEvent = SessionChangedEvent;
|
|
39
|
+
const React$1 = _dll_react;
|
|
40
|
+
const PropTypes = _dll_prop_types;
|
|
41
|
+
const {Tabs: Tabs} = _dll_material_ui__core;
|
|
42
|
+
const {Tab: Tab} = _dll_material_ui__core;
|
|
43
|
+
const {Typography: Typography} = _dll_material_ui__core;
|
|
44
|
+
const {withStyles: withStyles} = _dll_material_ui__core_styles;
|
|
45
|
+
const {color: color} = _dll_pie_lib__render_ui;
|
|
46
|
+
const {Purpose: Purpose} = _dll_pie_lib__render_ui;
|
|
47
|
+
const classNames = _dll_classnames;
|
|
48
|
+
const _jsxFileName = "/home/circleci/repo/packages/passage/src/stimulus-tabs.jsx";
|
|
49
|
+
const styles = () => ({
|
|
50
|
+
root: {
|
|
51
|
+
flexGrow: 1,
|
|
52
|
+
backgroundColor: color.background(),
|
|
53
|
+
color: color.text()
|
|
54
|
+
},
|
|
55
|
+
tab: {
|
|
56
|
+
fontSize: '0.8125em'
|
|
57
|
+
},
|
|
58
|
+
stickyTabs: {
|
|
59
|
+
background: color.background(),
|
|
60
|
+
paddingBottom: '20px',
|
|
61
|
+
position: 'sticky',
|
|
62
|
+
top: 0
|
|
63
|
+
},
|
|
64
|
+
title: {
|
|
65
|
+
textTransform: 'uppercase',
|
|
66
|
+
padding: '6px 24px',
|
|
67
|
+
borderBottom: `2px solid ${color.secondary()}`,
|
|
68
|
+
width: 'fit-content',
|
|
69
|
+
marginBottom: '6px'
|
|
70
|
+
},
|
|
71
|
+
buttonContainer: {
|
|
72
|
+
background: 'white'
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
function TabContainer(props) {
|
|
76
|
+
const padding = props.multiple ? '0 24px 24px 24px' : '24px';
|
|
77
|
+
return React$1.createElement(Typography, {
|
|
78
|
+
component: "div",
|
|
79
|
+
style: {
|
|
80
|
+
padding,
|
|
81
|
+
fontSize: '0.875em',
|
|
82
|
+
backgroundColor: color.background(),
|
|
83
|
+
color: color.text()
|
|
84
|
+
},
|
|
85
|
+
__self: this,
|
|
86
|
+
__source: {
|
|
87
|
+
fileName: _jsxFileName,
|
|
88
|
+
lineNumber: 41
|
|
89
|
+
}
|
|
90
|
+
}, props.children);
|
|
91
|
+
}
|
|
92
|
+
TabContainer.propTypes = {
|
|
93
|
+
children: PropTypes.node.isRequired,
|
|
94
|
+
multiple: PropTypes.bool
|
|
95
|
+
};
|
|
96
|
+
class StimulusTabs extends React$1.Component {
|
|
97
|
+
constructor(...args) {
|
|
98
|
+
super(...args);
|
|
99
|
+
StimulusTabs.prototype.__init.call(this);
|
|
100
|
+
StimulusTabs.prototype.__init2.call(this);
|
|
101
|
+
StimulusTabs.prototype.__init3.call(this);
|
|
102
|
+
}
|
|
103
|
+
__init() {
|
|
104
|
+
this.state = {
|
|
105
|
+
activeTab: 0
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
__init2() {
|
|
109
|
+
this.handleChange = (event, activeTab) => {
|
|
110
|
+
this.setState(() => ({
|
|
111
|
+
activeTab
|
|
112
|
+
}));
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
const tabChangeEvent = new CustomEvent('pie-ui-passage-tabChanged', {
|
|
115
|
+
detail: {
|
|
116
|
+
tab: activeTab
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
window.dispatchEvent(tabChangeEvent);
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
__init3() {
|
|
124
|
+
this.parsedText = text => {
|
|
125
|
+
const div = document.createElement('div');
|
|
126
|
+
div.innerHTML = text.replace(/(<br\/>\n)/g, '<br/>');
|
|
127
|
+
const audio = div.querySelector('audio');
|
|
128
|
+
if (audio) {
|
|
129
|
+
const source = document.createElement('source');
|
|
130
|
+
source.setAttribute('type', 'audio/mp3');
|
|
131
|
+
source.setAttribute('src', audio.getAttribute('src'));
|
|
132
|
+
audio.removeAttribute('src');
|
|
133
|
+
audio.appendChild(source);
|
|
134
|
+
}
|
|
135
|
+
return div.innerHTML;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
render() {
|
|
139
|
+
const {classes, tabs, disabledTabs} = this.props;
|
|
140
|
+
const {activeTab} = this.state;
|
|
141
|
+
if (tabs && tabs.length > 1) {
|
|
142
|
+
return disabledTabs ? React$1.createElement('div', {
|
|
143
|
+
className: "passages",
|
|
144
|
+
__self: this,
|
|
145
|
+
__source: {
|
|
146
|
+
fileName: _jsxFileName,
|
|
147
|
+
lineNumber: 103
|
|
148
|
+
}
|
|
149
|
+
}, tabs.map(tab => React$1.createElement('div', {
|
|
150
|
+
key: tab.id,
|
|
151
|
+
className: `passage-${tab.id}`,
|
|
152
|
+
__self: this,
|
|
153
|
+
__source: {
|
|
154
|
+
fileName: _jsxFileName,
|
|
155
|
+
lineNumber: 105
|
|
156
|
+
}
|
|
157
|
+
}, React$1.createElement(TabContainer, {
|
|
158
|
+
multiple: true,
|
|
159
|
+
__self: this,
|
|
160
|
+
__source: {
|
|
161
|
+
fileName: _jsxFileName,
|
|
162
|
+
lineNumber: 106
|
|
163
|
+
}
|
|
164
|
+
}, React$1.createElement('div', {
|
|
165
|
+
className: classNames(classes.title, 'title'),
|
|
166
|
+
dangerouslySetInnerHTML: {
|
|
167
|
+
__html: this.parsedText(tab.title)
|
|
168
|
+
},
|
|
169
|
+
__self: this,
|
|
170
|
+
__source: {
|
|
171
|
+
fileName: _jsxFileName,
|
|
172
|
+
lineNumber: 107
|
|
173
|
+
}
|
|
174
|
+
}), React$1.createElement(Purpose, {
|
|
175
|
+
purpose: "passage-text",
|
|
176
|
+
__self: this,
|
|
177
|
+
__source: {
|
|
178
|
+
fileName: _jsxFileName,
|
|
179
|
+
lineNumber: 111
|
|
180
|
+
}
|
|
181
|
+
}, React$1.createElement('div', {
|
|
182
|
+
className: "text",
|
|
183
|
+
key: tab.id,
|
|
184
|
+
dangerouslySetInnerHTML: {
|
|
185
|
+
__html: this.parsedText(tab.text)
|
|
186
|
+
},
|
|
187
|
+
__self: this,
|
|
188
|
+
__source: {
|
|
189
|
+
fileName: _jsxFileName,
|
|
190
|
+
lineNumber: 112
|
|
191
|
+
}
|
|
192
|
+
})))))) : React$1.createElement('div', {
|
|
193
|
+
className: classes.root,
|
|
194
|
+
__self: this,
|
|
195
|
+
__source: {
|
|
196
|
+
fileName: _jsxFileName,
|
|
197
|
+
lineNumber: 122
|
|
198
|
+
}
|
|
199
|
+
}, React$1.createElement(Tabs, {
|
|
200
|
+
classes: {
|
|
201
|
+
root: classes.stickyTabs,
|
|
202
|
+
flexContainer: classes.buttonContainer
|
|
203
|
+
},
|
|
204
|
+
value: activeTab,
|
|
205
|
+
onChange: this.handleChange,
|
|
206
|
+
__self: this,
|
|
207
|
+
__source: {
|
|
208
|
+
fileName: _jsxFileName,
|
|
209
|
+
lineNumber: 123
|
|
210
|
+
}
|
|
211
|
+
}, tabs.map(tab => React$1.createElement(Tab, {
|
|
212
|
+
className: classes.tab,
|
|
213
|
+
key: tab.id,
|
|
214
|
+
label: React$1.createElement(Purpose, {
|
|
215
|
+
purpose: "passage-title",
|
|
216
|
+
__self: this,
|
|
217
|
+
__source: {
|
|
218
|
+
fileName: _jsxFileName,
|
|
219
|
+
lineNumber: 136
|
|
220
|
+
}
|
|
221
|
+
}, React$1.createElement('span', {
|
|
222
|
+
dangerouslySetInnerHTML: {
|
|
223
|
+
__html: this.parsedText(tab.title)
|
|
224
|
+
},
|
|
225
|
+
__self: this,
|
|
226
|
+
__source: {
|
|
227
|
+
fileName: _jsxFileName,
|
|
228
|
+
lineNumber: 137
|
|
229
|
+
}
|
|
230
|
+
})),
|
|
231
|
+
value: tab.id,
|
|
232
|
+
__self: this,
|
|
233
|
+
__source: {
|
|
234
|
+
fileName: _jsxFileName,
|
|
235
|
+
lineNumber: 132
|
|
236
|
+
}
|
|
237
|
+
}))), tabs.map(tab => activeTab === tab.id ? React$1.createElement(TabContainer, {
|
|
238
|
+
multiple: true,
|
|
239
|
+
key: tab.id,
|
|
240
|
+
__self: this,
|
|
241
|
+
__source: {
|
|
242
|
+
fileName: _jsxFileName,
|
|
243
|
+
lineNumber: 148
|
|
244
|
+
}
|
|
245
|
+
}, React$1.createElement(Purpose, {
|
|
246
|
+
purpose: "passage-text",
|
|
247
|
+
__self: this,
|
|
248
|
+
__source: {
|
|
249
|
+
fileName: _jsxFileName,
|
|
250
|
+
lineNumber: 149
|
|
251
|
+
}
|
|
252
|
+
}, React$1.createElement('div', {
|
|
253
|
+
key: tab.id,
|
|
254
|
+
dangerouslySetInnerHTML: {
|
|
255
|
+
__html: this.parsedText(tab.text)
|
|
256
|
+
},
|
|
257
|
+
__self: this,
|
|
258
|
+
__source: {
|
|
259
|
+
fileName: _jsxFileName,
|
|
260
|
+
lineNumber: 150
|
|
261
|
+
}
|
|
262
|
+
}))) : null));
|
|
263
|
+
} else if (tabs && tabs[0]) {
|
|
264
|
+
return React$1.createElement('div', {
|
|
265
|
+
className: "passage",
|
|
266
|
+
style: {
|
|
267
|
+
whiteSpace: 'break-spaces'
|
|
268
|
+
},
|
|
269
|
+
__self: this,
|
|
270
|
+
__source: {
|
|
271
|
+
fileName: _jsxFileName,
|
|
272
|
+
lineNumber: 164
|
|
273
|
+
}
|
|
274
|
+
}, React$1.createElement(TabContainer, {
|
|
275
|
+
__self: this,
|
|
276
|
+
__source: {
|
|
277
|
+
fileName: _jsxFileName,
|
|
278
|
+
lineNumber: 165
|
|
279
|
+
}
|
|
280
|
+
}, React$1.createElement('div', {
|
|
281
|
+
className: "text",
|
|
282
|
+
dangerouslySetInnerHTML: {
|
|
283
|
+
__html: this.parsedText(tabs[0].text)
|
|
284
|
+
},
|
|
285
|
+
__self: this,
|
|
286
|
+
__source: {
|
|
287
|
+
fileName: _jsxFileName,
|
|
288
|
+
lineNumber: 166
|
|
289
|
+
}
|
|
290
|
+
})));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
StimulusTabs.propTypes = {
|
|
295
|
+
classes: PropTypes.object.isRequired,
|
|
296
|
+
tabs: PropTypes.arrayOf(PropTypes.shape({
|
|
297
|
+
id: PropTypes.number.isRequired,
|
|
298
|
+
title: PropTypes.string.isRequired,
|
|
299
|
+
text: PropTypes.string.isRequired
|
|
300
|
+
}).isRequired).isRequired,
|
|
301
|
+
disabledTabs: PropTypes.bool
|
|
302
|
+
};
|
|
303
|
+
var StimulusTabs$1 = withStyles(styles)(StimulusTabs);
|
|
304
|
+
const React = _dll_react;
|
|
305
|
+
const ReactDOM = _dll_react_dom;
|
|
306
|
+
class PiePassage extends HTMLElement {
|
|
307
|
+
constructor() {
|
|
308
|
+
super();
|
|
309
|
+
this._model = {
|
|
310
|
+
passages: []
|
|
311
|
+
};
|
|
312
|
+
this._session = null;
|
|
313
|
+
}
|
|
314
|
+
set model(s) {
|
|
315
|
+
this._model = s;
|
|
316
|
+
this.dispatchEvent(new ModelSetEvent_1(this.tagName.toLowerCase(), this._session, !!this._model));
|
|
317
|
+
this._render();
|
|
318
|
+
}
|
|
319
|
+
set session(s) {
|
|
320
|
+
this._session = s;
|
|
321
|
+
}
|
|
322
|
+
connectedCallback() {
|
|
323
|
+
this._render();
|
|
324
|
+
}
|
|
325
|
+
_render() {
|
|
326
|
+
if (this._model.passages.length > 0) {
|
|
327
|
+
const passagesTabs = this._model.passages.map((passage, index) => {
|
|
328
|
+
return {
|
|
329
|
+
id: index,
|
|
330
|
+
title: passage.title,
|
|
331
|
+
text: passage.text
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
let elem = React.createElement(StimulusTabs$1, {
|
|
335
|
+
tabs: passagesTabs
|
|
336
|
+
});
|
|
337
|
+
ReactDOM.render(elem, this);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
export {PiePassage as default};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>@pie-element/passage@1.7.6</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,92 @@
|
|
|
1
|
+
import PrintElement from './print.js';
|
|
2
|
+
|
|
3
|
+
var generate = {};
|
|
4
|
+
|
|
5
|
+
generate.model = (id, element) => ({
|
|
6
|
+
id,
|
|
7
|
+
element,
|
|
8
|
+
passages: [
|
|
9
|
+
{
|
|
10
|
+
title: 'Hope Is the Thing with Feathers',
|
|
11
|
+
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><p><span class="no-number">"Hope is the Thing With Feathers" by Emily Dickinson, from <em>The Complete Poems of Emily Dickinson</em>. In the public domain.</span></p>'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
title: 'Ineskeen Road, July Evening',
|
|
15
|
+
text: `The bicycles go by in twos and threes -<br/>
|
|
16
|
+
There's a dance in Billy Brennan's barn tonight,<br/>
|
|
17
|
+
And there's the half-talk code of mysteries<br/>
|
|
18
|
+
And the wink-and-elbow language of delight.<br/>
|
|
19
|
+
Half-past eight and there is not a spot<br/>
|
|
20
|
+
Upon a mile of road, no shadow thrown<br/>
|
|
21
|
+
That might turn out a man or woman, not<br/>
|
|
22
|
+
A footfall tapping secrecies of stone. <br/>
|
|
23
|
+
<p/>
|
|
24
|
+
I have what every poet hates in spite<br/>
|
|
25
|
+
Of all the solemn talk of contemplation.<br/>
|
|
26
|
+
Oh, Alexander Selkirk knew the plight<br/>
|
|
27
|
+
Of being king and government and nation.<br/>
|
|
28
|
+
A road, a mile of kingdom. I am king<br/>
|
|
29
|
+
Of banks and stones and every blooming thing.<br/>
|
|
30
|
+
`
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const { model } = generate;
|
|
36
|
+
|
|
37
|
+
var config = {
|
|
38
|
+
elements: {
|
|
39
|
+
'passage-element': '../..'
|
|
40
|
+
},
|
|
41
|
+
models: [model('1', 'passage-element')]
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// new init - just shows off print!
|
|
45
|
+
|
|
46
|
+
const init = async () => {
|
|
47
|
+
console.log('define the element...');
|
|
48
|
+
await Promise.all(
|
|
49
|
+
config.models.map(async (m) => {
|
|
50
|
+
try {
|
|
51
|
+
const printTag = `${m.element}-print`;
|
|
52
|
+
if (customElements.get(printTag)) {
|
|
53
|
+
return true;
|
|
54
|
+
} else {
|
|
55
|
+
customElements.define(printTag, PrintElement);
|
|
56
|
+
await customElements.whenDefined(printTag);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
console.log('now apply the model...');
|
|
66
|
+
config.models.forEach((m) => {
|
|
67
|
+
const printTag = `${m.element}-print`;
|
|
68
|
+
const h3s = document.createElement('h3');
|
|
69
|
+
h3s.textContent = 'student mode';
|
|
70
|
+
document.body.appendChild(h3s);
|
|
71
|
+
const de = document.createElement(printTag);
|
|
72
|
+
document.body.appendChild(de);
|
|
73
|
+
de.options = {};
|
|
74
|
+
de.model = m;
|
|
75
|
+
|
|
76
|
+
const h3 = document.createElement('h3');
|
|
77
|
+
h3.textContent = 'instructor mode';
|
|
78
|
+
document.body.appendChild(h3);
|
|
79
|
+
const instr = document.createElement(printTag);
|
|
80
|
+
document.body.appendChild(instr);
|
|
81
|
+
instr.options = { mode: 'instructor' };
|
|
82
|
+
instr.model = JSON.parse(JSON.stringify(m));
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
init()
|
|
87
|
+
.then(() => {
|
|
88
|
+
console.log('ready');
|
|
89
|
+
})
|
|
90
|
+
.catch((e) => {
|
|
91
|
+
console.error(e);
|
|
92
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>@pie-element/passage@1.7.6</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
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.8/module/index.js";
|
|
2
|
+
const React$1 = _dll_react;
|
|
3
|
+
const PropTypes = _dll_prop_types;
|
|
4
|
+
const {Tabs: Tabs} = _dll_material_ui__core;
|
|
5
|
+
const {Tab: Tab} = _dll_material_ui__core;
|
|
6
|
+
const {Typography: Typography} = _dll_material_ui__core;
|
|
7
|
+
const {withStyles: withStyles} = _dll_material_ui__core_styles;
|
|
8
|
+
const {color: color} = _dll_pie_lib__render_ui;
|
|
9
|
+
const {Purpose: Purpose} = _dll_pie_lib__render_ui;
|
|
10
|
+
const classNames = _dll_classnames;
|
|
11
|
+
const _jsxFileName = "/home/circleci/repo/packages/passage/src/stimulus-tabs.jsx";
|
|
12
|
+
const styles = () => ({
|
|
13
|
+
root: {
|
|
14
|
+
flexGrow: 1,
|
|
15
|
+
backgroundColor: color.background(),
|
|
16
|
+
color: color.text()
|
|
17
|
+
},
|
|
18
|
+
tab: {
|
|
19
|
+
fontSize: '0.8125em'
|
|
20
|
+
},
|
|
21
|
+
stickyTabs: {
|
|
22
|
+
background: color.background(),
|
|
23
|
+
paddingBottom: '20px',
|
|
24
|
+
position: 'sticky',
|
|
25
|
+
top: 0
|
|
26
|
+
},
|
|
27
|
+
title: {
|
|
28
|
+
textTransform: 'uppercase',
|
|
29
|
+
padding: '6px 24px',
|
|
30
|
+
borderBottom: `2px solid ${color.secondary()}`,
|
|
31
|
+
width: 'fit-content',
|
|
32
|
+
marginBottom: '6px'
|
|
33
|
+
},
|
|
34
|
+
buttonContainer: {
|
|
35
|
+
background: 'white'
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
function TabContainer(props) {
|
|
39
|
+
const padding = props.multiple ? '0 24px 24px 24px' : '24px';
|
|
40
|
+
return React$1.createElement(Typography, {
|
|
41
|
+
component: "div",
|
|
42
|
+
style: {
|
|
43
|
+
padding,
|
|
44
|
+
fontSize: '0.875em',
|
|
45
|
+
backgroundColor: color.background(),
|
|
46
|
+
color: color.text()
|
|
47
|
+
},
|
|
48
|
+
__self: this,
|
|
49
|
+
__source: {
|
|
50
|
+
fileName: _jsxFileName,
|
|
51
|
+
lineNumber: 41
|
|
52
|
+
}
|
|
53
|
+
}, props.children);
|
|
54
|
+
}
|
|
55
|
+
TabContainer.propTypes = {
|
|
56
|
+
children: PropTypes.node.isRequired,
|
|
57
|
+
multiple: PropTypes.bool
|
|
58
|
+
};
|
|
59
|
+
class StimulusTabs extends React$1.Component {
|
|
60
|
+
constructor(...args) {
|
|
61
|
+
super(...args);
|
|
62
|
+
StimulusTabs.prototype.__init.call(this);
|
|
63
|
+
StimulusTabs.prototype.__init2.call(this);
|
|
64
|
+
StimulusTabs.prototype.__init3.call(this);
|
|
65
|
+
}
|
|
66
|
+
__init() {
|
|
67
|
+
this.state = {
|
|
68
|
+
activeTab: 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
__init2() {
|
|
72
|
+
this.handleChange = (event, activeTab) => {
|
|
73
|
+
this.setState(() => ({
|
|
74
|
+
activeTab
|
|
75
|
+
}));
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
const tabChangeEvent = new CustomEvent('pie-ui-passage-tabChanged', {
|
|
78
|
+
detail: {
|
|
79
|
+
tab: activeTab
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
window.dispatchEvent(tabChangeEvent);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
__init3() {
|
|
87
|
+
this.parsedText = text => {
|
|
88
|
+
const div = document.createElement('div');
|
|
89
|
+
div.innerHTML = text.replace(/(<br\/>\n)/g, '<br/>');
|
|
90
|
+
const audio = div.querySelector('audio');
|
|
91
|
+
if (audio) {
|
|
92
|
+
const source = document.createElement('source');
|
|
93
|
+
source.setAttribute('type', 'audio/mp3');
|
|
94
|
+
source.setAttribute('src', audio.getAttribute('src'));
|
|
95
|
+
audio.removeAttribute('src');
|
|
96
|
+
audio.appendChild(source);
|
|
97
|
+
}
|
|
98
|
+
return div.innerHTML;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
render() {
|
|
102
|
+
const {classes, tabs, disabledTabs} = this.props;
|
|
103
|
+
const {activeTab} = this.state;
|
|
104
|
+
if (tabs && tabs.length > 1) {
|
|
105
|
+
return disabledTabs ? React$1.createElement('div', {
|
|
106
|
+
className: "passages",
|
|
107
|
+
__self: this,
|
|
108
|
+
__source: {
|
|
109
|
+
fileName: _jsxFileName,
|
|
110
|
+
lineNumber: 103
|
|
111
|
+
}
|
|
112
|
+
}, tabs.map(tab => React$1.createElement('div', {
|
|
113
|
+
key: tab.id,
|
|
114
|
+
className: `passage-${tab.id}`,
|
|
115
|
+
__self: this,
|
|
116
|
+
__source: {
|
|
117
|
+
fileName: _jsxFileName,
|
|
118
|
+
lineNumber: 105
|
|
119
|
+
}
|
|
120
|
+
}, React$1.createElement(TabContainer, {
|
|
121
|
+
multiple: true,
|
|
122
|
+
__self: this,
|
|
123
|
+
__source: {
|
|
124
|
+
fileName: _jsxFileName,
|
|
125
|
+
lineNumber: 106
|
|
126
|
+
}
|
|
127
|
+
}, React$1.createElement('div', {
|
|
128
|
+
className: classNames(classes.title, 'title'),
|
|
129
|
+
dangerouslySetInnerHTML: {
|
|
130
|
+
__html: this.parsedText(tab.title)
|
|
131
|
+
},
|
|
132
|
+
__self: this,
|
|
133
|
+
__source: {
|
|
134
|
+
fileName: _jsxFileName,
|
|
135
|
+
lineNumber: 107
|
|
136
|
+
}
|
|
137
|
+
}), React$1.createElement(Purpose, {
|
|
138
|
+
purpose: "passage-text",
|
|
139
|
+
__self: this,
|
|
140
|
+
__source: {
|
|
141
|
+
fileName: _jsxFileName,
|
|
142
|
+
lineNumber: 111
|
|
143
|
+
}
|
|
144
|
+
}, React$1.createElement('div', {
|
|
145
|
+
className: "text",
|
|
146
|
+
key: tab.id,
|
|
147
|
+
dangerouslySetInnerHTML: {
|
|
148
|
+
__html: this.parsedText(tab.text)
|
|
149
|
+
},
|
|
150
|
+
__self: this,
|
|
151
|
+
__source: {
|
|
152
|
+
fileName: _jsxFileName,
|
|
153
|
+
lineNumber: 112
|
|
154
|
+
}
|
|
155
|
+
})))))) : React$1.createElement('div', {
|
|
156
|
+
className: classes.root,
|
|
157
|
+
__self: this,
|
|
158
|
+
__source: {
|
|
159
|
+
fileName: _jsxFileName,
|
|
160
|
+
lineNumber: 122
|
|
161
|
+
}
|
|
162
|
+
}, React$1.createElement(Tabs, {
|
|
163
|
+
classes: {
|
|
164
|
+
root: classes.stickyTabs,
|
|
165
|
+
flexContainer: classes.buttonContainer
|
|
166
|
+
},
|
|
167
|
+
value: activeTab,
|
|
168
|
+
onChange: this.handleChange,
|
|
169
|
+
__self: this,
|
|
170
|
+
__source: {
|
|
171
|
+
fileName: _jsxFileName,
|
|
172
|
+
lineNumber: 123
|
|
173
|
+
}
|
|
174
|
+
}, tabs.map(tab => React$1.createElement(Tab, {
|
|
175
|
+
className: classes.tab,
|
|
176
|
+
key: tab.id,
|
|
177
|
+
label: React$1.createElement(Purpose, {
|
|
178
|
+
purpose: "passage-title",
|
|
179
|
+
__self: this,
|
|
180
|
+
__source: {
|
|
181
|
+
fileName: _jsxFileName,
|
|
182
|
+
lineNumber: 136
|
|
183
|
+
}
|
|
184
|
+
}, React$1.createElement('span', {
|
|
185
|
+
dangerouslySetInnerHTML: {
|
|
186
|
+
__html: this.parsedText(tab.title)
|
|
187
|
+
},
|
|
188
|
+
__self: this,
|
|
189
|
+
__source: {
|
|
190
|
+
fileName: _jsxFileName,
|
|
191
|
+
lineNumber: 137
|
|
192
|
+
}
|
|
193
|
+
})),
|
|
194
|
+
value: tab.id,
|
|
195
|
+
__self: this,
|
|
196
|
+
__source: {
|
|
197
|
+
fileName: _jsxFileName,
|
|
198
|
+
lineNumber: 132
|
|
199
|
+
}
|
|
200
|
+
}))), tabs.map(tab => activeTab === tab.id ? React$1.createElement(TabContainer, {
|
|
201
|
+
multiple: true,
|
|
202
|
+
key: tab.id,
|
|
203
|
+
__self: this,
|
|
204
|
+
__source: {
|
|
205
|
+
fileName: _jsxFileName,
|
|
206
|
+
lineNumber: 148
|
|
207
|
+
}
|
|
208
|
+
}, React$1.createElement(Purpose, {
|
|
209
|
+
purpose: "passage-text",
|
|
210
|
+
__self: this,
|
|
211
|
+
__source: {
|
|
212
|
+
fileName: _jsxFileName,
|
|
213
|
+
lineNumber: 149
|
|
214
|
+
}
|
|
215
|
+
}, React$1.createElement('div', {
|
|
216
|
+
key: tab.id,
|
|
217
|
+
dangerouslySetInnerHTML: {
|
|
218
|
+
__html: this.parsedText(tab.text)
|
|
219
|
+
},
|
|
220
|
+
__self: this,
|
|
221
|
+
__source: {
|
|
222
|
+
fileName: _jsxFileName,
|
|
223
|
+
lineNumber: 150
|
|
224
|
+
}
|
|
225
|
+
}))) : null));
|
|
226
|
+
} else if (tabs && tabs[0]) {
|
|
227
|
+
return React$1.createElement('div', {
|
|
228
|
+
className: "passage",
|
|
229
|
+
style: {
|
|
230
|
+
whiteSpace: 'break-spaces'
|
|
231
|
+
},
|
|
232
|
+
__self: this,
|
|
233
|
+
__source: {
|
|
234
|
+
fileName: _jsxFileName,
|
|
235
|
+
lineNumber: 164
|
|
236
|
+
}
|
|
237
|
+
}, React$1.createElement(TabContainer, {
|
|
238
|
+
__self: this,
|
|
239
|
+
__source: {
|
|
240
|
+
fileName: _jsxFileName,
|
|
241
|
+
lineNumber: 165
|
|
242
|
+
}
|
|
243
|
+
}, React$1.createElement('div', {
|
|
244
|
+
className: "text",
|
|
245
|
+
dangerouslySetInnerHTML: {
|
|
246
|
+
__html: this.parsedText(tabs[0].text)
|
|
247
|
+
},
|
|
248
|
+
__self: this,
|
|
249
|
+
__source: {
|
|
250
|
+
fileName: _jsxFileName,
|
|
251
|
+
lineNumber: 166
|
|
252
|
+
}
|
|
253
|
+
})));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
StimulusTabs.propTypes = {
|
|
258
|
+
classes: PropTypes.object.isRequired,
|
|
259
|
+
tabs: PropTypes.arrayOf(PropTypes.shape({
|
|
260
|
+
id: PropTypes.number.isRequired,
|
|
261
|
+
title: PropTypes.string.isRequired,
|
|
262
|
+
text: PropTypes.string.isRequired
|
|
263
|
+
}).isRequired).isRequired,
|
|
264
|
+
disabledTabs: PropTypes.bool
|
|
265
|
+
};
|
|
266
|
+
var StimulusTabs$1 = withStyles(styles)(StimulusTabs);
|
|
267
|
+
const React = _dll_react;
|
|
268
|
+
const ReactDOM = _dll_react_dom;
|
|
269
|
+
const {debounce: debounce} = _dll_lodash;
|
|
270
|
+
const debug = _dll_debug;
|
|
271
|
+
const log = debug('pie-element:passage:print');
|
|
272
|
+
const preparePrintPassage = model => model.passages.map((passage, index) => {
|
|
273
|
+
return {
|
|
274
|
+
id: index,
|
|
275
|
+
title: passage.title,
|
|
276
|
+
text: passage.text
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
class PassagePrint extends HTMLElement {
|
|
280
|
+
constructor() {
|
|
281
|
+
super();
|
|
282
|
+
this._model = null;
|
|
283
|
+
this._session = [];
|
|
284
|
+
this._rerender = debounce(() => {
|
|
285
|
+
if (this._model && this._session) {
|
|
286
|
+
if (this._model.passages && this._model.passages.length > 0) {
|
|
287
|
+
const printPassage = preparePrintPassage(this._model);
|
|
288
|
+
const element = React.createElement(StimulusTabs$1, {
|
|
289
|
+
tabs: printPassage,
|
|
290
|
+
disabledTabs: true
|
|
291
|
+
});
|
|
292
|
+
ReactDOM.render(element, this);
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
log('skip');
|
|
296
|
+
}
|
|
297
|
+
}, 50, {
|
|
298
|
+
leading: false,
|
|
299
|
+
trailing: true
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
set model(s) {
|
|
303
|
+
this._model = s;
|
|
304
|
+
this._rerender();
|
|
305
|
+
}
|
|
306
|
+
connectedCallback() {}
|
|
307
|
+
}
|
|
308
|
+
export {PassagePrint as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/passage",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@material-ui/core": "^3.9.2",
|
|
13
13
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
14
|
-
"@pie-lib/render-ui": "^4.12.
|
|
14
|
+
"@pie-lib/render-ui": "^4.12.5",
|
|
15
15
|
"classnames": "^2.2.5",
|
|
16
16
|
"prop-types": "^15.6.1",
|
|
17
17
|
"react": "^16.8.1",
|
|
18
18
|
"react-dom": "^16.8.1"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "b32a90d35916de8f2b77d7b3428b02efbd145313",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"postpublish": "../../scripts/postpublish"
|
|
23
23
|
},
|