@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/README.md
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
# @openremote/or-mwc-* \<or-mwc-*\>
|
|
2
|
-
[![NPM Version][npm-image]][npm-url]
|
|
3
|
-
[![Linux Build][travis-image]][travis-url]
|
|
4
|
-
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
5
|
-
|
|
6
|
-
Web components wrapper for `MDC` web UI components, the standard `MWC` components are not complete, and they have a
|
|
7
|
-
horrible icon font dependency (hopefully this will removed) whereas we use `SVG` based icon sets.
|
|
8
|
-
|
|
9
|
-
## Install
|
|
10
|
-
```bash
|
|
11
|
-
npm i @openremote/or-mwc-components
|
|
12
|
-
yarn add @openremote/or-mwc-components
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
For a full list of properties, methods and options refer to the TypeDoc generated [documentation]().
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Supported Browsers
|
|
20
|
-
The last 2 versions of all modern browsers are supported, including Chrome, Safari, Opera, Firefox, Edge. In addition,
|
|
21
|
-
Internet Explorer 11 is also supported.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## License
|
|
25
|
-
[GNU AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
|
|
26
|
-
|
|
27
|
-
[npm-image]: https://img.shields.io/npm/v/live-xxx.svg
|
|
28
|
-
[npm-url]: https://npmjs.org/package/@openremote/or-mwc-components
|
|
29
|
-
[travis-image]: https://img.shields.io/travis/live-js/live-xxx/master.svg
|
|
30
|
-
[travis-url]: https://travis-ci.org/live-js/live-xxx
|
|
31
|
-
[coveralls-image]: https://img.shields.io/coveralls/live-js/live-xxx/master.svg
|
|
32
|
-
[coveralls-url]: https://coveralls.io/r/live-js/live-xxx?branch=master
|
|
1
|
+
# @openremote/or-mwc-* \<or-mwc-*\>
|
|
2
|
+
[![NPM Version][npm-image]][npm-url]
|
|
3
|
+
[![Linux Build][travis-image]][travis-url]
|
|
4
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
5
|
+
|
|
6
|
+
Web components wrapper for `MDC` web UI components, the standard `MWC` components are not complete, and they have a
|
|
7
|
+
horrible icon font dependency (hopefully this will removed) whereas we use `SVG` based icon sets.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
```bash
|
|
11
|
+
npm i @openremote/or-mwc-components
|
|
12
|
+
yarn add @openremote/or-mwc-components
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
For a full list of properties, methods and options refer to the TypeDoc generated [documentation]().
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Supported Browsers
|
|
20
|
+
The last 2 versions of all modern browsers are supported, including Chrome, Safari, Opera, Firefox, Edge. In addition,
|
|
21
|
+
Internet Explorer 11 is also supported.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
[GNU AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
|
|
26
|
+
|
|
27
|
+
[npm-image]: https://img.shields.io/npm/v/live-xxx.svg
|
|
28
|
+
[npm-url]: https://npmjs.org/package/@openremote/or-mwc-components
|
|
29
|
+
[travis-image]: https://img.shields.io/travis/live-js/live-xxx/master.svg
|
|
30
|
+
[travis-url]: https://travis-ci.org/live-js/live-xxx
|
|
31
|
+
[coveralls-image]: https://img.shields.io/coveralls/live-js/live-xxx/master.svg
|
|
32
|
+
[coveralls-url]: https://coveralls.io/r/live-js/live-xxx?branch=master
|
package/build.gradle
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
buildDir = "dist"
|
|
2
|
-
|
|
3
|
-
task clean() {
|
|
4
|
-
doLast {
|
|
5
|
-
delete "dist"
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
task installDist() {
|
|
10
|
-
dependsOn npmAnalyze
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
task prepareUi() {
|
|
14
|
-
dependsOn clean, npmAnalyze, npmPrepare
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
task publishUi() {
|
|
18
|
-
dependsOn clean, npmPublish
|
|
19
|
-
}
|
|
1
|
+
buildDir = "dist"
|
|
2
|
+
|
|
3
|
+
task clean() {
|
|
4
|
+
doLast {
|
|
5
|
+
delete "dist"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
task installDist() {
|
|
10
|
+
dependsOn npmAnalyze
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
task prepareUi() {
|
|
14
|
+
dependsOn clean, npmAnalyze, npmPrepare
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
task publishUi() {
|
|
18
|
+
dependsOn clean, npmPublish
|
|
19
|
+
}
|
package/custom-elements.json
CHANGED
|
@@ -426,7 +426,7 @@
|
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
],
|
|
429
|
-
"description": "Function callback for when the browser window navigates to another place.\
|
|
429
|
+
"description": "Function callback for when the browser window navigates to another place.\nWe attempt to close the dialog when this occurs."
|
|
430
430
|
}
|
|
431
431
|
],
|
|
432
432
|
"events": [
|
|
@@ -3028,7 +3028,7 @@
|
|
|
3028
3028
|
}
|
|
3029
3029
|
}
|
|
3030
3030
|
],
|
|
3031
|
-
"description": "Function that is responsible for formatting the table content.\
|
|
3031
|
+
"description": "Function that is responsible for formatting the table content.\nFor example; dates should be formatted differently than strings, numbers and HTML templates."
|
|
3032
3032
|
},
|
|
3033
3033
|
{
|
|
3034
3034
|
"kind": "method",
|
|
@@ -3081,7 +3081,7 @@
|
|
|
3081
3081
|
}
|
|
3082
3082
|
}
|
|
3083
3083
|
],
|
|
3084
|
-
"description": "\"When user clicks on a checkbox\" when multiselect is enabled,\
|
|
3084
|
+
"description": "\"When user clicks on a checkbox\" when multiselect is enabled,\nit dispatches an OrMwcTableRowSelectEvent to the parent component / listeners."
|
|
3085
3085
|
},
|
|
3086
3086
|
{
|
|
3087
3087
|
"kind": "method",
|
|
@@ -3253,7 +3253,7 @@
|
|
|
3253
3253
|
}
|
|
3254
3254
|
}
|
|
3255
3255
|
],
|
|
3256
|
-
"description": "Uses the TemplateResult content to identify and analyze the content.\
|
|
3256
|
+
"description": "Uses the TemplateResult content to identify and analyze the content.\nSee the documentation here; https://lit.dev/docs/v2/api/templates/#TemplateResult\nSometimes it cannot analyze the HTML; if so, it will retain the same order."
|
|
3257
3257
|
},
|
|
3258
3258
|
{
|
|
3259
3259
|
"kind": "method",
|
package/lib/or-mwc-dialog.js
CHANGED
|
@@ -1,331 +1,78 @@
|
|
|
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
|
-
OrMwcDialogClosedEvent.NAME = "or-mwc-dialog-closed";
|
|
45
|
-
export function showErrorDialog(errorMessage, hostElement) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const title = "error";
|
|
48
|
-
const content = html `
|
|
49
|
-
<div>
|
|
50
|
-
<p><or-translate value="errorOccurred"></or-translate>
|
|
51
|
-
${errorMessage ? html `
|
|
52
|
-
:</p>
|
|
53
|
-
<p>
|
|
54
|
-
<or-translate value="error"></or-translate>
|
|
55
|
-
<span> = </span>
|
|
56
|
-
<or-translate .value="${errorMessage}"></or-translate>
|
|
57
|
-
` : ``}
|
|
58
|
-
</p>
|
|
59
|
-
</div>`;
|
|
60
|
-
return showOkDialog(title, content, undefined, hostElement);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
export function showOkCancelDialog(title, content, okText, hostElement) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
const deferred = new Util.Deferred();
|
|
66
|
-
showDialog(new OrMwcDialog()
|
|
67
|
-
.setContent(typeof (content) === "string" ? html `<p>${content}</p>` : content)
|
|
68
|
-
.setActions([
|
|
69
|
-
{
|
|
70
|
-
actionName: "cancel",
|
|
71
|
-
content: "cancel",
|
|
72
|
-
default: true,
|
|
73
|
-
action: () => deferred.resolve(false)
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
actionName: "ok",
|
|
77
|
-
content: okText ? okText : i18next.t("ok"),
|
|
78
|
-
action: () => deferred.resolve(true)
|
|
79
|
-
}
|
|
80
|
-
])
|
|
81
|
-
.setHeading(title)
|
|
82
|
-
.setStyles(html `
|
|
83
|
-
<style>
|
|
84
|
-
.mdc-dialog__content {
|
|
85
|
-
white-space: pre-wrap
|
|
86
|
-
}
|
|
87
|
-
</style>
|
|
88
|
-
`), hostElement);
|
|
89
|
-
return yield deferred.promise;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
export function showOkDialog(title, content, okText, hostElement) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const deferred = new Util.Deferred();
|
|
95
|
-
showDialog(new OrMwcDialog()
|
|
96
|
-
.setContent(typeof (content) === "string" ? html `<p>${content}</p>` : content)
|
|
97
|
-
.setActions([
|
|
98
|
-
{
|
|
99
|
-
actionName: "ok",
|
|
100
|
-
default: true,
|
|
101
|
-
content: okText ? okText : i18next.t("ok"),
|
|
102
|
-
action: () => deferred.resolve(true)
|
|
103
|
-
}
|
|
104
|
-
])
|
|
105
|
-
.setHeading(title), hostElement);
|
|
106
|
-
return yield deferred.promise;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
export function showDialog(dialog, hostElement) {
|
|
110
|
-
if (!hostElement) {
|
|
111
|
-
hostElement = OrMwcDialog.DialogHostElement || document.body;
|
|
112
|
-
}
|
|
113
|
-
dialog.setOpen(true);
|
|
114
|
-
dialog.addEventListener(OrMwcDialogOpenedEvent.NAME, (ev) => {
|
|
115
|
-
ev.stopPropagation();
|
|
116
|
-
});
|
|
117
|
-
dialog.addEventListener(OrMwcDialogClosedEvent.NAME, (ev) => {
|
|
118
|
-
ev.stopPropagation();
|
|
119
|
-
window.setTimeout(() => {
|
|
120
|
-
if (dialog.parentElement) {
|
|
121
|
-
dialog.parentElement.removeChild(dialog);
|
|
122
|
-
}
|
|
123
|
-
}, 0);
|
|
124
|
-
});
|
|
125
|
-
hostElement.append(dialog);
|
|
126
|
-
return dialog;
|
|
127
|
-
}
|
|
128
|
-
// language=CSS
|
|
129
|
-
const style = css `
|
|
130
|
-
:host {
|
|
131
|
-
position: relative;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.dialog-container {
|
|
135
|
-
display: flex;
|
|
136
|
-
flex-direction: row;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.dialog-container > * {
|
|
140
|
-
flex: 1 1 0;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.mdc-list {
|
|
144
|
-
padding: 0 24px
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.mdc-dialog .mdc-dialog__surface {
|
|
148
|
-
outline: none;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
@media (min-width: 1280px) {
|
|
152
|
-
.mdc-dialog .mdc-dialog__surface {
|
|
153
|
-
max-width: 1024px;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
`;
|
|
157
|
-
let OrMwcDialog = class OrMwcDialog extends LitElement {
|
|
158
|
-
constructor() {
|
|
159
|
-
super(...arguments);
|
|
160
|
-
this._open = false;
|
|
161
|
-
// Bind for the 'popstate' event that tracks changes in the browser history.
|
|
162
|
-
this._popstateEventBind = (ev) => this._onBrowserNavigate(ev);
|
|
163
|
-
}
|
|
164
|
-
static get styles() {
|
|
165
|
-
return [
|
|
166
|
-
css `${unsafeCSS(dialogStyle)}`,
|
|
167
|
-
css `${unsafeCSS(listStyle)}`,
|
|
168
|
-
style
|
|
169
|
-
];
|
|
170
|
-
}
|
|
171
|
-
get isOpen() {
|
|
172
|
-
return this._mdcComponent ? this._mdcComponent.isOpen : false;
|
|
173
|
-
}
|
|
174
|
-
setOpen(isOpen) {
|
|
175
|
-
this._open = true;
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
setHeading(heading) {
|
|
179
|
-
this.heading = heading;
|
|
180
|
-
return this;
|
|
181
|
-
}
|
|
182
|
-
setContent(content) {
|
|
183
|
-
this.content = content;
|
|
184
|
-
return this;
|
|
185
|
-
}
|
|
186
|
-
setActions(actions) {
|
|
187
|
-
this.actions = actions;
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
setDismissAction(action) {
|
|
191
|
-
this.dismissAction = action;
|
|
192
|
-
return this;
|
|
193
|
-
}
|
|
194
|
-
setStyles(styles) {
|
|
195
|
-
this.styles = styles;
|
|
196
|
-
return this;
|
|
197
|
-
}
|
|
198
|
-
setAvatar(avatar) {
|
|
199
|
-
this.avatar = avatar;
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
open() {
|
|
203
|
-
if (this._mdcElem && !this._mdcComponent) {
|
|
204
|
-
this._mdcComponent = new MDCDialog(this._mdcElem);
|
|
205
|
-
this._mdcComponent.scrimClickAction = this.dismissAction || this.dismissAction === null ? "close" : "";
|
|
206
|
-
}
|
|
207
|
-
if (this._mdcComponent) {
|
|
208
|
-
this._mdcComponent.open();
|
|
1
|
+
var __decorate=this&&this.__decorate||function(t,e,o,i){var n,s=arguments.length,a=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var r=t.length-1;r>=0;r--)(n=t[r])&&(a=(s<3?n(a):s>3?n(e,o,a):n(e,o))||a);return s>3&&a&&Object.defineProperty(e,o,a),a},__awaiter=this&&this.__awaiter||function(t,e,o,i){return new(o||(o=Promise))(function(n,s){function a(t){try{c(i.next(t))}catch(t){s(t)}}function r(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):((e=t.value)instanceof o?e:new o(function(t){t(e)})).then(a,r)}c((i=i.apply(t,e||[])).next())})};import{css as t,html as e,LitElement as o,unsafeCSS as i}from"lit";import{customElement as n,property as s,query as a}from"lit/decorators.js";import{MDCDialog as r}from"@material/dialog";import"@openremote/or-translate";import"./or-mwc-input";import{InputType as c}from"./or-mwc-input";import{i18next as d}from"@openremote/or-translate";import{Util as l}from"@openremote/core";let dialogStyle=require("@material/dialog/dist/mdc.dialog.css"),listStyle=require("@material/list/dist/mdc.list.css");export class OrMwcDialogOpenedEvent extends CustomEvent{constructor(){super(OrMwcDialogOpenedEvent.NAME,{bubbles:!0,composed:!0})}}OrMwcDialogOpenedEvent.NAME="or-mwc-dialog-opened";export class OrMwcDialogClosedEvent extends CustomEvent{constructor(t){super(OrMwcDialogClosedEvent.NAME,{detail:t,bubbles:!0,composed:!0})}}OrMwcDialogClosedEvent.NAME="or-mwc-dialog-closed";export function showErrorDialog(t,o){return __awaiter(this,void 0,void 0,function*(){return showOkDialog("error",e`
|
|
2
|
+
<div>
|
|
3
|
+
<p><or-translate value="errorOccurred"></or-translate>
|
|
4
|
+
${t?e`
|
|
5
|
+
:</p>
|
|
6
|
+
<p>
|
|
7
|
+
<or-translate value="error"></or-translate>
|
|
8
|
+
<span> = </span>
|
|
9
|
+
<or-translate .value="${t}"></or-translate>
|
|
10
|
+
`:""}
|
|
11
|
+
</p>
|
|
12
|
+
</div>`,void 0,o)})}export function showOkCancelDialog(t,o,i,n){return __awaiter(this,void 0,void 0,function*(){let s=new l.Deferred;return showDialog(new OrMwcDialog().setContent("string"==typeof o?e`<p>${o}</p>`:o).setActions([{actionName:"cancel",content:"cancel",default:!0,action:()=>s.resolve(!1)},{actionName:"ok",content:i||d.t("ok"),action:()=>s.resolve(!0)}]).setHeading(t).setStyles(e`
|
|
13
|
+
<style>
|
|
14
|
+
.mdc-dialog__content {
|
|
15
|
+
white-space: pre-wrap
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
`),n),yield s.promise})}export function showOkDialog(t,o,i,n){return __awaiter(this,void 0,void 0,function*(){let s=new l.Deferred;return showDialog(new OrMwcDialog().setContent("string"==typeof o?e`<p>${o}</p>`:o).setActions([{actionName:"ok",default:!0,content:i||d.t("ok"),action:()=>s.resolve(!0)}]).setHeading(t),n),yield s.promise})}export function showDialog(t,e){return e||(e=OrMwcDialog.DialogHostElement||document.body),t.setOpen(!0),t.addEventListener(OrMwcDialogOpenedEvent.NAME,t=>{t.stopPropagation()}),t.addEventListener(OrMwcDialogClosedEvent.NAME,e=>{e.stopPropagation(),window.setTimeout(()=>{t.parentElement&&t.parentElement.removeChild(t)},0)}),e.append(t),t}let style=t`
|
|
19
|
+
:host {
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.dialog-container {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.dialog-container > * {
|
|
29
|
+
flex: 1 1 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.mdc-list {
|
|
33
|
+
padding: 0 24px
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.mdc-dialog .mdc-dialog__surface {
|
|
37
|
+
outline: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@media (min-width: 1280px) {
|
|
41
|
+
.mdc-dialog .mdc-dialog__surface {
|
|
42
|
+
max-width: 1024px;
|
|
209
43
|
}
|
|
210
44
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
<div class="dialog-container mdc-dialog__content" id="dialog-content">
|
|
246
|
-
${typeof this.content === "function" ? this.content() : this.content}
|
|
247
|
-
</div>
|
|
248
|
-
<footer class="mdc-dialog__actions">
|
|
249
|
-
${this.actions ? this.actions.map((action) => {
|
|
250
|
-
return html `
|
|
251
|
-
<div class="mdc-button mdc-dialog__button" ?data-mdc-dialog-button-default="${action.default}" data-mdc-dialog-action="${action.disabled ? undefined : action.actionName}">
|
|
252
|
-
${typeof (action.content) === "string" ? html `<or-mwc-input .type="${InputType.BUTTON}" @or-mwc-input-changed="${(ev) => { if (ev.currentTarget.disabled)
|
|
253
|
-
ev.stopPropagation(); }}" .disabled="${action.disabled}" .label="${action.content}"></or-mwc-input>` : action.content}
|
|
254
|
-
</div>`;
|
|
255
|
-
}) : ``}
|
|
256
|
-
</footer>
|
|
257
|
-
` : html `
|
|
258
|
-
<ul class="mdc-list ${this.avatar ? "mdc-list--avatar-list" : ""}">
|
|
259
|
-
${!this.actions ? `` : this.actions.map((action, index) => {
|
|
260
|
-
return html `<li class="mdc-list-item" data-mdc-dialog-action="${action.actionName}"><span class="mdc-list-item__text">${action.content}</span></li>`;
|
|
261
|
-
})}
|
|
262
|
-
</ul>
|
|
263
|
-
`}
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
<div class="mdc-dialog__scrim"></div>
|
|
267
|
-
</div>
|
|
268
|
-
`;
|
|
269
|
-
}
|
|
270
|
-
updated(_changedProperties) {
|
|
271
|
-
super.updated(_changedProperties);
|
|
272
|
-
if (_changedProperties.has("_open") && this._open) {
|
|
273
|
-
this.open();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
_onDialogOpened() {
|
|
277
|
-
this.dispatchEvent(new OrMwcDialogOpenedEvent());
|
|
278
|
-
}
|
|
279
|
-
_onDialogClosed(action) {
|
|
280
|
-
if (action === "close" && this.dismissAction && this.dismissAction.action) {
|
|
281
|
-
this.dismissAction.action(this);
|
|
282
|
-
}
|
|
283
|
-
else if (action && this.actions) {
|
|
284
|
-
const matchedAction = this.actions.find((dialogAction) => dialogAction.actionName === action);
|
|
285
|
-
if (matchedAction && matchedAction.action) {
|
|
286
|
-
matchedAction.action(this);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
if (this._mdcComponent) {
|
|
290
|
-
this._mdcComponent.destroy();
|
|
291
|
-
this._mdcComponent = undefined;
|
|
292
|
-
}
|
|
293
|
-
this.dispatchEvent(new OrMwcDialogClosedEvent(action));
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Function callback for when the browser window navigates to another place.
|
|
297
|
-
* We attempt to close the dialog when this occurs.
|
|
298
|
-
*/
|
|
299
|
-
_onBrowserNavigate(ev) {
|
|
300
|
-
this.close("close");
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
__decorate([
|
|
304
|
-
property({ type: String })
|
|
305
|
-
], OrMwcDialog.prototype, "heading", void 0);
|
|
306
|
-
__decorate([
|
|
307
|
-
property({ type: Object, attribute: false })
|
|
308
|
-
], OrMwcDialog.prototype, "content", void 0);
|
|
309
|
-
__decorate([
|
|
310
|
-
property({ type: Array, attribute: false })
|
|
311
|
-
], OrMwcDialog.prototype, "actions", void 0);
|
|
312
|
-
__decorate([
|
|
313
|
-
property({ type: Object, attribute: false })
|
|
314
|
-
], OrMwcDialog.prototype, "dismissAction", void 0);
|
|
315
|
-
__decorate([
|
|
316
|
-
property({ type: Boolean })
|
|
317
|
-
], OrMwcDialog.prototype, "avatar", void 0);
|
|
318
|
-
__decorate([
|
|
319
|
-
property()
|
|
320
|
-
], OrMwcDialog.prototype, "styles", void 0);
|
|
321
|
-
__decorate([
|
|
322
|
-
property({ attribute: false })
|
|
323
|
-
], OrMwcDialog.prototype, "_open", void 0);
|
|
324
|
-
__decorate([
|
|
325
|
-
query("#dialog")
|
|
326
|
-
], OrMwcDialog.prototype, "_mdcElem", void 0);
|
|
327
|
-
OrMwcDialog = __decorate([
|
|
328
|
-
customElement("or-mwc-dialog")
|
|
329
|
-
], OrMwcDialog);
|
|
330
|
-
export { OrMwcDialog };
|
|
331
|
-
//# sourceMappingURL=or-mwc-dialog.js.map
|
|
45
|
+
`,OrMwcDialog=class extends o{constructor(){super(...arguments),this._open=!1,this._popstateEventBind=t=>this._onBrowserNavigate(t)}static get styles(){return[t`${i(dialogStyle)}`,t`${i(listStyle)}`,style]}get isOpen(){return!!this._mdcComponent&&this._mdcComponent.isOpen}setOpen(t){return this._open=!0,this}setHeading(t){return this.heading=t,this}setContent(t){return this.content=t,this}setActions(t){return this.actions=t,this}setDismissAction(t){return this.dismissAction=t,this}setStyles(t){return this.styles=t,this}setAvatar(t){return this.avatar=t,this}open(){this._mdcElem&&!this._mdcComponent&&(this._mdcComponent=new r(this._mdcElem),this._mdcComponent.scrimClickAction=this.dismissAction||null===this.dismissAction?"close":""),this._mdcComponent&&this._mdcComponent.open()}close(t){this._mdcComponent&&this._mdcComponent.close(t)}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._popstateEventBind)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._popstateEventBind),this._mdcComponent&&(this._mdcComponent.destroy(),this._mdcComponent=void 0)}render(){return e`
|
|
46
|
+
${"string"==typeof this.styles?e`<style>${this.styles}</style>`:this.styles||""}
|
|
47
|
+
|
|
48
|
+
<div id="dialog"
|
|
49
|
+
class="mdc-dialog"
|
|
50
|
+
role="alertdialog"
|
|
51
|
+
aria-modal="true"
|
|
52
|
+
aria-labelledby="dialog-title"
|
|
53
|
+
aria-describedby="dialog-content"
|
|
54
|
+
@MDCDialog:opened="${()=>this._onDialogOpened()}"
|
|
55
|
+
@MDCDialog:closed="${t=>this._onDialogClosed(t.detail.action)}">
|
|
56
|
+
<div class="mdc-dialog__container">
|
|
57
|
+
<div class="mdc-dialog__surface" tabindex="0">
|
|
58
|
+
${"string"==typeof this.heading?e`<h2 class="mdc-dialog__title" id="dialog-title"><or-translate value="${this.heading}"></or-translate></h2>`:this.heading?e`<span class="mdc-dialog__title" id="dialog-title">${this.heading}</span>`:""}
|
|
59
|
+
${this.content?e`
|
|
60
|
+
<div class="dialog-container mdc-dialog__content" id="dialog-content">
|
|
61
|
+
${"function"==typeof this.content?this.content():this.content}
|
|
62
|
+
</div>
|
|
63
|
+
<footer class="mdc-dialog__actions">
|
|
64
|
+
${this.actions?this.actions.map(t=>e`
|
|
65
|
+
<div class="mdc-button mdc-dialog__button" ?data-mdc-dialog-button-default="${t.default}" data-mdc-dialog-action="${t.disabled?void 0:t.actionName}">
|
|
66
|
+
${"string"==typeof t.content?e`<or-mwc-input .type="${c.BUTTON}" @or-mwc-input-changed="${t=>{t.currentTarget.disabled&&t.stopPropagation()}}" .disabled="${t.disabled}" .label="${t.content}"></or-mwc-input>`:t.content}
|
|
67
|
+
</div>`):""}
|
|
68
|
+
</footer>
|
|
69
|
+
`:e`
|
|
70
|
+
<ul class="mdc-list ${this.avatar?"mdc-list--avatar-list":""}">
|
|
71
|
+
${!this.actions?"":this.actions.map((t,o)=>e`<li class="mdc-list-item" data-mdc-dialog-action="${t.actionName}"><span class="mdc-list-item__text">${t.content}</span></li>`)}
|
|
72
|
+
</ul>
|
|
73
|
+
`}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="mdc-dialog__scrim"></div>
|
|
77
|
+
</div>
|
|
78
|
+
`}updated(t){super.updated(t),t.has("_open")&&this._open&&this.open()}_onDialogOpened(){this.dispatchEvent(new OrMwcDialogOpenedEvent)}_onDialogClosed(t){if("close"===t&&this.dismissAction&&this.dismissAction.action)this.dismissAction.action(this);else if(t&&this.actions){let e=this.actions.find(e=>e.actionName===t);e&&e.action&&e.action(this)}this._mdcComponent&&(this._mdcComponent.destroy(),this._mdcComponent=void 0),this.dispatchEvent(new OrMwcDialogClosedEvent(t))}_onBrowserNavigate(t){this.close("close")}};__decorate([s({type:String})],OrMwcDialog.prototype,"heading",void 0),__decorate([s({type:Object,attribute:!1})],OrMwcDialog.prototype,"content",void 0),__decorate([s({type:Array,attribute:!1})],OrMwcDialog.prototype,"actions",void 0),__decorate([s({type:Object,attribute:!1})],OrMwcDialog.prototype,"dismissAction",void 0),__decorate([s({type:Boolean})],OrMwcDialog.prototype,"avatar",void 0),__decorate([s()],OrMwcDialog.prototype,"styles",void 0),__decorate([s({attribute:!1})],OrMwcDialog.prototype,"_open",void 0),__decorate([a("#dialog")],OrMwcDialog.prototype,"_mdcElem",void 0),OrMwcDialog=__decorate([n("or-mwc-dialog")],OrMwcDialog);export{OrMwcDialog};
|