@teipublisher/pb-components 2.2.0 → 2.3.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 (77) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/demo/bundle-test.html +1 -1
  3. package/dist/demo/dts-client.html +1 -1
  4. package/dist/demo/pb-autocomplete.html +1 -1
  5. package/dist/demo/pb-autocomplete2.html +1 -1
  6. package/dist/demo/pb-blacklab-highlight.html +1 -1
  7. package/dist/demo/pb-blacklab-results.html +1 -1
  8. package/dist/demo/pb-browse-docs.html +1 -1
  9. package/dist/demo/pb-browse-docs2.html +1 -1
  10. package/dist/demo/pb-clipboard.html +1 -1
  11. package/dist/demo/pb-code-editor.html +2 -4
  12. package/dist/demo/pb-collapse.html +1 -1
  13. package/dist/demo/pb-collapse2.html +1 -1
  14. package/dist/demo/pb-combo-box.html +1 -1
  15. package/dist/demo/pb-custom-form.html +1 -1
  16. package/dist/demo/pb-document.html +1 -1
  17. package/dist/demo/pb-download.html +1 -1
  18. package/dist/demo/pb-drawer.html +1 -1
  19. package/dist/demo/pb-drawer2.html +1 -1
  20. package/dist/demo/pb-edit-app.html +1 -1
  21. package/dist/demo/pb-edit-xml.html +1 -1
  22. package/dist/demo/pb-facsimile-2.html +1 -1
  23. package/dist/demo/pb-facsimile.html +1 -1
  24. package/dist/demo/pb-formula.html +1 -1
  25. package/dist/demo/pb-grid.html +1 -1
  26. package/dist/demo/pb-image-strip-standalone.html +1 -1
  27. package/dist/demo/pb-image-strip-view.html +1 -1
  28. package/dist/demo/pb-leaflet-map.html +1 -1
  29. package/dist/demo/pb-leaflet-map2.html +1 -1
  30. package/dist/demo/pb-leaflet-map3.html +1 -1
  31. package/dist/demo/pb-link.html +1 -1
  32. package/dist/demo/pb-load.html +1 -1
  33. package/dist/demo/pb-login.html +1 -1
  34. package/dist/demo/pb-manage-odds.html +1 -1
  35. package/dist/demo/pb-markdown.html +1 -1
  36. package/dist/demo/pb-media-query.html +1 -1
  37. package/dist/demo/pb-mei.html +1 -1
  38. package/dist/demo/pb-mei2.html +1 -1
  39. package/dist/demo/pb-odd-editor.html +1 -1
  40. package/dist/demo/pb-popover.html +1 -1
  41. package/dist/demo/pb-print-preview.html +1 -1
  42. package/dist/demo/pb-search.html +1 -1
  43. package/dist/demo/pb-search2.html +1 -1
  44. package/dist/demo/pb-search3.html +1 -1
  45. package/dist/demo/pb-search4.html +1 -1
  46. package/dist/demo/pb-select-feature.html +1 -1
  47. package/dist/demo/pb-select-feature2.html +1 -1
  48. package/dist/demo/pb-select-feature3.html +1 -1
  49. package/dist/demo/pb-select-odd.html +1 -1
  50. package/dist/demo/pb-select.html +1 -1
  51. package/dist/demo/pb-select2.html +1 -1
  52. package/dist/demo/pb-select3.html +1 -1
  53. package/dist/demo/pb-svg.html +1 -1
  54. package/dist/demo/pb-table-grid.html +2 -2
  55. package/dist/demo/pb-tabs.html +1 -1
  56. package/dist/demo/pb-timeline2.html +1 -1
  57. package/dist/demo/pb-toggle-feature.html +1 -1
  58. package/dist/demo/pb-toggle-feature2.html +1 -1
  59. package/dist/demo/pb-toggle-feature3.html +1 -1
  60. package/dist/demo/pb-view.html +1 -1
  61. package/dist/demo/pb-view2.html +1 -1
  62. package/dist/demo/pb-view3.html +1 -1
  63. package/dist/demo/pb-view4.html +1 -1
  64. package/dist/demo/pb-zoom.html +1 -1
  65. package/dist/pb-components-bundle.js +42 -16
  66. package/dist/pb-elements.json +34 -0
  67. package/dist/pb-odd-editor.js +1 -1
  68. package/dist/{vaadin-element-mixin-c9455086.js → vaadin-element-mixin-cef6f588.js} +12 -15
  69. package/package.json +1 -1
  70. package/pb-elements.json +34 -0
  71. package/src/pb-collapse.js +2 -5
  72. package/src/pb-manage-odds.js +38 -10
  73. package/src/pb-page.js +16 -1
  74. package/src/pb-paginate.js +1 -0
  75. package/src/pb-search.js +15 -1
  76. package/src/pb-view.js +3 -3
  77. package/src/urls.js +23 -4
