@teipublisher/pb-components 1.43.0 → 1.43.1

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.
@@ -1,75 +1,76 @@
1
- import { LitElement, html, css } from 'lit-element';
2
- import { pbMixin } from './pb-mixin.js';
3
- import { translate } from "./pb-i18n.js";
4
- import '@polymer/paper-icon-button';
5
- import '@polymer/iron-icons';
6
-
7
- /**
8
- * A component with a button which copies the contained content to the clipboard.
9
- * Use for the typical 'quote this content as' hints on a webpage.
10
- *
11
- * @slot content - contains the actual content to copy to the clipboard
12
- */
13
- export class PbClipboard extends pbMixin(LitElement) {
14
- static get properties() {
15
- return {
16
- /**
17
- * Label to display above the text to be copied
18
- */
19
- label: {
20
- type: String
21
- },
22
- ...super.properties
23
- };
24
- }
25
-
26
- constructor() {
27
- super();
28
- this.label = 'clipboard.label';
29
- }
30
-
31
- render() {
32
- return html`
33
- <h3>${translate(this.label)}</h3>
34
- <div>
35
- <slot></slot>
36
- <paper-icon-button icon="icons:content-copy" @click="${this._copy}"
37
- title="${translate('clipboard.copy')}"></paper-icon-button>
38
- </div>
39
- `;
40
- }
41
-
42
- /**
43
- * Copy text content from the <slot> to the clipboard
44
- */
45
- _copy() {
46
- const slot = this.shadowRoot.querySelector('slot');
47
- // first import nodes from the slot into a temporary div
48
- const content = document.createElement('div');
49
- slot.assignedNodes().forEach((node) => {
50
- content.appendChild(document.importNode(node, true));
51
- });
52
- // copy the innerText of the temp div into the clipboard
53
- navigator.clipboard.writeText(content.innerText);
54
- }
55
-
56
- static get styles() {
57
- return css`
58
- :host {
59
- display: block;
60
- }
61
- h3 {
62
- margin: 0;
63
- font-size: .85em;
64
- font-weight: normal;
65
- color: #3a3a3a;
66
- }
67
- div {
68
- display: flex;
69
- align-items: center;
70
- padding: 0 16px;
71
- }
72
- `;
73
- }
74
- }
1
+ import { LitElement, html, css } from 'lit-element';
2
+ import { pbMixin } from './pb-mixin.js';
3
+ import { translate } from "./pb-i18n.js";
4
+ import { themableMixin } from "./theming.js";
5
+ import '@polymer/paper-icon-button';
6
+ import '@polymer/iron-icons';
7
+
8
+ /**
9
+ * A component with a button which copies the contained content to the clipboard.
10
+ * Use for the typical 'quote this content as' hints on a webpage.
11
+ *
12
+ * @slot content - contains the actual content to copy to the clipboard
13
+ */
14
+ export class PbClipboard extends themableMixin(pbMixin(LitElement)) {
15
+ static get properties() {
16
+ return {
17
+ /**
18
+ * Label to display above the text to be copied
19
+ */
20
+ label: {
21
+ type: String
22
+ },
23
+ ...super.properties
24
+ };
25
+ }
26
+
27
+ constructor() {
28
+ super();
29
+ this.label = 'clipboard.label';
30
+ }
31
+
32
+ render() {
33
+ return html`
34
+ <h3>${translate(this.label)}</h3>
35
+ <div>
36
+ <slot></slot>
37
+ <paper-icon-button icon="icons:content-copy" @click="${this._copy}"
38
+ title="${translate('clipboard.copy')}"></paper-icon-button>
39
+ </div>
40
+ `;
41
+ }
42
+
43
+ /**
44
+ * Copy text content from the <slot> to the clipboard
45
+ */
46
+ _copy() {
47
+ const slot = this.shadowRoot.querySelector('slot');
48
+ // first import nodes from the slot into a temporary div
49
+ const content = document.createElement('div');
50
+ slot.assignedNodes().forEach((node) => {
51
+ content.appendChild(document.importNode(node, true));
52
+ });
53
+ // copy the innerText of the temp div into the clipboard
54
+ navigator.clipboard.writeText(content.innerText);
55
+ }
56
+
57
+ static get styles() {
58
+ return css`
59
+ :host {
60
+ display: block;
61
+ }
62
+ h3 {
63
+ margin: 0;
64
+ font-size: .85em;
65
+ font-weight: normal;
66
+ color: #3a3a3a;
67
+ }
68
+ div {
69
+ display: flex;
70
+ align-items: center;
71
+ padding: 0 16px;
72
+ }
73
+ `;
74
+ }
75
+ }
75
76
  customElements.define('pb-clipboard', PbClipboard);
