@teipublisher/pb-components 2.25.4 → 2.25.6

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.
Files changed (130) hide show
  1. package/.github/workflows/main.yml +3 -3
  2. package/.github/workflows/node.js.yml +3 -3
  3. package/.github/workflows/release.js.yml +4 -4
  4. package/.releaserc.json +1 -1
  5. package/CHANGELOG.md +15 -0
  6. package/Dockerfile +78 -70
  7. package/css/components.css +5 -5
  8. package/dist/demo/pb-drawer2.html +1 -1
  9. package/dist/demo/pb-leaflet-map.html +1 -1
  10. package/dist/demo/pb-repeat.html +1 -3
  11. package/dist/demo/pb-view3.html +1 -1
  12. package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
  13. package/dist/pb-code-editor.js +25 -20
  14. package/dist/pb-component-docs.js +58 -54
  15. package/dist/pb-components-bundle.js +1827 -1520
  16. package/dist/pb-edit-app.js +167 -107
  17. package/dist/pb-elements.json +54 -54
  18. package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
  19. package/dist/pb-leaflet-map.js +23 -23
  20. package/dist/pb-mei.js +56 -41
  21. package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
  22. package/dist/pb-odd-editor.js +925 -758
  23. package/dist/pb-tify.js +2 -2
  24. package/dist/{vaadin-element-mixin-859a0132.js → vaadin-element-mixin-ad07ba25.js} +88 -61
  25. package/gh-pages.js +5 -3
  26. package/i18n/common/pl.json +2 -2
  27. package/package.json +2 -2
  28. package/pb-elements.json +54 -54
  29. package/src/assets/components.css +5 -5
  30. package/src/authority/airtable.js +20 -21
  31. package/src/authority/anton.js +129 -129
  32. package/src/authority/custom.js +23 -21
  33. package/src/authority/geonames.js +38 -32
  34. package/src/authority/gnd.js +47 -42
  35. package/src/authority/kbga.js +137 -134
  36. package/src/authority/metagrid.js +44 -46
  37. package/src/authority/reconciliation.js +66 -67
  38. package/src/authority/registry.js +4 -4
  39. package/src/docs/pb-component-docs.js +2 -2
  40. package/src/docs/pb-component-view.js +5 -5
  41. package/src/docs/pb-components-list.js +2 -2
  42. package/src/docs/pb-demo-snippet.js +2 -2
  43. package/src/dts-client.js +299 -297
  44. package/src/dts-select-endpoint.js +90 -82
  45. package/src/parse-date-service.js +184 -135
  46. package/src/pb-ajax.js +171 -167
  47. package/src/pb-authority-lookup.js +96 -81
  48. package/src/pb-autocomplete.js +292 -280
  49. package/src/pb-blacklab-highlight.js +264 -259
  50. package/src/pb-blacklab-results.js +236 -221
  51. package/src/pb-browse-docs.js +540 -475
  52. package/src/pb-browse.js +68 -65
  53. package/src/pb-clipboard.js +79 -76
  54. package/src/pb-code-editor.js +110 -102
  55. package/src/pb-code-highlight.js +209 -204
  56. package/src/pb-codepen.js +79 -72
  57. package/src/pb-collapse.js +149 -146
  58. package/src/pb-combo-box.js +190 -190
  59. package/src/pb-components-bundle.js +1 -1
  60. package/src/pb-custom-form.js +150 -149
  61. package/src/pb-document.js +89 -90
  62. package/src/pb-download.js +208 -195
  63. package/src/pb-drawer.js +145 -148
  64. package/src/pb-edit-app.js +301 -229
  65. package/src/pb-edit-xml.js +99 -96
  66. package/src/pb-events.js +114 -107
  67. package/src/pb-facs-link.js +104 -102
  68. package/src/pb-facsimile.js +411 -413
  69. package/src/pb-formula.js +151 -153
  70. package/src/pb-geolocation.js +129 -131
  71. package/src/pb-grid-action.js +53 -56
  72. package/src/pb-grid.js +231 -228
  73. package/src/pb-highlight.js +140 -140
  74. package/src/pb-hotkeys.js +40 -42
  75. package/src/pb-i18n.js +101 -104
  76. package/src/pb-image-strip.js +84 -78
  77. package/src/pb-lang.js +83 -70
  78. package/src/pb-leaflet-map.js +488 -485
  79. package/src/pb-link.js +126 -124
  80. package/src/pb-load.js +431 -426
  81. package/src/pb-login.js +275 -254
  82. package/src/pb-manage-odds.js +364 -318
  83. package/src/pb-map-icon.js +89 -89
  84. package/src/pb-map-layer.js +85 -85
  85. package/src/pb-markdown.js +90 -99
  86. package/src/pb-media-query.js +74 -72
  87. package/src/pb-mei.js +306 -295
  88. package/src/pb-message.js +143 -130
  89. package/src/pb-mixin.js +269 -264
  90. package/src/pb-navigation.js +80 -82
  91. package/src/pb-observable.js +38 -38
  92. package/src/pb-odd-editor.js +1056 -958
  93. package/src/pb-odd-elementspec-editor.js +348 -297
  94. package/src/pb-odd-model-editor.js +1058 -898
  95. package/src/pb-odd-parameter-editor.js +200 -178
  96. package/src/pb-odd-rendition-editor.js +136 -124
  97. package/src/pb-page.js +432 -422
  98. package/src/pb-paginate.js +202 -190
  99. package/src/pb-panel.js +191 -179
  100. package/src/pb-popover-themes.js +7 -5
  101. package/src/pb-popover.js +296 -287
  102. package/src/pb-print-preview.js +127 -127
  103. package/src/pb-progress.js +49 -49
  104. package/src/pb-repeat.js +105 -104
  105. package/src/pb-restricted.js +84 -77
  106. package/src/pb-search.js +238 -221
  107. package/src/pb-select-feature.js +127 -120
  108. package/src/pb-select-odd.js +132 -124
  109. package/src/pb-select-template.js +89 -78
  110. package/src/pb-select.js +251 -227
  111. package/src/pb-split-list.js +179 -174
  112. package/src/pb-svg.js +80 -79
  113. package/src/pb-table-column.js +54 -54
  114. package/src/pb-table-grid.js +221 -203
  115. package/src/pb-tabs.js +61 -63
  116. package/src/pb-tify.js +154 -154
  117. package/src/pb-timeline.js +271 -229
  118. package/src/pb-toggle-feature.js +198 -185
  119. package/src/pb-upload.js +184 -174
  120. package/src/pb-version.js +30 -30
  121. package/src/pb-view-annotate.js +132 -98
  122. package/src/pb-view.js +1282 -1263
  123. package/src/pb-zoom.js +40 -40
  124. package/src/polymer-hack.js +1 -1
  125. package/src/search-result-service.js +256 -223
  126. package/src/seed-element.js +13 -20
  127. package/src/settings.js +4 -4
  128. package/src/theming.js +91 -91
  129. package/src/urls.js +289 -289
  130. package/src/utils.js +53 -51
