@spectrum-web-components/dialog 0.10.9-devmode.0 → 0.10.10-devmode.0

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.
@@ -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.9-devmode.0+07474d44f",
3
+ "version": "0.10.10-devmode.0+1a8b29491",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -65,14 +65,14 @@
65
65
  "lit-html"
66
66
  ],
67
67
  "dependencies": {
68
- "@spectrum-web-components/base": "^0.5.9-devmode.24+07474d44f",
69
- "@spectrum-web-components/button": "^0.18.1-devmode.0+07474d44f",
70
- "@spectrum-web-components/button-group": "^0.8.12-devmode.0+07474d44f",
71
- "@spectrum-web-components/divider": "^0.4.12-devmode.0+07474d44f",
72
- "@spectrum-web-components/icons-workflow": "^0.8.12-devmode.0+07474d44f",
73
- "@spectrum-web-components/modal": "^0.6.10-devmode.0+07474d44f",
74
- "@spectrum-web-components/shared": "^0.14.5-devmode.0+07474d44f",
75
- "@spectrum-web-components/underlay": "^0.8.11-devmode.0+07474d44f",
68
+ "@spectrum-web-components/base": "^0.6.1-devmode.0+1a8b29491",
69
+ "@spectrum-web-components/button": "^0.18.2-devmode.0+1a8b29491",
70
+ "@spectrum-web-components/button-group": "^0.8.13-devmode.0+1a8b29491",
71
+ "@spectrum-web-components/divider": "^0.4.13-devmode.0+1a8b29491",
72
+ "@spectrum-web-components/icons-workflow": "^0.8.13-devmode.0+1a8b29491",
73
+ "@spectrum-web-components/modal": "^0.6.11-devmode.0+1a8b29491",
74
+ "@spectrum-web-components/shared": "^0.14.6-devmode.0+1a8b29491",
75
+ "@spectrum-web-components/underlay": "^0.8.12-devmode.0+1a8b29491",
76
76
  "tslib": "^2.0.0"
77
77
  },
78
78
  "devDependencies": {
@@ -81,7 +81,8 @@
81
81
  "types": "./src/index.d.ts",
82
82
  "customElements": "custom-elements.json",
83
83
  "sideEffects": [
84
- "./sp-*.js"
84
+ "./sp-*.js",
85
+ "./**/*.dev.js"
85
86
  ],
86
- "gitHead": "07474d44f6cee1db241b9ccf3dc812514ffbe7fa"
87
+ "gitHead": "1a8b294911ab377fa4f07e16eb016f1e3bf7b517"
87
88
  }
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;
package/src/Dialog.dev.js CHANGED
@@ -11,13 +11,14 @@ var __decorateClass = (decorators, target, key, kind) => {
11
11
  };
12
12
  import {
13
13
  html,
14
+ nothing,
14
15
  SpectrumElement
15
16
  } from "@spectrum-web-components/base";
16
17
  import {
17
18
  property,
18
19
  query
19
20
  } from "@spectrum-web-components/base/src/decorators.js";
20
- import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
21
+ import { classMap } from "@spectrum-web-components/base/src/directives.js";
21
22
  import { conditionAttributeWithId } from "@spectrum-web-components/base/src/condition-attribute-with-id.js";
22
23
  import "@spectrum-web-components/divider/sp-divider.js";
23
24
  import "@spectrum-web-components/button/sp-close-button.js";
@@ -82,45 +83,66 @@ const _Dialog = class extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spec
82
83
  cancelable: true
