@teipublisher/pb-components 1.36.2 → 1.38.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.
@@ -0,0 +1,101 @@
1
+ import { LitElement } from 'lit-element';
2
+
3
+ function sizeConverter(value, type) {
4
+ try {
5
+ return value.split(/\s*,\s*/).map(s => parseInt(s, 10));
6
+ } catch (e) {
7
+ console.error(`<pb-map-icon> Invalid size specified: ${value}`);
8
+ return null;
9
+ }
10
+ }
11
+ /**
12
+ * Configure a map icon type to be used for markers.
13
+ * Should be nested inside `pb-leaflet-map`.
14
+ *
15
+ */
16
+ export class PbMapIcon extends LitElement {
17
+ static get properties() {
18
+ return {
19
+ /**
20
+ * Name of the icon. Set to 'active' to configure the icon used for
21
+ * places which were target of a previous `pb-geolocation` event (i.e. are currently 'active').
22
+ */
23
+ name: {
24
+ type: String
25
+ },
26
+ /**
27
+ * The URL to load the icon from. Should be relative to the path set via the `imagesPath` property on `pb-leaflet-map`.
28
+ */
29
+ iconUrl: {
30
+ type: String,
31
+ attribute: 'icon-url'
32
+ },
33
+ /**
34
+ * Size of the icon as comma-separated string, i.e. 'height, width'.
35
+ */
36
+ iconSize: {
37
+ type: Array,
38
+ converter: sizeConverter,
39
+ attribute: 'icon-size'
40
+ },
41
+ /**
42
+ * Anchor position of the icon as comma-separated string, i.e. 'height, width'.
43
+ */
44
+ iconAnchor: {
45
+ type: Array,
46
+ converter: sizeConverter,
47
+ attribute: 'icon-anchor'
48
+ },
49
+ /**
50
+ * The URL to load the shadow icon from. Should be relative to the path set via the `imagesPath` property on `pb-leaflet-map`.
51
+ */
52
+ shadowUrl: {
53
+ type: String,
54
+ attribute: 'shadow-url'
55
+ },
56
+ /**
57
+ * Size of the shadow icon as comma-separated string, i.e. 'height, width'.
58
+ */
59
+ shadowSize: {
60
+ type: Array,
61
+ converter: sizeConverter,
62
+ attribute: 'shadow-size'
63
+ },
64
+ /**
65
+ * Anchor position of the shadow icon as comma-separated string, i.e. 'height, width'.
66
+ */
67
+ shadowAnchor: {
68
+ type: Array,
69
+ converter: sizeConverter,
70
+ attribute: 'shadow-anchor'
71
+ },
72
+ /**
73
+ * Anchor position of the popup as comma-separated string, i.e. 'height, width'.
74
+ */
75
+ popupAncor: {
76
+ type: Array,
77
+ converter: sizeConverter,
78
+ attribute: 'popup-anchor'
79
+ }
80
+ };
81
+ }
82
+
83
+ constructor() {
84
+ super();
85
+ this.name = 'default';
86
+ this.type = 'image';
87
+ this.iconUrl = null;
88
+ }
89
+
90
+ get options() {
91
+ const options = {};
92
+ Object.keys(PbMapIcon.properties).forEach(key => {
93
+ if (this[key]) {
94
+ options[key] = this[key];
95
+ }
96
+ });
97
+ console.log('<pb-map-icon> Options: %o', options);
98
+ return options;
99
+ }
100
+ }
101
+ customElements.define('pb-map-icon', PbMapIcon);
package/src/pb-page.js CHANGED
@@ -229,6 +229,15 @@ class PbPage extends pbMixin(LitElement) {
229
229
  return;
230
230
  }
231
231
 
232
+ const slot = this.shadowRoot.querySelector('slot');
233
+ slot.addEventListener('slotchange', () => {
234
+ const ev = new CustomEvent('pb-page-loaded', {
235
+ bubbles: true,
236
+ composed: true
237
+ });
238
+ this.dispatchEvent(ev);
239
+ }, { once: true });
240
+
232
241
  const defaultLocales = resolveURL('../i18n/') + '{{ns}}/{{lng}}.json';