@@ -1,183 +1,184 @@
1
- import { LitElement, html, css } from 'lit-element';
2
- import { pbMixin } from './pb-mixin.js';
3
- import '@polymer/iron-icon';
4
- import '@polymer/iron-icons';
5
- import '@polymer/iron-collapse';
6
-
7
-
8
- /**
9
- * A collapsible block: in collapsed state it only shows a header and expands if clicked.
10
- * The header should go into slot `collapse-trigger`, the content into `collapse-content`.
11
- * Example:
12
- *
13
- * ```html
14
- * <pb-collapse>
15
- * <div slot="collapse-trigger">
16
- * Metadata
17
- * </div>
18
- * <pb-view slot="collapse-content" src="document1" subscribe="transcription" xpath="//teiHeader"></pb-view>
19
- * </pb-collapse>
20
- * ```
21
- *
22
- * @slot collapse-trigger - trigger toggling collapsed content on/off
23
- * @slot collapse-content - content to be collapsed
24
- * @cssprop [--pb-collapse-icon-padding=0 4px 0 0] - padding in px for the "caret-down" icon left to the collapsible item
25
- * @fires pb-collapse-open - Fires opening the collapsed section
26
- */
27
- export class PbCollapse extends pbMixin(LitElement) {
28
- static get properties() {
29
- return {
30
- ...super.properties,
31
- /**
32
- * @deprecated
33
- * Corresponds to the iron-collapse's horizontal property.
34
- */
35
- horizontal: {
36
- type: Boolean
37
- },
38
- /**
39
- * Corresponds to the iron-collapse's noAnimation property.
40
- *
41
- */
42
- noAnimation: {
43
- type: Boolean,
44
- attribute: 'no-animation'
45
- },
46
- /**
47
- * Whether currently expanded.
48
- *
49
- */
50
- opened: {
51
- type: Boolean
52
- },
53
- /**
54
- * By default, an open collapse is closed if another pb-collapse is expanded on the same event channel.
55
- * Set to true to keep multiple pb-collapse open at the same time.
56
- */
57
- toggles: {
58
- type: Boolean
59
- },
60
- /**
61
- * The iron-icon when collapsed. Value must be one of the icons defined by iron-icons
62
- */
63
- expandIcon: {
64
- type: String,
65
- attribute: 'expand-icon'
66
- },
67
- /**
68
- * The icon when expanded.
69
- */
70
- collapseIcon: {
71
- type: String,
72
- attribute: 'collapse-icon'
73
- },
74
- /**
75
- * Whether to hide the expand/collapse icon.
76
- */
77
- noIcons: {
78
- type: Boolean,
79
- attribute: 'no-icons'
80
- }
81
- };
82
- }
83
-
84
- constructor() {
85
- super();
86
- this.horizontal = false;
87
- this.noAnimation = false;
88
- this.opened = false;
89
- this.expandIcon = 'icons:expand-more';
90
- this.collapseIcon = 'icons:expand-less';
91
- this.noIcons = false;
92
- this.toggles = false;
93
- }
94
-
95
- connectedCallback() {
96
- super.connectedCallback();
97
- this.addEventListener('pb-collapse-open', () => {
98
- this.open();
99
- });
100
- if (this.toggles) {
101
- this.subscribeTo('pb-collapse-open', (ev) => {
102
- if (!ev.detail || ev.detail._source === this) {
103
- return;
104
- }
105
- for (const collapse of this.querySelectorAll('pb-collapse')) {
106
- if (collapse === ev.detail._source) {
107
- return;
108
- }
109
- }
110
- this.close();
111
- });
112
- }
113
- }
114
-
115
- /**
116
- * opens the collapsible section
117
- */
118
- open() {
119
- if (this.opened) {
120
- return;
121
- }
122
- this.opened = true;
123
-
124
- this.emitTo('pb-collapse-open', this);
125
- }
126
-
127
- /**
128
- * closes the collapsible section
129
- */
130
- close() {
131
- if (this.opened) {
132
- this.opened = false;
133
- }
134
- }
135
-
136
- /**
137
- * toggles the collapsible state
138
- */
139
- toggle() {
140
- this.opened = !this.opened;
141
- if (this.opened) {
142
- this.emitTo('pb-collapse-open', this.data);
143
- }
144
- }
145
-
146
- render() {
147
- return html`
148
- <div id="trigger" @click="${this.toggle}" class="collapse-trigger">
149
- ${
150
- !this.noIcons ?
151
- html`<iron-icon icon="${this.opened ? this.collapseIcon : this.expandIcon}"></iron-icon>` :
152
- null
153
- }
154
- <slot id="collapseTrigger" name="collapse-trigger"></slot>
155
- </div>
156
- <iron-collapse id="collapse" horizontal="${this.horizontal}" no-animation="${this.noAnimation}" .opened="${this.opened}">
157
- <slot name="collapse-content"></slot>
158
- </iron-collapse>
159
- `;
160
- }
161
-
162
- static get styles() {
163
- return css`
164
- :host {
165
- display: block;
166
- }
167
-
168
- #trigger {
169
- display: table-row;
170
- }
171
-
172
- #trigger iron-icon {
173
- display: table-cell;
174
- padding: var(--pb-collapse-icon-padding, 0 4px 0 0);
175
- }
176
-
177
- slot[name="collapse-trigger"] {
178
- display: table-cell;
179
- }
180
- `;
181
- }
182
- }
1
+ import { LitElement, html, css } from 'lit-element';
2
+ import { pbMixin } from './pb-mixin.js';
3
+ import { themableMixin } from "./theming.js";
4
+ import '@polymer/iron-icon';
5
+ import '@polymer/iron-icons';
6
+ import '@polymer/iron-collapse';
7
+
8
+
9
+ /**
10
+ * A collapsible block: in collapsed state it only shows a header and expands if clicked.
11
+ * The header should go into slot `collapse-trigger`, the content into `collapse-content`.
12
+ * Example:
13
+ *
14
+ * ```html
15
+ * <pb-collapse>
16
+ * <div slot="collapse-trigger">
17
+ * Metadata
18
+ * </div>
19
+ * <pb-view slot="collapse-content" src="document1" subscribe="transcription" xpath="//teiHeader"></pb-view>
20
+ * </pb-collapse>
21
+ * ```
22
+ *
23
+ * @slot collapse-trigger - trigger toggling collapsed content on/off
24
+ * @slot collapse-content - content to be collapsed
25
+ * @cssprop [--pb-collapse-icon-padding=0 4px 0 0] - padding in px for the "caret-down" icon left to the collapsible item
26
+ * @fires pb-collapse-open - Fires opening the collapsed section
27
+ */
28
+ export class PbCollapse extends themableMixin(pbMixin(LitElement)) {
29
+ static get properties() {
30
+ return {
31
+ ...super.properties,
32
+ /**
33
+ * @deprecated
34
+ * Corresponds to the iron-collapse's horizontal property.
35
+ */
36
+ horizontal: {
37
+ type: Boolean
38
+ },
39
+ /**
40
+ * Corresponds to the iron-collapse's noAnimation property.
41
+ *
42
+ */
43
+ noAnimation: {
44
+ type: Boolean,
45
+ attribute: 'no-animation'
46
+ },
47
+ /**
48
+ * Whether currently expanded.
49
+ *
50
+ */
51
+ opened: {
52
+ type: Boolean
53
+ },
54
+ /**
55
+ * By default, an open collapse is closed if another pb-collapse is expanded on the same event channel.
56
+ * Set to true to keep multiple pb-collapse open at the same time.
57
+ */
58
+ toggles: {
59
+ type: Boolean
60
+ },
61
+ /**
62
+ * The iron-icon when collapsed. Value must be one of the icons defined by iron-icons
63
+ */
64
+ expandIcon: {
65
+ type: String,
66
+ attribute: 'expand-icon'
67
+ },
68
+ /**
69
+ * The icon when expanded.
70
+ */
71
+ collapseIcon: {
72
+ type: String,
73
+ attribute: 'collapse-icon'
74
+ },
75
+ /**
76
+ * Whether to hide the expand/collapse icon.
77
+ */
78
+ noIcons: {
79
+ type: Boolean,
80
+ attribute: 'no-icons'
81
+ }
82
+ };
83
+ }
84
+
85
+ constructor() {
86
+ super();
87
+ this.horizontal = false;
88
+ this.noAnimation = false;
89
+ this.opened = false;
90
+ this.expandIcon = 'icons:expand-more';
91
+ this.collapseIcon = 'icons:expand-less';
92
+ this.noIcons = false;
93
+ this.toggles = false;
94
+ }
95
+
96
+ connectedCallback() {
97
+ super.connectedCallback();
98
+ this.addEventListener('pb-collapse-open', () => {
99
+ this.open();
100
+ });
101
+ if (this.toggles) {
102
+ this.subscribeTo('pb-collapse-open', (ev) => {
103
+ if (!ev.detail || ev.detail._source === this) {
104
+ return;
105
+ }
106
+ for (const collapse of this.querySelectorAll('pb-collapse')) {
107
+ if (collapse === ev.detail._source) {
108
+ return;
109
+ }
110
+ }
111
+ this.close();
112
+ });
113
+ }
114
+ }
115
+
116
+ /**
117
+ * opens the collapsible section
118
+ */
119
+ open() {
120
+ if (this.opened) {
121
+ return;
122
+ }
123
+ this.opened = true;
124
+
125
+ this.emitTo('pb-collapse-open', this);
126
+ }
127
+
128
+ /**
129
+ * closes the collapsible section
130
+ */
131
+ close() {
132
+ if (this.opened) {
133
+ this.opened = false;
134
+ }
135
+ }
136
+
137
+ /**
138
+ * toggles the collapsible state
139
+ */
140
+ toggle() {
141
+ this.opened = !this.opened;
142
+ if (this.opened) {
143
+ this.emitTo('pb-collapse-open', this.data);
144
+ }
145
+ }
146
+
147
+ render() {
148
+ return html`
149
+ <div id="trigger" @click="${this.toggle}" class="collapse-trigger">
150
+ ${
151
+ !this.noIcons ?
152
+ html`<iron-icon icon="${this.opened ? this.collapseIcon : this.expandIcon}"></iron-icon>` :
153
+ null
154
+ }
155
+ <slot id="collapseTrigger" name="collapse-trigger"></slot>
156
+ </div>
157
+ <iron-collapse id="collapse" horizontal="${this.horizontal}" no-animation="${this.noAnimation}" .opened="${this.opened}">
158
+ <slot name="collapse-content"></slot>
159
+ </iron-collapse>
160
+ `;
161
+ }
162
+
163
+ static get styles() {
164
+ return css`
165
+ :host {
166
+ display: block;
167
+ }
168
+
169
+ #trigger {
170
+ display: table-row;
171
+ }
172
+
173
+ #trigger iron-icon {
174
+ display: table-cell;
175
+ padding: var(--pb-collapse-icon-padding, 0 4px 0 0);
176
+ }
177
+
178
+ slot[name="collapse-trigger"] {
179
+ display: table-cell;
180
+ }
181
+ `;
182
+ }
183
+ }
183
184
  customElements.define('pb-collapse', PbCollapse);