83
84
  }));
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
+ }
85
132
  render() {
86
133
  return html`
87
134
  <div class="grid">
88
- <slot name="hero"></slot>
89
- <slot
90
- name="heading"
91
- class=${ifDefined(this.hasHero ? this.hasHero : void 0)}
92
- @slotchange=${this.onHeadingSlotchange}
93
- ></slot>
135
+ ${this.renderHero()} ${this.renderHeading()}
94
136
  ${this.error ? html`
95
137
  <sp-icon-alert class="type-icon"></sp-icon-alert>
96
- ` : html``}
97
- ${this.noDivider ? html`` : html`
138
+ ` : nothing}
139
+ ${this.noDivider ? nothing : html`
98
140
  <sp-divider size="m" class="divider"></sp-divider>
99
141
  `}
100
- <div class="content">
101
- <slot @slotchange=${this.onContentSlotChange}></slot>
102
- </div>
103
- ${this.hasFooter ? html`
104
- <div class="footer">
105
- <slot name="footer"></slot>
106
- </div>
107
- ` : html``}
108
- ${this.hasButtons ? html`
109
- <sp-button-group
110
- class="button-group ${this.hasFooter ? "" : "button-group--noFooter"}"
111
- >
112
- <slot name="button"></slot>
113
- </sp-button-group>
114
- ` : html``}
115
- ${this.dismissable ? html`
116
- <sp-close-button
117
- class="close-button"
118
- label="Close"
119
- quiet
120
- size="m"
121
- @click=${this.close}
122
- ></sp-close-button>
123
- ` : html``}
142
+ ${this.renderContent()}
143
+ ${this.hasFooter ? this.renderFooter() : nothing}
144
+ ${this.hasButtons ? this.renderButtons() : nothing}
145
+ ${this.dismissable ? this.renderDismiss() : nothing}
124
146
  </div>
125
147
  `;
126
148
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 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/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 override 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-close-button\n class=\"close-button\"\n label=\"Close\"\n quiet\n size=\"m\"\n @click=${this.close}\n ></sp-close-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 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;AAOA;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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T;AACA,WAAK,uBAAuB,MAAM;AAC9B,6BAAqB;AACrB,YAAI,CAAC,YAAY;AACb,eAAK,gBAAgB,IAAI;AAAA,QAC7B;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAAA,EAEgB,oBAA0B;AACtC,UAAM,kBAAkB;AACxB,SAAK,WAAW;AAChB,WAAO,iBACH,UACA,KAAK,gCACT;AAAA,EACJ;AAAA,EAEgB,uBAA6B;AACzC,WAAO,oBACH,UACA,KAAK,gCACT;AACA,UAAM,qBAAqB;AAAA,EAC/B;AACJ;AAlNO;AAqII,AArIJ,OAqII,gBAAgB;AAzHvB;AAAA,EADA,AAAC,MAAM,eAAe;AAAA,GACtB,AAZG,OAYH;AAGQ;AAAA,EADR,AAAC,MAAM,UAAU;AAAA,GACT,AAfL,OAeK;AAGD;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AAlBJ,OAkBI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AArBJ,OAqBI;AAeA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,aAAa,CAAC;AAAA,GAC5D,AApCJ,OAoCI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AAvCJ,OAuCI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AA1CJ,OA0CI;",
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,MAcc,YAAqB;AAC/B,WAAO,KAAK,uBAAuB,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;AAAA,EAEgB,uBAA6B;AACzC,WAAO,oBACH,UACA,KAAK,gCACT;AACA,UAAM,qBAAqB;AAAA,EAC/B;AACJ;AArOO;AAwJI,AAxJJ,OAwJI,gBAAgB;AA5IvB;AAAA,EADA,AAAC,MAAM,eAAe;AAAA,GACtB,AAZG,OAYH;AAGQ;AAAA,EADR,AAAC,MAAM,UAAU;AAAA,GACT,AAfL,OAeK;AAGD;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AAlBJ,OAkBI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AArBJ,OAqBI;AAeA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,aAAa,CAAC;AAAA,GAC5D,AApCJ,OAoCI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AAvCJ,OAuCI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AA1CJ,OA0CI;",
6
6
  "names": []
7
7
  }
package/src/Dialog.js CHANGED
@@ -11,13 +11,14 @@ var __decorateClass = (decorators, target, key, kind) => {
11
11
  };
12
12
  import {
13
13
  html,
14
+ nothing,
14
15
  SpectrumElement
15
16
  } from "@spectrum-web-components/base";
16
17
  import {
17
18
  property,
18
19
  query
19
20
  } from "@spectrum-web-components/base/src/decorators.js";
20
- import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
21
+ import { classMap } from "@spectrum-web-components/base/src/directives.js";
21
22
  import { conditionAttributeWithId } from "@spectrum-web-components/base/src/condition-attribute-with-id.js";
22
23
  import "@spectrum-web-components/divider/sp-divider.js";
23
24
  import "@spectrum-web-components/button/sp-close-button.js";
@@ -82,45 +83,66 @@ const _Dialog = class extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spec
82
83
  cancelable: true
83
84
  }));
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
+ }
85
132
  render() {
86
133
  return html`
87
134
  <div class="grid">
88
- <slot name="hero"></slot>
89
- <slot
90
- name="heading"
91
- class=${ifDefined(this.hasHero ? this.hasHero : void 0)}
92
- @slotchange=${this.onHeadingSlotchange}
93
- ></slot>
135
+ ${this.renderHero()} ${this.renderHeading()}
94
136
  ${this.error ? html`
95
137
  <sp-icon-alert class="type-icon"></sp-icon-alert>
96
- ` : html``}
97
- ${this.noDivider ? html`` : html`
138
+ ` : nothing}
139
+ ${this.noDivider ? nothing : html`
98
140
  <sp-divider size="m" class="divider"></sp-divider>
99
141
  `}
100
- <div class="content">
101
- <slot @slotchange=${this.onContentSlotChange}></slot>
102
- </div>
103
- ${this.hasFooter ? html`
104
- <div class="footer">
105
- <slot name="footer"></slot>
106
- </div>
107
- ` : html``}
108
- ${this.hasButtons ? html`
109
- <sp-button-group
110
- class="button-group ${this.hasFooter ? "" : "button-group--noFooter"}"
111
- >
112
- <slot name="button"></slot>
113
- </sp-button-group>
114
- ` : html``}
115
- ${this.dismissable ? html`
116
- <sp-close-button
117
- class="close-button"
118
- label="Close"
119
- quiet
120
- size="m"
121
- @click=${this.close}
122
- ></sp-close-button>
123
- ` : html``}
142
+ ${this.renderContent()}
143
+ ${this.hasFooter ? this.renderFooter() : nothing}
144
+ ${this.hasButtons ? this.renderButtons() : nothing}
145
+ ${this.dismissable ? this.renderDismiss() : nothing}
124
146
  </div>
125
147
  `;
126
148
  }
