@teipublisher/pb-components 1.44.2 → 2.0.0

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 (72) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/demo/demos.json +2 -1
  3. package/dist/demo/pb-browse-docs.html +2 -1
  4. package/dist/demo/pb-combo-box.html +1 -1
  5. package/dist/demo/pb-document.html +2 -2
  6. package/dist/demo/pb-load.html +2 -2
  7. package/dist/demo/pb-select-feature.html +1 -1
  8. package/dist/demo/pb-select-feature2.html +10 -3
  9. package/dist/demo/pb-select-feature3.html +1 -1
  10. package/dist/demo/pb-select-odd.html +1 -1
  11. package/dist/demo/pb-table-grid.html +1 -1
  12. package/dist/demo/pb-tabs.html +8 -2
  13. package/dist/demo/pb-toggle-feature.html +2 -2
  14. package/dist/demo/pb-toggle-feature2.html +2 -2
  15. package/dist/demo/pb-toggle-feature3.html +2 -2
  16. package/dist/demo/pb-view.html +1 -1
  17. package/dist/demo/pb-view4.html +86 -0
  18. package/dist/pb-code-editor.js +1 -1
  19. package/dist/pb-component-docs.js +33 -33
  20. package/dist/pb-components-bundle.js +173 -173
  21. package/dist/pb-edit-app.js +6 -6
  22. package/dist/pb-elements.json +93 -27
  23. package/dist/{pb-i18n-3963b098.js → pb-i18n-8a90c591.js} +1 -1
  24. package/dist/pb-leaflet-map.js +1 -1
  25. package/dist/pb-mixin-8a593923.js +158 -0
  26. package/dist/pb-odd-editor.js +47 -47
  27. package/dist/{vaadin-element-mixin-08cf11b5.js → vaadin-element-mixin-672938e3.js} +18 -18
  28. package/i18n/common/en.json +9 -1
  29. package/package.json +4 -3
  30. package/pb-elements.json +93 -27
  31. package/src/dts-client.js +14 -14
  32. package/src/dts-select-endpoint.js +5 -5
  33. package/src/pb-ajax.js +4 -4
  34. package/src/pb-authority-lookup.js +2 -2
  35. package/src/pb-autocomplete.js +9 -11
  36. package/src/pb-blacklab-highlight.js +3 -3
  37. package/src/pb-browse-docs.js +44 -27
  38. package/src/pb-browse.js +9 -3
  39. package/src/pb-combo-box.js +2 -2
  40. package/src/pb-document.js +15 -1
  41. package/src/pb-download.js +2 -2
  42. package/src/pb-edit-app.js +2 -2
  43. package/src/pb-edit-xml.js +2 -2
  44. package/src/pb-events.js +26 -18
  45. package/src/pb-grid.js +55 -53
  46. package/src/pb-lang.js +2 -2
  47. package/src/pb-link.js +10 -16
  48. package/src/pb-load.js +35 -25
  49. package/src/pb-login.js +2 -2
  50. package/src/pb-manage-odds.js +2 -2
  51. package/src/pb-markdown.js +2 -2
  52. package/src/pb-mei.js +2 -2
  53. package/src/pb-mixin.js +103 -196
  54. package/src/pb-odd-editor.js +2 -2
  55. package/src/pb-page.js +30 -21
  56. package/src/pb-paginate.js +24 -19
  57. package/src/pb-print-preview.js +2 -2
  58. package/src/pb-repeat.js +2 -1
  59. package/src/pb-search.js +34 -8
  60. package/src/pb-select-feature.js +62 -39
  61. package/src/pb-select-odd.js +8 -7
  62. package/src/pb-select-template.js +5 -4
  63. package/src/pb-select.js +31 -28
  64. package/src/pb-split-list.js +18 -11
  65. package/src/pb-table-grid.js +9 -8
  66. package/src/pb-tabs.js +29 -12
  67. package/src/pb-toggle-feature.js +51 -55
  68. package/src/pb-upload.js +10 -3
  69. package/src/pb-view.js +118 -95
  70. package/src/theming.js +148 -149
  71. package/src/urls.js +233 -0
  72. package/dist/pb-mixin-88125cb2.js +0 -158
package/pb-elements.json CHANGED
@@ -3172,6 +3172,11 @@
3172
3172
  "type": "string",
3173
3173
  "default": "\"\""
3174
3174
  },
