@teipublisher/pb-components 2.26.0-next-3.12 → 2.26.0-next-3.13

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 (132) 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 +30 -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-progress.html +2 -2
  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 +1937 -1782
  16. package/dist/pb-edit-app.js +167 -107
  17. package/dist/pb-elements.json +45 -45
  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 +923 -756
  23. package/dist/pb-tify.js +2 -2
  24. package/dist/{vaadin-element-mixin-49ab4037.js → vaadin-element-mixin-84fb7d82.js} +178 -163
  25. package/gh-pages.js +5 -3
  26. package/i18n/common/pl.json +2 -2
  27. package/lib/openseadragon.min.js +1 -1
  28. package/package.json +2 -2
  29. package/pb-elements.json +45 -45
  30. package/src/assets/components.css +5 -5
  31. package/src/authority/airtable.js +20 -21
  32. package/src/authority/anton.js +129 -129
  33. package/src/authority/custom.js +23 -21
  34. package/src/authority/geonames.js +38 -32
  35. package/src/authority/gnd.js +47 -42
  36. package/src/authority/kbga.js +137 -134
  37. package/src/authority/metagrid.js +44 -46
  38. package/src/authority/reconciliation.js +66 -67
  39. package/src/authority/registry.js +4 -4
  40. package/src/docs/pb-component-docs.js +2 -2
  41. package/src/docs/pb-component-view.js +5 -5
  42. package/src/docs/pb-components-list.js +2 -2
  43. package/src/docs/pb-demo-snippet.js +2 -2
  44. package/src/dts-client.js +299 -297
  45. package/src/dts-select-endpoint.js +90 -82
  46. package/src/parse-date-service.js +184 -135
  47. package/src/pb-ajax.js +150 -146
  48. package/src/pb-authority-lookup.js +183 -146
  49. package/src/pb-autocomplete.js +292 -280
  50. package/src/pb-blacklab-highlight.js +264 -259
  51. package/src/pb-blacklab-results.js +236 -221
  52. package/src/pb-browse-docs.js +540 -475
  53. package/src/pb-browse.js +68 -65
  54. package/src/pb-clipboard.js +79 -76
  55. package/src/pb-code-editor.js +110 -102
  56. package/src/pb-code-highlight.js +209 -204
  57. package/src/pb-codepen.js +79 -72
  58. package/src/pb-collapse.js +212 -207
  59. package/src/pb-combo-box.js +190 -190
  60. package/src/pb-components-bundle.js +1 -1
  61. package/src/pb-custom-form.js +151 -149
  62. package/src/pb-dialog.js +94 -85
  63. package/src/pb-document.js +89 -90
  64. package/src/pb-download.js +210 -198
  65. package/src/pb-drawer.js +145 -148
  66. package/src/pb-edit-app.js +301 -229
  67. package/src/pb-edit-xml.js +98 -96
  68. package/src/pb-events.js +114 -107
  69. package/src/pb-facs-link.js +104 -102
  70. package/src/pb-facsimile.js +411 -413
  71. package/src/pb-formula.js +151 -153
  72. package/src/pb-geolocation.js +129 -131
  73. package/src/pb-grid-action.js +53 -56
  74. package/src/pb-grid.js +231 -228
  75. package/src/pb-highlight.js +140 -140
  76. package/src/pb-hotkeys.js +40 -42
  77. package/src/pb-i18n.js +101 -104
  78. package/src/pb-image-strip.js +84 -78
  79. package/src/pb-lang.js +132 -128
  80. package/src/pb-leaflet-map.js +488 -485
  81. package/src/pb-link.js +126 -124
  82. package/src/pb-load.js +431 -426
  83. package/src/pb-login.js +291 -248
  84. package/src/pb-manage-odds.js +364 -318
  85. package/src/pb-map-icon.js +89 -89
  86. package/src/pb-map-layer.js +85 -85
  87. package/src/pb-markdown.js +90 -99
  88. package/src/pb-media-query.js +74 -72
  89. package/src/pb-mei.js +306 -295
  90. package/src/pb-message.js +144 -144
  91. package/src/pb-mixin.js +269 -264
  92. package/src/pb-navigation.js +80 -82
  93. package/src/pb-observable.js +38 -38
  94. package/src/pb-odd-editor.js +1053 -955
  95. package/src/pb-odd-elementspec-editor.js +348 -297
  96. package/src/pb-odd-model-editor.js +1061 -901
  97. package/src/pb-odd-parameter-editor.js +200 -178
  98. package/src/pb-odd-rendition-editor.js +136 -124
  99. package/src/pb-page.js +431 -421
  100. package/src/pb-paginate.js +202 -190
  101. package/src/pb-panel.js +191 -179
  102. package/src/pb-popover-themes.js +7 -5
  103. package/src/pb-popover.js +296 -287
  104. package/src/pb-print-preview.js +127 -127
  105. package/src/pb-progress.js +51 -51
  106. package/src/pb-repeat.js +105 -104
  107. package/src/pb-restricted.js +84 -77
  108. package/src/pb-search.js +252 -241
  109. package/src/pb-select-feature.js +127 -120
  110. package/src/pb-select-odd.js +132 -124
  111. package/src/pb-select-template.js +89 -78
  112. package/src/pb-select.js +251 -227
  113. package/src/pb-split-list.js +179 -174
  114. package/src/pb-svg.js +80 -79
  115. package/src/pb-table-column.js +54 -54
  116. package/src/pb-table-grid.js +221 -203
  117. package/src/pb-tabs.js +61 -63
  118. package/src/pb-tify.js +154 -154
  119. package/src/pb-timeline.js +271 -229
  120. package/src/pb-toggle-feature.js +182 -175
  121. package/src/pb-upload.js +184 -174
  122. package/src/pb-version.js +30 -30
  123. package/src/pb-view-annotate.js +132 -98
  124. package/src/pb-view.js +1289 -1270
  125. package/src/pb-zoom.js +75 -59
  126. package/src/polymer-hack.js +1 -1
  127. package/src/search-result-service.js +256 -223
  128. package/src/seed-element.js +13 -20
  129. package/src/settings.js +4 -4
  130. package/src/theming.js +96 -96
  131. package/src/urls.js +289 -289
  132. 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
  }