@api-client/ui 0.5.19 → 0.5.21
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/elements/code-editor/internals/CodeEditor.d.ts +4 -8
- package/build/src/elements/code-editor/internals/CodeEditor.d.ts.map +1 -1
- package/build/src/elements/code-editor/internals/CodeEditor.js +13 -33
- package/build/src/elements/code-editor/internals/CodeEditor.js.map +1 -1
- package/build/src/md/dialog/internals/Dialog.d.ts +13 -35
- package/build/src/md/dialog/internals/Dialog.d.ts.map +1 -1
- package/build/src/md/dialog/internals/Dialog.js +32 -146
- package/build/src/md/dialog/internals/Dialog.js.map +1 -1
- package/demo/elements/code-editor/CodeEditorDemo.ts +7 -21
- package/package.json +1 -2
- package/src/elements/code-editor/README.md +9 -6
- package/src/elements/code-editor/internals/CodeEditor.ts +9 -21
- package/src/md/dialog/internals/Dialog.ts +20 -120
- package/test/elements/code-editor/code-editor.accessibility.test.ts +2 -29
- package/test/elements/code-editor/code-editor.test.ts +10 -13
- package/build/src/events/SyntheticSubmitEvent.d.ts +0 -9
- package/build/src/events/SyntheticSubmitEvent.d.ts.map +0 -1
- package/build/src/events/SyntheticSubmitEvent.js +0 -22
- package/build/src/events/SyntheticSubmitEvent.js.map +0 -1
- package/src/events/SyntheticSubmitEvent.ts +0 -27
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { __esDecorate, __runInitializers
|
|
2
|
-
import { html, nothing
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
3
|
import { property, query, queryAssignedElements, queryAssignedNodes, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { UiElement } from '../../UiElement.js';
|
|
6
6
|
import { isDisabled, setDisabled } from '../../../lib/disabled.js';
|
|
7
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
8
|
-
import { SyntheticSubmitEvent } from '../../../events/SyntheticSubmitEvent.js';
|
|
9
7
|
import '../../button/ui-button.js';
|
|
10
8
|
import { bound } from '../../../decorators/bound.js';
|
|
11
9
|
let UiDialog = (() => {
|
|
@@ -27,12 +25,12 @@ let UiDialog = (() => {
|
|
|
27
25
|
let _destructive_decorators;
|
|
28
26
|
let _destructive_initializers = [];
|
|
29
27
|
let _destructive_extraInitializers = [];
|
|
30
|
-
let _useForm_decorators;
|
|
31
|
-
let _useForm_initializers = [];
|
|
32
|
-
let _useForm_extraInitializers = [];
|
|
33
28
|
let _confirmValue_decorators;
|
|
34
29
|
let _confirmValue_initializers = [];
|
|
35
30
|
let _confirmValue_extraInitializers = [];
|
|
31
|
+
let _confirmType_decorators;
|
|
32
|
+
let _confirmType_initializers = [];
|
|
33
|
+
let _confirmType_extraInitializers = [];
|
|
36
34
|
let _submitClose_decorators;
|
|
37
35
|
let _submitClose_initializers = [];
|
|
38
36
|
let _submitClose_extraInitializers = [];
|
|
@@ -57,10 +55,6 @@ let UiDialog = (() => {
|
|
|
57
55
|
let _buttons_decorators;
|
|
58
56
|
let _buttons_initializers = [];
|
|
59
57
|
let _buttons_extraInitializers = [];
|
|
60
|
-
let _private_inject_decorators;
|
|
61
|
-
let _private_inject_initializers = [];
|
|
62
|
-
let _private_inject_extraInitializers = [];
|
|
63
|
-
let _private_inject_descriptor;
|
|
64
58
|
let _handleFormSubmit_decorators;
|
|
65
59
|
return class UiDialog extends _classSuper {
|
|
66
60
|
static {
|
|
@@ -71,8 +65,8 @@ let UiDialog = (() => {
|
|
|
71
65
|
_dismissLabel_decorators = [property({ type: String })];
|
|
72
66
|
_confirmLabel_decorators = [property({ type: String })];
|
|
73
67
|
_destructive_decorators = [property({ type: Boolean })];
|
|
74
|
-
_useForm_decorators = [property({ type: Boolean })];
|
|
75
68
|
_confirmValue_decorators = [property({ type: String })];
|
|
69
|
+
_confirmType_decorators = [property({ type: String })];
|
|
76
70
|
_submitClose_decorators = [property({ type: Boolean })];
|
|
77
71
|
_dialog_decorators = [query('dialog')];
|
|
78
72
|
_hasIcon_decorators = [state()];
|
|
@@ -81,7 +75,6 @@ let UiDialog = (() => {
|
|
|
81
75
|
_icons_decorators = [queryAssignedElements({ flatten: true, slot: 'icon' })];
|
|
82
76
|
_titles_decorators = [queryAssignedNodes({ flatten: true, slot: 'title' })];
|
|
83
77
|
_buttons_decorators = [queryAssignedElements({ flatten: true, slot: 'button' })];
|
|
84
|
-
_private_inject_decorators = [state()];
|
|
85
78
|
_handleFormSubmit_decorators = [bound];
|
|
86
79
|
__esDecorate(this, null, _set_disabled_decorators, { kind: "setter", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
87
80
|
__esDecorate(this, null, _modal_decorators, { kind: "accessor", name: "modal", static: false, private: false, access: { has: obj => "modal" in obj, get: obj => obj.modal, set: (obj, value) => { obj.modal = value; } }, metadata: _metadata }, _modal_initializers, _modal_extraInitializers);
|
|
@@ -89,8 +82,8 @@ let UiDialog = (() => {
|
|
|
89
82
|
__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);
|
|
90
83
|
__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
84
|
__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);
|
|
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);
|
|
93
85
|
__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);
|
|
86
|
+
__esDecorate(this, null, _confirmType_decorators, { kind: "accessor", name: "confirmType", static: false, private: false, access: { has: obj => "confirmType" in obj, get: obj => obj.confirmType, set: (obj, value) => { obj.confirmType = value; } }, metadata: _metadata }, _confirmType_initializers, _confirmType_extraInitializers);
|
|
94
87
|
__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);
|
|
95
88
|
__esDecorate(this, null, _dialog_decorators, { kind: "accessor", name: "dialog", static: false, private: false, access: { has: obj => "dialog" in obj, get: obj => obj.dialog, set: (obj, value) => { obj.dialog = value; } }, metadata: _metadata }, _dialog_initializers, _dialog_extraInitializers);
|
|
96
89
|
__esDecorate(this, null, _hasIcon_decorators, { kind: "accessor", name: "hasIcon", static: false, private: false, access: { has: obj => "hasIcon" in obj, get: obj => obj.hasIcon, set: (obj, value) => { obj.hasIcon = value; } }, metadata: _metadata }, _hasIcon_initializers, _hasIcon_extraInitializers);
|
|
@@ -99,7 +92,6 @@ let UiDialog = (() => {
|
|
|
99
92
|
__esDecorate(this, null, _icons_decorators, { kind: "accessor", name: "icons", static: false, private: false, access: { has: obj => "icons" in obj, get: obj => obj.icons, set: (obj, value) => { obj.icons = value; } }, metadata: _metadata }, _icons_initializers, _icons_extraInitializers);
|
|
100
93
|
__esDecorate(this, null, _titles_decorators, { kind: "accessor", name: "titles", static: false, private: false, access: { has: obj => "titles" in obj, get: obj => obj.titles, set: (obj, value) => { obj.titles = value; } }, metadata: _metadata }, _titles_initializers, _titles_extraInitializers);
|
|
101
94
|
__esDecorate(this, null, _buttons_decorators, { kind: "accessor", name: "buttons", static: false, private: false, access: { has: obj => "buttons" in obj, get: obj => obj.buttons, set: (obj, value) => { obj.buttons = value; } }, metadata: _metadata }, _buttons_initializers, _buttons_extraInitializers);
|
|
102
|
-
__esDecorate(this, _private_inject_descriptor = { get: __setFunctionName(function () { return this.#inject_accessor_storage; }, "#inject", "get"), set: __setFunctionName(function (value) { this.#inject_accessor_storage = value; }, "#inject", "set") }, _private_inject_decorators, { kind: "accessor", name: "#inject", static: false, private: true, access: { has: obj => #inject in obj, get: obj => obj.#inject, set: (obj, value) => { obj.#inject = value; } }, metadata: _metadata }, _private_inject_initializers, _private_inject_extraInitializers);
|
|
103
95
|
__esDecorate(this, null, _handleFormSubmit_decorators, { kind: "method", name: "handleFormSubmit", static: false, private: false, access: { has: obj => "handleFormSubmit" in obj, get: obj => obj.handleFormSubmit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
104
96
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
105
97
|
}
|
|
@@ -163,22 +155,10 @@ let UiDialog = (() => {
|
|
|
163
155
|
set confirmLabel(value) { this.#confirmLabel_accessor_storage = value; }
|
|
164
156
|
#destructive_accessor_storage = (__runInitializers(this, _confirmLabel_extraInitializers), __runInitializers(this, _destructive_initializers, false
|
|
165
157
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
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.
|
|
158
|
+
* Only when `confirmLabel` is set.
|
|
159
|
+
* Defines the value associated with the button's name when it's submitted with the form data.
|
|
160
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#value}
|
|
161
|
+
* @attribute
|
|
182
162
|
*/
|
|
183
163
|
));
|
|
184
164
|
/**
|
|
@@ -188,28 +168,7 @@ let UiDialog = (() => {
|
|
|
188
168
|
*/
|
|
189
169
|
get destructive() { return this.#destructive_accessor_storage; }
|
|
190
170
|
set destructive(value) { this.#destructive_accessor_storage = value; }
|
|
191
|
-
#
|
|
192
|
-
/**
|
|
193
|
-
* Part of the imperative access to the element.
|
|
194
|
-
* When set, it wraps the content in a `<form>` element.
|
|
195
|
-
* When this is enabled the following will happen:
|
|
196
|
-
* - The `confirm` button will get `type="submit"`
|
|
197
|
-
* - The form `method` attribute is set to `dialog`
|
|
198
|
-
* - The form `id` attribute is set to a random string. You can get it from the `formId` getter.
|
|
199
|
-
* - The dialog will dispatch the same `submit` event as the form.
|
|
200
|
-
* - When the `submit` event dispatched by the dialog gets cancelled, then:
|
|
201
|
-
* - The original submit event also gets cancelled.
|
|
202
|
-
* - The default confirm action is not invoked
|
|
203
|
-
* - The dialog stays opened
|
|
204
|
-
* - When the submit event is not cancelled, then:
|
|
205
|
-
* - The default confirm action is invoked.
|
|
206
|
-
* - The dialog is closed.
|
|
207
|
-
*
|
|
208
|
-
* @deprecated Wrap the content in a `<form>` element instead.
|
|
209
|
-
*/
|
|
210
|
-
get useForm() { return this.#useForm_accessor_storage; }
|
|
211
|
-
set useForm(value) { this.#useForm_accessor_storage = value; }
|
|
212
|
-
#confirmValue_accessor_storage = (__runInitializers(this, _useForm_extraInitializers), __runInitializers(this, _confirmValue_initializers, void 0));
|
|
171
|
+
#confirmValue_accessor_storage = (__runInitializers(this, _destructive_extraInitializers), __runInitializers(this, _confirmValue_initializers, void 0));
|
|
213
172
|
/**
|
|
214
173
|
* Only when `confirmLabel` is set.
|
|
215
174
|
* Defines the value associated with the button's name when it's submitted with the form data.
|
|
@@ -218,7 +177,17 @@ let UiDialog = (() => {
|
|
|
218
177
|
*/
|
|
219
178
|
get confirmValue() { return this.#confirmValue_accessor_storage; }
|
|
220
179
|
set confirmValue(value) { this.#confirmValue_accessor_storage = value; }
|
|
221
|
-
#
|
|
180
|
+
#confirmType_accessor_storage = (__runInitializers(this, _confirmValue_extraInitializers), __runInitializers(this, _confirmType_initializers, void 0));
|
|
181
|
+
/**
|
|
182
|
+
* The type of the confirm button.
|
|
183
|
+
* This is used to set the button's `type` attribute.
|
|
184
|
+
* If not set, the default is `button`.
|
|
185
|
+
* If set to `submit`, the dialog will trigger the form submission on the parent form.
|
|
186
|
+
* @attribute
|
|
187
|
+
*/
|
|
188
|
+
get confirmType() { return this.#confirmType_accessor_storage; }
|
|
189
|
+
set confirmType(value) { this.#confirmType_accessor_storage = value; }
|
|
190
|
+
#submitClose_accessor_storage = (__runInitializers(this, _confirmType_extraInitializers), __runInitializers(this, _submitClose_initializers, void 0));
|
|
222
191
|
/**
|
|
223
192
|
* When the dialog is wrapped in a form, set this to `true` to close the dialog
|
|
224
193
|
* when the form is submitted.
|
|
@@ -226,6 +195,7 @@ let UiDialog = (() => {
|
|
|
226
195
|
* Note that the dialog doesn't perform any validation of the form. It only closes
|
|
227
196
|
* when the form is submitted, regardless of the application logic. The `submit` event
|
|
228
197
|
* is dispatched by the dialog when the form is valid.
|
|
198
|
+
* @attribute
|
|
229
199
|
*/
|
|
230
200
|
get submitClose() { return this.#submitClose_accessor_storage; }
|
|
231
201
|
set submitClose(value) { this.#submitClose_accessor_storage = value; }
|
|
@@ -258,23 +228,6 @@ let UiDialog = (() => {
|
|
|
258
228
|
* This is passed to the close event.
|
|
259
229
|
*/
|
|
260
230
|
dialogValue = __runInitializers(this, _buttons_extraInitializers);
|
|
261
|
-
#formId;
|
|
262
|
-
/**
|
|
263
|
-
* @deprecated Use `useForm` instead.
|
|
264
|
-
*/
|
|
265
|
-
get formId() {
|
|
266
|
-
return this.#formId;
|
|
267
|
-
}
|
|
268
|
-
#inject_accessor_storage = __runInitializers(this, _private_inject_initializers, void 0);
|
|
269
|
-
/**
|
|
270
|
-
* @deprecated This will be removed in the future.
|
|
271
|
-
*/
|
|
272
|
-
get #inject() { return _private_inject_descriptor.get.call(this); }
|
|
273
|
-
set #inject(value) { return _private_inject_descriptor.set.call(this, value); }
|
|
274
|
-
/**
|
|
275
|
-
* @deprecated This will be removed in the future.
|
|
276
|
-
*/
|
|
277
|
-
#pendingStyles = __runInitializers(this, _private_inject_extraInitializers);
|
|
278
231
|
/**
|
|
279
232
|
* A reference to the parent form element.
|
|
280
233
|
* When a form is found, the dialog will hook into the form's submit event
|
|
@@ -288,29 +241,6 @@ let UiDialog = (() => {
|
|
|
288
241
|
this.addEventListener('click', this.handleClick);
|
|
289
242
|
this.addEventListener('keydown', this.handleKeyDown);
|
|
290
243
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Allows to inject a template into the internals of the element.
|
|
293
|
-
* This is helpful when working with imperative dialogs.
|
|
294
|
-
* @param content The content to inject into the body.
|
|
295
|
-
* @deprecated This will be removed in the future. To use forms, wrap the content in a `<form>` element.
|
|
296
|
-
*/
|
|
297
|
-
inject(content, styles) {
|
|
298
|
-
this.#inject = content;
|
|
299
|
-
if (styles) {
|
|
300
|
-
if (this.shadowRoot) {
|
|
301
|
-
adoptStyles(this.shadowRoot, styles);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
if (!this.#pendingStyles) {
|
|
305
|
-
this.#pendingStyles = [];
|
|
306
|
-
}
|
|
307
|
-
this.#pendingStyles.push(...styles);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
if (this.shadowRoot && styles) {
|
|
311
|
-
adoptStyles(this.shadowRoot, styles);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
244
|
connectedCallback() {
|
|
315
245
|
super.connectedCallback();
|
|
316
246
|
this.#form = this.closest('form');
|
|
@@ -325,20 +255,6 @@ let UiDialog = (() => {
|
|
|
325
255
|
this.#form = null;
|
|
326
256
|
}
|
|
327
257
|
}
|
|
328
|
-
firstUpdated() {
|
|
329
|
-
const styles = this.#pendingStyles;
|
|
330
|
-
if (styles) {
|
|
331
|
-
const root = this.shadowRoot;
|
|
332
|
-
const all = [...root.adoptedStyleSheets, ...styles];
|
|
333
|
-
adoptStyles(this.shadowRoot, all);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
willUpdate(cp) {
|
|
337
|
-
if (cp.has('useForm') && this.useForm && !this.#formId) {
|
|
338
|
-
const r = (Math.random() + 1).toString(36).substring(7);
|
|
339
|
-
this.#formId = `form-${r}`;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
258
|
handleFormSubmit() {
|
|
343
259
|
if (this.submitClose) {
|
|
344
260
|
this.handleInteraction('confirm');
|
|
@@ -461,45 +377,20 @@ let UiDialog = (() => {
|
|
|
461
377
|
this.handleInteraction('dismiss');
|
|
462
378
|
}
|
|
463
379
|
handleConfirm() {
|
|
464
|
-
|
|
465
|
-
this.handleInteraction('confirm');
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
#handleSubmit(event) {
|
|
469
|
-
const form = event.target;
|
|
470
|
-
const copy = new SyntheticSubmitEvent(event.type, form, {
|
|
471
|
-
submitter: event.submitter,
|
|
472
|
-
cancelable: true,
|
|
473
|
-
bubbles: false,
|
|
474
|
-
composed: false,
|
|
475
|
-
});
|
|
476
|
-
const dispatched = this.dispatchEvent(copy);
|
|
477
|
-
if (dispatched) {
|
|
478
|
-
this.handleInteraction('confirm');
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
event.preventDefault();
|
|
482
|
-
}
|
|
380
|
+
this.handleInteraction('confirm');
|
|
483
381
|
}
|
|
484
382
|
render() {
|
|
485
|
-
const {
|
|
383
|
+
const { modal } = this;
|
|
486
384
|
const dialogClass = modal ? 'modal' : 'non-modal';
|
|
487
385
|
return html `
|
|
488
386
|
<dialog @close="${this.handleDialogClose}" part="dialog" class="${dialogClass}">
|
|
489
|
-
<div class="container">${
|
|
387
|
+
<div class="container">${this.renderContent()}</div>
|
|
490
388
|
</dialog>
|
|
491
389
|
`;
|
|
492
390
|
}
|
|
493
391
|
renderContent() {
|
|
494
392
|
return [this.renderIcon(), this.renderTitle(), this.renderBody(), this.renderButtons()];
|
|
495
393
|
}
|
|
496
|
-
#renderFormContent() {
|
|
497
|
-
return html `
|
|
498
|
-
<form id="${ifDefined(this.formId)}" method="dialog" @submit="${this.#handleSubmit}" part="form">
|
|
499
|
-
${this.renderContent()}
|
|
500
|
-
</form>
|
|
501
|
-
`;
|
|
502
|
-
}
|
|
503
394
|
renderIcon() {
|
|
504
395
|
const classes = {
|
|
505
396
|
'icon': true,
|
|
@@ -524,12 +415,7 @@ let UiDialog = (() => {
|
|
|
524
415
|
`;
|
|
525
416
|
}
|
|
526
417
|
renderBody() {
|
|
527
|
-
|
|
528
|
-
if (typeof content === 'function') {
|
|
529
|
-
content = content();
|
|
530
|
-
}
|
|
531
|
-
const injected = content || nothing;
|
|
532
|
-
return html ` <div class="content" part="body"><slot></slot>${injected}</div> `;
|
|
418
|
+
return html ` <div class="content" part="body"><slot></slot></div> `;
|
|
533
419
|
}
|
|
534
420
|
renderButtons() {
|
|
535
421
|
const classes = {
|
|
@@ -560,11 +446,11 @@ let UiDialog = (() => {
|
|
|
560
446
|
`;
|
|
561
447
|
}
|
|
562
448
|
#renderConfirmButton() {
|
|
563
|
-
const { confirmLabel, confirmValue = 'confirm',
|
|
449
|
+
const { confirmLabel, confirmValue = 'confirm', destructive } = this;
|
|
564
450
|
if (!confirmLabel) {
|
|
565
451
|
return nothing;
|
|
566
452
|
}
|
|
567
|
-
const type =
|
|
453
|
+
const type = this.confirmType ?? 'button';
|
|
568
454
|
const buttonClass = destructive ? 'internal-button destructive' : 'internal-button';
|
|
569
455
|
return html `
|
|
570
456
|
<ui-button
|
|
@@ -592,8 +478,8 @@ let UiDialog = (() => {
|
|
|
592
478
|
* closing reason detail.
|
|
593
479
|
*
|
|
594
480
|
* ```javascript
|
|
595
|
-
* <ui-button color="text" value="dismiss">Cancel</ui-button>
|
|
596
|
-
* <ui-button color="text" value="confirm">Take action</ui-button>
|
|
481
|
+
* <ui-button slot="button" color="text" value="dismiss">Cancel</ui-button>
|
|
482
|
+
* <ui-button slot="button" color="text" value="confirm">Take action</ui-button>
|
|
597
483
|
* ```
|
|
598
484
|
*
|
|
599
485
|
* ```javascript
|
|
@@ -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;;sBAwEd,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AChB,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;;;AAxgBH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAudC","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 closing: CustomEvent<UiDialogClosingReason>\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 closing - A cancelable, non-bubbling event with the `UiDialogClosingReason` as the detail,\n * dispatched before the dialog closes. If prevented, the dialog will not close.\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\n const detail: UiDialogClosingReason = {\n cancelled: value === 'dismiss',\n }\n if (this.dialogValue !== undefined) {\n detail.value = this.dialogValue\n }\n\n // Dispatch cancelable closing event first\n const closingEvent = new CustomEvent<UiDialogClosingReason>('closing', {\n cancelable: true,\n composed: false,\n bubbles: false,\n detail,\n })\n const canClose = this.dispatchEvent(closingEvent)\n\n // Only proceed with closing if the event wasn't canceled\n if (!canClose) {\n return\n }\n\n this.open = false\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\n const detail: UiDialogClosingReason = {\n cancelled: true,\n }\n if (this.dialogValue !== undefined) {\n detail.value = this.dialogValue\n }\n\n // Dispatch cancelable closing event first\n const closingEvent = new CustomEvent<UiDialogClosingReason>('closing', {\n cancelable: true,\n composed: false,\n bubbles: false,\n detail,\n })\n const canClose = this.dispatchEvent(closingEvent)\n\n // Only proceed with closing if the event wasn't canceled\n if (!canClose) {\n // If closing was prevented, reopen the dialog\n this.dialog.showModal()\n return\n }\n\n this.open = false\n this.dispatchEvent(\n new CustomEvent<UiDialogClosingReason>('close', {\n composed: true,\n detail,\n })\n )\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
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAA;AAC7E,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;AAIlE,OAAO,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;;sBAwEd,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,MAAM,EAAE,CAAC;wCAO1B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAO1B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAQ3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAS1B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE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AI,CAAC,oBAAoB,EAAE,IAAI,IAAI,CAAC,oBAAoB,EAAE;;KAE/D,CAAA;QACH,CAAC;QAED,oBAAoB;YAClB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;YAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,OAAO,OAAO,CAAA;YAChB,CAAC;YACD,OAAO,IAAI,CAAA;;;;;kBAKG,IAAI,CAAC,aAAa;;WAEzB,YAAY;;KAElB,CAAA;QACH,CAAC;QAED,oBAAoB;YAClB,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,SAAS,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;YACpE,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,OAAO,OAAO,CAAA;YAChB,CAAC;YACD,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,IAAI,QAAQ,CAAA;YACzC,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;;;AAraH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAoXC","sourcesContent":["import { html, nothing, type PropertyValues, type TemplateResult } 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 type { ButtonType } from '../../button/internals/button.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 closing: CustomEvent<UiDialogClosingReason>\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 slot=\"button\" color=\"text\" value=\"dismiss\">Cancel</ui-button>\n * <ui-button slot=\"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 closing - A cancelable, non-bubbling event with the `UiDialogClosingReason` as the detail,\n * dispatched before the dialog closes. If prevented, the dialog will not close.\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 * 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 /**\n * The type of the confirm button.\n * This is used to set the button's `type` attribute.\n * If not set, the default is `button`.\n * If set to `submit`, the dialog will trigger the form submission on the parent form.\n * @attribute\n */\n @property({ type: String }) accessor confirmType: ButtonType | 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 * @attribute\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 /**\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 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 @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\n const detail: UiDialogClosingReason = {\n cancelled: value === 'dismiss',\n }\n if (this.dialogValue !== undefined) {\n detail.value = this.dialogValue\n }\n\n // Dispatch cancelable closing event first\n const closingEvent = new CustomEvent<UiDialogClosingReason>('closing', {\n cancelable: true,\n composed: false,\n bubbles: false,\n detail,\n })\n const canClose = this.dispatchEvent(closingEvent)\n\n // Only proceed with closing if the event wasn't canceled\n if (!canClose) {\n return\n }\n\n this.open = false\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\n const detail: UiDialogClosingReason = {\n cancelled: true,\n }\n if (this.dialogValue !== undefined) {\n detail.value = this.dialogValue\n }\n\n // Dispatch cancelable closing event first\n const closingEvent = new CustomEvent<UiDialogClosingReason>('closing', {\n cancelable: true,\n composed: false,\n bubbles: false,\n detail,\n })\n const canClose = this.dispatchEvent(closingEvent)\n\n // Only proceed with closing if the event wasn't canceled\n if (!canClose) {\n // If closing was prevented, reopen the dialog\n this.dialog.showModal()\n return\n }\n\n this.open = false\n this.dispatchEvent(\n new CustomEvent<UiDialogClosingReason>('close', {\n composed: true,\n detail,\n })\n )\n }\n\n protected handleDismiss(): void {\n this.handleInteraction('dismiss')\n }\n\n protected handleConfirm(): void {\n this.handleInteraction('confirm')\n }\n\n override render(): TemplateResult {\n const { 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\">${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 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 return html` <div class=\"content\" part=\"body\"><slot></slot></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', destructive } = this\n if (!confirmLabel) {\n return nothing\n }\n const type = this.confirmType ?? '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"]}
|
|
@@ -123,42 +123,28 @@ class CodeEditorDemo extends DemoPage {
|
|
|
123
123
|
|
|
124
124
|
<code-editor
|
|
125
125
|
label="Code Editor"
|
|
126
|
-
|
|
126
|
+
supportingtext="Type function names or {{fnName}} to see autocomplete"
|
|
127
127
|
.value=${this.editorValue}
|
|
128
128
|
.functionSchemas=${this.functions}
|
|
129
129
|
.suggestions=${this.suggestions}
|
|
130
|
-
@
|
|
131
|
-
@
|
|
130
|
+
@functioninsert=${this.handleFunctionInsert}
|
|
131
|
+
@suggestioninsert=${this.handleSuggestionInsert}
|
|
132
132
|
@input=${this.handleInput}
|
|
133
133
|
@change=${this.handleChange}
|
|
134
|
-
|
|
135
|
-
@
|
|
134
|
+
showdocumentation
|
|
135
|
+
@docsrequest="${this.handleFunctionDocumentation}"
|
|
136
136
|
></code-editor>
|
|
137
137
|
|
|
138
138
|
${this.output ? html`<p><strong>Output:</strong> ${this.output}</p>` : ''}
|
|
139
139
|
</section>
|
|
140
140
|
|
|
141
|
-
<section class="demo-section">
|
|
142
|
-
<h2 class="display-large">Dark Theme</h2>
|
|
143
|
-
<p>The same editor with dark theme enabled.</p>
|
|
144
|
-
|
|
145
|
-
<code-editor
|
|
146
|
-
label="Dark Theme Editor"
|
|
147
|
-
supporting-text="Dark theme variant"
|
|
148
|
-
.value=${'// Dark theme example\nconst theme = "dark"'}
|
|
149
|
-
.functionSchemas=${this.functions}
|
|
150
|
-
.suggestions=${this.suggestions}
|
|
151
|
-
dark-theme
|
|
152
|
-
></code-editor>
|
|
153
|
-
</section>
|
|
154
|
-
|
|
155
141
|
<section class="demo-section">
|
|
156
142
|
<h2 class="display-large">Disabled State</h2>
|
|
157
143
|
<p>A disabled editor for read-only content.</p>
|
|
158
144
|
|
|
159
145
|
<code-editor
|
|
160
146
|
label="Disabled Editor"
|
|
161
|
-
|
|
147
|
+
supportingtext="This editor is disabled"
|
|
162
148
|
.value=${'// This editor is disabled\nconst readOnly = true'}
|
|
163
149
|
.functionSchemas=${this.functions}
|
|
164
150
|
.suggestions=${this.suggestions}
|
|
@@ -172,7 +158,7 @@ class CodeEditorDemo extends DemoPage {
|
|
|
172
158
|
|
|
173
159
|
<code-editor
|
|
174
160
|
label="Error Editor"
|
|
175
|
-
|
|
161
|
+
supportingtext="This editor has an error"
|
|
176
162
|
.value=${'// This editor has an error\nconst invalid = true'}
|
|
177
163
|
.functionSchemas=${this.functions}
|
|
178
164
|
.suggestions=${this.suggestions}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/ui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
4
4
|
"description": "Internal UI component library for the API Client ecosystem.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "build/src/index.js",
|
|
@@ -186,7 +186,6 @@
|
|
|
186
186
|
"@codemirror/language": "^6.11.2",
|
|
187
187
|
"@codemirror/lint": "^6.8.5",
|
|
188
188
|
"@codemirror/state": "^6.5.2",
|
|
189
|
-
"@codemirror/theme-one-dark": "^6.1.3",
|
|
190
189
|
"@codemirror/view": "^6.38.0",
|
|
191
190
|
"@github/relative-time-element": "^4.4.6",
|
|
192
191
|
"@material/web": "^2.3.0",
|
|
@@ -29,8 +29,8 @@ import '@api-client/ui/elements/code-editor/code-editor.js'
|
|
|
29
29
|
.value=${this.code}
|
|
30
30
|
.functionSchemas=${this.functions}
|
|
31
31
|
.suggestions=${this.suggestions}
|
|
32
|
-
@
|
|
33
|
-
@
|
|
32
|
+
@functioninsert=${this.handleFunctionInsert}
|
|
33
|
+
@suggestioninsert=${this.handleSuggestionInsert}
|
|
34
34
|
@input=${this.handleInput}
|
|
35
35
|
></code-editor>
|
|
36
36
|
```
|
|
@@ -84,8 +84,8 @@ const suggestions: Suggestion[] = [
|
|
|
84
84
|
|
|
85
85
|
The component dispatches several events:
|
|
86
86
|
|
|
87
|
-
- `
|
|
88
|
-
- `
|
|
87
|
+
- `functioninsert`: When a function is inserted via autocomplete
|
|
88
|
+
- `suggestioninsert`: When a suggestion is inserted as a pill
|
|
89
89
|
- `input`: When the editor content changes (standard input event)
|
|
90
90
|
- `change`: When the editor loses focus and content has changed
|
|
91
91
|
|
|
@@ -129,6 +129,7 @@ code-editor {
|
|
|
129
129
|
## Accessibility
|
|
130
130
|
|
|
131
131
|
The component includes:
|
|
132
|
+
|
|
132
133
|
- Proper ARIA attributes for screen readers
|
|
133
134
|
- Keyboard navigation support
|
|
134
135
|
- Focus management
|
|
@@ -154,7 +155,7 @@ The component includes:
|
|
|
154
155
|
label="Code with Functions"
|
|
155
156
|
.value=${this.code}
|
|
156
157
|
.functionSchemas=${this.functions}
|
|
157
|
-
@
|
|
158
|
+
@functioninsert=${this.onFunctionInsert}
|
|
158
159
|
>
|
|
159
160
|
</code-editor>
|
|
160
161
|
```
|
|
@@ -166,7 +167,7 @@ The component includes:
|
|
|
166
167
|
label="Code with Mentions"
|
|
167
168
|
.value=${this.code}
|
|
168
169
|
.suggestions=${this.users}
|
|
169
|
-
@
|
|
170
|
+
@suggestioninsert=${this.onSuggestionInsert}
|
|
170
171
|
>
|
|
171
172
|
</code-editor>
|
|
172
173
|
```
|
|
@@ -189,6 +190,7 @@ A comprehensive demo is available at `/demo/elements/code-editor/` when running
|
|
|
189
190
|
## Browser Support
|
|
190
191
|
|
|
191
192
|
The component works in all modern browsers that support:
|
|
193
|
+
|
|
192
194
|
- ES2020+ features
|
|
193
195
|
- Web Components
|
|
194
196
|
- CSS Custom Properties
|
|
@@ -197,6 +199,7 @@ The component works in all modern browsers that support:
|
|
|
197
199
|
## Contributing
|
|
198
200
|
|
|
199
201
|
When contributing to this component, please follow the established patterns:
|
|
202
|
+
|
|
200
203
|
- Use TypeScript for type safety
|
|
201
204
|
- Follow the existing code style
|
|
202
205
|
- Include tests for new features
|