@@ -211,14 +211,15 @@ export class PbManageOdds extends pbMixin(LitElement) {
211
211
  ${this.odds.map((odd) =>
212
212
  html`
213
213
  <div class="odd">
214
- <a href="odd-editor.html?odd=${odd.name}.odd" target="_blank">${odd.label}</a>
214
+ <a href="odd-editor.html?odd=${odd.name}.odd" target="_blank"
215
+ title="edit ODD in graphical editor">${odd.label}</a>
215
216
  <!-- TODO this toolbar should only appear once per ODD files papercard -->
216
217
  <app-toolbar>
217
218
  ${
218
219
  odd.canWrite ?
219
220
  html`
220
221
  <pb-restricted login="login">
221
- <pb-ajax url="${regenUrl}?odd=${odd.name}.odd" method="post"
222
+ <pb-ajax url="${regenUrl}?odd=${odd.name}.odd" method="post"
222
223
  emit="${this.emit ? this.emit : ''}" .emitConfig="${this.emitConfig}">
223
224
  <h2 slot="title">${translate('menu.admin.recompile')}</h2>
224
225
  <paper-icon-button title="Regenerate ODD" icon="update"></paper-icon-button>
@@ -227,8 +228,10 @@ export class PbManageOdds extends pbMixin(LitElement) {
227
228
  </pb-restricted>
228
229
  ` : null
229
230
  }
230
- <pb-edit-xml path="${odd.path}">
231
- <paper-icon-button title="Edit ODD" icon="code"></paper-icon-button>
231
+ <a href="odd-editor.html?odd=${odd.name}.odd" target="_blank" class="editor-link"
232
+ title="edit ODD in graphical editor"><iron-icon icon="reorder"></iron-icon></a>
233
+ <pb-edit-xml path="${odd.path}" class="editor-link">
234
+ <paper-icon-button title="Edit XML" icon="create"></paper-icon-button>
232
235
  </pb-edit-xml>
233
236
  </app-toolbar>
234
237
  </div>
@@ -295,15 +298,19 @@ export class PbManageOdds extends pbMixin(LitElement) {
295
298
  margin-right: 1em;
296
299
  }
297
300
 
298
- .odd a {
301
+ .odd a,
302
+ .odd a:link,
303
+ .odd a:visited{
299
304
  display: block;
300
- flex: 2 0;
305
+ flex: 10 0;
306
+ color:var(--pb-manage-odds-link-color);
301
307
  }
302
308
 
303
309
  .odd app-toolbar {
304
310
  flex: 1 0;
305
- justify-content: flex-end;
306
- padding: 0;
311
+ justify-content: flex-end;
312
+ padding: 0;
313
+ min-height:0.25rem;
307
314
  }
308
315
 
309
316
  pb-restricted {
@@ -313,7 +320,7 @@ export class PbManageOdds extends pbMixin(LitElement) {
313
320
  .odd-description {
314
321
  color: #888888;
315
322
  font-size: 0.8em;
316
- margin-top: -1em;
323
+ margin-bottom: 0.25rem;
317
324
  }
318
325
 
319
326
  #regenerateAll {
@@ -322,7 +329,28 @@ export class PbManageOdds extends pbMixin(LitElement) {
322
329
  margin-top: 10px;
323
330
  text-align: right;
324
331
  }
332
+ [icon]{
333
+ color:var(--pb-manage-odds-icon-color);
334
+ }
335
+
336
+ [icon='reorder']
337
+ {
338
+ width:24px;
339
+ height: 24px;
340
+ }
341
+
342
+ @media (hover:hover) and (pointer: fine){
343
+ .odd app-toolbar .editor-link{
344
+ opacity: 0;
345
+ }
346
+ .odd:hover .editor-link{
347
+ opacity: 1;
348
+ transition: opacity 0.6s;
349
+ }
350
+ }
325
351
  `;
326
352
  }
327
353
  }
328
- customElements.define('pb-manage-odds', PbManageOdds);
354
+ if(!customElements.get('pb-manage-odds')){
355
+ customElements.define('pb-manage-odds', PbManageOdds);
356
+ }
package/src/pb-page.js CHANGED
@@ -39,10 +39,24 @@ export class PbPage extends pbMixin(LitElement) {
39
39
  type: String,
40
40
  attribute: 'app-root'
41
41
  },
42
+ /**
43
+ * Is the resource path part of the URL or should it be
44
+ * encoded as a parameter? TEI Publisher uses the
45
+ * URL path, but the webcomponent demos need to encode the resource path
46
+ * in a query parameter.
47
+ */
42
48
  urlPath: {
43
49
  type: String,
44
50
  attribute: 'url-path'
45
51
  },
52
+ /**
53
+ * If enabled, a hash in the URL (e.g. documentation.xml#introduction) will
54
+ * be interpreted as an xml:id to navigate to when talking to the server.
55
+ */
56
+ idHash: {
57
+ type: Boolean,
58
+ attribute: 'id-hash'
59
+ },
46
60
  /**
47
61
  * TEI Publisher internal: set to the current page template.
48
62
  */
@@ -148,6 +162,7 @@ export class PbPage extends pbMixin(LitElement) {
148
162
  this.unresolved = true;
149
163
  this.endpoint = ".";
150
164
  this.urlPath = 'path';
165
+ this.idHash = false;
151
166
  this.apiVersion = undefined;
152
167
  this.requireLanguage = false;
153
168
  this.theme = null;
@@ -189,7 +204,7 @@ export class PbPage extends pbMixin(LitElement) {
189
204
  this.appRoot = window.location.pathname;
190
205
  }
191
206
 
192
- registry.configure(this.urlPath === 'path', this.appRoot);
207
+ registry.configure(this.urlPath === 'path', this.idHash, this.appRoot);
193
208
 
194
209
  this.endpoint = this.endpoint.replace(/\/+$/, '');
195
210
 
@@ -10,6 +10,7 @@ import { translate } from "./pb-i18n.js";
10
10
  * which should cause the connected `pb-load` element to refresh.
11
11
  *
12
12
  * @fires pb-load - Fires when user selects new page to show
13
+ * @fires pb-paginate - Fires when user selects new page to show
13
14
  * @fires pb-results-received - When received, recalculates page ranges to display according to the parameters received
14
15
  */
15
16
  export class PbPaginate extends pbMixin(LitElement) {
package/src/pb-search.js CHANGED
@@ -23,6 +23,7 @@ import '@cwmr/paper-autocomplete';
23
23
  * @slot - searchButton allows to plug a component that acts as submit button. Must support the 'click' event
24
24
  * @slot - resetButton allows to plug a component that acts as reset button. Must support the 'click' event
25
25
  * @fires pb-load - Fired to perform the actual search with parameters passed to the request
26
+ * @fires pb-paginate - When received, triggers the search again with the new value of the start property
26
27
  * @fires pb-search-resubmit - When received, triggers the search again
27
28
  */
28
29
  export class PbSearch extends pbMixin(LitElement) {
@@ -62,6 +63,18 @@ export class PbSearch extends pbMixin(LitElement) {
62
63
  disableAutocomplete: {
63
64
  type: Boolean,
64
65
  attribute: 'disable-autocomplete'
66
+ },
67
+ /**
68
+ * Optional URL to query for suggestions. If relative, it is interpreted
69
+ * relative to the endpoint defined on a surrounding `pb-page`.
70
+ *
71
+ * Upon autocomplete, the current input by the user will be sent with a query parameter
72
+ * `query`. The name/values of form controls nested within `pb-search` or subforms will also be
73
+ * appended to the request as parameters. This allows the server side code to distinguish
74
+ * different states.
75
+ */
76
+ source: {
77
+ type: String
65
78
  }
66
79
  };
67
80
  }
@@ -109,8 +122,9 @@ export class PbSearch extends pbMixin(LitElement) {
109
122
  );
110
123
  waitOnce('pb-page-ready', (options) => {
111
124
  const loader = this.shadowRoot.getElementById('autocompleteLoader');
125
+ const url = this.source || "api/search/autocomplete";
112
126
  if (this.minApiVersion('1.0.0')) {
113
- loader.url = `${options.endpoint}/api/search/autocomplete`;
127
+ loader.url = `${options.endpoint}/${url}`;
114
128
  } else {
115
129
  loader.url = `${options.endpoint}/modules/autocomplete.xql`;
116
130
  }
package/src/pb-view.js CHANGED
@@ -907,13 +907,13 @@ export class PbView extends themableMixin(pbMixin(LitElement)) {
907
907
  if (this.noScroll) {
908
908
  return;
909
909
  }
910
- if (registry.state.id) {
911
- const target = this.shadowRoot.getElementById(registry.state.id);
910
+ if (registry.hash) {
911
+ const target = this.shadowRoot.getElementById(registry.hash.substring(1));
912
912
  console.log('hash target: %o', target);
913
913
  if (target) {
914
914
  window.requestAnimationFrame(() =>
915
915
  setTimeout(() => {
916
- target.scrollIntoView({block: 'nearest'});
916
+ target.scrollIntoView({ block: "center", inline: "nearest" });
917
917
  }, 400)
918
918
  );
919
919
  }
package/src/urls.js CHANGED
@@ -36,6 +36,11 @@ class Registry {
36
36
 
37
37
  constructor() {
38
38
  this.rootPath = '';
39
+ /**
40
+ * Is the resource path part of the URL path or is it
41
+ * passed in a query parameter?
42
+ */
43
+ this.usePath = false;
39
44
  /**
40
45
  * Records current state as determined from parsing the URL.
41
46
  * This should be used to initialize components.
@@ -46,12 +51,21 @@ class Registry {
46
51
  * if a component calls commit or replace.
47
52
  */
48
53
  this.channelStates = {};
54
+ /**
55
+ * Records the hash part of the URL, if any
56
+ */
57
+ this.hash = null;
58
+ /**
59
+ * Should a hash in the URL be interpreted as an xml:id for loading the content?
60
+ */
61
+ this.idHash = true;
49
62
  this._listeners = [];
50
63
  }
51
64
 
52
- configure(usePath = true, rootPath = '') {
65
+ configure(usePath = true, idHash = false, rootPath = '') {
53
66
  this.rootPath = rootPath;
54
67
  this.usePath = usePath;
68
+ this.idHash = idHash;
55
69
 
56
70
  // determine initial state of the registry by parsing current URL
57
71
  const initialState = this._stateFromURL();
@@ -92,8 +106,11 @@ class Registry {
92
106
 
93
107
  _stateFromURL() {
94
108
  const params = {};
95
- if (window.location.hash.length > 0) {
96
- params.id = window.location.hash.substring(1);
109
+ this.hash = window.location.hash;
110
+ // use the hash as an xml:id?
111
+ // hashs of the form #1.2.3.4 are internal eXist ids though and thus excluded
112
+ if (this.idHash && this.hash.length > 0 && (!/^#\d+\./.test(this.hash))) {
113
+ params.id = this.hash.substring(1);
97
114
  }
98
115
  if (this.usePath) {
99
116
  params.path = window.location.pathname.replace(new RegExp(`^${this.rootPath}/?`), '');
@@ -216,7 +233,9 @@ class Registry {
216
233
  newUrl.pathname = `${this.rootPath}/${this.state.path}`;
217
234
  }
218
235
 
219
- newUrl.hash = this.state.id ? `#${this.state.id}` : '';
236
+ if (this.state.id) {
237
+ newUrl.hash = `#${this.state.id}`;
238
+ }
220
239
 
221
240
  console.log('urlFromState', newUrl.searchParams.toString())
222
241
  return newUrl;