@teipublisher/pb-components 2.25.5 → 2.25.7

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 (130) hide show
  1. package/.github/workflows/main.yml +3 -3
  2. package/.github/workflows/node.js.yml +3 -3
  3. package/.github/workflows/release.js.yml +3 -3
  4. package/CHANGELOG.md +15 -0
  5. package/Dockerfile +78 -70
  6. package/css/components.css +5 -5
  7. package/dist/demo/pb-drawer2.html +1 -1
  8. package/dist/demo/pb-facsimile.html +2 -2
  9. package/dist/demo/pb-leaflet-map.html +1 -1
  10. package/dist/demo/pb-repeat.html +1 -3
  11. package/dist/demo/pb-view3.html +1 -1
  12. package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
  13. package/dist/pb-code-editor.js +25 -20
  14. package/dist/pb-component-docs.js +58 -54
  15. package/dist/pb-components-bundle.js +1827 -1520
  16. package/dist/pb-edit-app.js +167 -107
  17. package/dist/pb-elements.json +54 -54
  18. package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
  19. package/dist/pb-leaflet-map.js +23 -23
  20. package/dist/pb-mei.js +56 -41
  21. package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
  22. package/dist/pb-odd-editor.js +925 -758
  23. package/dist/pb-tify.js +2 -2
  24. package/dist/{vaadin-element-mixin-859a0132.js → vaadin-element-mixin-ad07ba25.js} +88 -61
  25. package/gh-pages.js +5 -3
  26. package/lib/openseadragon.min.js +6 -6
  27. package/package.json +3 -2
  28. package/pb-elements.json +54 -54
  29. package/src/assets/components.css +5 -5
  30. package/src/authority/airtable.js +20 -21
  31. package/src/authority/anton.js +129 -129
  32. package/src/authority/custom.js +23 -21
  33. package/src/authority/geonames.js +38 -32
  34. package/src/authority/gnd.js +47 -42
  35. package/src/authority/kbga.js +137 -134
  36. package/src/authority/metagrid.js +44 -46
  37. package/src/authority/reconciliation.js +66 -67
  38. package/src/authority/registry.js +4 -4
  39. package/src/docs/pb-component-docs.js +2 -2
  40. package/src/docs/pb-component-view.js +5 -5
  41. package/src/docs/pb-components-list.js +2 -2
  42. package/src/docs/pb-demo-snippet.js +2 -2
  43. package/src/dts-client.js +299 -297
  44. package/src/dts-select-endpoint.js +90 -82
  45. package/src/parse-date-service.js +184 -135
  46. package/src/pb-ajax.js +171 -167
  47. package/src/pb-authority-lookup.js +96 -81
  48. package/src/pb-autocomplete.js +292 -280
  49. package/src/pb-blacklab-highlight.js +264 -259
  50. package/src/pb-blacklab-results.js +236 -221
  51. package/src/pb-browse-docs.js +540 -475
  52. package/src/pb-browse.js +68 -65
  53. package/src/pb-clipboard.js +79 -76
  54. package/src/pb-code-editor.js +110 -102
  55. package/src/pb-code-highlight.js +209 -204
  56. package/src/pb-codepen.js +79 -72
  57. package/src/pb-collapse.js +149 -146
  58. package/src/pb-combo-box.js +190 -190
  59. package/src/pb-components-bundle.js +1 -1
  60. package/src/pb-custom-form.js +150 -149
  61. package/src/pb-document.js +89 -90
  62. package/src/pb-download.js +208 -195
  63. package/src/pb-drawer.js +145 -148
  64. package/src/pb-edit-app.js +301 -229
  65. package/src/pb-edit-xml.js +99 -96
  66. package/src/pb-events.js +114 -107
  67. package/src/pb-facs-link.js +104 -102
  68. package/src/pb-facsimile.js +444 -410
  69. package/src/pb-formula.js +151 -153
  70. package/src/pb-geolocation.js +129 -131
  71. package/src/pb-grid-action.js +53 -56
  72. package/src/pb-grid.js +231 -228
  73. package/src/pb-highlight.js +140 -140
  74. package/src/pb-hotkeys.js +40 -42
  75. package/src/pb-i18n.js +101 -104
  76. package/src/pb-image-strip.js +84 -78
  77. package/src/pb-lang.js +83 -70
  78. package/src/pb-leaflet-map.js +488 -485
  79. package/src/pb-link.js +126 -124
  80. package/src/pb-load.js +431 -426
  81. package/src/pb-login.js +275 -254
  82. package/src/pb-manage-odds.js +364 -318
  83. package/src/pb-map-icon.js +89 -89
  84. package/src/pb-map-layer.js +85 -85
  85. package/src/pb-markdown.js +90 -99
  86. package/src/pb-media-query.js +74 -72
  87. package/src/pb-mei.js +306 -295
  88. package/src/pb-message.js +143 -130
  89. package/src/pb-mixin.js +269 -264
  90. package/src/pb-navigation.js +80 -82
  91. package/src/pb-observable.js +38 -38
  92. package/src/pb-odd-editor.js +1056 -958
  93. package/src/pb-odd-elementspec-editor.js +348 -297
  94. package/src/pb-odd-model-editor.js +1058 -898
  95. package/src/pb-odd-parameter-editor.js +200 -178
  96. package/src/pb-odd-rendition-editor.js +136 -124
  97. package/src/pb-page.js +432 -422
  98. package/src/pb-paginate.js +202 -190
  99. package/src/pb-panel.js +191 -179
  100. package/src/pb-popover-themes.js +7 -5
  101. package/src/pb-popover.js +296 -287
  102. package/src/pb-print-preview.js +127 -127
  103. package/src/pb-progress.js +49 -49
  104. package/src/pb-repeat.js +105 -104
  105. package/src/pb-restricted.js +84 -77
  106. package/src/pb-search.js +238 -221
  107. package/src/pb-select-feature.js +127 -120
  108. package/src/pb-select-odd.js +132 -124
  109. package/src/pb-select-template.js +89 -78
  110. package/src/pb-select.js +251 -227
  111. package/src/pb-split-list.js +179 -174
  112. package/src/pb-svg.js +80 -79
  113. package/src/pb-table-column.js +54 -54
  114. package/src/pb-table-grid.js +221 -203
  115. package/src/pb-tabs.js +61 -63
  116. package/src/pb-tify.js +154 -154
  117. package/src/pb-timeline.js +271 -229
  118. package/src/pb-toggle-feature.js +198 -185
  119. package/src/pb-upload.js +184 -174
  120. package/src/pb-version.js +30 -30
  121. package/src/pb-view-annotate.js +132 -98
  122. package/src/pb-view.js +1282 -1263
  123. package/src/pb-zoom.js +40 -40
  124. package/src/polymer-hack.js +1 -1
  125. package/src/search-result-service.js +256 -223
  126. package/src/seed-element.js +13 -20
  127. package/src/settings.js +4 -4
  128. package/src/theming.js +91 -91
  129. package/src/urls.js +289 -289
  130. package/src/utils.js +53 -51
