@teipublisher/pb-components 2.26.1-next.3 → 3.0.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.
Files changed (154) 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 +4 -4
  4. package/.releaserc.json +2 -2
  5. package/CHANGELOG.md +262 -11
  6. package/Dockerfile +78 -70
  7. package/css/components.css +5 -5
  8. package/css/leaflet/images/layers.png +0 -0
  9. package/dist/demo/components.css +46 -1
  10. package/dist/demo/pb-browse-docs2.html +1 -1
  11. package/dist/demo/pb-dialog.html +3 -5
  12. package/dist/demo/pb-drawer2.html +1 -1
  13. package/dist/demo/pb-facsimile.html +2 -2
  14. package/dist/demo/pb-grid.html +19 -6
  15. package/dist/demo/pb-leaflet-map.html +1 -1
  16. package/dist/demo/pb-login.html +0 -2
  17. package/dist/demo/pb-message.html +1 -2
  18. package/dist/demo/pb-progress.html +2 -2
  19. package/dist/demo/pb-repeat.html +1 -3
  20. package/dist/demo/pb-search.html +7 -4
  21. package/dist/demo/pb-search3.html +1 -1
  22. package/dist/demo/pb-search4.html +2 -2
  23. package/dist/demo/pb-view3.html +1 -1
  24. package/dist/{iron-form-3b8dcaa7.js → iron-form-dfb3e3b1.js} +95 -95
  25. package/dist/paper-checkbox-645e1077.js +200 -0
  26. package/dist/{paper-icon-button-b1d31571.js → paper-icon-button-984162bd.js} +1 -1
  27. package/dist/{paper-checkbox-515a5284.js → paper-inky-focus-behavior-fa16796b.js} +58 -247
  28. package/dist/{paper-listbox-a3b7175c.js → paper-listbox-5f5d1cec.js} +152 -162
  29. package/dist/pb-code-editor.js +25 -20
  30. package/dist/pb-component-docs.js +68 -64
  31. package/dist/pb-components-bundle.js +1983 -2293
  32. package/dist/pb-edit-app.js +167 -107
  33. package/dist/pb-elements.json +176 -120
  34. package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
  35. package/dist/pb-leaflet-map.js +23 -23
  36. package/dist/pb-mei.js +56 -41
  37. package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
  38. package/dist/pb-odd-editor.js +1023 -782
  39. package/dist/pb-tify.js +2 -2
  40. package/dist/vaadin-element-mixin-beb74ffd.js +545 -0
  41. package/gh-pages.js +5 -3
  42. package/i18n/common/en.json +6 -0
  43. package/i18n/common/pl.json +2 -2
  44. package/lib/openseadragon.min.js +6 -6
  45. package/package.json +3 -3
  46. package/pb-elements.json +176 -120
  47. package/src/assets/components.css +5 -5
  48. package/src/authority/airtable.js +20 -21
  49. package/src/authority/anton.js +129 -129
  50. package/src/authority/custom.js +23 -21
  51. package/src/authority/geonames.js +38 -32
  52. package/src/authority/gnd.js +50 -42
  53. package/src/authority/kbga.js +137 -134
  54. package/src/authority/metagrid.js +44 -46
  55. package/src/authority/reconciliation.js +66 -67
  56. package/src/authority/registry.js +4 -4
  57. package/src/docs/pb-component-docs.js +2 -2
  58. package/src/docs/pb-component-view.js +5 -5
  59. package/src/docs/pb-components-list.js +2 -2
  60. package/src/docs/pb-demo-snippet.js +2 -2
  61. package/src/dts-client.js +299 -297
  62. package/src/dts-select-endpoint.js +90 -82
  63. package/src/parse-date-service.js +184 -135
  64. package/src/pb-ajax.js +158 -171
  65. package/src/pb-authority-lookup.js +191 -156
  66. package/src/pb-autocomplete.js +292 -280
  67. package/src/pb-blacklab-highlight.js +264 -259
  68. package/src/pb-blacklab-results.js +236 -221
  69. package/src/pb-browse-docs.js +540 -475
  70. package/src/pb-browse.js +68 -65
  71. package/src/pb-clipboard.js +79 -76
  72. package/src/pb-code-editor.js +110 -102
  73. package/src/pb-code-highlight.js +209 -204
  74. package/src/pb-codepen.js +79 -72
  75. package/src/pb-collapse.js +211 -151
  76. package/src/pb-combo-box.js +190 -190
  77. package/src/pb-components-bundle.js +1 -1
  78. package/src/pb-components.js +1 -0
  79. package/src/pb-custom-form.js +173 -153
  80. package/src/pb-dialog.js +98 -62
  81. package/src/pb-document.js +89 -90
  82. package/src/pb-download.js +212 -196
  83. package/src/pb-drawer.js +145 -148
  84. package/src/pb-edit-app.js +301 -229
  85. package/src/pb-edit-xml.js +100 -97
  86. package/src/pb-events.js +114 -107
  87. package/src/pb-facs-link.js +104 -102
  88. package/src/pb-facsimile.js +474 -410
  89. package/src/pb-formula.js +151 -153
  90. package/src/pb-geolocation.js +129 -131
  91. package/src/pb-grid-action.js +53 -56
  92. package/src/pb-grid.js +231 -228
  93. package/src/pb-highlight.js +140 -140
  94. package/src/pb-hotkeys.js +40 -42
  95. package/src/pb-i18n.js +101 -104
  96. package/src/pb-image-strip.js +84 -78
  97. package/src/pb-lang.js +142 -57
  98. package/src/pb-leaflet-map.js +488 -485
  99. package/src/pb-link.js +126 -124
  100. package/src/pb-load.js +431 -429
  101. package/src/pb-login.js +299 -244
  102. package/src/pb-manage-odds.js +352 -336
  103. package/src/pb-map-icon.js +89 -89
  104. package/src/pb-map-layer.js +85 -85
  105. package/src/pb-markdown.js +90 -99
  106. package/src/pb-media-query.js +74 -72
  107. package/src/pb-mei.js +306 -295
  108. package/src/pb-message.js +139 -97
  109. package/src/pb-mixin.js +269 -264
  110. package/src/pb-navigation.js +80 -95
  111. package/src/pb-observable.js +38 -38
  112. package/src/pb-odd-editor.js +1054 -958
  113. package/src/pb-odd-elementspec-editor.js +349 -298
  114. package/src/pb-odd-model-editor.js +1075 -909
  115. package/src/pb-odd-parameter-editor.js +200 -178
  116. package/src/pb-odd-rendition-editor.js +136 -124
  117. package/src/pb-page.js +431 -422
  118. package/src/pb-paginate.js +228 -179
  119. package/src/pb-panel.js +198 -182
  120. package/src/pb-popover-themes.js +15 -8
  121. package/src/pb-popover.js +296 -287
  122. package/src/pb-print-preview.js +127 -127
  123. package/src/pb-progress.js +51 -51
  124. package/src/pb-repeat.js +105 -104
  125. package/src/pb-restricted.js +84 -77
  126. package/src/pb-search.js +256 -228
  127. package/src/pb-select-feature.js +127 -120
  128. package/src/pb-select-odd.js +132 -124
  129. package/src/pb-select-template.js +89 -78
  130. package/src/pb-select.js +251 -227
  131. package/src/pb-split-list.js +179 -174
  132. package/src/pb-svg.js +80 -79
  133. package/src/pb-table-column.js +54 -54
  134. package/src/pb-table-grid.js +221 -203
  135. package/src/pb-tabs.js +61 -63
  136. package/src/pb-tify.js +154 -154
  137. package/src/pb-timeline.js +382 -249
  138. package/src/pb-toggle-feature.js +195 -187
  139. package/src/pb-upload.js +184 -174
  140. package/src/pb-version.js +30 -30
  141. package/src/pb-view-annotate.js +135 -98
  142. package/src/pb-view.js +1282 -1270
  143. package/src/pb-zoom.js +127 -45
  144. package/src/polymer-hack.js +1 -1
  145. package/src/search-result-service.js +256 -223
  146. package/src/seed-element.js +13 -20
  147. package/src/settings.js +4 -4
  148. package/src/theming.js +98 -91
  149. package/src/urls.js +289 -289
  150. package/src/utils.js +53 -51
  151. package/css/pb-styles.css +0 -51
  152. package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
  153. package/src/assets/pb-styles.css +0 -51
  154. package/src/pb-light-dom.js +0 -41
