@teipublisher/pb-components 2.26.1-next.3 → 3.0.0
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/.github/workflows/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +4 -4
- package/.releaserc.json +2 -2
- package/CHANGELOG.md +262 -11
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/css/leaflet/images/layers.png +0 -0
- package/dist/demo/components.css +46 -1
- package/dist/demo/pb-browse-docs2.html +1 -1
- package/dist/demo/pb-dialog.html +3 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-facsimile.html +2 -2
- package/dist/demo/pb-grid.html +19 -6
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-login.html +0 -2
- package/dist/demo/pb-message.html +1 -2
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-search.html +7 -4
- package/dist/demo/pb-search3.html +1 -1
- package/dist/demo/pb-search4.html +2 -2
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{iron-form-3b8dcaa7.js → iron-form-dfb3e3b1.js} +95 -95
- package/dist/paper-checkbox-645e1077.js +200 -0
- package/dist/{paper-icon-button-b1d31571.js → paper-icon-button-984162bd.js} +1 -1
- package/dist/{paper-checkbox-515a5284.js → paper-inky-focus-behavior-fa16796b.js} +58 -247
- package/dist/{paper-listbox-a3b7175c.js → paper-listbox-5f5d1cec.js} +152 -162
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +68 -64
- package/dist/pb-components-bundle.js +1983 -2293
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +176 -120
- package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +56 -41
- package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
- package/dist/pb-odd-editor.js +1023 -782
- package/dist/pb-tify.js +2 -2
- package/dist/vaadin-element-mixin-beb74ffd.js +545 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +6 -6
- package/package.json +3 -3
- package/pb-elements.json +176 -120
- package/src/assets/components.css +5 -5
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +23 -21
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +137 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -67
- package/src/authority/registry.js +4 -4
- package/src/docs/pb-component-docs.js +2 -2
- package/src/docs/pb-component-view.js +5 -5
- package/src/docs/pb-components-list.js +2 -2
- package/src/docs/pb-demo-snippet.js +2 -2
- package/src/dts-client.js +299 -297
- package/src/dts-select-endpoint.js +90 -82
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +158 -171
- package/src/pb-authority-lookup.js +191 -156
- package/src/pb-autocomplete.js +292 -280
- package/src/pb-blacklab-highlight.js +264 -259
- package/src/pb-blacklab-results.js +236 -221
- package/src/pb-browse-docs.js +540 -475
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +79 -76
- package/src/pb-code-editor.js +110 -102
- package/src/pb-code-highlight.js +209 -204
- package/src/pb-codepen.js +79 -72
- package/src/pb-collapse.js +211 -151
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-components.js +1 -0
- package/src/pb-custom-form.js +173 -153
- package/src/pb-dialog.js +98 -62
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +212 -196
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +100 -97
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +474 -410
- package/src/pb-formula.js +151 -153
- package/src/pb-geolocation.js +129 -131
- package/src/pb-grid-action.js +53 -56
- package/src/pb-grid.js +231 -228
- package/src/pb-highlight.js +140 -140
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +101 -104
- package/src/pb-image-strip.js +84 -78
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -429
- package/src/pb-login.js +299 -244
- package/src/pb-manage-odds.js +352 -336
- package/src/pb-map-icon.js +89 -89
- package/src/pb-map-layer.js +85 -85
- package/src/pb-markdown.js +90 -99
- package/src/pb-media-query.js +74 -72
- package/src/pb-mei.js +306 -295
- package/src/pb-message.js +139 -97
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -95
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1054 -958
- package/src/pb-odd-elementspec-editor.js +349 -298
- package/src/pb-odd-model-editor.js +1075 -909
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -422
- package/src/pb-paginate.js +228 -179
- package/src/pb-panel.js +198 -182
- package/src/pb-popover-themes.js +15 -8
- package/src/pb-popover.js +296 -287
- package/src/pb-print-preview.js +127 -127
- package/src/pb-progress.js +51 -51
- package/src/pb-repeat.js +105 -104
- package/src/pb-restricted.js +84 -77
- package/src/pb-search.js +256 -228
- package/src/pb-select-feature.js +127 -120
- package/src/pb-select-odd.js +132 -124
- package/src/pb-select-template.js +89 -78
- package/src/pb-select.js +251 -227
- package/src/pb-split-list.js +179 -174
- package/src/pb-svg.js +80 -79
- package/src/pb-table-column.js +54 -54
- package/src/pb-table-grid.js +221 -203
- package/src/pb-tabs.js +61 -63
- package/src/pb-tify.js +154 -154
- package/src/pb-timeline.js +382 -249
- package/src/pb-toggle-feature.js +195 -187
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +135 -98
- package/src/pb-view.js +1282 -1270
- package/src/pb-zoom.js +127 -45
- package/src/polymer-hack.js +1 -1
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +13 -20
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
- package/css/pb-styles.css +0 -51
- package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -41
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
|
-
|
|
4
|
+
window.TeiPublisher = {};
|
|
5
5
|
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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 =
|
|
104
|
-
|
|
107
|
+
export const pbMixin = superclass =>
|
|
108
|
+
class PbMixin extends superclass {
|
|
105
109
|
static get properties() {
|
|
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
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
super();
|
|
174
|
+
this._isReady = false;
|
|
175
|
+
this.disabled = false;
|
|
176
|
+
this._subscriptions = new Map();
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
connectedCallback() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
204
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
249
|
-
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
279
|
-
(this.subscribe && readyEventsFired.has(this.subscribe)) ||
|
|
280
|
-
(!this.subscribe && readyEventsFired.has('__default__'))
|
|
281
|
-
) {
|
|
282
|
-
return callback();
|
|
280
|
+
});
|
|
283
281
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
410
|
+
if (this.src) {
|
|
411
|
+
const doc = document.getElementById(this.src);
|
|
412
|
+
if (doc) {
|
|
413
|
+
return doc;
|
|
411
414
|
}
|
|
412
|
-
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
413
417
|
}
|
|
414
418
|
|
|
415
419
|
getParameter(name, fallback) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
439
|
+
return TeiPublisher.url;
|
|
435
440
|
}
|
|
436
441
|
|
|
437
442
|
getEndpoint() {
|
|
438
|
-
|
|
443
|
+
return this._endpoint;
|
|
439
444
|
}
|
|
440
445
|
|
|
441
446
|
toAbsoluteURL(relative, server) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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
|
-
|
|
464
|
+
return cmpVersion(this._apiVersion, requiredVersion) >= 0;
|
|
460
465
|
}
|
|
461
466
|
|
|
462
467
|
lessThanApiVersion(requiredVersion) {
|
|
463
|
-
|
|
468
|
+
return cmpVersion(this._apiVersion, requiredVersion) < 0;
|
|
464
469
|
}
|
|
465
470
|
|
|
466
471
|
compareApiVersion(requiredVersion) {
|
|
467
|
-
|
|
472
|
+
return cmpVersion(this._apiVersion, requiredVersion);
|
|
468
473
|
}
|
|
469
|
-
}
|
|
474
|
+
};
|