@api-client/ui 0.5.20 → 0.5.22
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/.github/instructions/lit-best-practices.instructions.md +1 -0
- package/build/src/md/button/ui-button-group.d.ts +1 -0
- package/build/src/md/button/ui-button-group.d.ts.map +1 -1
- package/build/src/md/button/ui-button-group.js.map +1 -1
- package/build/src/md/button/ui-button.d.ts +2 -0
- package/build/src/md/button/ui-button.d.ts.map +1 -1
- package/build/src/md/button/ui-button.js.map +1 -1
- package/build/src/md/chip/ui-chip.d.ts +1 -0
- package/build/src/md/chip/ui-chip.d.ts.map +1 -1
- package/build/src/md/chip/ui-chip.js +1 -0
- package/build/src/md/chip/ui-chip.js.map +1 -1
- package/build/src/md/dialog/internals/Dialog.d.ts +13 -36
- 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/build/src/md/dialog/ui-dialog.d.ts +1 -0
- package/build/src/md/dialog/ui-dialog.d.ts.map +1 -1
- package/build/src/md/dialog/ui-dialog.js.map +1 -1
- package/build/src/md/divider/ui-divider.d.ts +1 -0
- package/build/src/md/divider/ui-divider.d.ts.map +1 -1
- package/build/src/md/divider/ui-divider.js +1 -0
- package/build/src/md/divider/ui-divider.js.map +1 -1
- package/build/src/md/dropdown-list/ui-dropdown-list.d.ts +1 -0
- package/build/src/md/dropdown-list/ui-dropdown-list.d.ts.map +1 -1
- package/build/src/md/dropdown-list/ui-dropdown-list.js.map +1 -1
- package/build/src/md/icon-button/ui-icon-button.d.ts +2 -0
- package/build/src/md/icon-button/ui-icon-button.d.ts.map +1 -1
- package/build/src/md/icon-button/ui-icon-button.js.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.js +7 -0
- package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
- package/build/src/md/list/ui-list-item.d.ts +1 -0
- package/build/src/md/list/ui-list-item.d.ts.map +1 -1
- package/build/src/md/list/ui-list-item.js +1 -0
- package/build/src/md/list/ui-list-item.js.map +1 -1
- package/build/src/md/list/ui-list.d.ts +1 -0
- package/build/src/md/list/ui-list.d.ts.map +1 -1
- package/build/src/md/list/ui-list.js.map +1 -1
- package/build/src/md/menu/internal/Menu.d.ts +13 -0
- package/build/src/md/menu/internal/Menu.d.ts.map +1 -1
- package/build/src/md/menu/internal/Menu.js +30 -0
- package/build/src/md/menu/internal/Menu.js.map +1 -1
- package/build/src/md/menu/internal/MenuItem.d.ts +22 -0
- package/build/src/md/menu/internal/MenuItem.d.ts.map +1 -1
- package/build/src/md/menu/internal/MenuItem.js +74 -1
- package/build/src/md/menu/internal/MenuItem.js.map +1 -1
- package/build/src/md/menu/internal/MenuItem.styles.d.ts.map +1 -1
- package/build/src/md/menu/internal/MenuItem.styles.js +23 -0
- package/build/src/md/menu/internal/MenuItem.styles.js.map +1 -1
- package/build/src/md/menu/ui-menu-item.d.ts +1 -4
- package/build/src/md/menu/ui-menu-item.d.ts.map +1 -1
- package/build/src/md/menu/ui-menu-item.js +1 -4
- package/build/src/md/menu/ui-menu-item.js.map +1 -1
- package/build/src/md/menu/ui-menu.d.ts +1 -0
- package/build/src/md/menu/ui-menu.d.ts.map +1 -1
- package/build/src/md/menu/ui-menu.js.map +1 -1
- package/build/src/md/tabs/ui-tabs.d.ts +1 -0
- package/build/src/md/tabs/ui-tabs.d.ts.map +1 -1
- package/build/src/md/tabs/ui-tabs.js.map +1 -1
- package/demo/md/menu/index.ts +107 -1
- package/package.json +1 -1
- package/src/md/button/ui-button-group.ts +2 -0
- package/src/md/button/ui-button.ts +3 -0
- package/src/md/chip/ui-chip.ts +2 -0
- package/src/md/dialog/internals/Dialog.ts +20 -122
- package/src/md/dialog/ui-dialog.ts +2 -0
- package/src/md/divider/ui-divider.ts +2 -0
- package/src/md/dropdown-list/ui-dropdown-list.ts +2 -0
- package/src/md/icon-button/ui-icon-button.ts +3 -0
- package/src/md/list/internals/ListItem.styles.ts +7 -0
- package/src/md/list/ui-list-item.ts +2 -0
- package/src/md/list/ui-list.ts +2 -0
- package/src/md/menu/internal/Menu.ts +33 -0
- package/src/md/menu/internal/MenuItem.styles.ts +23 -0
- package/src/md/menu/internal/MenuItem.ts +49 -0
- package/src/md/menu/ui-menu-item.ts +2 -4
- package/src/md/menu/ui-menu.ts +2 -0
- package/src/md/tabs/ui-tabs.ts +2 -0
- package/test/md/menu/Menu.test.ts +346 -0
- package/test/md/menu/MenuItem.test.ts +292 -0
- 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
|
@@ -74,6 +74,7 @@ You are an expert developer in web components using the Lit library and Material
|
|
|
74
74
|
npm test -- --files=".tmp/test/**/[test file name].test.js"
|
|
75
75
|
```
|
|
76
76
|
- Prefer the Assert API over the Expect API for assertions. The Assert API is more performant and provides better error messages.
|
|
77
|
+
- When updating an element's property, await for the update to complete using `await element.updateComplete` before making assertions. This ensures that the component has fully rendered before checking its state.
|
|
77
78
|
|
|
78
79
|
## Component Demoing
|
|
79
80
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-button-group.d.ts","sourceRoot":"","sources":["../../../../src/md/button/ui-button-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE5C,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAG1C,qBACa,oBAAqB,SAAQ,OAAO;IAC/C,OAAgB,MAAM,EAAE,iBAAiB,EAAE,CAAW;CACvD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,oBAAoB,CAAA;KACxC;CACF"}
|
|
1
|
+
{"version":3,"file":"ui-button-group.d.ts","sourceRoot":"","sources":["../../../../src/md/button/ui-button-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE5C,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAG1C,qBACa,oBAAqB,SAAQ,OAAO;IAC/C,OAAgB,MAAM,EAAE,iBAAiB,EAAE,CAAW;CACvD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,oBAAoB,CAAA;KACxC;CACF;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-button-group.js","sourceRoot":"","sources":["../../../../src/md/button/ui-button-group.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAC1C,OAAO,MAAM,MAAM,6BAA6B,CAAA;IAGnC,oBAAoB;4BADhC,aAAa,CAAC,iBAAiB,CAAC;;;;sBACS,OAAO;oCAAf,SAAQ,WAAO;;;;YAAjD,6KAEC;;;;QADC,MAAM,CAAU,MAAM,GAAwB,CAAC,MAAM,CAAC,CAAA;;YAD3C,uDAAoB;;;;;SAApB,oBAAoB","sourcesContent":["import type { CSSResultOrNative } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport Element from './internals/group.js'\nimport styles from './internals/group.styles.js'\n\n@customElement('ui-button-group')\nexport class UiButtonGroupElement extends Element {\n static override styles: CSSResultOrNative[] = [styles]\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ui-button-group': UiButtonGroupElement\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ui-button-group.js","sourceRoot":"","sources":["../../../../src/md/button/ui-button-group.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAC1C,OAAO,MAAM,MAAM,6BAA6B,CAAA;IAGnC,oBAAoB;4BADhC,aAAa,CAAC,iBAAiB,CAAC;;;;sBACS,OAAO;oCAAf,SAAQ,WAAO;;;;YAAjD,6KAEC;;;;QADC,MAAM,CAAU,MAAM,GAAwB,CAAC,MAAM,CAAC,CAAA;;YAD3C,uDAAoB;;;;;SAApB,oBAAoB","sourcesContent":["import type { CSSResultOrNative } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport Element from './internals/group.js'\nimport styles from './internals/group.styles.js'\n\n@customElement('ui-button-group')\nexport class UiButtonGroupElement extends Element {\n static override styles: CSSResultOrNative[] = [styles]\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ui-button-group': UiButtonGroupElement\n }\n}\n\nexport type { MdGroupType } from './internals/group.js'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-button.d.ts","sourceRoot":"","sources":["../../../../src/md/button/ui-button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE5C,OAAO,OAAO,MAAM,uBAAuB,CAAA;AAG3C;;GAEG;AACH,qBACa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,MAAM,EAAE,iBAAiB,EAAE,CAAW;CACvD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,eAAe,CAAA;KAC7B;CACF"}
|
|
1
|
+
{"version":3,"file":"ui-button.d.ts","sourceRoot":"","sources":["../../../../src/md/button/ui-button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE5C,OAAO,OAAO,MAAM,uBAAuB,CAAA;AAG3C;;GAEG;AACH,qBACa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,MAAM,EAAE,iBAAiB,EAAE,CAAW;CACvD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,eAAe,CAAA;KAC7B;CACF;AAED,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-button.js","sourceRoot":"","sources":["../../../../src/md/button/ui-button.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,OAAO,MAAM,uBAAuB,CAAA;AAC3C,OAAO,MAAM,MAAM,8BAA8B,CAAA;AAEjD;;GAEG;IAEU,eAAe;4BAD3B,aAAa,CAAC,WAAW,CAAC;;;;sBACU,OAAO;+BAAf,SAAQ,WAAO;;;;YAA5C,6KAEC;;;;QADC,MAAM,CAAU,MAAM,GAAwB,CAAC,MAAM,CAAC,CAAA;;YAD3C,uDAAe;;;;;SAAf,eAAe","sourcesContent":["import type { CSSResultOrNative } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport Element from './internals/button.js'\nimport styles from './internals/button.styles.js'\n\n/**\n * @attribute {string} form\n */\n@customElement('ui-button')\nexport class UiButtonElement extends Element {\n static override styles: CSSResultOrNative[] = [styles]\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ui-button': UiButtonElement\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ui-button.js","sourceRoot":"","sources":["../../../../src/md/button/ui-button.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,OAAO,MAAM,uBAAuB,CAAA;AAC3C,OAAO,MAAM,MAAM,8BAA8B,CAAA;AAEjD;;GAEG;IAEU,eAAe;4BAD3B,aAAa,CAAC,WAAW,CAAC;;;;sBACU,OAAO;+BAAf,SAAQ,WAAO;;;;YAA5C,6KAEC;;;;QADC,MAAM,CAAU,MAAM,GAAwB,CAAC,MAAM,CAAC,CAAA;;YAD3C,uDAAe;;;;;SAAf,eAAe","sourcesContent":["import type { CSSResultOrNative } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport Element from './internals/button.js'\nimport styles from './internals/button.styles.js'\n\n/**\n * @attribute {string} form\n */\n@customElement('ui-button')\nexport class UiButtonElement extends Element {\n static override styles: CSSResultOrNative[] = [styles]\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ui-button': UiButtonElement\n }\n}\n\nexport type { MdButtonColor } from './internals/button.js'\nexport type { ButtonType, MdButtonShape, MdButtonSize } from './internals/base.js'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-chip.d.ts","sourceRoot":"","sources":["../../../../src/md/chip/ui-chip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE5C,OAAO,OAAO,MAAM,qBAAqB,CAAA;AAGzC,qBACa,aAAc,SAAQ,OAAO;IACxC,OAAgB,MAAM,EAAE,iBAAiB,EAAE,CAAW;CACvD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,aAAa,CAAA;KACzB;CACF"}
|
|
1
|
+
{"version":3,"file":"ui-chip.d.ts","sourceRoot":"","sources":["../../../../src/md/chip/ui-chip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE5C,OAAO,OAAO,MAAM,qBAAqB,CAAA;AAGzC,qBACa,aAAc,SAAQ,OAAO;IACxC,OAAgB,MAAM,EAAE,iBAAiB,EAAE,CAAW;CACvD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,aAAa,CAAA;KACzB;CACF;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-chip.js","sourceRoot":"","sources":["../../../../src/md/chip/ui-chip.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,OAAO,MAAM,qBAAqB,CAAA;AACzC,OAAO,MAAM,MAAM,4BAA4B,CAAA;IAGlC,aAAa;4BADzB,aAAa,CAAC,SAAS,CAAC;;;;sBACU,OAAO;6BAAf,SAAQ,WAAO;;;;YAA1C,6KAEC;;;;QADC,MAAM,CAAU,MAAM,GAAwB,CAAC,MAAM,CAAC,CAAA;;YAD3C,uDAAa;;;;;SAAb,aAAa","sourcesContent":["import type { CSSResultOrNative } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport Element from './internals/Chip.js'\nimport styles from './internals/Chip.styles.js'\n\n@customElement('ui-chip')\nexport class UiChipElement extends Element {\n static override styles: CSSResultOrNative[] = [styles]\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ui-chip': UiChipElement\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ui-chip.js","sourceRoot":"","sources":["../../../../src/md/chip/ui-chip.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,OAAO,MAAM,qBAAqB,CAAA;AACzC,OAAO,MAAM,MAAM,4BAA4B,CAAA;IAGlC,aAAa;4BADzB,aAAa,CAAC,SAAS,CAAC;;;;sBACU,OAAO;6BAAf,SAAQ,WAAO;;;;YAA1C,6KAEC;;;;QADC,MAAM,CAAU,MAAM,GAAwB,CAAC,MAAM,CAAC,CAAA;;YAD3C,uDAAa;;;;;SAAb,aAAa;AAU1B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA","sourcesContent":["import type { CSSResultOrNative } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport Element from './internals/Chip.js'\nimport styles from './internals/Chip.styles.js'\n\n@customElement('ui-chip')\nexport class UiChipElement extends Element {\n static override styles: CSSResultOrNative[] = [styles]\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ui-chip': UiChipElement\n }\n}\n\nexport { ChipType } from './internals/Chip.js'\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
2
2
|
import { UiElement } from '../../UiElement.js';
|
|
3
3
|
import type { TypedEvents } from '../../../core/types.js';
|
|
4
|
+
import type { ButtonType } from '../../button/internals/button.js';
|
|
4
5
|
import '../../button/ui-button.js';
|
|
5
6
|
export interface UiDialogClosingReason {
|
|
6
7
|
/**
|
|
@@ -18,7 +19,6 @@ interface DialogEventMap {
|
|
|
18
19
|
closing: CustomEvent<UiDialogClosingReason>;
|
|
19
20
|
close: CustomEvent<UiDialogClosingReason>;
|
|
20
21
|
}
|
|
21
|
-
export type RenderFunction = () => TemplateResult;
|
|
22
22
|
/**
|
|
23
23
|
* Styled dialog using a native `<dialog>` element under the hood.
|
|
24
24
|
* Note, since native dialog renders in the top layer it is not necessary
|
|
@@ -31,8 +31,8 @@ export type RenderFunction = () => TemplateResult;
|
|
|
31
31
|
* closing reason detail.
|
|
32
32
|
*
|
|
33
33
|
* ```javascript
|
|
34
|
-
* <ui-button color="text" value="dismiss">Cancel</ui-button>
|
|
35
|
-
* <ui-button color="text" value="confirm">Take action</ui-button>
|
|
34
|
+
* <ui-button slot="button" color="text" value="dismiss">Cancel</ui-button>
|
|
35
|
+
* <ui-button slot="button" color="text" value="confirm">Take action</ui-button>
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
38
|
* ```javascript
|
|
@@ -109,25 +109,6 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
109
109
|
* @attribute
|
|
110
110
|
*/
|
|
111
111
|
accessor destructive: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Part of the imperative access to the element.
|
|
114
|
-
* When set, it wraps the content in a `<form>` element.
|
|
115
|
-
* When this is enabled the following will happen:
|
|
116
|
-
* - The `confirm` button will get `type="submit"`
|
|
117
|
-
* - The form `method` attribute is set to `dialog`
|
|
118
|
-
* - The form `id` attribute is set to a random string. You can get it from the `formId` getter.
|
|
119
|
-
* - The dialog will dispatch the same `submit` event as the form.
|
|
120
|
-
* - When the `submit` event dispatched by the dialog gets cancelled, then:
|
|
121
|
-
* - The original submit event also gets cancelled.
|
|
122
|
-
* - The default confirm action is not invoked
|
|
123
|
-
* - The dialog stays opened
|
|
124
|
-
* - When the submit event is not cancelled, then:
|
|
125
|
-
* - The default confirm action is invoked.
|
|
126
|
-
* - The dialog is closed.
|
|
127
|
-
*
|
|
128
|
-
* @deprecated Wrap the content in a `<form>` element instead.
|
|
129
|
-
*/
|
|
130
|
-
accessor useForm: boolean | undefined;
|
|
131
112
|
/**
|
|
132
113
|
* Only when `confirmLabel` is set.
|
|
133
114
|
* Defines the value associated with the button's name when it's submitted with the form data.
|
|
@@ -135,6 +116,14 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
135
116
|
* @attribute
|
|
136
117
|
*/
|
|
137
118
|
accessor confirmValue: string | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* The type of the confirm button.
|
|
121
|
+
* This is used to set the button's `type` attribute.
|
|
122
|
+
* If not set, the default is `button`.
|
|
123
|
+
* If set to `submit`, the dialog will trigger the form submission on the parent form.
|
|
124
|
+
* @attribute
|
|
125
|
+
*/
|
|
126
|
+
accessor confirmType: ButtonType | undefined;
|
|
138
127
|
/**
|
|
139
128
|
* When the dialog is wrapped in a form, set this to `true` to close the dialog
|
|
140
129
|
* when the form is submitted.
|
|
@@ -142,6 +131,7 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
142
131
|
* Note that the dialog doesn't perform any validation of the form. It only closes
|
|
143
132
|
* when the form is submitted, regardless of the application logic. The `submit` event
|
|
144
133
|
* is dispatched by the dialog when the form is valid.
|
|
134
|
+
* @attribute
|
|
145
135
|
*/
|
|
146
136
|
accessor submitClose: boolean | undefined;
|
|
147
137
|
/**
|
|
@@ -159,22 +149,9 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
159
149
|
* This is passed to the close event.
|
|
160
150
|
*/
|
|
161
151
|
dialogValue?: unknown;
|
|
162
|
-
/**
|
|
163
|
-
* @deprecated Use `useForm` instead.
|
|
164
|
-
*/
|
|
165
|
-
get formId(): string | undefined;
|
|
166
152
|
constructor();
|
|
167
|
-
/**
|
|
168
|
-
* Allows to inject a template into the internals of the element.
|
|
169
|
-
* This is helpful when working with imperative dialogs.
|
|
170
|
-
* @param content The content to inject into the body.
|
|
171
|
-
* @deprecated This will be removed in the future. To use forms, wrap the content in a `<form>` element.
|
|
172
|
-
*/
|
|
173
|
-
inject(content?: TemplateResult | RenderFunction, styles?: CSSResultOrNative[]): void;
|
|
174
153
|
connectedCallback(): void;
|
|
175
154
|
disconnectedCallback(): void;
|
|
176
|
-
protected firstUpdated(): void;
|
|
177
|
-
willUpdate(cp: PropertyValues<this>): void;
|
|
178
155
|
protected handleFormSubmit(): void;
|
|
179
156
|
handleClick(e: MouseEvent): void;
|
|
180
157
|
handleKeyDown(e: KeyboardEvent): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../../src/md/dialog/internals/Dialog.ts"],"names":[],"mappings":"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"}
|
|
@@ -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
|