3175
+ {
3176
+ "name": "disable-history",
3177
+ "type": "boolean",
3178
+ "default": "false"
3179
+ },
3175
3180
  {
3176
3181
  "name": "subscribe",
3177
3182
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -3236,6 +3241,12 @@
3236
3241
  "type": "string",
3237
3242
  "default": "\"\""
3238
3243
  },
3244
+ {
3245
+ "name": "disableHistory",
3246
+ "attribute": "disable-history",
3247
+ "type": "boolean",
3248
+ "default": "false"
3249
+ },
3239
3250
  {
3240
3251
  "name": "subscribe",
3241
3252
  "attribute": "subscribe",
@@ -4753,7 +4764,8 @@
4753
4764
  {
4754
4765
  "name": "panels",
4755
4766
  "description": "an array of panel items to display when the component is loaded. It should contain a\nnumber for each panel to show, indicating the ordinal position of the template within the `<pb-panel>`\nto initialize. For example, if you have two templates in `<pb-panel>`: \"transcription\" and \"translation\",\nsetting `panels=\"[0, 1]\"` will show two columns, one with the transcription, the other with the translation.\n\nPassing in a browser parameter `panels` with a comma-separated list will set this property as well.",
4756
- "type": "array"
4767
+ "type": "array",
4768
+ "default": "[]"
4757
4769
  },
4758
4770
  {
4759
4771
  "name": "direction",
@@ -4809,7 +4821,8 @@
4809
4821
  "name": "panels",
4810
4822
  "attribute": "panels",
4811
4823
  "description": "an array of panel items to display when the component is loaded. It should contain a\nnumber for each panel to show, indicating the ordinal position of the template within the `<pb-panel>`\nto initialize. For example, if you have two templates in `<pb-panel>`: \"transcription\" and \"translation\",\nsetting `panels=\"[0, 1]\"` will show two columns, one with the transcription, the other with the translation.\n\nPassing in a browser parameter `panels` with a comma-separated list will set this property as well.",
4812
- "type": "array"
4824
+ "type": "array",
4825
+ "default": "[]"
4813
4826
  },
4814
4827
  {
4815
4828
  "name": "direction",
@@ -7996,6 +8009,11 @@
7996
8009
  "type": "string",
7997
8010
  "default": "\".\""
7998
8011
  },
8012
+ {
8013
+ "name": "url-path",
8014
+ "type": "string",
8015
+ "default": "\"path\""
8016
+ },
7999
8017
  {
8000
8018
  "name": "api-version",
8001
8019
  "type": "string",
@@ -8092,6 +8110,12 @@
8092
8110
  "type": "string",
8093
8111
  "default": "\".\""
8094
8112
  },
8113
+ {
8114
+ "name": "urlPath",
8115
+ "attribute": "url-path",
8116
+ "type": "string",
8117
+ "default": "\"path\""
8118
+ },
8095
8119
  {
8096
8120
  "name": "apiVersion",
8097
8121
  "attribute": "api-version",
@@ -9202,6 +9226,11 @@
9202
9226
  "name": "subforms",
9203
9227
  "type": "string"
9204
9228
  },
9229
+ {
9230
+ "name": "name",
9231
+ "type": "string",
9232
+ "default": "\"query\""
9233
+ },
9205
9234
  {
9206
9235
  "name": "value",
9207
9236
  "type": "string",
@@ -9227,6 +9256,11 @@
9227
9256
  "type": "boolean",
9228
9257
  "default": "false"
9229
9258
  },
9259
+ {
9260
+ "name": "start",
9261
+ "type": "number",
9262
+ "default": "1"
9263
+ },
9230
9264
  {
9231
9265
  "name": "subscribe",
9232
9266
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -9275,6 +9309,12 @@
9275
9309
  "attribute": "subforms",
9276
9310
  "type": "string"
9277
9311
  },
9312
+ {
9313
+ "name": "name",
9314
+ "attribute": "name",
9315
+ "type": "string",
9316
+ "default": "\"query\""
9317
+ },
9278
9318
  {
9279
9319
  "name": "value",
9280
9320
  "attribute": "value",
@@ -9305,6 +9345,12 @@
9305
9345
  "type": "boolean",
9306
9346
  "default": "false"
9307
9347
  },
9348
+ {
9349
+ "name": "start",
9350
+ "attribute": "start",
9351
+ "type": "number",
9352
+ "default": "1"
9353
+ },
9308
9354
  {
9309
9355
  "name": "subscribe",
9310
9356
  "attribute": "subscribe",
@@ -9385,7 +9431,7 @@
9385
9431
  {
9386
9432
  "name": "pb-select-feature",
9387
9433
  "path": "./src/pb-select-feature.js",
9388
- "description": "Similar to `pb-toggle-feature` but allows you to choose from a list of defined states instead of a simple\non/off toggle. Like `pb-toggle-feature` it can change state server-side as well as client-side. \n\nThe list of states is passed as a JSON array to property `items`:\n\n# Server-side\n\nProperties to be passed to the server are specified as follows:\n\n```javascript\n[\n {\"name\": \"Diplomatic View\", \"properties\": {\"mode\": \"diplomatic\", \"view\": \"page\"}},\n {\"name\": \"Normalized View\", \"properties\": {\"mode\": \"norm\", \"view\": \"single\"}}\n]\n```\n\n# Client-side\n\n```javascript\n[\n {\"name\": \"Diplomatic View\", \"selectors\": [{\"selector\": \".choice,.choice-alternate,br\", \"state\": false},{\"selector\": \".tei-foreign,pb-highlight,pb-popover\", \"command\": \"disable\"}]},\n {\"name\": \"Normalized View\", \"selectors\": [{\"selector\": \".choice,.choice-alternate,br\", \"state\": true},{\"selector\": \".tei-foreign,pb-highlight,pb-popover\", \"command\": \"disable\"}]},\n {\"name\": \"Plain Reading View\", \"selectors\": [{\"selector\": \".choice,.choice-alternate,br\", \"state\": true}, {\"selector\": \".tei-foreign,pb-highlight,pb-popover\", \"command\": \"disable\", \"state\": true}]}\n]\n```\n\nEach item in the `selectors` property above defines either a state or a command. *state* will simply add\na css class `.toggled` to the target element when true. If *command* is set to 'disable', it will entirely disable\nthe functionality of selected elements - provided that they are\npublisher components implementing the corresponding `command` method of `pb-mixin`.",
9434
+ "description": "Similar to `pb-toggle-feature` but allows you to choose from a list of defined states instead of a simple\non/off toggle. Like `pb-toggle-feature` it can change state server-side as well as client-side. \n\nThe list of states is passed as a JSON array to property `items`:\n\n# Server-side\n\nProperties to be passed to the server are specified as follows:\n\n```javascript\n[\n {\"name\": \"Diplomatic View\", \"properties\": {\"mode\": \"diplomatic\", \"view\": \"page\"}},\n {\"name\": \"Normalized View\", \"properties\": {\"mode\": \"norm\", \"view\": \"single\"}}\n]\n```\n\n# Client-side\n\n```javascript\n[\n {\"name\": \"Diplomatic View\", \"selectors\": [{\"selector\": \".choice,.choice-alternate,br\", \"state\": false},{\"selector\": \".tei-foreign,pb-highlight,pb-popover\", \"command\": \"disable\"}]},\n {\"name\": \"Normalized View\", \"selectors\": [{\"selector\": \".choice,.choice-alternate,br\", \"state\": true},{\"selector\": \".tei-foreign,pb-highlight,pb-popover\", \"command\": \"disable\"}]},\n {\"name\": \"Plain Reading View\", \"selectors\": [{\"selector\": \".choice,.choice-alternate,br\", \"state\": true}, {\"selector\": \".tei-foreign,pb-highlight,pb-popover\", \"command\": \"disable\", \"state\": true}]}\n]\n```\n\nEach item in the `selectors` property above defines either a state or a command. *state* will simply add\na css class `.toggle` to the target element when true. If *command* is set to 'disable', it will entirely disable\nthe functionality of selected elements - provided that they are\npublisher components implementing the corresponding `command` method of `pb-mixin`.\n\nClient-side you may also pass an optional property `\"global\": true` to toggle the state of elements which reside\nin the surrounding HTML context below `pb-page` (means: elements which are not inside a `pb-view` or `pb-load`).",
9389
9435
  "attributes": [
9390
9436
  {
9391
9437
  "name": "name",
@@ -9511,6 +9557,9 @@
9511
9557
  {
9512
9558
  "name": "pb-toggle",
9513
9559
  "description": "Fired when a feature is selected from the dropdown and sends the selected properties"
9560
+ },
9561
+ {
9562
+ "name": "pb-global-toggle"
9514
9563
  }
9515
9564
  ]
9516
9565
  },
@@ -10363,7 +10412,7 @@
10363
10412
  {
10364
10413
  "name": "selected",
10365
10414
  "type": "number",
10366
- "default": "\"_initial\""
10415
+ "default": "0"
10367
10416
  },
10368
10417
  {
10369
10418
  "name": "subscribe",
@@ -10402,7 +10451,7 @@
10402
10451
  "name": "selected",
10403
10452
  "attribute": "selected",
10404
10453
  "type": "number",
10405
- "default": "\"_initial\""
10454
+ "default": "0"
10406
10455
  },
10407
10456
  {
10408
10457
  "name": "subscribe",
@@ -10733,16 +10782,6 @@
10733
10782
  "description": "(optional) CSS selector: selects the elements to toggle client side (sets or unsets a \nCSS class `.toggled`). Setting this property will not trigger a reload as everything is\nhandled by javascript.",
10734
10783
  "type": "string"
10735
10784
  },
10736
- {
10737
- "name": "on",
10738
- "description": "Value to set the parameter to when the feature is enabled.",
10739
- "type": "string"
10740
- },
10741
- {
10742
- "name": "off",
10743
- "description": "Value to set the parameter to when the feature is disabled.",
10744
- "type": "string"
10745
- },
10746
10785
  {
10747
10786
  "name": "checked",
10748
10787
  "type": "boolean"
@@ -10753,6 +10792,18 @@
10753
10792
  "type": "string",
10754
10793
  "default": "\"on\""
10755
10794
  },
10795
+ {
10796
+ "name": "on",
10797
+ "description": "Value to set the parameter to when the feature is enabled.",
10798
+ "type": "string",
10799
+ "default": "\"on\""
10800
+ },
10801
+ {
10802
+ "name": "off",
10803
+ "description": "Value to set the parameter to when the feature is disabled.",
10804
+ "type": "string",
10805
+ "default": "\"off\""
10806
+ },
10756
10807
  {
10757
10808
  "name": "action",
10758
10809
  "description": "In combination with a selector specifies the action to be taken, currently one of\n`toggle` (default) or `disable`.",
@@ -10822,18 +10873,6 @@
10822
10873
  "description": "(optional) CSS selector: selects the elements to toggle client side (sets or unsets a \nCSS class `.toggled`). Setting this property will not trigger a reload as everything is\nhandled by javascript.",
10823
10874
  "type": "string"
10824
10875
  },
10825
- {
10826
- "name": "on",
10827
- "attribute": "on",
10828
- "description": "Value to set the parameter to when the feature is enabled.",
10829
- "type": "string"
10830
- },
10831
- {
10832
- "name": "off",
10833
- "attribute": "off",
10834
- "description": "Value to set the parameter to when the feature is disabled.",
10835
- "type": "string"
10836
- },
10837
10876
  {
10838
10877
  "name": "checked",
10839
10878
  "attribute": "checked",
@@ -10846,6 +10885,20 @@
10846
10885
  "type": "string",
10847
10886
  "default": "\"on\""
10848
10887
  },
10888
+ {
10889
+ "name": "on",
10890
+ "attribute": "on",
10891
+ "description": "Value to set the parameter to when the feature is enabled.",
10892
+ "type": "string",
10893
+ "default": "\"on\""
10894
+ },
10895
+ {
10896
+ "name": "off",
10897
+ "attribute": "off",
10898
+ "description": "Value to set the parameter to when the feature is disabled.",
10899
+ "type": "string",
10900
+ "default": "\"off\""
10901
+ },
10849
10902
  {
10850
10903
  "name": "action",
10851
10904
  "attribute": "action",
@@ -10938,6 +10991,12 @@
10938
10991
  "description": "a comma-separated list of file suffixes to accept for upload\n(by default: .xml,.tei,.odd,.docx)",
10939
10992
  "type": "string"
10940
10993
  },
10994
+ {
10995
+ "name": "event",
10996
+ "description": "the event to emit when the upload has completed (default: 'pb-load')",
10997
+ "type": "string",
10998
+ "default": "\"pb-load\""
10999
+ },
10941
11000
  {
10942
11001
  "name": "subscribe",
10943
11002
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -10983,6 +11042,13 @@
10983
11042
  "description": "a comma-separated list of file suffixes to accept for upload\n(by default: .xml,.tei,.odd,.docx)",
10984
11043
  "type": "string"
10985
11044
  },
11045
+ {
11046
+ "name": "event",
11047
+ "attribute": "event",
11048
+ "description": "the event to emit when the upload has completed (default: 'pb-load')",
11049
+ "type": "string",
11050
+ "default": "\"pb-load\""
11051
+ },
10986
11052
  {
10987
11053
  "name": "subscribe",
10988
11054
  "attribute": "subscribe",
package/src/dts-client.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
2
  import { pbMixin } from './pb-mixin.js';
3
- import { translate } from "./pb-i18n.js";
3
+ import { translate } from './pb-i18n.js';
4
+ import { registry } from './urls.js';
5
+
4
6
  import '@polymer/iron-ajax';
5
7
  import '@polymer/iron-icon';
6
8
  import '@polymer/iron-icons';
@@ -61,8 +63,8 @@ export class DtsClient extends pbMixin(LitElement) {
61
63
  connectedCallback() {
62
64
  super.connectedCallback();
63
65
 
64
- this.collection = this.getParameter('id');
65
- this.page = this.getParameter('page');
66
+ this.collection = registry.state.id;
67
+ this.page = registry.state.page;
66
68
 
67
69
  this.subscribeTo('dts-endpoint', (ev) => {
68
70
  this._setEndpoint(ev.detail.endpoint, ev.detail.collection, ev.detail.reload);
@@ -163,19 +165,16 @@ export class DtsClient extends pbMixin(LitElement) {
163
165
 
164
166
  _update() {
165
167
  this.emitTo('pb-start-update');
166
- const params = {};
168
+ const newState = {};
167
169
  if (this.collection) {
168
- params.id = this.collection;
169
-
170
- this.setParameter('id', this.collection);
171
- };
170
+ newState.id = this.collection;
171
+ }
172
172
  if (this.page) {
173
- params.page = this.page + 1;
174
- this.setParameter('page', this.page);
173
+ newState.page = this.page + 1;
175
174
  }
176
- this.pushHistory('dts-client-navigate');
175
+ registry.commit(this, newState);
177
176
 
178
- this.queryAPI.params = params;
177
+ this.queryAPI.params = newState;
179
178
  this.queryAPI.url = this._collectionEndpoint;
180
179
  this.queryAPI.generateRequest();
181
180
  }
@@ -205,7 +204,8 @@ export class DtsClient extends pbMixin(LitElement) {
205
204
  const json = this.documentsAPI.lastResponse;
206
205
  this.emitTo('pb-end-update');
207
206
  const url = new URL(json.path, window.location.href);
208
- window.location = url;
207
+ // use registry here?
208
+ window.location.replace(url);
209
209
  }
210
210
 
211
211
  _handleError(ev) {
@@ -284,7 +284,7 @@ export class DtsClient extends pbMixin(LitElement) {
284
284
  }
285
285
 
286
286
  _renderMember(member) {
287
- if (member['@type'] == 'Collection') {
287
+ if (member['@type'] === 'Collection') {
288
288
  return html`
289
289
  <iron-icon icon="icons:folder-open"></iron-icon>
290
290
  <div class="details">
@@ -1,6 +1,8 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
2
  import { pbMixin } from './pb-mixin.js';
3
- import { translate } from "./pb-i18n.js";
3
+ import { translate } from './pb-i18n.js';
4
+ import { registry } from './urls.js';
5
+
4
6
  import '@polymer/paper-dropdown-menu/paper-dropdown-menu.js';
5
7
  import '@polymer/paper-listbox';
6
8
  import '@polymer/paper-item';
@@ -53,8 +55,7 @@ export class DtsSelectEndpoint extends pbMixin(LitElement) {
53
55
 
54
56
  connectedCallback() {
55
57
  super.connectedCallback();
56
-
57
- this.endpoint = this.getParameter('endpoint');
58
+ this.endpoint = registry.state.endpoint;
58
59
  }
59
60
 
60
61
  updated(changedProperties) {
@@ -96,8 +97,7 @@ export class DtsSelectEndpoint extends pbMixin(LitElement) {
96
97
  return;
97
98
  }
98
99
  const endpoint = this.endpoints.find((endp) => endp.url === newEndpoint);
99
- this.setParameter('endpoint', endpoint.url);
100
- this.pushHistory('dts-endpoint');
100
+ registry.commit(this, { endpoint: endpoint.url });
101
101
  console.log('<dts-select-endpoint> Setting endpoint to %s', newEndpoint);
102
102
  this.emitTo('dts-endpoint', {
103
103
  endpoint: endpoint.url,
package/src/pb-ajax.js CHANGED
@@ -121,8 +121,8 @@ export class PbAjax extends pbMixin(LitElement) {
121
121
  if (this.confirm) {
122
122
  const dialog = this.shadowRoot.getElementById('confirmDialog');
123
123
  dialog.confirm(this._dialogTitle, i18n(this.confirm))
124
- .then(() => this.trigger())
125
- .catch(() => console.log('<pb-ajax> Action cancelled'));
124
+ .then(() => this.trigger())
125
+ .catch(() => console.log('<pb-ajax> Action cancelled'));
126
126
  } else {
127
127
  this.trigger();
128
128
  }
@@ -161,8 +161,8 @@ export class PbAjax extends pbMixin(LitElement) {
161
161
  } else {
162
162
  this._message = msg;
163
163
  }
164
- const dialog = this.shadowRoot.getElementById('messageDialog');
165
- dialog.open();
164
+ const dialog = this.shadowRoot.getElementById('confirmDialog');
165
+ dialog.show(i18n('dialogs.error'), this._message);
166
166
  this.emitTo('pb-end-update');
167
167
  }
168
168
 
@@ -1,6 +1,6 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
2
  import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
3
- import { pbMixin } from './pb-mixin.js';
3
+ import { pbMixin, waitOnce } from './pb-mixin.js';
4
4
  import { translate } from "./pb-i18n.js";
5
5
  import { createConnectors } from "./authority/connectors.js";
6
6
  import '@polymer/paper-input/paper-input';
@@ -66,7 +66,7 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
66
66
  this._query();
67
67
  });
68
68
 
69
- PbAuthorityLookup.waitOnce('pb-page-ready', () => {
69
+ waitOnce('pb-page-ready', () => {
70
70
  const connectors = createConnectors(this.getEndpoint(), this);
71
71
  connectors.forEach(connector => { this._authorities[connector.register] = connector });
72
72
  });
@@ -1,5 +1,5 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
- import { pbMixin } from './pb-mixin';
2
+ import { pbMixin, waitOnce } from './pb-mixin';
3
3
  import { translate } from './pb-i18n';
4
4
  import '@polymer/paper-input/paper-input.js';
5
5
  import '@polymer/iron-ajax';
@@ -140,12 +140,12 @@ export class PbAutocomplete extends pbMixin(LitElement) {
140
140
  if (this.substring) {
141
141
  autocomplete.queryFn = _query;
142
142
  }
143
- PbAutocomplete.waitOnce('pb-page-ready', () => {
143
+ waitOnce('pb-page-ready', () => {
144
144
  this._sendRequest();
145
145
  });
146
146
  } else if (this.value) {
147
147
  if (this.source) {
148
- PbAutocomplete.waitOnce('pb-page-ready', () => {
148
+ waitOnce('pb-page-ready', () => {
149
149
  //console.log('send autocomplete request for remote source %s on value %s', this.source, this.value);
150
150
  this._sendRequest(this.value);
151
151
  });
@@ -233,7 +233,7 @@ export class PbAutocomplete extends pbMixin(LitElement) {
233
233
  loader.url = this.toAbsoluteURL(this.source);
234
234
 
235
235
  const params = this._getParameters();
236
- params['query'] = query;
236
+ params.query = query;
237
237
  loader.params = params;
238
238
  //console.log('send request for %s with %o', loaderId, params);
239
239
 
@@ -286,18 +286,16 @@ export class PbAutocomplete extends pbMixin(LitElement) {
286
286
  }
287
287
 
288
288
  _autocompleteSelected(ev) {
289
- this.lastSelected = ev.detail.text;
289
+ const { text, value } = ev.detail;
290
+ this.lastSelected = text;
290
291
  const input = this.shadowRoot.getElementById('search');
291
- input.value = ev.detail.text;
292
- this.value = ev.detail.value;
292
+ input.value = text;
293
+ this.value = value;
293
294
  if (this._hiddenInput) {
294
295
  this._hiddenInput.value = this.value;
295
296
  }
296
297
 
297
- this.emitTo('pb-autocomplete-selected', {
298
- text: ev.detail.text,
299
- value: ev.detail.value
300
- });
298
+ this.emitTo('pb-autocomplete-selected', { text, value });
301
299
  }
302
300
 
303
301
  _setInput(ev) {
@@ -1,5 +1,5 @@
1
- import {LitElement, html, css} from 'lit-element';
2
- import {pbMixin} from './pb-mixin.js';
1
+ import { LitElement, html, css } from 'lit-element';
2
+ import { pbMixin, waitOnce } from './pb-mixin.js';
3
3
 
4
4
  /**
5
5
  * This component queries the blacklab API of TEI-Publisher for a list of text matches
@@ -108,7 +108,7 @@ export class PbBlacklabHighlight extends pbMixin(LitElement) {
108
108
  * waiting for the page to be ready before storing a reference to the shadowDOM of the view element this
109
109
  * component is attached to via the 'view' attribute.
110
110
  */
111
- PbBlacklabHighlight.waitOnce('pb-page-ready', () => {
111
+ waitOnce('pb-page-ready', () => {
112
112
  this.viewElement = document.getElementById(this.view);
113
113
  if (!this.viewElement) {
114
114
  console.error(`${this}: view element with id ${this.view} does not exist`);
@@ -1,7 +1,11 @@
1
1
  import { html, css } from 'lit-element';
2
2
  import { PbLoad } from './pb-load.js';
3
+ import { waitOnce } from './pb-mixin.js';
3
4
  import { translate } from "./pb-i18n.js";
4
5
  import { themableMixin } from "./theming.js";
6
+ import { cmpVersion } from './utils.js';
7
+ import { registry } from "./urls.js";
8
+
5
9
  import '@polymer/paper-input/paper-input.js';
6
10
  import '@polymer/paper-button';
7
11
  import '@polymer/paper-dropdown-menu/paper-dropdown-menu.js';
@@ -10,7 +14,6 @@ import '@polymer/paper-dialog';
10
14
  import '@polymer/paper-dialog-scrollable';
11
15
  import '@polymer/iron-ajax';
12
16
  import '@cwmr/paper-autocomplete/paper-autocomplete-suggestions.js';
13
- import { cmpVersion } from './utils.js';
14
17
 
15
18
  /**
16
19
  * Component to browse through a collection of documents with sorting, filtering and facets.
@@ -135,21 +138,43 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
135
138
  connectedCallback() {
136
139
  super.connectedCallback();
137
140
 
138
- const sortParam = this.getParameter('sort');
139
- if (sortParam) {
140
- this.sortBy = sortParam;
141
- }
141
+ waitOnce('pb-page-ready', () => {
142
+ if (registry.state.sort) {
143
+ this.sortBy = registry.state.sort;
144
+ }
142
145
 
143
- const filterParam = this.getParameter('filter');
144
- if (filterParam) {
145
- this.filter = filterParam;
146
- this.filterBy = this.getParameter('filterBy', this.filterBy);
147
- }
146
+ if (registry.state.filter) {
147
+ this.filter = registry.state.filter;
148
+ this.filterBy = registry.state.filterBy || this.filterBy;
149
+ }
148
150
 
149
- this.facets = this.getParametersMatching(/^facet-.*$/);
151
+ this.facets = {};
152
+ // registry get state by regex
153
+ // this.facets = registry.getParametersMatching(this, /^facet-.*$/)
154
+ Object.keys(registry.state).forEach((key) => {
155
+ if (/^facet-.*$/.test(key)) {
156
+ const param = registry.state[key];
157
+ if (this.facets[key]) {
158
+ this.facets[key].push(param);
159
+ } else {
160
+ this.facets[key] = [param];
161
+ }
162
+ }
163
+ });
150
164
 
151
- this.collection = this.getParameter('collection');
165
+ this.collection = registry.state.collection;
152
166
 
167
+ if (this.collection) {
168
+ registry.replace(this, {
169
+ collection: this.collection
170
+ });
171
+ }
172
+ registry.subscribe(this, (state) => {
173
+ this.collection = state.collection;
174
+ this.load();
175
+ });
176
+ });
177
+
153
178
  this.subscribeTo('pb-search-resubmit', this._facets.bind(this));
154
179
  this.subscribeTo('pb-login', (ev) => {
155
180
  if (ev.detail.userChanged) {
@@ -171,7 +196,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
171
196
  }
172
197
 
173
198
  firstUpdated() {
174
- PbBrowseDocs.waitOnce('pb-page-ready', (options) => {
199
+ waitOnce('pb-page-ready', (options) => {
175
200
  const loader = this.shadowRoot.getElementById('autocompleteLoader');
176
201
  if (cmpVersion(options.apiVersion, '1.0.0') >= 0) {
177
202
  loader.url = `${options.endpoint}/api/search/autocomplete`;
@@ -384,10 +409,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
384
409
  if (typeof filter !== 'undefined') {
385
410
  console.log('<pb-browse-docs> Filter by %s', filter);
386
411
  this.filter = filter;
387
- this.setParameter('filter', filter);
388
- this.setParameter('filterBy', filterBy);
389
- this.pushHistory('filter docs');
390
-
412
+ registry.commit(this, { filter, filterBy })
391
413
  this.load();
392
414
  }
393
415
  }
@@ -405,8 +427,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
405
427
  if (sortBy && sortBy !== this.sortBy) {
406
428
  console.log('<pb-browse-docs> Sorting by %s', sortBy);
407
429
  this.sortBy = sortBy;
408
- this.setParameter('sort', sortBy);
409
- this.pushHistory('sort docs');
430
+ registry.commit(this, { sort: sortBy })
410
431
 
411
432
  this.load();
412
433
  }
@@ -414,13 +435,10 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
414
435
 
415
436
  _facets(ev) {
416
437
  if (ev.detail && ev.detail.params) {
417
- this.clearParametersMatching(/^(all-|facet-).*/);
418
- for (let param in ev.detail.params) {
419
- this.setParameter(param, ev.detail.params[param]);
420
- }
438
+ registry.clearParametersMatching(this, /^(all-|facet-).*/);
421
439
  this.facets = ev.detail.params;
422
440
  this.start = 1;
423
- this.pushHistory('facets');
441
+ registry.commit(this, ev.detail.params)
424
442
  }
425
443
  this.load();
426
444
  }
@@ -442,8 +460,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
442
460
  ev.preventDefault();
443
461
  this.collection = link.getAttribute('data-collection');
444
462
  this.start = 1;
445
- this.setParameter('collection', this.collection);
446
- this.pushHistory('browse collection');
463
+ registry.commit(this, { collection: this.collection });
447
464
  console.log('<pb-browse-docs> loading collection %s', this.collection);
448
465
  this.load();
449
466
  });
@@ -513,7 +530,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
513
530
  }
514
531
 
515
532
  _handleEnter(e) {
516
- if (e.keyCode == 13) {
533
+ if (e.keyCode === 13) {
517
534
  this._filter();
518
535
  }
519
536
  }
package/src/pb-browse.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { PbLoad } from './pb-load.js';
2
+ import { registry } from './urls.js';
3
+ import { waitOnce } from "./pb-mixin.js";
2
4
 
3
5
  /**
4
6
  * Extends PbLoad to support browsing collections.
@@ -37,7 +39,10 @@ export class PbBrowse extends PbLoad {
37
39
 
38
40
  connectedCallback() {
39
41
  super.connectedCallback();
40
- this.collection = this.getParameter('collection');
42
+ waitOnce('pb-page-ready', () => {
43
+ this.collection = registry.state.collection;
44
+ registry.subscribe(this, (state) => { this.collection = state.collection; });
45
+ });
41
46
  }
42
47
 
43
48
  getURL(params) {
@@ -66,8 +71,9 @@ export class PbBrowse extends PbLoad {
66
71
  ev.preventDefault();
67
72
  this.collection = link.getAttribute('data-collection');
68
73
  this.start = 1;
69
- this.setParameter('collection', this.collection);
70
- this.pushHistory('browse collection');
74
+ if (this.history) {
75
+ registry.commit(this, { collection: this.collection });
76
+ }
71
77
  console.log('<pb-browse> loading collection %s', this.collection);
72
78
  this.emitTo('pb-search-resubmit');
73
79
  });
@@ -1,6 +1,6 @@
1
1
  import { LitElement } from 'lit-element';
2
2
  import TomSelect from "tom-select";
3
- import { pbMixin } from './pb-mixin.js';
3
+ import { pbMixin, waitOnce } from './pb-mixin.js';
4
4
  import { resolveURL } from './utils.js';
5
5
 
6
6
  function importTheme(theme) {
@@ -114,7 +114,7 @@ export class PbComboBox extends pbMixin(LitElement) {
114
114
  }
115
115
  input.autocomplete = false;
116
116
 
117
- PbComboBox.waitOnce('pb-page-ready', () => {
117
+ waitOnce('pb-page-ready', () => {
118
118
  const options = {};
119
119
  if (this.source) {
120
120
  const url = this.toAbsoluteURL(this.source);