package/src/pb-mixin.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { cmpVersion } from './utils.js';
2
2
 
3
3
  if (!window.TeiPublisher) {
4
- window.TeiPublisher = {};
4
+ window.TeiPublisher = {};
5
5
 
6
- TeiPublisher.url = new URL(window.location.href);
6
+ TeiPublisher.url = new URL(window.location.href);
7
7
  }
8
8
 
9
9
  /**
@@ -21,7 +21,7 @@ const initEventsFired = new Map();
21
21
  export const defaultChannel = '__default__';
22
22
 
23
23
  export function clearPageEvents() {
24
- initEventsFired.clear();
24
+ initEventsFired.clear();
25
25
  }
26
26
 
27
27
  /**
@@ -33,16 +33,20 @@ export function clearPageEvents() {
33
33
  * @param {Function} callback
34
34
  */
35
35
  export function waitOnce(name, callback) {
36
- if (initEventsFired.has(name)) {
37
- callback(initEventsFired.get(name));
38
- } else {
39
- document.addEventListener(name, (ev) => {
40
- initEventsFired.set(name, ev.detail);
41
- callback(ev.detail);
42
- }, {
43
- once: true
44
- });
45
- }
36
+ if (initEventsFired.has(name)) {
37
+ callback(initEventsFired.get(name));
38
+ } else {
39
+ document.addEventListener(
40
+ name,
41
+ ev => {
42
+ initEventsFired.set(name, ev.detail);
43
+ callback(ev.detail);
44
+ },
45
+ {
46
+ once: true,
47
+ },
48
+ );
49
+ }
46
50
  }