@@ -1,7 +1,6 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
2
  import { pbMixin } from './pb-mixin';
3
3
 
4
-
5
4
  /**
6
5
  * Link elements to each other: if the user moves the mouse over one element,
7
6
  * the others are highlighted by changing their background color. Which elements
@@ -11,7 +10,7 @@ import { pbMixin } from './pb-mixin';
11
10
  *
12
11
  * `pb-highlight` should be output for relevant elements via ODD processing model.
13
12
  *
14
- *
13
+ *
15
14
  *
16
15
  * @slot - default unnamed slot for highlight content
17
16
  * @fires pb-highlight-off - Fires removal of all highlights that might have existed before
@@ -19,151 +18,152 @@ import { pbMixin } from './pb-mixin';
19
18
  * @fires pb-highlight-off - When received, triggers removal of a highlight that might have been on for this element before
20
19
  * @fires pb-highlight-on - When received, switches the highlight on if the same key was received as the current element has
21
20
  * @cssprop --pb-highlight-color - Background color to highlight an element
22
- */
21
+ */
23
22
  export class PbHighlight extends pbMixin(LitElement) {
24
- static get properties() {
25
- return {
26
- ...super.properties,
27
- /**
28
- * The key to which this element is connected.
29
- */
30
- key: {
31
- type: String
32
- },
33
- /**
34
- * If set to > 0, specifies a duration (in ms) after which
35
- * the highlighting will be removed again
36
- */
37
- duration: {
38
- type: Number
39
- },
40
- /**
41
- * Scroll this element into view when it receives a highlight event
42
- */
43
- scroll: {
44
- type: Boolean
45
- },
46
- highlightSelf: {
47
- type: Boolean,
48
- attribute: 'highlight-self'
49
- },
50
- _className: {
51
- type: String
52
- }
53
- };
23
+ static get properties() {
24
+ return {
25
+ ...super.properties,
26
+ /**
27
+ * The key to which this element is connected.
28
+ */
29
+ key: {
30
+ type: String,
31
+ },
32
+ /**
33
+ * If set to > 0, specifies a duration (in ms) after which
34
+ * the highlighting will be removed again
35
+ */
36
+ duration: {
37
+ type: Number,
38
+ },
39
+ /**
40
+ * Scroll this element into view when it receives a highlight event
41
+ */
42
+ scroll: {
43
+ type: Boolean,
44
+ },
45
+ highlightSelf: {
46
+ type: Boolean,
47
+ attribute: 'highlight-self',
48
+ },
49
+ _className: {
50
+ type: String,
51
+ },
52
+ };
53
+ }
54
+
55
+ constructor() {
56
+ super();
57
+ this.key = null;
58
+ this.duration = 0;
59
+ this.scroll = false;
60
+ this.highlightSelf = false;
61
+ this._className = 'highlight-off';
62
+ }
63
+
64
+ connectedCallback() {
65
+ super.connectedCallback();
66
+ this.subscribeTo('pb-highlight-on', this._highlightOn.bind(this));
67
+ this.subscribeTo('pb-highlight-off', this._highlightOff.bind(this));
68
+ }
69
+
70
+ command(command, state) {
71
+ super.command(command, state);
72
+ if (this.disabled) {
73
+ this._className = 'highlight-off';
54
74
  }
55
-
56
- constructor() {
57
- super();
58
- this.key = null;
59
- this.duration = 0;
60
- this.scroll = false;
61
- this.highlightSelf = false;
62
- this._className = 'highlight-off';
75
+ }
76
+
77
+ _mouseOver() {
78
+ this.emitTo('pb-highlight-off', {
79
+ source: this,
80
+ });
81
+ if (this.highlightSelf) {
82
+ this._highlightOn({ detail: { id: this.key } });
63
83
  }
64
-
65
- connectedCallback() {
66
- super.connectedCallback();
67
- this.subscribeTo('pb-highlight-on', this._highlightOn.bind(this));
68
- this.subscribeTo('pb-highlight-off', this._highlightOff.bind(this));
84
+ this.emitTo('pb-highlight-on', {
85
+ id: this.key,
86
+ source: this,
87
+ scroll: this.scroll,
88
+ });
89
+ }
90
+
91
+ render() {
92
+ if (this.disabled) {
93
+ return html`<slot></slot>`;
69
94
  }
70
-
71
- command(command, state) {
72
- super.command(command, state);
73
- if (this.disabled) {
74
- this._className = 'highlight-off';
95
+ return html`<span id="content" class="${this._className}" @mouseover="${this._mouseOver}"
96
+ ><slot></slot
97
+ ></span>`;
98
+ }
99
+
100
+ static get styles() {
101
+ return css`
102
+ :host {
103
+ display: inline;
104
+ }
105
+
106
+ @keyframes keyFrameBackgroundColorIn {
107
+ 0% {
108
+ background-color: inherit;
75
109
  }
76
- }
77
-
78
- _mouseOver() {
79
- this.emitTo('pb-highlight-off', {
80
- source: this
81
- });
82
- if (this.highlightSelf) {
83
- this._highlightOn({ detail: { id: this.key } });
110
+ 100% {
111
+ background-color: var(--pb-highlight-color, #f9e976);
84
112
  }
85
- this.emitTo('pb-highlight-on', {
86
- id: this.key,
87
- source: this,
88
- scroll: this.scroll
89
- });
113
+ }
114
+
115
+ #content {
116
+ display: inline;
117
+ }
118
+
119
+ .highlight-on {
120
+ background-color: var(--pb-highlight-color, #f9e976);
121
+ animation-name: keyFrameBackgroundColorIn;
122
+ animation-duration: 500ms;
123
+ animation-iteration-count: 1;
124
+ animation-timing-function: ease-in;
125
+ }
126
+
127
+ .highlight-off {
128
+ background-color: inherit;
129
+ }
130
+ `;
131
+ }
132
+
133
+ _highlightOn(ev) {
134
+ if (ev.detail.source != this && ev.detail.id === this.key) {
135
+ this._className = 'highlight-on';
136
+ if (ev.detail.scroll && this.disabled == false) {
137
+ this.scrollIntoView({ block: 'center', behaviour: 'smooth' });
138
+ }
139
+ if (this.duration > 0) {
140
+ setTimeout(() => {
141
+ this._className = 'highlight-off';
142
+ }, this.duration);
143
+ }
90
144
  }
145
+ }
91
146
 
92
- render() {
93
- if (this.disabled) {
94
- return html`<slot></slot>`;
95
- }
96
- return html`<span id="content" class="${this._className}" @mouseover="${this._mouseOver}"><slot></slot></span>`;
147
+ _highlightOff(ev) {
148
+ if (ev.detail.source != this) {
149
+ this._className = 'highlight-off';
97
150
  }
98
-
99
- static get styles() {
100
- return css`
101
- :host {
102
- display: inline;
103
- }
104
-
105
- @keyframes keyFrameBackgroundColorIn {
106
- 0% {
107
- background-color: inherit;
108
- }
109
- 100% {
110
- background-color: var(--pb-highlight-color, #F9E976);
111
- }
112
- }
113
-
114
- #content {
115
- display: inline;
116
- }
117
-
118
- .highlight-on {
119
- background-color: var(--pb-highlight-color, #F9E976);
120
- animation-name: keyFrameBackgroundColorIn;
121
- animation-duration: 500ms;
122
- animation-iteration-count: 1;
123
- animation-timing-function: ease-in;
124
-
125
- }
126
-
127
- .highlight-off {
128
- background-color: inherit;
129
- }
130
- `;
131
- }
132
-
133
- _highlightOn(ev) {
134
- if (ev.detail.source != this && ev.detail.id === this.key) {
135
- this._className = 'highlight-on';
136
- if (ev.detail.scroll && this.disabled == false) {
137
- this.scrollIntoView({ block: "center", behaviour: 'smooth' });
138
- }
139
- if (this.duration > 0) {
140
- setTimeout(function () {
141
- this._className = 'highlight-off';
142
- }.bind(this), this.duration);
143
- }
144
- }
145
- }
146
-
147
- _highlightOff(ev) {
148
- if (ev.detail.source != this) {
149
- this._className = 'highlight-off';
150
- }
151
- }
152
-
153
- /**
154
- * Fired if mouse pointer enters the element
155
- *
156
- * @event pb-highlight-on
157
- * @param {String} id key
158
- * @param {Object} source this element
159
- * @param {scroll} should target scroll to highlighted position
160
- */
161
-
162
- /**
163
- * Fired if mouse pointer leaves the element
164
- *
165
- * @event pb-highlight-off
166
- * @param {Object} source this element
167
- */
151
+ }
152
+
153
+ /**
154
+ * Fired if mouse pointer enters the element
155
+ *
156
+ * @event pb-highlight-on
157
+ * @param {String} id key
158
+ * @param {Object} source this element
159
+ * @param {scroll} should target scroll to highlighted position
160
+ */
161
+
162
+ /**
163
+ * Fired if mouse pointer leaves the element
164
+ *
165
+ * @event pb-highlight-off
166
+ * @param {Object} source this element
167
+ */
168
168
  }
169
- customElements.define('pb-highlight', PbHighlight);
169
+ customElements.define('pb-highlight', PbHighlight);
package/src/pb-hotkeys.js CHANGED
@@ -1,18 +1,16 @@
1
1
  import hotkeys from 'hotkeys-js';
2
2
 
3
- const EXCLUDED_TAGS = [
4
- 'INPUT', 'SELECT', 'TEXTAREA', 'PAPER-INPUT', 'PAPER-TEXTAREA', 'PB-SEARCH'
5
- ];
3
+ const EXCLUDED_TAGS = ['INPUT', 'SELECT', 'TEXTAREA', 'PAPER-INPUT', 'PAPER-TEXTAREA', 'PB-SEARCH'];
6
4
  const excluded = new Set(EXCLUDED_TAGS);
7
5
 
8
6
  // disable hotkeys for form elements
9
7
  let firstLoad = true;
10
8
  if (firstLoad) {
11
- hotkeys.filter = (event) => {
12
- const tagName = (event.target || event.srcElement).tagName;
13
- return !(tagName.isContentEditable || excluded.has(tagName));
14
- }
15
- firstLoad = false;
9
+ hotkeys.filter = event => {
10
+ const { tagName } = event.target || event.srcElement;
11
+ return !(tagName.isContentEditable || excluded.has(tagName));
12
+ };
13
+ firstLoad = false;
16
14
  }
17
15
 
18
16
  /**
@@ -21,56 +19,56 @@ if (firstLoad) {
21
19
  * can then map the symbolic name to a function by calling `registerHotkey`.
22
20
  *
23
21
  */
24
- export const pbHotkeys = (superclass) => class PbHotkeys extends superclass {
25
-
22
+ export const pbHotkeys = superclass =>
23
+ class PbHotkeys extends superclass {
26
24
  static get properties() {
27
- return {
28
- ...super.properties,
29
- hotkeys: {
30
- type: Object
31
- }
32
- };
33
- };
25
+ return {
26
+ ...super.properties,
27
+ hotkeys: {
28
+ type: Object,
29
+ },
30
+ };
31
+ }
34
32
 
35
33
  constructor() {
36
- super();
37
- this.hotkeys = {};
34
+ super();
35
+ this.hotkeys = {};
38
36
  }
39
37
 
40
38
  /**
41
- *
39
+ *
42
40
  * @param {String} name symbolic name, must be defined in `this.hotkeys`
43
41
  * @param {import('hotkeys-js').KeyHandler} callback a callback function
44
42
  */
45
43
  registerHotkey(name, callback, target) {
46
- if (name && this.hotkeys[name]) {
47
- if (target) {
48
- hotkeys(this.hotkeys[name], { element: target }, callback);
49
- } else {
50
- hotkeys(this.hotkeys[name], callback);
51
- }
44
+ if (name && this.hotkeys[name]) {
45
+ if (target) {
46
+ hotkeys(this.hotkeys[name], { element: target }, callback);
47
+ } else {
48
+ hotkeys(this.hotkeys[name], callback);
52
49
  }
50
+ }
53
51
  }
54
52
 
55
53
  display(name) {
56
- if (name && this.hotkeys[name]) {
57
- let output = [];
58
- const keys = this.hotkeys[name].split(/\s*,\s*/);
59
- keys.forEach((key) => {
60
- output.push(key.replace('+', '-'));
61
- });
62
- return output.join(', ');
63
- }
64
- return '';
54
+ if (name && this.hotkeys[name]) {
55
+ const output = [];
56
+ const keys = this.hotkeys[name].split(/\s*,\s*/);
57
+ keys.forEach(key => {
58
+ output.push(key.replace('+', '-'));
59
+ });
60
+ return output.join(', ');
61
+ }
62
+ return '';
65
63
  }
66
- }
64
+ };
67
65
 
68
66
  export function registerHotkey(name, callback, target) {
69
- if (target) {
70
- hotkeys(name, { element: target }, callback);
71
- } else {
72
- hotkeys(name, callback);
73
- }
67
+ if (target) {
68
+ hotkeys(name, { element: target }, callback);
69
+ } else {
70
+ hotkeys(name, callback);
71
+ }
74
72
  }
75
73
 
76
- window.pbKeyboard = registerHotkey;
74
+ window.pbKeyboard = registerHotkey;
package/src/pb-i18n.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LitElement, html } from 'lit-element';
2
- import { directive, NodePart, AttributePart } from "lit-html";
2
+ import { directive, NodePart, AttributePart } from 'lit-html';
3
3
 
4
4
  // Cache created lit-html parts, so we can update translations
5
5
  const partCache = new Map();
@@ -7,92 +7,89 @@ const partCache = new Map();
7
7
  // The currently used i18next translation function
8
8
  let _translate;
9
9
 
10
- /**
10
+ /**
11
11
  * Called by pb-page before the first pb-i18n-update
12
12
  * to make sure the translation function is set.
13
13
  */
14
14
  export function initTranslation(translate) {
15
- _translate = translate;
15
+ _translate = translate;
16
16
  }
17
17
 
18
18
  function isConnected(part) {
19
- if (part instanceof NodePart) {
20
- return part.startNode.isConnected;
21
-
22
- }
23
- if (part instanceof AttributePart) {
24
- return part.committer.element.isConnected;
25
-
26
- }
27
- return part.element.isConnected;
19
+ if (part instanceof NodePart) {
20
+ return part.startNode.isConnected;
21
+ }
22
+ if (part instanceof AttributePart) {
23
+ return part.committer.element.isConnected;
24
+ }
25
+ return part.element.isConnected;
28
26
  }
29
27
 
30
28
  function removeDisconnectedParts() {
31
- Object.keys(partCache).forEach((part) => {
32
- if (!isConnected(part)) {
33
- partCache.delete(part);
34
- }
35
- });
29
+ Object.keys(partCache).forEach(part => {
30
+ if (!isConnected(part)) {
31
+ partCache.delete(part);
32
+ }
33
+ });
36
34
  }
37
35
 
38
36
  function whenIdle(cb) {
39
- "requestIdleCallback" in window ? window.requestIdleCallback(cb) : setTimeout(cb)
37
+ 'requestIdleCallback' in window ? window.requestIdleCallback(cb) : setTimeout(cb);
40
38
  }
41
39
 
42
40
  function updatePart(part, cb) {
41
+ // Grab the new value
42
+ const newValue = cb();
43
43
 
44
- // Grab the new value
45
- const newValue = cb();
44
+ // Only set the value if it has changed
45
+ if (part.value === newValue) {
46
+ return;
47
+ }
46
48
 
47
- // Only set the value if it has changed
48
- if (part.value === newValue) {
49
- return;
50
- }
51
-
52
- // Set the new value
53
- part.setValue(newValue);
54
- part.commit();
49
+ // Set the new value
50
+ part.setValue(newValue);
51
+ part.commit();
55
52
  }
56
53
 
57
54
  function updateParts(options) {
58
- _translate = options.t;
59
- partCache.forEach((cb, part) => {
60
- if (isConnected(part)) {
61
- updatePart(part, cb);
62
- }
63
- });
55
+ _translate = options.t;
56
+ partCache.forEach((cb, part) => {
57
+ if (isConnected(part)) {
58
+ updatePart(part, cb);
59
+ }
60
+ });
64
61
  }
65
62
 
66
63
  /**
67
64
  * Translate the given string using i18n.
68
- *
65
+ *
69
66
  * @param {String} key The key to translate
70
67
  * @param {Object} [value] Optional object containing interpolation values
71
- * @returns
68
+ * @returns
72
69
  */
73
70
  export function get(key, value) {
74
- if (_translate) {
75
- return _translate(key, value);
76
- }
77
- return key;
71
+ if (_translate) {
72
+ return _translate(key, value);
73
+ }
74
+ return key;
78
75
  }
79
76
 
80
- export const langChanged = directive((cb) => (part) => {
81
- partCache.set(part, cb);
82
- updatePart(part, cb);
77
+ export const langChanged = directive(cb => part => {
78
+ partCache.set(part, cb);
79
+ updatePart(part, cb);
83
80
  });
84
81
 
85
82
  /**
86
83
  * lit-html directive to translate a given key into the target language
87
84
  * using i18next.
88
- *
85
+ *
89
86
  * @param {String} key The key to translate
90
87
  * @param {Object} [value] Optional object containing interpolation values
91
88
  */
92
89
  export const translate = (key, value) => langChanged(() => get(key, value));
93
90
 
94
- document.addEventListener('pb-i18n-update', (ev) => {
95
- updateParts(ev.detail);
91
+ document.addEventListener('pb-i18n-update', ev => {
92
+ updateParts(ev.detail);
96
93
  });
97
94
 
98
95
  // start a background task to garbage collect parts
@@ -103,65 +100,65 @@ setInterval(() => whenIdle(() => removeDisconnectedParts()), 1000 * 60);
103
100
  * display the contained content.
104
101
  */
105
102
  export class PbI18n extends LitElement {
106
- static get properties() {
107
- return {
108
- ...super.properties,
109
- /**
110
- * The i18n key to use for looking up the translation.
111
- */
112
- key: {
113
- type: String
114
- },
115
- /**
116
- * Optional interpolation parameters to be passed to the
117
- * translation function
118
- */
119
- options: {
120
- type: Object
121
- },
122
- _translated: {
123
- type: String
124
- }
125
- };
126
- }
127
-
128
- constructor() {
129
- super();
130
- this.key = 'missing-key';
131
- this._options = null;
132
- this._translated = null;
133
- }
134
-
135
- connectedCallback() {
136
- super.connectedCallback();
137
-
138
- this._fallback = this.innerHTML;
139
-
140
- document.addEventListener('pb-i18n-update', this._translate.bind(this));
141
-
142
- this._translate();
103
+ static get properties() {
104
+ return {
105
+ ...super.properties,
106
+ /**
107
+ * The i18n key to use for looking up the translation.
108
+ */
109
+ key: {
110
+ type: String,
111
+ },
112
+ /**
113
+ * Optional interpolation parameters to be passed to the
114
+ * translation function
115
+ */
116
+ options: {
117
+ type: Object,
118
+ },
119
+ _translated: {
120
+ type: String,
121
+ },
122
+ };
123
+ }
124
+
125
+ constructor() {
126
+ super();
127
+ this.key = 'missing-key';
128
+ this._options = null;
129
+ this._translated = null;
130
+ }
131
+
132
+ connectedCallback() {
133
+ super.connectedCallback();
134
+
135
+ this._fallback = this.innerHTML;
136
+
137
+ document.addEventListener('pb-i18n-update', this._translate.bind(this));
138
+
139
+ this._translate();
140
+ }
141
+
142
+ set options(value) {
143
+ this._options = value;
144
+ this._translate();
145
+ }
146
+
147
+ _translate() {
148
+ const transl = get(this.key, this._options);
149
+ if (transl && transl !== this.key) {
150
+ this._translated = transl;
151
+ } else {
152
+ this._translated = null;
143
153
  }
154
+ }
144
155
 
145
- set options(value) {
146
- this._options = value;
147
- this._translate();
148
- }
156
+ render() {
157
+ return this._translated ? this._translated : this._fallback;
158
+ }
149
159
 
150
- _translate() {
151
- const transl = get(this.key, this._options);
152
- if (transl && transl !== this.key) {
153
- this._translated = transl;
154
- } else {
155
- this._translated = null;
156
- }
157
- }
158
-
159
- render() {
160
- return this._translated ? this._translated : this._fallback;
161
- }
162
-
163
- createRenderRoot() {
164
- return this;
165
- }
160
+ createRenderRoot() {
161
+ return this;
162
+ }
166
163
  }
167
- customElements.define('pb-i18n', PbI18n);
164
+ customElements.define('pb-i18n', PbI18n);