@teipublisher/pb-components 2.5.1 → 2.6.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.
@@ -10309,7 +10309,7 @@
10309
10309
  {
10310
10310
  "name": "pb-svg",
10311
10311
  "path": "./src/pb-svg.js",
10312
- "description": "Show an SVG image with zoom and pan functionality. The image URL may\neither be specified via the `url` property or an `pb-show-annotation` event\nsent to this component.",
10312
+ "description": "Show an SVG image with zoom and pan functionality. The image URL may\neither be specified via the `url` property or an `pb-show-annotation` event\nsent to this component. A relative URL will be resolved against the current API context.",
10313
10313
  "attributes": [
10314
10314
  {
10315
10315
  "name": "url",
@@ -10396,7 +10396,7 @@
10396
10396
  "events": [
10397
10397
  {
10398
10398
  "name": "pb-show-annotation",
10399
- "description": "When received, loads the image from the URL passed from the event"
10399
+ "description": "When received, loads the image from the URL passed in property `file`\nwithin the event"
10400
10400
  }
10401
10401
  ],
10402
10402
  "cssProperties": [
@@ -10706,6 +10706,12 @@
10706
10706
  "default": "false"
10707
10707
  }
10708
10708
  ],
10709
+ "events": [
10710
+ {
10711
+ "name": "pb-tab",
10712
+ "description": "fired if selected tab changes. Details contain number of \nselected tab in propery `selected`."
10713
+ }
10714
+ ],
10709
10715
  "slots": [
10710
10716
  {
10711
10717
  "name": "tab",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "2.5.1",
3
+ "version": "2.6.1",
4
4
  "description": "Collection of webcomponents underlying TEI Publisher",
5
5
  "repository": "https://github.com/eeditiones/tei-publisher-components.git",
6
6
  "main": "index.html",
package/pb-elements.json CHANGED
@@ -10309,7 +10309,7 @@
10309
10309
  {
10310
10310
  "name": "pb-svg",
10311
10311
  "path": "./src/pb-svg.js",
10312
- "description": "Show an SVG image with zoom and pan functionality. The image URL may\neither be specified via the `url` property or an `pb-show-annotation` event\nsent to this component.",
10312
+ "description": "Show an SVG image with zoom and pan functionality. The image URL may\neither be specified via the `url` property or an `pb-show-annotation` event\nsent to this component. A relative URL will be resolved against the current API context.",
10313
10313
  "attributes": [
10314
10314
  {
10315
10315
  "name": "url",
@@ -10396,7 +10396,7 @@
10396
10396
  "events": [
10397
10397
  {
10398
10398
  "name": "pb-show-annotation",
10399
- "description": "When received, loads the image from the URL passed from the event"
10399
+ "description": "When received, loads the image from the URL passed in property `file`\nwithin the event"
10400
10400
  }
10401
10401
  ],
10402
10402
  "cssProperties": [
@@ -10706,6 +10706,12 @@
10706
10706
  "default": "false"
10707
10707
  }
10708
10708
  ],
10709
+ "events": [
10710
+ {
10711
+ "name": "pb-tab",
10712
+ "description": "fired if selected tab changes. Details contain number of \nselected tab in propery `selected`."
10713
+ }
10714
+ ],
10709
10715
  "slots": [
10710
10716
  {
10711
10717
  "name": "tab",
@@ -3,19 +3,21 @@ import { Registry } from "./registry.js";
3
3
  /**
4
4
  * Connector for the corporate archive of Georgfischer AG.
5
5
  */
6
- export class GF extends Registry {
6
+ export class Anton extends Registry {
7
7
 
8
8
  constructor(configElem) {
9
9
  super(configElem);
10
+ this._url = configElem.getAttribute('url') || `https://archives.georgfischer.com/api`;
10
11
  this._api = configElem.getAttribute('api');
11
12
  this._limit = configElem.getAttribute('limit') || 999999;
13
+ this._provider = configElem.getAttribute('provider') || configElem.getAttribute('connector')
12
14
  }
13
15
 
14
16
  async query(key) {
15
17
  const results = [];
16
18
 
17
19
  const register = this.getRegister();
18
- const url = `https://archives.georgfischer.com/api/${register}?search=${encodeURIComponent(key)}&perPage=${this._limit}`;
20
+ const url = `${this._url}/${register}?search=${encodeURIComponent(key)}&perPage=${this._limit}`;
19
21
  const label = this.getLabelField();
20
22
  return new Promise((resolve) => {
21
23
  fetch(url)
@@ -38,9 +40,9 @@ export class GF extends Registry {
38
40
  id: (this._prefix ? `${this._prefix}-${item.id}` : item.id),
39
41
  label: item[label],
40
42
  details: `${item.id}`,
41
- link: `https://archives.georgfischer.com/api/${register}/${item.id}`,
43
+ link: `${this._url}/${register}/${item.id}`,
42
44
  strings: [item[label]],
43
- provider: 'GF'
45
+ provider: this._provider
44
46
  };
45
47
  results.push(result);
46
48
  });
@@ -87,7 +89,7 @@ export class GF extends Registry {
87
89
  */
88
90
  async getRecord(key) {
89
91
  const id = key.replace(/^.*-([^-]+)$/, '$1');
90
- const url = `https://archives.georgfischer.com/api/${this.getRegister()}/${id}`;
92
+ const url = `${this._url}/${this.getRegister()}/${id}`;
91
93
  return fetch(url)
92
94
  .then(response => response.json())
93
95
  .then(json => {
@@ -3,7 +3,7 @@ import { GeoNames } from './geonames.js';
3
3
  import { Airtable } from './airtable.js';
4
4
  import { GND } from './gnd.js';
5
5
  import { KBGA } from './kbga.js';
6
- import { GF } from './gf.js';
6
+ import { Anton } from './anton.js';
7
7
  import { ReconciliationService } from './reconciliation.js';
8
8
  import { Custom } from './custom.js';
9
9
 
@@ -25,8 +25,9 @@ export function createConnectors(endpoint, root) {
25
25
  case 'KBGA':
26
26
  instance = new KBGA(configElem);
27
27
  break;
28
+ case 'Anton':
28
29
  case 'GF':
29
- instance = new GF(configElem);
30
+ instance = new Anton(configElem);
30
31
  break;
31
32
  case 'ReconciliationService':
32
33
  instance = new ReconciliationService(configElem);
package/src/pb-svg.js CHANGED
@@ -6,9 +6,10 @@ import { pbMixin } from './pb-mixin.js';
6
6
  /**
7
7
  * Show an SVG image with zoom and pan functionality. The image URL may
8
8
  * either be specified via the `url` property or an `pb-show-annotation` event
9
- * sent to this component.
9
+ * sent to this component. A relative URL will be resolved against the current API context.
10
10
  *
11
- * @fires pb-show-annotation - When received, loads the image from the URL passed from the event
11
+ * @fires pb-show-annotation - When received, loads the image from the URL passed in property `file`
12
+ * within the event
12
13
  * @cssprop --pb-svg-height - Height of the SVG element
13
14
  * @cssprop --pb-svg-width - Width of the SVG element
14
15
  */
@@ -32,43 +33,48 @@ export class PbSvg extends pbMixin(LitElement) {
32
33
 
33
34
  connectedCallback() {
34
35
  super.connectedCallback();
35
- }
36
36
 
37
- firstUpdated() {
38
- super.firstUpdated();
39
37
  window.ESGlobalBridge.requestAvailability();
40
38
  window.ESGlobalBridge.instance.load("svg-pan-zoom", `https://cdn.jsdelivr.net/npm/svg-pan-zoom@3.6.1/dist/svg-pan-zoom.min.js`);
41
- window.addEventListener(
42
- "es-bridge-svg-pan-zoom-loaded",
43
- this._onSvgPanZoomLoaded.bind(this),
44
- { once: true }
45
- );
46
-
47
- this.container = this.shadowRoot.getElementById('image');
48
39
 
49
40
  this.subscribeTo('pb-show-annotation', (ev) => {
50
- console.log('<pb-svg> loading %s', ev.detail.file);
41
+ if (this.url === ev.detail.file) {
42
+ return;
43
+ }
51
44
  this.url = ev.detail.file;
52
- this.load();
53
45
  });
54
46
  }
55
47
 
56
- _onSvgPanZoomLoaded() {
57
- this.load();
48
+ firstUpdated() {
49
+ super.firstUpdated();
50
+
51
+ this.container = this.shadowRoot.getElementById('image');
52
+ }
53
+
54
+ updated(changed) {
55
+ if (changed.has('url') && this.url && this.url !== changed.get('url')) {
56
+ this.load();
57
+ }
58
58
  }
59
-
59
+
60
60
  load() {
61
+ if (!this.url) {
62
+ return;
63
+ }
64
+ const uri = this.toAbsoluteURL(this.url);
65
+ console.log('<pb-svg> Loading %s', uri);
61
66
  if (this._pan) {
62
67
  this._pan.destroy();
63
68
  this._pan = null;
64
69
  this.container.innerHTML = '';
65
70
  }
66
- if (!this.url) {
67
- return;
68
- }
69
- fetch(this.url)
71
+ fetch(uri)
70
72
  .then((response) => response.text())
71
73
  .then((data) => {
74
+ if (!window.svgPanZoom) {
75
+ console.error('<pb-svg> svgPanZoom not available');
76
+ return;
77
+ }
72
78
  const doc = new DOMParser().parseFromString(data, "image/svg+xml");
73
79
  const svg = doc.documentElement;
74
80
  this.container.appendChild(svg);
package/src/pb-tabs.js CHANGED
@@ -11,6 +11,8 @@ import { registry } from "./urls.js";
11
11
  * @slot tab - tab area
12
12
  * @slot page - page area
13
13
  * @csspart pages - wrapper around the tab pages
14
+ * @fires pb-tab - fired if selected tab changes. Details contain number of
15
+ * selected tab in propery `selected`.
14
16
  */
15
17
  export class PbTabs extends pbMixin(LitElement) {
16
18
  static get properties() {
@@ -43,11 +45,19 @@ export class PbTabs extends pbMixin(LitElement) {
43
45
  });
44
46
  }
45
47
 
48
+ firstUpdated() {
49
+ super.firstUpdated();
50
+ this.emitTo('pb-tab', { selected: this.selected });
51
+ }
52
+
46
53
  _switchTab(ev) {
47
54
  const current = parseInt(ev.detail.value, 10);
48
55
  if (this.selected === current) {
49
56
  return;
50
57
  }
58
+
59
+ this.emitTo('pb-tab', { selected: current });
60
+
51
61
  this.selected = current;
52
62
  if (this._initialized) {
53
63
  registry.commit(this, { tab: this.selected });