@spectrum-web-components/dialog 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/dialog",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,17 +46,17 @@
46
46
  "lit-html"
47
47
  ],
48
48
  "dependencies": {
49
- "@spectrum-web-components/action-button": "^0.8.0",
50
- "@spectrum-web-components/base": "^0.5.3",
51
- "@spectrum-web-components/button": "^0.17.0",
52
- "@spectrum-web-components/button-group": "^0.8.4",
53
- "@spectrum-web-components/divider": "^0.4.4",
54
- "@spectrum-web-components/icon": "^0.11.4",
55
- "@spectrum-web-components/icons-ui": "^0.8.4",
56
- "@spectrum-web-components/icons-workflow": "^0.8.4",
57
- "@spectrum-web-components/modal": "^0.6.2",
58
- "@spectrum-web-components/shared": "^0.13.5",
59
- "@spectrum-web-components/underlay": "^0.8.4",
49
+ "@spectrum-web-components/action-button": "^0.8.1",
50
+ "@spectrum-web-components/base": "^0.5.4",
51
+ "@spectrum-web-components/button": "^0.17.1",
52
+ "@spectrum-web-components/button-group": "^0.8.5",
53
+ "@spectrum-web-components/divider": "^0.4.5",
54
+ "@spectrum-web-components/icon": "^0.11.5",
55
+ "@spectrum-web-components/icons-ui": "^0.8.5",
56
+ "@spectrum-web-components/icons-workflow": "^0.8.5",
57
+ "@spectrum-web-components/modal": "^0.6.3",
58
+ "@spectrum-web-components/shared": "^0.13.6",
59
+ "@spectrum-web-components/underlay": "^0.8.5",
60
60
  "tslib": "^2.0.0"
61
61
  },
62
62
  "devDependencies": {
@@ -67,5 +67,5 @@
67
67
  "sideEffects": [
68
68
  "./sp-*.js"
69
69
  ],
70
- "gitHead": "57aba8030b6af96af4015a0aa830e342a17dc219"
70
+ "gitHead": "caf12727e7f91dcf961e1fadacc727eea9ece27b"
71
71
  }
