@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.
- package/.github/workflows/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +4 -4
- package/.releaserc.json +2 -2
- package/CHANGELOG.md +262 -11
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/css/leaflet/images/layers.png +0 -0
- package/dist/demo/components.css +46 -1
- package/dist/demo/pb-browse-docs2.html +1 -1
- package/dist/demo/pb-dialog.html +3 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-facsimile.html +2 -2
- package/dist/demo/pb-grid.html +19 -6
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-login.html +0 -2
- package/dist/demo/pb-message.html +1 -2
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-search.html +7 -4
- package/dist/demo/pb-search3.html +1 -1
- package/dist/demo/pb-search4.html +2 -2
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{iron-form-3b8dcaa7.js → iron-form-dfb3e3b1.js} +95 -95
- package/dist/paper-checkbox-645e1077.js +200 -0
- package/dist/{paper-icon-button-b1d31571.js → paper-icon-button-984162bd.js} +1 -1
- package/dist/{paper-checkbox-515a5284.js → paper-inky-focus-behavior-fa16796b.js} +58 -247
- package/dist/{paper-listbox-a3b7175c.js → paper-listbox-5f5d1cec.js} +152 -162
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +68 -64
- package/dist/pb-components-bundle.js +1983 -2293
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +176 -120
- package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +56 -41
- package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
- package/dist/pb-odd-editor.js +1023 -782
- package/dist/pb-tify.js +2 -2
- package/dist/vaadin-element-mixin-beb74ffd.js +545 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +6 -6
- package/package.json +3 -3
- package/pb-elements.json +176 -120
- package/src/assets/components.css +5 -5
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +23 -21
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +137 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -67
- package/src/authority/registry.js +4 -4
- package/src/docs/pb-component-docs.js +2 -2
- package/src/docs/pb-component-view.js +5 -5
- package/src/docs/pb-components-list.js +2 -2
- package/src/docs/pb-demo-snippet.js +2 -2
- package/src/dts-client.js +299 -297
- package/src/dts-select-endpoint.js +90 -82
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +158 -171
- package/src/pb-authority-lookup.js +191 -156
- package/src/pb-autocomplete.js +292 -280
- package/src/pb-blacklab-highlight.js +264 -259
- package/src/pb-blacklab-results.js +236 -221
- package/src/pb-browse-docs.js +540 -475
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +79 -76
- package/src/pb-code-editor.js +110 -102
- package/src/pb-code-highlight.js +209 -204
- package/src/pb-codepen.js +79 -72
- package/src/pb-collapse.js +211 -151
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-components.js +1 -0
- package/src/pb-custom-form.js +173 -153
- package/src/pb-dialog.js +98 -62
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +212 -196
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +100 -97
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +474 -410
- package/src/pb-formula.js +151 -153
- package/src/pb-geolocation.js +129 -131
- package/src/pb-grid-action.js +53 -56
- package/src/pb-grid.js +231 -228
- package/src/pb-highlight.js +140 -140
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +101 -104
- package/src/pb-image-strip.js +84 -78
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -429
- package/src/pb-login.js +299 -244
- package/src/pb-manage-odds.js +352 -336
- package/src/pb-map-icon.js +89 -89
- package/src/pb-map-layer.js +85 -85
- package/src/pb-markdown.js +90 -99
- package/src/pb-media-query.js +74 -72
- package/src/pb-mei.js +306 -295
- package/src/pb-message.js +139 -97
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -95
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1054 -958
- package/src/pb-odd-elementspec-editor.js +349 -298
- package/src/pb-odd-model-editor.js +1075 -909
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -422
- package/src/pb-paginate.js +228 -179
- package/src/pb-panel.js +198 -182
- package/src/pb-popover-themes.js +15 -8
- package/src/pb-popover.js +296 -287
- package/src/pb-print-preview.js +127 -127
- package/src/pb-progress.js +51 -51
- package/src/pb-repeat.js +105 -104
- package/src/pb-restricted.js +84 -77
- package/src/pb-search.js +256 -228
- package/src/pb-select-feature.js +127 -120
- package/src/pb-select-odd.js +132 -124
- package/src/pb-select-template.js +89 -78
- package/src/pb-select.js +251 -227
- package/src/pb-split-list.js +179 -174
- package/src/pb-svg.js +80 -79
- package/src/pb-table-column.js +54 -54
- package/src/pb-table-grid.js +221 -203
- package/src/pb-tabs.js +61 -63
- package/src/pb-tify.js +154 -154
- package/src/pb-timeline.js +382 -249
- package/src/pb-toggle-feature.js +195 -187
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +135 -98
- package/src/pb-view.js +1282 -1270
- package/src/pb-zoom.js +127 -45
- package/src/polymer-hack.js +1 -1
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +13 -20
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
- package/css/pb-styles.css +0 -51
- package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -41
package/src/pb-custom-form.js
CHANGED
|
@@ -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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
127
|
+
let message;
|
|
128
|
+
if (response) {
|
|
129
|
+
message = response.description;
|
|
130
|
+
} else {
|
|
131
|
+
message = 'Server error occurred';
|
|
90
132
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
79
|
-
|
|
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);
|