@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.
Files changed (262) hide show
  1. package/.github/workflows/docker-cypress.yml +54 -0
  2. package/.github/workflows/main.yml +6 -4
  3. package/.github/workflows/node.js.yml +56 -21
  4. package/.github/workflows/release.js.yml +19 -17
  5. package/.releaserc.json +1 -1
  6. package/CHANGELOG.md +351 -9
  7. package/Dockerfile +78 -70
  8. package/README.md +112 -4
  9. package/css/components.css +5 -5
  10. package/css/gridjs/mermaid.min.css +1 -1
  11. package/css/leaflet/Control.Geocoder.css +1 -126
  12. package/css/leaflet/images/layers.png +0 -0
  13. package/css/tify/tify.css +6 -5
  14. package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
  15. package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
  16. package/css/tom-select/tom-select.default.min.css +1 -1
  17. package/css/tom-select/tom-select.default.min.css.map +1 -0
  18. package/css/tom-select/tom-select.min.css +1 -1
  19. package/cypress.config.js +84 -0
  20. package/dist/api.html +1 -1
  21. package/dist/css/design-system.css +607 -0
  22. package/dist/demo/bundle-test.html +4 -3
  23. package/dist/demo/components.css +46 -1
  24. package/dist/demo/design-system.html +710 -0
  25. package/dist/demo/dts-client.html +2 -2
  26. package/dist/demo/pb-autocomplete.html +23 -11
  27. package/dist/demo/pb-autocomplete2.html +66 -55
  28. package/dist/demo/pb-autocomplete3.html +17 -8
  29. package/dist/demo/pb-blacklab-highlight.html +28 -11
  30. package/dist/demo/pb-blacklab-results.html +3 -2
  31. package/dist/demo/pb-browse-docs.html +24 -24
  32. package/dist/demo/pb-browse-docs2.html +3 -3
  33. package/dist/demo/pb-clipboard.html +32 -28
  34. package/dist/demo/pb-code-editor.html +6 -6
  35. package/dist/demo/pb-code-highlight.html +63 -63
  36. package/dist/demo/pb-codepen.html +1 -1
  37. package/dist/demo/pb-collapse.html +1 -1
  38. package/dist/demo/pb-collapse2.html +2 -2
  39. package/dist/demo/pb-combo-box.html +135 -130
  40. package/dist/demo/pb-custom-form.html +64 -55
  41. package/dist/demo/pb-dialog.html +12 -6
  42. package/dist/demo/pb-document.html +1 -1
  43. package/dist/demo/pb-download.html +68 -59
  44. package/dist/demo/pb-drawer.html +67 -46
  45. package/dist/demo/pb-drawer2.html +65 -58
  46. package/dist/demo/pb-edit-app.html +2 -2
  47. package/dist/demo/pb-edit-xml.html +1 -1
  48. package/dist/demo/pb-facsimile-2.html +26 -11
  49. package/dist/demo/pb-facsimile-3.html +25 -10
  50. package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
  51. package/dist/demo/pb-facsimile-dedup-test.html +48 -0
  52. package/dist/demo/pb-facsimile.html +4 -4
  53. package/dist/demo/pb-formula.html +1 -1
  54. package/dist/demo/pb-grid.html +22 -8
  55. package/dist/demo/pb-highlight.html +2 -2
  56. package/dist/demo/pb-i18n-simple.html +1 -0
  57. package/dist/demo/pb-i18n.html +15 -5
  58. package/dist/demo/pb-image-strip-standalone.html +2 -2
  59. package/dist/demo/pb-image-strip-view.html +2 -2
  60. package/dist/demo/pb-leaflet-map.html +3 -3
  61. package/dist/demo/pb-leaflet-map2.html +2 -2
  62. package/dist/demo/pb-leaflet-map3.html +3 -3
  63. package/dist/demo/pb-link.html +1 -1
  64. package/dist/demo/pb-load.html +2 -6
  65. package/dist/demo/pb-login.html +1 -3
  66. package/dist/demo/pb-manage-odds.html +9 -4
  67. package/dist/demo/pb-markdown.html +1 -1
  68. package/dist/demo/pb-media-query.html +2 -2
  69. package/dist/demo/pb-mei.html +2 -2
  70. package/dist/demo/pb-mei2.html +2 -2
  71. package/dist/demo/pb-message.html +2 -3
  72. package/dist/demo/pb-odd-editor.html +54 -52
  73. package/dist/demo/pb-page-header.html +27 -0
  74. package/dist/demo/pb-popover.html +1 -1
  75. package/dist/demo/pb-print-preview.html +2 -2
  76. package/dist/demo/pb-progress.html +4 -4
  77. package/dist/demo/pb-repeat.html +32 -36
  78. package/dist/demo/pb-search.html +16 -5
  79. package/dist/demo/pb-search2.html +4 -4
  80. package/dist/demo/pb-search3.html +3 -3
  81. package/dist/demo/pb-search4.html +3 -3
  82. package/dist/demo/pb-select-feature.html +4 -4
  83. package/dist/demo/pb-select-feature2.html +4 -4
  84. package/dist/demo/pb-select-feature3.html +2 -2
  85. package/dist/demo/pb-select-i18n.html +58 -53
  86. package/dist/demo/pb-select-odd.html +1 -1
  87. package/dist/demo/pb-select.html +190 -75
  88. package/dist/demo/pb-select2.html +91 -37
  89. package/dist/demo/pb-select3.html +109 -41
  90. package/dist/demo/pb-svg.html +1 -1
  91. package/dist/demo/pb-table-grid.html +26 -15
  92. package/dist/demo/pb-tabs.html +15 -7
  93. package/dist/demo/pb-tify.html +7 -7
  94. package/dist/demo/pb-timeline.html +1 -1
  95. package/dist/demo/pb-timeline2.html +1 -1
  96. package/dist/demo/pb-toggle-feature.html +26 -23
  97. package/dist/demo/pb-toggle-feature2.html +4 -4
  98. package/dist/demo/pb-toggle-feature3.html +2 -2
  99. package/dist/demo/pb-toggle-feature4.html +56 -54
  100. package/dist/demo/pb-version.html +2 -2
  101. package/dist/demo/pb-view.html +78 -40
  102. package/dist/demo/pb-view2.html +69 -46
  103. package/dist/demo/pb-view3.html +53 -48
  104. package/dist/demo/pb-view4.html +70 -49
  105. package/dist/demo/pb-zoom.html +2 -2
  106. package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
  107. package/dist/focus-mixin-VCsFap6b.js +768 -0
  108. package/dist/images/icons.svg +217 -0
  109. package/dist/jinn-codemirror-DETLdm08.js +1 -0
  110. package/dist/lib/openseadragon.min.js +80 -0
  111. package/dist/lib/openseadragon.min.js.map +1 -0
  112. package/dist/pb-code-editor.js +25 -20
  113. package/dist/pb-component-docs.js +414 -3225
  114. package/dist/pb-components-bundle.js +3046 -4402
  115. package/dist/pb-dialog-tklYGWfc.js +121 -0
  116. package/dist/pb-edit-app.js +208 -107
  117. package/dist/pb-elements.json +716 -249
  118. package/dist/pb-facsimile.js +46 -0
  119. package/dist/pb-i18n-C0NDma4h.js +1 -0
  120. package/dist/pb-leaflet-map.js +23 -23
  121. package/dist/pb-mei.js +152 -134
  122. package/dist/pb-mixin-DHoWQheB.js +1 -0
  123. package/dist/pb-odd-editor.js +1671 -1231
  124. package/dist/pb-tify.js +1 -27
  125. package/dist/unsafe-html-D5VGo9Oq.js +1 -0
  126. package/dist/urls-BEONu_g4.js +1 -0
  127. package/eslint.config.mjs +92 -0
  128. package/gh-pages.js +5 -3
  129. package/i18n/common/en.json +6 -0
  130. package/i18n/common/pl.json +2 -2
  131. package/images/icons.svg +217 -0
  132. package/index.html +0 -5
  133. package/lib/leaflet-src.js.map +1 -0
  134. package/lib/leaflet.markercluster-src.js.map +1 -0
  135. package/lib/openseadragon.min.js +6 -6
  136. package/package.json +56 -81
  137. package/pb-elements.json +716 -249
  138. package/rollup.config.mjs +312 -0
  139. package/src/assets/components.css +5 -5
  140. package/src/assets/design-system.css +607 -0
  141. package/src/authority/airtable.js +20 -21
  142. package/src/authority/anton.js +129 -129
  143. package/src/authority/custom.js +70 -27
  144. package/src/authority/geonames.js +38 -32
  145. package/src/authority/gnd.js +50 -42
  146. package/src/authority/kbga.js +136 -134
  147. package/src/authority/metagrid.js +44 -46
  148. package/src/authority/reconciliation.js +66 -68
  149. package/src/authority/registry.js +4 -4
  150. package/src/docs/demo-utils.js +91 -0
  151. package/src/docs/pb-component-docs.js +287 -147
  152. package/src/docs/pb-component-view.js +380 -273
  153. package/src/docs/pb-components-list.js +115 -51
  154. package/src/docs/pb-demo-snippet.js +199 -174
  155. package/src/dts-client.js +306 -303
  156. package/src/dts-select-endpoint.js +125 -85
  157. package/src/parse-date-service.js +184 -135
  158. package/src/pb-ajax.js +175 -173
  159. package/src/pb-authority-lookup.js +198 -158
  160. package/src/pb-autocomplete.js +731 -313
  161. package/src/pb-blacklab-highlight.js +266 -260
  162. package/src/pb-blacklab-results.js +230 -225
  163. package/src/pb-browse-docs.js +601 -484
  164. package/src/pb-browse.js +68 -65
  165. package/src/pb-clipboard.js +97 -76
  166. package/src/pb-code-editor.js +111 -103
  167. package/src/pb-code-highlight.js +234 -204
  168. package/src/pb-codepen.js +81 -73
  169. package/src/pb-collapse.js +265 -152
  170. package/src/pb-combo-box.js +191 -191
  171. package/src/pb-components-bundle.js +1 -7
  172. package/src/pb-components.js +2 -6
  173. package/src/pb-custom-form.js +230 -141
  174. package/src/pb-dialog.js +99 -63
  175. package/src/pb-document.js +118 -91
  176. package/src/pb-download.js +214 -198
  177. package/src/pb-drawer.js +146 -149
  178. package/src/pb-edit-app.js +471 -240
  179. package/src/pb-edit-xml.js +101 -98
  180. package/src/pb-events.js +126 -107
  181. package/src/pb-facs-link.js +130 -101
  182. package/src/pb-facsimile.js +494 -410
  183. package/src/pb-fetch.js +389 -0
  184. package/src/pb-formula.js +152 -154
  185. package/src/pb-geolocation.js +130 -132
  186. package/src/pb-grid-action.js +59 -56
  187. package/src/pb-grid.js +388 -228
  188. package/src/pb-highlight.js +142 -142
  189. package/src/pb-hotkeys.js +40 -42
  190. package/src/pb-i18n.js +115 -127
  191. package/src/pb-icon-button.js +108 -0
  192. package/src/pb-icon.js +283 -0
  193. package/src/pb-image-strip.js +85 -79
  194. package/src/pb-lang.js +142 -57
  195. package/src/pb-leaflet-map.js +551 -483
  196. package/src/pb-link.js +132 -126
  197. package/src/pb-load.js +495 -428
  198. package/src/pb-login.js +303 -248
  199. package/src/pb-manage-odds.js +384 -338
  200. package/src/pb-map-icon.js +90 -90
  201. package/src/pb-map-layer.js +86 -86
  202. package/src/pb-markdown.js +107 -110
  203. package/src/pb-media-query.js +75 -73
  204. package/src/pb-mei.js +523 -303
  205. package/src/pb-message.js +144 -98
  206. package/src/pb-mixin.js +268 -265
  207. package/src/pb-navigation.js +83 -96
  208. package/src/pb-observable.js +39 -39
  209. package/src/pb-odd-editor.js +1209 -948
  210. package/src/pb-odd-elementspec-editor.js +375 -310
  211. package/src/pb-odd-model-editor.js +1189 -941
  212. package/src/pb-odd-parameter-editor.js +269 -170
  213. package/src/pb-odd-rendition-editor.js +184 -131
  214. package/src/pb-page.js +451 -422
  215. package/src/pb-paginate.js +260 -178
  216. package/src/pb-panel.js +217 -183
  217. package/src/pb-popover-themes.js +16 -9
  218. package/src/pb-popover.js +297 -288
  219. package/src/pb-print-preview.js +128 -128
  220. package/src/pb-progress.js +52 -52
  221. package/src/pb-repeat.js +141 -108
  222. package/src/pb-restricted.js +85 -78
  223. package/src/pb-search.js +258 -230
  224. package/src/pb-select-feature.js +210 -126
  225. package/src/pb-select-odd.js +184 -118
  226. package/src/pb-select-template.js +113 -78
  227. package/src/pb-select.js +330 -229
  228. package/src/pb-split-list.js +181 -176
  229. package/src/pb-svg.js +81 -80
  230. package/src/pb-table-column.js +55 -55
  231. package/src/pb-table-grid.js +334 -205
  232. package/src/pb-tabs.js +238 -61
  233. package/src/pb-tify.js +3331 -126
  234. package/src/pb-timeline.js +394 -255
  235. package/src/pb-toggle-feature.js +196 -188
  236. package/src/pb-upload.js +201 -176
  237. package/src/pb-version.js +22 -34
  238. package/src/pb-view-annotate.js +138 -102
  239. package/src/pb-view.js +1722 -1272
  240. package/src/pb-zoom.js +144 -46
  241. package/src/search-result-service.js +256 -223
  242. package/src/seed-element.js +14 -22
  243. package/src/settings.js +4 -4
  244. package/src/theming.js +98 -91
  245. package/src/urls.js +403 -289
  246. package/src/utils.js +53 -51
  247. package/vite.config.js +86 -0
  248. package/css/pb-styles.css +0 -51
  249. package/dist/iron-form-3b8dcaa7.js +0 -210
  250. package/dist/jinn-codemirror-da0e2d1f.js +0 -1
  251. package/dist/paper-checkbox-515a5284.js +0 -1597
  252. package/dist/paper-icon-button-b1d31571.js +0 -398
  253. package/dist/paper-listbox-a3b7175c.js +0 -1265
  254. package/dist/pb-i18n-0611135a.js +0 -1
  255. package/dist/pb-mixin-b1caa22e.js +0 -158
  256. package/dist/polymer-hack.js +0 -1
  257. package/dist/vaadin-element-mixin-6e4cee3a.js +0 -527
  258. package/lib/Control.Geocoder.min.js +0 -2
  259. package/lib/Control.Geocoder.min.js.map +0 -1
  260. package/src/assets/pb-styles.css +0 -51
  261. package/src/pb-light-dom.js +0 -40
  262. 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