@@ -1,9 +1,8 @@
1
1
  import { html, css } from 'lit-element';
2
2
  import '@polymer/iron-form';
3
3
  import '@polymer/iron-ajax';
4
- import '@polymer/paper-dialog';
5
- import '@polymer/paper-dialog-scrollable';
6
4
  import { PbLoad } from './pb-load.js';
5
+ import './pb-dialog.js';
7
6
 
8
7
  /**
9
8
  * A custom form element which loads the actual form from a server-side script using AJAX.
@@ -19,159 +18,180 @@ import { PbLoad } from './pb-load.js';
19
18
  * @fires pb-submit - Fired when the form is submitted
20
19
  */
21
20
  export class PbCustomForm extends PbLoad {
22
-
23
- firstUpdated() {
24
- this.shadowRoot.getElementById('ironform').addEventListener('iron-form-presubmit', (ev) => {
25
- ev.preventDefault();
26
- this._submit();
27
- });
28
- this.addEventListener('click', (e) => {
29
- if (e.target.slot === 'searchButtonTop'){
30
- this.submit();
31
- }
32
- if (e.target.slot === 'searchButtonBottom'){
33
- this.submit();
34
- }
35
- if (e.target.slot === 'resetButton'){
36
- this._reset();
37
- }
38
- });
39
-
40
- this._submissionHandlers();
41
- }
42
-
43
- render() {
44
- return html`
45
- <iron-form id="ironform">
46
- <form action="" accept="text/html" method="GET">
47
- <slot name="searchButtonTop"></slot>
48
- <slot></slot>
49
- <slot name="searchButtonBottom"></slot>
50
- <slot name="resetButton"></slot>
51
- </form>
52
- </iron-form>
53
-
54
- <iron-ajax
55
- id="loadContent"
56
- verbose
57
- handle-as="text"
58
- method="get"
59
- with-credentials
60
- @response="${this._handleContent}"
61
- @error="${this._handleError}"></iron-ajax>
62
- <paper-dialog id="errorDialog">
63
- <h2>Error</h2>
64
- <paper-dialog-scrollable></paper-dialog-scrollable>
65
- <div class="buttons">
66
- <paper-button dialog-confirm="dialog-confirm" autofocus="autofocus">
67
- Close
68
- </paper-button>
69
- </div>
70
- </paper-dialog>
71
- `;
72
- }
73
-
74
- static get styles() {
75
- return css`
76
- :host {
77
- display: block;
78
- }
79
- `;
21
+ firstUpdated() {
22
+ this.shadowRoot.getElementById('ironform').addEventListener('iron-form-presubmit', ev => {
23
+ ev.preventDefault();
24
+ this._submit();
25
+ });
26
+ this.addEventListener('click', e => {
27
+ if (e.target.slot === 'searchButtonTop') {
28
+ this.submit();
29
+ }
30
+ if (e.target.slot === 'searchButtonBottom') {
31
+ this.submit();
32
+ }
33
+ if (e.target.slot === 'resetButton') {
34
+ this._reset();
35
+ }
36
+ });
37
+
38
+ this._submissionHandlers();
39
+ }
40
+
41
+ render() {
42
+ return html`
43
+ <iron-form id="ironform">
44
+ <form action="" accept="text/html" method="GET">
45
+ <slot name="searchButtonTop"></slot>
46
+ <slot></slot>
47
+ <slot name="searchButtonBottom"></slot>
48
+ <slot name="resetButton"></slot>
49
+ </form>
50
+ </iron-form>
51
+
52
+ <iron-ajax
53
+ id="loadContent"
54
+ verbose
55
+ handle-as="text"
56
+ method="get"
57
+ with-credentials
58
+ @response="${this._handleContent}"
59
+ @error="${this._handleError}"
60
+ ></iron-ajax>
61
+ <pb-dialog id="errorDialog" title="Error">
62
+ <p id="errorMessage"></p>
63
+ <div slot="footer">
64
+ <button rel="prev">Close</button>
65
+ </div>
66
+ </pb-dialog>
67
+ `;
68
+ }
69
+
70
+ static get styles() {
71
+ return css`
72
+ :host {
73
+ display: block;
74
+ }
75
+ `;
76
+ }
77
+
78
+ submit() {
79
+ this.shadowRoot.getElementById('ironform').submit();
80
+ }
81
+
82
+ _submit() {
83
+ const json = this.serializeForm();
84
+ this.emitTo('pb-search-resubmit', { params: json });
85
+ this.emitTo('pb-submit', { params: json });
86
+ }
87
+
88
+ _reset() {
89
+ this.shadowRoot.getElementById('ironform').reset();
90
+ }
91
+
92
+ /**
93
+ * serialize custom form to object with name value pairs
94
+ * empty, unselected and undifined inputs will be returned
95
+ * as null while disabled elements will still be omitted
96
+ * this allows url parameters to be reset in the URL
97
+ * as IronForm.serializeform will omit names without a value
98
+ * @returns {Object} name value pairs
99
+ */
100
+ serializeForm() {
101
+ const elements = this.shadowRoot.getElementById('ironform')._getSubmittableElements();
102
+ const initial = {};
103
+ for (const element of elements) {
104
+ initial[element.name] = null;
80
105
  }
81
-
82
- submit() {
83
- this.shadowRoot.getElementById('ironform').submit();
106
+ return Object.assign(initial, this.shadowRoot.getElementById('ironform').serializeForm());
107
+ }
108
+
109
+ _parseHeaders(xhr) {
110
+ // overwrite to avoid `pb-results-received` event being sent
111
+ }
112
+
113
+ _onLoad(content) {
114
+ super._onLoad(content);
115
+
116
+ this.dispatchEvent(new CustomEvent('pb-custom-form-loaded', { detail: content }));
117
+ }
118
+
119
+ _handleError() {
120
+ this.emitTo('pb-end-update');
121
+ const loader = this.shadowRoot.getElementById('loadContent');
122
+ const { response } = loader.lastError;
123
+ if (this.silent) {
124
+ console.error('Request failed: %s', response ? response.description : '');
125
+ return;
84
126
  }
85
-
86
- _submit() {
87
- const json = this.serializeForm();
88
- this.emitTo('pb-search-resubmit', { params: json });
89
- this.emitTo('pb-submit', { params: json});
127
+ let message;
128
+ if (response) {
129
+ message = response.description;
130
+ } else {
131
+ message = 'Server error occurred';
90
132
  }
91
-
92
- _reset(){
93
- this.shadowRoot.getElementById('ironform').reset();
133
+ const dialog = this.shadowRoot.getElementById('errorDialog');
134
+ const messageElement = this.shadowRoot.getElementById('errorMessage');
135
+ messageElement.textContent = `Server error: ${message}`;
136
+ dialog.openDialog();
137
+ }
138
+
139
+ _submissionHandlers() {
140
+ if (!this.autoSubmit) {
141
+ return;
94
142
  }
95
-
96
- /**
97
- * serialize custom form to object with name value pairs
98
- * empty, unselected and undifined inputs will be returned
99
- * as null while disabled elements will still be omitted
100
- * this allows url parameters to be reset in the URL
101
- * as IronForm.serializeform will omit names without a value
102
- * @returns {Object} name value pairs
103
- */
104
- serializeForm() {
105
- const elements = this.shadowRoot.getElementById('ironform')._getSubmittableElements()
106
- const initial = {}
107
- for (const element of elements) {
108
- initial[element.name] = null;
109
- }
110
- return Object.assign(
111
- initial,
112
- this.shadowRoot.getElementById('ironform').serializeForm()
113
- );
114
- }
115
-
116
- _parseHeaders(xhr) {
117
- // overwrite to avoid `pb-results-received` event being sent
118
- }
119
-
120
- _onLoad(content) {
121
- super._onLoad(content);
122
-
123
- this.dispatchEvent(new CustomEvent('pb-custom-form-loaded', { detail: content }));
124
- }
125
-
126
- _submissionHandlers() {
127
- if (!this.autoSubmit) {
128
- return;
129
- }
130
- this.querySelectorAll(this.autoSubmit).forEach((control) => {
131
- const name = control.nodeName.toLowerCase();
132
- let event = 'change';
133
- if (control instanceof HTMLButtonElement ||
134
- name === 'paper-icon-button' || name === 'paper-button' ||
135
- (name === 'input' && (control.type === 'button' || control.type === 'submit' || control.type === 'reset'))
136
- ) {
137
- event = 'click';
138
- } else if (name === 'paper-input' || (control instanceof HTMLInputElement && control.type === 'text')) {
139
- event = 'keyup';
140
- } else if (name === 'paper-dropdown-menu') {
141
- event = 'value-changed';
142
- }
143
- control.addEventListener(event, this._submit.bind(this));
144
- });
145
- }
146
-
147
- static get properties() {
148
- return {
149
- /**
150
- * Register event handlers on all descendant elements matching the given CSS selector and submit the form
151
- * automatically if any of those changes. For button-like controls,
152
- * a submit is triggered on click, for text input on keyUp, and for
153
- * all other form components on change.
154
- */
155
- autoSubmit: {
156
- type: String,
157
- attribute: 'auto-submit'
158
- },
159
- ...super.properties
160
- };
161
- }
162
-
163
- /**
164
- * Fired before the element updates its content
165
- *
166
- * @event pb-custom-form-loaded
167
- * @param {string} the loaded content
168
- */
169
-
170
- /**
171
- * Fired when form is submitted
172
- *
173
- * @event pb-search-resubmit
174
- * @param {object} params: serialized form parameters as json object
175
- */
143
+ this.querySelectorAll(this.autoSubmit).forEach(control => {
144
+ const name = control.nodeName.toLowerCase();
145
+ let event = 'change';
146
+ if (
147
+ control instanceof HTMLButtonElement ||
148
+ name === 'paper-icon-button' ||
149
+ name === 'paper-button' ||
150
+ (name === 'input' &&
151
+ (control.type === 'button' || control.type === 'submit' || control.type === 'reset'))
152
+ ) {
153
+ event = 'click';
154
+ } else if (
155
+ name === 'paper-input' ||
156
+ (control instanceof HTMLInputElement &&
157
+ (control.type === 'text' || control.type === 'search'))
158
+ ) {
159
+ event = 'keyup';
160
+ } else if (name === 'paper-dropdown-menu') {
161
+ event = 'value-changed';
162
+ }
163
+ control.addEventListener(event, this._submit.bind(this));
164
+ });
165
+ }
166
+
167
+ static get properties() {
168
+ return {
169
+ /**
170
+ * Register event handlers on all descendant elements matching the given CSS selector and submit the form
171
+ * automatically if any of those changes. For button-like controls,
172
+ * a submit is triggered on click, for text input on keyUp, and for
173
+ * all other form components on change.
174
+ */
175
+ autoSubmit: {
176
+ type: String,
177
+ attribute: 'auto-submit',
178
+ },
179
+ ...super.properties,
180
+ };
181
+ }
182
+
183
+ /**
184
+ * Fired before the element updates its content
185
+ *
186
+ * @event pb-custom-form-loaded
187
+ * @param {string} the loaded content
188
+ */
189
+
190
+ /**
191
+ * Fired when form is submitted
192
+ *
193
+ * @event pb-search-resubmit
194
+ * @param {object} params: serialized form parameters as json object
195
+ */
176
196
  }
177
- customElements.define('pb-custom-form', PbCustomForm);
197
+ customElements.define('pb-custom-form', PbCustomForm);
package/src/pb-dialog.js CHANGED
@@ -1,83 +1,119 @@
1
- import { LitElement, html } from 'lit-element';
2
- import { pbMixin } from './pb-mixin';
3
- import { pbLightDom } from './pb-light-dom';
1
+ import { LitElement, css, html } from 'lit-element';
4
2
  import { unsafeHTML } from 'lit-html/directives/unsafe-html';
3
+ import { pbMixin } from './pb-mixin';
4
+ import { themableMixin } from './theming.js';
5
5
 
6
6
  /**
7
- * A simple dialog component using the HTML5 <dialog> element (no shadow DOM).
7
+ * A simple dialog component using the HTML5 <dialog> element.
8
+ *
9
+ * Any button with the attribute `rel="prev"` will close the dialog when clicked.
8
10
  *
9
11
  * @slot - Content of the dialog
10
12
  * @slot title - Title of the dialog
11
13
  * @fires pb-dialog-opened - Fired when the dialog is opened
12
14
  * @fires pb-dialog-closed - Fired when the dialog is closed
13
15
  */
14
- export class PbDialog extends pbLightDom(pbMixin(LitElement)) {
16
+ export class PbDialog extends themableMixin(pbMixin(LitElement)) {
17
+ static get properties() {
18
+ return {
19
+ ...super.properties,
20
+ open: { type: Boolean, reflect: true },
21
+ modal: { type: Boolean, reflect: true },
22
+ title: { type: String, reflect: true },
23
+ message: { type: String, reflect: true },
24
+ };
25
+ }
15
26
 
16
- static get properties() {
17
- return {
18
- ...super.properties,
19
- open: { type: Boolean, reflect: true },
20
- modal: { type: Boolean, reflect: true },
21
- title: { type: String, reflect: true },
22
- message: { type: String, reflect: true }
23
- };
24
- }
27
+ constructor() {
28
+ super();
29
+ this.open = false;
30
+ this.modal = true;
31
+ this._escListener = this._onEsc.bind(this);
32
+ this.title = null;
33
+ this.message = null;
34
+ }
25
35
 
26
- constructor() {
27
- super();
28
- this.open = false;
29
- this.modal = true;
30
- this._escListener = this._onEsc.bind(this);
31
- this.title = null;
32
- this.message = null;
36
+ _onEsc(e) {
37
+ if (e.key === 'Escape' && this.open) {
38
+ this.closeDialog();
33
39
  }
40
+ }
34
41
 
35
- _onEsc(e) {
36
- if (e.key === 'Escape' && this.open) {
37
- this.closeDialog();
38
- }
42
+ openDialog() {
43
+ if (!this.open) {
44
+ if (this.modal) {
45
+ this._dialog.showModal();
46
+ } else {
47
+ this._dialog.show();
48
+ }
49
+ this.dispatchEvent(new CustomEvent('pb-dialog-opened', { bubbles: true, composed: true }));
50
+ this.open = true;
39
51
  }
52
+ }
40
53
 
41
- openDialog() {
42
- if (!this.open) {
43
- if (this.modal) {
44
- this._dialog.showModal();
45
- } else {
46
- this._dialog.show();
47
- }
48
- this.dispatchEvent(new CustomEvent('pb-dialog-opened', { bubbles: true, composed: true }));
49
- this.open = true;
50
- }
54
+ closeDialog() {
55
+ if (this.open) {
56
+ this._dialog.close();
57
+ this.dispatchEvent(new CustomEvent('pb-dialog-closed', { bubbles: true, composed: true }));
58
+ this.open = false;
51
59
  }
60
+ }
52
61
 
53
- closeDialog() {
54
- if (this.open) {
55
- this._dialog.close();
56
- this.dispatchEvent(new CustomEvent('pb-dialog-closed', { bubbles: true, composed: true }));
57
- this.open = false;
58
- }
59
- }
60
-
61
- render() {
62
- return html`
63
- <dialog @click="${(e) => e.target === this._dialog && this.modal && this.closeDialog()}" ?modal="${this.modal}">
64
- <article>
65
- <header>
66
- ${ this.title ? unsafeHTML(this.title) : this.fillSlot('title') }
67
- <button rel="prev" aria-label="Close" @click="${this.closeDialog}">&times;</button>
68
- </header>
69
- ${ this.message ? unsafeHTML(this.message) : this.fillSlot() }
70
- <footer>
71
- ${ this.fillSlot('footer') }
72
- </footer>
73
- </article>
74
- </dialog>
75
- `;
76
- }
62
+ render() {
63
+ return html`
64
+ <dialog @click="${e => e.target === this._dialog && this.modal && this.closeDialog()}">
65
+ <article>
66
+ <header>
67
+ ${this.title ? unsafeHTML(this.title) : html`<slot name="title"></slot>`}
68
+ <button rel="prev" aria-label="Close"></button>
69
+ </header>
70
+ ${this.message ? unsafeHTML(this.message) : html`<slot></slot>`}
71
+ <footer>
72
+ <slot name="footer"></slot>
73
+ </footer>
74
+ </article>
75
+ </dialog>
76
+ `;
77
+ }
77
78
 
78
- firstUpdated() {
79
- this._dialog = this.querySelector('dialog');
80
- }
79
+ firstUpdated() {
80
+ this._dialog = this.renderRoot.querySelector('dialog');
81
+ // Add click listeners to close buttons in both shadow and light DOM
82
+ [
83
+ ...this._dialog.querySelectorAll('button[rel="prev"]'),
84
+ ...this.querySelectorAll('button[rel="prev"]'),
85
+ ].forEach(button => button.addEventListener('click', this.closeDialog.bind(this)));
86
+ }
87
+
88
+ static get styles() {
89
+ return css`
90
+ header {
91
+ display: flex;
92
+ justify-content: space-between;
93
+ align-items: center;
94
+ }
95
+ button[rel='prev'] {
96
+ display: block;
97
+ height: 1rem;
98
+ width: 1rem;
99
+ background-image: var(
100
+ --pb-dialog-background-image,
101
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(136, 145, 164)' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E")
102
+ );
103
+ background-position: center;
104
+ background-size: auto 1rem;
105
+ background-repeat: no-repeat;
106
+ background-color: transparent;
107
+ border: none;
108
+ }
109
+ footer {
110
+ display: flex;
111
+ justify-content: flex-end;
112
+ align-items: center;
113
+ margin-top: 16px;
114
+ }
115
+ `;
116
+ }
81
117
  }
82
118
 
83
119
  customElements.define('pb-dialog', PbDialog);