@teipublisher/pb-components 2.26.1-next.3 → 3.0.0-next-4.2

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 +53 -0
  2. package/.github/workflows/node.js.yml +70 -21
  3. package/.releaserc.json +7 -2
  4. package/CHANGELOG.md +363 -11
  5. package/Dockerfile +78 -70
  6. package/README.md +112 -4
  7. package/css/components.css +5 -5
  8. package/css/gridjs/mermaid.min.css +1 -1
  9. package/css/leaflet/Control.Geocoder.css +1 -126
  10. package/css/leaflet/images/layers.png +0 -0
  11. package/css/tify/tify.css +6 -5
  12. package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
  13. package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
  14. package/css/tom-select/tom-select.default.min.css +1 -1
  15. package/css/tom-select/tom-select.default.min.css.map +1 -0
  16. package/css/tom-select/tom-select.min.css +1 -1
  17. package/cypress.config.js +84 -0
  18. package/dist/api.html +1 -1
  19. package/dist/css/design-system.css +607 -0
  20. package/dist/demo/bundle-test.html +4 -3
  21. package/dist/demo/components.css +46 -1
  22. package/dist/demo/design-system.html +710 -0
  23. package/dist/demo/dts-client.html +2 -2
  24. package/dist/demo/pb-autocomplete.html +23 -11
  25. package/dist/demo/pb-autocomplete2.html +66 -55
  26. package/dist/demo/pb-autocomplete3.html +17 -8
  27. package/dist/demo/pb-blacklab-highlight.html +28 -11
  28. package/dist/demo/pb-blacklab-results.html +3 -2
  29. package/dist/demo/pb-browse-docs.html +24 -24
  30. package/dist/demo/pb-browse-docs2.html +3 -3
  31. package/dist/demo/pb-clipboard.html +32 -28
  32. package/dist/demo/pb-code-editor.html +6 -6
  33. package/dist/demo/pb-code-highlight.html +63 -63
  34. package/dist/demo/pb-codepen.html +1 -1
  35. package/dist/demo/pb-collapse.html +1 -1
  36. package/dist/demo/pb-collapse2.html +2 -2
  37. package/dist/demo/pb-combo-box.html +135 -130
  38. package/dist/demo/pb-custom-form.html +64 -55
  39. package/dist/demo/pb-dialog.html +12 -6
  40. package/dist/demo/pb-document.html +1 -1
  41. package/dist/demo/pb-download.html +68 -59
  42. package/dist/demo/pb-drawer.html +67 -46
  43. package/dist/demo/pb-drawer2.html +65 -58
  44. package/dist/demo/pb-edit-app.html +2 -2
  45. package/dist/demo/pb-edit-xml.html +1 -1
  46. package/dist/demo/pb-facsimile-2.html +26 -11
  47. package/dist/demo/pb-facsimile-3.html +25 -10
  48. package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
  49. package/dist/demo/pb-facsimile-dedup-test.html +48 -0
  50. package/dist/demo/pb-facsimile.html +4 -4
  51. package/dist/demo/pb-formula.html +1 -1
  52. package/dist/demo/pb-grid.html +22 -8
  53. package/dist/demo/pb-highlight.html +2 -2
  54. package/dist/demo/pb-i18n-simple.html +1 -0
  55. package/dist/demo/pb-i18n.html +15 -5
  56. package/dist/demo/pb-image-strip-standalone.html +2 -2
  57. package/dist/demo/pb-image-strip-view.html +2 -2
  58. package/dist/demo/pb-leaflet-map.html +3 -3
  59. package/dist/demo/pb-leaflet-map2.html +2 -2
  60. package/dist/demo/pb-leaflet-map3.html +3 -3
  61. package/dist/demo/pb-link.html +1 -1
  62. package/dist/demo/pb-load.html +2 -6
  63. package/dist/demo/pb-login.html +1 -3
  64. package/dist/demo/pb-manage-odds.html +9 -4
  65. package/dist/demo/pb-markdown.html +1 -1
  66. package/dist/demo/pb-media-query.html +2 -2
  67. package/dist/demo/pb-mei.html +2 -2
  68. package/dist/demo/pb-mei2.html +2 -2
  69. package/dist/demo/pb-message.html +2 -3
  70. package/dist/demo/pb-odd-editor.html +54 -52
  71. package/dist/demo/pb-page-header.html +27 -0
  72. package/dist/demo/pb-popover.html +1 -1
  73. package/dist/demo/pb-print-preview.html +2 -2
  74. package/dist/demo/pb-progress.html +4 -4
  75. package/dist/demo/pb-repeat.html +32 -36
  76. package/dist/demo/pb-search.html +16 -5
  77. package/dist/demo/pb-search2.html +4 -4
  78. package/dist/demo/pb-search3.html +3 -3
  79. package/dist/demo/pb-search4.html +3 -3
  80. package/dist/demo/pb-select-feature.html +4 -4
  81. package/dist/demo/pb-select-feature2.html +4 -4
  82. package/dist/demo/pb-select-feature3.html +2 -2
  83. package/dist/demo/pb-select-i18n.html +58 -53
  84. package/dist/demo/pb-select-odd.html +1 -1
  85. package/dist/demo/pb-select.html +190 -75
  86. package/dist/demo/pb-select2.html +91 -37
  87. package/dist/demo/pb-select3.html +109 -41
  88. package/dist/demo/pb-svg.html +1 -1
  89. package/dist/demo/pb-table-grid.html +26 -15
  90. package/dist/demo/pb-tabs.html +15 -7
  91. package/dist/demo/pb-tify.html +7 -7
  92. package/dist/demo/pb-timeline.html +1 -1
  93. package/dist/demo/pb-timeline2.html +1 -1
  94. package/dist/demo/pb-toggle-feature.html +26 -23
  95. package/dist/demo/pb-toggle-feature2.html +4 -4
  96. package/dist/demo/pb-toggle-feature3.html +2 -2
  97. package/dist/demo/pb-toggle-feature4.html +56 -54
  98. package/dist/demo/pb-version.html +2 -2
  99. package/dist/demo/pb-view.html +78 -40
  100. package/dist/demo/pb-view2.html +69 -46
  101. package/dist/demo/pb-view3.html +53 -48
  102. package/dist/demo/pb-view4.html +70 -49
  103. package/dist/demo/pb-zoom.html +2 -2
  104. package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
  105. package/dist/focus-mixin-VCsFap6b.js +768 -0
  106. package/dist/images/icons.svg +217 -0
  107. package/dist/jinn-codemirror-DETLdm08.js +1 -0
  108. package/dist/lib/openseadragon.min.js +80 -0
  109. package/dist/lib/openseadragon.min.js.map +1 -0
  110. package/dist/pb-code-editor.js +25 -20
  111. package/dist/pb-component-docs.js +414 -3225
  112. package/dist/pb-components-bundle.js +3046 -4402
  113. package/dist/pb-dialog-tklYGWfc.js +121 -0
  114. package/dist/pb-edit-app.js +208 -107
  115. package/dist/pb-elements.json +716 -249
  116. package/dist/pb-facsimile.js +46 -0
  117. package/dist/pb-i18n-C0NDma4h.js +1 -0
  118. package/dist/pb-leaflet-map.js +23 -23
  119. package/dist/pb-mei.js +152 -134
  120. package/dist/pb-mixin-DHoWQheB.js +1 -0
  121. package/dist/pb-odd-editor.js +1671 -1231
  122. package/dist/pb-tify.js +1 -27
  123. package/dist/unsafe-html-D5VGo9Oq.js +1 -0
  124. package/dist/urls-BEONu_g4.js +1 -0
  125. package/eslint.config.mjs +92 -0
  126. package/gh-pages.js +5 -3
  127. package/i18n/common/en.json +6 -0
  128. package/i18n/common/pl.json +2 -2
  129. package/images/icons.svg +217 -0
  130. package/index.html +0 -5
  131. package/lib/leaflet-src.js.map +1 -0
  132. package/lib/leaflet.markercluster-src.js.map +1 -0
  133. package/lib/openseadragon.min.js +6 -6
  134. package/package.json +56 -81
  135. package/pb-elements.json +716 -249
  136. package/rollup.config.mjs +312 -0
  137. package/src/assets/components.css +5 -5
  138. package/src/assets/design-system.css +607 -0
  139. package/src/authority/airtable.js +20 -21
  140. package/src/authority/anton.js +129 -129
  141. package/src/authority/custom.js +70 -27
  142. package/src/authority/geonames.js +38 -32
  143. package/src/authority/gnd.js +50 -42
  144. package/src/authority/kbga.js +136 -134
  145. package/src/authority/metagrid.js +44 -46
  146. package/src/authority/reconciliation.js +66 -68
  147. package/src/authority/registry.js +4 -4
  148. package/src/docs/demo-utils.js +91 -0
  149. package/src/docs/pb-component-docs.js +287 -147
  150. package/src/docs/pb-component-view.js +380 -273
  151. package/src/docs/pb-components-list.js +115 -51
  152. package/src/docs/pb-demo-snippet.js +199 -174
  153. package/src/dts-client.js +306 -303
  154. package/src/dts-select-endpoint.js +125 -85
  155. package/src/parse-date-service.js +184 -135
  156. package/src/pb-ajax.js +175 -173
  157. package/src/pb-authority-lookup.js +198 -158
  158. package/src/pb-autocomplete.js +731 -313
  159. package/src/pb-blacklab-highlight.js +266 -260
  160. package/src/pb-blacklab-results.js +230 -225
  161. package/src/pb-browse-docs.js +601 -484
  162. package/src/pb-browse.js +68 -65
  163. package/src/pb-clipboard.js +97 -76
  164. package/src/pb-code-editor.js +111 -103
  165. package/src/pb-code-highlight.js +234 -204
  166. package/src/pb-codepen.js +81 -73
  167. package/src/pb-collapse.js +265 -152
  168. package/src/pb-combo-box.js +191 -191
  169. package/src/pb-components-bundle.js +1 -7
  170. package/src/pb-components.js +2 -6
  171. package/src/pb-custom-form.js +230 -141
  172. package/src/pb-dialog.js +99 -63
  173. package/src/pb-document.js +118 -91
  174. package/src/pb-download.js +214 -198
  175. package/src/pb-drawer.js +146 -149
  176. package/src/pb-edit-app.js +471 -240
  177. package/src/pb-edit-xml.js +101 -98
  178. package/src/pb-events.js +126 -107
  179. package/src/pb-facs-link.js +130 -101
  180. package/src/pb-facsimile.js +494 -410
  181. package/src/pb-fetch.js +389 -0
  182. package/src/pb-formula.js +152 -154
  183. package/src/pb-geolocation.js +130 -132
  184. package/src/pb-grid-action.js +59 -56
  185. package/src/pb-grid.js +388 -228
  186. package/src/pb-highlight.js +142 -142
  187. package/src/pb-hotkeys.js +40 -42
  188. package/src/pb-i18n.js +115 -127
  189. package/src/pb-icon-button.js +108 -0
  190. package/src/pb-icon.js +283 -0
  191. package/src/pb-image-strip.js +85 -79
  192. package/src/pb-lang.js +142 -57
  193. package/src/pb-leaflet-map.js +551 -483
  194. package/src/pb-link.js +132 -126
  195. package/src/pb-load.js +495 -428
  196. package/src/pb-login.js +303 -248
  197. package/src/pb-manage-odds.js +384 -338
  198. package/src/pb-map-icon.js +90 -90
  199. package/src/pb-map-layer.js +86 -86
  200. package/src/pb-markdown.js +107 -110
  201. package/src/pb-media-query.js +75 -73
  202. package/src/pb-mei.js +523 -303
  203. package/src/pb-message.js +144 -98
  204. package/src/pb-mixin.js +268 -265
  205. package/src/pb-navigation.js +83 -96
  206. package/src/pb-observable.js +39 -39
  207. package/src/pb-odd-editor.js +1209 -948
  208. package/src/pb-odd-elementspec-editor.js +375 -310
  209. package/src/pb-odd-model-editor.js +1189 -941
  210. package/src/pb-odd-parameter-editor.js +269 -170
  211. package/src/pb-odd-rendition-editor.js +184 -131
  212. package/src/pb-page.js +451 -422
  213. package/src/pb-paginate.js +260 -178
  214. package/src/pb-panel.js +217 -183
  215. package/src/pb-popover-themes.js +16 -9
  216. package/src/pb-popover.js +297 -288
  217. package/src/pb-print-preview.js +128 -128
  218. package/src/pb-progress.js +52 -52
  219. package/src/pb-repeat.js +141 -108
  220. package/src/pb-restricted.js +85 -78
  221. package/src/pb-search.js +258 -230
  222. package/src/pb-select-feature.js +210 -126
  223. package/src/pb-select-odd.js +184 -118
  224. package/src/pb-select-template.js +113 -78
  225. package/src/pb-select.js +330 -229
  226. package/src/pb-split-list.js +181 -176
  227. package/src/pb-svg.js +81 -80
  228. package/src/pb-table-column.js +55 -55
  229. package/src/pb-table-grid.js +334 -205
  230. package/src/pb-tabs.js +238 -61
  231. package/src/pb-tify.js +3331 -126
  232. package/src/pb-timeline.js +394 -255
  233. package/src/pb-toggle-feature.js +196 -188
  234. package/src/pb-upload.js +201 -176
  235. package/src/pb-version.js +22 -34
  236. package/src/pb-view-annotate.js +138 -102
  237. package/src/pb-view.js +1722 -1272
  238. package/src/pb-zoom.js +144 -46
  239. package/src/search-result-service.js +256 -223
  240. package/src/seed-element.js +14 -22
  241. package/src/settings.js +4 -4
  242. package/src/theming.js +98 -91
  243. package/src/urls.js +403 -289
  244. package/src/utils.js +53 -51
  245. package/vite.config.js +86 -0
  246. package/.github/workflows/main.yml +0 -24
  247. package/.github/workflows/release.js.yml +0 -34
  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-fe4a4883.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 -41
  262. package/src/polymer-hack.js +0 -6
