@spectrum-web-components/dialog 0.10.8 → 0.10.9

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.
Files changed (47) hide show
  1. package/custom-elements.json +66 -6
  2. package/package.json +35 -16
  3. package/sp-dialog-wrapper.dev.js +3 -0
  4. package/sp-dialog-wrapper.dev.js.map +7 -0
  5. package/sp-dialog-wrapper.js +3 -14
  6. package/sp-dialog-wrapper.js.map +7 -1
  7. package/sp-dialog.dev.js +3 -0
  8. package/sp-dialog.dev.js.map +7 -0
  9. package/sp-dialog.js +3 -14
  10. package/sp-dialog.js.map +7 -1
  11. package/src/Dialog.d.ts +6 -0
  12. package/src/Dialog.dev.js +230 -0
  13. package/src/Dialog.dev.js.map +7 -0
  14. package/src/Dialog.js +214 -204
  15. package/src/Dialog.js.map +7 -1
  16. package/src/DialogWrapper.dev.js +262 -0
  17. package/src/DialogWrapper.dev.js.map +7 -0
  18. package/src/DialogWrapper.js +205 -239
  19. package/src/DialogWrapper.js.map +7 -1
  20. package/src/dialog.css.dev.js +99 -0
  21. package/src/dialog.css.dev.js.map +7 -0
  22. package/src/dialog.css.js +3 -14
  23. package/src/dialog.css.js.map +7 -1
  24. package/src/index.dev.js +3 -0
  25. package/src/index.dev.js.map +7 -0
  26. package/src/index.js +3 -14
  27. package/src/index.js.map +7 -1
  28. package/src/spectrum-dialog.css.dev.js +97 -0
  29. package/src/spectrum-dialog.css.dev.js.map +7 -0
  30. package/src/spectrum-dialog.css.js +3 -14
  31. package/src/spectrum-dialog.css.js.map +7 -1
  32. package/stories/dialog-wrapper.stories.js +76 -87
  33. package/stories/dialog-wrapper.stories.js.map +7 -1
  34. package/stories/dialog.stories.js +20 -31
  35. package/stories/dialog.stories.js.map +7 -1
  36. package/stories/images.js +3 -14
  37. package/stories/images.js.map +7 -1
  38. package/test/benchmark/basic-test.js +5 -16
  39. package/test/benchmark/basic-test.js.map +7 -1
  40. package/test/dialog-wrapper.test-vrt.js +4 -15
  41. package/test/dialog-wrapper.test-vrt.js.map +7 -1
  42. package/test/dialog-wrapper.test.js +160 -156
  43. package/test/dialog-wrapper.test.js.map +7 -1
  44. package/test/dialog.test-vrt.js +4 -15
  45. package/test/dialog.test-vrt.js.map +7 -1
  46. package/test/dialog.test.js +148 -54
  47. package/test/dialog.test.js.map +7 -1