233
242
  console.log('<pb-page> Loading locales. common: %s; additional: %s; namespaces: %o',
234
243
  defaultLocales, this.locales, this._localeFallbacks);
package/src/pb-popover.js CHANGED
@@ -74,7 +74,7 @@ export function loadTippyStyles(root, theme) {
74
74
  * unless defined otherwise; clicking anywhere on the page will close the popup.
75
75
  * @prop {"click" | "mouseenter" | "focus" | "focusin"} trigger - Defines one or more actions (space separated) which should cause
76
76
  * the popover to show. If property `persistent` is set, `trigger` will by default be set to `click`.
77
- * @prop {String} poupClass - Additional class names which will be added to the popup element.
77
+ * @prop {String} popupClass - Additional class names which will be added to the popup element.
78
78
  * Use this to apply a specific style to certain popovers, but not others.
79
79
  * @prop {String} remote - An optional URL to asynchronously load the popover's content from. Content will
80
80
  * be loaded after the popover is displayed. The downloaded HTML content will replace the text set via the alternate slot.
@@ -282,6 +282,10 @@ export class PbTimeline extends pbMixin(LitElement) {
282
282
  scopes: {
283
283
  type: Array
284
284
  },
285
+ maxInterval: {
286
+ type: Number,
287
+ attribute: 'max-interval'
288
+ },
285
289
  /**
286
290
  * Endpoint to load timeline data from. Expects response to be an
287
291
  * object with key value pairs for (date, hits).
@@ -315,6 +319,7 @@ export class PbTimeline extends pbMixin(LitElement) {
315
319
  this.endDate = '';
316
320
  this.scope = '';
317
321
  this.scopes = ["D", "W", "M", "Y", "5Y", "10Y"];
322
+ this.maxInterval = 60;
318
323
  this.url = '';
319
324
  this.auto = false;
320
325
  this.resettable = false;
@@ -516,10 +521,18 @@ export class PbTimeline extends pbMixin(LitElement) {
516
521
  endDateStr: this.searchResult.getEndOfRangeDate(this.dataObj.scope, endDateStr),
517
522
  scope: this.dataObj.scope,
518
523
  categories,
519
- count: itemCount
524
+ count: itemCount,
525
+ label: this.label
520
526
  });
521
527
  } else {
522
- this.emitTo('pb-timeline-date-changed', { startDateStr, endDateStr: null, scope: this.dataObj.scope, categories, count: itemCount });
528
+ this.emitTo('pb-timeline-date-changed', {
529
+ startDateStr,
530
+ endDateStr: null,
531
+ scope: this.dataObj.scope,
532
+ categories,
533
+ count: itemCount,
534
+ label: this.label
535
+ });
523
536
  }
524
537
  } else {
525
538
  this.emitTo('pb-timeline-daterange-changed', {
@@ -527,7 +540,8 @@ export class PbTimeline extends pbMixin(LitElement) {
527
540
  endDateStr,
528
541
  categories,
529
542
  scope: this.dataObj.scope,
530
- count: itemCount
543
+ count: itemCount,
544
+ label: this.label
531
545
  });
532
546
  }
533
547
  }
@@ -732,15 +746,12 @@ export class PbTimeline extends pbMixin(LitElement) {
732
746
  } else {
733
747
  newJsonData = data;
734
748
  }
735
- this.searchResult = new SearchResultService(newJsonData, 60, this.scopes);
749
+ this.searchResult = new SearchResultService(newJsonData, this.maxInterval, this.scopes);
736
750
  this.setData(this.searchResult.export(this.scope));
737
- this.dispatchEvent(new CustomEvent('pb-timeline-loaded', {
738
- detail: {
739
- value: true
740
- },
741
- composed: true,
742
- bubbles: true
743
- }));
751
+ this.emitTo('pb-timeline-loaded', {
752
+ value: true,
753
+ label: this.label
754
+ });
744
755
  }
745
756
 
746
757
  }