@openremote/or-mwc-components 1.8.0 → 1.9.0-snapshot.20250826113849
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/src/or-mwc-snackbar.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import {css, html, LitElement, PropertyValues, unsafeCSS} from "lit";
|
|
2
|
-
import {customElement, property, query} from "lit/decorators.js";
|
|
3
|
-
import {MDCSnackbar, MDCSnackbarCloseEvent} from "@material/snackbar";
|
|
4
|
-
|
|
5
|
-
const drawerStyle = require("@material/snackbar/dist/mdc.snackbar.css");
|
|
6
|
-
|
|
7
|
-
export interface OrMwcSnackbarChangedEventDetail {
|
|
8
|
-
opened: boolean,
|
|
9
|
-
closeReason?: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class OrMwcSnackbarChangedEvent extends CustomEvent<OrMwcSnackbarChangedEventDetail> {
|
|
13
|
-
|
|
14
|
-
public static readonly NAME = "or-mwc-snackbar-changed";
|
|
15
|
-
|
|
16
|
-
constructor(value: OrMwcSnackbarChangedEventDetail) {
|
|
17
|
-
super(OrMwcSnackbarChangedEvent.NAME, {
|
|
18
|
-
detail: value,
|
|
19
|
-
bubbles: true,
|
|
20
|
-
composed: true
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
declare global {
|
|
26
|
-
export interface HTMLElementEventMap {
|
|
27
|
-
[OrMwcSnackbarChangedEvent.NAME]: OrMwcSnackbarChangedEvent;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function showSnackbar(hostElement: HTMLElement | undefined, text: string, buttonText?: string, buttonAction?: () => void): OrMwcSnackbar {
|
|
32
|
-
if (!hostElement) {
|
|
33
|
-
hostElement = OrMwcSnackbar.DialogHostElement || document.body;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const snackbar = new OrMwcSnackbar();
|
|
37
|
-
snackbar.text = text;
|
|
38
|
-
snackbar.buttonText = buttonText;
|
|
39
|
-
snackbar.buttonAction = buttonAction;
|
|
40
|
-
snackbar.isOpen = true;
|
|
41
|
-
snackbar.addEventListener(OrMwcSnackbarChangedEvent.NAME, (ev: OrMwcSnackbarChangedEvent) => {
|
|
42
|
-
ev.stopPropagation();
|
|
43
|
-
if (!ev.detail.opened) {
|
|
44
|
-
window.setTimeout(() => {
|
|
45
|
-
if (snackbar.parentElement) {
|
|
46
|
-
snackbar.parentElement.removeChild(snackbar);
|
|
47
|
-
}
|
|
48
|
-
}, 0);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
hostElement.append(snackbar);
|
|
52
|
-
return snackbar;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@customElement("or-mwc-snackbar")
|
|
56
|
-
export class OrMwcSnackbar extends LitElement {
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Can be set by apps to control where in the DOM snackbars are added
|
|
60
|
-
*/
|
|
61
|
-
public static DialogHostElement: HTMLElement;
|
|
62
|
-
|
|
63
|
-
public static get styles() {
|
|
64
|
-
return [
|
|
65
|
-
css`${unsafeCSS(drawerStyle)}`,
|
|
66
|
-
css`
|
|
67
|
-
`
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@property({type: String, attribute: false})
|
|
72
|
-
public text!: string;
|
|
73
|
-
@property({type: String})
|
|
74
|
-
public buttonText?: string;
|
|
75
|
-
@property({type: Object, attribute: false})
|
|
76
|
-
public buttonAction?: () => void;
|
|
77
|
-
@property({type: Number})
|
|
78
|
-
public timeout?: number;
|
|
79
|
-
@property({type: Boolean})
|
|
80
|
-
public _open: boolean = false;
|
|
81
|
-
@query("#mdc-snackbar")
|
|
82
|
-
protected _mdcElem!: HTMLElement;
|
|
83
|
-
protected _mdcComponent?: MDCSnackbar;
|
|
84
|
-
|
|
85
|
-
public get isOpen() {
|
|
86
|
-
return this._mdcComponent ? this._mdcComponent.isOpen : false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public set isOpen(isOpen: boolean) {
|
|
90
|
-
this._open = true;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public open() {
|
|
94
|
-
if (this._mdcElem && !this._mdcComponent) {
|
|
95
|
-
this._mdcComponent = new MDCSnackbar(this._mdcElem);
|
|
96
|
-
this._mdcComponent.timeoutMs = this.timeout || 4000;
|
|
97
|
-
}
|
|
98
|
-
if (this._mdcComponent) {
|
|
99
|
-
this._mdcComponent.open();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public close(action?: string) {
|
|
104
|
-
if (this._mdcComponent) {
|
|
105
|
-
this._mdcComponent.close(action);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public disconnectedCallback(): void {
|
|
110
|
-
super.disconnectedCallback();
|
|
111
|
-
if (this._mdcComponent) {
|
|
112
|
-
this._mdcComponent.destroy();
|
|
113
|
-
this._mdcComponent = undefined;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
protected render() {
|
|
118
|
-
return html`
|
|
119
|
-
<div id="mdc-snackbar" class="mdc-snackbar" @MDCSnackbar:opened="${() => this.onOpen()}"
|
|
120
|
-
@MDCSnackbar:closed="${(ev: MDCSnackbarCloseEvent) => this.onClose(ev.detail.reason)}">
|
|
121
|
-
<div class="mdc-snackbar__surface" role="status" aria-relevant="additions">
|
|
122
|
-
<div class="mdc-snackbar__label" aria-atomic="false">
|
|
123
|
-
<or-translate value="${this.text}"></or-translate>
|
|
124
|
-
</div>
|
|
125
|
-
${!this.buttonText ? html`` : html`
|
|
126
|
-
<div class="mdc-snackbar__actions" aria-atomic="true">
|
|
127
|
-
<or-mwc-input type="button" class="mdc-button mdc-snackbar__action" label="${this.buttonText}">
|
|
128
|
-
</or-mwc-input>
|
|
129
|
-
</div>
|
|
130
|
-
`}
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
`;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
protected updated(_changedProperties: PropertyValues) {
|
|
137
|
-
super.updated(_changedProperties);
|
|
138
|
-
if (_changedProperties.has("_open") && this._open) {
|
|
139
|
-
this.open();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
protected onClose(reason: string | undefined) {
|
|
144
|
-
if (this.buttonAction) {
|
|
145
|
-
this.buttonAction();
|
|
146
|
-
}
|
|
147
|
-
this.dispatchChangedEvent({opened: false, closeReason: reason});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
protected onOpen() {
|
|
151
|
-
this.dispatchChangedEvent({opened: true});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
protected dispatchChangedEvent(detail: OrMwcSnackbarChangedEventDetail) {
|
|
155
|
-
this.dispatchEvent(new OrMwcSnackbarChangedEvent(detail));
|
|
156
|
-
}
|
|
157
|
-
}
|