@teipublisher/pb-components 2.25.4 → 2.26.0-next-3.2
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/release.js.yml +1 -1
- package/.releaserc.json +1 -1
- package/CHANGELOG.md +28 -0
- package/dist/demo/components.css +37 -0
- package/dist/demo/demos.json +3 -0
- package/dist/demo/pb-dialog.html +27 -0
- package/dist/demo/pb-i18n.html +29 -29
- package/dist/iron-form-b76df6d4.js +113 -0
- package/dist/{paper-listbox-5f42cff5.js → paper-listbox-9b2edde9.js} +40 -130
- package/dist/pb-component-docs.js +12 -12
- package/dist/pb-components-bundle.js +71 -71
- package/dist/pb-edit-app.js +1 -1
- package/dist/pb-elements.json +141 -15
- package/dist/pb-odd-editor.js +1 -1
- package/dist/{vaadin-element-mixin-859a0132.js → vaadin-element-mixin-87f431bd.js} +39 -29
- package/i18n/common/en.json +6 -0
- package/package.json +1 -1
- package/pb-elements.json +141 -15
- package/src/pb-components.js +1 -0
- package/src/pb-dialog.js +83 -0
- package/src/pb-download.js +6 -3
- package/src/pb-lang.js +51 -36
- package/src/pb-login.js +59 -71
- package/src/pb-message.js +41 -34
- package/src/pb-page.js +3 -4
- package/src/pb-zoom.js +25 -5
- package/src/theming.js +15 -8
- package/dist/iron-form-7b5c5d03.js +0 -23
package/src/pb-message.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import '@polymer/paper-dialog/paper-dialog';
|
|
3
|
-
import '@polymer/paper-dialog-scrollable/paper-dialog-scrollable';
|
|
4
2
|
import '@polymer/paper-button/paper-button';
|
|
5
3
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
6
4
|
import { translate } from "./pb-i18n.js";
|
|
5
|
+
import './pb-dialog.js';
|
|
6
|
+
import { themableMixin } from './theming.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Show a dialog with buttons. Used by ODD editor.
|
|
10
10
|
*/
|
|
11
|
-
export class PbMessage extends LitElement {
|
|
11
|
+
export class PbMessage extends themableMixin(LitElement) {
|
|
12
12
|
|
|
13
13
|
static get styles() {
|
|
14
14
|
return css`
|
|
15
15
|
:host {
|
|
16
16
|
display:block;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
paper-dialog{
|
|
20
|
-
min-width:300px;
|
|
21
|
-
}
|
|
22
18
|
`;
|
|
23
19
|
}
|
|
24
20
|
|
|
@@ -57,33 +53,28 @@ export class PbMessage extends LitElement {
|
|
|
57
53
|
|
|
58
54
|
render() {
|
|
59
55
|
return html`
|
|
60
|
-
<
|
|
61
|
-
<h2 id="title">${unsafeHTML(this.title)}</h2>
|
|
62
|
-
<
|
|
56
|
+
<pb-dialog>
|
|
57
|
+
<h2 id="title" slot="title">${unsafeHTML(this.title)}</h2>
|
|
58
|
+
<div id="message" class="message" tabindex="0">
|
|
63
59
|
${ this.message ? unsafeHTML(this.message) : html`<slot></slot>` }
|
|
64
|
-
</
|
|
60
|
+
</div>
|
|
65
61
|
|
|
66
|
-
<div class="buttons">
|
|
67
|
-
|
|
68
|
-
<
|
|
69
|
-
<
|
|
62
|
+
<div class="buttons" slot="footer">
|
|
63
|
+
${ this.isMessage() ? html`<button class="close" autofocus="autofocus">${translate('dialogs.close')}</button>` : html`
|
|
64
|
+
<button class="confirm" autofocus="autofocus">${translate('dialogs.yes')}</button>
|
|
65
|
+
<button class="reject" autofocus="autofocus">${translate('dialogs.no')}</button>
|
|
66
|
+
`}
|
|
70
67
|
</div>
|
|
71
|
-
</
|
|
68
|
+
</pb-dialog>
|
|
72
69
|
`;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
firstUpdated() {
|
|
76
73
|
// this.shadowRoot.getElementById('modal').open();
|
|
77
|
-
this.modal = this.
|
|
74
|
+
this.modal = this.renderRoot.querySelector('pb-dialog');
|
|
78
75
|
|
|
79
76
|
}
|
|
80
77
|
|
|
81
|
-
updated() {
|
|
82
|
-
if (this.modal) {
|
|
83
|
-
this.modal.notifyResize();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
78
|
/**
|
|
88
79
|
* Open a modal dialog to display a message to the user.
|
|
89
80
|
*
|
|
@@ -93,9 +84,18 @@ export class PbMessage extends LitElement {
|
|
|
93
84
|
show(title, message) {
|
|
94
85
|
this.type = 'message';
|
|
95
86
|
this.set(title, message);
|
|
96
|
-
this.modal.
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
this.modal.openDialog();
|
|
88
|
+
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
// Wait for the next render cycle to ensure elements are available
|
|
91
|
+
requestAnimationFrame(() => {
|
|
92
|
+
const close = this.renderRoot.querySelector('.close');
|
|
93
|
+
close.addEventListener('click', () => {
|
|
94
|
+
this.modal.closeDialog();
|
|
95
|
+
resolve({ once: true });
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
@@ -110,14 +110,22 @@ export class PbMessage extends LitElement {
|
|
|
110
110
|
confirm(title, message) {
|
|
111
111
|
this.type = 'confirm';
|
|
112
112
|
this.set(title, message);
|
|
113
|
-
this.modal.
|
|
114
|
-
|
|
115
|
-
this.modal.open();
|
|
116
|
-
const confirm = this.shadowRoot.getElementById('confirm');
|
|
117
|
-
const cancel = this.shadowRoot.getElementById('reject');
|
|
113
|
+
this.modal.openDialog();
|
|
114
|
+
|
|
118
115
|
return new Promise((resolve, reject) => {
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
// Wait for the next render cycle to ensure elements are available
|
|
117
|
+
requestAnimationFrame(() => {
|
|
118
|
+
const confirm = this.renderRoot.querySelector('.confirm');
|
|
119
|
+
const cancel = this.renderRoot.querySelector('.reject');
|
|
120
|
+
confirm.addEventListener('click', () => {
|
|
121
|
+
this.modal.closeDialog();
|
|
122
|
+
resolve({ once: true });
|
|
123
|
+
});
|
|
124
|
+
cancel.addEventListener('click', () => {
|
|
125
|
+
this.modal.closeDialog();
|
|
126
|
+
reject({ once: true });
|
|
127
|
+
});
|
|
128
|
+
});
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
131
|
|
|
@@ -129,7 +137,6 @@ export class PbMessage extends LitElement {
|
|
|
129
137
|
if (message) {
|
|
130
138
|
this.message = message;
|
|
131
139
|
}
|
|
132
|
-
this.modal.notifyResize();
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
|
package/src/pb-page.js
CHANGED
|
@@ -267,12 +267,11 @@ export class PbPage extends pbMixin(LitElement) {
|
|
|
267
267
|
this.apiVersion = apiVersion;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
const stylesheetURLs = [
|
|
271
|
-
// TODO: replace with this.toAbsoluteURL
|
|
272
|
-
this.toAbsoluteURL('resources/css/components.css', this.endpoint)
|
|
273
|
-
];
|
|
270
|
+
const stylesheetURLs = [];
|
|
274
271
|
if (this.theme) {
|
|
275
272
|
stylesheetURLs.push(this.toAbsoluteURL(this.theme, this.endpoint));
|
|
273
|
+
} else {
|
|
274
|
+
stylesheetURLs.push('components.css');
|
|
276
275
|
}
|
|
277
276
|
console.log('<pb-page> Loading component theme stylesheets from %s', stylesheetURLs.join(', '));
|
|
278
277
|
this._themeSheet = await loadStylesheets(stylesheetURLs);
|
package/src/pb-zoom.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LitElement, html } from 'lit-element';
|
|
1
|
+
import { LitElement, css, html } from 'lit-element';
|
|
2
2
|
import { pbMixin } from './pb-mixin';
|
|
3
|
-
import '
|
|
4
|
-
import '
|
|
3
|
+
import { translate } from './pb-i18n';
|
|
4
|
+
import { themableMixin } from './theming';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Zoom button to enlarge/shrink the font for the views. This component does not
|
|
@@ -9,7 +9,7 @@ import '@polymer/paper-icon-button';
|
|
|
9
9
|
*
|
|
10
10
|
* @fires pb-zoom - sends an event for e.g. pb-views to react to
|
|
11
11
|
*/
|
|
12
|
-
export class PbZoom extends pbMixin(LitElement) {
|
|
12
|
+
export class PbZoom extends themableMixin(pbMixin(LitElement)) {
|
|
13
13
|
static get properties() {
|
|
14
14
|
return {
|
|
15
15
|
...super.properties,
|
|
@@ -44,7 +44,27 @@ export class PbZoom extends pbMixin(LitElement) {
|
|
|
44
44
|
|
|
45
45
|
render() {
|
|
46
46
|
return html`
|
|
47
|
-
<
|
|
47
|
+
<a href="#" @click="${this._handleClick}" title="${this.direction === 'in' ? translate('toolbar.zoom.in') : translate('toolbar.zoom.out')}">
|
|
48
|
+
<slot name="icon">
|
|
49
|
+
${this.direction === 'in' ? html`
|
|
50
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748ZM10 10V7H12V10H15V12H12V15H10V12H7V10H10Z"></path></svg>
|
|
51
|
+
` : html`
|
|
52
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748ZM7 10H15V12H7V10Z"></path></svg>
|
|
53
|
+
`}
|
|
54
|
+
</slot>
|
|
55
|
+
</a>
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static get styles() {
|
|
60
|
+
return css`
|
|
61
|
+
a {
|
|
62
|
+
color: inherit;
|
|
63
|
+
text-decoration: none;
|
|
64
|
+
}
|
|
65
|
+
a:hover {
|
|
66
|
+
color: inherit;
|
|
67
|
+
}
|
|
48
68
|
`;
|
|
49
69
|
}
|
|
50
70
|
|
package/src/theming.js
CHANGED
|
@@ -55,16 +55,10 @@ function loadResource(url) {
|
|
|
55
55
|
* @returns {CSSStyleSheet|null} a new CSSStylesheet or null
|
|
56
56
|
*/
|
|
57
57
|
export function importStyles(elem) {
|
|
58
|
-
const
|
|
59
|
-
if (!page) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
const theme = page.stylesheet;
|
|
58
|
+
const theme = getThemeCSS();
|
|
63
59
|
if (!theme) {
|
|
64
|
-
// no component styles defined
|
|
65
60
|
return null;
|
|
66
61
|
}
|
|
67
|
-
|
|
68
62
|
const selectors = getSelectors(elem).join('|');
|
|
69
63
|
if (themeMap.has(selectors)) {
|
|
70
64
|
return themeMap.get(selectors);
|
|
@@ -82,6 +76,19 @@ export function importStyles(elem) {
|
|
|
82
76
|
return adoptedSheet;
|
|
83
77
|
}
|
|
84
78
|
|
|
79
|
+
export function getThemeCSS() {
|
|
80
|
+
const page = document.querySelector('pb-page');
|
|
81
|
+
if (!page) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const theme = page.stylesheet;
|
|
85
|
+
if (!theme) {
|
|
86
|
+
// no component styles defined
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return theme;
|
|
90
|
+
}
|
|
91
|
+
|
|
85
92
|
/**
|
|
86
93
|
* Recursively copy matching styles from the theme CSS
|
|
87
94
|
* to create a new CSS stylesheet having all styles required
|
|
@@ -140,7 +147,7 @@ export const themableMixin = (superclass) => class ThemableMixin extends supercl
|
|
|
140
147
|
connectedCallback() {
|
|
141
148
|
super.connectedCallback();
|
|
142
149
|
waitOnce('pb-page-ready', (options) => {
|
|
143
|
-
const theme =
|
|
150
|
+
const theme = getThemeCSS();
|
|
144
151
|
if (theme) {
|
|
145
152
|
this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, theme];
|
|
146
153
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import{P as e,h as t,d as i}from"./paper-checkbox-4f410b1f.js";import"./paper-listbox-5f42cff5.js";
|
|
2
|
-
/**
|
|
3
|
-
@license
|
|
4
|
-
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
5
|
-
This code may only be used under the BSD style license found at
|
|
6
|
-
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
|
7
|
-
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
|
8
|
-
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
|
9
|
-
part of the polymer project is also subject to an additional IP rights grant
|
|
10
|
-
found at http://polymer.github.io/PATENTS.txt
|
|
11
|
-
*/e({_template:t`
|
|
12
|
-
<style>
|
|
13
|
-
:host {
|
|
14
|
-
display: block;
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
|
|
18
|
-
<!-- This form is used to collect the elements that should be submitted -->
|
|
19
|
-
<slot></slot>
|
|
20
|
-
|
|
21
|
-
<!-- This form is used for submission -->
|
|
22
|
-
<form id="helper" action\$="[[action]]" method\$="[[method]]" enctype\$="[[enctype]]"></form>
|
|
23
|
-
`,is:"iron-form",properties:{allowRedirect:{type:Boolean,value:!1},headers:{type:Object,value:function(){return{}}},withCredentials:{type:Boolean,value:!1}},attached:function(){this._form||(this._form=i(this).querySelector("form"),this._form?(this._init(),this.async(this._saveInitialValues.bind(this),1)):this._nodeObserver=i(this).observeNodes(function(e){for(var t=0;t<e.addedNodes.length;t++)"FORM"===e.addedNodes[t].tagName&&(this._form=e.addedNodes[t],this._init(),i(this).unobserveNodes(this._nodeObserver),this._nodeObserver=null)}.bind(this)))},detached:function(){this._nodeObserver&&(i(this).unobserveNodes(this._nodeObserver),this._nodeObserver=null)},_init:function(){this._form.addEventListener("submit",this.submit.bind(this)),this._form.addEventListener("reset",this.reset.bind(this)),this._defaults=this._defaults||new WeakMap,this._saveInitialValues()},saveResetValues:function(){this._saveInitialValues(!0)},_saveInitialValues:function(e){for(var t=this._getValidatableElements(),i=0;i<t.length;i++){var s=t[i];if(!this._defaults.has(s)||e){var r={value:s.value};"checked"in s&&(r.checked=s.checked),"invalid"in s&&(r.invalid=s.invalid),this._defaults.set(s,r)}}},validate:function(){if(!this._form)return!1;if(""===this._form.getAttribute("novalidate"))return!0;for(var e,t=this._form.checkValidity(),i=this._getValidatableElements(),s=0;e=i[s],s<i.length;s++){var r=e;r.validate&&(t=!!r.validate()&&t)}return t},submit:function(e){if(e&&e.preventDefault(),this._form)if(this.validate()){this.$.helper.textContent="";var t=this.serializeForm();if(this.allowRedirect){for(var i in t)this.$.helper.appendChild(this._createHiddenElement(i,t[i]));this.$.helper.action=this._form.getAttribute("action"),this.$.helper.method=this._form.getAttribute("method")||"GET",this.$.helper.contentType=this._form.getAttribute("enctype")||"application/x-www-form-urlencoded",this.$.helper.submit(),this.fire("iron-form-submit")}else this._makeAjaxRequest(t)}else this.fire("iron-form-invalid")},reset:function(e){if(e&&e.preventDefault(),this._form)if(e&&"reset"===e.type&&e.target===this._form){for(var t=this._getValidatableElements(),i=0;i<t.length;i++){var s=t[i];if(this._defaults.has(s)){var r=this._defaults.get(s);for(var n in r)s[n]=r[n]}}this.fire("iron-form-reset")}else this._form.reset()},serializeForm:function(){for(var e=this._getSubmittableElements(),t={},i=0;i<e.length;i++)for(var s=this._serializeElementValues(e[i]),r=0;r<s.length;r++)this._addSerializedElement(t,e[i].name,s[r]);return t},_handleFormResponse:function(e){this.fire("iron-form-response",e.detail)},_handleFormError:function(e){this.fire("iron-form-error",e.detail)},_makeAjaxRequest:function(e){this.request||(this.request=document.createElement("iron-ajax"),this.request.addEventListener("response",this._handleFormResponse.bind(this)),this.request.addEventListener("error",this._handleFormError.bind(this))),this.request.url=this._form.getAttribute("action"),this.request.method=this._form.getAttribute("method")||"GET",this.request.contentType=this._form.getAttribute("enctype")||"application/x-www-form-urlencoded",this.request.withCredentials=this.withCredentials,this.request.headers=this.headers,"POST"===this._form.method.toUpperCase()?this.request.body=e:this.request.params=e,this.fire("iron-form-presubmit",{},{cancelable:!0}).defaultPrevented||(this.request.generateRequest(),this.fire("iron-form-submit",e))},_getValidatableElements:function(){return this._findElements(this._form,!0,!1)},_getSubmittableElements:function(){return this._findElements(this._form,!1,!1)},_findElements:function(e,t,s,r){r=r||[];for(var n=i(e).querySelectorAll("*"),a=0;a<n.length;a++)s||"slot"!==n[a].localName&&"content"!==n[a].localName?this._searchSubmittable(r,n[a],t):this._searchSubmittableInSlot(r,n[a],t);return r},_searchSubmittableInSlot:function(e,t,s){for(var r=i(t).getDistributedNodes(),n=0;n<r.length;n++)if(r[n].nodeType!==Node.TEXT_NODE){this._searchSubmittable(e,r[n],s);for(var a=i(r[n]).querySelectorAll("*"),o=0;o<a.length;o++)this._searchSubmittable(e,a[o],s)}},_searchSubmittable:function(e,t,i){this._isSubmittable(t,i)?e.push(t):t.root&&this._findElements(t.root,i,!0,e)},_isSubmittable:function(e,t){return!e.disabled&&(t?e.name||"function"==typeof e.validate:e.name)},_serializeElementValues:function(e){var t=e.tagName.toLowerCase();return"button"===t||"input"===t&&("submit"===e.type||"reset"===e.type)?[]:"select"===t?this._serializeSelectValues(e):"input"===t?this._serializeInputValues(e):e._hasIronCheckedElementBehavior&&!e.checked?[]:[e.value]},_serializeSelectValues:function(e){for(var t=[],i=0;i<e.options.length;i++)e.options[i].selected&&t.push(e.options[i].value);return t},_serializeInputValues:function(e){var t=e.type.toLowerCase();return("checkbox"!==t&&"radio"!==t||e.checked)&&"file"!==t?[e.value]:[]},_createHiddenElement:function(e,t){var i=document.createElement("input");return i.setAttribute("type","hidden"),i.setAttribute("name",e),i.setAttribute("value",t),i},_addSerializedElement:function(e,t,i){void 0===e[t]?e[t]=i:(Array.isArray(e[t])||(e[t]=[e[t]]),e[t].push(i))}});
|