@teipublisher/pb-components 2.25.5 → 2.25.6

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 (128) 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 +8 -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-leaflet-map.html +1 -1
  9. package/dist/demo/pb-repeat.html +1 -3
  10. package/dist/demo/pb-view3.html +1 -1
  11. package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
  12. package/dist/pb-code-editor.js +25 -20
  13. package/dist/pb-component-docs.js +58 -54
  14. package/dist/pb-components-bundle.js +1827 -1520
  15. package/dist/pb-edit-app.js +167 -107
  16. package/dist/pb-elements.json +54 -54
  17. package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
  18. package/dist/pb-leaflet-map.js +23 -23
  19. package/dist/pb-mei.js +56 -41
  20. package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
  21. package/dist/pb-odd-editor.js +925 -758
  22. package/dist/pb-tify.js +2 -2
  23. package/dist/{vaadin-element-mixin-859a0132.js → vaadin-element-mixin-ad07ba25.js} +88 -61
  24. package/gh-pages.js +5 -3
  25. package/package.json +2 -2
  26. package/pb-elements.json +54 -54
  27. package/src/assets/components.css +5 -5
  28. package/src/authority/airtable.js +20 -21
  29. package/src/authority/anton.js +129 -129
  30. package/src/authority/custom.js +23 -21
  31. package/src/authority/geonames.js +38 -32
  32. package/src/authority/gnd.js +47 -42
  33. package/src/authority/kbga.js +137 -134
  34. package/src/authority/metagrid.js +44 -46
  35. package/src/authority/reconciliation.js +66 -67
  36. package/src/authority/registry.js +4 -4
  37. package/src/docs/pb-component-docs.js +2 -2
  38. package/src/docs/pb-component-view.js +5 -5
  39. package/src/docs/pb-components-list.js +2 -2
  40. package/src/docs/pb-demo-snippet.js +2 -2
  41. package/src/dts-client.js +299 -297
  42. package/src/dts-select-endpoint.js +90 -82
  43. package/src/parse-date-service.js +184 -135
  44. package/src/pb-ajax.js +171 -167
  45. package/src/pb-authority-lookup.js +96 -81
  46. package/src/pb-autocomplete.js +292 -280
  47. package/src/pb-blacklab-highlight.js +264 -259
  48. package/src/pb-blacklab-results.js +236 -221
  49. package/src/pb-browse-docs.js +540 -475
  50. package/src/pb-browse.js +68 -65
  51. package/src/pb-clipboard.js +79 -76
  52. package/src/pb-code-editor.js +110 -102
  53. package/src/pb-code-highlight.js +209 -204
  54. package/src/pb-codepen.js +79 -72
  55. package/src/pb-collapse.js +149 -146
  56. package/src/pb-combo-box.js +190 -190
  57. package/src/pb-components-bundle.js +1 -1
  58. package/src/pb-custom-form.js +150 -149
  59. package/src/pb-document.js +89 -90
  60. package/src/pb-download.js +208 -195
  61. package/src/pb-drawer.js +145 -148
  62. package/src/pb-edit-app.js +301 -229
  63. package/src/pb-edit-xml.js +99 -96
  64. package/src/pb-events.js +114 -107
  65. package/src/pb-facs-link.js +104 -102
  66. package/src/pb-facsimile.js +411 -413
  67. package/src/pb-formula.js +151 -153
  68. package/src/pb-geolocation.js +129 -131
  69. package/src/pb-grid-action.js +53 -56
  70. package/src/pb-grid.js +231 -228
  71. package/src/pb-highlight.js +140 -140
  72. package/src/pb-hotkeys.js +40 -42
  73. package/src/pb-i18n.js +101 -104
  74. package/src/pb-image-strip.js +84 -78
  75. package/src/pb-lang.js +83 -70
  76. package/src/pb-leaflet-map.js +488 -485
  77. package/src/pb-link.js +126 -124
  78. package/src/pb-load.js +431 -426
  79. package/src/pb-login.js +275 -254
  80. package/src/pb-manage-odds.js +364 -318
  81. package/src/pb-map-icon.js +89 -89
  82. package/src/pb-map-layer.js +85 -85
  83. package/src/pb-markdown.js +90 -99
  84. package/src/pb-media-query.js +74 -72
  85. package/src/pb-mei.js +306 -295
  86. package/src/pb-message.js +143 -130
  87. package/src/pb-mixin.js +269 -264
  88. package/src/pb-navigation.js +80 -82
  89. package/src/pb-observable.js +38 -38
  90. package/src/pb-odd-editor.js +1056 -958
  91. package/src/pb-odd-elementspec-editor.js +348 -297
  92. package/src/pb-odd-model-editor.js +1058 -898
  93. package/src/pb-odd-parameter-editor.js +200 -178
  94. package/src/pb-odd-rendition-editor.js +136 -124
  95. package/src/pb-page.js +432 -422
  96. package/src/pb-paginate.js +202 -190
  97. package/src/pb-panel.js +191 -179
  98. package/src/pb-popover-themes.js +7 -5
  99. package/src/pb-popover.js +296 -287
  100. package/src/pb-print-preview.js +127 -127
  101. package/src/pb-progress.js +49 -49
  102. package/src/pb-repeat.js +105 -104
  103. package/src/pb-restricted.js +84 -77
  104. package/src/pb-search.js +238 -221
  105. package/src/pb-select-feature.js +127 -120
  106. package/src/pb-select-odd.js +132 -124
  107. package/src/pb-select-template.js +89 -78
  108. package/src/pb-select.js +251 -227
  109. package/src/pb-split-list.js +179 -174
  110. package/src/pb-svg.js +80 -79
  111. package/src/pb-table-column.js +54 -54
  112. package/src/pb-table-grid.js +221 -203
  113. package/src/pb-tabs.js +61 -63
  114. package/src/pb-tify.js +154 -154
  115. package/src/pb-timeline.js +271 -229
  116. package/src/pb-toggle-feature.js +198 -185
  117. package/src/pb-upload.js +184 -174
  118. package/src/pb-version.js +30 -30
  119. package/src/pb-view-annotate.js +132 -98
  120. package/src/pb-view.js +1282 -1263
  121. package/src/pb-zoom.js +40 -40
  122. package/src/polymer-hack.js +1 -1
  123. package/src/search-result-service.js +256 -223
  124. package/src/seed-element.js +13 -20
  125. package/src/settings.js +4 -4
  126. package/src/theming.js +91 -91
  127. package/src/urls.js +289 -289
  128. package/src/utils.js +53 -51