47
51
 
48
52
  /**
@@ -52,18 +56,18 @@ export function waitOnce(name, callback) {
52
56
  * @returns {String[]} an array of channel names
53
57
  */
54
58
  export function getEmittedChannels(elem) {
55
- const emitConfig = elem.getAttribute('emit-config');
56
- if (emitConfig) {
57
- const json = JSON.parse(emitConfig);
58
- return Object.keys(json);
59
- }
60
-
61
- const emitAttr = elem.getAttribute('emit');
62
- if (emitAttr) {
63
- return [emitAttr]
64
- }
65
-
66
- return [defaultChannel];
59
+ const emitConfig = elem.getAttribute('emit-config');
60
+ if (emitConfig) {
61
+ const json = JSON.parse(emitConfig);
62
+ return Object.keys(json);
63
+ }
64
+
65
+ const emitAttr = elem.getAttribute('emit');
66
+ if (emitAttr) {
67
+ return [emitAttr];
68
+ }
69
+
70
+ return [defaultChannel];
67
71
  }
68
72
 
69
73
  /**
@@ -73,16 +77,16 @@ export function getEmittedChannels(elem) {
73
77
  * @returns {String[]} an array of channel names
74
78
  */
75
79
  export function getSubscribedChannels(elem) {
76
- const subscribeConfig = elem.getAttribute('subscribe-config');
77
- if (subscribeConfig) {
78
- const json = JSON.parse(subscribeConfig);
79
- return Object.keys(json);
80
- }
81
- const subscribeAttr = elem.getAttribute('subscribe');
82
- if (subscribeAttr) {
83
- return [subscribeAttr];
84
- }
85
- return [defaultChannel];
80
+ const subscribeConfig = elem.getAttribute('subscribe-config');
81
+ if (subscribeConfig) {
82
+ const json = JSON.parse(subscribeConfig);
83
+ return Object.keys(json);
84
+ }
85
+ const subscribeAttr = elem.getAttribute('subscribe');
86
+ if (subscribeAttr) {
87
+ return [subscribeAttr];
88
+ }
89
+ return [defaultChannel];
86
90
  }
87
91
 
88
92
  /**
@@ -100,93 +104,93 @@ export function getSubscribedChannels(elem) {
100
104
  * @polymer
101
105
  * @mixinFunction
102
106
  */