@@ -4,7 +4,7 @@
4
4
  "modules": [
5
5
  {
6
6
  "kind": "javascript-module",
7
- "path": "sp-dialog-wrapper.ts",
7
+ "path": "sp-dialog-wrapper.js",
8
8
  "declarations": [],
9
9
  "exports": [
10
10
  {
@@ -19,7 +19,7 @@
19
19
  },
20
20
  {
21
21
  "kind": "javascript-module",
22
- "path": "sp-dialog.ts",
22
+ "path": "sp-dialog.js",
23
23
  "declarations": [],
24
24
  "exports": [
25
25
  {
@@ -34,7 +34,7 @@
34
34
  },
35
35
  {
36
36
  "kind": "javascript-module",
37
- "path": "src/Dialog.ts",
37
+ "path": "src/Dialog.js",
38
38
  "declarations": [
39
39
  {
40
40
  "kind": "class",
@@ -165,6 +165,66 @@
165
165
  }
166
166
  }
167
167
  },
168
+ {
169
+ "kind": "method",
170
+ "name": "renderHero",
171
+ "privacy": "protected",
172
+ "return": {
173
+ "type": {
174
+ "text": "TemplateResult"
175
+ }
176
+ }
177
+ },
178
+ {
179
+ "kind": "method",
180
+ "name": "renderHeading",
181
+ "privacy": "protected",
182
+ "return": {
183
+ "type": {
184
+ "text": "TemplateResult"
185
+ }
186
+ }
187
+ },
188
+ {
189
+ "kind": "method",
190
+ "name": "renderContent",
191
+ "privacy": "protected",
192
+ "return": {
193
+ "type": {
194
+ "text": "TemplateResult"
195
+ }
196
+ }
197
+ },
198
+ {
199
+ "kind": "method",
200
+ "name": "renderFooter",
201
+ "privacy": "protected",
202
+ "return": {
203
+ "type": {
204
+ "text": "TemplateResult"
205
+ }
206
+ }
207
+ },
208
+ {
209
+ "kind": "method",
210
+ "name": "renderButtons",
211
+ "privacy": "protected",
212
+ "return": {
213
+ "type": {
214
+ "text": "TemplateResult"
215
+ }
216
+ }
217
+ },
218
+ {
219
+ "kind": "method",
220
+ "name": "renderDismiss",
221
+ "privacy": "protected",
222
+ "return": {
223
+ "type": {
224
+ "text": "TemplateResult"
225
+ }
226
+ }
227
+ },
168
228
  {
169
229
  "kind": "field",
170
230
  "name": "shouldManageTabOrderForScrolling",
@@ -317,14 +377,14 @@
317
377
  "name": "Dialog",
318
378
  "declaration": {
319
379
  "name": "Dialog",
320
- "module": "src/Dialog.ts"
380
+ "module": "src/Dialog.js"
321
381
  }
322
382
  }
323
383
  ]
324
384
  },
325
385
  {
326
386
  "kind": "javascript-module",
327
- "path": "src/DialogWrapper.ts",
387
+ "path": "src/DialogWrapper.js",
328
388
  "declarations": [
329
389
  {
330
390
  "kind": "class",
@@ -817,7 +877,7 @@
817
877
  "name": "DialogWrapper",
818
878
  "declaration": {
819
879
  "name": "DialogWrapper",
820
- "module": "src/DialogWrapper.ts"
880
+ "module": "src/DialogWrapper.js"
821
881
  }
822
882
  }
823
883
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/dialog",
3
- "version": "0.10.8",
3
+ "version": "0.10.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,13 +20,32 @@
20
20
  "module": "./src/index.js",
21
21
  "type": "module",
22
22
  "exports": {
23
- ".": "./src/index.js",
24
- "./src/*": "./src/*",
23
+ ".": {
24
+ "development": "./src/index.dev.js",
25
+ "default": "./src/index.js"
26
+ },
25
27
  "./package.json": "./package.json",
26
- "./sp-dialog": "./sp-dialog.js",
27
- "./sp-dialog.js": "./sp-dialog.js",
28
- "./sp-dialog-wrapper": "./sp-dialog-wrapper.js",
29
- "./sp-dialog-wrapper.js": "./sp-dialog-wrapper.js"
28
+ "./src/Dialog.js": {
29
+ "development": "./src/Dialog.dev.js",
30
+ "default": "./src/Dialog.js"
31
+ },
32
+ "./src/DialogWrapper.js": {
33
+ "development": "./src/DialogWrapper.dev.js",
34
+ "default": "./src/DialogWrapper.js"
35
+ },
36
+ "./src/dialog.css.js": "./src/dialog.css.js",
37
+ "./src/index.js": {
38
+ "development": "./src/index.dev.js",
39
+ "default": "./src/index.js"
40
+ },
41
+ "./sp-dialog.js": {
42
+ "development": "./sp-dialog.dev.js",
43
+ "default": "./sp-dialog.js"
44
+ },
45
+ "./sp-dialog-wrapper.js": {
46
+ "development": "./sp-dialog-wrapper.dev.js",
47
+ "default": "./sp-dialog-wrapper.js"
48
+ }
30
49
  },
31
50
  "scripts": {
32
51
  "test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
@@ -46,14 +65,14 @@
46
65
  "lit-html"
47
66
  ],
48
67
  "dependencies": {
49
- "@spectrum-web-components/base": "^0.5.8",
50
- "@spectrum-web-components/button": "^0.18.0",
51
- "@spectrum-web-components/button-group": "^0.8.11",
52
- "@spectrum-web-components/divider": "^0.4.11",
53
- "@spectrum-web-components/icons-workflow": "^0.8.11",
54
- "@spectrum-web-components/modal": "^0.6.9",
55
- "@spectrum-web-components/shared": "^0.14.4",
56
- "@spectrum-web-components/underlay": "^0.8.10",
68
+ "@spectrum-web-components/base": "^0.6.0",
69
+ "@spectrum-web-components/button": "^0.18.1",
70
+ "@spectrum-web-components/button-group": "^0.8.12",
71
+ "@spectrum-web-components/divider": "^0.4.12",
72
+ "@spectrum-web-components/icons-workflow": "^0.8.12",
73
+ "@spectrum-web-components/modal": "^0.6.10",
74
+ "@spectrum-web-components/shared": "^0.14.5",
75
+ "@spectrum-web-components/underlay": "^0.8.11",
57
76
  "tslib": "^2.0.0"
58
77
  },
59
78
  "devDependencies": {
@@ -64,5 +83,5 @@
64
83
  "sideEffects": [
65
84
  "./sp-*.js"
66
85
  ],
67
- "gitHead": "3be62133721efba844cd7032566a2c49ed6d9875"
86
+ "gitHead": "50cac779bbb0d6735c2061f1eceb86b9daf9b22b"
68
87
  }
@@ -0,0 +1,3 @@
1
+ import { DialogWrapper } from "./src/DialogWrapper.dev.js";
2
+ customElements.define("sp-dialog-wrapper", DialogWrapper);
3
+ //# sourceMappingURL=sp-dialog-wrapper.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-dialog-wrapper.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*/\nimport { DialogWrapper } from './src/DialogWrapper.dev.js'\n\ncustomElements.define('sp-dialog-wrapper', DialogWrapper);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-dialog-wrapper': DialogWrapper;\n }\n}\n"],
5
+ "mappings": "AAWA;AAEA,eAAe,OAAO,qBAAqB,aAAa;",
6
+ "names": []
7
+ }
@@ -1,14 +1,3 @@
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
1
+ import { DialogWrapper } from "./src/DialogWrapper.js";
2
+ customElements.define("sp-dialog-wrapper", DialogWrapper);
3
+ //# sourceMappingURL=sp-dialog-wrapper.js.map
@@ -1 +1,7 @@
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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-dialog-wrapper.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*/\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"],
5
+ "mappings": "AAWA;AAEA,eAAe,OAAO,qBAAqB,aAAa;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import { Dialog } from "./src/Dialog.dev.js";
2
+ customElements.define("sp-dialog", Dialog);
3
+ //# sourceMappingURL=sp-dialog.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-dialog.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*/\nimport { Dialog } from './src/Dialog.dev.js'\n\ncustomElements.define('sp-dialog', Dialog);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-dialog': Dialog;\n }\n}\n"],
5
+ "mappings": "AAWA;AAEA,eAAe,OAAO,aAAa,MAAM;",
6
+ "names": []
7
+ }
package/sp-dialog.js CHANGED
@@ -1,14 +1,3 @@
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
1
+ import { Dialog } from "./src/Dialog.js";
2
+ customElements.define("sp-dialog", Dialog);
3
+ //# sourceMappingURL=sp-dialog.js.map
package/sp-dialog.js.map CHANGED
@@ -1 +1,7 @@
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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-dialog.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*/\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"],
5
+ "mappings": "AAWA;AAEA,eAAe,OAAO,aAAa,MAAM;",
6
+ "names": []
7
+ }
package/src/Dialog.d.ts CHANGED
@@ -31,6 +31,12 @@ export declare class Dialog extends Dialog_base {
31
31
  mode?: 'fullscreen' | 'fullscreenTakeover';
32
32
  size?: 's' | 'm' | 'l';
33
33
  close(): void;
34
+ protected renderHero(): TemplateResult;
35
+ protected renderHeading(): TemplateResult;
36
+ protected renderContent(): TemplateResult;
37
+ protected renderFooter(): TemplateResult;
38
+ protected renderButtons(): TemplateResult;
39
+ protected renderDismiss(): TemplateResult;
34
40
  protected render(): TemplateResult;
35
41
  shouldManageTabOrderForScrolling: () => void;
36
42
  protected shouldUpdate(changes: PropertyValues): boolean;
@@ -0,0 +1,230 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import {
13
+ html,
14
+ nothing,
15
+ SpectrumElement
16
+ } from "@spectrum-web-components/base";
17
+ import {
18
+ property,
19
+ query
20
+ } from "@spectrum-web-components/base/src/decorators.js";
21
+ import { classMap } from "@spectrum-web-components/base/src/directives.js";
22
+ import { conditionAttributeWithId } from "@spectrum-web-components/base/src/condition-attribute-with-id.js";
23
+ import "@spectrum-web-components/divider/sp-divider.js";
24
+ import "@spectrum-web-components/button/sp-close-button.js";
25
+ import "@spectrum-web-components/button-group/sp-button-group.js";
26
+ import "@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";
27
+ import {
28
+ FocusVisiblePolyfillMixin,
29
+ ObserveSlotPresence
30
+ } from "@spectrum-web-components/shared";
31
+ import styles from "./dialog.css.js";
32
+ function gatherAppliedIdsFromSlottedChildren(slot, idBase) {
33
+ const assignedElements = slot.assignedElements();
34
+ const ids = [];
35
+ assignedElements.forEach((el, i) => {
36
+ if (el.id) {
37
+ ids.push(el.id);
38
+ } else {
39
+ const id = idBase + `-${i}`;
40
+ el.id = id;
41
+ ids.push(id);
42
+ }
43
+ });
44
+ return ids;
45
+ }
46
+ const _Dialog = class extends FocusVisiblePolyfillMixin(ObserveSlotPresence(SpectrumElement, [
47
+ '[slot="hero"]',
48
+ '[slot="footer"]',
49
+ '[slot="button"]'
50
+ ])) {
51
+ constructor() {
52
+ super(...arguments);
53
+ this.error = false;
54
+ this.dismissable = false;
55
+ this.noDivider = false;
56
+ this.shouldManageTabOrderForScrolling = () => {
57
+ const { offsetHeight, scrollHeight } = this.contentElement;
58
+ if (offsetHeight < scrollHeight) {
59
+ this.contentElement.tabIndex = 0;
60
+ } else {
61
+ this.contentElement.removeAttribute("tabindex");
62
+ }
63
+ };
64
+ this.labelledbyId = `sp-dialog-label-${_Dialog.instanceCount++}`;
65
+ this.describedbyId = `sp-dialog-description-${_Dialog.instanceCount++}`;
66
+ }
67
+ static get styles() {
68
+ return [styles];
69
+ }
70
+ get hasFooter() {
71
+ return this.getSlotContentPresence('[slot="footer"]');
72
+ }
73
+ get hasButtons() {
74
+ return this.getSlotContentPresence('[slot="button"]');
75
+ }
76
+ get hasHero() {
77
+ return this.getSlotContentPresence('[slot="hero"]');
78
+ }
79
+ close() {
80
+ this.dispatchEvent(new Event("close", {
81
+ bubbles: true,
82
+ composed: true,
83
+ cancelable: true
84
+ }));
85
+ }
86
+ renderHero() {
87
+ return html`
88
+ <slot name="hero"></slot>
89
+ `;
90
+ }
91
+ renderHeading() {
92
+ return html`
93
+ <slot name="heading" @slotchange=${this.onHeadingSlotchange}></slot>
94
+ `;
95
+ }
96
+ renderContent() {
97
+ return html`
98
+ <div class="content">
99
+ <slot @slotchange=${this.onContentSlotChange}></slot>
100
+ </div>
101
+ `;
102
+ }
103
+ renderFooter() {
104
+ return html`
105
+ <div class="footer">
106
+ <slot name="footer"></slot>
107
+ </div>
108
+ `;
109
+ }
110
+ renderButtons() {
111
+ const classes = {
112
+ "button-group": true,
113
+ "button-group--noFooter": !this.hasFooter
114
+ };
115
+ return html`
116
+ <sp-button-group class=${classMap(classes)}>
117
+ <slot name="button"></slot>
118
+ </sp-button-group>
119
+ `;
120
+ }
121
+ renderDismiss() {
122
+ return html`
123
+ <sp-close-button
124
+ class="close-button"
125
+ label="Close"
126
+ quiet
127
+ size="m"
128
+ @click=${this.close}
129
+ ></sp-close-button>
130
+ `;
131
+ }
132
+ render() {
133
+ return html`
134
+ <div class="grid">
135
+ ${this.renderHero()} ${this.renderHeading()}
136
+ ${this.error ? html`
137
+ <sp-icon-alert class="type-icon"></sp-icon-alert>
138
+ ` : nothing}
139
+ ${this.noDivider ? nothing : html`
140
+ <sp-divider size="m" class="divider"></sp-divider>
141
+ `}
142
+ ${this.renderContent()}
143
+ ${this.hasFooter ? this.renderFooter() : nothing}
144
+ ${this.hasButtons ? this.renderButtons() : nothing}
145
+ ${this.dismissable ? this.renderDismiss() : nothing}
146
+ </div>
147
+ `;
148
+ }
149
+ shouldUpdate(changes) {
150
+ if (changes.has("mode") && !!this.mode) {
151
+ this.dismissable = false;
152
+ }
153
+ if (changes.has("dismissable") && this.dismissable) {
154
+ this.dismissable = !this.mode;
155
+ }
156
+ return super.shouldUpdate(changes);
157
+ }
158
+ firstUpdated(changes) {
159
+ super.firstUpdated(changes);
160
+ this.setAttribute("role", "dialog");
161
+ }
162
+ onHeadingSlotchange({
163
+ target
164
+ }) {
165
+ if (this.conditionLabelledby) {
166
+ this.conditionLabelledby();
167
+ delete this.conditionLabelledby;
168
+ }
169
+ const ids = gatherAppliedIdsFromSlottedChildren(target, this.labelledbyId);
170
+ if (ids.length) {
171
+ this.conditionLabelledby = conditionAttributeWithId(this, "aria-labelledby", ids);
172
+ }
173
+ }
174
+ onContentSlotChange({
175
+ target
176
+ }) {
177
+ if (this.conditionDescribedby) {
178
+ this.conditionDescribedby();
179
+ delete this.conditionDescribedby;
180
+ }
181
+ const ids = gatherAppliedIdsFromSlottedChildren(target, this.describedbyId);
182
+ if (ids.length && ids.length < 4) {
183
+ this.conditionDescribedby = conditionAttributeWithId(this, "aria-describedby", ids);
184
+ } else if (!ids.length) {
185
+ const idProvided = !!this.id;
186
+ if (!idProvided)
187
+ this.id = this.describedbyId;
188
+ const conditionDescribedby = conditionAttributeWithId(this, "aria-describedby", this.id);
189
+ this.conditionDescribedby = () => {
190
+ conditionDescribedby();
191
+ if (!idProvided) {
192
+ this.removeAttribute("id");
193
+ }
194
+ };
195
+ }
196
+ }
197
+ connectedCallback() {
198
+ super.connectedCallback();
199
+ this.tabIndex = 0;
200
+ window.addEventListener("resize", this.shouldManageTabOrderForScrolling);
201
+ }
202
+ disconnectedCallback() {
203
+ window.removeEventListener("resize", this.shouldManageTabOrderForScrolling);
204
+ super.disconnectedCallback();
205
+ }
206
+ };
207
+ export let Dialog = _Dialog;
208
+ Dialog.instanceCount = 0;
209
+ __decorateClass([
210
+ query(".close-button")
211
+ ], Dialog.prototype, "closeButton", 2);
212
+ __decorateClass([
213
+ query(".content")
214
+ ], Dialog.prototype, "contentElement", 2);
215
+ __decorateClass([
216
+ property({ type: Boolean, reflect: true })
217
+ ], Dialog.prototype, "error", 2);
218
+ __decorateClass([
219
+ property({ type: Boolean, reflect: true })
220
+ ], Dialog.prototype, "dismissable", 2);
221
+ __decorateClass([
222
+ property({ type: Boolean, reflect: true, attribute: "no-divider" })
223
+ ], Dialog.prototype, "noDivider", 2);
224
+ __decorateClass([
225
+ property({ type: String, reflect: true })
226
+ ], Dialog.prototype, "mode", 2);
227
+ __decorateClass([
228
+ property({ type: String, reflect: true })
229
+ ], Dialog.prototype, "size", 2);
230
+ //# sourceMappingURL=Dialog.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["Dialog.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 nothing,\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 { classMap } 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/button/sp-close-button.js';\nimport '@spectrum-web-components/button-group/sp-button-group.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 { CloseButton } from '@spectrum-web-components/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 override get styles(): CSSResultArray {\n return [styles];\n }\n\n @query('.close-button')\n closeButton?: CloseButton;\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 renderHero(): TemplateResult {\n return html`\n <slot name=\"hero\"></slot>\n `;\n }\n\n protected renderHeading(): TemplateResult {\n return html`\n <slot name=\"heading\" @slotchange=${this.onHeadingSlotchange}></slot>\n `;\n }\n\n protected renderContent(): TemplateResult {\n return html`\n <div class=\"content\">\n <slot @slotchange=${this.onContentSlotChange}></slot>\n </div>\n `;\n }\n\n protected renderFooter(): TemplateResult {\n return html`\n <div class=\"footer\">\n <slot name=\"footer\"></slot>\n </div>\n `;\n }\n\n protected renderButtons(): TemplateResult {\n const classes = {\n 'button-group': true,\n 'button-group--noFooter': !this.hasFooter,\n };\n return html`\n <sp-button-group class=${classMap(classes)}>\n <slot name=\"button\"></slot>\n </sp-button-group>\n `;\n }\n\n protected renderDismiss(): TemplateResult {\n return html`\n <sp-close-button\n class=\"close-button\"\n label=\"Close\"\n quiet\n size=\"m\"\n @click=${this.close}\n ></sp-close-button>\n `;\n }\n\n protected override render(): TemplateResult {\n return html`\n <div class=\"grid\">\n ${this.renderHero()} ${this.renderHeading()}\n ${this.error\n ? html`\n <sp-icon-alert class=\"type-icon\"></sp-icon-alert>\n `\n : nothing}\n ${this.noDivider\n ? nothing\n : html`\n <sp-divider size=\"m\" class=\"divider\"></sp-divider>\n `}\n ${this.renderContent()}\n ${this.hasFooter ? this.renderFooter() : nothing}\n ${this.hasButtons ? this.renderButtons() : nothing}\n ${this.dismissable ? this.renderDismiss() : nothing}\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 override 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 override 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 override connectedCallback(): void {\n super.connectedCallback();\n this.tabIndex = 0;\n window.addEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n }\n\n public override disconnectedCallback(): void {\n window.removeEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n super.disconnectedCallback();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAAA;AAQA;AAAA;AAAA;AAAA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAKA;AAGA,6CACI,MACA,QACQ;AACR,QAAM,mBAAmB,KAAK,iBAAiB;AAC/C,QAAM,MAAgB,CAAC;AACvB,mBAAiB,QAAQ,CAAC,IAAI,MAAM;AAChC,QAAI,GAAG,IAAI;AACP,UAAI,KAAK,GAAG,EAAE;AAAA,IAClB,OAAO;AACH,YAAM,KAAK,SAAS,IAAI;AACxB,SAAG,KAAK;AACR,UAAI,KAAK,EAAE;AAAA,IACf;AAAA,EACJ,CAAC;AACD,SAAO;AACX;AAYO,8BAAqB,0BACxB,oBAAoB,iBAAiB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACJ,CAAC,CACL,EAAE;AAAA,EANK;AAAA;AAkBI,iBAAQ;AAGR,uBAAc;AAed,qBAAY;AA4FZ,4CAAmC,MAAY;AAClD,YAAM,EAAE,cAAc,iBAAiB,KAAK;AAC5C,UAAI,eAAe,cAAc;AAC7B,aAAK,eAAe,WAAW;AAAA,MACnC,OAAO;AACH,aAAK,eAAe,gBAAgB,UAAU;AAAA,MAClD;AAAA,IACJ;AAkBQ,wBAAe,mBAAmB,QAAO;AAwBzC,yBAAgB,yBAAyB,QAAO;AAAA;AAAA,aA1K7B,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,MA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