@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.
- package/CHANGELOG.md +7 -0
- package/css/components.css +5 -0
- package/dist/demo/components.css +15 -1
- package/dist/demo/pb-view2.html +135 -136
- package/dist/pb-component-docs.js +40 -40
- package/dist/pb-components-bundle.js +261 -261
- package/dist/pb-elements.json +93 -93
- package/dist/{pb-message-c4cd7861.js → pb-message-fbc1b645.js} +25 -26
- package/dist/pb-odd-editor.js +1 -1
- package/package.json +1 -1
- package/pb-elements.json +93 -93
- package/src/assets/components.css +5 -0
- package/src/pb-browse-docs.js +520 -519
- package/src/pb-clipboard.js +75 -74
- package/src/pb-collapse.js +183 -182
- package/src/pb-page.js +7 -4
- package/src/pb-table-grid.js +2 -2
- package/src/pb-view.js +1366 -1368
- package/src/theming.js +51 -16
package/src/pb-clipboard.js
CHANGED
|
@@ -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
|
|
5
|
-
import '@polymer/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
font-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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);
|
package/src/pb-collapse.js
CHANGED
|
@@ -1,183 +1,184 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
3
|
-
import
|
|
4
|
-
import '@polymer/iron-
|
|
5
|
-
import '@polymer/iron-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @slot collapse-
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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 {
|
|
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
|
-
|
|
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) {
|
package/src/pb-table-grid.js
CHANGED
|
@@ -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 {
|
|
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
|
|
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) {
|