@pie-element/passage 1.7.8 → 1.7.11
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 +24 -0
- package/package.json +3 -3
- package/module/demo.js +0 -63
- package/module/element.js +0 -341
- package/module/index.html +0 -21
- package/module/manifest.json +0 -10
- package/module/print-demo.js +0 -92
- package/module/print.html +0 -18
- package/module/print.js +0 -308
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.11](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage@1.7.10...@pie-element/passage@1.7.11) (2022-07-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/passage
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.7.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage@1.7.9...@pie-element/passage@1.7.10) (2022-06-13)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/passage
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.7.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage@1.7.8...@pie-element/passage@1.7.9) (2022-05-30)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-element/passage
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [1.7.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/passage@1.7.7...@pie-element/passage@1.7.8) (2022-05-03)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @pie-element/passage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/passage",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.11",
|
|
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.
|
|
14
|
+
"@pie-lib/render-ui": "^4.13.1",
|
|
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": "30ddb939cb470e2b4f0281aec44143a9188e3106",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"postpublish": "../../scripts/postpublish"
|
|
23
23
|
},
|
package/module/demo.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
});
|
package/module/element.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
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.13/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};
|
package/module/index.html
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<title>@pie-element/passage@1.7.7</title>
|
|
6
|
-
<script
|
|
7
|
-
type="module"
|
|
8
|
-
src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
|
|
9
|
-
|
|
10
|
-
<link
|
|
11
|
-
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
12
|
-
rel="stylesheet"
|
|
13
|
-
/>
|
|
14
|
-
<style>
|
|
15
|
-
html, body {
|
|
16
|
-
font-family: 'Roboto', sans-serif;
|
|
17
|
-
}
|
|
18
|
-
</style>
|
|
19
|
-
<script type="module" src="./demo.js"></script>
|
|
20
|
-
</head>
|
|
21
|
-
</html>
|
package/module/manifest.json
DELETED
package/module/print-demo.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import PrintElement from './print.js';
|
|
2
|
-
|
|
3
|
-
var generate = {};
|
|
4
|
-
|
|
5
|
-
generate.model = (id, element) => ({
|
|
6
|
-
id,
|
|
7
|
-
element,
|
|
8
|
-
passages: [
|
|
9
|
-
{
|
|
10
|
-
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
|
-
});
|
package/module/print.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<title>@pie-element/passage@1.7.7</title>
|
|
6
|
-
<link
|
|
7
|
-
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
8
|
-
rel="stylesheet"
|
|
9
|
-
/>
|
|
10
|
-
<style>
|
|
11
|
-
html, body {
|
|
12
|
-
font-family: 'Roboto', sans-serif;
|
|
13
|
-
}
|
|
14
|
-
</style>
|
|
15
|
-
<script type="module" src="./print-demo.js"></script>
|
|
16
|
-
</head>
|
|
17
|
-
<body></body>
|
|
18
|
-
</html>
|
package/module/print.js
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
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.13/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};
|