@openremote/or-mwc-components 1.8.0-snapshot.20250820125434 → 1.8.1
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/package.json +7 -7
- package/build.gradle +0 -36
- package/playwright.config.ts +0 -3
- package/rspack.config.js +0 -7
- package/src/or-mwc-dialog.ts +0 -374
- package/src/or-mwc-drawer.ts +0 -100
- package/src/or-mwc-input.ts +0 -1876
- package/src/or-mwc-list.ts +0 -335
- package/src/or-mwc-menu.ts +0 -279
- package/src/or-mwc-snackbar.ts +0 -157
- package/src/or-mwc-table.ts +0 -712
- package/src/or-mwc-tabs.ts +0 -175
- package/src/style.ts +0 -125
- package/test/or-mwc-input.test.ts +0 -46
- package/tsconfig.json +0 -15
- package/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openremote/or-mwc-components",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Material Design Components packaged as web components (The official components are hardcoded to use Material Design font which has limited icons)",
|
|
5
5
|
"customElements": "custom-elements.json",
|
|
6
6
|
"main": "dist/umd/index.bundle.js",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"@material/switch": "^9.0.0",
|
|
45
45
|
"@material/tab-bar": "^9.0.0",
|
|
46
46
|
"@material/textfield": "^9.0.0",
|
|
47
|
-
"@openremote/core": "1.8.
|
|
48
|
-
"@openremote/or-icon": "1.8.
|
|
49
|
-
"@openremote/or-translate": "1.8.
|
|
50
|
-
"lit": "^
|
|
47
|
+
"@openremote/core": "1.8.1",
|
|
48
|
+
"@openremote/or-icon": "1.8.1",
|
|
49
|
+
"@openremote/or-translate": "1.8.1",
|
|
50
|
+
"lit": "^3.3.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@openremote/test": "1.8.
|
|
54
|
-
"@openremote/util": "1.8.
|
|
53
|
+
"@openremote/test": "1.8.1",
|
|
54
|
+
"@openremote/util": "1.8.1"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
package/build.gradle
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
buildDir = "dist"
|
|
2
|
-
|
|
3
|
-
tasks.register('clean') {
|
|
4
|
-
doLast {
|
|
5
|
-
delete "dist"
|
|
6
|
-
delete "lib"
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
tasks.register('installDist') {
|
|
11
|
-
dependsOn npmAnalyze
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
tasks.register('prepareUi') {
|
|
15
|
-
dependsOn clean, npmAnalyze, npmPrepare
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
tasks.register('publishUi') {
|
|
19
|
-
dependsOn clean, npmPublish
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
tasks.register('npmBuild', Exec) {
|
|
23
|
-
mustRunAfter npmClean
|
|
24
|
-
dependsOn getYarnInstallTask()
|
|
25
|
-
commandLine npmCommand("yarn"), "run", "build"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
tasks.register('npmTest', Exec) {
|
|
29
|
-
dependsOn getYarnInstallTask()
|
|
30
|
-
commandLine npmCommand("yarn"), "run", "test"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
tasks.register('npmTestUI', Exec) {
|
|
34
|
-
dependsOn getYarnInstallTask()
|
|
35
|
-
commandLine npmCommand("yarn"), "run", "test", "--ui"
|
|
36
|
-
}
|
package/playwright.config.ts
DELETED
package/rspack.config.js
DELETED
package/src/or-mwc-dialog.ts
DELETED
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
import {css, html, LitElement, PropertyValues, TemplateResult, unsafeCSS} from "lit";
|
|
2
|
-
import {customElement, property, query} from "lit/decorators.js";
|
|
3
|
-
import {MDCDialog} from "@material/dialog";
|
|
4
|
-
import "@openremote/or-translate";
|
|
5
|
-
import "./or-mwc-input";
|
|
6
|
-
import {InputType, OrMwcInput} from "./or-mwc-input";
|
|
7
|
-
import {i18next} from "@openremote/or-translate";
|
|
8
|
-
import {Util} from "@openremote/core";
|
|
9
|
-
|
|
10
|
-
const dialogStyle = require("@material/dialog/dist/mdc.dialog.css");
|
|
11
|
-
const listStyle = require("@material/list/dist/mdc.list.css");
|
|
12
|
-
|
|
13
|
-
export interface DialogActionBase {
|
|
14
|
-
actionName: string;
|
|
15
|
-
action?: (dialog: OrMwcDialog) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface DialogAction extends DialogActionBase {
|
|
19
|
-
default?: boolean;
|
|
20
|
-
content: TemplateResult | string;
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class OrMwcDialogOpenedEvent extends CustomEvent<void> {
|
|
25
|
-
|
|
26
|
-
public static readonly NAME = "or-mwc-dialog-opened";
|
|
27
|
-
|
|
28
|
-
constructor() {
|
|
29
|
-
super(OrMwcDialogOpenedEvent.NAME, {
|
|
30
|
-
bubbles: true,
|
|
31
|
-
composed: true
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class OrMwcDialogClosedEvent extends CustomEvent<string | undefined> {
|
|
37
|
-
|
|
38
|
-
public static readonly NAME = "or-mwc-dialog-closed";
|
|
39
|
-
|
|
40
|
-
constructor(action?: string) {
|
|
41
|
-
super(OrMwcDialogClosedEvent.NAME, {
|
|
42
|
-
detail: action,
|
|
43
|
-
bubbles: true,
|
|
44
|
-
composed: true
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
declare global {
|
|
50
|
-
export interface HTMLElementEventMap {
|
|
51
|
-
[OrMwcDialogOpenedEvent.NAME]: OrMwcDialogOpenedEvent;
|
|
52
|
-
[OrMwcDialogClosedEvent.NAME]: OrMwcDialogClosedEvent;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export async function showErrorDialog(errorMessage: string, hostElement?: HTMLElement) {
|
|
57
|
-
const title = "error";
|
|
58
|
-
const content = html`
|
|
59
|
-
<div>
|
|
60
|
-
<p><or-translate value="errorOccurred"></or-translate>
|
|
61
|
-
${errorMessage ? html`
|
|
62
|
-
:</p>
|
|
63
|
-
<p>
|
|
64
|
-
<or-translate value="error"></or-translate>
|
|
65
|
-
<span> = </span>
|
|
66
|
-
<or-translate .value="${errorMessage}"></or-translate>
|
|
67
|
-
` : ``}
|
|
68
|
-
</p>
|
|
69
|
-
</div>`;
|
|
70
|
-
|
|
71
|
-
return showOkDialog(title, content, undefined, hostElement);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function showOkCancelDialog(title: string, content: string | TemplateResult, okText?: string, hostElement?: HTMLElement) {
|
|
75
|
-
|
|
76
|
-
const deferred = new Util.Deferred<boolean>();
|
|
77
|
-
|
|
78
|
-
showDialog(
|
|
79
|
-
new OrMwcDialog()
|
|
80
|
-
.setContent(typeof(content) === "string" ? html`<p>${content}</p>` : content)
|
|
81
|
-
.setActions(
|
|
82
|
-
[
|
|
83
|
-
{
|
|
84
|
-
actionName: "cancel",
|
|
85
|
-
content: "cancel",
|
|
86
|
-
default: true,
|
|
87
|
-
action: () => deferred.resolve(false)
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
actionName: "ok",
|
|
91
|
-
content: okText ? okText : i18next.t("ok"),
|
|
92
|
-
action: () => deferred.resolve(true)
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
)
|
|
96
|
-
.setHeading(title)
|
|
97
|
-
.setStyles(html`
|
|
98
|
-
<style>
|
|
99
|
-
.mdc-dialog__content {
|
|
100
|
-
white-space: pre-wrap
|
|
101
|
-
}
|
|
102
|
-
</style>
|
|
103
|
-
`),
|
|
104
|
-
hostElement);
|
|
105
|
-
|
|
106
|
-
return await deferred.promise;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export async function showOkDialog(title: string, content: string | TemplateResult, okText?: string, hostElement?: HTMLElement) {
|
|
110
|
-
|
|
111
|
-
const deferred = new Util.Deferred<boolean>();
|
|
112
|
-
|
|
113
|
-
showDialog(
|
|
114
|
-
new OrMwcDialog()
|
|
115
|
-
.setContent(typeof(content) === "string" ? html`<p>${content}</p>` : content)
|
|
116
|
-
.setActions(
|
|
117
|
-
[
|
|
118
|
-
{
|
|
119
|
-
actionName: "ok",
|
|
120
|
-
default: true,
|
|
121
|
-
content: okText ? okText : i18next.t("ok"),
|
|
122
|
-
action: () => deferred.resolve(true)
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
)
|
|
126
|
-
.setHeading(title),
|
|
127
|
-
hostElement);
|
|
128
|
-
|
|
129
|
-
return await deferred.promise;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function showDialog<T extends OrMwcDialog>(dialog: T, hostElement?: HTMLElement): T {
|
|
133
|
-
if (!hostElement) {
|
|
134
|
-
hostElement = OrMwcDialog.DialogHostElement || document.body;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
dialog.setOpen(true);
|
|
138
|
-
dialog.addEventListener(OrMwcDialogOpenedEvent.NAME, (ev) => {
|
|
139
|
-
ev.stopPropagation();
|
|
140
|
-
});
|
|
141
|
-
dialog.addEventListener(OrMwcDialogClosedEvent.NAME, (ev) => {
|
|
142
|
-
ev.stopPropagation();
|
|
143
|
-
window.setTimeout(() => {
|
|
144
|
-
if (dialog.parentElement) {
|
|
145
|
-
dialog.parentElement.removeChild(dialog);
|
|
146
|
-
}
|
|
147
|
-
}, 0);
|
|
148
|
-
});
|
|
149
|
-
hostElement.append(dialog);
|
|
150
|
-
return dialog;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// language=CSS
|
|
154
|
-
const style = css`
|
|
155
|
-
:host {
|
|
156
|
-
position: relative;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.dialog-container {
|
|
160
|
-
display: flex;
|
|
161
|
-
flex-direction: row;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.dialog-container > * {
|
|
165
|
-
flex: 1 1 0;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.mdc-list {
|
|
169
|
-
padding: 0 24px
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.mdc-dialog .mdc-dialog__surface {
|
|
173
|
-
outline: none;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@media (min-width: 1280px) {
|
|
177
|
-
.mdc-dialog .mdc-dialog__surface {
|
|
178
|
-
max-width: 1024px;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
`;
|
|
182
|
-
|
|
183
|
-
@customElement("or-mwc-dialog")
|
|
184
|
-
export class OrMwcDialog extends LitElement {
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Can be set by apps to control where in the DOM dialogs are added
|
|
188
|
-
*/
|
|
189
|
-
public static DialogHostElement: HTMLElement;
|
|
190
|
-
|
|
191
|
-
static get styles() {
|
|
192
|
-
return [
|
|
193
|
-
css`${unsafeCSS(dialogStyle)}`,
|
|
194
|
-
css`${unsafeCSS(listStyle)}`,
|
|
195
|
-
style
|
|
196
|
-
];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
@property({type: String})
|
|
200
|
-
public heading?: string | TemplateResult;
|
|
201
|
-
|
|
202
|
-
@property({type: Object, attribute: false})
|
|
203
|
-
public content?: TemplateResult | (() => TemplateResult);
|
|
204
|
-
|
|
205
|
-
@property({type: Array, attribute: false})
|
|
206
|
-
public actions?: DialogAction[];
|
|
207
|
-
|
|
208
|
-
@property({type: Object, attribute: false})
|
|
209
|
-
public dismissAction: DialogActionBase | null | undefined;
|
|
210
|
-
|
|
211
|
-
@property({type: Boolean})
|
|
212
|
-
public avatar?: boolean;
|
|
213
|
-
|
|
214
|
-
@property()
|
|
215
|
-
public styles?: TemplateResult | string;
|
|
216
|
-
|
|
217
|
-
@property({attribute: false})
|
|
218
|
-
protected _open: boolean = false;
|
|
219
|
-
|
|
220
|
-
@query("#dialog")
|
|
221
|
-
protected _mdcElem!: HTMLElement;
|
|
222
|
-
|
|
223
|
-
protected _mdcComponent?: MDCDialog;
|
|
224
|
-
|
|
225
|
-
// Bind for the 'popstate' event that tracks changes in the browser history.
|
|
226
|
-
protected _popstateEventBind = (ev: PopStateEvent) => this._onBrowserNavigate(ev);
|
|
227
|
-
|
|
228
|
-
public get isOpen() {
|
|
229
|
-
return this._mdcComponent ? this._mdcComponent.isOpen : false;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public setOpen(isOpen: boolean): OrMwcDialog {
|
|
233
|
-
this._open = true;
|
|
234
|
-
return this;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
public setHeading(heading: TemplateResult | string | undefined): OrMwcDialog {
|
|
238
|
-
this.heading = heading;
|
|
239
|
-
return this;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
public setContent(content: TemplateResult | (() => TemplateResult) | undefined): OrMwcDialog {
|
|
243
|
-
this.content = content;
|
|
244
|
-
return this;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
public setActions(actions: DialogAction[] | undefined): OrMwcDialog {
|
|
248
|
-
this.actions = actions;
|
|
249
|
-
return this;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
public setDismissAction(action: DialogActionBase | null | undefined): OrMwcDialog {
|
|
253
|
-
this.dismissAction = action;
|
|
254
|
-
return this;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
public setStyles(styles: string | TemplateResult | undefined): OrMwcDialog {
|
|
258
|
-
this.styles = styles;
|
|
259
|
-
return this;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
public setAvatar(avatar: boolean | undefined): OrMwcDialog {
|
|
263
|
-
this.avatar = avatar;
|
|
264
|
-
return this;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
public open() {
|
|
268
|
-
if (this._mdcElem && !this._mdcComponent) {
|
|
269
|
-
this._mdcComponent = new MDCDialog(this._mdcElem);
|
|
270
|
-
this._mdcComponent!.scrimClickAction = this.dismissAction || this.dismissAction === null ? "close" : "";
|
|
271
|
-
}
|
|
272
|
-
if (this._mdcComponent) {
|
|
273
|
-
this._mdcComponent.open();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
public close(action?: string) {
|
|
278
|
-
if (this._mdcComponent) {
|
|
279
|
-
this._mdcComponent.close(action);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
connectedCallback() {
|
|
284
|
-
super.connectedCallback();
|
|
285
|
-
window.addEventListener("popstate", this._popstateEventBind);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
disconnectedCallback(): void {
|
|
289
|
-
super.disconnectedCallback();
|
|
290
|
-
window.removeEventListener("popstate", this._popstateEventBind);
|
|
291
|
-
if (this._mdcComponent) {
|
|
292
|
-
this._mdcComponent.destroy();
|
|
293
|
-
this._mdcComponent = undefined;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
protected render() {
|
|
298
|
-
|
|
299
|
-
return html`
|
|
300
|
-
${typeof(this.styles) === "string" ? html`<style>${this.styles}</style>` : this.styles || ``}
|
|
301
|
-
|
|
302
|
-
<div id="dialog"
|
|
303
|
-
class="mdc-dialog"
|
|
304
|
-
role="alertdialog"
|
|
305
|
-
aria-modal="true"
|
|
306
|
-
aria-labelledby="dialog-title"
|
|
307
|
-
aria-describedby="dialog-content"
|
|
308
|
-
@MDCDialog:opened="${() => this._onDialogOpened()}"
|
|
309
|
-
@MDCDialog:closed="${(evt: any) => this._onDialogClosed(evt.detail.action)}">
|
|
310
|
-
<div class="mdc-dialog__container">
|
|
311
|
-
<div class="mdc-dialog__surface" tabindex="0">
|
|
312
|
-
${typeof(this.heading) === "string" ? html`<h2 class="mdc-dialog__title" id="dialog-title"><or-translate value="${this.heading}"></or-translate></h2>`
|
|
313
|
-
: this.heading ? html`<span class="mdc-dialog__title" id="dialog-title">${this.heading}</span>` : ``}
|
|
314
|
-
${this.content ? html`
|
|
315
|
-
<div class="dialog-container mdc-dialog__content" id="dialog-content">
|
|
316
|
-
${typeof this.content === "function" ? this.content() : this.content}
|
|
317
|
-
</div>
|
|
318
|
-
<footer class="mdc-dialog__actions">
|
|
319
|
-
${this.actions ? this.actions.map((action) => {
|
|
320
|
-
return html`
|
|
321
|
-
<div class="mdc-button mdc-dialog__button" ?data-mdc-dialog-button-default="${action.default}" data-mdc-dialog-action="${action.disabled ? undefined : action.actionName}">
|
|
322
|
-
${typeof(action.content) === "string" ? html`<or-mwc-input .type="${InputType.BUTTON}" @or-mwc-input-changed="${(ev: Event) => {if ((ev.currentTarget as OrMwcInput).disabled) ev.stopPropagation()}}" .disabled="${action.disabled}" .label="${action.content}"></or-mwc-input>` : action.content}
|
|
323
|
-
</div>`;
|
|
324
|
-
}) : ``}
|
|
325
|
-
</footer>
|
|
326
|
-
` : html`
|
|
327
|
-
<ul class="mdc-list ${this.avatar ? "mdc-list--avatar-list" : ""}">
|
|
328
|
-
${!this.actions ? `` : this.actions!.map((action, index) => {
|
|
329
|
-
return html`<li class="mdc-list-item" data-mdc-dialog-action="${action.actionName}"><span class="mdc-list-item__text">${action.content}</span></li>`;
|
|
330
|
-
})}
|
|
331
|
-
</ul>
|
|
332
|
-
`}
|
|
333
|
-
</div>
|
|
334
|
-
</div>
|
|
335
|
-
<div class="mdc-dialog__scrim"></div>
|
|
336
|
-
</div>
|
|
337
|
-
`;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
protected updated(_changedProperties: PropertyValues) {
|
|
341
|
-
super.updated(_changedProperties);
|
|
342
|
-
if (_changedProperties.has("_open") && this._open) {
|
|
343
|
-
this.open();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
protected _onDialogOpened() {
|
|
348
|
-
this.dispatchEvent(new OrMwcDialogOpenedEvent());
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
protected _onDialogClosed(action?: string) {
|
|
352
|
-
if (action === "close" && this.dismissAction && this.dismissAction.action) {
|
|
353
|
-
this.dismissAction.action(this);
|
|
354
|
-
} else if (action && this.actions) {
|
|
355
|
-
const matchedAction = this.actions.find((dialogAction) => dialogAction.actionName === action);
|
|
356
|
-
if (matchedAction && matchedAction.action) {
|
|
357
|
-
matchedAction.action(this);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (this._mdcComponent) {
|
|
361
|
-
this._mdcComponent.destroy();
|
|
362
|
-
this._mdcComponent = undefined;
|
|
363
|
-
}
|
|
364
|
-
this.dispatchEvent(new OrMwcDialogClosedEvent(action));
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Function callback for when the browser window navigates to another place.
|
|
369
|
-
* We attempt to close the dialog when this occurs.
|
|
370
|
-
*/
|
|
371
|
-
protected _onBrowserNavigate(ev: PopStateEvent) {
|
|
372
|
-
this.close("close");
|
|
373
|
-
}
|
|
374
|
-
}
|
package/src/or-mwc-drawer.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { css, html, LitElement, TemplateResult, unsafeCSS} from "lit";
|
|
2
|
-
import {customElement, property, query} from "lit/decorators.js";
|
|
3
|
-
import { MDCDrawer } from "@material/drawer";
|
|
4
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
5
|
-
|
|
6
|
-
const drawerStyle = require("@material/drawer/dist/mdc.drawer.css");
|
|
7
|
-
|
|
8
|
-
export class OrMwcDrawerChangedEvent extends CustomEvent<boolean> {
|
|
9
|
-
|
|
10
|
-
public static readonly NAME = "or-mwc-drawer-changed";
|
|
11
|
-
|
|
12
|
-
constructor(value: boolean) {
|
|
13
|
-
super(OrMwcDrawerChangedEvent.NAME, {
|
|
14
|
-
detail: value,
|
|
15
|
-
bubbles: true,
|
|
16
|
-
composed: true
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@customElement("or-mwc-drawer")
|
|
22
|
-
export class OrMwcDrawer extends LitElement {
|
|
23
|
-
|
|
24
|
-
public static get styles() {
|
|
25
|
-
return [
|
|
26
|
-
css`${unsafeCSS(drawerStyle)}`,
|
|
27
|
-
css`
|
|
28
|
-
.transparent{
|
|
29
|
-
background: none;
|
|
30
|
-
}`
|
|
31
|
-
];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@property({ attribute: false }) public header!: TemplateResult;
|
|
35
|
-
|
|
36
|
-
@property({ type: Boolean }) public dismissible: boolean = false;
|
|
37
|
-
@property({ type: Boolean }) public rightSided: boolean = false;
|
|
38
|
-
@property({ type: Boolean }) public transparent: boolean = false;
|
|
39
|
-
@property({ type: Boolean }) public open: boolean = false;
|
|
40
|
-
|
|
41
|
-
@property({ attribute: false }) public appContent!: HTMLElement;
|
|
42
|
-
@property({ attribute: false }) public topBar!: HTMLElement;
|
|
43
|
-
|
|
44
|
-
@query(".mdc-drawer")
|
|
45
|
-
protected drawerElement!: HTMLElement;
|
|
46
|
-
protected drawer?: MDCDrawer;
|
|
47
|
-
|
|
48
|
-
public toggle() {
|
|
49
|
-
this.open = !this.open;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public disconnectedCallback(): void {
|
|
53
|
-
super.disconnectedCallback();
|
|
54
|
-
if (this.drawer) {
|
|
55
|
-
this.drawer.destroy();
|
|
56
|
-
this.drawer = undefined;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
protected render() {
|
|
61
|
-
const isModal = !this.dismissible;
|
|
62
|
-
const classes = {
|
|
63
|
-
"mdc-drawer--dismissible": this.dismissible,
|
|
64
|
-
"mdc-drawer--modal": isModal,
|
|
65
|
-
"transparent": this.transparent
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
return html`
|
|
69
|
-
<aside class="mdc-drawer ${classMap(classes)}" dir="${(this.rightSided ? "rtl" : "ltr")}">
|
|
70
|
-
${this.header}
|
|
71
|
-
<div class="mdc-drawer__content" dir="ltr">
|
|
72
|
-
<slot></slot>
|
|
73
|
-
</div>
|
|
74
|
-
</aside>`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
protected updated() {
|
|
78
|
-
if (this.drawer!.open !== this.open) {
|
|
79
|
-
this.drawer!.open = this.open;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
protected dispatchChangedEvent(value: boolean) {
|
|
84
|
-
this.dispatchEvent(new OrMwcDrawerChangedEvent(value));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
protected firstUpdated() {
|
|
88
|
-
this.drawer = MDCDrawer.attachTo(this.drawerElement);
|
|
89
|
-
const openHandler = () => { this.dispatchChangedEvent(true); };
|
|
90
|
-
const closeHandler = () => { this.dispatchChangedEvent(false); };
|
|
91
|
-
this.drawer!.listen("MDCDrawer:opened", openHandler);
|
|
92
|
-
this.drawer!.listen("MDCDrawer:closed", closeHandler);
|
|
93
|
-
if (this.appContent) {
|
|
94
|
-
this.appContent.classList.add("mdc-drawer-app-content");
|
|
95
|
-
}
|
|
96
|
-
if (this.topBar) {
|
|
97
|
-
this.topBar.classList.add("mdc-top-app-bar");
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|