package/src/Dialog.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 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/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 override 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-close-button\n class=\"close-button\"\n label=\"Close\"\n quiet\n size=\"m\"\n @click=${this.close}\n ></sp-close-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 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;AAOA;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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CACT;AAAA,EACJ;AAAA,EAEgB,uBAA6B;AACzC,WAAO,oBACH,UACA,KAAK,gCACT;AACA,UAAM,qBAAqB;AAAA,EAC/B;AACJ;AAlNO;AAqII,AArIJ,OAqII,gBAAgB;AAzHvB;AAAA,EADA,AAAC,MAAM,eAAe;AAAA,GACtB,AAZG,OAYH;AAGQ;AAAA,EADR,AAAC,MAAM,UAAU;AAAA,GACT,AAfL,OAeK;AAGD;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AAlBJ,OAkBI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AArBJ,OAqBI;AAeA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,aAAa,CAAC;AAAA,GAC5D,AApCJ,OAoCI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AAvCJ,OAuCI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AA1CJ,OA0CI;",
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.shouldManageTab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AAA,GACT,AAfL,OAeK;AAGD;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AAlBJ,OAkBI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AArBJ,OAqBI;AAeA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,aAAa,CAAC;AAAA,GAC5D,AApCJ,OAoCI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AAvCJ,OAuCI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AA1CJ,OA0CI;",
6
6
  "names": []
7
7
  }
@@ -19,6 +19,7 @@ import {
19
19
  wrapperLabeledHero
20
20
  } from "../stories/dialog-wrapper.stories.js";
21
21
  import { html } from "@spectrum-web-components/base";
