@api-client/ui 0.5.3 → 0.5.4
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/build/src/md/dialog/internals/ConfirmDialog.d.ts +39 -0
- package/build/src/md/dialog/internals/ConfirmDialog.d.ts.map +1 -0
- package/build/src/md/dialog/internals/ConfirmDialog.js +75 -0
- package/build/src/md/dialog/internals/ConfirmDialog.js.map +1 -0
- package/build/src/md/dialog/internals/Dialog.d.ts +6 -0
- package/build/src/md/dialog/internals/Dialog.d.ts.map +1 -1
- package/build/src/md/dialog/internals/Dialog.js +43 -5
- package/build/src/md/dialog/internals/Dialog.js.map +1 -1
- package/build/src/md/dialog/internals/Dialog.styles.d.ts.map +1 -1
- package/build/src/md/dialog/internals/Dialog.styles.js +39 -1
- package/build/src/md/dialog/internals/Dialog.styles.js.map +1 -1
- package/build/src/md/dialog/ui-confirm-dialog.d.ts +48 -0
- package/build/src/md/dialog/ui-confirm-dialog.d.ts.map +1 -0
- package/build/src/md/dialog/ui-confirm-dialog.js +64 -0
- package/build/src/md/dialog/ui-confirm-dialog.js.map +1 -0
- package/demo/md/dialog/confirm-dialog.html +49 -0
- package/demo/md/dialog/confirm-dialog.ts +121 -0
- package/demo/md/dialog/dialog.ts +76 -1
- package/demo/md/index.html +2 -0
- package/package.json +1 -1
- package/src/md/dialog/README.md +212 -0
- package/src/md/dialog/internals/ConfirmDialog.ts +79 -0
- package/src/md/dialog/internals/Dialog.styles.ts +39 -1
- package/src/md/dialog/internals/Dialog.ts +17 -4
- package/src/md/dialog/ui-confirm-dialog.ts +52 -0
- package/test/README.md +2 -0
- package/test/md/dialog/UiConfirmDialog.test.ts +131 -0
- package/test/md/dialog/UiDialog.test.ts +42 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import UiDialog from './Dialog.js';
|
|
3
|
+
import '../../button/ui-button.js';
|
|
4
|
+
/**
|
|
5
|
+
* A simple Material Design 3 styled confirm dialog for confirming user actions.
|
|
6
|
+
*
|
|
7
|
+
* This dialog provides a clean way to ask users to confirm or dismiss an action.
|
|
8
|
+
* It supports customizable button labels and content through slots.
|
|
9
|
+
*
|
|
10
|
+
* **Usage Example:**
|
|
11
|
+
* ```html
|
|
12
|
+
* <ui-confirm-dialog modal .open="${this.showConfirm}" @close="${this.handleConfirmClose}">
|
|
13
|
+
* <span slot="title">Delete Item</span>
|
|
14
|
+
* <p>Are you sure you want to delete this item? This action cannot be undone.</p>
|
|
15
|
+
* </ui-confirm-dialog>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* **Event Handling:**
|
|
19
|
+
* Listen for the `close` event to handle user interaction:
|
|
20
|
+
* ```javascript
|
|
21
|
+
* dialog.addEventListener('close', (e) => {
|
|
22
|
+
* const { cancelled } = e.detail;
|
|
23
|
+
* if (!cancelled) {
|
|
24
|
+
* // User confirmed the action
|
|
25
|
+
* performAction();
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @slot title - The dialog title content
|
|
31
|
+
* @slot - The main body content of the dialog
|
|
32
|
+
* @fires close - Dispatched when the dialog is closed with closing reason details
|
|
33
|
+
*/
|
|
34
|
+
export default class ConfirmDialog extends UiDialog {
|
|
35
|
+
constructor();
|
|
36
|
+
protected renderContent(): TemplateResult[];
|
|
37
|
+
protected renderButtons(): TemplateResult;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=ConfirmDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmDialog.d.ts","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/ConfirmDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAQ,MAAM,KAAK,CAAA;AAE1C,OAAO,QAAQ,MAAM,aAAa,CAAA;AAElC,OAAO,2BAA2B,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,QAAQ;;cAS9B,aAAa,IAAI,cAAc,EAAE;cAIjC,aAAa,IAAI,cAAc;CA6BnD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
3
|
+
import UiDialog from './Dialog.js';
|
|
4
|
+
import '../../button/ui-button.js';
|
|
5
|
+
/**
|
|
6
|
+
* A simple Material Design 3 styled confirm dialog for confirming user actions.
|
|
7
|
+
*
|
|
8
|
+
* This dialog provides a clean way to ask users to confirm or dismiss an action.
|
|
9
|
+
* It supports customizable button labels and content through slots.
|
|
10
|
+
*
|
|
11
|
+
* **Usage Example:**
|
|
12
|
+
* ```html
|
|
13
|
+
* <ui-confirm-dialog modal .open="${this.showConfirm}" @close="${this.handleConfirmClose}">
|
|
14
|
+
* <span slot="title">Delete Item</span>
|
|
15
|
+
* <p>Are you sure you want to delete this item? This action cannot be undone.</p>
|
|
16
|
+
* </ui-confirm-dialog>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* **Event Handling:**
|
|
20
|
+
* Listen for the `close` event to handle user interaction:
|
|
21
|
+
* ```javascript
|
|
22
|
+
* dialog.addEventListener('close', (e) => {
|
|
23
|
+
* const { cancelled } = e.detail;
|
|
24
|
+
* if (!cancelled) {
|
|
25
|
+
* // User confirmed the action
|
|
26
|
+
* performAction();
|
|
27
|
+
* }
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @slot title - The dialog title content
|
|
32
|
+
* @slot - The main body content of the dialog
|
|
33
|
+
* @fires close - Dispatched when the dialog is closed with closing reason details
|
|
34
|
+
*/
|
|
35
|
+
export default class ConfirmDialog extends UiDialog {
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
// Set modal by default for confirm dialogs
|
|
39
|
+
this.modal = true;
|
|
40
|
+
this.confirmLabel = 'Confirm';
|
|
41
|
+
this.dismissLabel = 'Cancel';
|
|
42
|
+
}
|
|
43
|
+
renderContent() {
|
|
44
|
+
return [this.renderTitle(), this.renderBody(), this.renderButtons()];
|
|
45
|
+
}
|
|
46
|
+
renderButtons() {
|
|
47
|
+
const classes = {
|
|
48
|
+
'buttons': true,
|
|
49
|
+
'with-buttons': true,
|
|
50
|
+
};
|
|
51
|
+
return html `
|
|
52
|
+
<div class="${classMap(classes)}" part="buttons">
|
|
53
|
+
<ui-button
|
|
54
|
+
color="text"
|
|
55
|
+
value="dismiss"
|
|
56
|
+
class="internal-button"
|
|
57
|
+
@click="${this.handleDismiss}"
|
|
58
|
+
part="dismiss-button"
|
|
59
|
+
>
|
|
60
|
+
${this.dismissLabel}
|
|
61
|
+
</ui-button>
|
|
62
|
+
<ui-button
|
|
63
|
+
color="filled"
|
|
64
|
+
value="confirm"
|
|
65
|
+
class="internal-button ${this.destructive ? 'destructive' : ''}"
|
|
66
|
+
@click="${this.handleConfirm}"
|
|
67
|
+
part="confirm-button"
|
|
68
|
+
>
|
|
69
|
+
${this.confirmLabel}
|
|
70
|
+
</ui-button>
|
|
71
|
+
</div>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=ConfirmDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmDialog.js","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/ConfirmDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,QAAQ,MAAM,aAAa,CAAA;AAElC,OAAO,2BAA2B,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,QAAQ;IACjD;QACE,KAAK,EAAE,CAAA;QACP,2CAA2C;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAA;QAC7B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAA;IAC9B,CAAC;IAEkB,aAAa;QAC9B,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;IACtE,CAAC;IAEkB,aAAa;QAC9B,MAAM,OAAO,GAAc;YACzB,SAAS,EAAE,IAAI;YACf,cAAc,EAAE,IAAI;SACrB,CAAA;QAED,OAAO,IAAI,CAAA;oBACK,QAAQ,CAAC,OAAO,CAAC;;;;;oBAKjB,IAAI,CAAC,aAAa;;;YAG1B,IAAI,CAAC,YAAY;;;;;mCAKM,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE;oBACpD,IAAI,CAAC,aAAa;;;YAG1B,IAAI,CAAC,YAAY;;;KAGxB,CAAA;IACH,CAAC;CACF","sourcesContent":["import { TemplateResult, html } from 'lit'\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js'\nimport UiDialog from './Dialog.js'\n\nimport '../../button/ui-button.js'\n\n/**\n * A simple Material Design 3 styled confirm dialog for confirming user actions.\n *\n * This dialog provides a clean way to ask users to confirm or dismiss an action.\n * It supports customizable button labels and content through slots.\n *\n * **Usage Example:**\n * ```html\n * <ui-confirm-dialog modal .open=\"${this.showConfirm}\" @close=\"${this.handleConfirmClose}\">\n * <span slot=\"title\">Delete Item</span>\n * <p>Are you sure you want to delete this item? This action cannot be undone.</p>\n * </ui-confirm-dialog>\n * ```\n *\n * **Event Handling:**\n * Listen for the `close` event to handle user interaction:\n * ```javascript\n * dialog.addEventListener('close', (e) => {\n * const { cancelled } = e.detail;\n * if (!cancelled) {\n * // User confirmed the action\n * performAction();\n * }\n * });\n * ```\n *\n * @slot title - The dialog title content\n * @slot - The main body content of the dialog\n * @fires close - Dispatched when the dialog is closed with closing reason details\n */\nexport default class ConfirmDialog extends UiDialog {\n constructor() {\n super()\n // Set modal by default for confirm dialogs\n this.modal = true\n this.confirmLabel = 'Confirm'\n this.dismissLabel = 'Cancel'\n }\n\n protected override renderContent(): TemplateResult[] {\n return [this.renderTitle(), this.renderBody(), this.renderButtons()]\n }\n\n protected override renderButtons(): TemplateResult {\n const classes: ClassInfo = {\n 'buttons': true,\n 'with-buttons': true,\n }\n\n return html`\n <div class=\"${classMap(classes)}\" part=\"buttons\">\n <ui-button\n color=\"text\"\n value=\"dismiss\"\n class=\"internal-button\"\n @click=\"${this.handleDismiss}\"\n part=\"dismiss-button\"\n >\n ${this.dismissLabel}\n </ui-button>\n <ui-button\n color=\"filled\"\n value=\"confirm\"\n class=\"internal-button ${this.destructive ? 'destructive' : ''}\"\n @click=\"${this.handleConfirm}\"\n part=\"confirm-button\"\n >\n ${this.confirmLabel}\n </ui-button>\n </div>\n `\n }\n}\n"]}
|
|
@@ -100,6 +100,12 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
100
100
|
* @attribute
|
|
101
101
|
*/
|
|
102
102
|
accessor confirmLabel: string | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* When true, styles the confirm button with error colors to indicate
|
|
105
|
+
* a destructive action (e.g., delete, remove, etc.).
|
|
106
|
+
* @attribute
|
|
107
|
+
*/
|
|
108
|
+
accessor destructive: boolean;
|
|
103
109
|
/**
|
|
104
110
|
* Part of the imperative access to the element.
|
|
105
111
|
* When set, it wraps the content in a `<form>` element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAiB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAe,MAAM,KAAK,CAAA;AAGlH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAA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WAAW,EAAE,CAAA;IAEpG;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAIrB;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;;IA4BD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,EAAE,MAAM,CAAC,EAAE,iBAAiB,EAAE,GAAG,IAAI;IAiB5E,iBAAiB,IAAI,IAAI;IAQzB,oBAAoB,IAAI,IAAI;cAQlB,YAAY,IAAI,IAAI;IAS9B,UAAU,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAQnD,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAMzB,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IAkBhC,aAAa,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI;IAUrC,OAAO,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IA8B/D,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI;IAmB/D,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAQnC,SAAS,CAAC,aAAa,IAAI,IAAI;IAI/B,SAAS,CAAC,aAAa,IAAI,IAAI;IAsBtB,MAAM,IAAI,cAAc;IAUjC,SAAS,CAAC,aAAa,IAAI,cAAc,EAAE,GAAG,cAAc;IAY5D,SAAS,CAAC,UAAU,IAAI,cAAc;IAatC,SAAS,CAAC,WAAW,IAAI,cAAc;IAYvC,SAAS,CAAC,UAAU,IAAI,cAAc;IAStC,SAAS,CAAC,aAAa,IAAI,cAAc;CAiD1C"}
|
|
@@ -24,6 +24,9 @@ let UiDialog = (() => {
|
|
|
24
24
|
let _confirmLabel_decorators;
|
|
25
25
|
let _confirmLabel_initializers = [];
|
|
26
26
|
let _confirmLabel_extraInitializers = [];
|
|
27
|
+
let _destructive_decorators;
|
|
28
|
+
let _destructive_initializers = [];
|
|
29
|
+
let _destructive_extraInitializers = [];
|
|
27
30
|
let _useForm_decorators;
|
|
28
31
|
let _useForm_initializers = [];
|
|
29
32
|
let _useForm_extraInitializers = [];
|
|
@@ -67,6 +70,7 @@ let UiDialog = (() => {
|
|
|
67
70
|
_open_decorators = [property({ type: Boolean })];
|
|
68
71
|
_dismissLabel_decorators = [property({ type: String })];
|
|
69
72
|
_confirmLabel_decorators = [property({ type: String })];
|
|
73
|
+
_destructive_decorators = [property({ type: Boolean })];
|
|
70
74
|
_useForm_decorators = [property({ type: Boolean })];
|
|
71
75
|
_confirmValue_decorators = [property({ type: String })];
|
|
72
76
|
_submitClose_decorators = [property({ type: Boolean })];
|
|
@@ -84,6 +88,7 @@ let UiDialog = (() => {
|
|
|
84
88
|
__esDecorate(this, null, _open_decorators, { kind: "accessor", name: "open", static: false, private: false, access: { has: obj => "open" in obj, get: obj => obj.open, set: (obj, value) => { obj.open = value; } }, metadata: _metadata }, _open_initializers, _open_extraInitializers);
|
|
85
89
|
__esDecorate(this, null, _dismissLabel_decorators, { kind: "accessor", name: "dismissLabel", static: false, private: false, access: { has: obj => "dismissLabel" in obj, get: obj => obj.dismissLabel, set: (obj, value) => { obj.dismissLabel = value; } }, metadata: _metadata }, _dismissLabel_initializers, _dismissLabel_extraInitializers);
|
|
86
90
|
__esDecorate(this, null, _confirmLabel_decorators, { kind: "accessor", name: "confirmLabel", static: false, private: false, access: { has: obj => "confirmLabel" in obj, get: obj => obj.confirmLabel, set: (obj, value) => { obj.confirmLabel = value; } }, metadata: _metadata }, _confirmLabel_initializers, _confirmLabel_extraInitializers);
|
|
91
|
+
__esDecorate(this, null, _destructive_decorators, { kind: "accessor", name: "destructive", static: false, private: false, access: { has: obj => "destructive" in obj, get: obj => obj.destructive, set: (obj, value) => { obj.destructive = value; } }, metadata: _metadata }, _destructive_initializers, _destructive_extraInitializers);
|
|
87
92
|
__esDecorate(this, null, _useForm_decorators, { kind: "accessor", name: "useForm", static: false, private: false, access: { has: obj => "useForm" in obj, get: obj => obj.useForm, set: (obj, value) => { obj.useForm = value; } }, metadata: _metadata }, _useForm_initializers, _useForm_extraInitializers);
|
|
88
93
|
__esDecorate(this, null, _confirmValue_decorators, { kind: "accessor", name: "confirmValue", static: false, private: false, access: { has: obj => "confirmValue" in obj, get: obj => obj.confirmValue, set: (obj, value) => { obj.confirmValue = value; } }, metadata: _metadata }, _confirmValue_initializers, _confirmValue_extraInitializers);
|
|
89
94
|
__esDecorate(this, null, _submitClose_decorators, { kind: "accessor", name: "submitClose", static: false, private: false, access: { has: obj => "submitClose" in obj, get: obj => obj.submitClose, set: (obj, value) => { obj.submitClose = value; } }, metadata: _metadata }, _submitClose_initializers, _submitClose_extraInitializers);
|
|
@@ -156,7 +161,34 @@ let UiDialog = (() => {
|
|
|
156
161
|
*/
|
|
157
162
|
get confirmLabel() { return this.#confirmLabel_accessor_storage; }
|
|
158
163
|
set confirmLabel(value) { this.#confirmLabel_accessor_storage = value; }
|
|
159
|
-
#
|
|
164
|
+
#destructive_accessor_storage = (__runInitializers(this, _confirmLabel_extraInitializers), __runInitializers(this, _destructive_initializers, false
|
|
165
|
+
/**
|
|
166
|
+
* Part of the imperative access to the element.
|
|
167
|
+
* When set, it wraps the content in a `<form>` element.
|
|
168
|
+
* When this is enabled the following will happen:
|
|
169
|
+
* - The `confirm` button will get `type="submit"`
|
|
170
|
+
* - The form `method` attribute is set to `dialog`
|
|
171
|
+
* - The form `id` attribute is set to a random string. You can get it from the `formId` getter.
|
|
172
|
+
* - The dialog will dispatch the same `submit` event as the form.
|
|
173
|
+
* - When the `submit` event dispatched by the dialog gets cancelled, then:
|
|
174
|
+
* - The original submit event also gets cancelled.
|
|
175
|
+
* - The default confirm action is not invoked
|
|
176
|
+
* - The dialog stays opened
|
|
177
|
+
* - When the submit event is not cancelled, then:
|
|
178
|
+
* - The default confirm action is invoked.
|
|
179
|
+
* - The dialog is closed.
|
|
180
|
+
*
|
|
181
|
+
* @deprecated Wrap the content in a `<form>` element instead.
|
|
182
|
+
*/
|
|
183
|
+
));
|
|
184
|
+
/**
|
|
185
|
+
* When true, styles the confirm button with error colors to indicate
|
|
186
|
+
* a destructive action (e.g., delete, remove, etc.).
|
|
187
|
+
* @attribute
|
|
188
|
+
*/
|
|
189
|
+
get destructive() { return this.#destructive_accessor_storage; }
|
|
190
|
+
set destructive(value) { this.#destructive_accessor_storage = value; }
|
|
191
|
+
#useForm_accessor_storage = (__runInitializers(this, _destructive_extraInitializers), __runInitializers(this, _useForm_initializers, void 0));
|
|
160
192
|
/**
|
|
161
193
|
* Part of the imperative access to the element.
|
|
162
194
|
* When set, it wraps the content in a `<form>` element.
|
|
@@ -331,6 +363,9 @@ let UiDialog = (() => {
|
|
|
331
363
|
}
|
|
332
364
|
handleKeyDown(e) {
|
|
333
365
|
super.handleKeyDown(e);
|
|
366
|
+
if (e.defaultPrevented) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
334
369
|
if (e.key === 'Escape') {
|
|
335
370
|
this.handleInteraction('dismiss');
|
|
336
371
|
}
|
|
@@ -412,9 +447,10 @@ let UiDialog = (() => {
|
|
|
412
447
|
}
|
|
413
448
|
}
|
|
414
449
|
render() {
|
|
415
|
-
const { useForm } = this;
|
|
450
|
+
const { useForm, modal } = this;
|
|
451
|
+
const dialogClass = modal ? 'modal' : 'non-modal';
|
|
416
452
|
return html `
|
|
417
|
-
<dialog @close="${this.handleDialogClose}" part="dialog">
|
|
453
|
+
<dialog @close="${this.handleDialogClose}" part="dialog" class="${dialogClass}">
|
|
418
454
|
<div class="container">${useForm ? this.#renderFormContent() : this.renderContent()}</div>
|
|
419
455
|
</dialog>
|
|
420
456
|
`;
|
|
@@ -433,6 +469,7 @@ let UiDialog = (() => {
|
|
|
433
469
|
const classes = {
|
|
434
470
|
'icon': true,
|
|
435
471
|
'with-icon': this.hasIcon,
|
|
472
|
+
'destructive': this.destructive,
|
|
436
473
|
};
|
|
437
474
|
return html `
|
|
438
475
|
<div class="${classMap(classes)}" part="icon">
|
|
@@ -488,17 +525,18 @@ let UiDialog = (() => {
|
|
|
488
525
|
`;
|
|
489
526
|
}
|
|
490
527
|
#renderConfirmButton() {
|
|
491
|
-
const { confirmLabel, confirmValue = 'confirm', useForm } = this;
|
|
528
|
+
const { confirmLabel, confirmValue = 'confirm', useForm, destructive } = this;
|
|
492
529
|
if (!confirmLabel) {
|
|
493
530
|
return nothing;
|
|
494
531
|
}
|
|
495
532
|
const type = useForm ? 'submit' : 'button';
|
|
533
|
+
const buttonClass = destructive ? 'internal-button destructive' : 'internal-button';
|
|
496
534
|
return html `
|
|
497
535
|
<ui-button
|
|
498
536
|
color="text"
|
|
499
537
|
type="${type}"
|
|
500
538
|
value="${confirmValue}"
|
|
501
|
-
class="
|
|
539
|
+
class="${buttonClass}"
|
|
502
540
|
@click="${this.handleConfirm}"
|
|
503
541
|
part="positive-action"
|
|
504
542
|
>${confirmLabel}</ui-button
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAA0B,IAAI,EAAE,OAAO,EAA4C,WAAW,EAAE,MAAM,KAAK,CAAA;AAClH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACrG,OAAO,EAAkB,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAC9E,OAAO,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;;sBAqEd,SAAS;;;;;;;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ACH,YAAY;;kBAEX,IAAI,CAAC,aAAa;;WAEzB,YAAY;;KAElB,CAAA;QACH,CAAC;;;AA5cH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBA6ZC","sourcesContent":["import { type CSSResultOrNative, html, nothing, type PropertyValues, type TemplateResult, adoptStyles } from 'lit'\nimport { property, query, queryAssignedElements, queryAssignedNodes, state } from 'lit/decorators.js'\nimport { type ClassInfo, classMap } from 'lit/directives/class-map.js'\nimport { UiElement } from '../../UiElement.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport type UiButton from '../../button/internals/button.js'\nimport type { TypedEvents } from '../../../core/types.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { SyntheticSubmitEvent } from '../../../events/SyntheticSubmitEvent.js'\nimport '../../button/ui-button.js'\nimport { bound } from '../../../decorators/bound.js'\n\nexport interface UiDialogClosingReason {\n /**\n * Whether the dialog was cancelled by either activating the `dismiss` button\n * or by pressing escape.\n */\n cancelled: boolean\n /**\n * This is used in cases when the dialog has more complex purpose.\n * This is the value expected from the dialog.\n */\n value?: unknown\n}\n\ninterface DialogEventMap {\n close: CustomEvent<UiDialogClosingReason>\n}\n\nexport type RenderFunction = () => TemplateResult\n\n/**\n * Styled dialog using a native `<dialog>` element under the hood.\n * Note, since native dialog renders in the top layer it is not necessary\n * to place the dialog in the `<body>`.\n *\n * **Using Buttons**\n *\n * The dialog automatically recognizes buttons with values `confirm` and `dismiss`\n * to close the dialog and dispatch the `close` event. The event has additional\n * closing reason detail.\n *\n * ```javascript\n * <ui-button color=\"text\" value=\"dismiss\">Cancel</ui-button>\n * <ui-button color=\"text\" value=\"confirm\">Take action</ui-button>\n * ```\n *\n * ```javascript\n * <button value=\"dismiss\">Cancel</button>\n * <button value=\"confirm\">Take action</button>\n * ```\n *\n * The detail object of the `close` event has the following properties:\n * - cancelled - Whether the dialog was cancelled by either activating the `dismiss` button or by pressing escape.\n *\n * The `close` event is only dispatched when the user interact with the dialog. Imperative control of the\n * dialog won't trigger the close button.\n *\n * ** Full example**\n *\n * ```javascript\n * <ui-dialog modal>\n * <ui-icon slot=\"icon\" icon=\"delete\"></ui-icon>\n *\n * <span slot=\"title\">Delete photos?</span>\n * <p>This action will permanently remove the selected pictures from your account.</p>\n *\n * <ui-button color=\"text\" slot=\"button\" value=\"dismiss\" type=\"text\">Cancel</ui-button>\n * <ui-button color=\"text\" slot=\"button\" value=\"confirm\" type=\"text\">Confirm</ui-button>\n * </ui-dialog>\n * ```\n *\n * @slot - The slot for the content of the dialog.\n * @slot icon - The slot to place the dialog icon\n * @slot title - The slot to place the dialog title. Do not put elements here, just the text.\n * @slot button - The slot to place the dialog buttons. Use the `confirm` or `dismiss`\n * buttons to automatically close the dialog.\n * @fires close - A non-bubbling, non-cancellable event with the `UiDialogClosingReason` as the detail.\n */\nexport default class UiDialog extends UiElement implements TypedEvents<DialogEventMap> {\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n }\n\n /**\n * Opens the dialog as modal when toggling dialog's open state.\n *\n * Setting this value after the dialog was opened has no effect.\n *\n * @attribute\n */\n @property({ type: Boolean }) accessor modal = false\n\n /**\n * Toggles visibility of the dialog.\n * Note, the dialog is opened asynchronously after the update is performed.\n * @attribute\n */\n @property({ type: Boolean }) accessor open = false\n\n /**\n * Imperative access to create a dismiss button.\n * When set this will render a dismiss button at the end of the buttons line, before the `confirmLabel` button.\n * @attribute\n */\n @property({ type: String }) accessor dismissLabel: string | undefined\n\n /**\n * Imperative access to create a confirm button.\n * When set this will render a confirm button at the end of the buttons line, after the `dismissLabel` button.\n * @attribute\n */\n @property({ type: String }) accessor confirmLabel: string | undefined\n\n /**\n * Part of the imperative access to the element.\n * When set, it wraps the content in a `<form>` element.\n * When this is enabled the following will happen:\n * - The `confirm` button will get `type=\"submit\"`\n * - The form `method` attribute is set to `dialog`\n * - The form `id` attribute is set to a random string. You can get it from the `formId` getter.\n * - The dialog will dispatch the same `submit` event as the form.\n * - When the `submit` event dispatched by the dialog gets cancelled, then:\n * - The original submit event also gets cancelled.\n * - The default confirm action is not invoked\n * - The dialog stays opened\n * - When the submit event is not cancelled, then:\n * - The default confirm action is invoked.\n * - The dialog is closed.\n *\n * @deprecated Wrap the content in a `<form>` element instead.\n */\n @property({ type: Boolean }) accessor useForm: boolean | undefined\n\n /**\n * Only when `confirmLabel` is set.\n * Defines the value associated with the button's name when it's submitted with the form data.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#value}\n * @attribute\n */\n @property({ type: String }) accessor confirmValue: string | undefined\n /**\n * When the dialog is wrapped in a form, set this to `true` to close the dialog\n * when the form is submitted.\n *\n * Note that the dialog doesn't perform any validation of the form. It only closes\n * when the form is submitted, regardless of the application logic. The `submit` event\n * is dispatched by the dialog when the form is valid.\n */\n @property({ type: Boolean }) accessor submitClose: boolean | undefined\n\n /**\n * A reference to the underlying dialog element.\n */\n @query('dialog') accessor dialog!: HTMLDialogElement\n\n @state() protected accessor hasIcon = false\n\n @state() protected accessor hasTitle = false\n\n @state() protected accessor hasButton = false\n\n @queryAssignedElements({ flatten: true, slot: 'icon' }) protected accessor icons!: HTMLElement[]\n\n @queryAssignedNodes({ flatten: true, slot: 'title' }) protected accessor titles!: HTMLElement[]\n\n @queryAssignedElements({ flatten: true, slot: 'button' }) protected accessor buttons!: HTMLElement[]\n\n /**\n * To be set by a child class when closing the dialog.\n * This is passed to the close event.\n */\n dialogValue?: unknown\n\n #formId?: string\n\n /**\n * @deprecated Use `useForm` instead.\n */\n get formId(): string | undefined {\n return this.#formId\n }\n\n /**\n * @deprecated This will be removed in the future.\n */\n @state() accessor #inject: TemplateResult | RenderFunction | undefined\n\n /**\n * @deprecated This will be removed in the future.\n */\n #pendingStyles?: CSSResultOrNative[]\n\n /**\n * A reference to the parent form element.\n * When a form is found, the dialog will hook into the form's submit event\n * and close the dialog when the form is submitted.\n * Since the `submit` event is dispatched when the form is valid,\n * we can use this to close the dialog and not worry about the form validation.\n */\n #form: HTMLFormElement | null = null\n\n constructor() {\n super()\n\n this.addEventListener('click', this.handleClick)\n this.addEventListener('keydown', this.handleKeyDown)\n }\n\n /**\n * Allows to inject a template into the internals of the element.\n * This is helpful when working with imperative dialogs.\n * @param content The content to inject into the body.\n * @deprecated This will be removed in the future. To use forms, wrap the content in a `<form>` element.\n */\n inject(content?: TemplateResult | RenderFunction, styles?: CSSResultOrNative[]): void {\n this.#inject = content\n if (styles) {\n if (this.shadowRoot) {\n adoptStyles(this.shadowRoot, styles)\n } else {\n if (!this.#pendingStyles) {\n this.#pendingStyles = []\n }\n this.#pendingStyles.push(...styles)\n }\n }\n if (this.shadowRoot && styles) {\n adoptStyles(this.shadowRoot, styles)\n }\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.#form = this.closest('form')\n if (this.#form) {\n this.#form.addEventListener('submit', this.handleFormSubmit)\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n if (this.#form) {\n this.#form.removeEventListener('submit', this.handleFormSubmit)\n this.#form = null\n }\n }\n\n protected override firstUpdated(): void {\n const styles = this.#pendingStyles\n if (styles) {\n const root = this.shadowRoot as ShadowRoot\n const all = [...root.adoptedStyleSheets, ...styles]\n adoptStyles(this.shadowRoot as ShadowRoot, all)\n }\n }\n\n override willUpdate(cp: PropertyValues<this>): void {\n if (cp.has('useForm') && this.useForm && !this.#formId) {\n const r = (Math.random() + 1).toString(36).substring(7)\n this.#formId = `form-${r}`\n }\n }\n\n @bound\n protected handleFormSubmit(): void {\n if (this.submitClose) {\n this.handleInteraction('confirm')\n }\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n const path = e.composedPath()\n const { buttons } = this\n const button = path.find((i) => buttons.includes(i as HTMLElement)) as HTMLButtonElement | UiButton | undefined\n if (!button) {\n return\n }\n if (button.type === 'submit') {\n // Adds support for forms.\n // When a form's submit button is clicked we yield the flow control to the form.\n // This way the form can handle the submit event.\n return\n }\n const { value = '' } = button\n this.handleInteraction(value as 'dismiss' | 'confirm')\n }\n\n override handleKeyDown(e: KeyboardEvent): void {\n super.handleKeyDown(e)\n if (e.key === 'Escape') {\n this.handleInteraction('dismiss')\n }\n }\n\n override updated(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('open')) {\n this.#controlVisibility()\n }\n super.updated(changedProperties)\n }\n\n #controlVisibility(): void {\n const { dialog, modal, open } = this\n if (!dialog) {\n return\n }\n if (open) {\n if (modal) {\n dialog.showModal()\n } else {\n dialog.show()\n }\n } else {\n dialog.close()\n }\n }\n\n #handleSlotChange(): void {\n const { icons, titles, buttons } = this\n this.hasIcon = !!icons && !!icons.length\n this.hasTitle = !!titles && !!titles.length\n this.hasButton = !!buttons && !!buttons.length\n }\n\n protected handleInteraction(value: 'dismiss' | 'confirm'): void {\n if (!['dismiss', 'confirm'].includes(value)) {\n return\n }\n this.open = false\n const detail: UiDialogClosingReason = {\n cancelled: value === 'dismiss',\n }\n if (this.dialogValue !== undefined) {\n detail.value = this.dialogValue\n }\n this.dispatchEvent(\n new CustomEvent<UiDialogClosingReason>('close', {\n composed: true,\n detail,\n })\n )\n }\n\n protected handleDialogClose(): void {\n if (!this.open) {\n return\n }\n this.open = false\n this.handleInteraction('dismiss')\n }\n\n protected handleDismiss(): void {\n this.handleInteraction('dismiss')\n }\n\n protected handleConfirm(): void {\n if (!this.useForm) {\n this.handleInteraction('confirm')\n }\n }\n\n #handleSubmit(event: SubmitEvent): void {\n const form = event.target as HTMLFormElement\n const copy = new SyntheticSubmitEvent(event.type, form, {\n submitter: event.submitter,\n cancelable: true,\n bubbles: false,\n composed: false,\n })\n const dispatched = this.dispatchEvent(copy)\n if (dispatched) {\n this.handleInteraction('confirm')\n } else {\n event.preventDefault()\n }\n }\n\n override render(): TemplateResult {\n const { useForm } = this\n return html`\n <dialog @close=\"${this.handleDialogClose}\" part=\"dialog\">\n <div class=\"container\">${useForm ? this.#renderFormContent() : this.renderContent()}</div>\n </dialog>\n `\n }\n\n protected renderContent(): TemplateResult[] | TemplateResult {\n return [this.renderIcon(), this.renderTitle(), this.renderBody(), this.renderButtons()]\n }\n\n #renderFormContent(): TemplateResult {\n return html`\n <form id=\"${ifDefined(this.formId)}\" method=\"dialog\" @submit=\"${this.#handleSubmit}\" part=\"form\">\n ${this.renderContent()}\n </form>\n `\n }\n\n protected renderIcon(): TemplateResult {\n const classes: ClassInfo = {\n 'icon': true,\n 'with-icon': this.hasIcon,\n }\n return html`\n <div class=\"${classMap(classes)}\" part=\"icon\">\n <slot name=\"icon\" @slotchange=\"${this.#handleSlotChange}\"></slot>\n </div>\n `\n }\n\n protected renderTitle(): TemplateResult {\n const classes: ClassInfo = {\n 'title': true,\n 'with-title': this.hasTitle,\n }\n return html`\n <div class=\"${classMap(classes)}\" part=\"title\">\n <slot name=\"title\" @slotchange=\"${this.#handleSlotChange}\"></slot>\n </div>\n `\n }\n\n protected renderBody(): TemplateResult {\n let content = this.#inject\n if (typeof content === 'function') {\n content = content()\n }\n const injected = content || nothing\n return html` <div class=\"content\" part=\"body\"><slot></slot>${injected}</div> `\n }\n\n protected renderButtons(): TemplateResult {\n const classes: ClassInfo = {\n 'buttons': true,\n 'with-buttons': this.hasButton || !!this.confirmLabel || !!this.dismissLabel,\n }\n return html`\n <div class=\"${classMap(classes)}\" part=\"button\">\n <slot name=\"button\" @slotchange=\"${this.#handleSlotChange}\"></slot>\n ${this.#renderDismissButton()} ${this.#renderConfirmButton()}\n </div>\n `\n }\n\n #renderDismissButton(): TemplateResult | typeof nothing {\n const { dismissLabel } = this\n if (!dismissLabel) {\n return nothing\n }\n return html`\n <ui-button\n color=\"text\"\n value=\"dismiss\"\n class=\"internal-button\"\n @click=\"${this.handleDismiss}\"\n part=\"negative-action\"\n >${dismissLabel}</ui-button\n >\n `\n }\n\n #renderConfirmButton(): TemplateResult | typeof nothing {\n const { confirmLabel, confirmValue = 'confirm', useForm } = this\n if (!confirmLabel) {\n return nothing\n }\n const type = useForm ? 'submit' : 'button'\n return html`\n <ui-button\n color=\"text\"\n type=\"${type}\"\n value=\"${confirmValue}\"\n class=\"internal-button\"\n @click=\"${this.handleConfirm}\"\n part=\"positive-action\"\n >${confirmLabel}</ui-button\n >\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAA0B,IAAI,EAAE,OAAO,EAA4C,WAAW,EAAE,MAAM,KAAK,CAAA;AAClH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACrG,OAAO,EAAkB,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAC9E,OAAO,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;;sBAqEd,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA1B,QAAS,SAAQ,WAAS;;;wCAS5C,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iCAc1C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gCAO3B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAO3B,QAAQ,CAAC,EAAE,IAAI,EAAE,M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AA;YAChB,CAAC;YACD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAA;YAC1C,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,iBAAiB,CAAA;YACnF,OAAO,IAAI,CAAA;;;gBAGC,IAAI;iBACH,YAAY;iBACZ,WAAW;kBACV,IAAI,CAAC,aAAa;;WAEzB,YAAY;;KAElB,CAAA;QACH,CAAC;;;AAzdH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBA0aC","sourcesContent":["import { type CSSResultOrNative, html, nothing, type PropertyValues, type TemplateResult, adoptStyles } from 'lit'\nimport { property, query, queryAssignedElements, queryAssignedNodes, state } from 'lit/decorators.js'\nimport { type ClassInfo, classMap } from 'lit/directives/class-map.js'\nimport { UiElement } from '../../UiElement.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport type UiButton from '../../button/internals/button.js'\nimport type { TypedEvents } from '../../../core/types.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { SyntheticSubmitEvent } from '../../../events/SyntheticSubmitEvent.js'\nimport '../../button/ui-button.js'\nimport { bound } from '../../../decorators/bound.js'\n\nexport interface UiDialogClosingReason {\n /**\n * Whether the dialog was cancelled by either activating the `dismiss` button\n * or by pressing escape.\n */\n cancelled: boolean\n /**\n * This is used in cases when the dialog has more complex purpose.\n * This is the value expected from the dialog.\n */\n value?: unknown\n}\n\ninterface DialogEventMap {\n close: CustomEvent<UiDialogClosingReason>\n}\n\nexport type RenderFunction = () => TemplateResult\n\n/**\n * Styled dialog using a native `<dialog>` element under the hood.\n * Note, since native dialog renders in the top layer it is not necessary\n * to place the dialog in the `<body>`.\n *\n * **Using Buttons**\n *\n * The dialog automatically recognizes buttons with values `confirm` and `dismiss`\n * to close the dialog and dispatch the `close` event. The event has additional\n * closing reason detail.\n *\n * ```javascript\n * <ui-button color=\"text\" value=\"dismiss\">Cancel</ui-button>\n * <ui-button color=\"text\" value=\"confirm\">Take action</ui-button>\n * ```\n *\n * ```javascript\n * <button value=\"dismiss\">Cancel</button>\n * <button value=\"confirm\">Take action</button>\n * ```\n *\n * The detail object of the `close` event has the following properties:\n * - cancelled - Whether the dialog was cancelled by either activating the `dismiss` button or by pressing escape.\n *\n * The `close` event is only dispatched when the user interact with the dialog. Imperative control of the\n * dialog won't trigger the close button.\n *\n * ** Full example**\n *\n * ```javascript\n * <ui-dialog modal>\n * <ui-icon slot=\"icon\" icon=\"delete\"></ui-icon>\n *\n * <span slot=\"title\">Delete photos?</span>\n * <p>This action will permanently remove the selected pictures from your account.</p>\n *\n * <ui-button color=\"text\" slot=\"button\" value=\"dismiss\" type=\"text\">Cancel</ui-button>\n * <ui-button color=\"text\" slot=\"button\" value=\"confirm\" type=\"text\">Confirm</ui-button>\n * </ui-dialog>\n * ```\n *\n * @slot - The slot for the content of the dialog.\n * @slot icon - The slot to place the dialog icon\n * @slot title - The slot to place the dialog title. Do not put elements here, just the text.\n * @slot button - The slot to place the dialog buttons. Use the `confirm` or `dismiss`\n * buttons to automatically close the dialog.\n * @fires close - A non-bubbling, non-cancellable event with the `UiDialogClosingReason` as the detail.\n */\nexport default class UiDialog extends UiElement implements TypedEvents<DialogEventMap> {\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n }\n\n /**\n * Opens the dialog as modal when toggling dialog's open state.\n *\n * Setting this value after the dialog was opened has no effect.\n *\n * @attribute\n */\n @property({ type: Boolean }) accessor modal = false\n\n /**\n * Toggles visibility of the dialog.\n * Note, the dialog is opened asynchronously after the update is performed.\n * @attribute\n */\n @property({ type: Boolean }) accessor open = false\n\n /**\n * Imperative access to create a dismiss button.\n * When set this will render a dismiss button at the end of the buttons line, before the `confirmLabel` button.\n * @attribute\n */\n @property({ type: String }) accessor dismissLabel: string | undefined\n\n /**\n * Imperative access to create a confirm button.\n * When set this will render a confirm button at the end of the buttons line, after the `dismissLabel` button.\n * @attribute\n */\n @property({ type: String }) accessor confirmLabel: string | undefined\n\n /**\n * When true, styles the confirm button with error colors to indicate\n * a destructive action (e.g., delete, remove, etc.).\n * @attribute\n */\n @property({ type: Boolean }) accessor destructive = false\n\n /**\n * Part of the imperative access to the element.\n * When set, it wraps the content in a `<form>` element.\n * When this is enabled the following will happen:\n * - The `confirm` button will get `type=\"submit\"`\n * - The form `method` attribute is set to `dialog`\n * - The form `id` attribute is set to a random string. You can get it from the `formId` getter.\n * - The dialog will dispatch the same `submit` event as the form.\n * - When the `submit` event dispatched by the dialog gets cancelled, then:\n * - The original submit event also gets cancelled.\n * - The default confirm action is not invoked\n * - The dialog stays opened\n * - When the submit event is not cancelled, then:\n * - The default confirm action is invoked.\n * - The dialog is closed.\n *\n * @deprecated Wrap the content in a `<form>` element instead.\n */\n @property({ type: Boolean }) accessor useForm: boolean | undefined\n\n /**\n * Only when `confirmLabel` is set.\n * Defines the value associated with the button's name when it's submitted with the form data.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#value}\n * @attribute\n */\n @property({ type: String }) accessor confirmValue: string | undefined\n /**\n * When the dialog is wrapped in a form, set this to `true` to close the dialog\n * when the form is submitted.\n *\n * Note that the dialog doesn't perform any validation of the form. It only closes\n * when the form is submitted, regardless of the application logic. The `submit` event\n * is dispatched by the dialog when the form is valid.\n */\n @property({ type: Boolean }) accessor submitClose: boolean | undefined\n\n /**\n * A reference to the underlying dialog element.\n */\n @query('dialog') accessor dialog!: HTMLDialogElement\n\n @state() protected accessor hasIcon = false\n\n @state() protected accessor hasTitle = false\n\n @state() protected accessor hasButton = false\n\n @queryAssignedElements({ flatten: true, slot: 'icon' }) protected accessor icons!: HTMLElement[]\n\n @queryAssignedNodes({ flatten: true, slot: 'title' }) protected accessor titles!: HTMLElement[]\n\n @queryAssignedElements({ flatten: true, slot: 'button' }) protected accessor buttons!: HTMLElement[]\n\n /**\n * To be set by a child class when closing the dialog.\n * This is passed to the close event.\n */\n dialogValue?: unknown\n\n #formId?: string\n\n /**\n * @deprecated Use `useForm` instead.\n */\n get formId(): string | undefined {\n return this.#formId\n }\n\n /**\n * @deprecated This will be removed in the future.\n */\n @state() accessor #inject: TemplateResult | RenderFunction | undefined\n\n /**\n * @deprecated This will be removed in the future.\n */\n #pendingStyles?: CSSResultOrNative[]\n\n /**\n * A reference to the parent form element.\n * When a form is found, the dialog will hook into the form's submit event\n * and close the dialog when the form is submitted.\n * Since the `submit` event is dispatched when the form is valid,\n * we can use this to close the dialog and not worry about the form validation.\n */\n #form: HTMLFormElement | null = null\n\n constructor() {\n super()\n\n this.addEventListener('click', this.handleClick)\n this.addEventListener('keydown', this.handleKeyDown)\n }\n\n /**\n * Allows to inject a template into the internals of the element.\n * This is helpful when working with imperative dialogs.\n * @param content The content to inject into the body.\n * @deprecated This will be removed in the future. To use forms, wrap the content in a `<form>` element.\n */\n inject(content?: TemplateResult | RenderFunction, styles?: CSSResultOrNative[]): void {\n this.#inject = content\n if (styles) {\n if (this.shadowRoot) {\n adoptStyles(this.shadowRoot, styles)\n } else {\n if (!this.#pendingStyles) {\n this.#pendingStyles = []\n }\n this.#pendingStyles.push(...styles)\n }\n }\n if (this.shadowRoot && styles) {\n adoptStyles(this.shadowRoot, styles)\n }\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.#form = this.closest('form')\n if (this.#form) {\n this.#form.addEventListener('submit', this.handleFormSubmit)\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n if (this.#form) {\n this.#form.removeEventListener('submit', this.handleFormSubmit)\n this.#form = null\n }\n }\n\n protected override firstUpdated(): void {\n const styles = this.#pendingStyles\n if (styles) {\n const root = this.shadowRoot as ShadowRoot\n const all = [...root.adoptedStyleSheets, ...styles]\n adoptStyles(this.shadowRoot as ShadowRoot, all)\n }\n }\n\n override willUpdate(cp: PropertyValues<this>): void {\n if (cp.has('useForm') && this.useForm && !this.#formId) {\n const r = (Math.random() + 1).toString(36).substring(7)\n this.#formId = `form-${r}`\n }\n }\n\n @bound\n protected handleFormSubmit(): void {\n if (this.submitClose) {\n this.handleInteraction('confirm')\n }\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n const path = e.composedPath()\n const { buttons } = this\n const button = path.find((i) => buttons.includes(i as HTMLElement)) as HTMLButtonElement | UiButton | undefined\n if (!button) {\n return\n }\n if (button.type === 'submit') {\n // Adds support for forms.\n // When a form's submit button is clicked we yield the flow control to the form.\n // This way the form can handle the submit event.\n return\n }\n const { value = '' } = button\n this.handleInteraction(value as 'dismiss' | 'confirm')\n }\n\n override handleKeyDown(e: KeyboardEvent): void {\n super.handleKeyDown(e)\n if (e.defaultPrevented) {\n return\n }\n if (e.key === 'Escape') {\n this.handleInteraction('dismiss')\n }\n }\n\n override updated(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('open')) {\n this.#controlVisibility()\n }\n super.updated(changedProperties)\n }\n\n #controlVisibility(): void {\n const { dialog, modal, open } = this\n if (!dialog) {\n return\n }\n if (open) {\n if (modal) {\n dialog.showModal()\n } else {\n dialog.show()\n }\n } else {\n dialog.close()\n }\n }\n\n #handleSlotChange(): void {\n const { icons, titles, buttons } = this\n this.hasIcon = !!icons && !!icons.length\n this.hasTitle = !!titles && !!titles.length\n this.hasButton = !!buttons && !!buttons.length\n }\n\n protected handleInteraction(value: 'dismiss' | 'confirm'): void {\n if (!['dismiss', 'confirm'].includes(value)) {\n return\n }\n this.open = false\n const detail: UiDialogClosingReason = {\n cancelled: value === 'dismiss',\n }\n if (this.dialogValue !== undefined) {\n detail.value = this.dialogValue\n }\n this.dispatchEvent(\n new CustomEvent<UiDialogClosingReason>('close', {\n composed: true,\n detail,\n })\n )\n }\n\n protected handleDialogClose(): void {\n if (!this.open) {\n return\n }\n this.open = false\n this.handleInteraction('dismiss')\n }\n\n protected handleDismiss(): void {\n this.handleInteraction('dismiss')\n }\n\n protected handleConfirm(): void {\n if (!this.useForm) {\n this.handleInteraction('confirm')\n }\n }\n\n #handleSubmit(event: SubmitEvent): void {\n const form = event.target as HTMLFormElement\n const copy = new SyntheticSubmitEvent(event.type, form, {\n submitter: event.submitter,\n cancelable: true,\n bubbles: false,\n composed: false,\n })\n const dispatched = this.dispatchEvent(copy)\n if (dispatched) {\n this.handleInteraction('confirm')\n } else {\n event.preventDefault()\n }\n }\n\n override render(): TemplateResult {\n const { useForm, modal } = this\n const dialogClass = modal ? 'modal' : 'non-modal'\n return html`\n <dialog @close=\"${this.handleDialogClose}\" part=\"dialog\" class=\"${dialogClass}\">\n <div class=\"container\">${useForm ? this.#renderFormContent() : this.renderContent()}</div>\n </dialog>\n `\n }\n\n protected renderContent(): TemplateResult[] | TemplateResult {\n return [this.renderIcon(), this.renderTitle(), this.renderBody(), this.renderButtons()]\n }\n\n #renderFormContent(): TemplateResult {\n return html`\n <form id=\"${ifDefined(this.formId)}\" method=\"dialog\" @submit=\"${this.#handleSubmit}\" part=\"form\">\n ${this.renderContent()}\n </form>\n `\n }\n\n protected renderIcon(): TemplateResult {\n const classes: ClassInfo = {\n 'icon': true,\n 'with-icon': this.hasIcon,\n 'destructive': this.destructive,\n }\n return html`\n <div class=\"${classMap(classes)}\" part=\"icon\">\n <slot name=\"icon\" @slotchange=\"${this.#handleSlotChange}\"></slot>\n </div>\n `\n }\n\n protected renderTitle(): TemplateResult {\n const classes: ClassInfo = {\n 'title': true,\n 'with-title': this.hasTitle,\n }\n return html`\n <div class=\"${classMap(classes)}\" part=\"title\">\n <slot name=\"title\" @slotchange=\"${this.#handleSlotChange}\"></slot>\n </div>\n `\n }\n\n protected renderBody(): TemplateResult {\n let content = this.#inject\n if (typeof content === 'function') {\n content = content()\n }\n const injected = content || nothing\n return html` <div class=\"content\" part=\"body\"><slot></slot>${injected}</div> `\n }\n\n protected renderButtons(): TemplateResult {\n const classes: ClassInfo = {\n 'buttons': true,\n 'with-buttons': this.hasButton || !!this.confirmLabel || !!this.dismissLabel,\n }\n return html`\n <div class=\"${classMap(classes)}\" part=\"button\">\n <slot name=\"button\" @slotchange=\"${this.#handleSlotChange}\"></slot>\n ${this.#renderDismissButton()} ${this.#renderConfirmButton()}\n </div>\n `\n }\n\n #renderDismissButton(): TemplateResult | typeof nothing {\n const { dismissLabel } = this\n if (!dismissLabel) {\n return nothing\n }\n return html`\n <ui-button\n color=\"text\"\n value=\"dismiss\"\n class=\"internal-button\"\n @click=\"${this.handleDismiss}\"\n part=\"negative-action\"\n >${dismissLabel}</ui-button\n >\n `\n }\n\n #renderConfirmButton(): TemplateResult | typeof nothing {\n const { confirmLabel, confirmValue = 'confirm', useForm, destructive } = this\n if (!confirmLabel) {\n return nothing\n }\n const type = useForm ? 'submit' : 'button'\n const buttonClass = destructive ? 'internal-button destructive' : 'internal-button'\n return html`\n <ui-button\n color=\"text\"\n type=\"${type}\"\n value=\"${confirmValue}\"\n class=\"${buttonClass}\"\n @click=\"${this.handleConfirm}\"\n part=\"positive-action\"\n >${confirmLabel}</ui-button\n >\n `\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.styles.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"Dialog.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.styles.ts"],"names":[],"mappings":";AAEA,wBAgKC"}
|
|
@@ -27,6 +27,20 @@ export default css `
|
|
|
27
27
|
flex-direction: column;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/* Positioning for non-modal dialogs */
|
|
31
|
+
dialog.non-modal {
|
|
32
|
+
position: fixed;
|
|
33
|
+
top: 50%;
|
|
34
|
+
left: 50%;
|
|
35
|
+
transform: translate(-50%, -50%);
|
|
36
|
+
margin: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
dialog.non-modal:open {
|
|
40
|
+
/* Override the animation transform for non-modal dialogs to account for centering */
|
|
41
|
+
animation: 250ms cubic-bezier(0.2, 0, 0, 1) show-non-modal-dialog;
|
|
42
|
+
}
|
|
43
|
+
|
|
30
44
|
dialog:open::backdrop {
|
|
31
45
|
animation: 250ms cubic-bezier(0.2, 0, 0, 1) show-backdrop;
|
|
32
46
|
}
|
|
@@ -34,7 +48,6 @@ export default css `
|
|
|
34
48
|
.container {
|
|
35
49
|
display: flex;
|
|
36
50
|
flex-direction: column;
|
|
37
|
-
overflow: hidden;
|
|
38
51
|
flex: 1;
|
|
39
52
|
}
|
|
40
53
|
|
|
@@ -56,6 +69,11 @@ export default css `
|
|
|
56
69
|
height: 24px;
|
|
57
70
|
}
|
|
58
71
|
|
|
72
|
+
.icon.destructive ::slotted(*) {
|
|
73
|
+
color: var(--md-sys-color-error);
|
|
74
|
+
fill: var(--md-sys-color-error);
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
.title {
|
|
60
78
|
display: none;
|
|
61
79
|
color: var(--md-sys-color-on-surface);
|
|
@@ -113,6 +131,15 @@ export default css `
|
|
|
113
131
|
}
|
|
114
132
|
}
|
|
115
133
|
|
|
134
|
+
@keyframes show-non-modal-dialog {
|
|
135
|
+
from {
|
|
136
|
+
transform: translate(-50%, -50%) translateY(-110%) scaleY(0);
|
|
137
|
+
}
|
|
138
|
+
to {
|
|
139
|
+
transform: translate(-50%, -50%) translateY(0%) scaleY(1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
116
143
|
@keyframes show-backdrop {
|
|
117
144
|
from {
|
|
118
145
|
opacity: 0;
|
|
@@ -121,5 +148,16 @@ export default css `
|
|
|
121
148
|
opacity: 1;
|
|
122
149
|
}
|
|
123
150
|
}
|
|
151
|
+
|
|
152
|
+
/* Destructive button styling for dangerous actions */
|
|
153
|
+
.internal-button.destructive {
|
|
154
|
+
--_background-color: var(--md-sys-color-error);
|
|
155
|
+
--_color: var(--md-sys-color-on-error);
|
|
156
|
+
|
|
157
|
+
/* Override ripple colors for better interaction feedback */
|
|
158
|
+
--md-ripple-hover-state-layer-color: var(--md-sys-color-on-error);
|
|
159
|
+
--md-ripple-focus-state-layer-color: var(--md-sys-color-on-error);
|
|
160
|
+
--md-ripple-pressed-state-layer-color: var(--md-sys-color-on-error);
|
|
161
|
+
}
|
|
124
162
|
`;
|
|
125
163
|
//# sourceMappingURL=Dialog.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.styles.js","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"Dialog.styles.js","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgKjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n display: contents;\n }\n\n dialog {\n overflow: hidden;\n /* Do not override the display value here. It will render the dialog even when hidden */\n\n border: none;\n border-radius: var(--md-sys-shape-corner-extra-large);\n background-color: var(--md-sys-color-surface-container-high);\n box-shadow: var(--md-sys-elevation-3);\n color: var(--md-sys-color-on-surface-variant);\n padding: 24px;\n\n max-width: var(--ui-dialog-max-width, 90vw);\n max-height: var(--ui-dialog-max-height, 90vh);\n width: var(--ui-dialog-width, revert);\n height: var(--ui-dialog-height, revert);\n }\n\n dialog:open {\n animation: 250ms cubic-bezier(0.2, 0, 0, 1) show-dialog;\n display: flex;\n flex-direction: column;\n }\n\n /* Positioning for non-modal dialogs */\n dialog.non-modal {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n }\n\n dialog.non-modal:open {\n /* Override the animation transform for non-modal dialogs to account for centering */\n animation: 250ms cubic-bezier(0.2, 0, 0, 1) show-non-modal-dialog;\n }\n\n dialog:open::backdrop {\n animation: 250ms cubic-bezier(0.2, 0, 0, 1) show-backdrop;\n }\n\n .container {\n display: flex;\n flex-direction: column;\n flex: 1;\n }\n\n .icon {\n display: none;\n }\n\n .icon.with-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-bottom: 16px;\n }\n\n .icon ::slotted(*) {\n color: var(--md-sys-color-secondary);\n fill: var(--md-sys-color-secondary);\n width: 24px;\n height: 24px;\n }\n\n .icon.destructive ::slotted(*) {\n color: var(--md-sys-color-error);\n fill: var(--md-sys-color-error);\n }\n\n .title {\n display: none;\n color: var(--md-sys-color-on-surface);\n font-family: var(--md-sys-typescale-headline-small-font);\n font-weight: var(--md-sys-typescale-headline-small-weight);\n font-size: var(--md-sys-typescale-headline-small-size);\n letter-spacing: var(--md-sys-typescale-headline-small-tracking);\n line-height: var(--md-sys-typescale-headline-small-height);\n margin: 0;\n padding: 0;\n text-align: center;\n }\n\n .title.with-title {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-bottom: 16px;\n }\n\n .content {\n overflow: auto;\n font-family: var(--md-sys-typescale-body-medium-font);\n font-weight: var(--md-sys-typescale-body-medium-weight);\n font-size: var(--md-sys-typescale-body-medium-size);\n letter-spacing: var(--md-sys-typescale-body-medium-tracking);\n line-height: var(--md-sys-typescale-body-medium-height);\n }\n\n .buttons {\n display: none;\n display: flex;\n align-items: center;\n justify-content: end;\n }\n\n .buttons.with-buttons {\n margin-top: 24px;\n }\n\n .buttons ::slotted(:not(:last-child)) {\n margin-right: 12px;\n }\n\n .content ::slotted(*) {\n background-color: var(--md-sys-color-surface-container-high);\n }\n\n @keyframes show-dialog {\n from {\n transform: translateY(-110%) scaleY(0);\n }\n to {\n transform: translateY(0%) scaleY(1);\n }\n }\n\n @keyframes show-non-modal-dialog {\n from {\n transform: translate(-50%, -50%) translateY(-110%) scaleY(0);\n }\n to {\n transform: translate(-50%, -50%) translateY(0%) scaleY(1);\n }\n }\n\n @keyframes show-backdrop {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n\n /* Destructive button styling for dangerous actions */\n .internal-button.destructive {\n --_background-color: var(--md-sys-color-error);\n --_color: var(--md-sys-color-on-error);\n\n /* Override ripple colors for better interaction feedback */\n --md-ripple-hover-state-layer-color: var(--md-sys-color-on-error);\n --md-ripple-focus-state-layer-color: var(--md-sys-color-on-error);\n --md-ripple-pressed-state-layer-color: var(--md-sys-color-on-error);\n }\n`\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CSSResultOrNative } from 'lit';
|
|
2
|
+
import Element from './internals/ConfirmDialog.js';
|
|
3
|
+
/**
|
|
4
|
+
* A simple Material Design 3 styled confirm dialog component.
|
|
5
|
+
*
|
|
6
|
+
* This dialog is designed specifically for confirmation workflows where users
|
|
7
|
+
* need to confirm or dismiss an action. It provides a clean, accessible interface
|
|
8
|
+
* with customizable button labels and content.
|
|
9
|
+
*
|
|
10
|
+
* **Features:**
|
|
11
|
+
* - Material Design 3 styling
|
|
12
|
+
* - Customizable confirm and dismiss button labels
|
|
13
|
+
* - Modal by default
|
|
14
|
+
* - Accessible keyboard navigation
|
|
15
|
+
* - Slot-based content structure
|
|
16
|
+
*
|
|
17
|
+
* **Usage:**
|
|
18
|
+
* ```html
|
|
19
|
+
* <ui-confirm-dialog .open="${showDialog}" @close="${handleClose}">
|
|
20
|
+
* <span slot="title">Confirm Action</span>
|
|
21
|
+
* <p>Are you sure you want to proceed with this action?</p>
|
|
22
|
+
* </ui-confirm-dialog>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* **Customizing Button Labels:**
|
|
26
|
+
* ```html
|
|
27
|
+
* <ui-confirm-dialog
|
|
28
|
+
* confirmLabel="Delete"
|
|
29
|
+
* dismissLabel="Keep"
|
|
30
|
+
* .open="${showDialog}"
|
|
31
|
+
* >
|
|
32
|
+
* <span slot="title">Delete Item</span>
|
|
33
|
+
* <p>This action cannot be undone.</p>
|
|
34
|
+
* </ui-confirm-dialog>
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @slot title - The dialog title
|
|
38
|
+
* @slot - The main content body
|
|
39
|
+
*/
|
|
40
|
+
export declare class UiConfirmDialogElement extends Element {
|
|
41
|
+
static styles: CSSResultOrNative[];
|
|
42
|
+
}
|
|
43
|
+
declare global {
|
|
44
|
+
interface HTMLElementTagNameMap {
|
|
45
|
+
'ui-confirm-dialog': UiConfirmDialogElement;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ui-confirm-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-confirm-dialog.d.ts","sourceRoot":"","sources":["../../../../src/md/dialog/ui-confirm-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE5C,OAAO,OAAO,MAAM,8BAA8B,CAAA;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBACa,sBAAuB,SAAQ,OAAO;IACjD,OAAgB,MAAM,EAAE,iBAAiB,EAAE,CAAiB;CAC7D;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,sBAAsB,CAAA;KAC5C;CACF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
import Element from './internals/ConfirmDialog.js';
|
|
4
|
+
import dialogStyles from './internals/Dialog.styles.js';
|
|
5
|
+
/**
|
|
6
|
+
* A simple Material Design 3 styled confirm dialog component.
|
|
7
|
+
*
|
|
8
|
+
* This dialog is designed specifically for confirmation workflows where users
|
|
9
|
+
* need to confirm or dismiss an action. It provides a clean, accessible interface
|
|
10
|
+
* with customizable button labels and content.
|
|
11
|
+
*
|
|
12
|
+
* **Features:**
|
|
13
|
+
* - Material Design 3 styling
|
|
14
|
+
* - Customizable confirm and dismiss button labels
|
|
15
|
+
* - Modal by default
|
|
16
|
+
* - Accessible keyboard navigation
|
|
17
|
+
* - Slot-based content structure
|
|
18
|
+
*
|
|
19
|
+
* **Usage:**
|
|
20
|
+
* ```html
|
|
21
|
+
* <ui-confirm-dialog .open="${showDialog}" @close="${handleClose}">
|
|
22
|
+
* <span slot="title">Confirm Action</span>
|
|
23
|
+
* <p>Are you sure you want to proceed with this action?</p>
|
|
24
|
+
* </ui-confirm-dialog>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* **Customizing Button Labels:**
|
|
28
|
+
* ```html
|
|
29
|
+
* <ui-confirm-dialog
|
|
30
|
+
* confirmLabel="Delete"
|
|
31
|
+
* dismissLabel="Keep"
|
|
32
|
+
* .open="${showDialog}"
|
|
33
|
+
* >
|
|
34
|
+
* <span slot="title">Delete Item</span>
|
|
35
|
+
* <p>This action cannot be undone.</p>
|
|
36
|
+
* </ui-confirm-dialog>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @slot title - The dialog title
|
|
40
|
+
* @slot - The main content body
|
|
41
|
+
*/
|
|
42
|
+
let UiConfirmDialogElement = (() => {
|
|
43
|
+
let _classDecorators = [customElement('ui-confirm-dialog')];
|
|
44
|
+
let _classDescriptor;
|
|
45
|
+
let _classExtraInitializers = [];
|
|
46
|
+
let _classThis;
|
|
47
|
+
let _classSuper = Element;
|
|
48
|
+
var UiConfirmDialogElement = class extends _classSuper {
|
|
49
|
+
static { _classThis = this; }
|
|
50
|
+
static {
|
|
51
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
52
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
53
|
+
UiConfirmDialogElement = _classThis = _classDescriptor.value;
|
|
54
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
55
|
+
}
|
|
56
|
+
static styles = [dialogStyles];
|
|
57
|
+
static {
|
|
58
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return UiConfirmDialogElement = _classThis;
|
|
62
|
+
})();
|
|
63
|
+
export { UiConfirmDialogElement };
|
|
64
|
+
//# sourceMappingURL=ui-confirm-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-confirm-dialog.js","sourceRoot":"","sources":["../../../../src/md/dialog/ui-confirm-dialog.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,OAAO,MAAM,8BAA8B,CAAA;AAClD,OAAO,YAAY,MAAM,8BAA8B,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;IAEU,sBAAsB;4BADlC,aAAa,CAAC,mBAAmB,CAAC;;;;sBACS,OAAO;sCAAf,SAAQ,WAAO;;;;YAAnD,6KAEC;;;;QADC,MAAM,CAAU,MAAM,GAAwB,CAAC,YAAY,CAAC,CAAA;;YADjD,uDAAsB;;;;;SAAtB,sBAAsB","sourcesContent":["import type { CSSResultOrNative } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport Element from './internals/ConfirmDialog.js'\nimport dialogStyles from './internals/Dialog.styles.js'\n\n/**\n * A simple Material Design 3 styled confirm dialog component.\n *\n * This dialog is designed specifically for confirmation workflows where users\n * need to confirm or dismiss an action. It provides a clean, accessible interface\n * with customizable button labels and content.\n *\n * **Features:**\n * - Material Design 3 styling\n * - Customizable confirm and dismiss button labels\n * - Modal by default\n * - Accessible keyboard navigation\n * - Slot-based content structure\n *\n * **Usage:**\n * ```html\n * <ui-confirm-dialog .open=\"${showDialog}\" @close=\"${handleClose}\">\n * <span slot=\"title\">Confirm Action</span>\n * <p>Are you sure you want to proceed with this action?</p>\n * </ui-confirm-dialog>\n * ```\n *\n * **Customizing Button Labels:**\n * ```html\n * <ui-confirm-dialog\n * confirmLabel=\"Delete\"\n * dismissLabel=\"Keep\"\n * .open=\"${showDialog}\"\n * >\n * <span slot=\"title\">Delete Item</span>\n * <p>This action cannot be undone.</p>\n * </ui-confirm-dialog>\n * ```\n *\n * @slot title - The dialog title\n * @slot - The main content body\n */\n@customElement('ui-confirm-dialog')\nexport class UiConfirmDialogElement extends Element {\n static override styles: CSSResultOrNative[] = [dialogStyles]\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ui-confirm-dialog': UiConfirmDialogElement\n }\n}\n"]}
|