@@ -7,7 +7,7 @@ function _details(item) {
7
7
  professions = item.professionOrOccupation.map(p => p.label).join(', ');
8
8
  }
9
9
  if (item.biographicalOrHistoricalInformation) {
10
- professions = `${professions}; ${item.biographicalOrHistoricalInformation.join(', ')}`;
10
+ professions = `${professions}; ${item.biographicalOrHistoricalInformation.join(', ')}`;
11
11
  }
12
12
  const dates = [];
13
13
  if (item.dateOfBirth && item.dateOfBirth.length > 0) {
@@ -27,7 +27,6 @@ function _details(item) {
27
27
  * Uses https://lobid.org to query the German GND
28
28
  */
29
29
  export class GND extends Registry {
30
-
31
30
  query(key) {
32
31
  const results = [];
33
32
  let filter;
@@ -41,32 +40,39 @@ export class GND extends Registry {
41
40
  case 'organization':
42
41
  filter = 'CorporateBody';
43
42
  break;
43
+ case 'work':
44
+ filter = 'Work';
45
+ break;
44
46
  default:
45
47
  filter = 'Person';
46
48
  break;
47
49
  }
48
- return new Promise((resolve) => {
49
- fetch(`https://lobid.org/gnd/search?q=${encodeURIComponent(key)}&filter=%2B%28type%3A${filter}%29&format=json&size=100`)
50
- .then((response) => response.json())
51
- .then((json) => {
52
- json.member.forEach((item) => {
50
+ return new Promise(resolve => {
51
+ fetch(
52
+ `https://lobid.org/gnd/search?q=${encodeURIComponent(
53
+ key,
54
+ )}&filter=%2B%28type%3A${filter}%29&format=json&size=100`,
55
+ )
56
+ .then(response => response.json())
57
+ .then(json => {
58
+ json.member.forEach(item => {
53
59
  const result = {
54
- register: this._register,
55
- id: (this._prefix ? `${this._prefix}-${item.gndIdentifier}` : item.gndIdentifier),
56
- label: item.preferredName,
57
- link: item.id,
58
- details: _details(item),
59
- strings: [item.preferredName].concat(item.variantName),
60
- provider: 'GND'
60
+ register: this._register,
61
+ id: this._prefix ? `${this._prefix}-${item.gndIdentifier}` : item.gndIdentifier,
62
+ label: item.preferredName,
63
+ link: item.id,
64
+ details: _details(item),
65
+ strings: [item.preferredName].concat(item.variantName),
66
+ provider: 'GND',
61
67
  };
62
68
  results.push(result);
63
- });
64
- resolve({
65
- totalItems: json.totalItems,
66
- items: results,
67
- });
68
- })
69
- })
69
+ });
70
+ resolve({
71
+ totalItems: json.totalItems,
72
+ items: results,
73
+ });
74
+ });
75
+ });
70
76
  }
71
77
 
72
78
  /**
@@ -78,14 +84,14 @@ export class GND extends Registry {
78
84
  async getRecord(key) {
79
85
  const id = this._prefix ? key.substring(this._prefix.length + 1) : key;
80
86
  return fetch(`https://lobid.org/gnd/${id}.json`)
81
- .then((response) => {
87
+ .then(response => {
82
88
  if (response.ok) {
83
89
  return response.json();
84
90
  }
85
91
  return Promise.reject();
86
92
  })
87
- .then((json) => {
88
- const output = Object.assign({}, json);
93
+ .then(json => {
94
+ const output = { ...json };
89
95
  output.name = json.preferredName;
90
96
  output.link = json.id;
91
97
  if (json.dateOfBirth && json.dateOfBirth.length > 0) {
@@ -98,7 +104,7 @@ export class GND extends Registry {
98
104
  output.note = json.biographicalOrHistoricalInformation.join('; ');
99
105
  }
100
106
  if (json.professionOrOccupation && json.professionOrOccupation.length > 0) {
101
- output.profession = json.professionOrOccupation.map((prof) => prof.label);
107
+ output.profession = json.professionOrOccupation.map(prof => prof.label);
102
108
  }
103
109
  return output;
104
110
  })
@@ -111,38 +117,40 @@ export class GND extends Registry {
111
117
  }
112
118
  return new Promise((resolve, reject) => {
113
119
  this.getRecord(key)
114
- .then((json) => {
115
- let info;
116
- if (json.type.indexOf('SubjectHeading') > -1) {
117
- info = this.infoSubject(json);
118
- } else if (json.type.indexOf('AuthorityResource') > -1) {
119
- info = this.infoPerson(json);
120
- }
121
- const output = `
120
+ .then(json => {
121
+ let info;
122
+ if (json.type.indexOf('SubjectHeading') > -1) {
123
+ info = this.infoSubject(json);
124
+ } else if (json.type.indexOf('AuthorityResource') > -1) {
125
+ info = this.infoPerson(json);
126
+ }
127
+ const output = `
122
128
  <h3 class="label">
123
129
  <a href="https://${json.id}" target="_blank"> ${json.preferredName} </a>
124
130
  </h3>
125
131
  ${info}
126
132
  `;
127
- container.innerHTML = output;
128
- resolve({
129
- id: this._prefix ? `${this._prefix}-${json.gndIdentifier}` : json.gndIdentifier,
130
- strings: [json.preferredName].concat(json.variantName)
131
- });
132
- })
133
- .catch(() => reject());
133
+ container.innerHTML = output;
134
+ resolve({
135
+ id: this._prefix ? `${this._prefix}-${json.gndIdentifier}` : json.gndIdentifier,
136
+ strings: [json.preferredName].concat(json.variantName),
137
+ });
138
+ })
139
+ .catch(() => reject());
134
140
  });
135
141
  }
136
142
 
137
143
  infoPerson(json) {
138
- const professions = json.professionOrOccuption ? json.professionOrOccupation.map((prof) => prof.label) : [];
144
+ const professions = json.professionOrOccuption
145
+ ? json.professionOrOccupation.map(prof => prof.label)
146
+ : [];
139
147
  return `<p>${json.dateOfBirth} - ${json.dateOfDeath}</p>
140
148
  <p>${professions.join(' ')}</p>`;
141
149
  }
142
150
 
143
151
  infoSubject(json) {
144
152
  if (json.broaderTermGeneral) {
145
- const terms = json.broaderTermGeneral.map((term) => term.label);
153
+ const terms = json.broaderTermGeneral.map(term => term.label);
146
154
  return `<p>${terms.join(', ')}</p>`;
147
155
  }
148
156
  return '';
@@ -1,156 +1,158 @@
1
- import { internalProperty } from "lit-element";
2
- import { Registry } from "./registry.js";
1
+ import { Registry } from './registry.js';
3
2
 
4
3
  export class KBGA extends Registry {
5
-
6
- constructor(configElem) {
7
- super(configElem);
8
- this._api = configElem.getAttribute('api');
9
- this._limit = configElem.getAttribute('limit') || 999999;
10
- }
4
+ constructor(configElem) {
5
+ super(configElem);
6
+ this._api = configElem.getAttribute('api');
7
+ this._limit = configElem.getAttribute('limit') || 999999;
8
+ }
11
9
 
12
- async query(key) {
13
- const results = [];
14
-
15
- const register = this.getRegister();
16
- const searchParam = register === 'bibls' ? 'biblsearch' : 'search';
17
- const url = `https://meta.karl-barth.ch/api/${register}?${searchParam}=${encodeURIComponent(key)}&perPage=${this._limit}`;
18
- const label = this.getLabelField();
19
- return new Promise((resolve) => {
20
- fetch(url)
21
- .then(response => response.json())
22
- .then(json => {
23
- json.data.forEach(item => {
24
-
25
- if ((this._register === 'organization' && item.authority_type !== 'organisation') ||
26
- (this._register === 'person' && item.authority_type !== 'person')) {
27
- return;
28
- }
29
- const result = {
30
- register: this._register,
31
- id: (this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id']),
32
- label: typeof label === "string" ? item[label] : label(item),
33
- details: `${item['full-id']}`,
34
- link: `https://meta.karl-barth.ch/${register}/${item.id}`,
35
- strings: [typeof label === "string" ? item[label] : label(item)],
36
- provider: 'KBGA'
37
- };
38
- results.push(result);
39
- });
40
- resolve({
41
- totalItems: json.meta.total,
42
- items: results,
43
- });
44
- });
45
- })
46
- }
10
+ async query(key) {
11
+ const results = [];
47
12
 
48
- info(key, container) {
49
- if (!key) {
50
- return Promise.resolve({});
51
- }
52
- const label = this.getLabelField();
53
- return new Promise((resolve) => {
54
- this.getRecord(key)
13
+ const register = this.getRegister();
14
+ const searchParam = register === 'bibls' ? 'biblsearch' : 'search';
15
+ const url = `https://meta.karl-barth.ch/api/${register}?${searchParam}=${encodeURIComponent(
16
+ key,
17
+ )}&perPage=${this._limit}`;
18
+ const label = this.getLabelField();
19
+ return new Promise(resolve => {
20
+ fetch(url)
21
+ .then(response => response.json())
55
22
  .then(json => {
56
- const died = json.data.death ? `† ${json.data.death}` : '';
57
- const dates = json.data.birth ? `<p>* ${json.data.birth} ${died}</p>` : '';
58
- const note = json.data.note_bio ? `<p>${json.data.note_bio}</p>` : '';
59
- const output = `
60
- <h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${typeof label === 'string' ? json.data[label] : label(json.data)}</a></h3>
23
+ json.data.forEach(item => {
24
+ if (
25
+ (this._register === 'organization' && item.authority_type !== 'organisation') ||
26
+ (this._register === 'person' && item.authority_type !== 'person')
27
+ ) {
28
+ return;
29
+ }
30
+ const result = {
31
+ register: this._register,
32
+ id: this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id'],
33
+ label: typeof label === 'string' ? item[label] : label(item),
34
+ details: `${item['full-id']}`,
35
+ link: `https://meta.karl-barth.ch/${register}/${item.id}`,
36
+ strings: [typeof label === 'string' ? item[label] : label(item)],
37
+ provider: 'KBGA',
38
+ };
39
+ results.push(result);
40
+ });
41
+ resolve({
42
+ totalItems: json.meta.total,
43
+ items: results,
44
+ });
45
+ });
46
+ });
47
+ }
48
+
49
+ info(key, container) {
50
+ if (!key) {
51
+ return Promise.resolve({});
52
+ }
53
+ const label = this.getLabelField();
54
+ return new Promise(resolve => {
55
+ this.getRecord(key).then(json => {
56
+ const died = json.data.death ? `† ${json.data.death}` : '';
57
+ const dates = json.data.birth ? `<p>* ${json.data.birth} ${died}</p>` : '';
58
+ const note = json.data.note_bio ? `<p>${json.data.note_bio}</p>` : '';
59
+ const output = `
60
+ <h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${
61
+ typeof label === 'string' ? json.data[label] : label(json.data)
62
+ }</a></h3>
61
63
  ${dates}
62
64
  ${note}
63
65
  `;
64
- container.innerHTML = output;
65
- resolve({
66
- id: json.data['full-id'],
67
- strings: [typeof label === 'string' ? json.data[label] : label(json.data)]
68
- });
66
+ container.innerHTML = output;
67
+ resolve({
68
+ id: json.data['full-id'],
69
+ strings: [typeof label === 'string' ? json.data[label] : label(json.data)],
69
70
  });
70
71
  });
71
- }
72
+ });
73
+ }
72
74
 
73
- /**
75
+ /**
74
76
  * Retrieve a raw JSON record for the given key as returned by the endpoint.
75
- *
77
+ *
76
78
  * @param {string} key the key to look up
77
79
  * @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
78
80
  */
79
81
  async getRecord(key) {
80
- const id = key.replace(/^.*-([^-]+)$/, '$1')
82
+ const id = key.replace(/^.*-([^-]+)$/, '$1');
81
83
  return fetch(`https://meta.karl-barth.ch/api/${this.getRegister()}/${id}`)
82
- .then(response => response.json())
83
- .then(json => {
84
- const output = Object.assign({}, json);
85
- output.name = json.data[this.getLabelField()];
86
- switch (this._register) {
87
- case 'place':
88
- output.country = json.data.country;
89
- output.location = json.data.location.coordinates;
90
- output.links = json.data.links.map((link) => link.url);
91
- break;
92
- case 'person':
93
- output.birth = json.data.birth;
94
- output.death = json.data.death;
95
- output.note = json.data.note_bio;
96
- output.links = [`https://${json.wikipediaURL}`];
97
- break;
98
- default:
99
- break;
100
- }
101
- return output;
102
- })
103
- .catch((reason) => Promise.reject(reason));
104
- }
105
-
106
- getLabelField() {
107
- let label;
108
- switch (this._register) {
84
+ .then(response => response.json())
85
+ .then(json => {
86
+ const output = { ...json };
87
+ output.name = json.data[this.getLabelField()];
88
+ switch (this._register) {
109
89
  case 'place':
110
- label = 'placeName_full';
111
- break;
112
- case 'term':
113
- label = 'fullLabel';
114
- break;
115
- case 'abbreviation':
116
- label = 'label';
117
- break;
118
- case 'bibl':
119
- case 'songs':
120
- label = 'asHtml';
121
- break;
90
+ output.country = json.data.country;
91
+ output.location = json.data.location.coordinates;
92
+ output.links = json.data.links.map(link => link.url);
93
+ break;
94
+ case 'person':
95
+ output.birth = json.data.birth;
96
+ output.death = json.data.death;
97
+ output.note = json.data.note_bio;
98
+ output.links = [`https://${json.wikipediaURL}`];
99
+ break;
122
100
  default:
123
- label = 'persName_full';
124
- break;
125
- }
126
- return label;
101
+ break;
102
+ }
103
+ return output;
104
+ })
105
+ .catch(reason => Promise.reject(reason));
106
+ }
107
+
108
+ getLabelField() {
109
+ let label;
110
+ switch (this._register) {
111
+ case 'place':
112
+ label = 'placeName_full';
113
+ break;
114
+ case 'term':
115
+ label = 'fullLabel';
116
+ break;
117
+ case 'abbreviation':
118
+ label = 'label';
119
+ break;
120
+ case 'bibl':
121
+ case 'songs':
122
+ label = 'asHtml';
123
+ break;
124
+ default:
125
+ label = 'persName_full';
126
+ break;
127
127
  }
128
+ return label;
129
+ }
128
130
 
129
- getRegister() {
130
- if (this._api) {
131
- return this._api;
132
- }
133
- let register;
134
- switch(this._register) {
135
- case 'person':
136
- case 'organization':
137
- register = 'actors';
138
- break;
139
- case 'place':
140
- register = 'places';
141
- break;
142
- case 'term':
143
- register = 'terms';
144
- break;
145
- case 'abbreviation':
146
- register = 'abbreviations';
147
- break;
148
- case 'bibl':
149
- register = 'bibls';
150
- break;
151
- default:
152
- register = this._register;
153
- }
154
- return register;
131
+ getRegister() {
132
+ if (this._api) {
133
+ return this._api;
155
134
  }
156
- }
135
+ let register;
136
+ switch (this._register) {
137
+ case 'person':
138
+ case 'organization':
139
+ register = 'actors';
140
+ break;
141
+ case 'place':
142
+ register = 'places';
143
+ break;
144
+ case 'term':
145
+ register = 'terms';
146
+ break;
147
+ case 'abbreviation':
148
+ register = 'abbreviations';
149
+ break;
150
+ case 'bibl':
151
+ register = 'bibls';
152
+ break;
153
+ default:
154
+ register = this._register;
155
+ }
156
+ return register;
157
+ }
158
+ }
@@ -2,42 +2,40 @@
2
2
  import { Registry } from './registry.js';
3
3
 
4
4
  export class Metagrid extends Registry {
5
-
6
5
  async query(key) {
7
6
  const query = key.replace(/[^\w\s]+/g, '');
8
7
  const results = [];
9
8
  const url = `https://api.metagrid.ch/search?query=${encodeURIComponent(query)}`;
10
-
11
- return new Promise((resolve) => {
12
- fetch(url)
13
- .then((response) => response.json())
14
- .then((json) => {
15
- json.resources.forEach(item => {
16
- const name = `${item.metadata.last_name}, ${item.metadata.first_name} `;
17
- const result = {
18
- register: this._register,
19
- id: `${item.provider.slug}-${item.identifier}`,
20
- label: name,
21
- details: `${item.metadata.birth_date} - ${item.metadata.death_date}`,
22
- link: item.link.uri,
23
- provider: item.provider.slug
24
- };
25
- results.push(result);
26
- });
27
- resolve({
28
- totalItems: json.meta.total,
29
- items: results,
30
- });
9
+
10
+ return new Promise(resolve => {
11
+ fetch(url)
12
+ .then(response => response.json())
13
+ .then(json => {
14
+ json.resources.forEach(item => {
15
+ const name = `${item.metadata.last_name}, ${item.metadata.first_name} `;
16
+ const result = {
17
+ register: this._register,
18
+ id: `${item.provider.slug}-${item.identifier}`,
19
+ label: name,
20
+ details: `${item.metadata.birth_date} - ${item.metadata.death_date}`,
21
+ link: item.link.uri,
22
+ provider: item.provider.slug,
23
+ };
24
+ results.push(result);
25
+ });
26
+ resolve({
27
+ totalItems: json.meta.total,
28
+ items: results,
29
+ });
31
30
  });
32
- })
31
+ });
33
32
  }
34
33
 
35
34
  info(key, container) {
36
35
  const p = key.indexOf('-');
37
36
  const slug = key.substring(0, p);
38
- return new Promise((resolve) => {
39
- this.getRecord(key)
40
- .then(json => {
37
+ return new Promise(resolve => {
38
+ this.getRecord(key).then(json => {
41
39
  const output = `
42
40
  <h3 class="label">
43
41
  <a href="https://${json.link.uri}" target="_blank">
@@ -49,37 +47,37 @@ export class Metagrid extends Registry {
49
47
  container.innerHTML = output;
50
48
  resolve({
51
49
  id: `${slug}-${json.identifier}`,
52
- strings: [`${json.metadata.first_name} ${json.metadata.last_name}`]
53
- })
50
+ strings: [`${json.metadata.first_name} ${json.metadata.last_name}`],
51
+ });
54
52
  });
55
53
  });
56
54
  }
57
55
 
58
56
  /**
59
57
  * Retrieve a raw JSON record for the given key as returned by the endpoint.
60
- *
58
+ *
61
59
  * @param {string} key the key to look up
62
60
  * @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
63
61
  */
64
- async getRecord(key) {
62
+ async getRecord(key) {
65
63
  const p = key.indexOf('-');
66
64
  const slug = key.substring(0, p);
67
65
  const id = key.substring(p + 1);
68
66
  return fetch(`https://api.metagrid.ch/search?slug=${slug}&query=${id}`)
69
- .then(response => response.json())
70
- .then(json => {
71
- const item = json.resources[0];
72
- const output = Object.assign({}, item);
73
- output.name = `${item.metadata.first_name} ${item.metadata.last_name}`;
74
- output.links = [`https://${item.link.uri}`];
75
- if (item.metadata.birth_date && item.metadata.birth_date.length > 0) {
76
- output.birth = item.metadata.birth_date;
77
- }
78
- if (item.metadata.death_date && item.metadata.death_date.length > 0) {
79
- output.death = item.metadata.death_date;
80
- }
81
- return output;
82
- })
83
- .catch((reason) => Promise.reject(reason));
84
- }
67
+ .then(response => response.json())
68
+ .then(json => {
69
+ const item = json.resources[0];
70
+ const output = { ...item };
71
+ output.name = `${item.metadata.first_name} ${item.metadata.last_name}`;
72
+ output.links = [`https://${item.link.uri}`];
73
+ if (item.metadata.birth_date && item.metadata.birth_date.length > 0) {
74
+ output.birth = item.metadata.birth_date;
75
+ }
76
+ if (item.metadata.death_date && item.metadata.death_date.length > 0) {
77
+ output.death = item.metadata.death_date;
78
+ }
79
+ return output;
80
+ })
81
+ .catch(reason => Promise.reject(reason));
82
+ }
85
83
  }