@teipublisher/pb-components 2.26.1-next.3 → 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 +346 -11
  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-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
package/src/dts-client.js CHANGED
@@ -1,361 +1,364 @@
1
- import { LitElement, html, css } from 'lit-element';
1
+ import { LitElement, html, css } from 'lit';
2
2
  import { pbMixin } from './pb-mixin.js';
3
3
  import { translate } from './pb-i18n.js';
4
4
  import { registry } from './urls.js';
5
-
6
- import '@polymer/iron-ajax';
7
- import '@polymer/iron-icon';
8
- import '@polymer/iron-icons';
9
- import '@polymer/paper-button';
5
+ import './pb-icon.js';
6
+ import './pb-fetch.js';
10
7
 
11
8
  /**
12
9
  * A client for the Distributed Text Services (DTS) protocol. This defines an API
13
10
  * for working with collections of text.
14
- *
15
- *
11
+ *
12
+ *
16
13
  * @slot toolbar - toolbar area
17
14
  * @slot pagination - pagination area
18
- *
15
+ *
19
16
  * @csspart parent-link - Link to parent collection
20
17
  * @csspart collection-title - Collection title
21
18
  * @csspart title - Member title
22
19
  * @csspart author - Author
23
20
  * @csspart license - License information
24
21
  * @csspart link - Links
25
- *
22
+ *
26
23
  * @fires pb-start-update - Fired before the element updates its content
27
24
  * @fires pb-results-received - Fired when results are received from the server
28
25
  * @fires pb-end-update - Fired after the element has finished updating its content
29
26
  * @fires dts-endpoint - When received sets the endpoint to the one passed in from the event
30
- * @fires pb-load - When received triggers the refresh accorting to the selected page
27
+ * @fires pb-load - When received triggers the refresh accorting to the selected page
31
28
  */