22
+ import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
22
23
  async function styledFixture(story) {
23
24
  const test = await fixture(html`
24
25
  <sp-theme theme="classic" scale="medium" color="dark">
@@ -28,6 +29,7 @@ async function styledFixture(story) {
28
29
  return test.children[0];
29
30
  }
30
31
  describe("Dialog Wrapper", () => {
32
+ testForLitDevWarnings(async () => await styledFixture(wrapperDismissable()));
31
33
  it("loads wrapped dialog accessibly", async () => {
32
34
  const el = await styledFixture(wrapperDismissable());
33
35
  await elementUpdated(el);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["dialog-wrapper.test.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 elementUpdated,\n expect,\n fixture,\n nextFrame,\n oneEvent,\n} from '@open-wc/testing';\nimport { spy } from 'sinon';\n\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport '@spectrum-web-components/dialog/sp-dialog-wrapper.js';\nimport { Dialog, DialogWrapper } from '@spectrum-web-components/dialog';\nimport { ActionButton } from '@spectrum-web-components/action-button';\nimport { Button } from '@spectrum-web-components/button';\nimport { Underlay } from '@spectrum-web-components/underlay';\nimport {\n longContent,\n wrapperButtons,\n wrapperButtonsUnderlay,\n wrapperDismissable,\n wrapperDismissableUnderlayError,\n wrapperFullscreen,\n wrapperLabeledHero,\n} from '../stories/dialog-wrapper.stories.js';\nimport { OverlayTrigger } from '@spectrum-web-components/overlay';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { Theme } from '@spectrum-web-components/theme';\n\nasync function styledFixture<T extends Element>(\n story: TemplateResult\n): Promise<T> {\n const test = await fixture<Theme>(html`\n <sp-theme theme=\"classic\" scale=\"medium\" color=\"dark\">\n ${story}\n </sp-theme>\n `);\n return test.children[0] as T;\n}\n\ndescribe('Dialog Wrapper', () => {\n it('loads wrapped dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperDismissable());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads labeled hero dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperLabeledHero());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads fullscreen wrapped dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperFullscreen());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n xit('loads with underlay and no headline accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtonsUnderlay());\n await elementUpdated(el);\n el.headline = '';\n await elementUpdated(el);\n await expect(el).to.be.accessible();\n });\n it('opens and closes', async () => {\n const closeSpy = spy();\n const test = await styledFixture<OverlayTrigger>(longContent());\n const el = test.querySelector('sp-dialog-wrapper') as DialogWrapper;\n el.addEventListener('close', () => closeSpy());\n\n await elementUpdated(el);\n\n const opened = oneEvent(test, 'sp-opened');\n test.open = 'click';\n await opened;\n\n expect(el.open).to.be.true;\n\n const closed = oneEvent(test, 'sp-closed');\n test.open = undefined;\n await closed;\n await nextFrame();\n\n expect(el.open).to.be.false;\n expect(closeSpy.callCount).to.equal(1);\n });\n it('dismisses via clicking the underlay when [dismissable]', async () => {\n const test = await styledFixture<DialogWrapper>(\n wrapperDismissableUnderlayError()\n );\n const el = test.querySelector('sp-dialog-wrapper') as DialogWrapper;\n await elementUpdated(el);\n expect(el.open).to.be.true;\n el.dismissable = true;\n const underlay = el.shadowRoot.querySelector('sp-underlay') as Underlay;\n underlay.click();\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('does not dismiss via clicking the underlay :not([dismissable])', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtonsUnderlay());\n await elementUpdated(el);\n expect(el.open).to.be.true;\n const underlay = el.shadowRoot.querySelector('sp-underlay') as Underlay;\n underlay.click();\n await elementUpdated(el);\n expect(el.open).to.be.true;\n });\n it('dismisses', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperDismissable());\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n\n const root = el.shadowRoot ? el.shadowRoot : el;\n const dialog = root.querySelector('sp-dialog') as Dialog;\n const dialogRoot = dialog.shadowRoot ? dialog.shadowRoot : dialog;\n const dismissButton = dialogRoot.querySelector(\n '.close-button'\n ) as HTMLButtonElement;\n dismissButton.click();\n\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('manages entry focus - dismissable', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperDismissable());\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n expect(document.activeElement !== el, 'no focused').to.be.true;\n\n const dialog = el.shadowRoot.querySelector('sp-dialog') as Dialog;\n const dialogRoot = dialog.shadowRoot ? dialog.shadowRoot : dialog;\n const dismissButton = dialogRoot.querySelector(\n '.close-button'\n ) as ActionButton;\n\n el.focus();\n await elementUpdated(el);\n expect(\n document.activeElement === el,\n `focused generally, ${document.activeElement}`\n ).to.be.true;\n expect(\n (dismissButton.getRootNode() as Document).activeElement !==\n dismissButton,\n `does not focus specifically, ${\n (dismissButton.getRootNode() as Document).activeElement\n }`\n ).to.be.true;\n\n dismissButton.click();\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('manages entry focus - buttons', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtons());\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n expect(document.activeElement !== el, 'no focused').to.be.true;\n\n const button = el.shadowRoot.querySelector('sp-button') as Button;\n\n el.focus();\n await elementUpdated(el);\n expect(\n document.activeElement === el,\n `focused generally, ${document.activeElement}`\n ).to.be.true;\n expect(\n (button.getRootNode() as Document).activeElement === button,\n `focused specifically, ${\n (button.getRootNode() as Document).activeElement?.outerHTML\n }`\n ).to.be.true;\n });\n it('dispatches `confirm`, `cancel` and `secondary`', async () => {\n const confirmSpy = spy();\n const cancelSpy = spy();\n const secondarySpy = spy();\n const handleConfirm = (): void => confirmSpy();\n const handleCancel = (): void => cancelSpy();\n const handleSecondary = (): void => secondarySpy();\n const el = await styledFixture<DialogWrapper>(wrapperButtons());\n el.addEventListener('confirm', handleConfirm);\n el.addEventListener('cancel', handleCancel);\n el.addEventListener('secondary', handleSecondary);\n\n await elementUpdated(el);\n expect(confirmSpy.called).to.be.false;\n expect(cancelSpy.called).to.be.false;\n expect(secondarySpy.called).to.be.false;\n\n const accentButton = el.shadowRoot.querySelector(\n '[variant=\"accent\"]'\n ) as Button;\n const primaryButton = el.shadowRoot.querySelector(\n '[variant=\"primary\"]'\n ) as Button;\n const secondaryButton = el.shadowRoot.querySelector(\n '[variant=\"secondary\"]'\n ) as Button;\n\n accentButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.called, 'dispatched `confirm`').to.be.true;\n expect(secondarySpy.called).to.be.false;\n expect(cancelSpy.called).to.be.false;\n\n primaryButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.callCount).to.equal(1);\n expect(secondarySpy.called, 'dispatched `cancel`').to.be.true;\n expect(cancelSpy.called).to.be.false;\n\n secondaryButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.callCount).to.equal(1);\n expect(secondarySpy.callCount).to.equal(1);\n expect(cancelSpy.called, 'dispatched `secondary`').to.be.true;\n });\n});\n"],
5
- "mappings": "AAYA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA;AAEA;AACA;AACA;AAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AAGA,6BACI,OACU;AACV,QAAM,OAAO,MAAM,QAAe;AAAA;AAAA,cAExB;AAAA;AAAA,KAET;AACD,SAAO,KAAK,SAAS;AACzB;AAEA,SAAS,kBAAkB,MAAM;AAC7B,KAAG,mCAAmC,YAAY;AAC9C,UAAM,KAAK,MAAM,cAA6B,mBAAmB,CAAC;AAElE,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,wCAAwC,YAAY;AACnD,UAAM,KAAK,MAAM,cAA6B,mBAAmB,CAAC;AAElE,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,8CAA8C,YAAY;AACzD,UAAM,KAAK,MAAM,cAA6B,kBAAkB,CAAC;AAEjE,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,MAAI,kDAAkD,YAAY;AAC9D,UAAM,KAAK,MAAM,cAA6B,uBAAuB,CAAC;AAC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qBAAqB,EAAE,GAAG,GAAG;AACzD,WAAO,UAAU,MAAM,EAAE,GAAG,GAAG;AAE/B,oBAAgB,MAAM;AAEtB,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,SAAS,EAAE,GAAG,MAAM,CAAC;AACvC,WAAO,aAAa,SAAS,EAAE,GAAG,MAAM,CAAC;AACzC,WAAO,UAAU,QAAQ,wBAAwB,EAAE,GAAG,GAAG;AAAA,EAC7D,CAAC;AACL,CAAC;",
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 elementUpdated,\n expect,\n fixture,\n nextFrame,\n oneEvent,\n} from '@open-wc/testing';\nimport { spy } from 'sinon';\n\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport '@spectrum-web-components/dialog/sp-dialog-wrapper.js';\nimport { Dialog, DialogWrapper } from '@spectrum-web-components/dialog';\nimport { ActionButton } from '@spectrum-web-components/action-button';\nimport { Button } from '@spectrum-web-components/button';\nimport { Underlay } from '@spectrum-web-components/underlay';\nimport {\n longContent,\n wrapperButtons,\n wrapperButtonsUnderlay,\n wrapperDismissable,\n wrapperDismissableUnderlayError,\n wrapperFullscreen,\n wrapperLabeledHero,\n} from '../stories/dialog-wrapper.stories.js';\nimport { OverlayTrigger } from '@spectrum-web-components/overlay';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { Theme } from '@spectrum-web-components/theme';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\nasync function styledFixture<T extends Element>(\n story: TemplateResult\n): Promise<T> {\n const test = await fixture<Theme>(html`\n <sp-theme theme=\"classic\" scale=\"medium\" color=\"dark\">\n ${story}\n </sp-theme>\n `);\n return test.children[0] as T;\n}\n\ndescribe('Dialog Wrapper', () => {\n testForLitDevWarnings(\n async () => await styledFixture<DialogWrapper>(wrapperDismissable())\n );\n it('loads wrapped dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperDismissable());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads labeled hero dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperLabeledHero());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads fullscreen wrapped dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperFullscreen());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n xit('loads with underlay and no headline accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtonsUnderlay());\n await elementUpdated(el);\n el.headline = '';\n await elementUpdated(el);\n await expect(el).to.be.accessible();\n });\n it('opens and closes', async () => {\n const closeSpy = spy();\n const test = await styledFixture<OverlayTrigger>(longContent());\n const el = test.querySelector('sp-dialog-wrapper') as DialogWrapper;\n el.addEventListener('close', () => closeSpy());\n\n await elementUpdated(el);\n\n const opened = oneEvent(test, 'sp-opened');\n test.open = 'click';\n await opened;\n\n expect(el.open).to.be.true;\n\n const closed = oneEvent(test, 'sp-closed');\n test.open = undefined;\n await closed;\n await nextFrame();\n\n expect(el.open).to.be.false;\n expect(closeSpy.callCount).to.equal(1);\n });\n it('dismisses via clicking the underlay when [dismissable]', async () => {\n const test = await styledFixture<DialogWrapper>(\n wrapperDismissableUnderlayError()\n );\n const el = test.querySelector('sp-dialog-wrapper') as DialogWrapper;\n await elementUpdated(el);\n expect(el.open).to.be.true;\n el.dismissable = true;\n const underlay = el.shadowRoot.querySelector('sp-underlay') as Underlay;\n underlay.click();\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('does not dismiss via clicking the underlay :not([dismissable])', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtonsUnderlay());\n await elementUpdated(el);\n expect(el.open).to.be.true;\n const underlay = el.shadowRoot.querySelector('sp-underlay') as Underlay;\n underlay.click();\n await elementUpdated(el);\n expect(el.open).to.be.true;\n });\n it('dismisses', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperDismissable());\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n\n const root = el.shadowRoot ? el.shadowRoot : el;\n const dialog = root.querySelector('sp-dialog') as Dialog;\n const dialogRoot = dialog.shadowRoot ? dialog.shadowRoot : dialog;\n const dismissButton = dialogRoot.querySelector(\n '.close-button'\n ) as HTMLButtonElement;\n dismissButton.click();\n\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('manages entry focus - dismissable', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperDismissable());\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n expect(document.activeElement !== el, 'no focused').to.be.true;\n\n const dialog = el.shadowRoot.querySelector('sp-dialog') as Dialog;\n const dialogRoot = dialog.shadowRoot ? dialog.shadowRoot : dialog;\n const dismissButton = dialogRoot.querySelector(\n '.close-button'\n ) as ActionButton;\n\n el.focus();\n await elementUpdated(el);\n expect(\n document.activeElement === el,\n `focused generally, ${document.activeElement}`\n ).to.be.true;\n expect(\n (dismissButton.getRootNode() as Document).activeElement !==\n dismissButton,\n `does not focus specifically, ${\n (dismissButton.getRootNode() as Document).activeElement\n }`\n ).to.be.true;\n\n dismissButton.click();\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('manages entry focus - buttons', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtons());\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n expect(document.activeElement !== el, 'no focused').to.be.true;\n\n const button = el.shadowRoot.querySelector('sp-button') as Button;\n\n el.focus();\n await elementUpdated(el);\n expect(\n document.activeElement === el,\n `focused generally, ${document.activeElement}`\n ).to.be.true;\n expect(\n (button.getRootNode() as Document).activeElement === button,\n `focused specifically, ${\n (button.getRootNode() as Document).activeElement?.outerHTML\n }`\n ).to.be.true;\n });\n it('dispatches `confirm`, `cancel` and `secondary`', async () => {\n const confirmSpy = spy();\n const cancelSpy = spy();\n const secondarySpy = spy();\n const handleConfirm = (): void => confirmSpy();\n const handleCancel = (): void => cancelSpy();\n const handleSecondary = (): void => secondarySpy();\n const el = await styledFixture<DialogWrapper>(wrapperButtons());\n el.addEventListener('confirm', handleConfirm);\n el.addEventListener('cancel', handleCancel);\n el.addEventListener('secondary', handleSecondary);\n\n await elementUpdated(el);\n expect(confirmSpy.called).to.be.false;\n expect(cancelSpy.called).to.be.false;\n expect(secondarySpy.called).to.be.false;\n\n const accentButton = el.shadowRoot.querySelector(\n '[variant=\"accent\"]'\n ) as Button;\n const primaryButton = el.shadowRoot.querySelector(\n '[variant=\"primary\"]'\n ) as Button;\n const secondaryButton = el.shadowRoot.querySelector(\n '[variant=\"secondary\"]'\n ) as Button;\n\n accentButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.called, 'dispatched `confirm`').to.be.true;\n expect(secondarySpy.called).to.be.false;\n expect(cancelSpy.called).to.be.false;\n\n primaryButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.callCount).to.equal(1);\n expect(secondarySpy.called, 'dispatched `cancel`').to.be.true;\n expect(cancelSpy.called).to.be.false;\n\n secondaryButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.callCount).to.equal(1);\n expect(secondarySpy.callCount).to.equal(1);\n expect(cancelSpy.called, 'dispatched `secondary`').to.be.true;\n });\n});\n"],
5
+ "mappings": "AAYA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA;AAEA;AACA;AACA;AAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AAEA;AAEA,6BACI,OACU;AACV,QAAM,OAAO,MAAM,QAAe;AAAA;AAAA,cAExB;AAAA;AAAA,KAET;AACD,SAAO,KAA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AAa;AAC5C,OAAG,iBAAiB,UAAU,YAAY;AAC1C,OAAG,iBAAiB,aAAa,eAAe;AAEhD,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,MAAM,EAAE,GAAG,GAAG;AAChC,WAAO,UAAU,MAAM,EAAE,GAAG,GAAG;AAC/B,WAAO,aAAa,MAAM,EAAE,GAAG,GAAG;AAElC,UAAM,eAAe,GAAG,WAAW,cAC/B,oBACJ;AACA,UAAM,gBAAgB,GAAG,WAAW,cAChC,qBACJ;AACA,UAAM,kBAAkB,GAAG,WAAW,cAClC,uBACJ;AAEA,iBAAa,MAAM;AAEnB,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,QAAQ,sBAAsB,EAAE,GAAG,GAAG;AACxD,WAAO,aAAa,MAAM,EAAE,GAAG,GAAG;AAClC,WAAO,UAAU,MAAM,EAAE,GAAG,GAAG;AAE/B,kBAAc,MAAM;AAEpB,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,SAAS,EAAE,GAAG,MAAM,CAAC;AACvC,WAAO,aAAa,QAAQ,qBAAqB,EAAE,GAAG,GAAG;AACzD,WAAO,UAAU,MAAM,EAAE,GAAG,GAAG;AAE/B,oBAAgB,MAAM;AAEtB,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,SAAS,EAAE,GAAG,MAAM,CAAC;AACvC,WAAO,aAAa,SAAS,EAAE,GAAG,MAAM,CAAC;AACzC,WAAO,UAAU,QAAQ,wBAAwB,EAAE,GAAG,GAAG;AAAA,EAC7D,CAAC;AACL,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,6 @@
1
- import { elementUpdated, expect, fixture } from "@open-wc/testing";
1
+ import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
2
2
  import "@spectrum-web-components/dialog/sp-dialog.js";