package/src/pb-page.js CHANGED
@@ -5,7 +5,7 @@ import XHR from 'i18next-xhr-backend';
5
5
  import Backend from 'i18next-chained-backend';
6
6
  import { pbMixin, clearPageEvents } from './pb-mixin.js';
7
7
  import { resolveURL } from './utils.js';
8
- import { loadStylesheet } from "./theming.js";
8
+ import { loadStylesheets } from "./theming.js";
9
9
  import { initTranslation } from "./pb-i18n.js";
10
10
  import { typesetMath } from "./pb-formula.js";
11
11
 
@@ -196,11 +196,14 @@ export class PbPage extends pbMixin(LitElement) {
196
196
  this.apiVersion = apiVersion;
197
197
  }
198
198
 
199
+ const stylesheetURLs = [
200
+ resolveURL('../css/components.css')
201
+ ];
199
202
  if (this.theme) {
200
- const url = this.toAbsoluteURL(this.theme, this.endpoint);
201
- console.log('<pb-page> Loading component theme stylesheet from %s', url);
202
- this._themeSheet = await loadStylesheet(url);
203
+ stylesheetURLs.push(this.toAbsoluteURL(this.theme, this.endpoint));
203
204
  }
205
+ console.log('<pb-page> Loading component theme stylesheets from %s', stylesheetURLs.join(', '));
206
+ this._themeSheet = await loadStylesheets(stylesheetURLs);
204
207
 
205
208
  // try to figure out what version of TEI Publisher the server is running
206
209
  if (!this.apiVersion) {
@@ -2,7 +2,7 @@ import { LitElement, html, css } from 'lit-element';
2
2
  import { Grid } from "gridjs";
3
3
  import { pbMixin } from './pb-mixin.js';
4
4
  import { resolveURL } from './utils.js';
5
- import { loadStylesheet, importStyles } from "./theming.js";
5
+ import { loadStylesheets, importStyles } from "./theming.js";
6
6
  import '@polymer/paper-input/paper-input';
7
7
  import '@polymer/iron-icons';
8
8
  import '@polymer/iron-form';
@@ -114,7 +114,7 @@ export class PbTableGrid extends pbMixin(LitElement) {
114
114
  }
115
115
  }
116
116
 
117
- const gridjsTheme = await loadStylesheet(`${resolveURL(this.cssPath)}/mermaid.min.css`);
117
+ const gridjsTheme = await loadStylesheets([`${resolveURL(this.cssPath)}/mermaid.min.css`]);
118
118
  const theme = importStyles(this);
119
119
  const sheets = [...this.shadowRoot.adoptedStyleSheets, gridjsTheme];
120
120
  if (theme) {