@pie-element/passage 2.13.1-next.3 → 2.13.1-next.5

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/module/element.js CHANGED
@@ -8581,39 +8581,62 @@ const classNames = _dll_classnames;
8581
8581
  const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
8582
8582
  const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
8583
8583
  const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
8584
- const {Purpose: Purpose} = _dll_pie_lib__pie_toolbox_render_ui;
8585
8584
  const _jsxFileName = "/home/circleci/repo/packages/passage/src/stimulus-tabs.jsx";
8585
+ function _optionalChain(ops) {
8586
+ let lastAccessLHS = undefined;
8587
+ let value = ops[0];
8588
+ let i = 1;
8589
+ while (i < ops.length) {
8590
+ const op = ops[i];
8591
+ const fn = ops[i + 1];
8592
+ i += 2;
8593
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
8594
+ return undefined;
8595
+ }
8596
+ if (op === 'access' || op === 'optionalAccess') {
8597
+ lastAccessLHS = value;
8598
+ value = fn(value);
8599
+ } else if (op === 'call' || op === 'optionalCall') {
8600
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
8601
+ lastAccessLHS = undefined;
8602
+ }
8603
+ }
8604
+ return value;
8605
+ }
8586
8606
  const styles = theme => ({
8587
- root: {
8607
+ passages: {
8588
8608
  flexGrow: 1,
8589
8609
  backgroundColor: color.background(),
8590
8610
  color: color.text()
8591
8611
  },
8592
- tab: {
8593
- background: theme.palette.common.white,
8594
- fontSize: 'inherit',
8595
- color: theme.palette.common.black
8612
+ passage: {
8613
+ backgroundColor: color.background(),
8614
+ color: color.text(),
8615
+ padding: theme.spacing.unit * 2
8616
+ },
8617
+ passageTitle: {
8618
+ fontSize: '1.75rem'
8619
+ },
8620
+ passageSubtitle: {
8621
+ fontSize: '1.5rem'
8622
+ },
8623
+ passageAuthor: {
8624
+ fontSize: '1.25rem'
8596
8625
  },
8626
+ passageText: {},
8597
8627
  stickyTabs: {
8598
8628
  background: color.background(),
8599
8629
  position: 'sticky',
8600
8630
  top: 0
8601
8631
  },
8602
- title: {
8603
- textTransform: 'uppercase',
8604
- padding: `${theme.spacing.unit}px ${theme.spacing.unit * 3}px`,
8605
- borderBottom: `2px solid ${color.secondary()}`,
8606
- width: 'fit-content',
8607
- marginBottom: theme.spacing.unit
8632
+ tab: {
8633
+ background: theme.palette.common.white,
8634
+ fontSize: 'inherit',
8635
+ color: theme.palette.common.black
8608
8636
  },
8609
- buttonContainer: {
8637
+ tabButton: {
8610
8638
  background: theme.palette.common.white
8611
8639
  },
8612
- tabContainer: {
8613
- backgroundColor: color.background(),
8614
- color: color.text(),
8615
- padding: theme.spacing.unit * 2
8616
- },
8617
8640
  breakSpaces: {
8618
8641
  whiteSpace: 'break-spaces'
8619
8642
  },
@@ -8682,7 +8705,7 @@ class StimulusTabs extends React$1.Component {
8682
8705
  };
8683
8706
  }
8684
8707
  __init4() {
8685
- this.parsedText = text => {
8708
+ this.parsedText = (text = '') => {
8686
8709
  const div = document.createElement('div');
8687
8710
  div.innerHTML = text.replace(/(<br\/>\n)/g, '<br/>');
8688
8711
  const audio = div.querySelector('audio');
@@ -8708,7 +8731,7 @@ class StimulusTabs extends React$1.Component {
8708
8731
  __self: this,
8709
8732
  __source: {
8710
8733
  fileName: _jsxFileName,
8711
- lineNumber: 127
8734
+ lineNumber: 130
8712
8735
  }
8713
8736
  });
8714
8737
  if (disabledTabs) {
@@ -8722,171 +8745,126 @@ class StimulusTabs extends React$1.Component {
8722
8745
  __self: this,
8723
8746
  __source: {
8724
8747
  fileName: _jsxFileName,
8725
- lineNumber: 140
8748
+ lineNumber: 143
8726
8749
  }
8727
8750
  }, teacherInstructionsDiv);
8728
8751
  }
8752
+ renderTab(tab, showTeacherInstructions, disabledTabs) {
8753
+ const {classes} = this.props;
8754
+ return React$1.createElement('div', {
8755
+ className: classNames(classes.passage, 'passage'),
8756
+ key: tab.id,
8757
+ id: `tabpanel-${tab.id}`,
8758
+ role: "tabpanel",
8759
+ 'aria-labelledby': `button-${tab.id}`,
8760
+ __self: this,
8761
+ __source: {
8762
+ fileName: _jsxFileName,
8763
+ lineNumber: 158
8764
+ }
8765
+ }, this.renderInstructions(showTeacherInstructions, tab.teacherInstructions, disabledTabs), React$1.createElement('h2', {
8766
+ __self: this,
8767
+ __source: {
8768
+ fileName: _jsxFileName,
8769
+ lineNumber: 166
8770
+ }
8771
+ }, React$1.createElement('div', {
8772
+ className: classNames(classes.passageTitle, 'title'),
8773
+ dangerouslySetInnerHTML: {
8774
+ __html: this.parsedText(tab.title)
8775
+ },
8776
+ __self: this,
8777
+ __source: {
8778
+ fileName: _jsxFileName,
8779
+ lineNumber: 167
8780
+ }
8781
+ }), React$1.createElement('div', {
8782
+ className: classNames(classes.passageSubtitle, 'subtitle'),
8783
+ dangerouslySetInnerHTML: {
8784
+ __html: this.parsedText(tab.subtitle)
8785
+ },
8786
+ __self: this,
8787
+ __source: {
8788
+ fileName: _jsxFileName,
8789
+ lineNumber: 171
8790
+ }
8791
+ })), React$1.createElement('div', {
8792
+ className: classNames(classes.passageAuthor, 'author'),
8793
+ dangerouslySetInnerHTML: {
8794
+ __html: this.parsedText(tab.author)
8795
+ },
8796
+ __self: this,
8797
+ __source: {
8798
+ fileName: _jsxFileName,
8799
+ lineNumber: 176
8800
+ }
8801
+ }), React$1.createElement('div', {
8802
+ key: tab.id,
8803
+ className: classNames(classes.passageText, 'text'),
8804
+ dangerouslySetInnerHTML: {
8805
+ __html: this.parsedText(tab.text)
8806
+ },
8807
+ __self: this,
8808
+ __source: {
8809
+ fileName: _jsxFileName,
8810
+ lineNumber: 180
8811
+ }
8812
+ }));
8813
+ }
8729
8814
  render() {
8730
8815
  const {classes, tabs, disabledTabs, showTeacherInstructions} = this.props;
8731
8816
  const {activeTab} = this.state;
8732
- if (tabs && tabs.length > 1) {
8733
- return disabledTabs ? React$1.createElement('div', {
8734
- className: classNames(classes.root, 'passages'),
8735
- __self: this,
8736
- __source: {
8737
- fileName: _jsxFileName,
8738
- lineNumber: 157
8739
- }
8740
- }, tabs.map(tab => React$1.createElement('div', {
8741
- key: tab.id,
8742
- className: `passage-${tab.id}`,
8743
- id: `tabpanel-${tab.id}`,
8744
- 'aria-labelledby': `tab-${tab.id}`,
8745
- 'aria-controls': `tabpanel-${tab.id}`,
8746
- tabIndex: "0",
8747
- __self: this,
8748
- __source: {
8749
- fileName: _jsxFileName,
8750
- lineNumber: 159
8751
- }
8752
- }, React$1.createElement('div', {
8753
- className: classes.tabContainer,
8754
- id: `tabpanel-${tab.id}`,
8755
- role: "tabpanel",
8756
- 'aria-labelledby': `button-${tab.id}`,
8757
- __self: this,
8758
- __source: {
8759
- fileName: _jsxFileName,
8760
- lineNumber: 167
8761
- }
8762
- }, React$1.createElement('div', {
8763
- className: classNames(classes.title, 'title'),
8817
+ if (!_optionalChain([tabs, 'optionalAccess', _ => _.length])) {
8818
+ return;
8819
+ }
8820
+ const selectedTab = (tabs || []).find(tab => tab.id === activeTab);
8821
+ return React$1.createElement('div', {
8822
+ className: classNames(classes.passages, {
8823
+ [classes.breakSpaces]: tabs.length === 1
8824
+ }, 'passages'),
8825
+ __self: this,
8826
+ __source: {
8827
+ fileName: _jsxFileName,
8828
+ lineNumber: 200
8829
+ }
8830
+ }, disabledTabs || tabs.length === 1 ? tabs.map(tab => this.renderTab(tab, showTeacherInstructions, disabledTabs)) : React$1.createElement(React$1.Fragment, null, React$1.createElement(Tabs, {
8831
+ classes: {
8832
+ root: classes.stickyTabs,
8833
+ flexContainer: classes.tabButton
8834
+ },
8835
+ value: activeTab,
8836
+ onChange: this.handleChange,
8837
+ __self: this,
8838
+ __source: {
8839
+ fileName: _jsxFileName,
8840
+ lineNumber: 205
8841
+ }
8842
+ }, tabs.map(tab => React$1.createElement(Tab, {
8843
+ className: classes.tab,
8844
+ key: tab.id,
8845
+ id: `button-${tab.id}`,
8846
+ label: React$1.createElement('span', {
8764
8847
  dangerouslySetInnerHTML: {
8765
8848
  __html: this.parsedText(tab.title)
8766
8849
  },
8767
8850
  __self: this,
8768
8851
  __source: {
8769
8852
  fileName: _jsxFileName,
8770
- lineNumber: 173
8771
- }
8772
- }), this.renderInstructions(showTeacherInstructions, tab.teacherInstructions, disabledTabs), React$1.createElement(Purpose, {
8773
- purpose: "passage-text",
8774
- __self: this,
8775
- __source: {
8776
- fileName: _jsxFileName,
8777
- lineNumber: 178
8778
- }
8779
- }, React$1.createElement('div', {
8780
- className: "text",
8781
- key: tab.id,
8782
- dangerouslySetInnerHTML: {
8783
- __html: this.parsedText(tab.text)
8784
- },
8785
- __self: this,
8786
- __source: {
8787
- fileName: _jsxFileName,
8788
- lineNumber: 179
8789
- }
8790
- })))))) : React$1.createElement('div', {
8791
- className: classNames(classes.root, 'passages'),
8792
- __self: this,
8793
- __source: {
8794
- fileName: _jsxFileName,
8795
- lineNumber: 186
8796
- }
8797
- }, React$1.createElement(Tabs, {
8798
- classes: {
8799
- root: classes.stickyTabs,
8800
- flexContainer: classes.buttonContainer
8801
- },
8802
- value: activeTab,
8803
- onChange: this.handleChange,
8804
- __self: this,
8805
- __source: {
8806
- fileName: _jsxFileName,
8807
- lineNumber: 187
8808
- }
8809
- }, tabs.map(tab => React$1.createElement(Tab, {
8810
- className: classes.tab,
8811
- key: tab.id,
8812
- id: `button-${tab.id}`,
8813
- label: React$1.createElement(Purpose, {
8814
- purpose: "passage-title",
8815
- __self: this,
8816
- __source: {
8817
- fileName: _jsxFileName,
8818
- lineNumber: 201
8819
- }
8820
- }, React$1.createElement('span', {
8821
- dangerouslySetInnerHTML: {
8822
- __html: this.parsedText(tab.title)
8823
- },
8824
- __self: this,
8825
- __source: {
8826
- fileName: _jsxFileName,
8827
- lineNumber: 202
8828
- }
8829
- })),
8830
- value: tab.id,
8831
- tabIndex: activeTab === tab.id ? 0 : -1,
8832
- 'aria-controls': `tabpanel-${tab.id}`,
8833
- 'aria-selected': activeTab === tab.id,
8834
- onFocus: () => this.handleChange(null, tab.id),
8835
- onKeyDown: event => this.handleKeyDown(event, tab.id),
8836
- __self: this,
8837
- __source: {
8838
- fileName: _jsxFileName,
8839
- lineNumber: 196
8840
- }
8841
- }))), tabs.map(tab => activeTab === tab.id ? React$1.createElement('div', {
8842
- className: classes.tabContainer,
8843
- key: tab.id,
8844
- id: `tabpanel-${tab.id}`,
8845
- role: "tabpanel",
8846
- 'aria-labelledby': `button-${tab.id}`,
8847
- __self: this,
8848
- __source: {
8849
- fileName: _jsxFileName,
8850
- lineNumber: 217
8851
- }
8852
- }, this.renderInstructions(showTeacherInstructions, tab.teacherInstructions), React$1.createElement(Purpose, {
8853
- purpose: "passage-text",
8854
- __self: this,
8855
- __source: {
8856
- fileName: _jsxFileName,
8857
- lineNumber: 226
8858
- }
8859
- }, React$1.createElement('div', {
8860
- key: tab.id,
8861
- dangerouslySetInnerHTML: {
8862
- __html: this.parsedText(tab.text)
8863
- },
8864
- __self: this,
8865
- __source: {
8866
- fileName: _jsxFileName,
8867
- lineNumber: 227
8868
- }
8869
- }))) : null));
8870
- } else if (tabs && tabs[0]) {
8871
- return React$1.createElement(React$1.Fragment, null, this.renderInstructions(showTeacherInstructions, tabs[0].teacherInstructions, disabledTabs), React$1.createElement('div', {
8872
- className: classNames(classes.root, classes.tabContainer, classes.breakSpaces, 'passage'),
8873
- __self: this,
8874
- __source: {
8875
- fileName: _jsxFileName,
8876
- lineNumber: 238
8877
- }
8878
- }, React$1.createElement('div', {
8879
- className: "text",
8880
- dangerouslySetInnerHTML: {
8881
- __html: this.parsedText(tabs[0].text)
8882
- },
8883
- __self: this,
8884
- __source: {
8885
- fileName: _jsxFileName,
8886
- lineNumber: 239
8853
+ lineNumber: 218
8887
8854
  }
8888
- })));
8889
- }
8855
+ }),
8856
+ value: tab.id,
8857
+ tabIndex: activeTab === tab.id ? 0 : -1,
8858
+ 'aria-controls': `tabpanel-${tab.id}`,
8859
+ 'aria-selected': activeTab === tab.id,
8860
+ onFocus: () => this.handleChange(null, tab.id),
8861
+ onKeyDown: event => this.handleKeyDown(event, tab.id),
8862
+ __self: this,
8863
+ __source: {
8864
+ fileName: _jsxFileName,
8865
+ lineNumber: 214
8866
+ }
8867
+ }))), selectedTab ? this.renderTab(selectedTab, showTeacherInstructions, disabledTabs) : null));
8890
8868
  }
8891
8869
  }
8892
8870
  StimulusTabs.propTypes = {
@@ -8894,6 +8872,8 @@ StimulusTabs.propTypes = {
8894
8872
  tabs: PropTypes.arrayOf(PropTypes.shape({
8895
8873
  id: PropTypes.number.isRequired,
8896
8874
  title: PropTypes.string.isRequired,
8875
+ subtitle: PropTypes.string,
8876
+ author: PropTypes.string,
8897
8877
  text: PropTypes.string.isRequired,
8898
8878
  teacherInstructions: PropTypes.string
8899
8879
  }).isRequired).isRequired,
@@ -8925,17 +8905,17 @@ class PiePassage extends HTMLElement {
8925
8905
  this._render();
8926
8906
  }
8927
8907
  _render() {
8928
- const {showTeacherInstructions = false} = this._model;
8908
+ const {passages = [], showTeacherInstructions = false} = this._model;
8929
8909
  if (this._model.passages.length > 0) {
8930
- const passagesTabs = this._model.passages.map((passage, index) => {
8931
- return {
8932
- id: index,
8933
- title: passage.title,
8934
- text: passage.text,
8935
- teacherInstructions: passage.teacherInstructions || ''
8936
- };
8937
- });
8938
- let elem = React.createElement(StimulusTabs$1, {
8910
+ const passagesTabs = passages.map((passage, index) => ({
8911
+ id: index,
8912
+ title: passage.title,
8913
+ subtitle: passage.subtitle,
8914
+ author: passage.author,
8915
+ text: passage.text,
8916
+ teacherInstructions: passage.teacherInstructions || ''
8917
+ }));
8918
+ const elem = React.createElement(StimulusTabs$1, {
8939
8919
  tabs: passagesTabs,
8940
8920
  showTeacherInstructions
8941
8921
  });
@@ -7,28 +7,30 @@ generate.model = (id, element) => ({
7
7
  element,
8
8
  passages: [
9
9
  {
10
- teacherInstructions: 'Teacher instructions tab 1',
10
+ teacherInstructions: 'Teacher instructions for first tab',
11
11
  title: 'Hope Is the Thing with Feathers',
12
- 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><p><span class="no-number">&#34;Hope is the Thing With Feathers&#34; by Emily Dickinson, from <em>The Complete Poems of Emily Dickinson</em>. In the public domain.</span></p>',
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>',
13
15
  },
14
16
  {
15
17
  title: 'Ineskeen Road, July Evening',
16
- text: `The bicycles go by in twos and threes -<br/>
17
- There's a dance in Billy Brennan's barn tonight,<br/>
18
- And there's the half-talk code of mysteries<br/>
19
- And the wink-and-elbow language of delight.<br/>
20
- Half-past eight and there is not a spot<br/>
21
- Upon a mile of road, no shadow thrown<br/>
22
- That might turn out a man or woman, not<br/>
23
- A footfall tapping secrecies of stone. <br/>
24
- <p/>
25
- I have what every poet hates in spite<br/>
26
- Of all the solemn talk of contemplation.<br/>
27
- Oh, Alexander Selkirk knew the plight<br/>
28
- Of being king and government and nation.<br/>
29
- A road, a mile of kingdom. I am king<br/>
30
- Of banks and stones and every blooming thing.<br/>
31
- `,
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
+ `,
32
34
  },
33
35
  ],
34
36
  });