@teipublisher/pb-components 1.42.7 → 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 +14 -0
- package/css/components.css +5 -0
- package/dist/demo/components.css +26 -0
- package/dist/demo/pb-code-highlight.html +63 -63
- package/dist/demo/pb-table-grid.html +16 -16
- package/dist/demo/pb-view2.html +135 -136
- package/dist/pb-code-editor.js +1 -1
- package/dist/pb-component-docs.js +40 -40
- package/dist/pb-components-bundle.js +261 -262
- package/dist/pb-edit-app.js +1 -1
- package/dist/pb-elements.json +703 -690
- package/dist/{pb-i18n-6ad23bcf.js → pb-i18n-dc551878.js} +1 -1
- package/dist/pb-leaflet-map.js +1 -1
- package/dist/{pb-message-0fb0b538.js → pb-message-fbc1b645.js} +25 -26
- package/dist/{pb-mixin-15ff531f.js → pb-mixin-f8b22e51.js} +1 -1
- package/dist/pb-odd-editor.js +1 -1
- package/package.json +1 -1
- package/pb-elements.json +703 -690
- 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-code-highlight.js +194 -193
- package/src/pb-collapse.js +183 -182
- package/src/pb-mixin.js +542 -529
- package/src/pb-page.js +399 -384
- package/src/pb-split-list.js +2 -1
- package/src/pb-table-grid.js +218 -211
- package/src/pb-view.js +1366 -1368
- package/src/theming.js +150 -0
- package/src/utils.js +50 -51
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);
|