103
- export const pbMixin = (superclass) => class PbMixin extends superclass {
104
-
107
+ export const pbMixin = superclass =>
108
+ class PbMixin extends superclass {
105
109
  static get properties() {
106
- return {
107
- /**
108
- * The name of the channel to subscribe to. Only events on a channel corresponding
109
- * to this property are listened to.
110
- */
111
- subscribe: {
112
- type: String
113
- },
114
- /**
115
- * Configuration object to define a channel/event mapping. Every property
116
- * in the object is interpreted as the name of a channel and its value should
117
- * be an array of event names to listen to.
118
- */
119
- subscribeConfig: {
120
- type: Object,
121
- attribute: 'subscribe-config'
122
- },
123
- /**
124
- * The name of the channel to send events to.
125
- */
126
- emit: {
127
- type: String
128
- },
129
- /**
130
- * Configuration object to define a channel/event mapping. Every property
131
- * in the object is interpreted as the name of a channel and its value should
132
- * be an array of event names to be dispatched.
133
- */
134
- emitConfig: {
135
- type: Object,
136
- attribute: 'emit-config'
137
- },
138
- /**
139
- * A selector pointing to other components this component depends on.
140
- * When method `wait` is called, it will wait until all referenced
141
- * components signal with a `pb-ready` event that they are ready and listening
142
- * to events.
143
- */
144
- waitFor: {
145
- type: String,
146
- attribute: 'wait-for'
147
- },
148
- _isReady: {
149
- type: Boolean
150
- },
151
- /**
152
- * Common property to disable the functionality associated with a component.
153
- * `pb-highlight` and `pb-popover` react to this.
154
- */
155
- disabled: {
156
- type: Boolean,
157
- reflect: true
158
- },
159
- _endpoint: {
160
- type: String
161
- },
162
- _apiVersion: {
163
- type: String
164
- }
165
- }
110
+ return {
111
+ /**
112
+ * The name of the channel to subscribe to. Only events on a channel corresponding
113
+ * to this property are listened to.
114
+ */
115
+ subscribe: {
116
+ type: String,
117
+ },
118
+ /**
119
+ * Configuration object to define a channel/event mapping. Every property
120
+ * in the object is interpreted as the name of a channel and its value should
121
+ * be an array of event names to listen to.
122
+ */
123
+ subscribeConfig: {
124
+ type: Object,
125
+ attribute: 'subscribe-config',
126
+ },
127
+ /**
128
+ * The name of the channel to send events to.
129
+ */
130
+ emit: {
131
+ type: String,
132
+ },
133
+ /**
134
+ * Configuration object to define a channel/event mapping. Every property
135
+ * in the object is interpreted as the name of a channel and its value should
136
+ * be an array of event names to be dispatched.
137
+ */
138
+ emitConfig: {
139
+ type: Object,
140
+ attribute: 'emit-config',
141
+ },
142
+ /**
143
+ * A selector pointing to other components this component depends on.
144
+ * When method `wait` is called, it will wait until all referenced
145
+ * components signal with a `pb-ready` event that they are ready and listening
146
+ * to events.
147
+ */
148
+ waitFor: {
149
+ type: String,
150
+ attribute: 'wait-for',
151
+ },
152
+ _isReady: {
153
+ type: Boolean,
154
+ },
155
+ /**
156
+ * Common property to disable the functionality associated with a component.
157
+ * `pb-highlight` and `pb-popover` react to this.
158
+ */
159
+ disabled: {
160
+ type: Boolean,
161
+ reflect: true,
162
+ },
163
+ _endpoint: {
164
+ type: String,
165
+ },
166
+ _apiVersion: {
167
+ type: String,
168
+ },
169
+ };
166
170
  }
167
171
 
168
172
  constructor() {
169
- super();
170
- this._isReady = false;
171
- this.disabled = false;
172
- this._subscriptions = new Map();
173
+ super();
174
+ this._isReady = false;
175
+ this.disabled = false;
176
+ this._subscriptions = new Map();
173
177
  }
174
178
 
175
179
  connectedCallback() {
176
- super.connectedCallback();
177
- waitOnce('pb-page-ready', (options) => {
178
- this._endpoint = options.endpoint;
179
- this._apiVersion = options.apiVersion;
180
- });
180
+ super.connectedCallback();
181
+ waitOnce('pb-page-ready', options => {
182
+ this._endpoint = options.endpoint;
183
+ this._apiVersion = options.apiVersion;
184
+ });
181
185
  }
182
186
 
183
187
  disconnectedCallback() {
184
- super.disconnectedCallback();
185
- this._subscriptions.forEach((handlers, type) => {
186
- handlers.forEach((handler) => {
187
- document.removeEventListener(type, handler);
188
- });
188
+ super.disconnectedCallback();
189
+ this._subscriptions.forEach((handlers, type) => {
190
+ handlers.forEach(handler => {
191
+ document.removeEventListener(type, handler);
189
192
  });
193
+ });
190
194
  }
191
195
 
192
196
  /**
@@ -200,9 +204,9 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
200
204
  * @param {Boolean} state the state to set the setting to
201
205
  */
202
206
  command(command, state) {
203
- if (command === 'disable') {
204
- this.disabled = state;
205
- }
207
+ if (command === 'disable') {
208
+ this.disabled = state;
209
+ }
206
210
  }
207
211
 
208
212
  /**
@@ -213,49 +217,49 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
213
217
  * @param {Function} callback function to be called when all components are ready
214
218
  */
215
219
  wait(callback) {
216
- const _checkAndWait = () => {
217
- const targetNodes = Array.from(document.querySelectorAll(this.waitFor));
218
- const targets = targetNodes.filter(target => this.emitsOnSameChannel(target));
219
- const targetCount = targets.length;
220
- if (targetCount === 0) {
221
- // selector did not return any targets
222
- callback();
223
- return;
224
- }
225
- let count = targetCount;
226
- targets.forEach((target) => {
227
- if (target._isReady) {
228
- count -= 1;
229
- if (count === 0) {
230
- callback();
231
- }
232
- return;
233
- }
234
- const handler = target.addEventListener('pb-ready', (ev) => {
235
- if (ev.detail.source === this) {
236
- // same source: ignore
237
- return;
238
- }
239
- count -= 1;
240
- if (count === 0) {
241
- target.removeEventListener('pb-ready', handler);
242
- callback();
243
- }
244
- });
245
- });
220
+ const _checkAndWait = () => {
221
+ const targetNodes = Array.from(document.querySelectorAll(this.waitFor));
222
+ const targets = targetNodes.filter(target => this.emitsOnSameChannel(target));
223
+ const targetCount = targets.length;
224
+ if (targetCount === 0) {
225
+ // selector did not return any targets
226
+ callback();
227
+ return;
246
228
  }
247
-
248
- if (!this.waitFor) {
249
- callback();
229
+ let count = targetCount;
230
+ targets.forEach(target => {
231
+ if (target._isReady) {
232
+ count -= 1;
233
+ if (count === 0) {
234
+ callback();
235
+ }
250
236
  return;
251
- }
252
- if (document.readyState === 'loading') {
253
- document.addEventListener('DOMContentLoaded', () => {
254
- _checkAndWait();
255
- });
256
- } else {
257
- _checkAndWait();
258
- }
237
+ }
238
+ const handler = target.addEventListener('pb-ready', ev => {
239
+ if (ev.detail.source === this) {
240
+ // same source: ignore
241
+ return;
242
+ }
243
+ count -= 1;
244
+ if (count === 0) {
245
+ target.removeEventListener('pb-ready', handler);
246
+ callback();
247
+ }
248
+ });
249
+ });
250
+ };
251
+
252
+ if (!this.waitFor) {
253
+ callback();
254
+ return;
255
+ }
256
+ if (document.readyState === 'loading') {
257
+ document.addEventListener('DOMContentLoaded', () => {
258
+ _checkAndWait();
259
+ });
260
+ } else {
261
+ _checkAndWait();
262
+ }
259
263
  }
260
264
 
261
265
  /**
@@ -266,29 +270,29 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
266
270
  * @param callback function to be called when `pb-ready` is received
267
271
  */
268
272
  waitForChannel(callback) {
269
- // check first if a `pb-ready` event has already been received on one of the channels
270
- if (this.subscribeConfig) {
271
- for (const key in this.subscribeConfig) {
272
- this.subscribeConfig[key].forEach(t => {
273
- if (t === 'pb-ready' && readyEventsFired.has(key)) {
274
- return callback();
275
- }
276
- });
273
+ // check first if a `pb-ready` event has already been received on one of the channels
274
+ if (this.subscribeConfig) {
275
+ for (const key in this.subscribeConfig) {
276
+ this.subscribeConfig[key].forEach(t => {
277
+ if (t === 'pb-ready' && readyEventsFired.has(key)) {
278
+ return callback();
277
279
  }
278
- } else if (
279
- (this.subscribe && readyEventsFired.has(this.subscribe)) ||
280
- (!this.subscribe && readyEventsFired.has('__default__'))
281
- ) {
282
- return callback();
280
+ });
283
281
  }
284
-
285
- const listeners = this.subscribeTo('pb-ready', (ev) => {
286
- if (ev.detail._source == this) {
287
- return;
288
- }
289
- listeners.forEach(listener => document.removeEventListener('pb-ready', listener));
290
- callback();
291
- });
282
+ } else if (
283
+ (this.subscribe && readyEventsFired.has(this.subscribe)) ||
284
+ (!this.subscribe && readyEventsFired.has('__default__'))
285
+ ) {
286
+ return callback();
287
+ }
288
+
289
+ const listeners = this.subscribeTo('pb-ready', ev => {
290
+ if (ev.detail._source == this) {
291
+ return;
292
+ }
293
+ listeners.forEach(listener => document.removeEventListener('pb-ready', listener));
294
+ callback();
295
+ });
292
296
  }
293
297
 
294
298
  /**
@@ -301,7 +305,7 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
301
305
  * @deprecated Use exported `waitOnce` function
302
306
  */
303
307
  static waitOnce(name, callback) {
304
- waitOnce(name, callback);
308
+ waitOnce(name, callback);
305
309
  }
306
310
 
307
311
  /**
@@ -309,10 +313,10 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
309
313
  * Emits an event to all channels the component is registered with.
310
314
  */
311
315
  signalReady(name = 'pb-ready', data) {
312
- this._isReady = true;
313
- initEventsFired.set(name, data);
314
- this.dispatchEvent(new CustomEvent(name, { detail: { data, source: this } }));
315
- this.emitTo(name, data);
316
+ this._isReady = true;
317
+ initEventsFired.set(name, data);
318
+ this.dispatchEvent(new CustomEvent(name, { detail: { data, source: this } }));
319
+ this.emitTo(name, data);
316
320
  }
317
321
 
318
322
  /**
@@ -322,13 +326,13 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
322
326
  * @param {Element} other the other element to compare with
323
327
  */
324
328
  emitsOnSameChannel(other) {
325
- const myChannels = getSubscribedChannels(this);
326
- const otherChannels = getEmittedChannels(other);
327
- if (myChannels.length === 0 && otherChannels.length === 0) {
328
- // both emit to the default channel
329
- return true;
330
- }
331
- return myChannels.some((channel) => otherChannels.includes(channel));
329
+ const myChannels = getSubscribedChannels(this);
330
+ const otherChannels = getEmittedChannels(other);
331
+ if (myChannels.length === 0 && otherChannels.length === 0) {
332
+ // both emit to the default channel
333
+ return true;
334
+ }
335
+ return myChannels.some(channel => otherChannels.includes(channel));
332
336
  }
333
337
 
334
338
  /**
@@ -342,25 +346,25 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
342
346
  * the emit property. Pass empty array to target the default channel.
343
347
  */
344
348
  subscribeTo(type, listener, channels) {
345
- let chs;
346
- if (channels) {
347
- chs = channels.length === 0 ? [defaultChannel] : channels;
348
- } else {
349
- chs = getSubscribedChannels(this);
350
- }
351
- const handlers = chs.map(key => {
352
- const handle = ev => {
353
- if (!ev.detail || !ev.detail.key || ev.detail.key !== key) {
354
- return;
355
- }
356
- listener(ev);
357
- };
358
- document.addEventListener(type, handle);
359
- return handle;
360
- });
361
- // add new handlers to list of active subscriptions
362
- this._subscriptions.set(type, handlers);
363
- return handlers;
349
+ let chs;
350
+ if (channels) {
351
+ chs = channels.length === 0 ? [defaultChannel] : channels;
352
+ } else {
353
+ chs = getSubscribedChannels(this);
354
+ }
355
+ const handlers = chs.map(key => {
356
+ const handle = ev => {
357
+ if (!ev.detail || !ev.detail.key || ev.detail.key !== key) {
358
+ return;
359
+ }
360
+ listener(ev);
361
+ };
362
+ document.addEventListener(type, handle);
363
+ return handle;
364
+ });
365
+ // add new handlers to list of active subscriptions
366
+ this._subscriptions.set(type, handlers);
367
+ return handlers;
364
368
  }
365
369
 
366
370
  /**
@@ -373,28 +377,28 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
373
377
  * the 'emit' property setting. Pass empty array to target the default channel.
374
378
  */
375
379
  emitTo(type, options, channels) {
376
- let chs;
377
- if (channels) {
378
- chs = channels.length === 0 ? [defaultChannel] : channels;
379
- } else {
380
- chs = getEmittedChannels(this);
381
- }
382
- chs.forEach(ch => this._emit(ch, type, options));
380
+ let chs;
381
+ if (channels) {
382
+ chs = channels.length === 0 ? [defaultChannel] : channels;
383
+ } else {
384
+ chs = getEmittedChannels(this);
385
+ }
386
+ chs.forEach(ch => this._emit(ch, type, options));
383
387
  }
384
388
 
385
389
  _emit(key, type, options) {
386
- if (type === 'pb-ready') {
387
- readyEventsFired.add(key);
388
- }
389
-
390
- // eslint-disable-next-line prefer-object-spread
391
- const detail = Object.assign({ key, _source: this }, options);
392
- const ev = new CustomEvent(type, {
393
- detail,
394
- composed: true,
395
- bubbles: true
396
- });
397
- this.dispatchEvent(ev);
390
+ if (type === 'pb-ready') {
391
+ readyEventsFired.add(key);
392
+ }
393
+
394
+ // eslint-disable-next-line prefer-object-spread
395
+ const detail = Object.assign({ key, _source: this }, options);
396
+ const ev = new CustomEvent(type, {
397
+ detail,
398
+ composed: true,
399
+ bubbles: true,
400
+ });
401
+ this.dispatchEvent(ev);
398
402
  }
399
403
 
400
404
  /**
@@ -403,67 +407,68 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
403
407
  * @returns the document component or undefined if not set/found
404
408
  */
405
409
  getDocument() {
406
- if (this.src) {
407
- const doc = document.getElementById(this.src);
408
- if (doc) {
409
- return doc;
410
- }
410
+ if (this.src) {
411
+ const doc = document.getElementById(this.src);
412
+ if (doc) {
413
+ return doc;
411
414
  }
412
- return null;
415
+ }
416
+ return null;
413
417
  }
414
418
 
415
419
  getParameter(name, fallback) {
416
- const params = TeiPublisher.url.searchParams && TeiPublisher.url.searchParams.getAll(name);
417
- if (params && params.length == 1) {
418
- return params[0];
419
- } else if (params && params.length > 1) {
420
- return params
421
- }
422
- return fallback;
420
+ const params = TeiPublisher.url.searchParams && TeiPublisher.url.searchParams.getAll(name);
421
+ if (params && params.length == 1) {
422
+ return params[0];
423
+ }
424
+ if (params && params.length > 1) {
425
+ return params;
426
+ }
427
+ return fallback;
423
428
  }
424
429
 
425
430
  getParameters() {
426
- const params = {};
427
- for (let key of TeiPublisher.url.searchParams.keys()) {
428
- params[key] = this.getParameter(key);
429
- }
430
- return params;
431
+ const params = {};
432
+ for (const key of TeiPublisher.url.searchParams.keys()) {
433
+ params[key] = this.getParameter(key);
434
+ }
435
+ return params;
431
436
  }
432
437
 
433
438
  getUrl() {
434
- return TeiPublisher.url;
439
+ return TeiPublisher.url;
435
440
  }
436
441
 
437
442
  getEndpoint() {
438
- return this._endpoint;
443
+ return this._endpoint;
439
444
  }
440
445
 
441
446
  toAbsoluteURL(relative, server) {
442
- if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(relative)) {
443
- return relative;
444
- }
445
- const endpoint = server === '' ? '' : (server || this.getEndpoint());
446
- let base;
447
- if (endpoint === '.') {
448
- base = new URL(window.location.href);
449
- // loaded in iframe
450
- } else if (window.location.protocol === 'about:') {
451
- base = document.baseURI
452
- } else {
453
- base = new URL(`${endpoint}/`, `${window.location.protocol}//${window.location.host}`);
454
- }
455
- return new URL(relative, base).href;
447
+ if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(relative)) {
448
+ return relative;
449
+ }
450
+ const endpoint = server === '' ? '' : server || this.getEndpoint();
451
+ let base;
452
+ if (endpoint === '.') {
453
+ base = new URL(window.location.href);
454
+ // loaded in iframe
455
+ } else if (window.location.protocol === 'about:') {
456
+ base = document.baseURI;
457
+ } else {
458
+ base = new URL(`${endpoint}/`, `${window.location.protocol}//${window.location.host}`);
459
+ }
460
+ return new URL(relative, base).href;
456
461
  }
457
462
 
458
463
  minApiVersion(requiredVersion) {
459
- return cmpVersion(this._apiVersion, requiredVersion) >= 0;
464
+ return cmpVersion(this._apiVersion, requiredVersion) >= 0;
460
465
  }
461
466
 
462
467
  lessThanApiVersion(requiredVersion) {
463
- return cmpVersion(this._apiVersion, requiredVersion) < 0;
468
+ return cmpVersion(this._apiVersion, requiredVersion) < 0;
464
469
  }
465
470
 
466
471
  compareApiVersion(requiredVersion) {
467
- return cmpVersion(this._apiVersion, requiredVersion);
472
+ return cmpVersion(this._apiVersion, requiredVersion);
468
473
  }
469
- }
474
+ };