@spectrum-web-components/dialog 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +105 -7
- package/package.json +13 -13
- package/src/Dialog.d.ts +12 -2
- package/src/Dialog.js +61 -22
- package/src/Dialog.js.map +1 -1
- package/src/DialogWrapper.d.ts +3 -0
- package/src/DialogWrapper.js +27 -6
- package/src/DialogWrapper.js.map +1 -1
- package/stories/dialog-wrapper.stories.js +112 -13
- package/stories/dialog-wrapper.stories.js.map +1 -1
package/custom-elements.json
CHANGED
|
@@ -63,6 +63,13 @@
|
|
|
63
63
|
}
|
|
64
64
|
],
|
|
65
65
|
"members": [
|
|
66
|
+
{
|
|
67
|
+
"kind": "field",
|
|
68
|
+
"name": "closeButton",
|
|
69
|
+
"type": {
|
|
70
|
+
"text": "ActionButton | undefined"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
66
73
|
{
|
|
67
74
|
"kind": "field",
|
|
68
75
|
"name": "contentElement",
|
|
@@ -150,7 +157,7 @@
|
|
|
150
157
|
},
|
|
151
158
|
{
|
|
152
159
|
"kind": "method",
|
|
153
|
-
"name": "
|
|
160
|
+
"name": "close",
|
|
154
161
|
"privacy": "public",
|
|
155
162
|
"return": {
|
|
156
163
|
"type": {
|
|
@@ -158,20 +165,65 @@
|
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
167
|
},
|
|
168
|
+
{
|
|
169
|
+
"kind": "field",
|
|
170
|
+
"name": "shouldManageTabOrderForScrolling",
|
|
171
|
+
"privacy": "public"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"kind": "field",
|
|
175
|
+
"name": "instanceCount",
|
|
176
|
+
"type": {
|
|
177
|
+
"text": "number"
|
|
178
|
+
},
|
|
179
|
+
"static": true,
|
|
180
|
+
"default": "0"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"kind": "field",
|
|
184
|
+
"name": "labelledbyId",
|
|
185
|
+
"privacy": "private",
|
|
186
|
+
"default": "`sp-dialog-label-${Dialog.instanceCount++}`"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"kind": "field",
|
|
190
|
+
"name": "conditionLabelledby",
|
|
191
|
+
"type": {
|
|
192
|
+
"text": "() => void | undefined"
|
|
193
|
+
},
|
|
194
|
+
"privacy": "private"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"kind": "field",
|
|
198
|
+
"name": "conditionDescribedby",
|
|
199
|
+
"type": {
|
|
200
|
+
"text": "() => void | undefined"
|
|
201
|
+
},
|
|
202
|
+
"privacy": "private"
|
|
203
|
+
},
|
|
161
204
|
{
|
|
162
205
|
"kind": "method",
|
|
163
|
-
"name": "
|
|
164
|
-
"privacy": "
|
|
206
|
+
"name": "onHeadingSlotchange",
|
|
207
|
+
"privacy": "private",
|
|
165
208
|
"return": {
|
|
166
209
|
"type": {
|
|
167
210
|
"text": "void"
|
|
168
211
|
}
|
|
169
|
-
}
|
|
212
|
+
},
|
|
213
|
+
"parameters": [
|
|
214
|
+
{
|
|
215
|
+
"name": "{\n target,\n }",
|
|
216
|
+
"type": {
|
|
217
|
+
"text": "Event & { target: HTMLSlotElement }"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
]
|
|
170
221
|
},
|
|
171
222
|
{
|
|
172
223
|
"kind": "field",
|
|
173
|
-
"name": "
|
|
174
|
-
"privacy": "
|
|
224
|
+
"name": "describedbyId",
|
|
225
|
+
"privacy": "private",
|
|
226
|
+
"default": "`sp-dialog-description-${Dialog.instanceCount++}`"
|
|
175
227
|
},
|
|
176
228
|
{
|
|
177
229
|
"kind": "method",
|
|
@@ -181,7 +233,15 @@
|
|
|
181
233
|
"type": {
|
|
182
234
|
"text": "void"
|
|
183
235
|
}
|
|
184
|
-
}
|
|
236
|
+
},
|
|
237
|
+
"parameters": [
|
|
238
|
+
{
|
|
239
|
+
"name": "{\n target,\n }",
|
|
240
|
+
"type": {
|
|
241
|
+
"text": "Event & { target: HTMLSlotElement }"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
]
|
|
185
245
|
}
|
|
186
246
|
],
|
|
187
247
|
"events": [
|
|
@@ -462,6 +522,16 @@
|
|
|
462
522
|
}
|
|
463
523
|
}
|
|
464
524
|
},
|
|
525
|
+
{
|
|
526
|
+
"kind": "method",
|
|
527
|
+
"name": "overlayWillCloseCallback",
|
|
528
|
+
"privacy": "public",
|
|
529
|
+
"return": {
|
|
530
|
+
"type": {
|
|
531
|
+
"text": "boolean"
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
},
|
|
465
535
|
{
|
|
466
536
|
"kind": "method",
|
|
467
537
|
"name": "dismiss",
|
|
@@ -502,6 +572,24 @@
|
|
|
502
572
|
}
|
|
503
573
|
}
|
|
504
574
|
},
|
|
575
|
+
{
|
|
576
|
+
"kind": "method",
|
|
577
|
+
"name": "handleClose",
|
|
578
|
+
"privacy": "protected",
|
|
579
|
+
"return": {
|
|
580
|
+
"type": {
|
|
581
|
+
"text": "void"
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
"parameters": [
|
|
585
|
+
{
|
|
586
|
+
"name": "event",
|
|
587
|
+
"type": {
|
|
588
|
+
"text": "Event"
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
]
|
|
592
|
+
},
|
|
505
593
|
{
|
|
506
594
|
"kind": "method",
|
|
507
595
|
"name": "close",
|
|
@@ -512,6 +600,16 @@
|
|
|
512
600
|
}
|
|
513
601
|
}
|
|
514
602
|
},
|
|
603
|
+
{
|
|
604
|
+
"kind": "method",
|
|
605
|
+
"name": "dispatchClosed",
|
|
606
|
+
"privacy": "private",
|
|
607
|
+
"return": {
|
|
608
|
+
"type": {
|
|
609
|
+
"text": "void"
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
},
|
|
515
613
|
{
|
|
516
614
|
"kind": "method",
|
|
517
615
|
"name": "handleUnderlayTransitionend",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/dialog",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"lit-html"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@spectrum-web-components/action-button": "^0.7.
|
|
50
|
-
"@spectrum-web-components/base": "^0.5.
|
|
51
|
-
"@spectrum-web-components/button": "^0.16.
|
|
52
|
-
"@spectrum-web-components/button-group": "^0.8.
|
|
53
|
-
"@spectrum-web-components/divider": "^0.4.
|
|
54
|
-
"@spectrum-web-components/icon": "^0.11.
|
|
55
|
-
"@spectrum-web-components/icons-ui": "^0.8.
|
|
56
|
-
"@spectrum-web-components/icons-workflow": "^0.8.
|
|
57
|
-
"@spectrum-web-components/modal": "^0.6.
|
|
58
|
-
"@spectrum-web-components/shared": "^0.13.
|
|
59
|
-
"@spectrum-web-components/underlay": "^0.8.
|
|
49
|
+
"@spectrum-web-components/action-button": "^0.7.4",
|
|
50
|
+
"@spectrum-web-components/base": "^0.5.2",
|
|
51
|
+
"@spectrum-web-components/button": "^0.16.4",
|
|
52
|
+
"@spectrum-web-components/button-group": "^0.8.3",
|
|
53
|
+
"@spectrum-web-components/divider": "^0.4.3",
|
|
54
|
+
"@spectrum-web-components/icon": "^0.11.3",
|
|
55
|
+
"@spectrum-web-components/icons-ui": "^0.8.3",
|
|
56
|
+
"@spectrum-web-components/icons-workflow": "^0.8.3",
|
|
57
|
+
"@spectrum-web-components/modal": "^0.6.1",
|
|
58
|
+
"@spectrum-web-components/shared": "^0.13.4",
|
|
59
|
+
"@spectrum-web-components/underlay": "^0.8.3",
|
|
60
60
|
"tslib": "^2.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"sideEffects": [
|
|
68
68
|
"./sp-*.js"
|
|
69
69
|
],
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "bb5308b9be01cc7c5bbab289312042256bdcc740"
|
|
71
71
|
}
|
package/src/Dialog.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import '@spectrum-web-components/action-button/sp-action-button.js';
|
|
|
4
4
|
import '@spectrum-web-components/button-group/sp-button-group.js';
|
|
5
5
|
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';
|
|
6
6
|
import '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';
|
|
7
|
+
import type { ActionButton } from '@spectrum-web-components/action-button';
|
|
7
8
|
declare const Dialog_base: typeof SpectrumElement & {
|
|
8
9
|
new (...args: any[]): import("@spectrum-web-components/shared").SlotPresenceObservingInterface;
|
|
9
10
|
prototype: import("@spectrum-web-components/shared").SlotPresenceObservingInterface;
|
|
@@ -20,6 +21,7 @@ declare const Dialog_base: typeof SpectrumElement & {
|
|
|
20
21
|
*/
|
|
21
22
|
export declare class Dialog extends Dialog_base {
|
|
22
23
|
static get styles(): CSSResultArray;
|
|
24
|
+
closeButton?: ActionButton;
|
|
23
25
|
private contentElement;
|
|
24
26
|
error: boolean;
|
|
25
27
|
dismissable: boolean;
|
|
@@ -29,12 +31,20 @@ export declare class Dialog extends Dialog_base {
|
|
|
29
31
|
noDivider: boolean;
|
|
30
32
|
mode?: 'fullscreen' | 'fullscreenTakeover';
|
|
31
33
|
size?: 's' | 'm' | 'l';
|
|
32
|
-
focus(): void;
|
|
33
34
|
close(): void;
|
|
34
35
|
protected render(): TemplateResult;
|
|
35
36
|
shouldManageTabOrderForScrolling: () => void;
|
|
36
37
|
protected shouldUpdate(changes: PropertyValues): boolean;
|
|
37
|
-
protected
|
|
38
|
+
protected firstUpdated(changes: PropertyValues): void;
|
|
39
|
+
static instanceCount: number;
|
|
40
|
+
private labelledbyId;
|
|
41
|
+
private conditionLabelledby?;
|
|
42
|
+
private conditionDescribedby?;
|
|
43
|
+
private onHeadingSlotchange;
|
|
44
|
+
private describedbyId;
|
|
45
|
+
protected onContentSlotChange({ target, }: Event & {
|
|
46
|
+
target: HTMLSlotElement;
|
|
47
|
+
}): void;
|
|
38
48
|
connectedCallback(): void;
|
|
39
49
|
disconnectedCallback(): void;
|
|
40
50
|
}
|
package/src/Dialog.js
CHANGED
|
@@ -13,6 +13,7 @@ import { __decorate } from "tslib";
|
|
|
13
13
|
import { html, SpectrumElement, } from '@spectrum-web-components/base';
|
|
14
14
|
import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
|
|
15
15
|
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
|
|
16
|
+
import { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';
|
|
16
17
|
import '@spectrum-web-components/divider/sp-divider.js';
|
|
17
18
|
import '@spectrum-web-components/action-button/sp-action-button.js';
|
|
18
19
|
import '@spectrum-web-components/button-group/sp-button-group.js';
|
|
@@ -20,8 +21,22 @@ import crossStyles from '@spectrum-web-components/icon/src/spectrum-icon-cross.c
|
|
|
20
21
|
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';
|
|
21
22
|
import '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';
|
|
22
23
|
import { FocusVisiblePolyfillMixin, ObserveSlotPresence, } from '@spectrum-web-components/shared';
|
|
23
|
-
import { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';
|
|
24
24
|
import styles from './dialog.css.js';
|
|
25
|
+
function gatherAppliedIdsFromSlottedChildren(slot, idBase) {
|
|
26
|
+
const assignedElements = slot.assignedElements();
|
|
27
|
+
const ids = [];
|
|
28
|
+
assignedElements.forEach((el, i) => {
|
|
29
|
+
if (el.id) {
|
|
30
|
+
ids.push(el.id);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const id = idBase + `-${i}`;
|
|
34
|
+
el.id = id;
|
|
35
|
+
ids.push(id);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return ids;
|
|
39
|
+
}
|
|
25
40
|
/**
|
|
26
41
|
* @element sp-dialog
|
|
27
42
|
*
|
|
@@ -51,6 +66,8 @@ export class Dialog extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spectr
|
|
|
51
66
|
this.contentElement.removeAttribute('tabindex');
|
|
52
67
|
}
|
|
53
68
|
};
|
|
69
|
+
this.labelledbyId = `sp-dialog-label-${Dialog.instanceCount++}`;
|
|
70
|
+
this.describedbyId = `sp-dialog-description-${Dialog.instanceCount++}`;
|
|
54
71
|
}
|
|
55
72
|
static get styles() {
|
|
56
73
|
return [styles, crossStyles];
|
|
@@ -64,28 +81,11 @@ export class Dialog extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spectr
|
|
|
64
81
|
get hasHero() {
|
|
65
82
|
return this.getSlotContentPresence('[slot="hero"]');
|
|
66
83
|
}
|
|
67
|
-
focus() {
|
|
68
|
-
if (this.shadowRoot) {
|
|
69
|
-
const firstFocusable = firstFocusableIn(this.shadowRoot);
|
|
70
|
-
if (firstFocusable) {
|
|
71
|
-
if (firstFocusable.updateComplete) {
|
|
72
|
-
firstFocusable.updateComplete.then(() => firstFocusable.focus());
|
|
73
|
-
/* c8 ignore next 3 */
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
firstFocusable.focus();
|
|
77
|
-
}
|
|
78
|
-
this.removeAttribute('tabindex');
|
|
79
|
-
}
|
|
80
|
-
/* c8 ignore next 3 */
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
super.focus();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
84
|
close() {
|
|
87
85
|
this.dispatchEvent(new Event('close', {
|
|
88
86
|
bubbles: true,
|
|
87
|
+
composed: true,
|
|
88
|
+
cancelable: true,
|
|
89
89
|
}));
|
|
90
90
|
}
|
|
91
91
|
render() {
|
|
@@ -95,6 +95,7 @@ export class Dialog extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spectr
|
|
|
95
95
|
<slot
|
|
96
96
|
name="heading"
|
|
97
97
|
class=${ifDefined(this.hasHero ? this.hasHero : undefined)}
|
|
98
|
+
@slotchange=${this.onHeadingSlotchange}
|
|
98
99
|
></slot>
|
|
99
100
|
${this.error
|
|
100
101
|
? html `
|
|
@@ -155,11 +156,45 @@ export class Dialog extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spectr
|
|
|
155
156
|
}
|
|
156
157
|
return super.shouldUpdate(changes);
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
firstUpdated(changes) {
|
|
160
|
+
super.firstUpdated(changes);
|
|
161
|
+
this.setAttribute('role', 'dialog');
|
|
162
|
+
}
|
|
163
|
+
onHeadingSlotchange({ target, }) {
|
|
164
|
+
if (this.conditionLabelledby) {
|
|
165
|
+
this.conditionLabelledby();
|
|
166
|
+
delete this.conditionLabelledby;
|
|
167
|
+
}
|
|
168
|
+
const ids = gatherAppliedIdsFromSlottedChildren(target, this.labelledbyId);
|
|
169
|
+
if (ids.length) {
|
|
170
|
+
this.conditionLabelledby = conditionAttributeWithId(this, 'aria-labelledby', ids);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
onContentSlotChange({ target, }) {
|
|
174
|
+
if (this.conditionDescribedby) {
|
|
175
|
+
this.conditionDescribedby();
|
|
176
|
+
delete this.conditionDescribedby;
|
|
177
|
+
}
|
|
178
|
+
const ids = gatherAppliedIdsFromSlottedChildren(target, this.describedbyId);
|
|
179
|
+
if (ids.length && ids.length < 4) {
|
|
180
|
+
this.conditionDescribedby = conditionAttributeWithId(this, 'aria-describedby', ids);
|
|
181
|
+
}
|
|
182
|
+
else if (!ids.length) {
|
|
183
|
+
const idProvided = !!this.id;
|
|
184
|
+
if (!idProvided)
|
|
185
|
+
this.id = this.describedbyId;
|
|
186
|
+
const conditionDescribedby = conditionAttributeWithId(this, 'aria-describedby', this.id);
|
|
187
|
+
this.conditionDescribedby = () => {
|
|
188
|
+
conditionDescribedby();
|
|
189
|
+
if (!idProvided) {
|
|
190
|
+
this.removeAttribute('id');
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
160
194
|
}
|
|
161
195
|
connectedCallback() {
|
|
162
196
|
super.connectedCallback();
|
|
197
|
+
this.tabIndex = 0;
|
|
163
198
|
window.addEventListener('resize', this.shouldManageTabOrderForScrolling);
|
|
164
199
|
}
|
|
165
200
|
disconnectedCallback() {
|
|
@@ -167,6 +202,10 @@ export class Dialog extends FocusVisiblePolyfillMixin(ObserveSlotPresence(Spectr
|
|
|
167
202
|
super.disconnectedCallback();
|
|
168
203
|
}
|
|
169
204
|
}
|
|
205
|
+
Dialog.instanceCount = 0;
|
|
206
|
+
__decorate([
|
|
207
|
+
query('.close-button')
|
|
208
|
+
], Dialog.prototype, "closeButton", void 0);
|
|
170
209
|
__decorate([
|
|
171
210
|
query('.content')
|
|
172
211
|
], Dialog.prototype, "contentElement", void 0);
|
package/src/Dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["Dialog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OAAO,gDAAgD,CAAC;AACxD,OAAO,4DAA4D,CAAC;AACpE,OAAO,0DAA0D,CAAC;AAClE,OAAO,WAAW,MAAM,8DAA8D,CAAC;AACvF,OAAO,6DAA6D,CAAC;AACrE,OAAO,gEAAgE,CAAC;AACxE,OAAO,EACH,yBAAyB,EACzB,mBAAmB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAE7F,OAAO,MAAM,MAAM,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,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;SAC5B;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE;YAChD,IAAI,CAAC,WAAW,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;SACjC;QACD,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAES,mBAAmB;QACzB,IAAI,CAAC,gCAAgC,EAAE,CAAC;IAC5C,CAAC;IAEM,iBAAiB;QACpB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,CAAC,gBAAgB,CACnB,QAAQ,EACR,IAAI,CAAC,gCAAgC,CACxC,CAAC;IACN,CAAC;IAEM,oBAAoB;QACvB,MAAM,CAAC,mBAAmB,CACtB,QAAQ,EACR,IAAI,CAAC,gCAAgC,CACxC,CAAC;QACF,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACjC,CAAC;CACJ;AA1JG;IADC,KAAK,CAAC,UAAU,CAAC;8CACsB;AAGxC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCACtB;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAChB;AAe3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;yCAC3C;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCACQ;AAGlD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCACZ","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '@spectrum-web-components/divider/sp-divider.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/button-group/sp-button-group.js';\nimport crossStyles from '@spectrum-web-components/icon/src/spectrum-icon-cross.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport {\n FocusVisiblePolyfillMixin,\n ObserveSlotPresence,\n} from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\nimport styles from './dialog.css.js';\n\n/**\n * @element sp-dialog\n *\n * @slot hero - Accepts a hero image to display at the top of the dialog\n * @slot heading - Acts as the heading of the dialog. This should be an actual heading tag `<h1-6 />`\n * @slot - Content not addressed to a specific slot will be interpreted as the main content of the dialog\n * @slot footer - Content addressed to the `footer` will be placed below the main content and to the side of any `[slot='button']` content\n * @slot button - Button elements addressed to this slot may be placed below the content when not delivered in a fullscreen mode\n * @fires close - Announces that the dialog has been closed.\n */\nexport class Dialog extends FocusVisiblePolyfillMixin(\n ObserveSlotPresence(SpectrumElement, [\n '[slot=\"hero\"]',\n '[slot=\"footer\"]',\n '[slot=\"button\"]',\n ])\n) {\n public static get styles(): CSSResultArray {\n return [styles, crossStyles];\n }\n\n @query('.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 focus(): void {\n if (this.shadowRoot) {\n const firstFocusable = firstFocusableIn(this.shadowRoot);\n if (firstFocusable) {\n if (firstFocusable.updateComplete) {\n firstFocusable.updateComplete.then(() =>\n firstFocusable.focus()\n );\n /* c8 ignore next 3 */\n } else {\n firstFocusable.focus();\n }\n this.removeAttribute('tabindex');\n }\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n }\n\n public close(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n })\n );\n }\n\n protected render(): TemplateResult {\n return html`\n <div class=\"grid\">\n <slot name=\"hero\"></slot>\n <slot\n name=\"heading\"\n class=${ifDefined(this.hasHero ? this.hasHero : undefined)}\n ></slot>\n ${this.error\n ? html`\n <sp-icon-alert class=\"type-icon\"></sp-icon-alert>\n `\n : html``}\n ${this.noDivider\n ? html``\n : html`\n <sp-divider size=\"m\" class=\"divider\"></sp-divider>\n `}\n <div class=\"content\">\n <slot @slotchange=${this.onContentSlotChange}></slot>\n </div>\n ${this.hasFooter\n ? html`\n <div class=\"footer\">\n <slot name=\"footer\"></slot>\n </div>\n `\n : html``}\n ${this.hasButtons\n ? html`\n <sp-button-group\n class=\"button-group ${this.hasFooter\n ? ''\n : 'button-group--noFooter'}\"\n >\n <slot name=\"button\"></slot>\n </sp-button-group>\n `\n : html``}\n ${this.dismissable\n ? html`\n <sp-action-button\n class=\"close-button\"\n label=\"Close\"\n quiet\n size=\"m\"\n @click=${this.close}\n >\n <sp-icon-cross500\n class=\"spectrum-UIIcon-Cross500\"\n slot=\"icon\"\n ></sp-icon-cross500>\n </sp-action-button>\n `\n : html``}\n </div>\n `;\n }\n\n public shouldManageTabOrderForScrolling = (): void => {\n const { offsetHeight, scrollHeight } = this.contentElement;\n if (offsetHeight < scrollHeight) {\n this.contentElement.tabIndex = 0;\n } else {\n this.contentElement.removeAttribute('tabindex');\n }\n };\n\n protected shouldUpdate(changes: PropertyValues): boolean {\n if (changes.has('mode') && !!this.mode) {\n this.dismissable = false;\n }\n if (changes.has('dismissable') && this.dismissable) {\n this.dismissable = !this.mode;\n }\n return super.shouldUpdate(changes);\n }\n\n protected onContentSlotChange(): void {\n this.shouldManageTabOrderForScrolling();\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n window.addEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n }\n\n public disconnectedCallback(): void {\n window.removeEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n super.disconnectedCallback();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["Dialog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kEAAkE,CAAC;AAE5G,OAAO,gDAAgD,CAAC;AACxD,OAAO,4DAA4D,CAAC;AACpE,OAAO,0DAA0D,CAAC;AAClE,OAAO,WAAW,MAAM,8DAA8D,CAAC;AACvF,OAAO,6DAA6D,CAAC;AACrE,OAAO,gEAAgE,CAAC;AACxE,OAAO,EACH,yBAAyB,EACzB,mBAAmB,GACtB,MAAM,iCAAiC,CAAC;AAEzC,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,EAAE,CAAC;qCACtB;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAChB;AAe3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;yCAC3C;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCACQ;AAGlD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCACZ","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';\n\nimport '@spectrum-web-components/divider/sp-divider.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/button-group/sp-button-group.js';\nimport crossStyles from '@spectrum-web-components/icon/src/spectrum-icon-cross.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport {\n FocusVisiblePolyfillMixin,\n ObserveSlotPresence,\n} from '@spectrum-web-components/shared';\n\nimport styles from './dialog.css.js';\nimport type { ActionButton } from '@spectrum-web-components/action-button';\n\nfunction gatherAppliedIdsFromSlottedChildren(\n slot: HTMLSlotElement,\n idBase: string\n): string[] {\n const assignedElements = slot.assignedElements();\n const ids: string[] = [];\n assignedElements.forEach((el, i) => {\n if (el.id) {\n ids.push(el.id);\n } else {\n const id = idBase + `-${i}`;\n el.id = id;\n ids.push(id);\n }\n });\n return ids;\n}\n\n/**\n * @element sp-dialog\n *\n * @slot hero - Accepts a hero image to display at the top of the dialog\n * @slot heading - Acts as the heading of the dialog. This should be an actual heading tag `<h1-6 />`\n * @slot - Content not addressed to a specific slot will be interpreted as the main content of the dialog\n * @slot footer - Content addressed to the `footer` will be placed below the main content and to the side of any `[slot='button']` content\n * @slot button - Button elements addressed to this slot may be placed below the content when not delivered in a fullscreen mode\n * @fires close - Announces that the dialog has been closed.\n */\nexport class Dialog extends FocusVisiblePolyfillMixin(\n ObserveSlotPresence(SpectrumElement, [\n '[slot=\"hero\"]',\n '[slot=\"footer\"]',\n '[slot=\"button\"]',\n ])\n) {\n public static get styles(): CSSResultArray {\n return [styles, crossStyles];\n }\n\n @query('.close-button')\n closeButton?: ActionButton;\n\n @query('.content')\n private contentElement!: HTMLDivElement;\n\n @property({ type: Boolean, reflect: true })\n public error = false;\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n protected get hasFooter(): boolean {\n return this.getSlotContentPresence('[slot=\"footer\"]');\n }\n\n protected get hasButtons(): boolean {\n return this.getSlotContentPresence('[slot=\"button\"]');\n }\n\n protected get hasHero(): boolean {\n return this.getSlotContentPresence('[slot=\"hero\"]');\n }\n\n @property({ type: Boolean, reflect: true, attribute: 'no-divider' })\n public noDivider = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n @property({ type: String, reflect: true })\n public size?: 's' | 'm' | 'l';\n\n public close(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n protected render(): TemplateResult {\n return html`\n <div class=\"grid\">\n <slot name=\"hero\"></slot>\n <slot\n name=\"heading\"\n class=${ifDefined(this.hasHero ? this.hasHero : undefined)}\n @slotchange=${this.onHeadingSlotchange}\n ></slot>\n ${this.error\n ? html`\n <sp-icon-alert class=\"type-icon\"></sp-icon-alert>\n `\n : html``}\n ${this.noDivider\n ? html``\n : html`\n <sp-divider size=\"m\" class=\"divider\"></sp-divider>\n `}\n <div class=\"content\">\n <slot @slotchange=${this.onContentSlotChange}></slot>\n </div>\n ${this.hasFooter\n ? html`\n <div class=\"footer\">\n <slot name=\"footer\"></slot>\n </div>\n `\n : html``}\n ${this.hasButtons\n ? html`\n <sp-button-group\n class=\"button-group ${this.hasFooter\n ? ''\n : 'button-group--noFooter'}\"\n >\n <slot name=\"button\"></slot>\n </sp-button-group>\n `\n : html``}\n ${this.dismissable\n ? html`\n <sp-action-button\n class=\"close-button\"\n label=\"Close\"\n quiet\n size=\"m\"\n @click=${this.close}\n >\n <sp-icon-cross500\n class=\"spectrum-UIIcon-Cross500\"\n slot=\"icon\"\n ></sp-icon-cross500>\n </sp-action-button>\n `\n : html``}\n </div>\n `;\n }\n\n public shouldManageTabOrderForScrolling = (): void => {\n const { offsetHeight, scrollHeight } = this.contentElement;\n if (offsetHeight < scrollHeight) {\n this.contentElement.tabIndex = 0;\n } else {\n this.contentElement.removeAttribute('tabindex');\n }\n };\n\n protected shouldUpdate(changes: PropertyValues): boolean {\n if (changes.has('mode') && !!this.mode) {\n this.dismissable = false;\n }\n if (changes.has('dismissable') && this.dismissable) {\n this.dismissable = !this.mode;\n }\n return super.shouldUpdate(changes);\n }\n\n protected firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('role', 'dialog');\n }\n\n static instanceCount = 0;\n private labelledbyId = `sp-dialog-label-${Dialog.instanceCount++}`;\n private conditionLabelledby?: () => void;\n private conditionDescribedby?: () => void;\n\n private onHeadingSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (this.conditionLabelledby) {\n this.conditionLabelledby();\n delete this.conditionLabelledby;\n }\n const ids = gatherAppliedIdsFromSlottedChildren(\n target,\n this.labelledbyId\n );\n if (ids.length) {\n this.conditionLabelledby = conditionAttributeWithId(\n this,\n 'aria-labelledby',\n ids\n );\n }\n }\n\n private describedbyId = `sp-dialog-description-${Dialog.instanceCount++}`;\n\n protected onContentSlotChange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (this.conditionDescribedby) {\n this.conditionDescribedby();\n delete this.conditionDescribedby;\n }\n const ids = gatherAppliedIdsFromSlottedChildren(\n target,\n this.describedbyId\n );\n if (ids.length && ids.length < 4) {\n this.conditionDescribedby = conditionAttributeWithId(\n this,\n 'aria-describedby',\n ids\n );\n } else if (!ids.length) {\n const idProvided = !!this.id;\n if (!idProvided) this.id = this.describedbyId;\n const conditionDescribedby = conditionAttributeWithId(\n this,\n 'aria-describedby',\n this.id\n );\n this.conditionDescribedby = () => {\n conditionDescribedby();\n if (!idProvided) {\n this.removeAttribute('id');\n }\n };\n }\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.tabIndex = 0;\n window.addEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n }\n\n public disconnectedCallback(): void {\n window.removeEventListener(\n 'resize',\n this.shouldManageTabOrderForScrolling\n );\n super.disconnectedCallback();\n }\n}\n"]}
|
package/src/DialogWrapper.d.ts
CHANGED
|
@@ -33,11 +33,14 @@ export declare class DialogWrapper extends DialogWrapper_base {
|
|
|
33
33
|
underlay: boolean;
|
|
34
34
|
private dialog;
|
|
35
35
|
focus(): void;
|
|
36
|
+
overlayWillCloseCallback(): boolean;
|
|
36
37
|
private dismiss;
|
|
37
38
|
private clickSecondary;
|
|
38
39
|
private clickCancel;
|
|
39
40
|
private clickConfirm;
|
|
41
|
+
protected handleClose(event: Event): void;
|
|
40
42
|
close(): void;
|
|
43
|
+
private dispatchClosed;
|
|
41
44
|
protected handleUnderlayTransitionend(): void;
|
|
42
45
|
protected handleModalTransitionend(): void;
|
|
43
46
|
protected update(changes: PropertyValues<this>): void;
|
package/src/DialogWrapper.js
CHANGED
|
@@ -52,7 +52,7 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
52
52
|
}
|
|
53
53
|
focus() {
|
|
54
54
|
if (this.shadowRoot) {
|
|
55
|
-
const firstFocusable = firstFocusableIn(this.
|
|
55
|
+
const firstFocusable = firstFocusableIn(this.dialog);
|
|
56
56
|
if (firstFocusable) {
|
|
57
57
|
if (firstFocusable.updateComplete) {
|
|
58
58
|
firstFocusable.updateComplete.then(() => firstFocusable.focus());
|
|
@@ -72,6 +72,12 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
72
72
|
super.focus();
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
overlayWillCloseCallback() {
|
|
76
|
+
if (!this.open)
|
|
77
|
+
return false;
|
|
78
|
+
this.close();
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
75
81
|
dismiss() {
|
|
76
82
|
if (!this.dismissable) {
|
|
77
83
|
return;
|
|
@@ -93,20 +99,30 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
93
99
|
bubbles: true,
|
|
94
100
|
}));
|
|
95
101
|
}
|
|
102
|
+
handleClose(event) {
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
this.close();
|
|
105
|
+
}
|
|
96
106
|
close() {
|
|
97
107
|
this.open = false;
|
|
108
|
+
}
|
|
109
|
+
dispatchClosed() {
|
|
98
110
|
this.dispatchEvent(new Event('close', {
|
|
99
111
|
bubbles: true,
|
|
100
112
|
}));
|
|
101
113
|
}
|
|
102
114
|
handleUnderlayTransitionend() {
|
|
103
115
|
if (!this.open) {
|
|
116
|
+
this.dispatchClosed();
|
|
104
117
|
this.resolveTransitionPromise();
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
120
|
handleModalTransitionend() {
|
|
108
121
|
if (this.open || !this.underlay) {
|
|
109
122
|
this.resolveTransitionPromise();
|
|
123
|
+
if (!this.open) {
|
|
124
|
+
this.dispatchClosed();
|
|
125
|
+
}
|
|
110
126
|
}
|
|
111
127
|
}
|
|
112
128
|
update(changes) {
|
|
@@ -136,7 +152,7 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
136
152
|
?error=${this.error}
|
|
137
153
|
mode=${ifDefined(this.mode ? this.mode : undefined)}
|
|
138
154
|
size=${ifDefined(this.size ? this.size : undefined)}
|
|
139
|
-
@close=${this.
|
|
155
|
+
@close=${this.handleClose}
|
|
140
156
|
>
|
|
141
157
|
${this.hero
|
|
142
158
|
? html `
|
|
@@ -199,10 +215,15 @@ export class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
|
199
215
|
`;
|
|
200
216
|
}
|
|
201
217
|
updated(changes) {
|
|
202
|
-
if (changes.has('open')
|
|
203
|
-
this.
|
|
204
|
-
this.dialog.
|
|
205
|
-
|
|
218
|
+
if (changes.has('open')) {
|
|
219
|
+
if (this.open) {
|
|
220
|
+
this.dialog.updateComplete.then(() => {
|
|
221
|
+
this.dialog.shouldManageTabOrderForScrolling();
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
this.tabIndex = 0;
|
|
226
|
+
}
|
|
206
227
|
}
|
|
207
228
|
}
|
|
208
229
|
/**
|
package/src/DialogWrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogWrapper.js","sourceRoot":"","sources":["DialogWrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OA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AAS,EAAE,cAAc,EAAE,CAAC;kDAChB;AAGxB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;mDAChB;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAChB;AAG3B;IADC,QAAQ,EAAE;6CACQ;AAGnB;IADC,QAAQ,EAAE;2CACM;AAGjB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;gDAChB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;gDAC3C;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACvB;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACQ;AAGlD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACZ;AAG9B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;qDAChB;AAG3B;IADC,QAAQ,EAAE;+CACU;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDACF;AAO1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CACJ;AAGxB;IADC,KAAK,CAAC,WAAW,CAAC;6CACK","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';\n\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport '@spectrum-web-components/button/sp-button.js';\n\nimport '../sp-dialog.js';\nimport modalWrapperStyles from '@spectrum-web-components/modal/src/modal-wrapper.css.js';\nimport modalStyles from '@spectrum-web-components/modal/src/modal.css.js';\nimport { Dialog } from './Dialog.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\n/**\n * @element sp-dialog-wrapper\n *\n * @slot - content for the dialog\n * @fires secondary - Announces that the \"secondary\" button has been clicked.\n * @fires cancel - Announces that the \"cancel\" button has been clicked.\n * @fires confirm - Announces that the \"confirm\" button has been clicked.\n * @fires close - Announces that the dialog has been closed.\n */\nexport class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {\n public static get styles(): CSSResultArray {\n return [modalWrapperStyles, modalStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public error = false;\n\n @property({ attribute: 'cancel-label' })\n public cancelLabel = '';\n\n @property({ attribute: 'confirm-label' })\n public confirmLabel = '';\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n @property()\n public footer = '';\n\n @property()\n public hero = '';\n\n @property({ attribute: 'hero-label' })\n public heroLabel = '';\n\n @property({ type: Boolean, reflect: true, attribute: 'no-divider' })\n public noDivider = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n @property({ type: String, reflect: true })\n public size?: 's' | 'm' | 'l';\n\n @property({ attribute: 'secondary-label' })\n public secondaryLabel = '';\n\n @property()\n public headline = '';\n\n @property({ type: Boolean })\n public responsive = false;\n\n private transitionPromise = Promise.resolve();\n\n private resolveTransitionPromise!: () => void;\n\n @property({ type: Boolean })\n public underlay = false;\n\n @query('sp-dialog')\n private dialog!: Dialog;\n\n public focus(): void {\n if (this.shadowRoot) {\n const firstFocusable = firstFocusableIn(this.shadowRoot);\n if (firstFocusable) {\n if (firstFocusable.updateComplete) {\n firstFocusable.updateComplete.then(() =>\n firstFocusable.focus()\n );\n /* c8 ignore next 3 */\n } else {\n firstFocusable.focus();\n }\n this.removeAttribute('tabindex');\n } else {\n this.dialog.focus();\n }\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n }\n\n private dismiss(): void {\n if (!this.dismissable) {\n return;\n }\n this.close();\n }\n\n private clickSecondary(): void {\n this.dispatchEvent(\n new Event('secondary', {\n bubbles: true,\n })\n );\n }\n\n private clickCancel(): void {\n this.dispatchEvent(\n new Event('cancel', {\n bubbles: true,\n })\n );\n }\n\n private clickConfirm(): void {\n this.dispatchEvent(\n new Event('confirm', {\n bubbles: true,\n })\n );\n }\n\n public close(): void {\n this.open = false;\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n })\n );\n }\n\n protected handleUnderlayTransitionend(): void {\n if (!this.open) {\n this.resolveTransitionPromise();\n }\n }\n\n protected handleModalTransitionend(): void {\n if (this.open || !this.underlay) {\n this.resolveTransitionPromise();\n }\n }\n\n protected update(changes: PropertyValues<this>): void {\n if (changes.has('open') && changes.get('open') !== undefined) {\n this.transitionPromise = new Promise(\n (res) => (this.resolveTransitionPromise = res)\n );\n }\n super.update(changes);\n }\n\n protected render(): TemplateResult {\n return html`\n ${this.underlay\n ? html`\n <sp-underlay\n ?open=${this.open}\n @click=${this.dismiss}\n @transitionend=${this.handleUnderlayTransitionend}\n ></sp-underlay>\n `\n : html``}\n <div\n class=\"modal ${this.mode}\"\n @transitionend=${this.handleModalTransitionend}\n >\n <sp-dialog\n ?dismissable=${this.dismissable}\n ?no-divider=${this.noDivider}\n ?error=${this.error}\n mode=${ifDefined(this.mode ? this.mode : undefined)}\n size=${ifDefined(this.size ? this.size : undefined)}\n @close=${this.close}\n >\n ${this.hero\n ? html`\n <img\n src=\"${this.hero}\"\n slot=\"hero\"\n aria-hidden=${ifDefined(\n this.heroLabel ? undefined : 'true'\n )}\n alt=${ifDefined(\n this.heroLabel\n ? this.heroLabel\n : undefined\n )}\n />\n `\n : html``}\n ${this.headline\n ? html`\n <h2 slot=\"heading\">${this.headline}</h2>\n `\n : html``}\n <slot></slot>\n ${this.footer\n ? html`\n <div slot=\"footer\">${this.footer}</div>\n `\n : html``}\n ${this.secondaryLabel\n ? html`\n <sp-button\n variant=\"primary\"\n slot=\"button\"\n @click=${this.clickSecondary}\n >\n ${this.secondaryLabel}\n </sp-button>\n `\n : html``}\n ${this.cancelLabel\n ? html`\n <sp-button\n variant=\"secondary\"\n slot=\"button\"\n @click=${this.clickCancel}\n >\n ${this.cancelLabel}\n </sp-button>\n `\n : html``}\n ${this.confirmLabel\n ? html`\n <sp-button\n variant=\"cta\"\n slot=\"button\"\n @click=${this.clickConfirm}\n >\n ${this.confirmLabel}\n </sp-button>\n `\n : html``}\n </sp-dialog>\n </div>\n `;\n }\n\n protected updated(changes: PropertyValues<this>): void {\n if (changes.has('open') && this.open) {\n this.dialog.updateComplete.then(() => {\n this.dialog.shouldManageTabOrderForScrolling();\n });\n }\n }\n\n /**\n * Bind the open/close transition into the update complete lifecycle so\n * that the overlay system can wait for it to be \"visibly ready\" before\n * attempting to throw focus into the content contained herein. Not\n * waiting for this can cause small amounts of page scroll to happen\n * while opening the Tray when focusable content is included: e.g. Menu\n * elements whose selected Menu Item is not the first Menu Item.\n */\n protected async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.transitionPromise;\n return complete;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DialogWrapper.js","sourceRoot":"","sources":["DialogWrapper.ts"],"names":[],"mapp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GpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACQ;AAGlD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACZ;AAG9B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;qDAChB;AAG3B;IADC,QAAQ,EAAE;+CACU;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDACF;AAO1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CACJ;AAGxB;IADC,KAAK,CAAC,WAAW,CAAC;6CACK","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';\n\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport '@spectrum-web-components/button/sp-button.js';\n\nimport '../sp-dialog.js';\nimport modalWrapperStyles from '@spectrum-web-components/modal/src/modal-wrapper.css.js';\nimport modalStyles from '@spectrum-web-components/modal/src/modal.css.js';\nimport { Dialog } from './Dialog.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\n/**\n * @element sp-dialog-wrapper\n *\n * @slot - content for the dialog\n * @fires secondary - Announces that the \"secondary\" button has been clicked.\n * @fires cancel - Announces that the \"cancel\" button has been clicked.\n * @fires confirm - Announces that the \"confirm\" button has been clicked.\n * @fires close - Announces that the dialog has been closed.\n */\nexport class DialogWrapper extends FocusVisiblePolyfillMixin(SpectrumElement) {\n public static get styles(): CSSResultArray {\n return [modalWrapperStyles, modalStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public error = false;\n\n @property({ attribute: 'cancel-label' })\n public cancelLabel = '';\n\n @property({ attribute: 'confirm-label' })\n public confirmLabel = '';\n\n @property({ type: Boolean, reflect: true })\n public dismissable = false;\n\n @property()\n public footer = '';\n\n @property()\n public hero = '';\n\n @property({ attribute: 'hero-label' })\n public heroLabel = '';\n\n @property({ type: Boolean, reflect: true, attribute: 'no-divider' })\n public noDivider = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String, reflect: true })\n public mode?: 'fullscreen' | 'fullscreenTakeover';\n\n @property({ type: String, reflect: true })\n public size?: 's' | 'm' | 'l';\n\n @property({ attribute: 'secondary-label' })\n public secondaryLabel = '';\n\n @property()\n public headline = '';\n\n @property({ type: Boolean })\n public responsive = false;\n\n private transitionPromise = Promise.resolve();\n\n private resolveTransitionPromise!: () => void;\n\n @property({ type: Boolean })\n public underlay = false;\n\n @query('sp-dialog')\n private dialog!: Dialog;\n\n public focus(): void {\n if (this.shadowRoot) {\n const firstFocusable = firstFocusableIn(this.dialog);\n if (firstFocusable) {\n if (firstFocusable.updateComplete) {\n firstFocusable.updateComplete.then(() =>\n firstFocusable.focus()\n );\n /* c8 ignore next 3 */\n } else {\n firstFocusable.focus();\n }\n this.removeAttribute('tabindex');\n } else {\n this.dialog.focus();\n }\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n }\n\n public overlayWillCloseCallback(): boolean {\n if (!this.open) return false;\n this.close();\n return true;\n }\n\n private dismiss(): void {\n if (!this.dismissable) {\n return;\n }\n this.close();\n }\n\n private clickSecondary(): void {\n this.dispatchEvent(\n new Event('secondary', {\n bubbles: true,\n })\n );\n }\n\n private clickCancel(): void {\n this.dispatchEvent(\n new Event('cancel', {\n bubbles: true,\n })\n );\n }\n\n private clickConfirm(): void {\n this.dispatchEvent(\n new Event('confirm', {\n bubbles: true,\n })\n );\n }\n\n protected handleClose(event: Event): void {\n event.stopPropagation();\n this.close();\n }\n\n public close(): void {\n this.open = false;\n }\n\n private dispatchClosed(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n })\n );\n }\n\n protected handleUnderlayTransitionend(): void {\n if (!this.open) {\n this.dispatchClosed();\n this.resolveTransitionPromise();\n }\n }\n\n protected handleModalTransitionend(): void {\n if (this.open || !this.underlay) {\n this.resolveTransitionPromise();\n if (!this.open) {\n this.dispatchClosed();\n }\n }\n }\n\n protected update(changes: PropertyValues<this>): void {\n if (changes.has('open') && changes.get('open') !== undefined) {\n this.transitionPromise = new Promise(\n (res) => (this.resolveTransitionPromise = res)\n );\n }\n super.update(changes);\n }\n\n protected render(): TemplateResult {\n return html`\n ${this.underlay\n ? html`\n <sp-underlay\n ?open=${this.open}\n @click=${this.dismiss}\n @transitionend=${this.handleUnderlayTransitionend}\n ></sp-underlay>\n `\n : html``}\n <div\n class=\"modal ${this.mode}\"\n @transitionend=${this.handleModalTransitionend}\n >\n <sp-dialog\n ?dismissable=${this.dismissable}\n ?no-divider=${this.noDivider}\n ?error=${this.error}\n mode=${ifDefined(this.mode ? this.mode : undefined)}\n size=${ifDefined(this.size ? this.size : undefined)}\n @close=${this.handleClose}\n >\n ${this.hero\n ? html`\n <img\n src=\"${this.hero}\"\n slot=\"hero\"\n aria-hidden=${ifDefined(\n this.heroLabel ? undefined : 'true'\n )}\n alt=${ifDefined(\n this.heroLabel\n ? this.heroLabel\n : undefined\n )}\n />\n `\n : html``}\n ${this.headline\n ? html`\n <h2 slot=\"heading\">${this.headline}</h2>\n `\n : html``}\n <slot></slot>\n ${this.footer\n ? html`\n <div slot=\"footer\">${this.footer}</div>\n `\n : html``}\n ${this.secondaryLabel\n ? html`\n <sp-button\n variant=\"primary\"\n slot=\"button\"\n @click=${this.clickSecondary}\n >\n ${this.secondaryLabel}\n </sp-button>\n `\n : html``}\n ${this.cancelLabel\n ? html`\n <sp-button\n variant=\"secondary\"\n slot=\"button\"\n @click=${this.clickCancel}\n >\n ${this.cancelLabel}\n </sp-button>\n `\n : html``}\n ${this.confirmLabel\n ? html`\n <sp-button\n variant=\"cta\"\n slot=\"button\"\n @click=${this.clickConfirm}\n >\n ${this.confirmLabel}\n </sp-button>\n `\n : html``}\n </sp-dialog>\n </div>\n `;\n }\n\n protected updated(changes: PropertyValues<this>): void {\n if (changes.has('open')) {\n if (this.open) {\n this.dialog.updateComplete.then(() => {\n this.dialog.shouldManageTabOrderForScrolling();\n });\n } else {\n this.tabIndex = 0;\n }\n }\n }\n\n /**\n * Bind the open/close transition into the update complete lifecycle so\n * that the overlay system can wait for it to be \"visibly ready\" before\n * attempting to throw focus into the content contained herein. Not\n * waiting for this can cause small amounts of page scroll to happen\n * while opening the Tray when focusable content is included: e.g. Menu\n * elements whose selected Menu Item is not the first Menu Item.\n */\n protected async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.transitionPromise;\n return complete;\n }\n}\n"]}
|
|
@@ -10,7 +10,11 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
import { html } from '@spectrum-web-components/base';
|
|
13
|
+
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
|
|
13
14
|
import '@spectrum-web-components/button/sp-button.js';
|
|
15
|
+
import '@spectrum-web-components/field-label/sp-field-label.js';
|
|
16
|
+
import '@spectrum-web-components/help-text/sp-help-text.js';
|
|
17
|
+
import '@spectrum-web-components/textfield/sp-textfield.js';
|
|
14
18
|
import '@spectrum-web-components/overlay/overlay-trigger.js';
|
|
15
19
|
import '../sp-dialog-wrapper.js';
|
|
16
20
|
import { landscape } from './images.js';
|
|
@@ -55,7 +59,12 @@ export const wrapperLabeledHero = (args = {}, context = {}) => {
|
|
|
55
59
|
Content of the dialog
|
|
56
60
|
</sp-dialog-wrapper>
|
|
57
61
|
<sp-button
|
|
58
|
-
onClick="
|
|
62
|
+
onClick="
|
|
63
|
+
this.previousElementSibling.open = !this.previousElementSibling.open;
|
|
64
|
+
if (this.previousElementSibling.open) {
|
|
65
|
+
this.previousElementSibling.focus();
|
|
66
|
+
}
|
|
67
|
+
"
|
|
59
68
|
variant="primary"
|
|
60
69
|
>
|
|
61
70
|
Toggle Dialog
|
|
@@ -76,7 +85,12 @@ export const wrapperDismissable = (args = {}, context = {}) => {
|
|
|
76
85
|
Content of the dialog
|
|
77
86
|
</sp-dialog-wrapper>
|
|
78
87
|
<sp-button
|
|
79
|
-
onClick="
|
|
88
|
+
onClick="
|
|
89
|
+
this.previousElementSibling.open = !this.previousElementSibling.open;
|
|
90
|
+
if (this.previousElementSibling.open) {
|
|
91
|
+
this.previousElementSibling.focus();
|
|
92
|
+
}
|
|
93
|
+
"
|
|
80
94
|
variant="primary"
|
|
81
95
|
>
|
|
82
96
|
Toggle Dialog
|
|
@@ -86,12 +100,6 @@ export const wrapperDismissable = (args = {}, context = {}) => {
|
|
|
86
100
|
export const wrapperDismissableUnderlay = (args = {}, context = {}) => {
|
|
87
101
|
const open = context.viewMode === 'docs' ? false : true;
|
|
88
102
|
return html `
|
|
89
|
-
<sp-button
|
|
90
|
-
onClick="this.nextElementSibling.open = !this.nextElementSibling.open"
|
|
91
|
-
variant="primary"
|
|
92
|
-
>
|
|
93
|
-
Toggle Dialog
|
|
94
|
-
</sp-button>
|
|
95
103
|
<sp-dialog-wrapper
|
|
96
104
|
?open=${open}
|
|
97
105
|
hero=${landscape}
|
|
@@ -103,6 +111,92 @@ export const wrapperDismissableUnderlay = (args = {}, context = {}) => {
|
|
|
103
111
|
>
|
|
104
112
|
Content of the dialog
|
|
105
113
|
</sp-dialog-wrapper>
|
|
114
|
+
<sp-button
|
|
115
|
+
onClick="
|
|
116
|
+
this.previousElementSibling.open = !this.previousElementSibling.open;
|
|
117
|
+
if (this.previousElementSibling.open) {
|
|
118
|
+
this.previousElementSibling.focus();
|
|
119
|
+
}
|
|
120
|
+
"
|
|
121
|
+
variant="primary"
|
|
122
|
+
>
|
|
123
|
+
Toggle Dialog
|
|
124
|
+
</sp-button>
|
|
125
|
+
`;
|
|
126
|
+
};
|
|
127
|
+
export const form = (args = {}, context = {}) => {
|
|
128
|
+
const open = context.viewMode === 'docs' ? undefined : 'click';
|
|
129
|
+
return html `
|
|
130
|
+
<overlay-trigger
|
|
131
|
+
type="modal"
|
|
132
|
+
placement="none"
|
|
133
|
+
@close=${handleClose(args)}
|
|
134
|
+
open=${ifDefined(open)}
|
|
135
|
+
>
|
|
136
|
+
<sp-button slot="trigger" variant="primary">
|
|
137
|
+
Toggle Dialog
|
|
138
|
+
</sp-button>
|
|
139
|
+
<sp-dialog-wrapper
|
|
140
|
+
id="form-fields"
|
|
141
|
+
slot="click-content"
|
|
142
|
+
headline="Add Delivery Address"
|
|
143
|
+
underlay
|
|
144
|
+
size="m"
|
|
145
|
+
confirm-label="Verify Address"
|
|
146
|
+
secondary-label="Add"
|
|
147
|
+
cancel-label="Cancel"
|
|
148
|
+
@close=${handleClose(args)}
|
|
149
|
+
@confirm=${({ target }) => {
|
|
150
|
+
target.dispatchEvent(new Event('close', { bubbles: true, composed: true }));
|
|
151
|
+
handleConfirm(args);
|
|
152
|
+
}}
|
|
153
|
+
@secondary=${({ target }) => {
|
|
154
|
+
target.dispatchEvent(new Event('close', { bubbles: true, composed: true }));
|
|
155
|
+
handleSecondary(args);
|
|
156
|
+
}}
|
|
157
|
+
@cancel=${({ target }) => {
|
|
158
|
+
target.dispatchEvent(new Event('close', { bubbles: true, composed: true }));
|
|
159
|
+
handleCancel(args);
|
|
160
|
+
}}
|
|
161
|
+
>
|
|
162
|
+
<style>
|
|
163
|
+
#form-fields div {
|
|
164
|
+
display: grid;
|
|
165
|
+
gap: var(--spectrum-global-dimension-size-150);
|
|
166
|
+
grid-template-columns: auto auto;
|
|
167
|
+
|
|
168
|
+
--spectrum-fieldlabel-m-side-padding-right: 0;
|
|
169
|
+
}
|
|
170
|
+
</style>
|
|
171
|
+
<div>
|
|
172
|
+
<sp-field-label side-aligned="end" for="street">
|
|
173
|
+
Street:
|
|
174
|
+
</sp-field-label>
|
|
175
|
+
<sp-textfield id="street" autofocus></sp-textfield>
|
|
176
|
+
<sp-field-label side-aligned="end" for="city">
|
|
177
|
+
City:
|
|
178
|
+
</sp-field-label>
|
|
179
|
+
<sp-textfield id="city"></sp-textfield>
|
|
180
|
+
<sp-field-label side-aligned="end" for="state">
|
|
181
|
+
State:
|
|
182
|
+
</sp-field-label>
|
|
183
|
+
<sp-textfield id="state"></sp-textfield>
|
|
184
|
+
<sp-field-label side-aligned="end" for="zip">
|
|
185
|
+
Zip:
|
|
186
|
+
</sp-field-label>
|
|
187
|
+
<sp-textfield id="zip"></sp-textfield>
|
|
188
|
+
<sp-field-label side-aligned="end" for="instructions">
|
|
189
|
+
Special instructions:
|
|
190
|
+
</sp-field-label>
|
|
191
|
+
<sp-textfield id="instructions" multiline>
|
|
192
|
+
<sp-help-text slot="help-text">
|
|
193
|
+
For example, gate code or other information to help
|
|
194
|
+
the driver find you
|
|
195
|
+
</sp-help-text>
|
|
196
|
+
</sp-textfield>
|
|
197
|
+
</div>
|
|
198
|
+
</sp-dialog-wrapper>
|
|
199
|
+
</overlay-trigger>
|
|
106
200
|
`;
|
|
107
201
|
};
|
|
108
202
|
export const longContent = (args = {}, context = {}) => {
|
|
@@ -112,8 +206,11 @@ export const longContent = (args = {}, context = {}) => {
|
|
|
112
206
|
type="modal"
|
|
113
207
|
placement="none"
|
|
114
208
|
@close=${handleClose(args)}
|
|
115
|
-
|
|
209
|
+
open=${ifDefined(open)}
|
|
116
210
|
>
|
|
211
|
+
<sp-button slot="trigger" variant="primary">
|
|
212
|
+
Toggle Dialog
|
|
213
|
+
</sp-button>
|
|
117
214
|
<sp-dialog-wrapper
|
|
118
215
|
slot="click-content"
|
|
119
216
|
headline="Dialog title"
|
|
@@ -215,9 +312,6 @@ export const longContent = (args = {}, context = {}) => {
|
|
|
215
312
|
tincidunt. In enim a arcu imperdiet malesuada.
|
|
216
313
|
</p>
|
|
217
314
|
</sp-dialog-wrapper>
|
|
218
|
-
<sp-button slot="trigger" variant="primary">
|
|
219
|
-
Toggle Dialog
|
|
220
|
-
</sp-button>
|
|
221
315
|
</overlay-trigger>
|
|
222
316
|
`;
|
|
223
317
|
};
|
|
@@ -226,7 +320,12 @@ export const wrapperDismissableUnderlayError = (args = {}, context = {}) => {
|
|
|
226
320
|
return html `
|
|
227
321
|
<div>
|
|
228
322
|
<sp-button
|
|
229
|
-
onClick="
|
|
323
|
+
onClick="
|
|
324
|
+
this.previousElementSibling.open = !this.previousElementSibling.open;
|
|
325
|
+
if (this.previousElementSibling.open) {
|
|
326
|
+
this.previousElementSibling.focus();
|
|
327
|
+
}
|
|
328
|
+
"
|
|
230
329
|
variant="primary"
|
|
231
330
|
>
|
|
232
331
|
Toggle Dialog
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-wrapper.stories.js","sourceRoot":"","sources":["dialog-wrapper.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AAErE,OAAO,8CAA8C,CAAC;AACtD,OAAO,qDAAqD,CAAC;AAE7D,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAe;IACX,KAAK,EAAE,gBAAgB;IACvB,SAAS,EAAE,mBAAmB;IAC9B,QAAQ,EAAE;QACN,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;QAC5B,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;QA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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*/\n\nimport { html, TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/button/sp-button.js';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\n\nimport '../sp-dialog-wrapper.js';\nimport { landscape } from './images.js';\n\nexport default {\n title: 'Dialog Wrapped',\n component: 'sp-dialog-wrapper',\n argTypes: {\n onClose: { action: 'close' },\n onConfirm: { action: 'confirm' },\n onSecondary: { action: 'secondary' },\n onCancel: { action: 'cancel' },\n },\n};\n\ntype StoryArgs = {\n onClose?: (event: Event) => void;\n onConfirm?: (event: Event) => void;\n onSecondary?: (event: Event) => void;\n onCancel?: (event: Event) => void;\n};\n\nconst handleClose =\n ({ onClose }: StoryArgs) =>\n (event: Event) => {\n if (onClose) onClose(event);\n };\n\nconst handleConfirm =\n ({ onConfirm }: StoryArgs) =>\n (event: Event) => {\n if (onConfirm) onConfirm(event);\n };\n\nconst handleSecondary =\n ({ onSecondary }: StoryArgs) =>\n (event: Event) => {\n if (onSecondary) onSecondary(event);\n };\n\nconst handleCancel =\n ({ onCancel }: StoryArgs) =>\n (event: Event) => {\n if (onCancel) onCancel(event);\n };\n\nexport const wrapperLabeledHero = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n hero=${landscape}\n hero-label=\"Hero Image Alt Text\"\n dismissable\n headline=\"Wrapped Dialog w/ Hero Image\"\n @close=${handleClose(args)}\n size=\"s\"\n >\n Content of the dialog\n </sp-dialog-wrapper>\n <sp-button\n onClick=\"this.previousElementSibling.open = !this.previousElementSibling.open\"\n variant=\"primary\"\n >\n Toggle Dialog\n </sp-button>\n `;\n};\n\nexport const wrapperDismissable = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n hero=${landscape}\n dismissable\n headline=\"Wrapped Dialog w/ Hero Image\"\n @close=${handleClose(args)}\n size=\"s\"\n >\n Content of the dialog\n </sp-dialog-wrapper>\n <sp-button\n onClick=\"this.previousElementSibling.open = !this.previousElementSibling.open\"\n variant=\"primary\"\n >\n Toggle Dialog\n </sp-button>\n `;\n};\n\nexport const wrapperDismissableUnderlay = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-button\n onClick=\"this.nextElementSibling.open = !this.nextElementSibling.open\"\n variant=\"primary\"\n >\n Toggle Dialog\n </sp-button>\n <sp-dialog-wrapper\n ?open=${open}\n hero=${landscape}\n dismissable\n headline=\"Wrapped Dialog w/ Hero Image\"\n underlay\n @close=${handleClose(args)}\n size=\"s\"\n >\n Content of the dialog\n </sp-dialog-wrapper>\n `;\n};\n\nexport const longContent = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? undefined : 'click';\n return html`\n <overlay-trigger\n type=\"modal\"\n placement=\"none\"\n @close=${handleClose(args)}\n .open=${open}\n >\n <sp-dialog-wrapper\n slot=\"click-content\"\n headline=\"Dialog title\"\n dismissable\n underlay\n size=\"s\"\n >\n <p>\n Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Sed ac dolor sit amet purus malesuada congue. Donec quis\n nibh at felis congue commodo. Ut enim ad minima veniam, quis\n nostrum exercitationem ullam corporis suscipit laboriosam,\n nisi ut aliquid ex ea commodi consequatur? Sed ac dolor sit\n amet purus malesuada congue. Nam libero tempore, cum soluta\n nobis est eligendi optio cumque nihil impedit quo minus id\n quod maxime placeat facere possimus, omnis voluptas\n assumenda est, omnis dolor repellendus. Nullam sit amet\n magna in magna gravida vehicula. Itaque earum rerum hic\n tenetur a sapiente delectus, ut aut reiciendis voluptatibus\n maiores alias consequatur aut perferendis doloribus\n asperiores repellat. Neque porro quisquam est, qui dolorem\n ipsum quia dolor sit amet, consectetur, adipisci velit, sed\n quia non numquam eius modi tempora incidunt ut labore et\n dolore magnam aliquam quaerat voluptatem. Phasellus faucibus\n molestie nisl. Vestibulum fermentum tortor id mi. Integer\n rutrum, orci vestibulum ullamcorper ultricies, lacus quam\n ultricies odio, vitae placerat pede sem sit amet enim.\n Maecenas sollicitudin. Nullam rhoncus aliquam metus.\n </p>\n <p>\n Curabitur ligula sapien, pulvinar a vestibulum quis,\n facilisis vel sapien. Fusce nibh. Proin pede metus,\n vulputate nec, fermentum fringilla, vehicula vitae, justo.\n Aenean placerat. Aliquam erat volutpat. Et harum quidem\n rerum facilis est et expedita distinctio. Fusce nibh.\n Temporibus autem quibusdam et aut officiis debitis aut rerum\n necessitatibus saepe eveniet ut et voluptates repudiandae\n sint et molestiae non recusandae. Vestibulum erat nulla,\n ullamcorper nec, rutrum non, nonummy ac, erat. Etiam posuere\n lacus quis dolor. Mauris elementum mauris vitae tortor.\n Nulla turpis magna, cursus sit amet, suscipit a, interdum\n id, felis. Nam libero tempore, cum soluta nobis est eligendi\n optio cumque nihil impedit quo minus id quod maxime placeat\n facere possimus, omnis voluptas assumenda est, omnis dolor\n repellendus. Nulla accumsan, elit sit amet varius semper,\n nulla mauris mollis quam, tempor suscipit diam nulla vel\n leo. Pellentesque sapien.\n </p>\n <p>\n Curabitur vitae diam non enim vestibulum interdum. Sed elit\n dui, pellentesque a, faucibus vel, interdum nec, diam.\n Praesent vitae arcu tempor neque lacinia pretium. Ut tempus\n purus at lorem. Phasellus rhoncus. Temporibus autem\n quibusdam et aut officiis debitis aut rerum necessitatibus\n saepe eveniet ut et voluptates repudiandae sint et molestiae\n non recusandae. Duis ante orci, molestie vitae vehicula\n venenatis, tincidunt ac pede. Integer vulputate sem a nibh\n rutrum consequat. Aenean placerat. Cum sociis natoque\n penatibus et magnis dis parturient montes, nascetur\n ridiculus mus. Sed vel lectus. Donec odio tempus molestie,\n porttitor ut, iaculis quis, sem. Class aptent taciti\n sociosqu ad litora torquent per conubia nostra, per inceptos\n hymenaeos. Integer in sapien. Nullam dapibus fermentum\n ipsum.\n </p>\n <p>\n Integer vulputate sem a nibh rutrum consequat. Class aptent\n taciti sociosqu ad litora torquent per conubia nostra, per\n inceptos hymenaeos. Duis bibendum, lectus ut viverra\n rhoncus, dolor nunc faucibus libero, eget facilisis enim\n ipsum id lacus. Aliquam erat volutpat. Aenean id metus id\n velit ullamcorper pulvinar. Morbi scelerisque luctus velit.\n Aliquam erat volutpat. Temporibus autem quibusdam et aut\n officiis debitis aut rerum necessitatibus saepe eveniet ut\n et voluptates repudiandae sint et molestiae non recusandae.\n Fusce dui leo, imperdiet in, aliquam sit amet, feugiat eu,\n orci. Suspendisse sagittis ultrices augue. Nullam justo\n enim, consectetuer nec, ullamcorper ac, vestibulum in, elit.\n Praesent vitae arcu tempor neque lacinia pretium. Nullam\n faucibus mi quis velit. Maecenas aliquet accumsan leo. Morbi\n scelerisque luctus velit. Aliquam ornare wisi eu metus.\n </p>\n <p>\n Sed elit dui, pellentesque a, faucibus vel, interdum nec,\n diam. Praesent vitae arcu tempor neque lacinia pretium.\n Etiam dictum tincidunt diam. Et harum quidem rerum facilis\n est et expedita distinctio. Duis ante orci, molestie vitae\n vehicula venenatis, tincidunt ac pede. Integer lacinia.\n Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n Mauris tincidunt sem sed arcu. Praesent in mauris eu tortor\n porttitor accumsan. Aenean id metus id velit ullamcorper\n pulvinar. Donec iaculis gravida nulla. Duis bibendum, lectus\n ut viverra rhoncus, dolor nunc faucibus libero, eget\n facilisis enim ipsum id lacus. Nulla quis diam. Quisque\n porta. Integer rutrum, orci vestibulum ullamcorper\n ultricies, lacus quam ultricies odio, vitae placerat pede\n sem sit amet enim. Nam sed tellus id magna elementum\n tincidunt. In enim a arcu imperdiet malesuada.\n </p>\n </sp-dialog-wrapper>\n <sp-button slot=\"trigger\" variant=\"primary\">\n Toggle Dialog\n </sp-button>\n </overlay-trigger>\n `;\n};\n\nexport const wrapperDismissableUnderlayError = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <div>\n <sp-button\n onClick=\"this.nextElementSibling.open = !this.nextElementSibling.open\"\n variant=\"primary\"\n >\n Toggle Dialog\n </sp-button>\n <sp-dialog-wrapper\n ?open=${open}\n hero=${landscape}\n dismissable\n error\n headline=\"Wrapped Dialog w/ Hero Image\"\n underlay\n @close=${handleClose(args)}\n size=\"s\"\n >\n Content of the dialog\n </sp-dialog-wrapper>\n </div>\n `;\n};\n\nexport const wrapperButtons = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n size=\"l\"\n headline=\"Wrapped Dialog w/ Buttons\"\n confirm-label=\"Keep Both\"\n secondary-label=\"Replace\"\n cancel-label=\"Cancel\"\n footer=\"Content for footer\"\n @close=${handleClose(args)}\n @confirm=${handleConfirm(args)}\n @secondary=${handleSecondary(args)}\n @cancel=${handleCancel(args)}\n >\n Content of the dialog\n </sp-dialog-wrapper>\n `;\n};\n\nexport const wrapperButtonsUnderlay = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n underlay\n size=\"l\"\n headline=\"Wrapped Dialog w/ Buttons\"\n confirm-label=\"Keep Both\"\n secondary-label=\"Replace\"\n cancel-label=\"Cancel\"\n footer=\"Content for footer\"\n @close=${handleClose(args)}\n @confirm=${handleConfirm(args)}\n @secondary=${handleSecondary(args)}\n @cancel=${handleCancel(args)}\n >\n Content of the dialog\n </sp-dialog-wrapper>\n `;\n};\n\nexport const wrapperFullscreen = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n headline=\"Wrapped Dialog - Fullscreen\"\n mode=\"fullscreen\"\n confirm-label=\"Keep Both\"\n secondary-label=\"Replace\"\n cancel-label=\"Cancel\"\n @close=${handleClose(args)}\n @confirm=${handleConfirm(args)}\n @secondary=${handleSecondary(args)}\n @cancel=${handleCancel(args)}\n >\n Content of the dialog\n </sp-dialog-wrapper>\n `;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"dialog-wrapper.stories.js","sourceRoot":"","sources":["dialog-wrapper.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OAAO,8CAA8C,CAAC;AACtD,OAAO,wDAAwD,CAAC;AAChE,OAAO,oDAAoD,CAAC;AAC5D,OAAO,oDAAoD,CAAC;AAC5D,OAAO,qDAAqD,CAAC;AAE7D,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAe;IACX,KAAK,EAAE,gBAAgB;IACvB,SAAS,EAAE,mBAAmB;IAC9B,QAAQ,EAAE;QACN,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;QAC5B,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;QAChC,WAAW,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;QACpC,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;KACj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AK,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,OAAO,IAAI,CAAA;;oBAEK,IAAI;;;;;;;qBAOH,WAAW,CAAC,IAAI,CAAC;uBACf,aAAa,CAAC,IAAI,CAAC;yBACjB,eAAe,CAAC,IAAI,CAAC;sBACxB,YAAY,CAAC,IAAI,CAAC;;;;KAInC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,OAAkB,EAAE,EACpB,UAAiC,EAAE,EACrB,EAAE;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,OAAO,IAAI,CAAA;;oBAEK,IAAI;;;;;;;;qBAQH,WAAW,CAAC,IAAI,CAAC;uBACf,aAAa,CAAC,IAAI,CAAC;yBACjB,eAAe,CAAC,IAAI,CAAC;sBACxB,YAAY,CAAC,IAAI,CAAC;;;;KAInC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC7B,OAAkB,EAAE,EACpB,UAAiC,EAAE,EACrB,EAAE;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,OAAO,IAAI,CAAA;;oBAEK,IAAI;;;;;;qBAMH,WAAW,CAAC,IAAI,CAAC;uBACf,aAAa,CAAC,IAAI,CAAC;yBACjB,eAAe,CAAC,IAAI,CAAC;sBACxB,YAAY,CAAC,IAAI,CAAC;;;;KAInC,CAAC;AACN,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*/\n\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '@spectrum-web-components/button/sp-button.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport '@spectrum-web-components/help-text/sp-help-text.js';\nimport '@spectrum-web-components/textfield/sp-textfield.js';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\n\nimport '../sp-dialog-wrapper.js';\nimport { landscape } from './images.js';\n\nexport default {\n title: 'Dialog Wrapped',\n component: 'sp-dialog-wrapper',\n argTypes: {\n onClose: { action: 'close' },\n onConfirm: { action: 'confirm' },\n onSecondary: { action: 'secondary' },\n onCancel: { action: 'cancel' },\n },\n};\n\ntype StoryArgs = {\n onClose?: (event: Event) => void;\n onConfirm?: (event: Event) => void;\n onSecondary?: (event: Event) => void;\n onCancel?: (event: Event) => void;\n};\n\nconst handleClose =\n ({ onClose }: StoryArgs) =>\n (event: Event) => {\n if (onClose) onClose(event);\n };\n\nconst handleConfirm =\n ({ onConfirm }: StoryArgs) =>\n (event: Event) => {\n if (onConfirm) onConfirm(event);\n };\n\nconst handleSecondary =\n ({ onSecondary }: StoryArgs) =>\n (event: Event) => {\n if (onSecondary) onSecondary(event);\n };\n\nconst handleCancel =\n ({ onCancel }: StoryArgs) =>\n (event: Event) => {\n if (onCancel) onCancel(event);\n };\n\nexport const wrapperLabeledHero = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n hero=${landscape}\n hero-label=\"Hero Image Alt Text\"\n dismissable\n headline=\"Wrapped Dialog w/ Hero Image\"\n @close=${handleClose(args)}\n size=\"s\"\n >\n Content of the dialog\n </sp-dialog-wrapper>\n <sp-button\n onClick=\"\n this.previousElementSibling.open = !this.previousElementSibling.open;\n if (this.previousElementSibling.open) {\n this.previousElementSibling.focus();\n }\n \"\n variant=\"primary\"\n >\n Toggle Dialog\n </sp-button>\n `;\n};\n\nexport const wrapperDismissable = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n hero=${landscape}\n dismissable\n headline=\"Wrapped Dialog w/ Hero Image\"\n @close=${handleClose(args)}\n size=\"s\"\n >\n Content of the dialog\n </sp-dialog-wrapper>\n <sp-button\n onClick=\"\n this.previousElementSibling.open = !this.previousElementSibling.open;\n if (this.previousElementSibling.open) {\n this.previousElementSibling.focus();\n }\n \"\n variant=\"primary\"\n >\n Toggle Dialog\n </sp-button>\n `;\n};\n\nexport const wrapperDismissableUnderlay = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n hero=${landscape}\n dismissable\n headline=\"Wrapped Dialog w/ Hero Image\"\n underlay\n @close=${handleClose(args)}\n size=\"s\"\n >\n Content of the dialog\n </sp-dialog-wrapper>\n <sp-button\n onClick=\"\n this.previousElementSibling.open = !this.previousElementSibling.open;\n if (this.previousElementSibling.open) {\n this.previousElementSibling.focus();\n }\n \"\n variant=\"primary\"\n >\n Toggle Dialog\n </sp-button>\n `;\n};\n\nexport const form = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? undefined : 'click';\n return html`\n <overlay-trigger\n type=\"modal\"\n placement=\"none\"\n @close=${handleClose(args)}\n open=${ifDefined(open)}\n >\n <sp-button slot=\"trigger\" variant=\"primary\">\n Toggle Dialog\n </sp-button>\n <sp-dialog-wrapper\n id=\"form-fields\"\n slot=\"click-content\"\n headline=\"Add Delivery Address\"\n underlay\n size=\"m\"\n confirm-label=\"Verify Address\"\n secondary-label=\"Add\"\n cancel-label=\"Cancel\"\n @close=${handleClose(args)}\n @confirm=${({ target }: Event & { target: HTMLElement }) => {\n target.dispatchEvent(\n new Event('close', { bubbles: true, composed: true })\n );\n handleConfirm(args);\n }}\n @secondary=${({ target }: Event & { target: HTMLElement }) => {\n target.dispatchEvent(\n new Event('close', { bubbles: true, composed: true })\n );\n handleSecondary(args);\n }}\n @cancel=${({ target }: Event & { target: HTMLElement }) => {\n target.dispatchEvent(\n new Event('close', { bubbles: true, composed: true })\n );\n handleCancel(args);\n }}\n >\n <style>\n #form-fields div {\n display: grid;\n gap: var(--spectrum-global-dimension-size-150);\n grid-template-columns: auto auto;\n\n --spectrum-fieldlabel-m-side-padding-right: 0;\n }\n </style>\n <div>\n <sp-field-label side-aligned=\"end\" for=\"street\">\n Street:\n </sp-field-label>\n <sp-textfield id=\"street\" autofocus></sp-textfield>\n <sp-field-label side-aligned=\"end\" for=\"city\">\n City:\n </sp-field-label>\n <sp-textfield id=\"city\"></sp-textfield>\n <sp-field-label side-aligned=\"end\" for=\"state\">\n State:\n </sp-field-label>\n <sp-textfield id=\"state\"></sp-textfield>\n <sp-field-label side-aligned=\"end\" for=\"zip\">\n Zip:\n </sp-field-label>\n <sp-textfield id=\"zip\"></sp-textfield>\n <sp-field-label side-aligned=\"end\" for=\"instructions\">\n Special instructions:\n </sp-field-label>\n <sp-textfield id=\"instructions\" multiline>\n <sp-help-text slot=\"help-text\">\n For example, gate code or other information to help\n the driver find you\n </sp-help-text>\n </sp-textfield>\n </div>\n </sp-dialog-wrapper>\n </overlay-trigger>\n `;\n};\n\nexport const longContent = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? undefined : 'click';\n return html`\n <overlay-trigger\n type=\"modal\"\n placement=\"none\"\n @close=${handleClose(args)}\n open=${ifDefined(open)}\n >\n <sp-button slot=\"trigger\" variant=\"primary\">\n Toggle Dialog\n </sp-button>\n <sp-dialog-wrapper\n slot=\"click-content\"\n headline=\"Dialog title\"\n dismissable\n underlay\n size=\"s\"\n >\n <p>\n Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Sed ac dolor sit amet purus malesuada congue. Donec quis\n nibh at felis congue commodo. Ut enim ad minima veniam, quis\n nostrum exercitationem ullam corporis suscipit laboriosam,\n nisi ut aliquid ex ea commodi consequatur? Sed ac dolor sit\n amet purus malesuada congue. Nam libero tempore, cum soluta\n nobis est eligendi optio cumque nihil impedit quo minus id\n quod maxime placeat facere possimus, omnis voluptas\n assumenda est, omnis dolor repellendus. Nullam sit amet\n magna in magna gravida vehicula. Itaque earum rerum hic\n tenetur a sapiente delectus, ut aut reiciendis voluptatibus\n maiores alias consequatur aut perferendis doloribus\n asperiores repellat. Neque porro quisquam est, qui dolorem\n ipsum quia dolor sit amet, consectetur, adipisci velit, sed\n quia non numquam eius modi tempora incidunt ut labore et\n dolore magnam aliquam quaerat voluptatem. Phasellus faucibus\n molestie nisl. Vestibulum fermentum tortor id mi. Integer\n rutrum, orci vestibulum ullamcorper ultricies, lacus quam\n ultricies odio, vitae placerat pede sem sit amet enim.\n Maecenas sollicitudin. Nullam rhoncus aliquam metus.\n </p>\n <p>\n Curabitur ligula sapien, pulvinar a vestibulum quis,\n facilisis vel sapien. Fusce nibh. Proin pede metus,\n vulputate nec, fermentum fringilla, vehicula vitae, justo.\n Aenean placerat. Aliquam erat volutpat. Et harum quidem\n rerum facilis est et expedita distinctio. Fusce nibh.\n Temporibus autem quibusdam et aut officiis debitis aut rerum\n necessitatibus saepe eveniet ut et voluptates repudiandae\n sint et molestiae non recusandae. Vestibulum erat nulla,\n ullamcorper nec, rutrum non, nonummy ac, erat. Etiam posuere\n lacus quis dolor. Mauris elementum mauris vitae tortor.\n Nulla turpis magna, cursus sit amet, suscipit a, interdum\n id, felis. Nam libero tempore, cum soluta nobis est eligendi\n optio cumque nihil impedit quo minus id quod maxime placeat\n facere possimus, omnis voluptas assumenda est, omnis dolor\n repellendus. Nulla accumsan, elit sit amet varius semper,\n nulla mauris mollis quam, tempor suscipit diam nulla vel\n leo. Pellentesque sapien.\n </p>\n <p>\n Curabitur vitae diam non enim vestibulum interdum. Sed elit\n dui, pellentesque a, faucibus vel, interdum nec, diam.\n Praesent vitae arcu tempor neque lacinia pretium. Ut tempus\n purus at lorem. Phasellus rhoncus. Temporibus autem\n quibusdam et aut officiis debitis aut rerum necessitatibus\n saepe eveniet ut et voluptates repudiandae sint et molestiae\n non recusandae. Duis ante orci, molestie vitae vehicula\n venenatis, tincidunt ac pede. Integer vulputate sem a nibh\n rutrum consequat. Aenean placerat. Cum sociis natoque\n penatibus et magnis dis parturient montes, nascetur\n ridiculus mus. Sed vel lectus. Donec odio tempus molestie,\n porttitor ut, iaculis quis, sem. Class aptent taciti\n sociosqu ad litora torquent per conubia nostra, per inceptos\n hymenaeos. Integer in sapien. Nullam dapibus fermentum\n ipsum.\n </p>\n <p>\n Integer vulputate sem a nibh rutrum consequat. Class aptent\n taciti sociosqu ad litora torquent per conubia nostra, per\n inceptos hymenaeos. Duis bibendum, lectus ut viverra\n rhoncus, dolor nunc faucibus libero, eget facilisis enim\n ipsum id lacus. Aliquam erat volutpat. Aenean id metus id\n velit ullamcorper pulvinar. Morbi scelerisque luctus velit.\n Aliquam erat volutpat. Temporibus autem quibusdam et aut\n officiis debitis aut rerum necessitatibus saepe eveniet ut\n et voluptates repudiandae sint et molestiae non recusandae.\n Fusce dui leo, imperdiet in, aliquam sit amet, feugiat eu,\n orci. Suspendisse sagittis ultrices augue. Nullam justo\n enim, consectetuer nec, ullamcorper ac, vestibulum in, elit.\n Praesent vitae arcu tempor neque lacinia pretium. Nullam\n faucibus mi quis velit. Maecenas aliquet accumsan leo. Morbi\n scelerisque luctus velit. Aliquam ornare wisi eu metus.\n </p>\n <p>\n Sed elit dui, pellentesque a, faucibus vel, interdum nec,\n diam. Praesent vitae arcu tempor neque lacinia pretium.\n Etiam dictum tincidunt diam. Et harum quidem rerum facilis\n est et expedita distinctio. Duis ante orci, molestie vitae\n vehicula venenatis, tincidunt ac pede. Integer lacinia.\n Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n Mauris tincidunt sem sed arcu. Praesent in mauris eu tortor\n porttitor accumsan. Aenean id metus id velit ullamcorper\n pulvinar. Donec iaculis gravida nulla. Duis bibendum, lectus\n ut viverra rhoncus, dolor nunc faucibus libero, eget\n facilisis enim ipsum id lacus. Nulla quis diam. Quisque\n porta. Integer rutrum, orci vestibulum ullamcorper\n ultricies, lacus quam ultricies odio, vitae placerat pede\n sem sit amet enim. Nam sed tellus id magna elementum\n tincidunt. In enim a arcu imperdiet malesuada.\n </p>\n </sp-dialog-wrapper>\n </overlay-trigger>\n `;\n};\n\nexport const wrapperDismissableUnderlayError = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <div>\n <sp-button\n onClick=\"\n this.previousElementSibling.open = !this.previousElementSibling.open;\n if (this.previousElementSibling.open) {\n this.previousElementSibling.focus();\n }\n \"\n variant=\"primary\"\n >\n Toggle Dialog\n </sp-button>\n <sp-dialog-wrapper\n ?open=${open}\n hero=${landscape}\n dismissable\n error\n headline=\"Wrapped Dialog w/ Hero Image\"\n underlay\n @close=${handleClose(args)}\n size=\"s\"\n >\n Content of the dialog\n </sp-dialog-wrapper>\n </div>\n `;\n};\n\nexport const wrapperButtons = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n size=\"l\"\n headline=\"Wrapped Dialog w/ Buttons\"\n confirm-label=\"Keep Both\"\n secondary-label=\"Replace\"\n cancel-label=\"Cancel\"\n footer=\"Content for footer\"\n @close=${handleClose(args)}\n @confirm=${handleConfirm(args)}\n @secondary=${handleSecondary(args)}\n @cancel=${handleCancel(args)}\n >\n Content of the dialog\n </sp-dialog-wrapper>\n `;\n};\n\nexport const wrapperButtonsUnderlay = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n underlay\n size=\"l\"\n headline=\"Wrapped Dialog w/ Buttons\"\n confirm-label=\"Keep Both\"\n secondary-label=\"Replace\"\n cancel-label=\"Cancel\"\n footer=\"Content for footer\"\n @close=${handleClose(args)}\n @confirm=${handleConfirm(args)}\n @secondary=${handleSecondary(args)}\n @cancel=${handleCancel(args)}\n >\n Content of the dialog\n </sp-dialog-wrapper>\n `;\n};\n\nexport const wrapperFullscreen = (\n args: StoryArgs = {},\n context: { viewMode?: string } = {}\n): TemplateResult => {\n const open = context.viewMode === 'docs' ? false : true;\n return html`\n <sp-dialog-wrapper\n ?open=${open}\n headline=\"Wrapped Dialog - Fullscreen\"\n mode=\"fullscreen\"\n confirm-label=\"Keep Both\"\n secondary-label=\"Replace\"\n cancel-label=\"Cancel\"\n @close=${handleClose(args)}\n @confirm=${handleConfirm(args)}\n @secondary=${handleSecondary(args)}\n @cancel=${handleCancel(args)}\n >\n Content of the dialog\n </sp-dialog-wrapper>\n `;\n};\n"]}
|