- 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
  /**
@@ -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 = (superclass) => class PbMixin extends superclass {
104
-
106
+ export const pbMixin = superclass =>
107
+ class PbMixin extends superclass {
105
108
  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
- }
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
- super();
170
- this._isReady = false;
171
- this.disabled = false;
172
- this._subscriptions = new Map();
172
+ super();
173
+ this._isReady = false;
174
+ this.disabled = false;
175
+ this._subscriptions = new Map();
173
176
  }
174
177
 
175
178
  connectedCallback() {
176
- super.connectedCallback();
177
- waitOnce('pb-page-ready', (options) => {
178
- this._endpoint = options.endpoint;
179
- this._apiVersion = options.apiVersion;
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
- super.disconnectedCallback();
185
- this._subscriptions.forEach((handlers, type) => {
186
- handlers.forEach((handler) => {
187
- document.removeEventListener(type, handler);
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
- if (command === 'disable') {
204
- this.disabled = state;
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
- 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
- });
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
- if (!this.waitFor) {
249
- callback();
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
- if (document.readyState === 'loading') {
253
- document.addEventListener('DOMContentLoaded', () => {
254
- _checkAndWait();
255
- });
256
- } else {
257
- _checkAndWait();
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
- // 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
- });
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
- } else if (
279
- (this.subscribe && readyEventsFired.has(this.subscribe)) ||
280
- (!this.subscribe && readyEventsFired.has('__default__'))
281
- ) {
282
- return callback();
279
+ });
283
280
  }
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
- });
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
- waitOnce(name, callback);
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
- this._isReady = true;
313
- initEventsFired.set(name, data);
314
- this.dispatchEvent(new CustomEvent(name, { detail: { data, source: this } }));
315
- this.emitTo(name, data);
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
- 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));
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
- 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;
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
- 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));
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
- 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);
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
- if (this.src) {
407
- const doc = document.getElementById(this.src);
408
- if (doc) {
409
- return doc;
410
- }
408
+ if (this.src) {
409
+ const doc = document.getElementById(this.src);
410
+ if (doc) {
411
+ return doc;
411
412
  }
412
- return null;
413
+ }
414
+ return null;
413
415
  }
414
416
 
415
417
  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;
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
- const params = {};
427
- for (let key of TeiPublisher.url.searchParams.keys()) {
428
- params[key] = this.getParameter(key);
429
- }
430
- return params;
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
- return TeiPublisher.url;
437
+ return TeiPublisher.url;
435
438
  }
436
439
 
437
440
  getEndpoint() {
438
- return this._endpoint;
441
+ return this._endpoint;
439
442
  }
440
443
 
441
444
  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;
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
- return cmpVersion(this._apiVersion, requiredVersion) >= 0;
462
+ return cmpVersion(this._apiVersion, requiredVersion) >= 0;
460
463
  }
461
464
 
462
465
  lessThanApiVersion(requiredVersion) {
463
- return cmpVersion(this._apiVersion, requiredVersion) < 0;
466
+ return cmpVersion(this._apiVersion, requiredVersion) < 0;
464
467
  }
465
468
 
466
469
  compareApiVersion(requiredVersion) {
467
- return cmpVersion(this._apiVersion, requiredVersion);
470
+ return cmpVersion(this._apiVersion, requiredVersion);
468
471
  }
469
- }
472
+ };