@openremote/or-mwc-components 1.8.0-snapshot.20250725120002 → 1.8.0-snapshot.20250728102340
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/README.md +32 -32
- package/build.gradle +19 -19
- package/custom-elements.json +4 -4
- package/lib/or-mwc-dialog.js +76 -329
- package/lib/or-mwc-drawer.js +10 -114
- package/lib/or-mwc-input.js +439 -1760
- package/lib/or-mwc-list.js +71 -283
- package/lib/or-mwc-menu.js +45 -237
- package/lib/or-mwc-snackbar.js +17 -141
- package/lib/or-mwc-table.js +245 -685
- package/lib/or-mwc-tabs.js +53 -173
- package/lib/style.js +121 -125
- package/package.json +5 -5
- package/rspack.config.js +7 -7
- package/src/or-mwc-dialog.ts +374 -374
- package/src/or-mwc-drawer.ts +100 -100
- package/src/or-mwc-input.ts +1876 -1876
- package/src/or-mwc-list.ts +335 -335
- package/src/or-mwc-menu.ts +279 -279
- package/src/or-mwc-snackbar.ts +157 -157
- package/src/or-mwc-table.ts +712 -712
- package/src/or-mwc-tabs.ts +175 -175
- package/src/style.ts +125 -125
- package/tsconfig.json +15 -15
- package/tsconfig.tsbuildinfo +1 -1
package/lib/or-mwc-menu.js
CHANGED
|
@@ -1,237 +1,45 @@
|
|
|
1
|
-
var __decorate =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
Object.assign(menu.style, {
|
|
47
|
-
position: 'fixed',
|
|
48
|
-
top: `${rect.bottom}px`,
|
|
49
|
-
left: `${rect.left}px`,
|
|
50
|
-
zIndex: '1000',
|
|
51
|
-
display: 'block'
|
|
52
|
-
});
|
|
53
|
-
return menu;
|
|
54
|
-
}
|
|
55
|
-
export function getContentWithMenuTemplate(content, menuItems, selectedValues, valueChangedCallback, closedCallback, multiSelect = false, translateValues = true, midHeight = false, fullWidth = false, menuId = "menu", fixedToHost = false) {
|
|
56
|
-
let menuRef = null; // Reference to the menu
|
|
57
|
-
const openMenu = (evt) => {
|
|
58
|
-
if (!menuItems) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (fixedToHost && menuRef) {
|
|
62
|
-
const hostElement = evt.currentTarget;
|
|
63
|
-
// Using run time coordinates to assign a fixed position to the menu
|
|
64
|
-
positionMenuAtElement(menuRef, hostElement);
|
|
65
|
-
}
|
|
66
|
-
evt.currentTarget.parentElement.lastElementChild.open();
|
|
67
|
-
};
|
|
68
|
-
return html `
|
|
69
|
-
<span>
|
|
70
|
-
<span @click="${openMenu}">${content}</span>
|
|
71
|
-
${menuItems ? html `<or-mwc-menu ?multiselect="${multiSelect}" @or-mwc-menu-closed="${() => { if (closedCallback) {
|
|
72
|
-
closedCallback();
|
|
73
|
-
} }}" @or-mwc-menu-changed="${(evt) => { if (valueChangedCallback) {
|
|
74
|
-
valueChangedCallback(evt.detail);
|
|
75
|
-
} }}" .translateValues="${translateValues}" .values="${selectedValues}" .menuItems="${menuItems}" .midHeight="${midHeight}" .fullWidth="${fullWidth}" id="${menuId}" ${ref(el => (menuRef = el))}></or-mwc-menu>` : ``}
|
|
76
|
-
</span>
|
|
77
|
-
`;
|
|
78
|
-
}
|
|
79
|
-
// language=CSS
|
|
80
|
-
const style = css `
|
|
81
|
-
:host {
|
|
82
|
-
white-space: nowrap;
|
|
83
|
-
--internal-or-mwc-input-color: var(--or-mwc-input-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
|
|
84
|
-
--internal-or-mwc-input-text-color: var(--or-mwc-input-text-color, var(--or-app-color8, ${unsafeCSS(DefaultColor8)}));
|
|
85
|
-
|
|
86
|
-
--mdc-theme-primary: var(--internal-or-mwc-input-color);
|
|
87
|
-
--mdc-theme-on-primary: var(--internal-or-mwc-input-text-color);
|
|
88
|
-
--mdc-theme-secondary: var(--internal-or-mwc-input-color);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.mdc-list-item__graphic {
|
|
92
|
-
margin-right: 16px;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
a {
|
|
96
|
-
text-decoration: none;
|
|
97
|
-
color: rgba(0, 0, 0, 0.87);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.mdc-menu-surface-mid-height {
|
|
101
|
-
max-height: calc(45vh - 32px) !important;
|
|
102
|
-
}
|
|
103
|
-
.mdc-menu-surface-full-width {
|
|
104
|
-
width: 100%;
|
|
105
|
-
}
|
|
106
|
-
`;
|
|
107
|
-
let OrMwcMenu = class OrMwcMenu extends LitElement {
|
|
108
|
-
static get styles() {
|
|
109
|
-
return [
|
|
110
|
-
css `${unsafeCSS(listStyle)}`,
|
|
111
|
-
css `${unsafeCSS(menuStyle)}`,
|
|
112
|
-
css `${unsafeCSS(menuSurfaceStyle)}`,
|
|
113
|
-
style
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
open() {
|
|
117
|
-
this._mdcComponent.open = true;
|
|
118
|
-
}
|
|
119
|
-
disconnectedCallback() {
|
|
120
|
-
super.disconnectedCallback();
|
|
121
|
-
if (this._mdcComponent) {
|
|
122
|
-
this._mdcComponent.destroy();
|
|
123
|
-
this._mdcComponent = undefined;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
render() {
|
|
127
|
-
if (!this.menuItems || this.menuItems.length === 0) {
|
|
128
|
-
return html ``;
|
|
129
|
-
}
|
|
130
|
-
const content = this.getItemsTemplate(this.menuItems, this.translateValues);
|
|
131
|
-
const isTwoLine = this.menuItems && this.menuItems.some((item) => item && !Array.isArray(item) && !!item.secondaryText);
|
|
132
|
-
const classes = {
|
|
133
|
-
'mdc-menu-surface-mid-height': (this.midHeight ? 1 : 0),
|
|
134
|
-
'mdc-menu-surface-full-width': (this.fullWidth ? 1 : 0)
|
|
135
|
-
};
|
|
136
|
-
return html `
|
|
137
|
-
<div id="wrapper" class="mdc-menu-surface--anchor">
|
|
138
|
-
<div class="mdc-menu mdc-menu-surface ${classMap(classes)}" id="menu" @MDCMenuSurface:closed="${this._onMenuClosed}">
|
|
139
|
-
${getListTemplate(ListType.MULTI_TICK, content, isTwoLine, "menu")}
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
`;
|
|
143
|
-
}
|
|
144
|
-
getItemsTemplate(items, translate) {
|
|
145
|
-
const type = this.multiSelect ? ListType.MULTI_TICK : ListType.PLAIN;
|
|
146
|
-
return html `
|
|
147
|
-
${items.map((item, index) => {
|
|
148
|
-
if (Array.isArray(item)) {
|
|
149
|
-
return html `
|
|
150
|
-
<li>
|
|
151
|
-
<ul class="mdc-menu__selection-group">
|
|
152
|
-
${this.getItemsTemplate(item, translate)}
|
|
153
|
-
</ul>
|
|
154
|
-
</li>
|
|
155
|
-
`;
|
|
156
|
-
}
|
|
157
|
-
return getItemTemplate(item, index, (Array.isArray(this.values) ? this.values : this.values ? [this.values] : []), type, translate, (e, item) => this._itemClicked(e, item));
|
|
158
|
-
})}`;
|
|
159
|
-
}
|
|
160
|
-
firstUpdated(_changedProperties) {
|
|
161
|
-
super.firstUpdated(_changedProperties);
|
|
162
|
-
if (this._mdcElem) {
|
|
163
|
-
this._mdcComponent = new MDCMenu(this._mdcElem);
|
|
164
|
-
// This overrides the standard mdc menu body click capture handler as it doesn't work with webcomponents
|
|
165
|
-
this._mdcComponent.menuSurface_.foundation.handleBodyClick = function (evt) {
|
|
166
|
-
const el = evt.composedPath()[0]; // Use composed path not evt target to work with webcomponents
|
|
167
|
-
if (this.adapter.isElementInContainer(el)) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
this.close();
|
|
171
|
-
};
|
|
172
|
-
this._mdcComponent.quickOpen = true;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
updated(_changedProperties) {
|
|
176
|
-
if (_changedProperties.has("visible")) {
|
|
177
|
-
this._mdcComponent.open = this.visible || false;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
_onMenuClosed() {
|
|
181
|
-
this.dispatchEvent(new OrMwcMenuClosedEvent());
|
|
182
|
-
}
|
|
183
|
-
_itemClicked(e, item) {
|
|
184
|
-
e.stopPropagation();
|
|
185
|
-
const value = item.value;
|
|
186
|
-
if (!this.multiSelect) {
|
|
187
|
-
this.values = value;
|
|
188
|
-
this._mdcComponent.open = false;
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
if (!Array.isArray(this.values)) {
|
|
192
|
-
this.values = this.values ? [this.values] : [];
|
|
193
|
-
}
|
|
194
|
-
const index = this.values.findIndex((v) => v === value);
|
|
195
|
-
if (index >= 0) {
|
|
196
|
-
this.values.splice(index, 1);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
this.values.push(value);
|
|
200
|
-
}
|
|
201
|
-
this.requestUpdate();
|
|
202
|
-
}
|
|
203
|
-
this.dispatchEvent(new OrMwcMenuChangedEvent(this.values));
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
__decorate([
|
|
207
|
-
property({ type: Array })
|
|
208
|
-
], OrMwcMenu.prototype, "menuItems", void 0);
|
|
209
|
-
__decorate([
|
|
210
|
-
property({ type: Array })
|
|
211
|
-
], OrMwcMenu.prototype, "values", void 0);
|
|
212
|
-
__decorate([
|
|
213
|
-
property({ type: Boolean, attribute: true })
|
|
214
|
-
], OrMwcMenu.prototype, "multiSelect", void 0);
|
|
215
|
-
__decorate([
|
|
216
|
-
property({ type: Boolean, attribute: true })
|
|
217
|
-
], OrMwcMenu.prototype, "visible", void 0);
|
|
218
|
-
__decorate([
|
|
219
|
-
property({ type: Boolean, attribute: true })
|
|
220
|
-
], OrMwcMenu.prototype, "translateValues", void 0);
|
|
221
|
-
__decorate([
|
|
222
|
-
property({ type: Boolean, attribute: false })
|
|
223
|
-
], OrMwcMenu.prototype, "midHeight", void 0);
|
|
224
|
-
__decorate([
|
|
225
|
-
property({ type: Boolean, attribute: false })
|
|
226
|
-
], OrMwcMenu.prototype, "fullWidth", void 0);
|
|
227
|
-
__decorate([
|
|
228
|
-
query("#wrapper")
|
|
229
|
-
], OrMwcMenu.prototype, "_wrapperElem", void 0);
|
|
230
|
-
__decorate([
|
|
231
|
-
query("#menu")
|
|
232
|
-
], OrMwcMenu.prototype, "_mdcElem", void 0);
|
|
233
|
-
OrMwcMenu = __decorate([
|
|
234
|
-
customElement("or-mwc-menu")
|
|
235
|
-
], OrMwcMenu);
|
|
236
|
-
export { OrMwcMenu };
|
|
237
|
-
//# sourceMappingURL=or-mwc-menu.js.map
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,r,o){var n,i=arguments.length,s=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(i<3?n(s):i>3?n(t,r,s):n(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s};import{css as e,html as t,LitElement as r,unsafeCSS as o}from"lit";import{customElement as n,property as i,query as s}from"lit/decorators.js";import{classMap as c}from"lit/directives/class-map.js";import{MDCMenu as a}from"@material/menu";import{DefaultColor4 as m,DefaultColor8 as l}from"@openremote/core";import u from"@material/list/dist/mdc.list.css";import d from"@material/menu-surface/dist/mdc.menu-surface.css";import{getItemTemplate as p,getListTemplate as h,ListType as v}from"./or-mwc-list";import{ref as M}from"lit/directives/ref.js";let menuStyle=require("@material/menu/dist/mdc.menu.css");export class OrMwcMenuChangedEvent extends CustomEvent{constructor(e){super(OrMwcMenuChangedEvent.NAME,{detail:e,bubbles:!0,composed:!0})}}OrMwcMenuChangedEvent.NAME="or-mwc-menu-changed";export class OrMwcMenuClosedEvent extends CustomEvent{constructor(){super(OrMwcMenuClosedEvent.NAME,{bubbles:!0,composed:!0})}}OrMwcMenuClosedEvent.NAME="or-mwc-menu-closed";export function positionMenuAtElement(e,t){t||(t=document.body);let r=t.getBoundingClientRect();return Object.assign(e.style,{position:"fixed",top:`${r.bottom}px`,left:`${r.left}px`,zIndex:"1000",display:"block"}),e}export function getContentWithMenuTemplate(e,r,o,n,i,s=!1,c=!0,a=!1,m=!1,l="menu",u=!1){let d=null;return t`
|
|
2
|
+
<span>
|
|
3
|
+
<span @click="${e=>{if(r){if(u&&d){let t=e.currentTarget;positionMenuAtElement(d,t)}e.currentTarget.parentElement.lastElementChild.open()}}}">${e}</span>
|
|
4
|
+
${r?t`<or-mwc-menu ?multiselect="${s}" @or-mwc-menu-closed="${()=>{i&&i()}}" @or-mwc-menu-changed="${e=>{n&&n(e.detail)}}" .translateValues="${c}" .values="${o}" .menuItems="${r}" .midHeight="${a}" .fullWidth="${m}" id="${l}" ${M(e=>d=e)}></or-mwc-menu>`:""}
|
|
5
|
+
</span>
|
|
6
|
+
`}let style=e`
|
|
7
|
+
:host {
|
|
8
|
+
white-space: nowrap;
|
|
9
|
+
--internal-or-mwc-input-color: var(--or-mwc-input-color, var(--or-app-color4, ${o(m)}));
|
|
10
|
+
--internal-or-mwc-input-text-color: var(--or-mwc-input-text-color, var(--or-app-color8, ${o(l)}));
|
|
11
|
+
|
|
12
|
+
--mdc-theme-primary: var(--internal-or-mwc-input-color);
|
|
13
|
+
--mdc-theme-on-primary: var(--internal-or-mwc-input-text-color);
|
|
14
|
+
--mdc-theme-secondary: var(--internal-or-mwc-input-color);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.mdc-list-item__graphic {
|
|
18
|
+
margin-right: 16px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
a {
|
|
22
|
+
text-decoration: none;
|
|
23
|
+
color: rgba(0, 0, 0, 0.87);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.mdc-menu-surface-mid-height {
|
|
27
|
+
max-height: calc(45vh - 32px) !important;
|
|
28
|
+
}
|
|
29
|
+
.mdc-menu-surface-full-width {
|
|
30
|
+
width: 100%;
|
|
31
|
+
}
|
|
32
|
+
`,OrMwcMenu=class extends r{static get styles(){return[e`${o(u)}`,e`${o(menuStyle)}`,e`${o(d)}`,style]}open(){this._mdcComponent.open=!0}disconnectedCallback(){super.disconnectedCallback(),this._mdcComponent&&(this._mdcComponent.destroy(),this._mdcComponent=void 0)}render(){if(!this.menuItems||0===this.menuItems.length)return t``;let e=this.getItemsTemplate(this.menuItems,this.translateValues),r=this.menuItems&&this.menuItems.some(e=>e&&!Array.isArray(e)&&!!e.secondaryText),o={"mdc-menu-surface-mid-height":+!!this.midHeight,"mdc-menu-surface-full-width":+!!this.fullWidth};return t`
|
|
33
|
+
<div id="wrapper" class="mdc-menu-surface--anchor">
|
|
34
|
+
<div class="mdc-menu mdc-menu-surface ${c(o)}" id="menu" @MDCMenuSurface:closed="${this._onMenuClosed}">
|
|
35
|
+
${h(v.MULTI_TICK,e,r,"menu")}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
`}getItemsTemplate(e,r){let o=this.multiSelect?v.MULTI_TICK:v.PLAIN;return t`
|
|
39
|
+
${e.map((e,n)=>Array.isArray(e)?t`
|
|
40
|
+
<li>
|
|
41
|
+
<ul class="mdc-menu__selection-group">
|
|
42
|
+
${this.getItemsTemplate(e,r)}
|
|
43
|
+
</ul>
|
|
44
|
+
</li>
|
|
45
|
+
`:p(e,n,Array.isArray(this.values)?this.values:this.values?[this.values]:[],o,r,(e,t)=>this._itemClicked(e,t)))}`}firstUpdated(e){super.firstUpdated(e),this._mdcElem&&(this._mdcComponent=new a(this._mdcElem),this._mdcComponent.menuSurface_.foundation.handleBodyClick=function(e){let t=e.composedPath()[0];this.adapter.isElementInContainer(t)||this.close()},this._mdcComponent.quickOpen=!0)}updated(e){e.has("visible")&&(this._mdcComponent.open=this.visible||!1)}_onMenuClosed(){this.dispatchEvent(new OrMwcMenuClosedEvent)}_itemClicked(e,t){e.stopPropagation();let r=t.value;if(this.multiSelect){Array.isArray(this.values)||(this.values=this.values?[this.values]:[]);let e=this.values.findIndex(e=>e===r);e>=0?this.values.splice(e,1):this.values.push(r),this.requestUpdate()}else this.values=r,this._mdcComponent.open=!1;this.dispatchEvent(new OrMwcMenuChangedEvent(this.values))}};__decorate([i({type:Array})],OrMwcMenu.prototype,"menuItems",void 0),__decorate([i({type:Array})],OrMwcMenu.prototype,"values",void 0),__decorate([i({type:Boolean,attribute:!0})],OrMwcMenu.prototype,"multiSelect",void 0),__decorate([i({type:Boolean,attribute:!0})],OrMwcMenu.prototype,"visible",void 0),__decorate([i({type:Boolean,attribute:!0})],OrMwcMenu.prototype,"translateValues",void 0),__decorate([i({type:Boolean,attribute:!1})],OrMwcMenu.prototype,"midHeight",void 0),__decorate([i({type:Boolean,attribute:!1})],OrMwcMenu.prototype,"fullWidth",void 0),__decorate([s("#wrapper")],OrMwcMenu.prototype,"_wrapperElem",void 0),__decorate([s("#menu")],OrMwcMenu.prototype,"_mdcElem",void 0),OrMwcMenu=__decorate([n("or-mwc-menu")],OrMwcMenu);export{OrMwcMenu};
|
package/lib/or-mwc-snackbar.js
CHANGED
|
@@ -1,141 +1,17 @@
|
|
|
1
|
-
var __decorate =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
OrMwcSnackbarChangedEvent.NAME = "or-mwc-snackbar-changed";
|
|
21
|
-
export function showSnackbar(hostElement, text, buttonText, buttonAction) {
|
|
22
|
-
if (!hostElement) {
|
|
23
|
-
hostElement = OrMwcSnackbar.DialogHostElement || document.body;
|
|
24
|
-
}
|
|
25
|
-
const snackbar = new OrMwcSnackbar();
|
|
26
|
-
snackbar.text = text;
|
|
27
|
-
snackbar.buttonText = buttonText;
|
|
28
|
-
snackbar.buttonAction = buttonAction;
|
|
29
|
-
snackbar.isOpen = true;
|
|
30
|
-
snackbar.addEventListener(OrMwcSnackbarChangedEvent.NAME, (ev) => {
|
|
31
|
-
ev.stopPropagation();
|
|
32
|
-
if (!ev.detail.opened) {
|
|
33
|
-
window.setTimeout(() => {
|
|
34
|
-
if (snackbar.parentElement) {
|
|
35
|
-
snackbar.parentElement.removeChild(snackbar);
|
|
36
|
-
}
|
|
37
|
-
}, 0);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
hostElement.append(snackbar);
|
|
41
|
-
return snackbar;
|
|
42
|
-
}
|
|
43
|
-
let OrMwcSnackbar = class OrMwcSnackbar extends LitElement {
|
|
44
|
-
constructor() {
|
|
45
|
-
super(...arguments);
|
|
46
|
-
this._open = false;
|
|
47
|
-
}
|
|
48
|
-
static get styles() {
|
|
49
|
-
return [
|
|
50
|
-
css `${unsafeCSS(drawerStyle)}`,
|
|
51
|
-
css `
|
|
52
|
-
`
|
|
53
|
-
];
|
|
54
|
-
}
|
|
55
|
-
get isOpen() {
|
|
56
|
-
return this._mdcComponent ? this._mdcComponent.isOpen : false;
|
|
57
|
-
}
|
|
58
|
-
set isOpen(isOpen) {
|
|
59
|
-
this._open = true;
|
|
60
|
-
}
|
|
61
|
-
open() {
|
|
62
|
-
if (this._mdcElem && !this._mdcComponent) {
|
|
63
|
-
this._mdcComponent = new MDCSnackbar(this._mdcElem);
|
|
64
|
-
this._mdcComponent.timeoutMs = this.timeout || 4000;
|
|
65
|
-
}
|
|
66
|
-
if (this._mdcComponent) {
|
|
67
|
-
this._mdcComponent.open();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
close(action) {
|
|
71
|
-
if (this._mdcComponent) {
|
|
72
|
-
this._mdcComponent.close(action);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
disconnectedCallback() {
|
|
76
|
-
super.disconnectedCallback();
|
|
77
|
-
if (this._mdcComponent) {
|
|
78
|
-
this._mdcComponent.destroy();
|
|
79
|
-
this._mdcComponent = undefined;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
render() {
|
|
83
|
-
return html `
|
|
84
|
-
<div id="mdc-snackbar" class="mdc-snackbar" @MDCSnackbar:opened="${() => this.onOpen()}"
|
|
85
|
-
@MDCSnackbar:closed="${(ev) => this.onClose(ev.detail.reason)}">
|
|
86
|
-
<div class="mdc-snackbar__surface" role="status" aria-relevant="additions">
|
|
87
|
-
<div class="mdc-snackbar__label" aria-atomic="false">
|
|
88
|
-
<or-translate value="${this.text}"></or-translate>
|
|
89
|
-
</div>
|
|
90
|
-
${!this.buttonText ? html `` : html `
|
|
91
|
-
<div class="mdc-snackbar__actions" aria-atomic="true">
|
|
92
|
-
<or-mwc-input type="button" class="mdc-button mdc-snackbar__action" label="${this.buttonText}">
|
|
93
|
-
</or-mwc-input>
|
|
94
|
-
</div>
|
|
95
|
-
`}
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
`;
|
|
99
|
-
}
|
|
100
|
-
updated(_changedProperties) {
|
|
101
|
-
super.updated(_changedProperties);
|
|
102
|
-
if (_changedProperties.has("_open") && this._open) {
|
|
103
|
-
this.open();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
onClose(reason) {
|
|
107
|
-
if (this.buttonAction) {
|
|
108
|
-
this.buttonAction();
|
|
109
|
-
}
|
|
110
|
-
this.dispatchChangedEvent({ opened: false, closeReason: reason });
|
|
111
|
-
}
|
|
112
|
-
onOpen() {
|
|
113
|
-
this.dispatchChangedEvent({ opened: true });
|
|
114
|
-
}
|
|
115
|
-
dispatchChangedEvent(detail) {
|
|
116
|
-
this.dispatchEvent(new OrMwcSnackbarChangedEvent(detail));
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
__decorate([
|
|
120
|
-
property({ type: String, attribute: false })
|
|
121
|
-
], OrMwcSnackbar.prototype, "text", void 0);
|
|
122
|
-
__decorate([
|
|
123
|
-
property({ type: String })
|
|
124
|
-
], OrMwcSnackbar.prototype, "buttonText", void 0);
|
|
125
|
-
__decorate([
|
|
126
|
-
property({ type: Object, attribute: false })
|
|
127
|
-
], OrMwcSnackbar.prototype, "buttonAction", void 0);
|
|
128
|
-
__decorate([
|
|
129
|
-
property({ type: Number })
|
|
130
|
-
], OrMwcSnackbar.prototype, "timeout", void 0);
|
|
131
|
-
__decorate([
|
|
132
|
-
property({ type: Boolean })
|
|
133
|
-
], OrMwcSnackbar.prototype, "_open", void 0);
|
|
134
|
-
__decorate([
|
|
135
|
-
query("#mdc-snackbar")
|
|
136
|
-
], OrMwcSnackbar.prototype, "_mdcElem", void 0);
|
|
137
|
-
OrMwcSnackbar = __decorate([
|
|
138
|
-
customElement("or-mwc-snackbar")
|
|
139
|
-
], OrMwcSnackbar);
|
|
140
|
-
export { OrMwcSnackbar };
|
|
141
|
-
//# sourceMappingURL=or-mwc-snackbar.js.map
|
|
1
|
+
var __decorate=this&&this.__decorate||function(t,e,n,o){var a,r=arguments.length,c=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(a=t[s])&&(c=(r<3?a(c):r>3?a(e,n,c):a(e,n))||c);return r>3&&c&&Object.defineProperty(e,n,c),c};import{css as t,html as e,LitElement as n,unsafeCSS as o}from"lit";import{customElement as a,property as r,query as c}from"lit/decorators.js";import{MDCSnackbar as s}from"@material/snackbar";let drawerStyle=require("@material/snackbar/dist/mdc.snackbar.css");export class OrMwcSnackbarChangedEvent extends CustomEvent{constructor(t){super(OrMwcSnackbarChangedEvent.NAME,{detail:t,bubbles:!0,composed:!0})}}OrMwcSnackbarChangedEvent.NAME="or-mwc-snackbar-changed";export function showSnackbar(t,e,n,o){t||(t=OrMwcSnackbar.DialogHostElement||document.body);let a=new OrMwcSnackbar;return a.text=e,a.buttonText=n,a.buttonAction=o,a.isOpen=!0,a.addEventListener(OrMwcSnackbarChangedEvent.NAME,t=>{t.stopPropagation(),t.detail.opened||window.setTimeout(()=>{a.parentElement&&a.parentElement.removeChild(a)},0)}),t.append(a),a}let OrMwcSnackbar=class extends n{constructor(){super(...arguments),this._open=!1}static get styles(){return[t`${o(drawerStyle)}`,t`
|
|
2
|
+
`]}get isOpen(){return!!this._mdcComponent&&this._mdcComponent.isOpen}set isOpen(t){this._open=!0}open(){this._mdcElem&&!this._mdcComponent&&(this._mdcComponent=new s(this._mdcElem),this._mdcComponent.timeoutMs=this.timeout||4e3),this._mdcComponent&&this._mdcComponent.open()}close(t){this._mdcComponent&&this._mdcComponent.close(t)}disconnectedCallback(){super.disconnectedCallback(),this._mdcComponent&&(this._mdcComponent.destroy(),this._mdcComponent=void 0)}render(){return e`
|
|
3
|
+
<div id="mdc-snackbar" class="mdc-snackbar" @MDCSnackbar:opened="${()=>this.onOpen()}"
|
|
4
|
+
@MDCSnackbar:closed="${t=>this.onClose(t.detail.reason)}">
|
|
5
|
+
<div class="mdc-snackbar__surface" role="status" aria-relevant="additions">
|
|
6
|
+
<div class="mdc-snackbar__label" aria-atomic="false">
|
|
7
|
+
<or-translate value="${this.text}"></or-translate>
|
|
8
|
+
</div>
|
|
9
|
+
${!this.buttonText?e``:e`
|
|
10
|
+
<div class="mdc-snackbar__actions" aria-atomic="true">
|
|
11
|
+
<or-mwc-input type="button" class="mdc-button mdc-snackbar__action" label="${this.buttonText}">
|
|
12
|
+
</or-mwc-input>
|
|
13
|
+
</div>
|
|
14
|
+
`}
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
`}updated(t){super.updated(t),t.has("_open")&&this._open&&this.open()}onClose(t){this.buttonAction&&this.buttonAction(),this.dispatchChangedEvent({opened:!1,closeReason:t})}onOpen(){this.dispatchChangedEvent({opened:!0})}dispatchChangedEvent(t){this.dispatchEvent(new OrMwcSnackbarChangedEvent(t))}};__decorate([r({type:String,attribute:!1})],OrMwcSnackbar.prototype,"text",void 0),__decorate([r({type:String})],OrMwcSnackbar.prototype,"buttonText",void 0),__decorate([r({type:Object,attribute:!1})],OrMwcSnackbar.prototype,"buttonAction",void 0),__decorate([r({type:Number})],OrMwcSnackbar.prototype,"timeout",void 0),__decorate([r({type:Boolean})],OrMwcSnackbar.prototype,"_open",void 0),__decorate([c("#mdc-snackbar")],OrMwcSnackbar.prototype,"_mdcElem",void 0),OrMwcSnackbar=__decorate([a("or-mwc-snackbar")],OrMwcSnackbar);export{OrMwcSnackbar};
|