@leavittsoftware/web 1.2.2 → 1.3.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leavittsoftware/web",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "files": [
@@ -34,5 +34,5 @@
34
34
  "url": "https://github.com/LeavittSoftware/titanium-elements/issues"
35
35
  },
36
36
  "homepage": "https://github.com/LeavittSoftware/titanium-elements/#readme",
37
- "gitHead": "b10ae9a6bd83a16c8d4c1665f0c34cdf9263c93a"
37
+ "gitHead": "3de8cd3d1b933a26870ae663633b0b4f29c004c9"
38
38
  }
@@ -0,0 +1,10 @@
1
+ import { TemplateResult } from 'lit';
2
+ export declare class ConfirmDialogOpenEvent extends Event {
3
+ static eventType: string;
4
+ header: string;
5
+ text: string | TemplateResult;
6
+ dialogResult: Promise<boolean>;
7
+ resolver: (confirmed: boolean) => void;
8
+ constructor(header: string, text: string | TemplateResult);
9
+ }
10
+ //# sourceMappingURL=confirm-dialog-open-event.d.ts.map
@@ -0,0 +1,12 @@
1
+ export class ConfirmDialogOpenEvent extends Event {
2
+ static { this.eventType = 'confirm-dialog-open'; }
3
+ constructor(header, text) {
4
+ super(ConfirmDialogOpenEvent.eventType, { bubbles: true, composed: true });
5
+ this.header = header;
6
+ this.text = text;
7
+ this.dialogResult = new Promise((res) => {
8
+ this.resolver = res;
9
+ });
10
+ }
11
+ }
12
+ //# sourceMappingURL=confirm-dialog-open-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-dialog-open-event.js","sourceRoot":"","sources":["confirm-dialog-open-event.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,sBAAuB,SAAQ,KAAK;aACxC,cAAS,GAAG,qBAAqB,CAAC;IAMzC,YAAY,MAAc,EAAE,IAA6B;QACvD,KAAK,CAAC,sBAAsB,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACtC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -0,0 +1,25 @@
1
+ import '@material/web/dialog/dialog';
2
+ import '@material/web/button/text-button';
3
+ import { LitElement, TemplateResult } from 'lit';
4
+ import { ConfirmDialogOpenEvent } from './confirm-dialog-open-event';
5
+ import { MdDialog } from '@material/web/dialog/dialog';
6
+ export default class TitaniumConfirmDialog extends LitElement {
7
+ #private;
8
+ protected accessor text: string | TemplateResult;
9
+ protected accessor headline: string;
10
+ protected accessor dialog: MdDialog;
11
+ /**
12
+ * This method is used to set up the event listener to capture the confirm dialog open event
13
+ * You can skip using this method and set up the event listener yourself (recommended)
14
+ */
15
+ listenOn(el: HTMLElement): void;
16
+ /**
17
+ * This method is used after capturing the confirm dialog open event
18
+ * usually in the same class where the confirm-dialog element is used.
19
+ * After capturing the event pass it directly into this method `this.dialog.handleEvent(e);`
20
+ */
21
+ handleEvent(event: ConfirmDialogOpenEvent): Promise<void>;
22
+ static styles: import("lit").CSSResult[];
23
+ render(): TemplateResult<1>;
24
+ }
25
+ //# sourceMappingURL=confirm-dialog.d.ts.map
@@ -0,0 +1,92 @@
1
+ import { __decorate } from "tslib";
2
+ import '@material/web/dialog/dialog';
3
+ import '@material/web/button/text-button';
4
+ import { css, html, LitElement } from 'lit';
5
+ import { customElement, query, state } from 'lit/decorators.js';
6
+ import { ConfirmDialogOpenEvent } from './confirm-dialog-open-event';
7
+ import { p } from '../styles/p';
8
+ let TitaniumConfirmDialog = class TitaniumConfirmDialog extends LitElement {
9
+ #text_accessor_storage;
10
+ get text() { return this.#text_accessor_storage; }
11
+ set text(value) { this.#text_accessor_storage = value; }
12
+ #headline_accessor_storage;
13
+ get headline() { return this.#headline_accessor_storage; }
14
+ set headline(value) { this.#headline_accessor_storage = value; }
15
+ #dialog_accessor_storage;
16
+ get dialog() { return this.#dialog_accessor_storage; }
17
+ set dialog(value) { this.#dialog_accessor_storage = value; }
18
+ #resolve;
19
+ /**
20
+ * This method is used to set up the event listener to capture the confirm dialog open event
21
+ * You can skip using this method and set up the event listener yourself (recommended)
22
+ */
23
+ listenOn(el) {
24
+ el.addEventListener(ConfirmDialogOpenEvent.eventType, async (event) => {
25
+ this.#openDialogWithEvent(event);
26
+ });
27
+ }
28
+ /**
29
+ * This method is used after capturing the confirm dialog open event
30
+ * usually in the same class where the confirm-dialog element is used.
31
+ * After capturing the event pass it directly into this method `this.dialog.handleEvent(e);`
32
+ */
33
+ async handleEvent(event) {
34
+ this.#openDialogWithEvent(event);
35
+ }
36
+ #openDialogWithEvent = async (event) => {
37
+ this.headline = event.header;
38
+ this.text = event.text;
39
+ this.dialog.returnValue = '';
40
+ this.dialog.show();
41
+ const result = await new Promise((resolve) => {
42
+ this.#resolve = resolve;
43
+ });
44
+ event.resolver(result === 'confirmed');
45
+ };
46
+ static { this.styles = [
47
+ p,
48
+ css `
49
+ p {
50
+ margin: 6px 24px 0 24px;
51
+ }
52
+
53
+ md-dialog {
54
+ max-width: 550px;
55
+ max-height: calc(100vh - 24px);
56
+ }
57
+ `,
58
+ ]; }
59
+ render() {
60
+ return html `
61
+ <md-dialog
62
+ @close=${(e) => {
63
+ if (e.target.returnValue === 'confirmed') {
64
+ return this.#resolve('confirmed');
65
+ }
66
+ return this.#resolve('cancel');
67
+ }}
68
+ >
69
+ <div slot="headline">${this.headline}</div>
70
+ <p slot="content">${this.text}</p>
71
+ <div slot="actions">
72
+ <md-text-button @click=${() => this.dialog.close('cancel')}>Cancel</md-text-button>
73
+ <md-text-button @click=${() => this.dialog.close('confirmed')}>Confirm</md-text-button>
74
+ </div>
75
+ </md-dialog>
76
+ `;
77
+ }
78
+ };
79
+ __decorate([
80
+ state()
81
+ ], TitaniumConfirmDialog.prototype, "text", null);
82
+ __decorate([
83
+ state()
84
+ ], TitaniumConfirmDialog.prototype, "headline", null);
85
+ __decorate([
86
+ query('md-dialog')
87
+ ], TitaniumConfirmDialog.prototype, "dialog", null);
88
+ TitaniumConfirmDialog = __decorate([
89
+ customElement('titanium-confirm-dialog')
90
+ ], TitaniumConfirmDialog);
91
+ export default TitaniumConfirmDialog;
92
+ //# sourceMappingURL=confirm-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-dialog.js","sourceRoot":"","sources":["confirm-dialog.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,kCAAkC,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAGjB,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAC/B,uBAA8B;IAA9B,IAAA,IAAI,0CAA0B;IAA9B,IAAA,IAAI,gDAA0B;IAC9B,2BAAiB;IAAjB,IAAA,QAAQ,8CAAS;IAAjB,IAAA,QAAQ,oDAAS;IACN,yBAAkB;IAAlB,IAAA,MAAM,4CAAY;IAAlB,IAAA,MAAM,kDAAY;IACzD,QAAQ,CAA0C;IAElD;;;OAGG;IACH,QAAQ,CAAC,EAAe;QACtB,EAAE,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,SAAS,EAAE,KAAK,EAAE,KAA6B,EAAE,EAAE;YAC5F,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,C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