@spectrum-web-components/dialog 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +22 -0
- package/package.json +11 -12
- package/src/DialogBase.d.ts +1 -0
- package/src/DialogBase.dev.js +19 -3
- package/src/DialogBase.dev.js.map +2 -2
- package/src/DialogBase.js +3 -3
- package/src/DialogBase.js.map +3 -3
- package/LICENSE +0 -201
- package/stories/dialog-base.stories.js +0 -196
- package/stories/dialog-base.stories.js.map +0 -7
- package/stories/dialog-wrapper.stories.js +0 -578
- package/stories/dialog-wrapper.stories.js.map +0 -7
- package/stories/dialog.stories.js +0 -510
- package/stories/dialog.stories.js.map +0 -7
- package/stories/images.js +0 -4
- package/stories/images.js.map +0 -7
- package/stories/index.js +0 -30
- package/stories/index.js.map +0 -7
- package/test/benchmark/basic-test.js +0 -20
- package/test/benchmark/basic-test.js.map +0 -7
- package/test/dialog-base.test-vrt.js +0 -5
- package/test/dialog-base.test-vrt.js.map +0 -7
- package/test/dialog-base.test.js +0 -106
- package/test/dialog-base.test.js.map +0 -7
- package/test/dialog-memory.test.js +0 -5
- package/test/dialog-memory.test.js.map +0 -7
- package/test/dialog-wrapper.test-vrt.js +0 -5
- package/test/dialog-wrapper.test-vrt.js.map +0 -7
- package/test/dialog-wrapper.test.js +0 -320
- package/test/dialog-wrapper.test.js.map +0 -7
- package/test/dialog.test-vrt.js +0 -5
- package/test/dialog.test-vrt.js.map +0 -7
- package/test/dialog.test.js +0 -221
- package/test/dialog.test.js.map +0 -7
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { html } from "@spectrum-web-components/base";
|
|
3
|
-
import "@spectrum-web-components/dialog/sp-dialog-base.js";
|
|
4
|
-
import "@spectrum-web-components/dialog/sp-dialog.js";
|
|
5
|
-
import "@spectrum-web-components/button/sp-button.js";
|
|
6
|
-
import "@spectrum-web-components/overlay/sp-overlay.js";
|
|
7
|
-
import "@spectrum-web-components/checkbox/sp-checkbox.js";
|
|
8
|
-
import { alertDestructive } from "./dialog.stories.js";
|
|
9
|
-
import { portrait } from "./images.js";
|
|
10
|
-
import { disabledButtonDecorator } from "./index.js";
|
|
11
|
-
export default {
|
|
12
|
-
title: "Dialog Base",
|
|
13
|
-
component: "sp-dialog-base",
|
|
14
|
-
decorators: [
|
|
15
|
-
(story) => {
|
|
16
|
-
return html`
|
|
17
|
-
<sp-button variant="primary" id="trigger">
|
|
18
|
-
Toggle Dialog
|
|
19
|
-
</sp-button>
|
|
20
|
-
<sp-overlay type="modal" trigger="trigger@click" open>
|
|
21
|
-
${story()}
|
|
22
|
-
</sp-overlay>
|
|
23
|
-
`;
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
};
|
|
27
|
-
export const Slotted = () => html`
|
|
28
|
-
<sp-dialog-base
|
|
29
|
-
underlay
|
|
30
|
-
@click=${(event) => {
|
|
31
|
-
if (event.target.localName === "sp-button") {
|
|
32
|
-
event.target.dispatchEvent(
|
|
33
|
-
new Event("close", { bubbles: true, composed: true })
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
${alertDestructive()}
|
|
39
|
-
</sp-dialog-base>
|
|
40
|
-
`;
|
|
41
|
-
export const disabledButton = () => {
|
|
42
|
-
return html`
|
|
43
|
-
<sp-dialog-base
|
|
44
|
-
underlay
|
|
45
|
-
@click=${(event) => {
|
|
46
|
-
if (event.target.localName === "sp-button") {
|
|
47
|
-
event.target.dispatchEvent(
|
|
48
|
-
new Event("close", { bubbles: true, composed: true })
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}}
|
|
52
|
-
@sp-opened=${({ target }) => {
|
|
53
|
-
let count = 5;
|
|
54
|
-
const timer = setInterval(() => {
|
|
55
|
-
count -= 1;
|
|
56
|
-
if (!count) {
|
|
57
|
-
document.querySelector(
|
|
58
|
-
"#changing-header"
|
|
59
|
-
).textContent = "The button in this dialog is now enabled";
|
|
60
|
-
document.querySelector(
|
|
61
|
-
"#changing-button"
|
|
62
|
-
).disabled = false;
|
|
63
|
-
clearInterval(timer);
|
|
64
|
-
target.dispatchEvent(new Event("countdown-complete"));
|
|
65
|
-
}
|
|
66
|
-
document.querySelector(".time").textContent = count.toString();
|
|
67
|
-
}, 1e3);
|
|
68
|
-
}}
|
|
69
|
-
@close=${() => {
|
|
70
|
-
document.querySelector("#changing-header").textContent = "The button in this dialog is disabled";
|
|
71
|
-
document.querySelector(
|
|
72
|
-
"#changing-button"
|
|
73
|
-
).disabled = true;
|
|
74
|
-
document.querySelector(".time").textContent = "5";
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<sp-dialog size="s">
|
|
78
|
-
<h2 slot="heading" id="changing-header">
|
|
79
|
-
The button in this dialog is disabled
|
|
80
|
-
</h2>
|
|
81
|
-
<p>
|
|
82
|
-
After about
|
|
83
|
-
<span class="time">5</span>
|
|
84
|
-
seconds the button with be enabled.
|
|
85
|
-
</p>
|
|
86
|
-
<sp-button disabled slot="button" id="changing-button">
|
|
87
|
-
Ok
|
|
88
|
-
</sp-button>
|
|
89
|
-
</sp-dialog>
|
|
90
|
-
</sp-dialog-base>
|
|
91
|
-
`;
|
|
92
|
-
};
|
|
93
|
-
disabledButton.decorators = [disabledButtonDecorator];
|
|
94
|
-
export const notAgain = () => html`
|
|
95
|
-
<sp-dialog-base
|
|
96
|
-
underlay
|
|
97
|
-
@click=${(event) => {
|
|
98
|
-
if (event.target.localName === "sp-button") {
|
|
99
|
-
event.target.dispatchEvent(
|
|
100
|
-
new Event("close", { bubbles: true, composed: true })
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
<sp-dialog size="s">
|
|
106
|
-
<h2 slot="heading">A thing is about to happen</h2>
|
|
107
|
-
<p>Something that might happen a lot is about to happen.</p>
|
|
108
|
-
<p>
|
|
109
|
-
The click events for the "OK" button are bound to the story not
|
|
110
|
-
to the components in specific.
|
|
111
|
-
</p>
|
|
112
|
-
<sp-button variant="secondary" treatment="fill" slot="button">
|
|
113
|
-
Ok
|
|
114
|
-
</sp-button>
|
|
115
|
-
<sp-checkbox slot="footer">Don't show me this again</sp-checkbox>
|
|
116
|
-
</sp-dialog>
|
|
117
|
-
</sp-dialog-base>
|
|
118
|
-
`;
|
|
119
|
-
export const moreCustom = () => html`
|
|
120
|
-
<sp-dialog-base
|
|
121
|
-
underlay
|
|
122
|
-
@click=${(event) => {
|
|
123
|
-
if (event.target.localName === "sp-button") {
|
|
124
|
-
event.target.dispatchEvent(
|
|
125
|
-
new Event("close", { bubbles: true, composed: true })
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}}
|
|
129
|
-
>
|
|
130
|
-
<div style="display: flex;">
|
|
131
|
-
<div
|
|
132
|
-
style="
|
|
133
|
-
display: grid;
|
|
134
|
-
place-content: center;
|
|
135
|
-
grid-template-columns: calc(100% - 40px);
|
|
136
|
-
grid-template-rows: calc(100% - 40px);
|
|
137
|
-
"
|
|
138
|
-
>
|
|
139
|
-
<img
|
|
140
|
-
src=${portrait}
|
|
141
|
-
alt=""
|
|
142
|
-
style="
|
|
143
|
-
width: 100%;
|
|
144
|
-
height: 100%;
|
|
145
|
-
object-fit: contain;
|
|
146
|
-
object-placement: center;
|
|
147
|
-
"
|
|
148
|
-
/>
|
|
149
|
-
</div>
|
|
150
|
-
<sp-dialog size="s">
|
|
151
|
-
<h2 slot="heading">Look at that image</h2>
|
|
152
|
-
<p>
|
|
153
|
-
Its position has been customized beyond the language of
|
|
154
|
-
Spectrum. Be careful with all this power. There's no
|
|
155
|
-
"mobile" default for delivering content like this.
|
|
156
|
-
</p>
|
|
157
|
-
<sp-button variant="accent" treatment="outline" slot="button">
|
|
158
|
-
Ok
|
|
159
|
-
</sp-button>
|
|
160
|
-
</sp-dialog>
|
|
161
|
-
</div>
|
|
162
|
-
</sp-dialog-base>
|
|
163
|
-
`;
|
|
164
|
-
export const fullyCustom = () => html`
|
|
165
|
-
<sp-dialog-base
|
|
166
|
-
underlay
|
|
167
|
-
@click=${(event) => {
|
|
168
|
-
if (event.target.localName === "button") {
|
|
169
|
-
event.target.dispatchEvent(
|
|
170
|
-
new Event("close", { bubbles: true, composed: true })
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
}}
|
|
174
|
-
>
|
|
175
|
-
<div id="fully-custom-dialog">
|
|
176
|
-
<style>
|
|
177
|
-
#fully-custom-dialog {
|
|
178
|
-
margin: 1em;
|
|
179
|
-
}
|
|
180
|
-
</style>
|
|
181
|
-
<h2>Custom headline</h2>
|
|
182
|
-
<p>
|
|
183
|
-
The click events for the "Done" button are bound to the story
|
|
184
|
-
not to the components in specific.
|
|
185
|
-
</p>
|
|
186
|
-
<p>
|
|
187
|
-
This is a demonstration of what is possible with
|
|
188
|
-
<sp-dialog-base>, only, and should not be seen as an
|
|
189
|
-
endorsement for fully custom dialog UIs.
|
|
190
|
-
</p>
|
|
191
|
-
<p>Fully open content area, for whatever DOM you would like.</p>
|
|
192
|
-
<button>Done</button>
|
|
193
|
-
</div>
|
|
194
|
-
</sp-dialog-base>
|
|
195
|
-
`;
|
|
196
|
-
//# sourceMappingURL=dialog-base.stories.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["dialog-base.stories.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\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 '@spectrum-web-components/dialog/sp-dialog-base.js';\nimport '@spectrum-web-components/dialog/sp-dialog.js';\nimport '@spectrum-web-components/button/sp-button.js';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\nimport '@spectrum-web-components/checkbox/sp-checkbox.js';\nimport { alertDestructive } from './dialog.stories.js';\nimport { portrait } from './images.js';\nimport { disabledButtonDecorator } from './index.js';\n\nexport default {\n title: 'Dialog Base',\n component: 'sp-dialog-base',\n decorators: [\n (story: () => TemplateResult): TemplateResult => {\n return html`\n <sp-button variant=\"primary\" id=\"trigger\">\n Toggle Dialog\n </sp-button>\n <sp-overlay type=\"modal\" trigger=\"trigger@click\" open>\n ${story()}\n </sp-overlay>\n `;\n },\n ],\n};\n\nexport const Slotted = (): TemplateResult => html`\n <sp-dialog-base\n underlay\n @click=${(event: Event) => {\n if ((event.target as HTMLElement).localName === 'sp-button') {\n (event.target as HTMLElement).dispatchEvent(\n new Event('close', { bubbles: true, composed: true })\n );\n }\n }}\n >\n ${alertDestructive()}\n </sp-dialog-base>\n`;\n\nexport const disabledButton = (): TemplateResult => {\n return html`\n <sp-dialog-base\n underlay\n @click=${(event: Event) => {\n if ((event.target as HTMLElement).localName === 'sp-button') {\n (event.target as HTMLElement).dispatchEvent(\n new Event('close', { bubbles: true, composed: true })\n );\n }\n }}\n @sp-opened=${({ target }: Event & { target: HTMLElement }) => {\n let count = 5;\n const timer = setInterval(() => {\n count -= 1;\n if (!count) {\n (\n document.querySelector(\n '#changing-header'\n ) as HTMLElement\n ).textContent =\n 'The button in this dialog is now enabled';\n (\n document.querySelector(\n '#changing-button'\n ) as HTMLButtonElement\n ).disabled = false;\n clearInterval(timer);\n target.dispatchEvent(new Event('countdown-complete'));\n }\n (\n document.querySelector('.time') as HTMLElement\n ).textContent = count.toString();\n }, 1000);\n }}\n @close=${() => {\n (\n document.querySelector('#changing-header') as HTMLElement\n ).textContent = 'The button in this dialog is disabled';\n (\n document.querySelector(\n '#changing-button'\n ) as HTMLButtonElement\n ).disabled = true;\n (document.querySelector('.time') as HTMLElement).textContent =\n '5';\n }}\n >\n <sp-dialog size=\"s\">\n <h2 slot=\"heading\" id=\"changing-header\">\n The button in this dialog is disabled\n </h2>\n <p>\n After about\n <span class=\"time\">5</span>\n seconds the button with be enabled.\n </p>\n <sp-button disabled slot=\"button\" id=\"changing-button\">\n Ok\n </sp-button>\n </sp-dialog>\n </sp-dialog-base>\n `;\n};\n\ndisabledButton.decorators = [disabledButtonDecorator];\n\nexport const notAgain = (): TemplateResult => html`\n <sp-dialog-base\n underlay\n @click=${(event: Event) => {\n if ((event.target as HTMLElement).localName === 'sp-button') {\n (event.target as HTMLElement).dispatchEvent(\n new Event('close', { bubbles: true, composed: true })\n );\n }\n }}\n >\n <sp-dialog size=\"s\">\n <h2 slot=\"heading\">A thing is about to happen</h2>\n <p>Something that might happen a lot is about to happen.</p>\n <p>\n The click events for the \"OK\" button are bound to the story not\n to the components in specific.\n </p>\n <sp-button variant=\"secondary\" treatment=\"fill\" slot=\"button\">\n Ok\n </sp-button>\n <sp-checkbox slot=\"footer\">Don't show me this again</sp-checkbox>\n </sp-dialog>\n </sp-dialog-base>\n`;\n\nexport const moreCustom = (): TemplateResult => html`\n <sp-dialog-base\n underlay\n @click=${(event: Event) => {\n if ((event.target as HTMLElement).localName === 'sp-button') {\n (event.target as HTMLElement).dispatchEvent(\n new Event('close', { bubbles: true, composed: true })\n );\n }\n }}\n >\n <div style=\"display: flex;\">\n <div\n style=\"\n display: grid;\n place-content: center;\n grid-template-columns: calc(100% - 40px);\n grid-template-rows: calc(100% - 40px);\n \"\n >\n <img\n src=${portrait}\n alt=\"\"\n style=\"\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-placement: center;\n \"\n />\n </div>\n <sp-dialog size=\"s\">\n <h2 slot=\"heading\">Look at that image</h2>\n <p>\n Its position has been customized beyond the language of\n Spectrum. Be careful with all this power. There's no\n \"mobile\" default for delivering content like this.\n </p>\n <sp-button variant=\"accent\" treatment=\"outline\" slot=\"button\">\n Ok\n </sp-button>\n </sp-dialog>\n </div>\n </sp-dialog-base>\n`;\n\nexport const fullyCustom = (): TemplateResult => html`\n <sp-dialog-base\n underlay\n @click=${(event: Event) => {\n if ((event.target as HTMLElement).localName === 'button') {\n (event.target as HTMLElement).dispatchEvent(\n new Event('close', { bubbles: true, composed: true })\n );\n }\n }}\n >\n <div id=\"fully-custom-dialog\">\n <style>\n #fully-custom-dialog {\n margin: 1em;\n }\n </style>\n <h2>Custom headline</h2>\n <p>\n The click events for the \"Done\" button are bound to the story\n not to the components in specific.\n </p>\n <p>\n This is a demonstration of what is possible with\n <sp-dialog-base>, only, and should not be seen as an\n endorsement for fully custom dialog UIs.\n </p>\n <p>Fully open content area, for whatever DOM you would like.</p>\n <button>Done</button>\n </div>\n </sp-dialog-base>\n`;\n"],
|
|
5
|
-
"mappings": ";AAWA,SAAS,YAA4B;AACrC,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,+BAA+B;AAExC,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,IACR,CAAC,UAAgD;AAC7C,aAAO;AAAA;AAAA;AAAA;AAAA;AAAA,sBAKG,MAAM,CAAC;AAAA;AAAA;AAAA,IAGrB;AAAA,EACJ;AACJ;AAEO,aAAM,UAAU,MAAsB;AAAA;AAAA;AAAA,iBAG5B,CAAC,UAAiB;AACvB,MAAK,MAAM,OAAuB,cAAc,aAAa;AACzD,IAAC,MAAM,OAAuB;AAAA,MAC1B,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC;AAAA,IACxD;AAAA,EACJ;AACJ,CAAC;AAAA;AAAA,UAEC,iBAAiB,CAAC;AAAA;AAAA;AAIrB,aAAM,iBAAiB,MAAsB;AAChD,SAAO;AAAA;AAAA;AAAA,qBAGU,CAAC,UAAiB;AACvB,QAAK,MAAM,OAAuB,cA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