@@ -0,0 +1,6 @@
1
+ import { DialogWrapper } from './src/DialogWrapper.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-dialog-wrapper': DialogWrapper;
5
+ }
6
+ }
@@ -0,0 +1,14 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { DialogWrapper } from './src/DialogWrapper.js';
13
+ customElements.define('sp-dialog-wrapper', DialogWrapper);
14
+ //# sourceMappingURL=sp-dialog-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sp-dialog-wrapper.js","sourceRoot":"","sources":["sp-dialog-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,cAAc,CAAC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC","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*/\nimport { DialogWrapper } from './src/DialogWrapper.js';\n\ncustomElements.define('sp-dialog-wrapper', DialogWrapper);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-dialog-wrapper': DialogWrapper;\n }\n}\n"]}
package/sp-dialog.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Dialog } from './src/Dialog.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-dialog': Dialog;
5
+ }
6
+ }
package/sp-dialog.js ADDED
@@ -0,0 +1,14 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { Dialog } from './src/Dialog.js';
13
+ customElements.define('sp-dialog', Dialog);
14
+ //# sourceMappingURL=sp-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sp-dialog.js","sourceRoot":"","sources":["sp-dialog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC","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*/\nimport { Dialog } from './src/Dialog.js';\n\ncustomElements.define('sp-dialog', Dialog);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-dialog': Dialog;\n }\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
+ import '@spectrum-web-components/divider/sp-divider.js';
3
+ import '@spectrum-web-components/action-button/sp-action-button.js';
4
+ import '@spectrum-web-components/button-group/sp-button-group.js';
5
+ import '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';
6
+ import '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';
7
+ import type { ActionButton } from '@spectrum-web-components/action-button';
8
+ declare const Dialog_base: typeof SpectrumElement & {
9
+ new (...args: any[]): import("@spectrum-web-components/shared").SlotPresenceObservingInterface;
10
+ prototype: import("@spectrum-web-components/shared").SlotPresenceObservingInterface;
11
+ };
12
+ /**
13
+ * @element sp-dialog
14
+ *
15
+ * @slot hero - Accepts a hero image to display at the top of the dialog
16
+ * @slot heading - Acts as the heading of the dialog. This should be an actual heading tag `<h1-6 />`
17
+ * @slot - Content not addressed to a specific slot will be interpreted as the main content of the dialog
18
+ * @slot footer - Content addressed to the `footer` will be placed below the main content and to the side of any `[slot='button']` content
19
+ * @slot button - Button elements addressed to this slot may be placed below the content when not delivered in a fullscreen mode
20
+ * @fires close - Announces that the dialog has been closed.
21
+ */
22
+ export declare class Dialog extends Dialog_base {
23
+ static get styles(): CSSResultArray;
24
+ closeButton?: ActionButton;
25
+ private contentElement;
26
+ error: boolean;
27
+ dismissable: boolean;
28
+ protected get hasFooter(): boolean;
29
+ protected get hasButtons(): boolean;
30
+ protected get hasHero(): boolean;
31
+ noDivider: boolean;
32
+ mode?: 'fullscreen' | 'fullscreenTakeover';
33
+ size?: 's' | 'm' | 'l';
34
+ close(): void;
35
+ protected render(): TemplateResult;
36
+ shouldManageTabOrderForScrolling: () => void;
37
+ protected shouldUpdate(changes: PropertyValues): boolean;
38
+ protected firstUpdated(changes: PropertyValues): void;
39
+ static instanceCount: number;
40
+ private labelledbyId;
41
+ private conditionLabelledby?;
42
+ private conditionDescribedby?;
43
+ private onHeadingSlotchange;
44
+ private describedbyId;
45
+ protected onContentSlotChange({ target, }: Event & {
46
+ target: HTMLSlotElement;
47
+ }): void;
48
+ connectedCallback(): void;
49
+ disconnectedCallback(): void;
50
+ }
51
+ export {};
package/src/Dialog.js ADDED
@@ -0,0 +1,227 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { __decorate } from "tslib";
13
+ import { html, SpectrumElement, } from '@spectrum-web-components/base';
14
+ import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
15
+ import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
16
+ import { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';
17
+ import '@spectrum-web-components/divider/sp-divider.js';
18
+ import '@spectrum-web-components/action-button/sp-action-button.js';
19
+ import '@spectrum-web-components/button-group/sp-button-group.js';
20
+ import crossStyles from '@spectrum-web-components/icon/src/spectrum-icon-cross.css.js';
21
+ import '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';
22
+ import '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';
23
+ import { FocusVisiblePolyfillMixin, ObserveSlotPresence, } from '@spectrum-web-components/shared';
24
+ import styles from './dialog.css.js';
25
+ function gatherAppliedIdsFromSlottedChildren(slot, idBase) {
26
+ const assignedElements = slot.assignedElements();
27
+ const ids = [];
28
+ assignedElements.forEach((el, i) => {
29
+ if (el.id) {
30
+ ids.push(el.id);
31
+ }
32
+ else {
33
+ const id = idBase + `-${i}`;
34
+ el.id = id;
35
+ ids.push(id);
36
+ }
37
+ });
38
+ return ids;
39
+ }
40
+ /**
41
+ * @element sp-dialog
42
+ *
43
+ * @slot hero - Accepts a hero image to display at the top of the dialog
44
+ * @slot heading - Acts as the heading of the dialog. This should be an actual heading tag `<h1-6 />`
45
+ * @slot - Content not addressed to a specific slot will be interpreted as the main content of the dialog
46
+ * @slot footer - Content addressed to the `footer` will be placed below the main content and to the side of any `[slot='button']` content
47
+ * @slot button - Button elements addressed to this slot may be placed below the content when not delivered in a fullscreen mode
48
+ * @fires close - Announces that the dialog has been closed.
49
+ */
50
+ export class Dialog extends FocusVisiblePolyfillMixin(ObserveSlotPresence(SpectrumElement, [
51
+ '[slot="hero"]',
52
+ '[slot="footer"]',
53
+ '[slot="button"]',
54
+ ])) {
55
+ constructor() {
56
+ super(...arguments);
57
+ this.error = false;
58
+ this.dismissable = false;
59
+ this.noDivider = false;
60
+ this.shouldManageTabOrderForScrolling = () => {
61
+ const { offsetHeight, scrollHeight } = this.contentElement;
62
+ if (offsetHeight < scrollHeight) {
63
+ this.contentElement.tabIndex = 0;
64
+ }
65
+ else {
66
+ this.contentElement.removeAttribute('tabindex');
67
+ }
68
+ };
69
+ this.labelledbyId = `sp-dialog-label-${Dialog.instanceCount++}`;
70
+ this.describedbyId = `sp-dialog-description-${Dialog.instanceCount++}`;
71
+ }
72
+ static get styles() {
73
+ return [styles, crossStyles];
74
+ }
75
+ get hasFooter() {
76
+ return this.getSlotContentPresence('[slot="footer"]');
77
+ }
78
+ get hasButtons() {
79
+ return this.getSlotContentPresence('[slot="button"]');
80
+ }
81
+ get hasHero() {
82
+ return this.getSlotContentPresence('[slot="hero"]');
83
+ }
84
+ close() {
85
+ this.dispatchEvent(new Event('close', {
86
+ bubbles: true,
87
+ composed: true,
88
+ cancelable: true,
89
+ }));
90
+ }
91
+ render() {
92
+ return html `
93
+ <div class="grid">
94
+ <slot name="hero"></slot>
95
+ <slot
96
+ name="heading"
97
+ class=${ifDefined(this.hasHero ? this.hasHero : undefined)}
98
+ @slotchange=${this.onHeadingSlotchange}
99
+ ></slot>
100
+ ${this.error
101
+ ? html `
102
+ <sp-icon-alert class="type-icon"></sp-icon-alert>
103
+ `
104
+ : html ``}
105
+ ${this.noDivider
106
+ ? html ``
107
+ : html `
108
+ <sp-divider size="m" class="divider"></sp-divider>
109
+ `}
110
+ <div class="content">
111
+ <slot @slotchange=${this.onContentSlotChange}></slot>
112
+ </div>
113
+ ${this.hasFooter
114
+ ? html `
115
+ <div class="footer">
116
+ <slot name="footer"></slot>
117
+ </div>
118
+ `
119
+ : html ``}
120
+ ${this.hasButtons
121
+ ? html `
122
+ <sp-button-group
123
+ class="button-group ${this.hasFooter
124
+ ? ''
125
+ : 'button-group--noFooter'}"
126
+ >
127
+ <slot name="button"></slot>
128
+ </sp-button-group>
129
+ `
130
+ : html ``}
131
+ ${this.dismissable
132
+ ? html `
133
+ <sp-action-button
134
+ class="close-button"
135
+ label="Close"
136
+ quiet
137
+ size="m"
138
+ @click=${this.close}
139
+ >
140
+ <sp-icon-cross500
141
+ class="spectrum-UIIcon-Cross500"
142
+ slot="icon"
143
+ ></sp-icon-cross500>
144
+ </sp-action-button>
145
+ `
146
+ : html ``}
147
+ </div>
148
+ `;
149
+ }
150
+ shouldUpdate(changes) {
151
+ if (changes.has('mode') && !!this.mode) {
152
+ this.dismissable = false;
153
+ }
154
+ if (changes.has('dismissable') && this.dismissable) {
155
+ this.dismissable = !this.mode;
156
+ }
157
+ return super.shouldUpdate(changes);
158
+ }
159
+ firstUpdated(changes) {
160
+ super.firstUpdated(changes);
161
+ this.setAttribute('role', 'dialog');
162
+ }
163
+ onHeadingSlotchange({ target, }) {
164
+ if (this.conditionLabelledby) {
165
+ this.conditionLabelledby();
166
+ delete this.conditionLabelledby;
167
+ }
168
+ const ids = gatherAppliedIdsFromSlottedChildren(target, this.labelledbyId);
169
+ if (ids.length) {
170
+ this.conditionLabelledby = conditionAttributeWithId(this, 'aria-labelledby', ids);
171
+ }
172
+ }
173
+ onContentSlotChange({ target, }) {
174
+ if (this.conditionDescribedby) {
175
+ this.conditionDescribedby();
176
+ delete this.conditionDescribedby;
177
+ }
178
+ const ids = gatherAppliedIdsFromSlottedChildren(target, this.describedbyId);
179
+ if (ids.length && ids.length < 4) {
180
+ this.conditionDescribedby = conditionAttributeWithId(this, 'aria-describedby', ids);
181
+ }
182
+ else if (!ids.length) {
183
+ const idProvided = !!this.id;
184
+ if (!idProvided)
185
+ this.id = this.describedbyId;
186
+ const conditionDescribedby = conditionAttributeWithId(this, 'aria-describedby', this.id);
187
+ this.conditionDescribedby = () => {
188
+ conditionDescribedby();
189
+ if (!idProvided) {
190
+ this.removeAttribute('id');
191
+ }
192
+ };
193
+ }
194
+ }
195
+ connectedCallback() {
196
+ super.connectedCallback();
197
+ this.tabIndex = 0;
198
+ window.addEventListener('resize', this.shouldManageTabOrderForScrolling);
199
+ }
200
+ disconnectedCallback() {
201
+ window.removeEventListener('resize', this.shouldManageTabOrderForScrolling);
202
+ super.disconnectedCallback();
203
+ }
204
+ }
205
+ Dialog.instanceCount = 0;
206
+ __decorate([
207
+ query('.close-button')
208
+ ], Dialog.prototype, "closeButton", void 0);
209
+ __decorate([
210
+ query('.content')
211
+ ], Dialog.prototype, "contentElement", void 0);
212
+ __decorate([
213
+ property({ type: Boolean, reflect: true })
214
+ ], Dialog.prototype, "error", void 0);
215
+ __decorate([
216
+ property({ type: Boolean, reflect: true })
217
+ ], Dialog.prototype, "dismissable", void 0);
218
+ __decorate([
219
+ property({ type: Boolean, reflect: true, attribute: 'no-divider' })
220
+ ], Dialog.prototype, "noDivider", void 0);
221
+ __decorate([
222
+ property({ type: String, reflect: true })
223
+ ], Dialog.prototype, "mode", void 0);
224
+ __decorate([
225
+ property({ type: String, reflect: true })
226
+ ], Dialog.prototype, "size", void 0);
227
+ //# sourceMappingURL=Dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["Dialog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,O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;QAC1B,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,MAAM,CAAC,gBAAgB,CACnB,QAAQ,EACR,IAAI,CAAC,gCAAgC,CACxC,CAAC;IACN,CAAC;IAEM,oBAAoB;QACvB,MAAM,CAAC,mBAAmB,CACtB,QAAQ,EACR,IAAI,CAAC,gCAAgC,CACxC,CAAC;QACF,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACjC,CAAC;;AA5EM,oBAAa,GAAG,CAAC,CAAC;AA9HzB;IADC,KAAK,CAAC,eAAe,CAAC;2CACI;AAG3B;IADC,KAAK,CAAC,UAAU,CAAC;8CACsB;AAGxC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCACtB;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAChB;AAe3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;yCAC3C;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCACQ;AAGlD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCACZ","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 {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';\n\nimport '@spectrum-web-components/divider/sp-divider.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/button-group/sp-button-group.js';\nimport crossStyles from '@spectrum-web-components/icon/src/spectrum-icon-cross.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport {\n FocusVisiblePolyfillMixin,\n ObserveSlotPresence,\n} from '@spectrum-web-components/shared';\n\nimport styles from './dialog.css.js';\nimport type { ActionButton } from '@spectrum-web-components/action-button';\n\nfunction gatherAppliedIdsFromSlottedChildren(\n slot: HTMLSlotElement,\n idBase: string\n): string[] {\n const assignedElements = slot.assignedElements();\n const ids: string[] = [];\n assignedElements.forEach((el, i) => {\n if (el.id) {\n ids.push(el.id);\n } else {\n const id = idBase + `-${i}`;\n el.id = id;\n ids.push(id);\n }\n });\n return ids;\n}\n\n/**\n * @element sp-dialog\n *\n * @slot hero - Accepts a hero image to display at the top of the dialog\n * @slot heading - Acts as the heading of the dialog. This should be an actual heading tag `<h1-6 />`\n * @slot - Content not addressed to a specific slot will be interpreted as the main content of the dialog\n * @slot footer - Content addressed to the `footer` will be placed below the main content and to the side of any `[slot='button']` content\n * @slot button - Button elements addressed to this slot may be placed below the content when not delivered in a fullscreen mode\n * @fires close - Announces that the dialog has been closed.\n */\nexport class Dialog extends FocusVisiblePolyfillMixin(\n ObserveSlotPresence(SpectrumElement, [\n '[slot=\"hero\"]',\n '[slot=\"footer\"]',\n '[slot=\"button\"]',\n ])\n) {\n public static get styles(): CSSResultArray {\n return [styles, crossStyles];\n }\n\n @query('.close-button')\n closeButton?: ActionButton;\n\n @query('.content')\n private contentElement!: HTMLDivElement;\n\n @property({ type: Boolean, reflect: true })\n public error = false;\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n protected get hasFooter(): boolean {\n return this.getSlotContentPresence('[slot=\"footer\"]');\n }\n\n protected get hasButtons(): boolean {\n return this.getSlotContentPresence('[slot=\"button\"]');\n }\n\n protected get hasHero(): boolean {\n return this.getSlotContentPresence('[slot=\"hero\"]');\n }\n\n @property({ type: Boolean, reflect: true, attribute: 'no-divider' })\n public noDivider = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n @property({ type: String, reflect: true })\n public size?: 's' | 'm' | 'l';\n\n public close(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n protected render(): TemplateResult {\n return html`\n <div class=\"grid\">\n <slot name=\"hero\"></slot>\n <slot\n name=\"heading\"\n class=${ifDefined(this.hasHero ? this.hasHero : undefined)}\n @slotchange=${this.onHeadingSlotchange}\n ></slot>\n ${this.error\n ? html`\n <sp-icon-alert class=\"type-icon\"></sp-icon-alert>\n `\n : html``}\n ${this.noDivider\n ? html``\n : html`\n <sp-divider size=\"m\" class=\"divider\"></sp-divider>\n `}\n <div class=\"content\">\n <slot @slotchange=${this.onContentSlotChange}></slot>\n </div>\n ${this.hasFooter\n ? html`\n <div class=\"footer\">\n <slot name=\"footer\"></slot>\n </div>\n `\n : html``}\n ${this.hasButtons\n ? html`\n <sp-button-group\n class=\"button-group ${this.hasFooter\n ? ''\n : 'button-group--noFooter'}\"\n >\n <slot name=\"button\"></slot>\n </sp-button-group>\n `\n : html``}\n ${this.dismissable\n ? html`\n <sp-action-button\n class=\"close-button\"\n label=\"Close\"\n quiet\n size=\"m\"\n @click=${this.close}\n >\n <sp-icon-cross500\n class=\"spectrum-UIIcon-Cross500\"\n slot=\"icon\"\n ></sp-icon-cross500>\n </sp-action-button>\n `\n : html``}\n </div>\n `;\n }\n\n public shouldManageTabOrderForScrolling = (): void => {\n const { offsetHeight, scrollHeight } = this.contentElement;\n if (offsetHeight < scrollHeight) {\n this.contentElement.tabIndex = 0;\n } else {\n this.contentElement.removeAttribute('tabindex');\n }\n };\n\n protected shouldUpdate(changes: PropertyValues): boolean {\n if (changes.has('mode') && !!this.mode) {\n this.dismissable = false;\n }\n if (changes.has('dismissable') && this.dismissable) {\n this.dismissable = !this.mode;\n }\n return super.shouldUpdate(changes);\n }\n\n protected firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('role', 'dialog');\n }\n\n static instanceCount = 0;\n private labelledbyId = `sp-dialog-label-${Dialog.instanceCount++}`;\n private conditionLabelledby?: () => void;\n private conditionDescribedby?: () => void;\n\n private onHeadingSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (this.conditionLabelledby) {\n this.conditionLabelledby();\n delete this.conditionLabelledby;\n }\n const ids = gatherAppliedIdsFromSlottedChildren(\n target,\n this.labelledbyId\n );\n if (ids.length) {\n this.conditionLabelledby = conditionAttributeWithId(\n this,\n 'aria-labelledby',\n ids\n );\n }\n }\n\n private describedbyId = `sp-dialog-description-${Dialog.instanceCount++}`;\n\n protected onContentSlotChange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (this.conditionDescribedby) {\n this.conditionDescribedby();\n delete this.conditionDescribedby;\n }\n const ids = gatherAppliedIdsFromSlottedChildren(\n target,\n this.describedbyId\n );\n if (ids.length && ids.length < 4) {\n this.conditionDescribedby = conditionAttributeWithId(\n this,\n 'aria-describedby',\n ids\n );\n } else if (!ids.length) {\n const idProvided = !!this.id;\n if (!idProvided) this.id = this.describedbyId;\n const conditionDescribedby = conditionAttributeWithId(\n this,\n 'aria-describedby',\n this.id\n );\n this.conditionDescribedby = () => {\n conditionDescribedby();\n if (!idProvided) {\n this.removeAttribute('id');\n }\n };\n }\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.tabIndex = 0;\n window.addEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n }\n\n public disconnectedCallback(): void {\n window.removeEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n super.disconnectedCallback();\n }\n}\n"]}
@@ -0,0 +1,59 @@
1
+ import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
+ import '@spectrum-web-components/underlay/sp-underlay.js';
3
+ import '@spectrum-web-components/button/sp-button.js';
4
+ import '../sp-dialog.js';
5
+ declare const DialogWrapper_base: typeof SpectrumElement;
6
+ /**
7
+ * @element sp-dialog-wrapper
8
+ *
9
+ * @slot - content for the dialog
10
+ * @fires secondary - Announces that the "secondary" button has been clicked.
11
+ * @fires cancel - Announces that the "cancel" button has been clicked.
12
+ * @fires confirm - Announces that the "confirm" button has been clicked.
13
+ * @fires close - Announces that the dialog has been closed.
14
+ */
15
+ export declare class DialogWrapper extends DialogWrapper_base {
16
+ static get styles(): CSSResultArray;
17
+ error: boolean;
18
+ cancelLabel: string;
19
+ confirmLabel: string;
20
+ dismissable: boolean;
21
+ footer: string;
22
+ hero: string;
23
+ heroLabel: string;
24
+ noDivider: boolean;
25
+ open: boolean;
26
+ mode?: 'fullscreen' | 'fullscreenTakeover';
27
+ size?: 's' | 'm' | 'l';
28
+ secondaryLabel: string;
29
+ headline: string;
30
+ responsive: boolean;
31
+ private transitionPromise;
32
+ private resolveTransitionPromise;
33
+ underlay: boolean;
34
+ private dialog;
35
+ focus(): void;
36
+ overlayWillCloseCallback(): boolean;
37
+ private dismiss;
38
+ private clickSecondary;
39
+ private clickCancel;
40
+ private clickConfirm;
41
+ protected handleClose(event: Event): void;
42
+ close(): void;
43
+ private dispatchClosed;
44
+ protected handleUnderlayTransitionend(): void;
45
+ protected handleModalTransitionend(): void;
46
+ protected update(changes: PropertyValues<this>): void;
47
+ protected render(): TemplateResult;
48
+ protected updated(changes: PropertyValues<this>): void;
49
+ /**
50
+ * Bind the open/close transition into the update complete lifecycle so
51
+ * that the overlay system can wait for it to be "visibly ready" before
52
+ * attempting to throw focus into the content contained herein. Not
53
+ * waiting for this can cause small amounts of page scroll to happen
54
+ * while opening the Tray when focusable content is included: e.g. Menu
55
+ * elements whose selected Menu Item is not the first Menu Item.
56
+ */
57
+ protected getUpdateComplete(): Promise<boolean>;
58
+ }
59
+ export {};