@spectrum-web-components/dialog 0.11.0 → 0.11.2
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/custom-elements.json +504 -109
- package/package.json +13 -5
- package/sp-dialog-base.d.ts +6 -0
- package/sp-dialog-base.dev.js +4 -0
- package/sp-dialog-base.dev.js.map +7 -0
- package/sp-dialog-base.js +2 -0
- package/sp-dialog-base.js.map +7 -0
- package/sp-dialog-wrapper.dev.js +1 -0
- package/sp-dialog-wrapper.dev.js.map +1 -1
- package/sp-dialog-wrapper.js +1 -1
- package/sp-dialog-wrapper.js.map +2 -2
- package/sp-dialog.dev.js +1 -0
- package/sp-dialog.dev.js.map +1 -1
- package/sp-dialog.js +1 -1
- package/sp-dialog.js.map +2 -2
- package/src/Dialog.dev.js +46 -17
- package/src/Dialog.dev.js.map +1 -1
- package/src/Dialog.js +10 -10
- package/src/Dialog.js.map +2 -2
- package/src/DialogBase.d.ts +48 -0
- package/src/DialogBase.dev.js +177 -0
- package/src/DialogBase.dev.js.map +7 -0
- package/src/DialogBase.js +19 -0
- package/src/DialogBase.js.map +7 -0
- package/src/DialogWrapper.d.ts +6 -35
- package/src/DialogWrapper.dev.js +79 -188
- package/src/DialogWrapper.dev.js.map +2 -2
- package/src/DialogWrapper.js +53 -66
- package/src/DialogWrapper.js.map +3 -3
- package/src/dialog.css.dev.js +2 -1
- package/src/dialog.css.dev.js.map +2 -2
- package/src/dialog.css.js +2 -2
- package/src/dialog.css.js.map +3 -3
- package/src/index.d.ts +1 -0
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +2 -2
- package/src/index.js +1 -1
- package/src/index.js.map +2 -2
- package/src/spectrum-dialog.css.dev.js +1 -0
- package/src/spectrum-dialog.css.dev.js.map +1 -1
- package/src/spectrum-dialog.css.js +1 -1
- package/src/spectrum-dialog.css.js.map +2 -2
- package/stories/dialog-base.stories.js +187 -0
- package/stories/dialog-base.stories.js.map +7 -0
- package/stories/dialog-wrapper.stories.js +171 -48
- package/stories/dialog-wrapper.stories.js.map +2 -2
- package/stories/dialog.stories.js +66 -19
- package/stories/dialog.stories.js.map +2 -2
- package/stories/images.js +3 -1
- package/stories/images.js.map +1 -1
- package/stories/index.js +37 -0
- package/stories/index.js.map +7 -0
- package/test/benchmark/basic-test.js +5 -1
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/dialog-base.test-vrt.js +5 -0
- package/test/dialog-base.test-vrt.js.map +7 -0
- package/test/dialog-base.test.js +133 -0
- package/test/dialog-base.test.js.map +7 -0
- package/test/dialog-wrapper.test-vrt.js +4 -1
- package/test/dialog-wrapper.test-vrt.js.map +1 -1
- package/test/dialog-wrapper.test.js +208 -3
- package/test/dialog-wrapper.test.js.map +2 -2
- package/test/dialog.test-vrt.js +4 -1
- package/test/dialog.test-vrt.js.map +1 -1
- package/test/dialog.test.js +149 -13
- package/test/dialog.test.js.map +1 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
if (decorator = decorators[i])
|
|
8
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
+
if (kind && result)
|
|
10
|
+
__defProp(target, key, result);
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
import {
|
|
14
|
+
html,
|
|
15
|
+
SpectrumElement
|
|
16
|
+
} from "@spectrum-web-components/base";
|
|
17
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
18
|
+
import "@spectrum-web-components/underlay/sp-underlay.js";
|
|
19
|
+
import "@spectrum-web-components/button/sp-button.js";
|
|
20
|
+
import "../sp-dialog.dev.js";
|
|
21
|
+
import modalWrapperStyles from "@spectrum-web-components/modal/src/modal-wrapper.css.js";
|
|
22
|
+
import modalStyles from "@spectrum-web-components/modal/src/modal.css.js";
|
|
23
|
+
import { FocusVisiblePolyfillMixin } from "@spectrum-web-components/shared";
|
|
24
|
+
import { firstFocusableIn } from "@spectrum-web-components/shared/src/first-focusable-in.js";
|
|
25
|
+
export class DialogBase extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.dismissable = false;
|
|
29
|
+
this.open = false;
|
|
30
|
+
this.responsive = false;
|
|
31
|
+
this.transitionPromise = Promise.resolve();
|
|
32
|
+
this.resolveTransitionPromise = () => {
|
|
33
|
+
return;
|
|
34
|
+
};
|
|
35
|
+
this.underlay = false;
|
|
36
|
+
}
|
|
37
|
+
static get styles() {
|
|
38
|
+
return [modalWrapperStyles, modalStyles];
|
|
39
|
+
}
|
|
40
|
+
get dialog() {
|
|
41
|
+
const dialog = this.shadowRoot.querySelector("slot").assignedElements()[0];
|
|
42
|
+
if (true) {
|
|
43
|
+
if (!dialog) {
|
|
44
|
+
window.__swc.warn(
|
|
45
|
+
this,
|
|
46
|
+
`<${this.localName}> expects to be provided dialog content via its default slot.`,
|
|
47
|
+
"https://opensource.adobe.com/spectrum-web-components/components/dialog-base/#dialog"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return dialog || this;
|
|
52
|
+
}
|
|
53
|
+
focus() {
|
|
54
|
+
if (this.shadowRoot) {
|
|
55
|
+
const firstFocusable = firstFocusableIn(this.dialog);
|
|
56
|
+
if (firstFocusable) {
|
|
57
|
+
if (firstFocusable.updateComplete) {
|
|
58
|
+
firstFocusable.updateComplete.then(
|
|
59
|
+
() => firstFocusable.focus()
|
|
60
|
+
);
|
|
61
|
+
} else {
|
|
62
|
+
firstFocusable.focus();
|
|
63
|
+
}
|
|
64
|
+
this.removeAttribute("tabindex");
|
|
65
|
+
} else {
|
|
66
|
+
this.dialog.focus();
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
super.focus();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
overlayWillCloseCallback() {
|
|
73
|
+
if (!this.open)
|
|
74
|
+
return false;
|
|
75
|
+
this.close();
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
dismiss() {
|
|
79
|
+
if (!this.dismissable) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.close();
|
|
83
|
+
}
|
|
84
|
+
handleClose(event) {
|
|
85
|
+
event.stopPropagation();
|
|
86
|
+
this.close();
|
|
87
|
+
}
|
|
88
|
+
close() {
|
|
89
|
+
this.open = false;
|
|
90
|
+
}
|
|
91
|
+
dispatchClosed() {
|
|
92
|
+
this.dispatchEvent(
|
|
93
|
+
new Event("close", {
|
|
94
|
+
bubbles: true
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
handleUnderlayTransitionend(event) {
|
|
99
|
+
if (!this.open && event.propertyName === "visibility") {
|
|
100
|
+
this.dispatchClosed();
|
|
101
|
+
this.resolveTransitionPromise();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
handleModalTransitionend() {
|
|
105
|
+
if (this.open || !this.underlay) {
|
|
106
|
+
this.resolveTransitionPromise();
|
|
107
|
+
if (!this.open) {
|
|
108
|
+
this.dispatchClosed();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
update(changes) {
|
|
113
|
+
if (changes.has("open") && changes.get("open") !== void 0) {
|
|
114
|
+
this.transitionPromise = new Promise(
|
|
115
|
+
(res) => this.resolveTransitionPromise = res
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
super.update(changes);
|
|
119
|
+
}
|
|
120
|
+
renderDialog() {
|
|
121
|
+
return html`
|
|
122
|
+
<slot></slot>
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
render() {
|
|
126
|
+
return html`
|
|
127
|
+
${this.underlay ? html`
|
|
128
|
+
<sp-underlay
|
|
129
|
+
?open=${this.open}
|
|
130
|
+
@click=${this.dismiss}
|
|
131
|
+
@transitionend=${this.handleUnderlayTransitionend}
|
|
132
|
+
></sp-underlay>
|
|
133
|
+
` : html``}
|
|
134
|
+
<div
|
|
135
|
+
class="modal ${this.mode}"
|
|
136
|
+
@transitionend=${this.handleModalTransitionend}
|
|
137
|
+
@close=${this.handleClose}
|
|
138
|
+
>
|
|
139
|
+
${this.renderDialog()}
|
|
140
|
+
</div>
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
updated(changes) {
|
|
144
|
+
if (changes.has("open")) {
|
|
145
|
+
if (this.open) {
|
|
146
|
+
if ("updateComplete" in this.dialog && "shouldManageTabOrderForScrolling" in this.dialog) {
|
|
147
|
+
this.dialog.updateComplete.then(() => {
|
|
148
|
+
this.dialog.shouldManageTabOrderForScrolling();
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
this.tabIndex = 0;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async getUpdateComplete() {
|
|
157
|
+
const complete = await super.getUpdateComplete();
|
|
158
|
+
await this.transitionPromise;
|
|
159
|
+
return complete;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
__decorateClass([
|
|
163
|
+
property({ type: Boolean, reflect: true })
|
|
164
|
+
], DialogBase.prototype, "dismissable", 2);
|
|
165
|
+
__decorateClass([
|
|
166
|
+
property({ type: Boolean, reflect: true })
|
|
167
|
+
], DialogBase.prototype, "open", 2);
|
|
168
|
+
__decorateClass([
|
|
169
|
+
property({ type: String, reflect: true })
|
|
170
|
+
], DialogBase.prototype, "mode", 2);
|
|
171
|
+
__decorateClass([
|
|
172
|
+
property({ type: Boolean })
|
|
173
|
+
], DialogBase.prototype, "responsive", 2);
|
|
174
|
+
__decorateClass([
|
|
175
|
+
property({ type: Boolean })
|
|
176
|
+
], DialogBase.prototype, "underlay", 2);
|
|
177
|
+
//# sourceMappingURL=DialogBase.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["DialogBase.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport '@spectrum-web-components/button/sp-button.js';\n\nimport '../sp-dialog.dev.js'\nimport modalWrapperStyles from '@spectrum-web-components/modal/src/modal-wrapper.css.js';\nimport modalStyles from '@spectrum-web-components/modal/src/modal.css.js';\nimport { Dialog } from './Dialog.dev.js'\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\n/**\n * @element sp-dialog-base\n *\n * @slot - A Dialog element to display.\n * @fires close - Announces that the dialog has been closed.\n */\nexport class DialogBase extends FocusVisiblePolyfillMixin(SpectrumElement) {\n public static override get styles(): CSSResultArray {\n return [modalWrapperStyles, modalStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n /**\n * When set to true, fills screens smaller than 350px high and 400px wide with the full dialog.\n */\n @property({ type: Boolean })\n public responsive = false;\n\n private transitionPromise = Promise.resolve();\n\n private resolveTransitionPromise = (): void => {\n return;\n };\n\n @property({ type: Boolean })\n public underlay = false;\n\n protected get dialog(): Dialog {\n const dialog = (\n this.shadowRoot.querySelector('slot') as HTMLSlotElement\n ).assignedElements()[0] as Dialog;\n if (window.__swc.DEBUG) {\n if (!dialog) {\n window.__swc.warn(\n this,\n `<${this.localName}> expects to be provided dialog content via its default slot.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/dialog-base/#dialog'\n );\n }\n }\n return dialog || this;\n }\n\n public override focus(): void {\n if (this.shadowRoot) {\n const firstFocusable = firstFocusableIn(this.dialog);\n if (firstFocusable) {\n if (firstFocusable.updateComplete) {\n firstFocusable.updateComplete.then(() =>\n firstFocusable.focus()\n );\n /* c8 ignore next 3 */\n } else {\n firstFocusable.focus();\n }\n this.removeAttribute('tabindex');\n } else {\n this.dialog.focus();\n }\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n }\n\n public overlayWillCloseCallback(): boolean {\n if (!this.open) return false;\n this.close();\n return true;\n }\n\n private dismiss(): void {\n if (!this.dismissable) {\n return;\n }\n this.close();\n }\n\n protected handleClose(event: Event): void {\n event.stopPropagation();\n this.close();\n }\n\n public close(): void {\n this.open = false;\n }\n\n private dispatchClosed(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n })\n );\n }\n\n protected handleUnderlayTransitionend(event: TransitionEvent): void {\n if (!this.open && event.propertyName === 'visibility') {\n this.dispatchClosed();\n this.resolveTransitionPromise();\n }\n }\n\n protected handleModalTransitionend(): void {\n if (this.open || !this.underlay) {\n this.resolveTransitionPromise();\n if (!this.open) {\n this.dispatchClosed();\n }\n }\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (changes.has('open') && changes.get('open') !== undefined) {\n this.transitionPromise = new Promise(\n (res) => (this.resolveTransitionPromise = res)\n );\n }\n super.update(changes);\n }\n\n protected renderDialog(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.underlay\n ? html`\n <sp-underlay\n ?open=${this.open}\n @click=${this.dismiss}\n @transitionend=${this.handleUnderlayTransitionend}\n ></sp-underlay>\n `\n : html``}\n <div\n class=\"modal ${this.mode}\"\n @transitionend=${this.handleModalTransitionend}\n @close=${this.handleClose}\n >\n ${this.renderDialog()}\n </div>\n `;\n }\n\n protected override updated(changes: PropertyValues<this>): void {\n if (changes.has('open')) {\n if (this.open) {\n if (\n 'updateComplete' in this.dialog &&\n 'shouldManageTabOrderForScrolling' in this.dialog\n ) {\n this.dialog.updateComplete.then(() => {\n this.dialog.shouldManageTabOrderForScrolling();\n });\n }\n } else {\n this.tabIndex = 0;\n }\n }\n }\n\n /**\n * Bind the open/close transition into the update complete lifecycle so\n * that the overlay system can wait for it to be \"visibly ready\" before\n * attempting to throw focus into the content contained herein. Not\n * waiting for this can cause small amounts of page scroll to happen\n * while opening the Tray when focusable content is included: e.g. Menu\n * elements whose selected Menu Item is not the first Menu Item.\n */\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.transitionPromise;\n return complete;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EAEA;AAAA,OAEG;AACP,SAAS,gBAAgB;AAEzB,OAAO;AACP,OAAO;AAEP,OAAO;AACP,OAAO,wBAAwB;AAC/B,OAAO,iBAAiB;AAExB,SAAS,iCAAiC;AAC1C,SAAS,wBAAwB;AAQ1B,aAAM,mBAAmB,0BAA0B,eAAe,EAAE;AAAA,EAApE;AAAA;AAMH,SAAO,cAAc;AAGrB,SAAO,OAAO;AASd,SAAO,aAAa;AAEpB,SAAQ,oBAAoB,QAAQ,QAAQ;AAE5C,SAAQ,2BAA2B,MAAY;AAC3C;AAAA,IACJ;AAGA,SAAO,WAAW;AAAA;AAAA,EA1BlB,WAA2B,SAAyB;AAChD,WAAO,CAAC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EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GARjC,WASF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAXhC,WAYF;AAMA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GAjBlB,WAkBF;AASA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GA1BlB,WA2BF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var i=(a,s,e,o)=>{for(var t=o>1?void 0:o?u(s,e):s,n=a.length-1,d;n>=0;n--)(d=a[n])&&(t=(o?d(s,e,t):d(t))||t);return o&&t&&p(s,e,t),t};import{html as l,SpectrumElement as c}from"@spectrum-web-components/base";import{property as r}from"@spectrum-web-components/base/src/decorators.js";import"@spectrum-web-components/underlay/sp-underlay.js";import"@spectrum-web-components/button/sp-button.js";import"../sp-dialog.js";import h from"@spectrum-web-components/modal/src/modal-wrapper.css.js";import m from"@spectrum-web-components/modal/src/modal.css.js";import{FocusVisiblePolyfillMixin as f}from"@spectrum-web-components/shared";import{firstFocusableIn as v}from"@spectrum-web-components/shared/src/first-focusable-in.js";export class DialogBase extends f(c){constructor(){super(...arguments);this.dismissable=!1;this.open=!1;this.responsive=!1;this.transitionPromise=Promise.resolve();this.resolveTransitionPromise=()=>{};this.underlay=!1}static get styles(){return[h,m]}get dialog(){return this.shadowRoot.querySelector("slot").assignedElements()[0]||this}focus(){if(this.shadowRoot){const e=v(this.dialog);e?(e.updateComplete?e.updateComplete.then(()=>e.focus()):e.focus(),this.removeAttribute("tabindex")):this.dialog.focus()}else super.focus()}overlayWillCloseCallback(){return this.open?(this.close(),!0):!1}dismiss(){!this.dismissable||this.close()}handleClose(e){e.stopPropagation(),this.close()}close(){this.open=!1}dispatchClosed(){this.dispatchEvent(new Event("close",{bubbles:!0}))}handleUnderlayTransitionend(e){!this.open&&e.propertyName==="visibility"&&(this.dispatchClosed(),this.resolveTransitionPromise())}handleModalTransitionend(){(this.open||!this.underlay)&&(this.resolveTransitionPromise(),this.open||this.dispatchClosed())}update(e){e.has("open")&&e.get("open")!==void 0&&(this.transitionPromise=new Promise(o=>this.resolveTransitionPromise=o)),super.update(e)}renderDialog(){return l`
|
|
2
|
+
<slot></slot>
|
|
3
|
+
`}render(){return l`
|
|
4
|
+
${this.underlay?l`
|
|
5
|
+
<sp-underlay
|
|
6
|
+
?open=${this.open}
|
|
7
|
+
@click=${this.dismiss}
|
|
8
|
+
@transitionend=${this.handleUnderlayTransitionend}
|
|
9
|
+
></sp-underlay>
|
|
10
|
+
`:l``}
|
|
11
|
+
<div
|
|
12
|
+
class="modal ${this.mode}"
|
|
13
|
+
@transitionend=${this.handleModalTransitionend}
|
|
14
|
+
@close=${this.handleClose}
|
|
15
|
+
>
|
|
16
|
+
${this.renderDialog()}
|
|
17
|
+
</div>
|
|
18
|
+
`}updated(e){e.has("open")&&(this.open?"updateComplete"in this.dialog&&"shouldManageTabOrderForScrolling"in this.dialog&&this.dialog.updateComplete.then(()=>{this.dialog.shouldManageTabOrderForScrolling()}):this.tabIndex=0)}async getUpdateComplete(){const e=await super.getUpdateComplete();return await this.transitionPromise,e}}i([r({type:Boolean,reflect:!0})],DialogBase.prototype,"dismissable",2),i([r({type:Boolean,reflect:!0})],DialogBase.prototype,"open",2),i([r({type:String,reflect:!0})],DialogBase.prototype,"mode",2),i([r({type:Boolean})],DialogBase.prototype,"responsive",2),i([r({type:Boolean})],DialogBase.prototype,"underlay",2);
|
|
19
|
+
//# sourceMappingURL=DialogBase.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["DialogBase.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport '@spectrum-web-components/button/sp-button.js';\n\nimport '../sp-dialog.js';\nimport modalWrapperStyles from '@spectrum-web-components/modal/src/modal-wrapper.css.js';\nimport modalStyles from '@spectrum-web-components/modal/src/modal.css.js';\nimport { Dialog } from './Dialog.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\n/**\n * @element sp-dialog-base\n *\n * @slot - A Dialog element to display.\n * @fires close - Announces that the dialog has been closed.\n */\nexport class DialogBase extends FocusVisiblePolyfillMixin(SpectrumElement) {\n public static override get styles(): CSSResultArray {\n return [modalWrapperStyles, modalStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n /**\n * When set to true, fills screens smaller than 350px high and 400px wide with the full dialog.\n */\n @property({ type: Boolean })\n public responsive = false;\n\n private transitionPromise = Promise.resolve();\n\n private resolveTransitionPromise = (): void => {\n return;\n };\n\n @property({ type: Boolean })\n public underlay = false;\n\n protected get dialog(): Dialog {\n const dialog = (\n this.shadowRoot.querySelector('slot') as HTMLSlotElement\n ).assignedElements()[0] as Dialog;\n if (window.__swc.DEBUG) {\n if (!dialog) {\n window.__swc.warn(\n this,\n `<${this.localName}> expects to be provided dialog content via its default slot.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/dialog-base/#dialog'\n );\n }\n }\n return dialog || this;\n }\n\n public override focus(): void {\n if (this.shadowRoot) {\n const firstFocusable = firstFocusableIn(this.dialog);\n if (firstFocusable) {\n if (firstFocusable.updateComplete) {\n firstFocusable.updateComplete.then(() =>\n firstFocusable.focus()\n );\n /* c8 ignore next 3 */\n } else {\n firstFocusable.focus();\n }\n this.removeAttribute('tabindex');\n } else {\n this.dialog.focus();\n }\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n }\n\n public overlayWillCloseCallback(): boolean {\n if (!this.open) return false;\n this.close();\n return true;\n }\n\n private dismiss(): void {\n if (!this.dismissable) {\n return;\n }\n this.close();\n }\n\n protected handleClose(event: Event): void {\n event.stopPropagation();\n this.close();\n }\n\n public close(): void {\n this.open = false;\n }\n\n private dispatchClosed(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n })\n );\n }\n\n protected handleUnderlayTransitionend(event: TransitionEvent): void {\n if (!this.open && event.propertyName === 'visibility') {\n this.dispatchClosed();\n this.resolveTransitionPromise();\n }\n }\n\n protected handleModalTransitionend(): void {\n if (this.open || !this.underlay) {\n this.resolveTransitionPromise();\n if (!this.open) {\n this.dispatchClosed();\n }\n }\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (changes.has('open') && changes.get('open') !== undefined) {\n this.transitionPromise = new Promise(\n (res) => (this.resolveTransitionPromise = res)\n );\n }\n super.update(changes);\n }\n\n protected renderDialog(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.underlay\n ? html`\n <sp-underlay\n ?open=${this.open}\n @click=${this.dismiss}\n @transitionend=${this.handleUnderlayTransitionend}\n ></sp-underlay>\n `\n : html``}\n <div\n class=\"modal ${this.mode}\"\n @transitionend=${this.handleModalTransitionend}\n @close=${this.handleClose}\n >\n ${this.renderDialog()}\n </div>\n `;\n }\n\n protected override updated(changes: PropertyValues<this>): void {\n if (changes.has('open')) {\n if (this.open) {\n if (\n 'updateComplete' in this.dialog &&\n 'shouldManageTabOrderForScrolling' in this.dialog\n ) {\n this.dialog.updateComplete.then(() => {\n this.dialog.shouldManageTabOrderForScrolling();\n });\n }\n } else {\n this.tabIndex = 0;\n }\n }\n }\n\n /**\n * Bind the open/close transition into the update complete lifecycle so\n * that the overlay system can wait for it to be \"visibly ready\" before\n * attempting to throw focus into the content contained herein. Not\n * waiting for this can cause small amounts of page scroll to happen\n * while opening the Tray when focusable content is included: e.g. Menu\n * elements whose selected Menu Item is not the first Menu Item.\n */\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.transitionPromise;\n return complete;\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,EAEA,mBAAAC,MAEG,gCACP,OAAS,YAAAC,MAAgB,kDAEzB,MAAO,mDACP,MAAO,+CAEP,MAAO,kBACP,OAAOC,MAAwB,0DAC/B,OAAOC,MAAiB,kDAExB,OAAS,6BAAAC,MAAiC,kCAC1C,OAAS,oBAAAC,MAAwB,4DAQ1B,aAAM,mBAAmBD,EAA0BJ,CAAe,CAAE,CAApE,kCAMH,KAAO,YAAc,GAGrB,KAAO,KAAO,GASd,KAAO,WAAa,GAEpB,KAAQ,kBAAoB,QAAQ,QAAQ,EAE5C,KAAQ,yBAA2B,IAAY,CAE/C,EAGA,KAAO,SAAW,GA1BlB,WAA2B,QAAyB,CAChD,MAAO,CAACE,EAAoBC,CAAW,CAC3C,CA0BA,IAAc,QAAiB,CAa3B,OAXI,KAAK,WAAW,cAAc,MAAM,EACtC,iBAAiB,EAAE,IAUJ,IACrB,CAEgB,OAAc,CAC1B,GAAI,KAAK,WAAY,CACjB,MAAMG,EAAiBD,EAAiB,KAAK,MAAM,EAC/CC,GACIA,EAAe,eACfA,EAAe,eAAe,KAAK,IAC/BA,EAAe,MAAM,CACzB,EAGAA,EAAe,MA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,iCAAiC,CACjD,CAAC,EAGL,KAAK,SAAW,EAG5B,CAUA,MAAyB,mBAAsC,CAC3D,MAAME,EAAY,MAAM,MAAM,kBAAkB,EAChD,aAAM,KAAK,kBACJA,CACX,CACJ,CA7KWC,EAAA,CADNV,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GALjC,WAMF,2BAGAU,EAAA,CADNV,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GARjC,WASF,oBAGAU,EAAA,CADNV,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAXhC,WAYF,oBAMAU,EAAA,CADNV,EAAS,CAAE,KAAM,OAAQ,CAAC,GAjBlB,WAkBF,0BASAU,EAAA,CADNV,EAAS,CAAE,KAAM,OAAQ,CAAC,GA1BlB,WA2BF",
|
|
6
|
+
"names": ["html", "SpectrumElement", "property", "modalWrapperStyles", "modalStyles", "FocusVisiblePolyfillMixin", "firstFocusableIn", "firstFocusable", "event", "changes", "res", "complete", "__decorateClass"]
|
|
7
|
+
}
|
package/src/DialogWrapper.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { CSSResultArray,
|
|
1
|
+
import { CSSResultArray, TemplateResult } from '@spectrum-web-components/base';
|
|
2
2
|
import '@spectrum-web-components/underlay/sp-underlay.js';
|
|
3
3
|
import '@spectrum-web-components/button/sp-button.js';
|
|
4
4
|
import '../sp-dialog.js';
|
|
5
|
-
|
|
5
|
+
import { DialogBase } from './DialogBase.js';
|
|
6
|
+
import { Dialog } from './Dialog.js';
|
|
6
7
|
/**
|
|
7
8
|
* @element sp-dialog-wrapper
|
|
8
9
|
*
|
|
@@ -12,51 +13,21 @@ declare const DialogWrapper_base: typeof SpectrumElement;
|
|
|
12
13
|
* @fires confirm - Announces that the "confirm" button has been clicked.
|
|
13
14
|
* @fires close - Announces that the dialog has been closed.
|
|
14
15
|
*/
|
|
15
|
-
export declare class DialogWrapper extends
|
|
16
|
+
export declare class DialogWrapper extends DialogBase {
|
|
16
17
|
static get styles(): CSSResultArray;
|
|
17
18
|
error: boolean;
|
|
18
19
|
cancelLabel: string;
|
|
19
20
|
confirmLabel: string;
|
|
20
|
-
dismissable: boolean;
|
|
21
21
|
footer: string;
|
|
22
22
|
hero: string;
|
|
23
23
|
heroLabel: string;
|
|
24
24
|
noDivider: boolean;
|
|
25
|
-
open: boolean;
|
|
26
|
-
mode?: 'fullscreen' | 'fullscreenTakeover';
|
|
27
25
|
size?: 's' | 'm' | 'l';
|
|
28
26
|
secondaryLabel: string;
|
|
29
27
|
headline: string;
|
|
30
|
-
|
|
31
|
-
* When set to true, fills screens smaller than 350px high and 400px wide with the full dialog.
|
|
32
|
-
*/
|
|
33
|
-
responsive: boolean;
|
|
34
|
-
private transitionPromise;
|
|
35
|
-
private resolveTransitionPromise;
|
|
36
|
-
underlay: boolean;
|
|
37
|
-
private dialog;
|
|
38
|
-
focus(): void;
|
|
39
|
-
overlayWillCloseCallback(): boolean;
|
|
40
|
-
private dismiss;
|
|
28
|
+
protected get dialog(): Dialog;
|
|
41
29
|
private clickSecondary;
|
|
42
30
|
private clickCancel;
|
|
43
31
|
private clickConfirm;
|
|
44
|
-
protected
|
|
45
|
-
close(): void;
|
|
46
|
-
private dispatchClosed;
|
|
47
|
-
protected handleUnderlayTransitionend(event: TransitionEvent): void;
|
|
48
|
-
protected handleModalTransitionend(): void;
|
|
49
|
-
protected update(changes: PropertyValues<this>): void;
|
|
50
|
-
protected render(): TemplateResult;
|
|
51
|
-
protected updated(changes: PropertyValues<this>): void;
|
|
52
|
-
/**
|
|
53
|
-
* Bind the open/close transition into the update complete lifecycle so
|
|
54
|
-
* that the overlay system can wait for it to be "visibly ready" before
|
|
55
|
-
* attempting to throw focus into the content contained herein. Not
|
|
56
|
-
* waiting for this can cause small amounts of page scroll to happen
|
|
57
|
-
* while opening the Tray when focusable content is included: e.g. Menu
|
|
58
|
-
* elements whose selected Menu Item is not the first Menu Item.
|
|
59
|
-
*/
|
|
60
|
-
protected getUpdateComplete(): Promise<boolean>;
|
|
32
|
+
protected renderDialog(): TemplateResult;
|
|
61
33
|
}
|
|
62
|
-
export {};
|
package/src/DialogWrapper.dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -10,206 +11,114 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
11
|
return result;
|
|
11
12
|
};
|
|
12
13
|
import {
|
|
13
|
-
html
|
|
14
|
-
SpectrumElement
|
|
14
|
+
html
|
|
15
15
|
} from "@spectrum-web-components/base";
|
|
16
|
-
import {
|
|
17
|
-
property,
|
|
18
|
-
query
|
|
19
|
-
} from "@spectrum-web-components/base/src/decorators.js";
|
|
16
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
20
17
|
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
21
18
|
import "@spectrum-web-components/underlay/sp-underlay.js";
|
|
22
19
|
import "@spectrum-web-components/button/sp-button.js";
|
|
23
20
|
import "../sp-dialog.dev.js";
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
import { FocusVisiblePolyfillMixin } from "@spectrum-web-components/shared";
|
|
27
|
-
import { firstFocusableIn } from "@spectrum-web-components/shared/src/first-focusable-in.js";
|
|
28
|
-
export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
21
|
+
import { DialogBase } from "./DialogBase.dev.js";
|
|
22
|
+
export class DialogWrapper extends DialogBase {
|
|
29
23
|
constructor() {
|
|
30
24
|
super(...arguments);
|
|
31
25
|
this.error = false;
|
|
32
26
|
this.cancelLabel = "";
|
|
33
27
|
this.confirmLabel = "";
|
|
34
|
-
this.dismissable = false;
|
|
35
28
|
this.footer = "";
|
|
36
29
|
this.hero = "";
|
|
37
30
|
this.heroLabel = "";
|
|
38
31
|
this.noDivider = false;
|
|
39
|
-
this.open = false;
|
|
40
32
|
this.secondaryLabel = "";
|
|
41
33
|
this.headline = "";
|
|
42
|
-
this.responsive = false;
|
|
43
|
-
this.transitionPromise = Promise.resolve();
|
|
44
|
-
this.resolveTransitionPromise = () => {
|
|
45
|
-
return;
|
|
46
|
-
};
|
|
47
|
-
this.underlay = false;
|
|
48
34
|
}
|
|
49
35
|
static get styles() {
|
|
50
|
-
return [
|
|
51
|
-
}
|
|
52
|
-
focus() {
|
|
53
|
-
if (this.shadowRoot) {
|
|
54
|
-
const firstFocusable = firstFocusableIn(this.dialog);
|
|
55
|
-
if (firstFocusable) {
|
|
56
|
-
if (firstFocusable.updateComplete) {
|
|
57
|
-
firstFocusable.updateComplete.then(() => firstFocusable.focus());
|
|
58
|
-
} else {
|
|
59
|
-
firstFocusable.focus();
|
|
60
|
-
}
|
|
61
|
-
this.removeAttribute("tabindex");
|
|
62
|
-
} else {
|
|
63
|
-
this.dialog.focus();
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
super.focus();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
overlayWillCloseCallback() {
|
|
70
|
-
if (!this.open)
|
|
71
|
-
return false;
|
|
72
|
-
this.close();
|
|
73
|
-
return true;
|
|
36
|
+
return [...super.styles];
|
|
74
37
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
this.close();
|
|
38
|
+
get dialog() {
|
|
39
|
+
return this.shadowRoot.querySelector("sp-dialog");
|
|
80
40
|
}
|
|
81
41
|
clickSecondary() {
|
|
82
|
-
this.dispatchEvent(
|
|
83
|
-
|
|
84
|
-
|
|
42
|
+
this.dispatchEvent(
|
|
43
|
+
new Event("secondary", {
|
|
44
|
+
bubbles: true
|
|
45
|
+
})
|
|
46
|
+
);
|
|
85
47
|
}
|
|
86
48
|
clickCancel() {
|
|
87
|
-
this.dispatchEvent(
|
|
88
|
-
|
|
89
|
-
|
|
49
|
+
this.dispatchEvent(
|
|
50
|
+
new Event("cancel", {
|
|
51
|
+
bubbles: true
|
|
52
|
+
})
|
|
53
|
+
);
|
|
90
54
|
}
|
|
91
55
|
clickConfirm() {
|
|
92
|
-
this.dispatchEvent(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
event.stopPropagation();
|
|
98
|
-
this.close();
|
|
99
|
-
}
|
|
100
|
-
close() {
|
|
101
|
-
this.open = false;
|
|
56
|
+
this.dispatchEvent(
|
|
57
|
+
new Event("confirm", {
|
|
58
|
+
bubbles: true
|
|
59
|
+
})
|
|
60
|
+
);
|
|
102
61
|
}
|
|
103
|
-
|
|
104
|
-
this.dispatchEvent(new Event("close", {
|
|
105
|
-
bubbles: true
|
|
106
|
-
}));
|
|
107
|
-
}
|
|
108
|
-
handleUnderlayTransitionend(event) {
|
|
109
|
-
if (!this.open && event.propertyName === "visibility") {
|
|
110
|
-
this.dispatchClosed();
|
|
111
|
-
this.resolveTransitionPromise();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
handleModalTransitionend() {
|
|
115
|
-
if (this.open || !this.underlay) {
|
|
116
|
-
this.resolveTransitionPromise();
|
|
117
|
-
if (!this.open) {
|
|
118
|
-
this.dispatchClosed();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
update(changes) {
|
|
123
|
-
if (changes.has("open") && changes.get("open") !== void 0) {
|
|
124
|
-
this.transitionPromise = new Promise((res) => this.resolveTransitionPromise = res);
|
|
125
|
-
}
|
|
126
|
-
super.update(changes);
|
|
127
|
-
}
|
|
128
|
-
render() {
|
|
62
|
+
renderDialog() {
|
|
129
63
|
return html`
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
` : html``}
|
|
137
|
-
<div
|
|
138
|
-
class="modal ${this.mode}"
|
|
139
|
-
@transitionend=${this.handleModalTransitionend}
|
|
64
|
+
<sp-dialog
|
|
65
|
+
?dismissable=${this.dismissable}
|
|
66
|
+
?no-divider=${this.noDivider}
|
|
67
|
+
?error=${this.error}
|
|
68
|
+
mode=${ifDefined(this.mode)}
|
|
69
|
+
size=${ifDefined(this.size)}
|
|
140
70
|
>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
${this.confirmLabel}
|
|
191
|
-
</sp-button>
|
|
192
|
-
` : html``}
|
|
193
|
-
</sp-dialog>
|
|
194
|
-
</div>
|
|
71
|
+
${this.hero ? html`
|
|
72
|
+
<img
|
|
73
|
+
src="${this.hero}"
|
|
74
|
+
slot="hero"
|
|
75
|
+
aria-hidden=${ifDefined(
|
|
76
|
+
this.heroLabel ? void 0 : "true"
|
|
77
|
+
)}
|
|
78
|
+
alt=${ifDefined(
|
|
79
|
+
this.heroLabel ? this.heroLabel : void 0
|
|
80
|
+
)}
|
|
81
|
+
/>
|
|
82
|
+
` : html``}
|
|
83
|
+
${this.headline ? html`
|
|
84
|
+
<h2 slot="heading">${this.headline}</h2>
|
|
85
|
+
` : html``}
|
|
86
|
+
<slot></slot>
|
|
87
|
+
${this.footer ? html`
|
|
88
|
+
<div slot="footer">${this.footer}</div>
|
|
89
|
+
` : html``}
|
|
90
|
+
${this.cancelLabel ? html`
|
|
91
|
+
<sp-button
|
|
92
|
+
variant="secondary"
|
|
93
|
+
treatment="outline"
|
|
94
|
+
slot="button"
|
|
95
|
+
@click=${this.clickCancel}
|
|
96
|
+
>
|
|
97
|
+
${this.cancelLabel}
|
|
98
|
+
</sp-button>
|
|
99
|
+
` : html``}
|
|
100
|
+
${this.secondaryLabel ? html`
|
|
101
|
+
<sp-button
|
|
102
|
+
variant="primary"
|
|
103
|
+
treatment="outline"
|
|
104
|
+
slot="button"
|
|
105
|
+
@click=${this.clickSecondary}
|
|
106
|
+
>
|
|
107
|
+
${this.secondaryLabel}
|
|
108
|
+
</sp-button>
|
|
109
|
+
` : html``}
|
|
110
|
+
${this.confirmLabel ? html`
|
|
111
|
+
<sp-button
|
|
112
|
+
variant="accent"
|
|
113
|
+
slot="button"
|
|
114
|
+
@click=${this.clickConfirm}
|
|
115
|
+
>
|
|
116
|
+
${this.confirmLabel}
|
|
117
|
+
</sp-button>
|
|
118
|
+
` : html``}
|
|
119
|
+
</sp-dialog>
|
|
195
120
|
`;
|
|
196
121
|
}
|
|
197
|
-
updated(changes) {
|
|
198
|
-
if (changes.has("open")) {
|
|
199
|
-
if (this.open) {
|
|
200
|
-
this.dialog.updateComplete.then(() => {
|
|
201
|
-
this.dialog.shouldManageTabOrderForScrolling();
|
|
202
|
-
});
|
|
203
|
-
} else {
|
|
204
|
-
this.tabIndex = 0;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
async getUpdateComplete() {
|
|
209
|
-
const complete = await super.getUpdateComplete();
|
|
210
|
-
await this.transitionPromise;
|
|
211
|
-
return complete;
|
|
212
|
-
}
|
|
213
122
|
}
|
|
214
123
|
__decorateClass([
|
|
215
124
|
property({ type: Boolean, reflect: true })
|
|
@@ -220,9 +129,6 @@ __decorateClass([
|
|
|
220
129
|
__decorateClass([
|
|
221
130
|
property({ attribute: "confirm-label" })
|
|
222
131
|
], DialogWrapper.prototype, "confirmLabel", 2);
|
|
223
|
-
__decorateClass([
|
|
224
|
-
property({ type: Boolean, reflect: true })
|
|
225
|
-
], DialogWrapper.prototype, "dismissable", 2);
|
|
226
132
|
__decorateClass([
|
|
227
133
|
property()
|
|
228
134
|
], DialogWrapper.prototype, "footer", 2);
|
|
@@ -235,12 +141,6 @@ __decorateClass([
|
|
|
235
141
|
__decorateClass([
|
|
236
142
|
property({ type: Boolean, reflect: true, attribute: "no-divider" })
|
|
237
143
|
], DialogWrapper.prototype, "noDivider", 2);
|
|
238
|
-
__decorateClass([
|
|
239
|
-
property({ type: Boolean, reflect: true })
|
|
240
|
-
], DialogWrapper.prototype, "open", 2);
|
|
241
|
-
__decorateClass([
|
|
242
|
-
property({ type: String, reflect: true })
|
|
243
|
-
], DialogWrapper.prototype, "mode", 2);
|
|
244
144
|
__decorateClass([
|
|
245
145
|
property({ type: String, reflect: true })
|
|
246
146
|
], DialogWrapper.prototype, "size", 2);
|
|
@@ -250,13 +150,4 @@ __decorateClass([
|
|
|
250
150
|
__decorateClass([
|
|
251
151
|
property()
|
|
252
152
|
], DialogWrapper.prototype, "headline", 2);
|
|
253
|
-
__decorateClass([
|
|
254
|
-
property({ type: Boolean })
|
|
255
|
-
], DialogWrapper.prototype, "responsive", 2);
|
|
256
|
-
__decorateClass([
|
|
257
|
-
property({ type: Boolean })
|
|
258
|
-
], DialogWrapper.prototype, "underlay", 2);
|
|
259
|
-
__decorateClass([
|
|
260
|
-
query("sp-dialog")
|
|
261
|
-
], DialogWrapper.prototype, "dialog", 2);
|
|
262
153
|
//# sourceMappingURL=DialogWrapper.dev.js.map
|