@pacem/pacem-ui 1.0.0-abel
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/LICENSE +191 -0
- package/NOTICE +4 -0
- package/dist/browser/pacem-ui.js +6343 -0
- package/dist/browser/pacem-ui.js.map +1 -0
- package/dist/browser/pacem-ui.min.js +2 -0
- package/dist/browser/pacem-ui.min.js.map +1 -0
- package/dist/bundle/pacem-ui.min.mjs +168 -0
- package/dist/bundle/pacem-ui.mjs +6276 -0
- package/dist/bundle/pacem-ui.mjs.map +7 -0
- package/dist/esm/adapter.js +360 -0
- package/dist/esm/anchor.js +149 -0
- package/dist/esm/balloon.js +583 -0
- package/dist/esm/binder.js +678 -0
- package/dist/esm/blade.js +31 -0
- package/dist/esm/bottom-sheet.js +277 -0
- package/dist/esm/button.js +100 -0
- package/dist/esm/buttonset.js +41 -0
- package/dist/esm/calendar.js +662 -0
- package/dist/esm/collapse.js +72 -0
- package/dist/esm/dialog-abstractions.js +61 -0
- package/dist/esm/dialog.js +102 -0
- package/dist/esm/divider.js +48 -0
- package/dist/esm/icon.js +131 -0
- package/dist/esm/image.js +109 -0
- package/dist/esm/index-components-ui.js +41 -0
- package/dist/esm/index-components.js +1 -0
- package/dist/esm/index-iife.js +3 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/infinite-scroller.js +137 -0
- package/dist/esm/iterative.js +45 -0
- package/dist/esm/lightbox-abstractions.js +6 -0
- package/dist/esm/lightbox.js +203 -0
- package/dist/esm/loader.js +100 -0
- package/dist/esm/markdown-svc.js +235 -0
- package/dist/esm/markdown.js +35 -0
- package/dist/esm/marquee.js +87 -0
- package/dist/esm/media-query.js +85 -0
- package/dist/esm/menu.js +165 -0
- package/dist/esm/pager.js +111 -0
- package/dist/esm/picture.js +157 -0
- package/dist/esm/progressbar.js +54 -0
- package/dist/esm/sidebar.js +60 -0
- package/dist/esm/slideshow.js +27 -0
- package/dist/esm/social-twitter.js +39 -0
- package/dist/esm/sticky-header.js +113 -0
- package/dist/esm/tabs.js +187 -0
- package/dist/esm/ticker.js +78 -0
- package/dist/esm/toast.js +171 -0
- package/dist/esm/toc.js +171 -0
- package/dist/esm/tuner.js +200 -0
- package/dist/esm/types.js +7 -0
- package/dist/esm/vibration.js +33 -0
- package/dist/esm/view.js +206 -0
- package/dist/esm/window.js +181 -0
- package/package.json +38 -0
- package/typings/index.d.ts +1165 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { P, PCSS, CustomElement, Watch, ViewChild, Utils, PropertyConverters, PacemEventTarget, Components } from '@pacem/pacem-core';
|
|
8
|
+
//namespace Pacem.Components.UI {
|
|
9
|
+
let PacemCollapseElement = class PacemCollapseElement extends PacemEventTarget {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this._resizeHandler = (evt) => {
|
|
13
|
+
this.#state = evt.detail;
|
|
14
|
+
this._toggle();
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
#state;
|
|
18
|
+
propertyChangedCallback(name, old, val, first) {
|
|
19
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
20
|
+
if (!first) {
|
|
21
|
+
switch (name) {
|
|
22
|
+
case 'collapse':
|
|
23
|
+
this._toggle();
|
|
24
|
+
case 'disabled':
|
|
25
|
+
if (!Utils.isNull(this._resizer)) {
|
|
26
|
+
this._resizer.disabled = this.disabled || this.collapse;
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
viewActivatedCallback() {
|
|
33
|
+
super.viewActivatedCallback();
|
|
34
|
+
const r = this._resizer;
|
|
35
|
+
this.#state = r.currentSize;
|
|
36
|
+
this._toggle();
|
|
37
|
+
}
|
|
38
|
+
_toggle() {
|
|
39
|
+
const div = this, collapse = this.collapse, state = this.#state;
|
|
40
|
+
if (this.disabled || Utils.isNull(div))
|
|
41
|
+
return;
|
|
42
|
+
//
|
|
43
|
+
if (this.horizontal) {
|
|
44
|
+
Utils.addClass(div, PCSS + '-horizontal');
|
|
45
|
+
div.style.height = state && (state.height + 'px') || '';
|
|
46
|
+
div.style.width = collapse ? '0' : (state && state.width + 'px') || '';
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
Utils.removeClass(div, PCSS + '-horizontal');
|
|
50
|
+
div.style.height = collapse ? '0' : (state && state.height + 'px') || '';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
__decorate([
|
|
55
|
+
Watch({ converter: PropertyConverters.Boolean })
|
|
56
|
+
], PacemCollapseElement.prototype, "collapse", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
Watch({ emit: false, converter: PropertyConverters.Boolean })
|
|
59
|
+
], PacemCollapseElement.prototype, "horizontal", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
ViewChild(P + '-resize')
|
|
62
|
+
], PacemCollapseElement.prototype, "_resizer", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
ViewChild(`[part=content]`)
|
|
65
|
+
], PacemCollapseElement.prototype, "_container", void 0);
|
|
66
|
+
PacemCollapseElement = __decorate([
|
|
67
|
+
CustomElement({
|
|
68
|
+
tagName: P + '-collapse', shadow: true,
|
|
69
|
+
template: `<${P}-resize on-${Components.ResizeEventName}=":host._resizeHandler($event)" target="{{ ::_container }}"></${P}-resize><div part="container"><div part="content"><slot></slot></div></div>`
|
|
70
|
+
})
|
|
71
|
+
], PacemCollapseElement);
|
|
72
|
+
export { PacemCollapseElement };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Watch, Utils, Components, CustomTypedEvent, Logging, avoidHandler } from '@pacem/pacem-core';
|
|
8
|
+
//namespace Pacem.Components.UI {
|
|
9
|
+
export var DialogButtons;
|
|
10
|
+
(function (DialogButtons) {
|
|
11
|
+
DialogButtons["YesNo"] = "yesno";
|
|
12
|
+
DialogButtons["YesNoCancel"] = "yesnocancel";
|
|
13
|
+
DialogButtons["Ok"] = "ok";
|
|
14
|
+
DialogButtons["OkCancel"] = "okcancel";
|
|
15
|
+
})(DialogButtons || (DialogButtons = {}));
|
|
16
|
+
export var DialogButton;
|
|
17
|
+
(function (DialogButton) {
|
|
18
|
+
DialogButton["Yes"] = "yes";
|
|
19
|
+
DialogButton["No"] = "no";
|
|
20
|
+
DialogButton["Cancel"] = "cancel";
|
|
21
|
+
DialogButton["Ok"] = "ok";
|
|
22
|
+
})(DialogButton || (DialogButton = {}));
|
|
23
|
+
export const DialogResultEventName = 'commit';
|
|
24
|
+
export class DialogResultEvent extends CustomTypedEvent {
|
|
25
|
+
constructor(args) {
|
|
26
|
+
super(DialogResultEventName, args);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class PacemDialogBase extends Components.PacemElement {
|
|
30
|
+
#deferred;
|
|
31
|
+
open(state) {
|
|
32
|
+
const lb = this.lightbox;
|
|
33
|
+
if (!Utils.isNull(this.#deferred)) {
|
|
34
|
+
throw `Dialog already open.`;
|
|
35
|
+
}
|
|
36
|
+
const deferred = this.#deferred = Promise.withResolvers();
|
|
37
|
+
if (this.hide || this.disabled) {
|
|
38
|
+
this.log(Logging.LogLevel.Warn, 'Dialog hidden or disabled, opening forbidden.');
|
|
39
|
+
deferred.reject();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.dispatchEvent(new Event('open'));
|
|
43
|
+
lb.show = true;
|
|
44
|
+
this.state = state;
|
|
45
|
+
}
|
|
46
|
+
return deferred.promise;
|
|
47
|
+
}
|
|
48
|
+
commit(btn, evt) {
|
|
49
|
+
avoidHandler(evt);
|
|
50
|
+
this.log(Logging.LogLevel.Debug, `Committing dialog by clicking '${btn}'.`);
|
|
51
|
+
const state = this.state;
|
|
52
|
+
var drevt = new DialogResultEvent({ button: btn, state: state });
|
|
53
|
+
this.lightbox.show = false;
|
|
54
|
+
this.#deferred.resolve(drevt.detail);
|
|
55
|
+
this.#deferred = null;
|
|
56
|
+
this.dispatchEvent(drevt);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
__decorate([
|
|
60
|
+
Watch()
|
|
61
|
+
], PacemDialogBase.prototype, "state", void 0);
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { P, PCSS, Defaults, CustomElement, ViewChild, Watch, PropertyConverters } from '@pacem/pacem-core';
|
|
8
|
+
import { PacemDialogBase, DialogButtons } from './dialog-abstractions';
|
|
9
|
+
//namespace Pacem.Components.UI {
|
|
10
|
+
let PacemDialogElement = class PacemDialogElement extends PacemDialogBase {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.buttons = DialogButtons.Ok;
|
|
14
|
+
this.okCaption = 'OK';
|
|
15
|
+
this.yesCaption = 'Yes';
|
|
16
|
+
this.noCaption = 'No';
|
|
17
|
+
this.cancelCaption = 'Cancel';
|
|
18
|
+
}
|
|
19
|
+
propertyChangedCallback(name, old, val, first) {
|
|
20
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
21
|
+
switch (name) {
|
|
22
|
+
case 'buttons':
|
|
23
|
+
//
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
open(state) {
|
|
28
|
+
const retval = super.open(state);
|
|
29
|
+
switch (this.buttons) {
|
|
30
|
+
case DialogButtons.Ok:
|
|
31
|
+
case DialogButtons.OkCancel:
|
|
32
|
+
this.dialogButtons.ok.focus();
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
this.dialogButtons.yes.focus();
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
return retval;
|
|
39
|
+
}
|
|
40
|
+
viewActivatedCallback() {
|
|
41
|
+
super.viewActivatedCallback();
|
|
42
|
+
// HACK: move the buttons outside the .pacem-scrollable element in the lightbox
|
|
43
|
+
//requestAnimationFrame(() => {
|
|
44
|
+
// const elFrom = this.lightbox && this.lightbox.container;
|
|
45
|
+
// if (!Utils.isNull(elFrom)) {
|
|
46
|
+
// elFrom.appendChild(this._buttons);
|
|
47
|
+
// this.dispatchEvent(new PropertyChangeEvent({ propertyName: 'dialogButtons', currentValue: this.dialogButtons }));
|
|
48
|
+
// } else {
|
|
49
|
+
// this.log(Logging.LogLevel.Warn, `Could not find the lightbox container as expected.`);
|
|
50
|
+
// }
|
|
51
|
+
//});
|
|
52
|
+
}
|
|
53
|
+
/** Gets the 'ok', 'yes', 'no' and 'cancel' dialog buttons. */
|
|
54
|
+
get dialogButtons() {
|
|
55
|
+
const btns = this._buttons;
|
|
56
|
+
return {
|
|
57
|
+
ok: btns && btns.firstElementChild.firstElementChild,
|
|
58
|
+
yes: btns && btns.firstElementChild.children.item(1),
|
|
59
|
+
no: btns && btns.firstElementChild.children.item(2),
|
|
60
|
+
cancel: btns && btns.firstElementChild.lastElementChild
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
__decorate([
|
|
65
|
+
Watch({ converter: PropertyConverters.String })
|
|
66
|
+
], PacemDialogElement.prototype, "buttons", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
Watch({ reflectBack: true, converter: PropertyConverters.String })
|
|
69
|
+
], PacemDialogElement.prototype, "okCaption", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
Watch({ reflectBack: true, converter: PropertyConverters.String })
|
|
72
|
+
], PacemDialogElement.prototype, "yesCaption", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
Watch({ reflectBack: true, converter: PropertyConverters.String })
|
|
75
|
+
], PacemDialogElement.prototype, "noCaption", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
Watch({ reflectBack: true, converter: PropertyConverters.String })
|
|
78
|
+
], PacemDialogElement.prototype, "cancelCaption", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
ViewChild(`.${PCSS}-dialog-buttons`)
|
|
81
|
+
], PacemDialogElement.prototype, "_buttons", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
ViewChild(P + '-lightbox')
|
|
84
|
+
], PacemDialogElement.prototype, "lightbox", void 0);
|
|
85
|
+
PacemDialogElement = __decorate([
|
|
86
|
+
CustomElement({
|
|
87
|
+
tagName: P + '-dialog', shadow: Defaults.USE_SHADOW_ROOT,
|
|
88
|
+
template: `<${P}-lightbox modal="true" logger="{{ :host.logger }}">
|
|
89
|
+
<${P}-content></${P}-content>
|
|
90
|
+
<div class="${PCSS}-dialog-buttons ${PCSS}-buttonset buttons" part="dialog-buttons" slot="bottom">
|
|
91
|
+
<div class="buttonset-left">
|
|
92
|
+
<${P}-button class="button button-size size-small primary dialog-ok" css-class="{{ {'buttonset-last': :host.buttons === 'ok'} }}" on-click=":host.commit('ok', $event)" disabled="{{ :host.disabled || this.hide }}" hide="{{ :host.buttons !== 'ok' && :host.buttons !== 'okcancel' }}"><${P}-text text="{{ :host.okCaption }}"></${P}-text></${P}-button>
|
|
93
|
+
<${P}-button class="button button-size size-small primary dialog-yes" css-class="{{ {'buttonset-first': :host.buttons !== 'ok' || :host.buttons !== 'okcancel'} }}" on-click=":host.commit('yes', $event)" disabled="{{ :host.disabled || this.hide }}" hide="{{ :host.buttons === 'ok' || :host.buttons === 'okcancel' }}"><${P}-text text="{{ :host.yesCaption }}"></${P}-text></${P}-button>
|
|
94
|
+
<${P}-button class="button button-size size-small dialog-no" css-class="{{ {'buttonset-last': :host.buttons === 'yesno'} }}" on-click=":host.commit('no', $event)" disabled="{{ :host.disabled || this.hide }}" hide="{{ :host.buttons !== 'yesno' && :host.buttons !== 'yesnocancel' }}"><${P}-text text="{{ :host.noCaption }}"></${P}-text></${P}-button>
|
|
95
|
+
<${P}-button class="button button-size size-small dialog-cancel" on-click=":host.commit('cancel', $event)" disabled="{{ :host.disabled || this.hide }}" hide="{{ :host.buttons !== 'yesnocancel' && :host.buttons !== 'okcancel' }}"><${P}-text text="{{ :host.cancelCaption }}"></${P}-text></${P}-button>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</${P}-lightbox>`
|
|
99
|
+
})
|
|
100
|
+
], PacemDialogElement);
|
|
101
|
+
export { PacemDialogElement };
|
|
102
|
+
//}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { P, CustomElement, Watch, Utils, PropertyConverters, Components } from '@pacem/pacem-core';
|
|
8
|
+
//namespace Pacem.Components.UI {
|
|
9
|
+
let PacemDividerElement = class PacemDividerElement extends Components.PacemElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super('separator');
|
|
12
|
+
}
|
|
13
|
+
propertyChangedCallback(name, old, val, first) {
|
|
14
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
15
|
+
if (!first && name === 'orientation') {
|
|
16
|
+
this._syncOrientation(val);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
viewActivatedCallback() {
|
|
20
|
+
super.viewActivatedCallback();
|
|
21
|
+
this._syncOrientation();
|
|
22
|
+
}
|
|
23
|
+
_syncOrientation(orientation = this.orientation) {
|
|
24
|
+
if (orientation !== 'vertical') {
|
|
25
|
+
// exclude invalid runtime values
|
|
26
|
+
orientation = 'horizontal';
|
|
27
|
+
}
|
|
28
|
+
super.aria.attributes.set('orientation', orientation);
|
|
29
|
+
switch (orientation) {
|
|
30
|
+
case 'vertical':
|
|
31
|
+
Utils.addClass(this, 'divider-vertical');
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
Utils.removeClass(this, 'divider-vertical');
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
__decorate([
|
|
40
|
+
Watch({ converter: PropertyConverters.String, emit: false })
|
|
41
|
+
], PacemDividerElement.prototype, "orientation", void 0);
|
|
42
|
+
PacemDividerElement = __decorate([
|
|
43
|
+
CustomElement({
|
|
44
|
+
tagName: P + '-divider', shadow: true,
|
|
45
|
+
template: `<div part="divider"><div part="prepend"></div><slot part="content"></slot><div part="append"></div></div>`
|
|
46
|
+
})
|
|
47
|
+
], PacemDividerElement);
|
|
48
|
+
export { PacemDividerElement };
|
package/dist/esm/icon.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { P, PCSS, CustomElement, Watch, Utils, PropertyConverters, Components, CustomElementUtils } from '@pacem/pacem-core';
|
|
8
|
+
//namespace Pacem.Components.UI {
|
|
9
|
+
const SVG = /^\s*<svg\s/;
|
|
10
|
+
const FA = /^fa(b|r|s|l|d|t|-brands|-solid|-regular|-light|-thin|-duotone)?\s+fa-/;
|
|
11
|
+
const FA_CDN = { url: "https://kit.fontawesome.com/4922589c3c.js", crossOrigin: true };
|
|
12
|
+
const LNI = /^lni\s+lni-/;
|
|
13
|
+
const LNI_CDN = "https://cdn.lineicons.com/2.0/LineIcons.css";
|
|
14
|
+
const COREUI = /^ci[dlsbf]-/;
|
|
15
|
+
const COREUI_CDN = "https://unpkg.com/@coreui/icons/css/all.min.css";
|
|
16
|
+
const MATERIAL = /^material-icons?\s+([\w]+)/;
|
|
17
|
+
//const MATERIAL_CDN = "https://fonts.googleapis.com/icon?family=Material+Icons";
|
|
18
|
+
const MATERIAL_SYMBOLS = /^material(-symbols?)?\s+([\w]+)/;
|
|
19
|
+
// TODO: put this url in a css variable and use it across the site (eventually)
|
|
20
|
+
const MATERIAL_SYMBOLS_CDN = "https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200";
|
|
21
|
+
const URL = /^(https?:\/\/|\/\/)?.+\.(webp|svg|gif|png|jpe?g)$/;
|
|
22
|
+
const iconImportMemoizer = [];
|
|
23
|
+
function importConditionally(cssClassName, url, sha, crossOrigin, js) {
|
|
24
|
+
if (iconImportMemoizer.indexOf(cssClassName) >= 0) {
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
iconImportMemoizer.push(cssClassName);
|
|
28
|
+
// this is the heavy part, be sure to call it just once (thus the memoizer)
|
|
29
|
+
if (Utils.Css.isClassDefined(cssClassName)) {
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
}
|
|
32
|
+
return js ? CustomElementUtils.importjs(url, sha, crossOrigin) : CustomElementUtils.importcss(url, sha, crossOrigin);
|
|
33
|
+
}
|
|
34
|
+
function getIconMarkup(icon) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
// null or empty
|
|
37
|
+
if (Utils.isNullOrEmpty(icon)) {
|
|
38
|
+
reject('No icon provided');
|
|
39
|
+
}
|
|
40
|
+
// svg?
|
|
41
|
+
else if (SVG.test(icon)) {
|
|
42
|
+
resolve(icon);
|
|
43
|
+
}
|
|
44
|
+
// font-awesome?
|
|
45
|
+
else if (FA.test(icon)) {
|
|
46
|
+
importConditionally("fa", FA_CDN.url, undefined, FA_CDN.crossOrigin, true).then(_ => {
|
|
47
|
+
resolve(`<i class="${icon}"></i>`);
|
|
48
|
+
}, e => reject(e));
|
|
49
|
+
}
|
|
50
|
+
// explicit material symbols?
|
|
51
|
+
else if (MATERIAL_SYMBOLS.test(icon)) {
|
|
52
|
+
importConditionally("material-symbols", MATERIAL_SYMBOLS_CDN).then(_ => {
|
|
53
|
+
const regExcArray = MATERIAL_SYMBOLS.exec(icon), ligature = regExcArray[2], rest = icon.substring(regExcArray[0].length);
|
|
54
|
+
resolve(`<i class="material-symbols-outlined${rest}">${ligature}</i>`);
|
|
55
|
+
}, e => reject(e));
|
|
56
|
+
}
|
|
57
|
+
// explicit material icons? (switch to the new material-symbols anyway)
|
|
58
|
+
else if (MATERIAL.test(icon)) {
|
|
59
|
+
importConditionally("material-icons", MATERIAL_SYMBOLS_CDN).then(_ => {
|
|
60
|
+
const regExcArray = MATERIAL.exec(icon), ligature = regExcArray[1], rest = icon.substring(regExcArray[0].length);
|
|
61
|
+
resolve(`<i class="material-icons${rest}">${ligature}</i>`);
|
|
62
|
+
}, e => reject(e));
|
|
63
|
+
}
|
|
64
|
+
// line-icons?
|
|
65
|
+
else if (LNI.test(icon)) {
|
|
66
|
+
importConditionally('lni', LNI_CDN).then(_ => {
|
|
67
|
+
resolve(`<i class="${icon}"></i>`);
|
|
68
|
+
}, e => reject(e));
|
|
69
|
+
}
|
|
70
|
+
// coreui icons?
|
|
71
|
+
else if (COREUI.test(icon)) {
|
|
72
|
+
importConditionally('clb', COREUI_CDN).then(_ => {
|
|
73
|
+
resolve(`<i class="${icon}"></i>`);
|
|
74
|
+
}, e => reject(e));
|
|
75
|
+
}
|
|
76
|
+
// image url?
|
|
77
|
+
else if (URL.test(icon)) {
|
|
78
|
+
resolve(`<img src="${icon}" />`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// assume material icon as default
|
|
82
|
+
const parts = icon.trim().split(' ');
|
|
83
|
+
const ligature = parts[0];
|
|
84
|
+
const css = parts.length > 1 ? ' ' + parts.slice(1).join(' ') : '';
|
|
85
|
+
resolve(`<i class="${PCSS}-icon${css}">${ligature}</i>`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
let PacemIconElement = class PacemIconElement extends Components.PacemElement {
|
|
90
|
+
constructor() {
|
|
91
|
+
super('', { hidden: 'true' });
|
|
92
|
+
}
|
|
93
|
+
propertyChangedCallback(name, old, val, first) {
|
|
94
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
95
|
+
if (!first) {
|
|
96
|
+
switch (name) {
|
|
97
|
+
case 'icon':
|
|
98
|
+
this._setIcon();
|
|
99
|
+
break;
|
|
100
|
+
case 'hide':
|
|
101
|
+
if (!val) {
|
|
102
|
+
// overrides the default `PacemElement` behavior:
|
|
103
|
+
// keep aria-hidden=true (to prevent screen readers from reading the ligatures)
|
|
104
|
+
this.aria.attributes.set('hidden', 'true');
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
viewActivatedCallback() {
|
|
111
|
+
super.viewActivatedCallback();
|
|
112
|
+
this._setIcon();
|
|
113
|
+
}
|
|
114
|
+
_setIcon(icon = this.icon) {
|
|
115
|
+
getIconMarkup(icon).then(markup => {
|
|
116
|
+
this.innerHTML = markup;
|
|
117
|
+
}, _ => {
|
|
118
|
+
this.innerHTML = '';
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
__decorate([
|
|
123
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
124
|
+
], PacemIconElement.prototype, "icon", void 0);
|
|
125
|
+
PacemIconElement = __decorate([
|
|
126
|
+
CustomElement({
|
|
127
|
+
tagName: P + '-icon'
|
|
128
|
+
})
|
|
129
|
+
], PacemIconElement);
|
|
130
|
+
export { PacemIconElement };
|
|
131
|
+
//}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { P, CustomElement, Watch, Utils, PropertyConverters, Components } from '@pacem/pacem-core';
|
|
8
|
+
//namespace Pacem.Components.UI {
|
|
9
|
+
let PacemImageElement = class PacemImageElement extends Components.PacemElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super('img');
|
|
12
|
+
}
|
|
13
|
+
propertyChangedCallback(name, old, val, first) {
|
|
14
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
15
|
+
if (!first) {
|
|
16
|
+
switch (name) {
|
|
17
|
+
case 'src':
|
|
18
|
+
case 'disabled':
|
|
19
|
+
this._setSource();
|
|
20
|
+
break;
|
|
21
|
+
case 'size':
|
|
22
|
+
case 'adapt':
|
|
23
|
+
this._setLayout();
|
|
24
|
+
break;
|
|
25
|
+
case 'loading':
|
|
26
|
+
(!val ? Utils.addClass : Utils.removeClass)(this, 'img-ready');
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
viewActivatedCallback() {
|
|
32
|
+
super.viewActivatedCallback();
|
|
33
|
+
this._setLayout();
|
|
34
|
+
this._setSource();
|
|
35
|
+
}
|
|
36
|
+
_setLayout() {
|
|
37
|
+
const sizeDeclared = !Utils.isNullOrEmpty(this.size);
|
|
38
|
+
const bgsize = this.adapt || 'auto';
|
|
39
|
+
const size = this.size || this.#naturalSize || { width: '0', height: '0' };
|
|
40
|
+
this.style.backgroundSize = bgsize;
|
|
41
|
+
const adapt = bgsize === 'auto', w = size.width, h = size.height;
|
|
42
|
+
if (adapt || sizeDeclared) {
|
|
43
|
+
this.style.width = w || '';
|
|
44
|
+
this.style.height = h || '';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
#naturalSize;
|
|
48
|
+
async _setSource() {
|
|
49
|
+
if (this.disabled || !this.isReady) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
//
|
|
53
|
+
const src = this.src;
|
|
54
|
+
this.style.backgroundImage = '';
|
|
55
|
+
if (!Utils.isNullOrEmpty(src)) {
|
|
56
|
+
this.loading = true;
|
|
57
|
+
try {
|
|
58
|
+
const img = await Utils.loadImage(src);
|
|
59
|
+
let weight, entries, entry;
|
|
60
|
+
if (window.performance
|
|
61
|
+
&& (entries = performance.getEntriesByName(img.src))
|
|
62
|
+
&& (entry = entries[0])) {
|
|
63
|
+
weight = entry.decodedBodySize;
|
|
64
|
+
}
|
|
65
|
+
this.#naturalSize = {
|
|
66
|
+
width: img.naturalWidth + 'px',
|
|
67
|
+
height: img.naturalHeight + 'px',
|
|
68
|
+
weight: weight
|
|
69
|
+
};
|
|
70
|
+
this._setLayout();
|
|
71
|
+
this.style.backgroundImage = `url("${img.src}")`;
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
// 404, whatever...
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
this.loading = false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
__decorate([
|
|
83
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
84
|
+
], PacemImageElement.prototype, "adapt", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
87
|
+
], PacemImageElement.prototype, "src", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
Watch({ emit: false,
|
|
90
|
+
converter: {
|
|
91
|
+
convert: (attr, el) => {
|
|
92
|
+
// parse strings like "20,20" ".5 , 1vh" "15" and returns respectively ["20px", "20px"], [".5px", "1vh"] and ["15px", "15px"]
|
|
93
|
+
const regex = /^\s*([\d.]+)(px|em|rem|vw|vh)?\s*(?:,\s*([\d.]+)(px|em|rem|vw|vh)?)?\s*$/i;
|
|
94
|
+
const match = regex.exec(attr);
|
|
95
|
+
const width = match ? match[1] + (match[2] || 'px') : '0', height = match ? (match[3] ? match[3] + (match[4] || 'px') : width) : '0';
|
|
96
|
+
return { width, height };
|
|
97
|
+
},
|
|
98
|
+
convertBack: (prop, el) => `${prop?.width},${prop?.height}`
|
|
99
|
+
}, reflectBack: true })
|
|
100
|
+
], PacemImageElement.prototype, "size", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
Watch({ converter: PropertyConverters.Boolean })
|
|
103
|
+
], PacemImageElement.prototype, "loading", void 0);
|
|
104
|
+
PacemImageElement = __decorate([
|
|
105
|
+
CustomElement({
|
|
106
|
+
tagName: P + '-img'
|
|
107
|
+
})
|
|
108
|
+
], PacemImageElement);
|
|
109
|
+
export { PacemImageElement };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export * from './adapter';
|
|
2
|
+
export * from './anchor';
|
|
3
|
+
export * from './balloon';
|
|
4
|
+
export * from './binder';
|
|
5
|
+
export * from './blade';
|
|
6
|
+
export * from './bottom-sheet';
|
|
7
|
+
export * from './button';
|
|
8
|
+
export * from './buttonset';
|
|
9
|
+
export * from './calendar';
|
|
10
|
+
export * from './collapse';
|
|
11
|
+
export * from './dialog-abstractions';
|
|
12
|
+
export * from './dialog';
|
|
13
|
+
export * from './divider';
|
|
14
|
+
export * from './icon';
|
|
15
|
+
export * from './image';
|
|
16
|
+
export * from './infinite-scroller';
|
|
17
|
+
export * from './iterative';
|
|
18
|
+
export * from './lightbox-abstractions';
|
|
19
|
+
export * from './lightbox';
|
|
20
|
+
export * from './loader';
|
|
21
|
+
export * from './markdown';
|
|
22
|
+
export * from './markdown-svc';
|
|
23
|
+
export * from './marquee';
|
|
24
|
+
export * from './media-query';
|
|
25
|
+
export * from './menu';
|
|
26
|
+
export * from './pager';
|
|
27
|
+
export * from './picture';
|
|
28
|
+
export * from './progressbar';
|
|
29
|
+
export * from './sidebar';
|
|
30
|
+
export * from './slideshow';
|
|
31
|
+
export * from './social-twitter';
|
|
32
|
+
export * from './sticky-header';
|
|
33
|
+
export * from './tabs';
|
|
34
|
+
export * from './ticker';
|
|
35
|
+
export * from './toast';
|
|
36
|
+
export * from './toc';
|
|
37
|
+
export * from './tuner';
|
|
38
|
+
export * from './types';
|
|
39
|
+
export * from './vibration';
|
|
40
|
+
export * from './view';
|
|
41
|
+
export * from './window';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as UI from './index-components-ui';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Components from './index-components';
|