@@ -1,72 +1,69 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
2
  import { pbMixin } from './pb-mixin.js';
3
3
 
4
-
5
4
  /**
6
5
  * an action component to execute an 'add panel' or 'remove panel' action on a pb-grid.
7
6
  *
8
7
  * @slot - default unnamed slot for content
9
- *
8
+ *
10
9
  */
11
10
  export class PbGridAction extends pbMixin(LitElement) {
12
- static get properties() {
13
- return {
14
- ...super.properties,
15
- /**
16
- * the type of action. Can be either `add` or `remove`
17
- *
18
- * Defaults to `add`
19
- */
20
- action: {
21
- type: String
22
- },
23
- /**
24
- * reference to a pb-grid element
25
- */
26
- grid: {
27
- type: String
28
- },
29
- initial: {
30
- type: Number
31
- },
32
- };
33
- }
11
+ static get properties() {
12
+ return {
13
+ ...super.properties,
14
+ /**
15
+ * the type of action. Can be either `add` or `remove`
16
+ *
17
+ * Defaults to `add`
18
+ */
19
+ action: {
20
+ type: String,
21
+ },
22
+ /**
23
+ * reference to a pb-grid element
24
+ */
25
+ grid: {
26
+ type: String,
27
+ },
28
+ initial: {
29
+ type: Number,
30
+ },
31
+ };
32
+ }
34
33
 
35
- constructor() {
36
- super();
37
- this.action = 'add';
38
- this.initial = 0;
39
- }
34
+ constructor() {
35
+ super();
36
+ this.action = 'add';
37
+ this.initial = 0;
38
+ }
40
39
 
41
- connectedCallback() {
42
- super.connectedCallback();
43
- }
40
+ connectedCallback() {
41
+ super.connectedCallback();
42
+ }
44
43
 
45
- render() {
46
- return html`
47
- <a @click="${this._click}"><slot></slot></a>
48
- `;
49
- }
44
+ render() {
45
+ return html` <a @click="${this._click}"><slot></slot></a> `;
46
+ }
50
47
 
51
- static get styles() {
52
- return css`
53
- :host {
54
- display: block;
55
- }
56
- `;
57
- }
48
+ static get styles() {
49
+ return css`
50
+ :host {
51
+ display: block;
52
+ }
53
+ `;
54
+ }
58
55
 
59
- _click() {
60
- // todo: grid must be in lightDOM to be discovered. What is expected for this.grid? A string like '#myId'?
61
- const grid = document.querySelector(this.grid);
62
- if (!(grid && grid.addPanel)) {
63
- return console.error('<pb-grid-action> grid not found: %s', this.grid);
64
- }
65
- if (this.action === 'add') {
66
- grid.addPanel(this.initial);
67
- } else {
68
- grid.removePanel(this.parentNode);
69
- }
56
+ _click() {
57
+ // todo: grid must be in lightDOM to be discovered. What is expected for this.grid? A string like '#myId'?
58
+ const grid = document.querySelector(this.grid);
59
+ if (!(grid && grid.addPanel)) {
60
+ return console.error('<pb-grid-action> grid not found: %s', this.grid);
61
+ }
62
+ if (this.action === 'add') {
63
+ grid.addPanel(this.initial);
64
+ } else {
65
+ grid.removePanel(this.parentNode);
70
66
  }
67
+ }
71
68
  }
72
- customElements.define('pb-grid-action', PbGridAction);
69
+ customElements.define('pb-grid-action', PbGridAction);
package/src/pb-grid.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
2
  import { pbMixin } from './pb-mixin.js';
3
- import { registry } from "./urls.js";
3
+ import { registry } from './urls.js';
4
4
  import './pb-panel.js';
5
5
 
6
6
  /**
@@ -15,265 +15,268 @@ import './pb-panel.js';
15
15
  * @cssprop --pb-grid-column-gap - Width of the gap between columns
16
16
  */
17
17
  export class PbGrid extends pbMixin(LitElement) {
18
- static get properties() {
19
- return {
20
- ...super.properties,
21
- /**
22
- * an array of panel items to display when the component is loaded. It should contain a
23
- * number for each panel to show, indicating the ordinal position of the template within the `<pb-panel>`
24
- * to initialize. For example, if you have two templates in `<pb-panel>`: "transcription" and "translation",
25
- * setting `panels="[0, 1]"` will show two columns, one with the transcription, the other with the translation.
26
- *
27
- * Passing in a browser parameter `panels` with a comma-separated list will set this property as well.
28
- */
29
- panels: {
30
- type: Array
31
- },
32
- direction: {
33
- type: String
34
- },
35
- /**
36
- * the number of columns
37
- */
38
- _columns: {
39
- type: Number
40
- },
41
- /**
42
- * CSS Selektor to choose elements to animate. If not specified all 'pb-view' elements will be animated by default.
43
- */
44
- animated: {
45
- type: String
46
- },
47
- /**
48
- * wether to animate the view when new page is loaded. Defaults to 'false' meaning that no
49
- * animation takes place.
50
- */
51
- animation: {
52
- type: Boolean
53
- }
54
- };
55
- }
18
+ static get properties() {
19
+ return {
20
+ ...super.properties,
21
+ /**
22
+ * an array of panel items to display when the component is loaded. It should contain a
23
+ * number for each panel to show, indicating the ordinal position of the template within the `<pb-panel>`
24
+ * to initialize. For example, if you have two templates in `<pb-panel>`: "transcription" and "translation",
25
+ * setting `panels="[0, 1]"` will show two columns, one with the transcription, the other with the translation.
26
+ *
27
+ * Passing in a browser parameter `panels` with a comma-separated list will set this property as well.
28
+ */
29
+ panels: {
30
+ type: Array,
31
+ },
32
+ direction: {
33
+ type: String,
34
+ },
35
+ /**
36
+ * the number of columns
37
+ */
38
+ _columns: {
39
+ type: Number,
40
+ },
41
+ /**
42
+ * CSS Selektor to choose elements to animate. If not specified all 'pb-view' elements will be animated by default.
43
+ */
44
+ animated: {
45
+ type: String,
46
+ },
47
+ /**
48
+ * wether to animate the view when new page is loaded. Defaults to 'false' meaning that no
49
+ * animation takes place.
50
+ */
51
+ animation: {
52
+ type: Boolean,
53
+ },
54
+ };
55
+ }
56
56
 
57
- constructor() {
58
- super();
59
- this.panels = [];
60
- this.direction = 'ltr';
61
- this.animated = 'pb-view';
62
- this.animation = false;
63
- }
57
+ constructor() {
58
+ super();
59
+ this.panels = [];
60
+ this.direction = 'ltr';
61
+ this.animated = 'pb-view';
62
+ this.animation = false;
63
+ }
64
64
 
65
- connectedCallback() {
66
- super.connectedCallback();
65
+ connectedCallback() {
66
+ super.connectedCallback();
67
67
 
68
- this.subscribeTo('pb-panel', ev => {
69
- const idx = this._getPanelIndex(ev.detail.panel);
70
- if (idx < 0) {
71
- return // panel not found
72
- }
73
- console.log('<pb-grid> Updating panel %d to show %s', idx, ev.detail.active);
74
- this.panels[this.direction === 'rtl' ? this.panels.length - idx - 1 : idx] = ev.detail.active;
68
+ this.subscribeTo('pb-panel', ev => {
69
+ const idx = this._getPanelIndex(ev.detail.panel);
70
+ if (idx < 0) {
71
+ return; // panel not found
72
+ }
73
+ console.log('<pb-grid> Updating panel %d to show %s', idx, ev.detail.active);
74
+ this.panels[this.direction === 'rtl' ? this.panels.length - idx - 1 : idx] = ev.detail.active;
75
75
 
76
- registry.commit(this, this._getState())
77
- });
76
+ registry.commit(this, this._getState());
77
+ });
78
78
 
79
- this.subscribeTo('pb-zoom', ev => {
80
- this.zoom(ev.detail.direction);
81
- });
79
+ this.subscribeTo('pb-zoom', ev => {
80
+ this.zoom(ev.detail.direction);
81
+ });
82
82
 
83
- const panelsParam = registry.get('panels');
84
- if (panelsParam) {
85
- this.panels = panelsParam.split('.').map(param => parseInt(param));
86
- }
87
-
88
- registry.subscribe(this, (state) => {
89
- const newState = state.panels ? state.panels.split('.') : [];
90
- this.panels = newState;
91
- this.innerHTML=''; // hard reset of child DOM
92
- this.panels.forEach(panelNum => this._insertPanel(panelNum));
93
- this._update();
94
- });
95
- this._columns = this.panels.length;
96
- this.template = this.querySelector('template');
83
+ const panelsParam = registry.get('panels');
84
+ if (panelsParam) {
85
+ this.panels = panelsParam.split('.').map(param => parseInt(param));
97
86
  }
98
87
 
99
- firstUpdated() {
88
+ registry.subscribe(this, state => {
89
+ const newState = state.panels ? state.panels.split('.') : [];
90
+ this.panels = newState;
91
+ this.innerHTML = ''; // hard reset of child DOM
92
+ this.panels.forEach(panelNum => this._insertPanel(panelNum));
93
+ this._update();
94
+ });
95
+ this._columns = this.panels.length;
96
+ this.template = this.querySelector('template');
97
+ }
100
98
 
101
- this.panels.forEach(panelNum => this._insertPanel(panelNum));
102
- registry.commit(this, this._getState())
103
- this._animate();
104
- this._update();
99
+ firstUpdated() {
100
+ this.panels.forEach(panelNum => this._insertPanel(panelNum));
101
+ registry.commit(this, this._getState());
102
+ this._animate();
103
+ this._update();
105
104
 
106
- this.addEventListener('pb-drop', (ev) => {
107
- const draggedPanelIdx = parseInt(ev.detail.panel);
108
- const targetPanelIdx = this._getPanelIndex(ev.detail.target);
105
+ this.addEventListener('pb-drop', ev => {
106
+ const draggedPanelIdx = parseInt(ev.detail.panel);
107
+ const targetPanelIdx = this._getPanelIndex(ev.detail.target);
109
108
 
110
- console.log('<pb-grid> Insert panel %d at %d in %s', draggedPanelIdx, targetPanelIdx, this.panels);
111
- this.querySelectorAll('._grid_panel').forEach((panel) => {
112
- panel.classList.remove('dragover');
113
- });
114
-
115
- this.panels.splice(targetPanelIdx, 0, this.panels.splice(draggedPanelIdx, 1)[0]);
116
- this.innerHTML=''; // hard reset of child DOM
117
- this.panels.forEach(panelNum => this._insertPanel(panelNum));
118
- registry.commit(this, this._getState());
119
- this._update();
109
+ console.log(
110
+ '<pb-grid> Insert panel %d at %d in %s',
111
+ draggedPanelIdx,
112
+ targetPanelIdx,
113
+ this.panels,
114
+ );
115
+ this.querySelectorAll('._grid_panel').forEach(panel => {
116
+ panel.classList.remove('dragover');
117
+ });
118
+
119
+ this.panels.splice(targetPanelIdx, 0, this.panels.splice(draggedPanelIdx, 1)[0]);
120
+ this.innerHTML = ''; // hard reset of child DOM
121
+ this.panels.forEach(panelNum => this._insertPanel(panelNum));
122
+ registry.commit(this, this._getState());
123
+ this._update();
124
+ });
125
+ }
126
+
127
+ /**
128
+ * slides in all panels from left to right with a slight delay between the panels. If animejs is not
129
+ * loaded nothing happens and content is displayed as usual.
130
+ */
131
+ _animate() {
132
+ if (this.animation) {
133
+ if (typeof anime && 'anime' in window) {
134
+ // console.log('animated elements', document.querySelectorAll('pb-panel'));
135
+ const animated = document.querySelectorAll(this.animated);
136
+ const anim = anime.timeline({
137
+ easing: 'linear',
138
+ duration: 400,
139
+ });
140
+ anim.add({
141
+ targets: animated,
142
+ opacity: {
143
+ value: [0, 0.6],
144
+ duration: 200,
145
+ delay: 100,
146
+ easing: 'linear',
147
+ },
148
+ translateX: [2000, 0],
149
+ duration: 400,
150
+ delay: anime.stagger(100, { start: 100 }),
151
+ });
152
+ anim.add({
153
+ targets: animated,
154
+ opacity: [0.6, 1],
155
+ duration: 200,
156
+ delay: anime.stagger(50),
120
157
  });
158
+ anim.play();
159
+ }
121
160
  }
161
+ }
122
162
 
123
- /**
124
- * slides in all panels from left to right with a slight delay between the panels. If animejs is not
125
- * loaded nothing happens and content is displayed as usual.
126
- */
127
- _animate() {
128
- if (this.animation) {
129
- if (typeof anime && "anime" in window) {
130
- // console.log('animated elements', document.querySelectorAll('pb-panel'));
131
- const animated = document.querySelectorAll(this.animated);
132
- const anim = anime.timeline({
133
- easing: 'linear',
134
- duration: 400
135
- });
136
- anim.add({
137
- targets: animated,
138
- opacity: {
139
- value: [0, 0.6],
140
- duration: 200,
141
- delay: 100,
142
- easing: 'linear'
143
- },
144
- translateX: [2000, 0],
145
- duration: 400,
146
- delay: anime.stagger(100, { start: 100 })
147
- });
148
- anim.add({
149
- targets: animated,
150
- opacity: [0.6, 1],
151
- duration: 200,
152
- delay: anime.stagger(50)
153
- });
154
- anim.play();
155
- }
156
- }
163
+ /**
164
+ * Add a panel. Defaults to opening 'the next' panel if the `initial` parameter is omitted: if
165
+ * panels 1,6,3 are open, panel 7 will be added
166
+ *
167
+ * @param {number} [initial] The panel number of the panel to add.
168
+ */
169
+ addPanel(initial) {
170
+ let value = initial;
171
+ if (initial === undefined && !this.panels.length) {
172
+ value = 0;
173
+ }
174
+ if (initial === undefined && this.panels.length) {
175
+ const max = this.panels.reduce((result, next) => Math.max(result, next), 0);
176
+ value = max + 1;
157
177
  }
158
178
 
159
- /**
160
- * Add a panel. Defaults to opening 'the next' panel if the `initial` parameter is omitted: if
161
- * panels 1,6,3 are open, panel 7 will be added
162
- *
163
- * @param {number} [initial] The panel number of the panel to add.
164
- */
165
- addPanel(initial) {
166
- let value = initial;
167
- if (initial === undefined && !this.panels.length) {
168
- value = 0;
169
- }
170
- if (initial === undefined && this.panels.length) {
171
- const max = this.panels.reduce((result, next) => Math.max(result, next), 0);
172
- value = max + 1;
173
- }
179
+ this._columns += 1;
180
+ this.panels.push(value);
174
181
 
175
- this._columns += 1;
176
- this.panels.push(value);
182
+ this._insertPanel(value);
183
+ registry.commit(this, this._getState());
184
+ this._update();
185
+ this.emitTo('pb-refresh');
186
+ }
177
187
 
178
- this._insertPanel(value);
179
- registry.commit(this, this._getState());
180
- this._update();
181
- this.emitTo('pb-refresh');
188
+ /**
189
+ * Remove a panel from the grid
190
+ *
191
+ * @param {HTMLElement|number} panel the pb-panel element or the panel number
192
+ */
193
+ removePanel(panel) {
194
+ let idx;
195
+ let container;
196
+ if (typeof panel === 'number') {
197
+ idx = this.panels.indexOf(panel);
198
+ container = this.querySelector(`[active="${panel}"]`);
199
+ } else {
200
+ container = panel;
201
+ idx = this._getPanelIndex(panel);
182
202
  }
203
+ console.log('<pb-grid> Removing panel %d', idx);
204
+ this.panels.splice(this.direction === 'rtl' ? this.panels.length - idx - 1 : idx, 1);
183
205
 
184
- /**
185
- * Remove a panel from the grid
186
- *
187
- * @param {HTMLElement|number} panel the pb-panel element or the panel number
188
- */
189
- removePanel(panel) {
190
- let idx;
191
- let container;
192
- if (typeof panel === 'number') {
193
- idx = this.panels.indexOf(panel);
194
- container = this.querySelector(`[active="${panel}"]`);
195
- } else {
196
- container = panel;
197
- idx = this._getPanelIndex(panel);
198
- }
199
- console.log('<pb-grid> Removing panel %d', idx);
200
- this.panels.splice(this.direction === 'rtl' ? this.panels.length - idx - 1 : idx, 1);
206
+ container.parentNode.removeChild(container);
207
+ this._columns -= 1;
208
+ registry.commit(this, this._getState());
209
+ this._assignPanelIds();
210
+ this._update();
211
+ }
201
212
 
202
- container.parentNode.removeChild(container);
203
- this._columns -= 1;
204
- registry.commit(this, this._getState());
205
- this._assignPanelIds();
206
- this._update();
213
+ _insertPanel(active) {
214
+ const clone = document.importNode(this.template.content.firstElementChild, true);
215
+ clone.setAttribute('active', active);
216
+ if (this.direction === 'ltr' || this.querySelectorAll('._grid_panel').length === 0) {
217
+ this.appendChild(clone);
218
+ } else {
219
+ this.insertBefore(clone, this.firstElementChild);
207
220
  }
221
+ clone.classList.add('_grid_panel');
222
+ this._assignPanelIds();
223
+ }
208
224
 
209
- _insertPanel(active) {
210
- const clone = document.importNode(this.template.content.firstElementChild, true);
211
- clone.setAttribute('active', active);
212
- if (this.direction === 'ltr' || this.querySelectorAll('._grid_panel').length === 0) {
213
- this.appendChild(clone);
214
- } else {
215
- this.insertBefore(clone, this.firstElementChild);
225
+ _update() {
226
+ const widths = Array.from(this.children)
227
+ .filter(child => !(child instanceof HTMLTemplateElement))
228
+ .map(child => {
229
+ const styles = window.getComputedStyle(child);
230
+ const width = styles.getPropertyValue('max-width');
231
+ if (width && width !== 'none') {
232
+ return width;
216
233
  }
217
- clone.classList.add('_grid_panel');
218
- this._assignPanelIds();
219
- }
234
+ return '1fr';
235
+ });
236
+ this.style.setProperty('--pb-computed-column-widths', widths.join(' '));
237
+ }
220
238
 
221
- _update() {
222
- const widths = Array.from(this.children)
223
- .filter(child => !(child instanceof HTMLTemplateElement))
224
- .map(child => {
225
- const styles = window.getComputedStyle(child);
226
- const width = styles.getPropertyValue('max-width');
227
- if (width && width !== 'none') {
228
- return width;
229
- }
230
- return '1fr';
231
- });
232
- this.style.setProperty('--pb-computed-column-widths', widths.join(' '));
233
- }
239
+ _getPanelIndex(panel) {
240
+ const panels = Array.from(this.querySelectorAll('._grid_panel'));
241
+ return panels.indexOf(panel);
242
+ }
234
243
 
235
- _getPanelIndex(panel) {
236
- const panels = Array.from(this.querySelectorAll('._grid_panel'));
237
- return panels.indexOf(panel);
238
- }
244
+ _assignPanelIds() {
245
+ this.querySelectorAll('._grid_panel').forEach((panel, idx) => {
246
+ panel.position = idx;
247
+ });
248
+ }
239
249
 
240
- _assignPanelIds() {
241
- this.querySelectorAll('._grid_panel').forEach((panel, idx) => {
242
- panel.position = idx;
243
- });
244
- }
250
+ _getState() {
251
+ return { panels: this.panels.join('.') };
252
+ }
245
253
 
246
- _getState() {
247
- return { panels: this.panels.join('.') };
248
- }
249
-
250
- render() {
251
- return html`<slot></slot>`;
252
- }
254
+ render() {
255
+ return html`<slot></slot>`;
256
+ }
253
257
 
254
- static get styles() {
255
- return css`
256
- :host {
257
- display: grid;
258
- grid-template-columns: var(--pb-grid-column-widths, var(--pb-computed-column-widths));
259
- grid-column-gap: var(--pb-grid-column-gap, 20px);
260
- justify-content: space-between;
261
- }
262
- `;
263
- }
258
+ static get styles() {
259
+ return css`
260
+ :host {
261
+ display: grid;
262
+ grid-template-columns: var(--pb-grid-column-widths, var(--pb-computed-column-widths));
263
+ grid-column-gap: var(--pb-grid-column-gap, 20px);
264
+ justify-content: space-between;
265
+ }
266
+ `;
267
+ }
264
268
 
265
- zoom(direction) {
266
- const fontSize = window.getComputedStyle(this).getPropertyValue('font-size');
267
- const size = parseInt(fontSize.replace(/^(\d+)px/, "$1"));
269
+ zoom(direction) {
270
+ const fontSize = window.getComputedStyle(this).getPropertyValue('font-size');
271
+ const size = parseInt(fontSize.replace(/^(\d+)px/, '$1'));
268
272
 
269
- if (direction === 'in') {
270
- this.style.fontSize = (size + 1) + 'px';
271
- } else {
272
- this.style.fontSize = (size - 1) + 'px';
273
- }
273
+ if (direction === 'in') {
274
+ this.style.fontSize = `${size + 1}px`;
275
+ } else {
276
+ this.style.fontSize = `${size - 1}px`;
274
277
  }
275
-
278
+ }
276
279
  }
277
280
  if (!customElements.get('pb-grid')) {
278
- customElements.define('pb-grid', PbGrid);
281
+ customElements.define('pb-grid', PbGrid);
279
282
  }