3
+ import { Dialog } from "@spectrum-web-components/dialog";
3
4
  import {
4
5
  alertError,
5
6
  dismissable,
@@ -7,7 +8,9 @@ import {
7
8
  small
8
9
  } from "../stories/dialog.stories.js";
9
10
  import { spy } from "sinon";
11
+ import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
10
12
  describe("Dialog", () => {
13
+ testForLitDevWarnings(async () => await fixture(small()));
11
14
  it("loads `[size=small]` dialog accessibly", async () => {
12
15
  const el = await fixture(small());
13
16
  await elementUpdated(el);
@@ -43,5 +46,104 @@ describe("Dialog", () => {
43
46
  await elementUpdated(el);
44
47
  expect(closeSpy.calledOnce).to.be.true;
45
48
  });
49
+ it("allows hero override", async () => {
50
+ class Override extends Dialog {
51
+ get hasHero() {
52
+ return true;
53
+ }
54
+ renderHero() {
55
+ return html`
56
+ <div id="hero-container"></div>
57
+ `;
58
+ }
59
+ }
60
+ customElements.define("hero-dialog", Override);
61
+ const el = await fixture(html`
62
+ <hero-dialog></hero-dialog>
63
+ `);
64
+ const container = el.shadowRoot.querySelector("#hero-container");
65
+ expect(container).to.not.be.null;
66
+ });
67
+ it("allows heading override", async () => {
68
+ class Override extends Dialog {
69
+ renderHeading() {
70
+ return html`
71
+ <h2 id="heading-container">Test</h2>
72
+ `;
73
+ }
74
+ }
75
+ customElements.define("heading-dialog", Override);
76
+ const el = await fixture(html`
77
+ <heading-dialog></heading-dialog>
78
+ `);
79
+ const container = el.shadowRoot.querySelector("#heading-container");
80
+ expect(container).to.not.be.null;
81
+ });
82
+ it("allows content override", async () => {
83
+ class Override extends Dialog {
84
+ renderContent() {
85
+ return html`
86
+ <p id="content-container">Test</p>
87
+ `;
88
+ }
89
+ }
90
+ customElements.define("content-dialog", Override);
91
+ const el = await fixture(html`
92
+ <content-dialog></content-dialog>
93
+ `);
94
+ const container = el.shadowRoot.querySelector("#content-container");
95
+ expect(container).to.not.be.null;
96
+ });
97
+ it("allows footer override", async () => {
98
+ class Override extends Dialog {
99
+ get hasFooter() {
100
+ return true;
101
+ }
102
+ renderFooter() {
103
+ return html`
104
+ <p id="footer-container">Test</p>
105
+ `;
106
+ }
107
+ }
108
+ customElements.define("footer-dialog", Override);
109
+ const el = await fixture(html`
110
+ <footer-dialog></footer-dialog>
111
+ `);
112
+ const container = el.shadowRoot.querySelector("#footer-container");
113
+ expect(container).to.not.be.null;
114
+ });
115
+ it("allows button override", async () => {
116
+ class Override extends Dialog {
117
+ get hasButtons() {
118
+ return true;
119
+ }
120
+ renderButtons() {
121
+ return html`
122
+ <p id="button-container">Test</p>
123
+ `;
124
+ }
125
+ }
126
+ customElements.define("button-dialog", Override);
127
+ const el = await fixture(html`
128
+ <button-dialog></button-dialog>
129
+ `);
130
+ const container = el.shadowRoot.querySelector("#button-container");
131
+ expect(container).to.not.be.null;
132
+ });
133
+ it("allows dismiss override", async () => {
134
+ class Override extends Dialog {
135
+ renderDismiss() {
136
+ return html`
137
+ <p id="dismiss-container">Test</p>
138
+ `;
139
+ }
140
+ }
141
+ customElements.define("dismiss-dialog", Override);
142
+ const el = await fixture(html`
143
+ <dismiss-dialog dismissable></dismiss-dialog>
144
+ `);
145
+ const container = el.shadowRoot.querySelector("#dismiss-container");
146
+ expect(container).to.not.be.null;
147
+ });
46
148
  });
47
149
  //# sourceMappingURL=dialog.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["dialog.test.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 { elementUpdated, expect, fixture } from '@open-wc/testing';\n\nimport '@spectrum-web-components/dialog/sp-dialog.js';\nimport { Dialog } from '@spectrum-web-components/dialog';\nimport {\n alertError,\n dismissable,\n fullscreen,\n small,\n} from '../stories/dialog.stories.js';\nimport { spy } from 'sinon';\n\ndescribe('Dialog', () => {\n it('loads `[size=small]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(small());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[size=alert]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(alertError());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[dismissable]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(dismissable());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[mode=fullscreen]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(fullscreen());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads dialog without footer accessibly', async () => {\n const el = await fixture<Dialog>(small());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('closes', async () => {\n const closeSpy = spy();\n const el = await fixture<Dialog>(dismissable());\n el.addEventListener('close', () => closeSpy());\n await elementUpdated(el);\n\n const closeButton = (\n el.shadowRoot\n ? el.shadowRoot.querySelector('.close-button')\n : el.querySelector('.close-button ')\n ) as HTMLElement;\n\n closeButton.click();\n\n await elementUpdated(el);\n expect(closeSpy.calledOnce).to.be.true;\n });\n});\n"],
5
- "mappings": "AAYA;AAEA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAEA,SAAS,UAAU,MAAM;AACrB,KAAG,0CAA0C,YAAY;AACrD,UAAM,KAAK,MAAM,QAAgB,MAAM,CAAC;AAExC,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,0CAA0C,YAAY;AACrD,UAAM,KAAK,MAAM,QAAgB,WAAW,CAAC;AAE7C,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,2CAA2C,YAAY;AACtD,UAAM,KAAK,MAAM,QAAgB,YAAY,CAAC;AAE9C,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,+CAA+C,YAAY;AAC1D,UAAM,KAAK,MAAM,QAAgB,WAAW,CAAC;AAE7C,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,0CAA0C,YAAY;AACrD,UAAM,KAAK,MAAM,QAAgB,MAAM,CAAC;AAExC,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,UAAU,YAAY;AACrB,UAAM,WAAW,IAAI;AACrB,UAAM,KAAK,MAAM,QAAgB,YAAY,CAAC;AAC9C,OAAG,iBAAiB,SAAS,MAAM,SAAS,CAAC;AAC7C,UAAM,eAAe,EAAE;AAEvB,UAAM,cACF,GAAG,aACG,GAAG,WAAW,cAAc,eAAe,IAC3C,GAAG,cAAc,gBAAgB;AAG3C,gBAAY,MAAM;AAElB,UAAM,eAAe,EAAE;AACvB,WAAO,SAAS,UAAU,EAAE,GAAG,GAAG;AAAA,EACtC,CAAC;AACL,CAAC;",
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 { elementUpdated, expect, fixture, html } from '@open-wc/testing';\nimport { TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/dialog/sp-dialog.js';\nimport { Dialog } from '@spectrum-web-components/dialog';\nimport {\n alertError,\n dismissable,\n fullscreen,\n small,\n} from '../stories/dialog.stories.js';\nimport { spy } from 'sinon';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Dialog', () => {\n testForLitDevWarnings(async () => await fixture<Dialog>(small()));\n it('loads `[size=small]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(small());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[size=alert]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(alertError());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[dismissable]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(dismissable());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[mode=fullscreen]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(fullscreen());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads dialog without footer accessibly', async () => {\n const el = await fixture<Dialog>(small());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('closes', async () => {\n const closeSpy = spy();\n const el = await fixture<Dialog>(dismissable());\n el.addEventListener('close', () => closeSpy());\n await elementUpdated(el);\n\n const closeButton = (\n el.shadowRoot\n ? el.shadowRoot.querySelector('.close-button')\n : el.querySelector('.close-button ')\n ) as HTMLElement;\n\n closeButton.click();\n\n await elementUpdated(el);\n expect(closeSpy.calledOnce).to.be.true;\n });\n it('allows hero override', async () => {\n class Override extends Dialog {\n protected override get hasHero(): boolean {\n return true;\n }\n protected override renderHero(): TemplateResult {\n return html`\n <div id=\"hero-container\"></div>\n `;\n }\n }\n\n customElements.define('hero-dialog', Override);\n\n const el = await fixture<Override>(\n html`\n <hero-dialog></hero-dialog>\n `\n );\n\n const container = el.shadowRoot.querySelector('#hero-container');\n expect(container).to.not.be.null;\n });\n it('allows heading override', async () => {\n class Override extends Dialog {\n protected override renderHeading(): TemplateResult {\n return html`\n <h2 id=\"heading-container\">Test</h2>\n `;\n }\n }\n\n customElements.define('heading-dialog', Override);\n\n const el = await fixture<Override>(\n html`\n <heading-dialog></heading-dialog>\n `\n );\n\n const container = el.shadowRoot.querySelector('#heading-container');\n expect(container).to.not.be.null;\n });\n it('allows content override', async () => {\n class Override extends Dialog {\n protected override renderContent(): TemplateResult {\n return html`\n <p id=\"content-container\">Test</p>\n `;\n }\n }\n\n customElements.define('content-dialog', Override);\n\n const el = await fixture<Override>(\n html`\n <content-dialog></content-dialog>\n `\n );\n\n const container = el.shadowRoot.querySelector('#content-container');\n expect(container).to.not.be.null;\n });\n it('allows footer override', async () => {\n class Override extends Dialog {\n protected override get hasFooter(): boolean {\n return true;\n }\n protected override renderFooter(): TemplateResult {\n return html`\n <p id=\"footer-container\">Test</p>\n `;\n }\n }\n\n customElements.define('footer-dialog', Override);\n\n const el = await fixture<Override>(\n html`\n <footer-dialog></footer-dialog>\n `\n );\n\n const container = el.shadowRoot.querySelector('#footer-container');\n expect(container).to.not.be.null;\n });\n it('allows button override', async () => {\n class Override extends Dialog {\n protected override get hasButtons(): boolean {\n return true;\n }\n protected override renderButtons(): TemplateResult {\n return html`\n <p id=\"button-container\">Test</p>\n `;\n }\n }\n\n customElements.define('button-dialog', Override);\n\n const el = await fixture<Override>(\n html`\n <button-dialog></button-dialog>\n `\n );\n\n const container = el.shadowRoot.querySelector('#button-container');\n expect(container).to.not.be.null;\n });\n it('allows dismiss override', async () => {\n class Override extends Dialog {\n protected override renderDismiss(): TemplateResult {\n return html`\n <p id=\"dismiss-container\">Test</p>\n `;\n }\n }\n\n customElements.define('dismiss-dialog', Override);\n\n const el = await fixture<Override>(\n html`\n <dismiss-dialog dismissable></dismiss-dialog>\n `\n );\n\n const container = el.shadowRoot.querySelector('#dismiss-container');\n expect(container).to.not.be.null;\n });\n});\n"],
5
+ "mappings": "AAYA;AAGA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AACA;AAEA,SAAS,UAAU,MAAM;AACrB,wBAAsB,YAAY,MAAM,QAAgB,MAAM,CAAC,CAAC;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