@teipublisher/pb-components 1.30.3 → 1.32.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "1.30.3",
3
+ "version": "1.32.1",
4
4
  "description": "Collection of webcomponents underlying TEI Publisher",
5
5
  "repository": "https://github.com/eeditiones/tei-publisher-components.git",
6
6
  "main": "index.html",
@@ -76,6 +76,7 @@
76
76
  "i18next-xhr-backend": "^3.2.2",
77
77
  "js-cookie": "^2.2.1",
78
78
  "leaflet": "^1.7.1",
79
+ "leaflet.markercluster": "^1.5.3",
79
80
  "lit-element": "latest",
80
81
  "lit-html": "^1.3.0",
81
82
  "marked": "^1.2.0",
package/pb-elements.json CHANGED
@@ -2249,8 +2249,13 @@
2249
2249
  {
2250
2250
  "name": "pb-custom-form",
2251
2251
  "path": "./src/pb-custom-form.js",
2252
- "description": "A custom form element which loads the actual form from a server-side script using AJAX.\nEmits a `pb-search-resubmit` event when the form is submitted, signalling `pb-search` that\na search should be redone using the parameters passed.\n\nThe component is currently used to implement the additional search facets on the start page and\nsearch result page.",
2252
+ "description": "A custom form element which loads the actual form from a server-side script using AJAX.\nEmits `pb-search-resubmit` and `pb-submit` events, signalling the receiver that it should\nrefresh.\n\nThe component is currently used to implement the additional search facets on the start and\nsearch result page. It can also be combined with `pb-split-list` to contain an additional form\nwith options.",
2253
2253
  "attributes": [
2254
+ {
2255
+ "name": "auto-submit",
2256
+ "description": "Register event handlers on all inputs and submit the form\nautomatically if any of those changes. For button-like controls,\na submit is triggered on click, for text input on keyUp, and for\nall other form components on change.",
2257
+ "type": "string"
2258
+ },
2254
2259
  {
2255
2260
  "name": "url",
2256
2261
  "description": "The URL for the AJAX request. If a relative URL is passed, it will be resolved\nagainst the current API endpoint.",
@@ -2345,6 +2350,12 @@
2345
2350
  }
2346
2351
  ],
2347
2352
  "properties": [
2353
+ {
2354
+ "name": "autoSubmit",
2355
+ "attribute": "auto-submit",
2356
+ "description": "Register event handlers on all inputs and submit the form\nautomatically if any of those changes. For button-like controls,\na submit is triggered on click, for text input on keyUp, and for\nall other form components on change.",
2357
+ "type": "string"
2358
+ },
2348
2359
  {
2349
2360
  "name": "url",
2350
2361
  "attribute": "url",
@@ -2466,7 +2477,16 @@
2466
2477
  ],
2467
2478
  "events": [
2468
2479
  {
2469
- "name": "pb-custom-form-loaded"
2480
+ "name": "pb-custom-form-loaded",
2481
+ "description": "Fired before the element updates its content"
2482
+ },
2483
+ {
2484
+ "name": "pb-search-resubmit",
2485
+ "description": "Fired when the form is submitted"
2486
+ },
2487
+ {
2488
+ "name": "pb-submit",
2489
+ "description": "Fired when the form is submitted"
2470
2490
  },
2471
2491
  {
2472
2492
  "name": "pb-start-update",
@@ -3735,9 +3755,21 @@
3735
3755
  },
3736
3756
  {
3737
3757
  "name": "event",
3758
+ "description": "Name of the event which triggers a pb-geolocation event, e.g. 'click'.\nDefault is 'mouseover'.",
3738
3759
  "type": "string",
3739
3760
  "default": "\"mouseover\""
3740
3761
  },
3762
+ {
3763
+ "name": "auto",
3764
+ "description": "If set, add location to a map automatically upon load by\nemitting an event. If not set, locations are only added when\nthe configured event is triggered.",
3765
+ "type": "boolean",
3766
+ "default": "false"
3767
+ },
3768
+ {
3769
+ "name": "zoom",
3770
+ "description": "Zoom level to use for the map if it centers on the location.",
3771
+ "type": "number"
3772
+ },
3741
3773
  {
3742
3774
  "name": "key",
3743
3775
  "description": "The key to which this element is connected.",
@@ -3816,9 +3848,23 @@
3816
3848
  {
3817
3849
  "name": "event",
3818
3850
  "attribute": "event",
3851
+ "description": "Name of the event which triggers a pb-geolocation event, e.g. 'click'.\nDefault is 'mouseover'.",
3819
3852
  "type": "string",
3820
3853
  "default": "\"mouseover\""
3821
3854
  },
3855
+ {
3856
+ "name": "auto",
3857
+ "attribute": "auto",
3858
+ "description": "If set, add location to a map automatically upon load by\nemitting an event. If not set, locations are only added when\nthe configured event is triggered.",
3859
+ "type": "boolean",
3860
+ "default": "false"
3861
+ },
3862
+ {
3863
+ "name": "zoom",
3864
+ "attribute": "zoom",
3865
+ "description": "Zoom level to use for the map if it centers on the location.",
3866
+ "type": "number"
3867
+ },
3822
3868
  {
3823
3869
  "name": "key",
3824
3870
  "attribute": "key",
@@ -4547,6 +4593,18 @@
4547
4593
  "type": "boolean",
4548
4594
  "default": "false"
4549
4595
  },
4596
+ {
4597
+ "name": "cluster",
4598
+ "description": "If set, combine markers into clusters if they are located too close together\nto display as single markers",
4599
+ "type": "boolean",
4600
+ "default": "false"
4601
+ },
4602
+ {
4603
+ "name": "fit-markers",
4604
+ "description": "If set, the map will automatically zoom so it can fit all the markers",
4605
+ "type": "boolean",
4606
+ "default": "false"
4607
+ },
4550
4608
  {
4551
4609
  "name": "subscribe",
4552
4610
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -4636,6 +4694,20 @@
4636
4694
  "type": "boolean",
4637
4695
  "default": "false"
4638
4696
  },
4697
+ {
4698
+ "name": "cluster",
4699
+ "attribute": "cluster",
4700
+ "description": "If set, combine markers into clusters if they are located too close together\nto display as single markers",
4701
+ "type": "boolean",
4702
+ "default": "false"
4703
+ },
4704
+ {
4705
+ "name": "fitMarkers",
4706
+ "attribute": "fit-markers",
4707
+ "description": "If set, the map will automatically zoom so it can fit all the markers",
4708
+ "type": "boolean",
4709
+ "default": "false"
4710
+ },
4639
4711
  {
4640
4712
  "name": "subscribe",
4641
4713
  "attribute": "subscribe",
@@ -8841,6 +8913,136 @@
8841
8913
  }
8842
8914
  ]
8843
8915
  },
8916
+ {
8917
+ "name": "pb-split-list",
8918
+ "path": "./src/pb-split-list.js",
8919
+ "description": "Implements a list which is split into different categories \n(e.g. letters of the alphabet, countries ...).\nOnly one category is shown at a time unless the server reports\nno categories (e.g. if the number of items to display goes below\na defined threshold).\n\nThe server-side API endpoint should return a JSON object with two\nproperties:\n\n+ `categories`: an array of category descriptions: each item should \n be an object with two properties: `category` - containing the name of the category\n and `count` - containing a count of items available under this category.\n+ `items`: an array with the items to be shown for the currently selected\n category. Those may contain HTML markup.",
8920
+ "attributes": [
8921
+ {
8922
+ "name": "url",
8923
+ "description": "Server-side API endpoint to retrieve items from",
8924
+ "type": "string"
8925
+ },
8926
+ {
8927
+ "name": "selected",
8928
+ "description": "The initially selected category",
8929
+ "type": "string"
8930
+ },
8931
+ {
8932
+ "name": "subforms",
8933
+ "description": "A CSS selector pointing to one or more `pb-custom-form`\ninstances. The element will collect additional parameters\nfrom those forms and includes them in the request to the server",
8934
+ "type": "string"
8935
+ },
8936
+ {
8937
+ "name": "subscribe",
8938
+ "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
8939
+ "type": "string"
8940
+ },
8941
+ {
8942
+ "name": "subscribe-config",
8943
+ "description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
8944
+ "type": "object"
8945
+ },
8946
+ {
8947
+ "name": "emit",
8948
+ "description": "The name of the channel to send events to.",
8949
+ "type": "string"
8950
+ },
8951
+ {
8952
+ "name": "emit-config",
8953
+ "description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
8954
+ "type": "object"
8955
+ },
8956
+ {
8957
+ "name": "wait-for",
8958
+ "description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
8959
+ "type": "string"
8960
+ },
8961
+ {
8962
+ "name": "disabled",
8963
+ "description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
8964
+ "type": "boolean",
8965
+ "default": "false"
8966
+ }
8967
+ ],
8968
+ "properties": [
8969
+ {
8970
+ "name": "url",
8971
+ "attribute": "url",
8972
+ "description": "Server-side API endpoint to retrieve items from",
8973
+ "type": "string"
8974
+ },
8975
+ {
8976
+ "name": "selected",
8977
+ "attribute": "selected",
8978
+ "description": "The initially selected category",
8979
+ "type": "string"
8980
+ },
8981
+ {
8982
+ "name": "subforms",
8983
+ "attribute": "subforms",
8984
+ "description": "A CSS selector pointing to one or more `pb-custom-form`\ninstances. The element will collect additional parameters\nfrom those forms and includes them in the request to the server",
8985
+ "type": "string"
8986
+ },
8987
+ {
8988
+ "name": "subscribe",
8989
+ "attribute": "subscribe",
8990
+ "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
8991
+ "type": "string"
8992
+ },
8993
+ {
8994
+ "name": "subscribeConfig",
8995
+ "attribute": "subscribe-config",
8996
+ "description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
8997
+ "type": "object"
8998
+ },
8999
+ {
9000
+ "name": "emit",
9001
+ "attribute": "emit",
9002
+ "description": "The name of the channel to send events to.",
9003
+ "type": "string"
9004
+ },
9005
+ {
9006
+ "name": "emitConfig",
9007
+ "attribute": "emit-config",
9008
+ "description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
9009
+ "type": "object"
9010
+ },
9011
+ {
9012
+ "name": "waitFor",
9013
+ "attribute": "wait-for",
9014
+ "description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
9015
+ "type": "string"
9016
+ },
9017
+ {
9018
+ "name": "disabled",
9019
+ "attribute": "disabled",
9020
+ "description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
9021
+ "type": "boolean",
9022
+ "default": "false"
9023
+ }
9024
+ ],
9025
+ "events": [
9026
+ {
9027
+ "name": "pb-submit",
9028
+ "description": "when received, submit a request to the server and refresh"
9029
+ },
9030
+ {
9031
+ "name": "pb-start-update",
9032
+ "description": "sent before the element sends the request to the server"
9033
+ },
9034
+ {
9035
+ "name": "pb-end-update",
9036
+ "description": "sent after new content has been received"
9037
+ }
9038
+ ],
9039
+ "cssProperties": [
9040
+ {
9041
+ "name": "--pb-categorized-list-columns",
9042
+ "description": "the number of columns to display (default: 2)"
9043
+ }
9044
+ ]
9045
+ },
8844
9046
  {
8845
9047
  "name": "pb-svg",
8846
9048
  "path": "./src/pb-svg.js",
@@ -57,6 +57,7 @@ import './pb-message.js';
57
57
  import './pb-blacklab-results.js';
58
58
  import './pb-blacklab-highlight.js';
59
59
  import './pb-table-grid.js';
60
+ import './pb-split-list.js';
60
61
 
61
62
  import '@polymer/iron-icons/editor-icons';
62
63
  import '@polymer/iron-icons/social-icons';
@@ -7,14 +7,16 @@ import { PbLoad } from './pb-load.js';
7
7
 
8
8
  /**
9
9
  * A custom form element which loads the actual form from a server-side script using AJAX.
10
- * Emits a `pb-search-resubmit` event when the form is submitted, signalling `pb-search` that
11
- * a search should be redone using the parameters passed.
10
+ * Emits `pb-search-resubmit` and `pb-submit` events, signalling the receiver that it should
11
+ * refresh.
12
12
  *
13
- * The component is currently used to implement the additional search facets on the start page and
14
- * search result page.
13
+ * The component is currently used to implement the additional search facets on the start and
14
+ * search result page. It can also be combined with `pb-split-list` to contain an additional form
15
+ * with options.
15
16
  *
16
- * @customElement
17
- * @polymer
17
+ * @fires pb-custom-form-loaded - Fired before the element updates its content
18
+ * @fires pb-search-resubmit - Fired when the form is submitted
19
+ * @fires pb-submit - Fired when the form is submitted
18
20
  */
19
21
  export class PbCustomForm extends PbLoad {
20
22
 
@@ -34,6 +36,8 @@ export class PbCustomForm extends PbLoad {
34
36
  this._reset();
35
37
  }
36
38
  });
39
+
40
+ this._submissionHandlers();
37
41
  }
38
42
 
39
43
  render() {
@@ -81,7 +85,8 @@ export class PbCustomForm extends PbLoad {
81
85
 
82
86
  _submit() {
83
87
  const json = this.serializeForm();
84
- this.emitTo('pb-search-resubmit', { 'params': json });
88
+ this.emitTo('pb-search-resubmit', { params: json });
89
+ this.emitTo('pb-submit', { params: json});
85
90
  }
86
91
 
87
92
  _reset(){
@@ -102,6 +107,43 @@ export class PbCustomForm extends PbLoad {
102
107
  this.dispatchEvent(new CustomEvent('pb-custom-form-loaded', { detail: content }));
103
108
  }
104
109
 
110
+ _submissionHandlers() {
111
+ if (!this.autoSubmit) {
112
+ return;
113
+ }
114
+ this.querySelectorAll(this.autoSubmit).forEach((control) => {
115
+ const name = control.nodeName.toLowerCase();
116
+ let event = 'change';
117
+ if (control instanceof HTMLButtonElement ||
118
+ name === 'paper-icon-button' || name === 'paper-button' ||
119
+ (name === 'input' && (control.type === 'button' || control.type === 'submit' || control.type === 'reset'))
120
+ ) {
121
+ event = 'click';
122
+ } else if (name === 'paper-input' || (control instanceof HTMLInputElement && control.type === 'text')) {
123
+ event = 'keyup';
124
+ } else if (name === 'paper-dropdown-menu') {
125
+ event = 'value-changed';
126
+ }
127
+ control.addEventListener(event, this._submit.bind(this));
128
+ });
129
+ }
130
+
131
+ static get properties() {
132
+ return {
133
+ /**
134
+ * Register event handlers on all inputs and submit the form
135
+ * automatically if any of those changes. For button-like controls,
136
+ * a submit is triggered on click, for text input on keyUp, and for
137
+ * all other form components on change.
138
+ */
139
+ autoSubmit: {
140
+ type: String,
141
+ attribute: 'auto-submit'
142
+ },
143
+ ...super.properties
144
+ };
145
+ }
146
+
105
147
  /**
106
148
  * Fired before the element updates its content
107
149
  *
@@ -30,8 +30,26 @@ export class PbGeolocation extends PbHighlight {
30
30
  label: {
31
31
  type: String
32
32
  },
33
+ /**
34
+ * Name of the event which triggers a pb-geolocation event, e.g. 'click'.
35
+ * Default is 'mouseover'.
36
+ */
33
37
  event: {
34
38
  type: String
39
+ },
40
+ /**
41
+ * Zoom level to use for the map if it centers on the location.
42
+ */
43
+ zoom: {
44
+ type: Number
45
+ },
46
+ /**
47
+ * If set, add location to a map automatically upon load by
48
+ * emitting an event. If not set, locations are only added when
49
+ * the configured event is triggered.
50
+ */
51
+ auto: {
52
+ type: Boolean
35
53
  }
36
54
  };
37
55
  }
@@ -39,22 +57,41 @@ export class PbGeolocation extends PbHighlight {
39
57
  constructor() {
40
58
  super();
41
59
  this.event = 'mouseover';
60
+ this.auto = false;
61
+ this.zoom = null;
42
62
  }
43
63
 
44
64
  connectedCallback() {
45
65
  super.connectedCallback();
46
66
 
47
- this.addEventListener(this.event, () =>
48
- this.emitTo('pb-geolocation', {
49
- coordinates: {
50
- latitude: this.latitude,
51
- longitude: this.longitude
52
- },
53
- label: this.label,
54
- popup: this.popup,
55
- element: this
56
- })
57
- );
67
+ if (this.event) {
68
+ this.addEventListener(this.event, () =>
69
+ this.emitTo('pb-geolocation', {
70
+ coordinates: {
71
+ latitude: this.latitude,
72
+ longitude: this.longitude
73
+ },
74
+ label: this.label,
75
+ zoom: this.zoom,
76
+ popup: this.popup,
77
+ element: this
78
+ })
79
+ );
80
+ }
81
+ if (this.auto) {
82
+ this.waitForChannel(() => {
83
+ this.emitTo('pb-geolocation', {
84
+ coordinates: {
85
+ latitude: this.latitude,
86
+ longitude: this.longitude
87
+ },
88
+ label: this.label,
89
+ popup: this.popup,
90
+ fitBounds: true,
91
+ element: this
92
+ });
93
+ });
94
+ }
58
95
  }
59
96
 
60
97
  render() {