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