32
29
  export class DtsClient extends pbMixin(LitElement) {
33
- static get properties() {
34
- return {
35
- ...super.properties,
36
- baseUri: {
37
- type: String
38
- },
39
- data: {
40
- type: Object
41
- },
42
- collection: {
43
- type: String
44
- },
45
- page: {
46
- type: Number
47
- },
48
- perPage: {
49
- type: Number
50
- },
51
- _collectionEndpoint: {
52
- type: String
53
- }
54
- };
55
- }
30
+ static get properties() {
31
+ return {
32
+ ...super.properties,
33
+ baseUri: {
34
+ type: String,
35
+ },
36
+ data: {
37
+ type: Object,
38
+ },
39
+ collection: {
40
+ type: String,
41
+ },
42
+ page: {
43
+ type: Number,
44
+ },
45
+ perPage: {
46
+ type: Number,
47
+ },
48
+ _collectionEndpoint: {
49
+ type: String,
50
+ },
51
+ };
52
+ }
56
53
 
57
- constructor() {
58
- super();
59
- this._parentCollections = [];
60
- this.collection = 'default';
61
- }
54
+ constructor() {
55
+ super();
56
+ this._parentCollections = [];
57
+ this.collection = 'default';
58
+ }
62
59
 
63
- connectedCallback() {
64
- super.connectedCallback();
60
+ connectedCallback() {
61
+ super.connectedCallback();
65
62
 
66
- this.collection = registry.state.id;
67
- this.page = registry.state.page;
63
+ this.collection = registry.state.id;
64
+ this.page = registry.state.page;
68
65
 
69
- this.subscribeTo('dts-endpoint', (ev) => {
70
- this._setEndpoint(ev.detail.endpoint, ev.detail.collection, ev.detail.reload);
71
- });
72
- this.subscribeTo('pb-load', (ev) => {
73
- this.page = ev.detail.params.page;
74
- console.log('<dts-client> Loading page %d', this.page);
75
- this._update();
76
- });
77
- }
66
+ this.subscribeTo('dts-endpoint', ev => {
67
+ this._setEndpoint(ev.detail.endpoint, ev.detail.collection, ev.detail.reload);
68
+ });
69
+ this.subscribeTo('pb-load', ev => {
70
+ this.page = ev.detail.params.page;
71
+ console.log('<dts-client> Loading page %d', this.page);
72
+ this._update();
73
+ });
74
+ }
78
75
 
79
- firstUpdated() {
80
- super.firstUpdated();
76
+ firstUpdated() {
77
+ super.firstUpdated();
81
78
 
82
- this.queryAPI = this.shadowRoot.getElementById('queryAPI');
83
- this.documentsAPI = this.shadowRoot.getElementById('documentsAPI');
84
- this.signalReady();
85
- }
79
+ this.queryAPI = this.shadowRoot.getElementById('queryAPI');
80
+ this.documentsAPI = this.shadowRoot.getElementById('documentsAPI');
81
+ this.signalReady();
82
+ }
86
83
 
87
- _setEndpoint(endpoint, collection, reload) {
88
- if (!reload) {
89
- this.page = null;
90
- }
91
- this.collection = collection;
92
- this._configureEndpoint(endpoint);
93
- this.baseUri = endpoint;
84
+ _setEndpoint(endpoint, collection, reload) {
85
+ if (!reload) {
86
+ this.page = null;
94
87
  }
88
+ this.collection = collection;
89
+ this._configureEndpoint(endpoint);
90
+ this.baseUri = endpoint;
91
+ }
95
92
 
96
- _configureEndpoint(newBaseUri) {
97
- if (newBaseUri) {
98
- console.log('<dts-client> initializing connection to endpoint %s', newBaseUri);
99
- this.emitTo('pb-start-update');
100
- this.queryAPI.url = newBaseUri;
101
- this.queryAPI.generateRequest();
102
- }
93
+ _configureEndpoint(newBaseUri) {
94
+ if (newBaseUri) {
95
+ console.log('<dts-client> initializing connection to endpoint %s', newBaseUri);
96
+ this.emitTo('pb-start-update');
97
+ this.queryAPI.url = newBaseUri;
98
+ this.queryAPI.generateRequest();
103
99
  }
100
+ }
104
101
 
105
- _navigate(ev, member, downwards = true) {
106
- ev.preventDefault();
107
- if (downwards) {
108
- this._parentCollections.push(this.collection);
109
- }
110
- this.collection = member && typeof member === 'object' ? member['@id'] : member;
111
- this.page = null;
112
- console.log('<dts-client> navigating to collection %s', this.collection);
113
- this._update();
102
+ _navigate(ev, member, downwards = true) {
103
+ ev.preventDefault();
104
+ if (downwards) {
105
+ this._parentCollections.push(this.collection);
114
106
  }
107
+ this.collection = member && typeof member === 'object' ? member['@id'] : member;
108
+ this.page = null;
109
+ console.log('<dts-client> navigating to collection %s', this.collection);
110
+ this._update();
111
+ }
115
112
 
116
- _navigateUp(ev) {
117
- if (this._parentCollections.length === 0) {
118
- return;
119
- }
120
- this._navigate(ev, this._parentCollections.pop(), false);
113
+ _navigateUp(ev) {
114
+ if (this._parentCollections.length === 0) {
115
+ return;
121
116
  }
117
+ this._navigate(ev, this._parentCollections.pop(), false);
118
+ }
122
119
 
123
- _preview(ev, member) {
124
- ev.preventDefault();
125
- this.emitTo('pb-start-update');
126
- const path = member['dts:passage'] || member['dts:download'];
127
- const url = new URL(path, this.baseUri).toString();
128
- console.log('<dts-client> downloading %s', url);
129
- if (this.lessThanApiVersion('1.0.0')) {
130
- this.documentsAPI.url = `${this.getEndpoint()}/modules/lib/dts.xql`;
131
- this.documentsAPI.params = {
132
- 'preview': url,
133
- 'id': member['@id']
134
- };
135
- } else {
136
- this.documentsAPI.url = `${this.getEndpoint()}/api/dts/import`;
137
- this.documentsAPI.params = {
138
- uri: url,
139
- temp: true
140
- };
141
- }
142
- this.documentsAPI.generateRequest();
120
+ _preview(ev, member) {
121
+ ev.preventDefault();
122
+ this.emitTo('pb-start-update');
123
+ const path = member['dts:passage'] || member['dts:download'];
124
+ const url = new URL(path, this.baseUri).toString();
125
+ console.log('<dts-client> downloading %s', url);
126
+ if (this.lessThanApiVersion('1.0.0')) {
127
+ this.documentsAPI.url = `${this.getEndpoint()}/modules/lib/dts.xql`;
128
+ this.documentsAPI.params = {
129
+ preview: url,
130
+ id: member['@id'],
131
+ };
132
+ } else {
133
+ this.documentsAPI.url = `${this.getEndpoint()}/api/dts/import`;
134
+ this.documentsAPI.params = {
135
+ uri: url,
136
+ temp: true,
137
+ };
143
138
  }
139
+ this.documentsAPI.generateRequest();
140
+ }
144
141
 
145
- _download(ev, member) {
146
- this.emitTo('pb-start-update');
147
- const path = member['dts:passage'] || member['dts:download'];
148
- const url = new URL(path, this.baseUri).toString();
149
- console.log('<dts-client> importing %s', url);
150
- if (this.lessThanApiVersion('1.0.0')) {
151
- this.documentsAPI.url = `${this.getEndpoint()}/modules/lib/dts.xql`;
152
- this.documentsAPI.params = {
153
- 'import': url,
154
- 'id': member['@id']
155
- };
156
- } else {
157
- this.documentsAPI.url = `${this.getEndpoint()}/api/dts/import`;
158
- this.documentsAPI.params = {
159
- uri: url,
160
- temp: false
161
- };
162
- }
163
- this.documentsAPI.generateRequest();
142
+ _download(ev, member) {
143
+ this.emitTo('pb-start-update');
144
+ const path = member['dts:passage'] || member['dts:download'];
145
+ const url = new URL(path, this.baseUri).toString();
146
+ console.log('<dts-client> importing %s', url);
147
+ if (this.lessThanApiVersion('1.0.0')) {
148
+ this.documentsAPI.url = `${this.getEndpoint()}/modules/lib/dts.xql`;
149
+ this.documentsAPI.params = {
150
+ import: url,
151
+ id: member['@id'],
152
+ };
153
+ } else {
154
+ this.documentsAPI.url = `${this.getEndpoint()}/api/dts/import`;
155
+ this.documentsAPI.params = {
156
+ uri: url,
157
+ temp: false,
158
+ };
164
159
  }
160
+ this.documentsAPI.generateRequest();
161
+ }
165
162
 
166
- _update() {
167
- this.emitTo('pb-start-update');
168
- const newState = {};
169
- if (this.collection) {
170
- newState.id = this.collection;
171
- }
172
- if (this.page) {
173
- newState.page = this.page + 1;
174
- }
175
- registry.commit(this, newState);
176
-
177
- this.queryAPI.params = newState;
178
- this.queryAPI.url = this._collectionEndpoint;
179
- this.queryAPI.generateRequest();
163
+ _update() {
164
+ this.emitTo('pb-start-update');
165
+ const newState = {};
166
+ if (this.collection) {
167
+ newState.id = this.collection;
180
168
  }
169
+ if (this.page) {
170
+ newState.page = this.page + 1;
171
+ }
172
+ registry.commit(this, newState);
181
173
 
182
- _handleResponse() {
183
- const json = this.queryAPI.lastResponse;
184
- if (json['@type'] === 'EntryPoint') {
185
- this._collectionEndpoint = new URL(json.collections, this.baseUri).toString();
186
- console.log('<dts-client> configured collection endpoint: %s', this._collectionEndpoint);
174
+ this.queryAPI.params = newState;
175
+ this.queryAPI.url = this._collectionEndpoint;
176
+ this.queryAPI.generateRequest();
177
+ }
187
178
 
188
- this._update();
189
- } else {
190
- this.data = json;
191
- console.log('<dts-client> received collection data: %o', json);
192
- if (!this.page && json.totalItems > json.member.length) {
193
- this.perPage = json.member.length;
194
- }
195
- this.emitTo('pb-results-received', {
196
- start: this.page && this.page > 0 ? this.page * this.perPage + 1 : 1,
197
- count: json.totalItems
198
- });
199
- }
200
- this.emitTo('pb-end-update');
201
- }
179
+ _handleResponse() {
180
+ const json = this.queryAPI.lastResponse;
181
+ if (json['@type'] === 'EntryPoint') {
182
+ this._collectionEndpoint = new URL(json.collections, this.baseUri).toString();
183
+ console.log('<dts-client> configured collection endpoint: %s', this._collectionEndpoint);
202
184
 
203
- _handlePreview() {
204
- const json = this.documentsAPI.lastResponse;
205
- this.emitTo('pb-end-update');
206
- const url = new URL(json.path, window.location.href);
207
- // use registry here?
208
- window.location.replace(url);
185
+ this._update();
186
+ } else {
187
+ this.data = json;
188
+ console.log('<dts-client> received collection data: %o', json);
189
+ if (!this.page && json.totalItems > json.member.length) {
190
+ this.perPage = json.member.length;
191
+ }
192
+ this.emitTo('pb-results-received', {
193
+ start: this.page && this.page > 0 ? this.page * this.perPage + 1 : 1,
194
+ count: json.totalItems,
195
+ });
209
196
  }
197
+ this.emitTo('pb-end-update');
198
+ }
210
199
 
211
- _handleError(ev) {
212
- this.emitTo('pb-end-update');
213
- const msg = ev.target.lastError.response;
214
- const parser = new DOMParser();
215
- const doc = parser.parseFromString(msg, "application/xml");
216
- const node = doc.querySelector('message');
200
+ _handlePreview() {
201
+ const json = this.documentsAPI.lastResponse;
202
+ this.emitTo('pb-end-update');
203
+ const url = new URL(json.path, window.location.href);
204
+ // use registry here?
205
+ window.location.replace(url);
206
+ }
217
207
 
218
- const dialog = document.getElementById('errorDialog');
219
- const body = dialog.querySelector("paper-dialog-scrollable");
220
- if (node) {
221
- body.innerHTML = node.textContent;
222
- } else {
223
- body.innerHTML = ev.detail.error.message;
224
- }
225
- dialog.open();
226
- }
208
+ _handleError(ev) {
209
+ this.emitTo('pb-end-update');
210
+ const msg = ev.target.lastError.response;
211
+ const parser = new DOMParser();
212
+ const doc = parser.parseFromString(msg, 'application/xml');
213
+ const node = doc.querySelector('message');
227
214
 
228
- static _getCreator(item) {
229
- const dc = item['dts:dublincore'];
230
- return dc ? dc['dc:creator'] : null;
215
+ const dialog = document.getElementById('errorDialog');
216
+ const body = dialog.querySelector('paper-dialog-scrollable');
217
+ if (node) {
218
+ body.innerHTML = node.textContent;
219
+ } else {
220
+ body.innerHTML = ev.detail.error.message;
231
221
  }
222
+ dialog.open();
223
+ }
232
224
 
233
- static _getLicense(item) {
234
- const dc = item['dts:dublincore'];
235
- return dc ? dc['dc:license'] : null;
236
- }
225
+ static _getCreator(item) {
226
+ const dc = item['dts:dublincore'];
227
+ return dc ? dc['dc:creator'] : null;
228
+ }
237
229
 
238
- render() {
239
- return html`
240
- <slot name="toolbar"></slot>
241
- ${this.baseUri ? this._renderClient() : ''}
242
-
243
- <iron-ajax
244
- id="queryAPI"
245
- verbose
246
- handle-as="json"
247
- method="get"
248
- @response="${this._handleResponse}"
249
- @error="${this._handleError}"></iron-ajax>
250
- <iron-ajax
251
- id="documentsAPI"
252
- verbose
253
- handle-as="json"
254
- method="get"
255
- @response="${this._handlePreview}"
256
- @error="${this._handleError}"></iron-ajax>
257
- `;
258
- }
230
+ static _getLicense(item) {
231
+ const dc = item['dts:dublincore'];
232
+ return dc ? dc['dc:license'] : null;
233
+ }
259
234
 
260
- _renderClient() {
261
- return html`
262
- <div class="uri">${this.baseUri}</div>
263
- <h3 part="collection-title">${this.data ? this.data.title : 'Loading ...'}</h3>
264
- <slot name="pagination"></slot>
265
- ${
266
- this._parentCollections.length > 0 || this.collection ?
267
- html`
268
- <paper-button part="parent-link" @click="${this._navigateUp}">
269
- <iron-icon icon="icons:arrow-upward"></iron-icon>
270
- ${translate('browse.up')}
271
- </paper-button>`
272
- : null
273
- }
274
- ${this.data ? this._renderMembers() : ''}
275
- `;
276
- }
235
+ render() {
236
+ return html`
237
+ <slot name="toolbar"></slot>
238
+ ${this.baseUri ? this._renderClient() : ''}
277
239
 
278
- _renderMembers() {
279
- const members = [];
280
- this.data.member.forEach((member) => {
281
- members.push(html`<div class="member">${this._renderMember(member)}</div>`);
282
- });
283
- return members;
284
- }
240
+ <pb-fetch
241
+ id="queryAPI"
242
+ verbose
243
+ handle-as="json"
244
+ method="get"
245
+ @response="${this._handleResponse}"
246
+ @error="${this._handleError}"
247
+ ></pb-fetch>
248
+ <pb-fetch
249
+ id="documentsAPI"
250
+ verbose
251
+ handle-as="json"
252
+ method="get"
253
+ @response="${this._handlePreview}"
254
+ @error="${this._handleError}"
255
+ ></pb-fetch>
256
+ `;
257
+ }
285
258
 
286
- _renderMember(member) {
287
- if (member['@type'] === 'Collection') {
288
- return html`
289
- <iron-icon icon="icons:folder-open"></iron-icon>
290
- <div class="details">
291
- <a href="#" @click="${(ev) => this._navigate(ev, member)}" part="link">
292
- <h4 class="collection" part="collection-title">
293
- ${member.title}
294
- </h4>
295
- </a>
296
- </div>
297
- `;
298
- }
299
- const license = DtsClient._getLicense(member);
300
- return html`
301
- <iron-icon icon="icons:code"></iron-icon>
302
- <div class="details">
303
- <div>
304
- <a href="#" @click="${(ev) => this._preview(ev, member)}" part="link">
305
- <h4 part="title">
306
- ${member.title}
307
- </h4>
308
- </a>
309
- <p part="creator" class="creator">${DtsClient._getCreator(member)}</p>
310
- ${license ? html`<p part="license" class="license"><a href="${license}">${translate('dts.licence')}</a></p>` : ''}
311
- </div>
312
- <iron-icon title="${translate('dts.import')}" icon="icons:file-download"
313
- @click="${(ev) => this._download(ev, member)}">
314
- </iron-icon>
315
- </div>
316
- `;
317
- }
259
+ _renderClient() {
260
+ return html`
261
+ <div class="uri">${this.baseUri}</div>
262
+ <h3 part="collection-title">${this.data ? this.data.title : 'Loading ...'}</h3>
263
+ <slot name="pagination"></slot>
264
+ ${this._parentCollections.length > 0 || this.collection
265
+ ? html` <button
266
+ part="parent-link"
267
+ class="pb-button pb-button--text"
268
+ type="button"
269
+ @click="${this._navigateUp}"
270
+ >
271
+ <pb-icon icon="icons:arrow-upward" decorative></pb-icon>
272
+ ${translate('browse.up')}
273
+ </button>`
274
+ : null}
275
+ ${this.data ? this._renderMembers() : ''}
276
+ `;
277
+ }
318
278
 
319
- static get styles() {
320
- return css`
321
- :host {
322
- display: block;
323
- }
279
+ _renderMembers() {
280
+ const members = [];
281
+ this.data.member.forEach(member => {
282
+ members.push(html`<div class="member">${this._renderMember(member)}</div>`);
283
+ });
284
+ return members;
285
+ }
324
286
 
325
- .uri {
326
- color: #607d8a;
327
- margin-top: 12px;
328
- font-weight: bold;
329
- }
330
- h3 {
331
- margin-top: 0;
332
- }
333
- .member {
334
- display: flex;
335
- }
336
- .member .details {
337
- flex: 2;
338
- margin-left: 20px;
339
- display: flex;
340
- justify-content: space-between;
341
- }
342
- .member iron-icon {
343
- width: 24px;
344
- }
345
- .member h4 {
346
- margin: 0;
347
- }
348
- .member h4.collection {
349
- margin-bottom: 10px;
350
- }
351
- [name='toolbar'] {
352
- display: flex;
353
- justify-content: space-between;
354
- align-items: center;
355
- color: #f6a622;
356
- font-size: 85%;
357
- }
358
- `;
287
+ _renderMember(member) {
288
+ if (member['@type'] === 'Collection') {
289
+ return html`
290
+ <pb-icon icon="icons:folder-open" decorative></pb-icon>
291
+ <div class="details">
292
+ <button @click="${ev => this._navigate(ev, member)}" part="link" type="button">
293
+ <h4 class="collection" part="collection-title">${member.title}</h4>
294
+ </button>
295
+ </div>
296
+ `;
359
297
  }
298
+ const license = DtsClient._getLicense(member);
299
+ return html`
300
+ <pb-icon icon="icons:code" decorative></pb-icon>
301
+ <div class="details">
302
+ <div>
303
+ <button @click="${ev => this._preview(ev, member)}" part="link" type="button">
304
+ <h4 part="title">${member.title}</h4>
305
+ </button>
306
+ <p part="creator" class="creator">${DtsClient._getCreator(member)}</p>
307
+ ${license
308
+ ? html`<p part="license" class="license">
309
+ <a href="${license}">${translate('dts.licence')}</a>
310
+ </p>`
311
+ : ''}
312
+ </div>
313
+ <pb-icon
314
+ title="${translate('dts.import')}"
315
+ icon="icons:file-download"
316
+ @click="${ev => this._download(ev, member)}"
317
+ ></pb-icon>
318
+ </div>
319
+ `;
320
+ }
321
+
322
+ static get styles() {
323
+ return css`
324
+ :host {
325
+ display: block;
326
+ }
327
+
328
+ .uri {
329
+ color: #607d8a;
330
+ margin-top: 12px;
331
+ font-weight: bold;
332
+ }
333
+ h3 {
334
+ margin-top: 0;
335
+ }
336
+ .member {
337
+ display: flex;
338
+ }
339
+ .member .details {
340
+ flex: 2;
341
+ margin-left: 20px;
342
+ display: flex;
343
+ justify-content: space-between;
344
+ }
345
+ .member pb-icon {
346
+ width: 24px;
347
+ }
348
+ .member h4 {
349
+ margin: 0;
350
+ }
351
+ .member h4.collection {
352
+ margin-bottom: 10px;
353
+ }
354
+ [name='toolbar'] {
355
+ display: flex;
356
+ justify-content: space-between;
357
+ align-items: center;
358
+ color: #f6a622;
359
+ font-size: 85%;
360
+ }
361
+ `;
362
+ }
360
363
  }
361
- customElements.define('dts-client', DtsClient);
364
+ customElements.define('dts-client', DtsClient);