@spectrum-web-components/button 0.19.0-devmode.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/sp-button.js +1 -2
- package/sp-button.js.map +1 -1
- package/sp-clear-button.js +1 -2
- package/sp-clear-button.js.map +1 -1
- package/sp-close-button.js +1 -2
- package/sp-close-button.js.map +1 -1
- package/src/Button.js +1 -78
- package/src/Button.js.map +1 -1
- package/src/ButtonBase.js +6 -205
- package/src/ButtonBase.js.map +1 -1
- package/src/ClearButton.js +6 -52
- package/src/ClearButton.js.map +1 -1
- package/src/CloseButton.js +5 -48
- package/src/CloseButton.js.map +1 -1
- package/src/StyledButton.js +1 -7
- package/src/StyledButton.js.map +1 -1
- package/src/button-base.css.js +2 -4
- package/src/button-base.css.js.map +1 -1
- package/src/button.css.js +2 -4
- package/src/button.css.js.map +1 -1
- package/src/index.js +1 -5
- package/src/index.js.map +1 -1
- package/src/spectrum-button-base.css.js +2 -4
- package/src/spectrum-button-base.css.js.map +1 -1
- package/src/spectrum-button.css.js +2 -4
- package/src/spectrum-button.css.js.map +1 -1
- package/stories/button-accent-fill-sizes.stories.js +1 -30
- package/stories/button-accent-fill-sizes.stories.js.map +1 -1
- package/stories/button-accent-fill.stories.js +1 -31
- package/stories/button-accent-fill.stories.js.map +1 -1
- package/stories/button-accent-outline-sizes.stories.js +1 -30
- package/stories/button-accent-outline-sizes.stories.js.map +1 -1
- package/stories/button-accent-outline.stories.js +1 -31
- package/stories/button-accent-outline.stories.js.map +1 -1
- package/stories/button-black-fill-sizes.stories.js +1 -31
- package/stories/button-black-fill-sizes.stories.js.map +1 -1
- package/stories/button-black-fill.stories.js +1 -33
- package/stories/button-black-fill.stories.js.map +1 -1
- package/stories/button-black-outline-sizes.stories.js +1 -31
- package/stories/button-black-outline-sizes.stories.js.map +1 -1
- package/stories/button-black-outline.stories.js +1 -33
- package/stories/button-black-outline.stories.js.map +1 -1
- package/stories/button-negative-fill-sizes.stories.js +1 -30
- package/stories/button-negative-fill-sizes.stories.js.map +1 -1
- package/stories/button-negative-fill.stories.js +1 -31
- package/stories/button-negative-fill.stories.js.map +1 -1
- package/stories/button-negative-outline-sizes.stories.js +1 -30
- package/stories/button-negative-outline-sizes.stories.js.map +1 -1
- package/stories/button-negative-outline.stories.js +1 -31
- package/stories/button-negative-outline.stories.js.map +1 -1
- package/stories/button-primary-fill-sizes.stories.js +1 -30
- package/stories/button-primary-fill-sizes.stories.js.map +1 -1
- package/stories/button-primary-fill.stories.js +1 -31
- package/stories/button-primary-fill.stories.js.map +1 -1
- package/stories/button-primary-outline-sizes.stories.js +1 -30
- package/stories/button-primary-outline-sizes.stories.js.map +1 -1
- package/stories/button-primary-outline.stories.js +1 -31
- package/stories/button-primary-outline.stories.js.map +1 -1
- package/stories/button-secondary-fill-sizes.stories.js +1 -30
- package/stories/button-secondary-fill-sizes.stories.js.map +1 -1
- package/stories/button-secondary-fill.stories.js +1 -31
- package/stories/button-secondary-fill.stories.js.map +1 -1
- package/stories/button-secondary-outline-sizes.stories.js +1 -30
- package/stories/button-secondary-outline-sizes.stories.js.map +1 -1
- package/stories/button-secondary-outline.stories.js +1 -31
- package/stories/button-secondary-outline.stories.js.map +1 -1
- package/stories/button-white-fill-sizes.stories.js +1 -31
- package/stories/button-white-fill-sizes.stories.js.map +1 -1
- package/stories/button-white-fill.stories.js +1 -33
- package/stories/button-white-fill.stories.js.map +1 -1
- package/stories/button-white-outline-sizes.stories.js +1 -31
- package/stories/button-white-outline-sizes.stories.js.map +1 -1
- package/stories/button-white-outline.stories.js +1 -33
- package/stories/button-white-outline.stories.js.map +1 -1
- package/stories/index.js +36 -137
- package/stories/index.js.map +1 -1
- package/test/benchmark/test-basic.js +1 -4
- package/test/benchmark/test-basic.js.map +1 -1
- package/test/button-accent-fill-sizes.test-vrt.js +1 -3
- package/test/button-accent-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-accent-fill.test-vrt.js +1 -3
- package/test/button-accent-fill.test-vrt.js.map +1 -1
- package/test/button-accent-outline-sizes.test-vrt.js +1 -3
- package/test/button-accent-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-accent-outline.test-vrt.js +1 -3
- package/test/button-accent-outline.test-vrt.js.map +1 -1
- package/test/button-black-fill-sizes.test-vrt.js +1 -3
- package/test/button-black-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-black-fill.test-vrt.js +1 -3
- package/test/button-black-fill.test-vrt.js.map +1 -1
- package/test/button-black-outline-sizes.test-vrt.js +1 -3
- package/test/button-black-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-black-outline.test-vrt.js +1 -3
- package/test/button-black-outline.test-vrt.js.map +1 -1
- package/test/button-negative-fill-sizes.test-vrt.js +1 -3
- package/test/button-negative-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-negative-fill.test-vrt.js +1 -3
- package/test/button-negative-fill.test-vrt.js.map +1 -1
- package/test/button-negative-outline-sizes.test-vrt.js +1 -3
- package/test/button-negative-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-negative-outline.test-vrt.js +1 -3
- package/test/button-negative-outline.test-vrt.js.map +1 -1
- package/test/button-primary-fill-sizes.test-vrt.js +1 -3
- package/test/button-primary-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-primary-fill.test-vrt.js +1 -3
- package/test/button-primary-fill.test-vrt.js.map +1 -1
- package/test/button-primary-outline-sizes.test-vrt.js +1 -3
- package/test/button-primary-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-primary-outline.test-vrt.js +1 -3
- package/test/button-primary-outline.test-vrt.js.map +1 -1
- package/test/button-secondary-fill-sizes.test-vrt.js +1 -3
- package/test/button-secondary-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-secondary-fill.test-vrt.js +1 -3
- package/test/button-secondary-fill.test-vrt.js.map +1 -1
- package/test/button-secondary-outline-sizes.test-vrt.js +1 -3
- package/test/button-secondary-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-secondary-outline.test-vrt.js +1 -3
- package/test/button-secondary-outline.test-vrt.js.map +1 -1
- package/test/button-white-fill-sizes.test-vrt.js +1 -3
- package/test/button-white-fill-sizes.test-vrt.js.map +1 -1
- package/test/button-white-fill.test-vrt.js +1 -3
- package/test/button-white-fill.test-vrt.js.map +1 -1
- package/test/button-white-outline-sizes.test-vrt.js +1 -3
- package/test/button-white-outline-sizes.test-vrt.js.map +1 -1
- package/test/button-white-outline.test-vrt.js +1 -3
- package/test/button-white-outline.test-vrt.js.map +1 -1
- package/test/button.test.js +29 -349
- package/test/button.test.js.map +1 -1
- package/test/clear-button.test.js +4 -15
- package/test/clear-button.test.js.map +1 -1
- package/test/close-button.test.js +4 -15
- package/test/close-button.test.js.map +1 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["button-secondary-fill.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/button-secondary-fill.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('ButtonSecondaryFillStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,8DACA,8DAEA,EAAe,6BAA8B,CAAO",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { regressVisuals } from "../../../test/visual/test.js";
|
|
3
|
-
regressVisuals("ButtonSecondaryOutlineSizesStories", stories);
|
|
1
|
+
import*as r from"../stories/button-secondary-outline-sizes.stories.js";import{regressVisuals as s}from"../../../test/visual/test.js";s("ButtonSecondaryOutlineSizesStories",r);
|
|
4
2
|
//# sourceMappingURL=button-secondary-outline-sizes.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["button-secondary-outline-sizes.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/button-secondary-outline-sizes.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('ButtonSecondaryOutlineSizesStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,uEACA,8DAEA,EAAe,qCAAsC,CAAO",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { regressVisuals } from "../../../test/visual/test.js";
|
|
3
|
-
regressVisuals("ButtonSecondaryOutlineStories", stories);
|
|
1
|
+
import*as r from"../stories/button-secondary-outline.stories.js";import{regressVisuals as o}from"../../../test/visual/test.js";o("ButtonSecondaryOutlineStories",r);
|
|
4
2
|
//# sourceMappingURL=button-secondary-outline.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["button-secondary-outline.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/button-secondary-outline.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('ButtonSecondaryOutlineStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,iEACA,8DAEA,EAAe,gCAAiC,CAAO",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { regressVisuals } from "../../../test/visual/test.js";
|
|
3
|
-
regressVisuals("ButtonWhiteFillSizesStories", stories);
|
|
1
|
+
import*as s from"../stories/button-white-fill-sizes.stories.js";import{regressVisuals as i}from"../../../test/visual/test.js";i("ButtonWhiteFillSizesStories",s);
|
|
4
2
|
//# sourceMappingURL=button-white-fill-sizes.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["button-white-fill-sizes.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/button-white-fill-sizes.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('ButtonWhiteFillSizesStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,gEACA,8DAEA,EAAe,8BAA+B,CAAO",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { regressVisuals } from "../../../test/visual/test.js";
|
|
3
|
-
regressVisuals("ButtonWhiteFillStories", stories);
|
|
1
|
+
import*as r from"../stories/button-white-fill.stories.js";import{regressVisuals as s}from"../../../test/visual/test.js";s("ButtonWhiteFillStories",r);
|
|
4
2
|
//# sourceMappingURL=button-white-fill.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["button-white-fill.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/button-white-fill.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('ButtonWhiteFillStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,0DACA,8DAEA,EAAe,yBAA0B,CAAO",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { regressVisuals } from "../../../test/visual/test.js";
|
|
3
|
-
regressVisuals("ButtonWhiteOutlineSizesStories", stories);
|
|
1
|
+
import*as s from"../stories/button-white-outline-sizes.stories.js";import{regressVisuals as i}from"../../../test/visual/test.js";i("ButtonWhiteOutlineSizesStories",s);
|
|
4
2
|
//# sourceMappingURL=button-white-outline-sizes.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["button-white-outline-sizes.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/button-white-outline-sizes.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('ButtonWhiteOutlineSizesStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,mEACA,8DAEA,EAAe,iCAAkC,CAAO",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { regressVisuals } from "../../../test/visual/test.js";
|
|
3
|
-
regressVisuals("ButtonWhiteOutlineStories", stories);
|
|
1
|
+
import*as r from"../stories/button-white-outline.stories.js";import{regressVisuals as s}from"../../../test/visual/test.js";s("ButtonWhiteOutlineStories",r);
|
|
4
2
|
//# sourceMappingURL=button-white-outline.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["button-white-outline.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/button-white-outline.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('ButtonWhiteOutlineStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,6DACA,8DAEA,EAAe,4BAA6B,CAAO",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/button.test.js
CHANGED
|
@@ -1,391 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
elementUpdated,
|
|
4
|
-
expect,
|
|
5
|
-
fixture,
|
|
6
|
-
html,
|
|
7
|
-
waitUntil
|
|
8
|
-
} from "@open-wc/testing";
|
|
9
|
-
import {
|
|
10
|
-
shiftTabEvent,
|
|
11
|
-
testForLitDevWarnings
|
|
12
|
-
} from "../../../test/testing-helpers.js";
|
|
13
|
-
import { spy } from "sinon";
|
|
14
|
-
describe("Button", () => {
|
|
15
|
-
testForLitDevWarnings(async () => await fixture(html`
|
|
1
|
+
import"@spectrum-web-components/button/sp-button.js";import{elementUpdated as n,expect as a,fixture as o,html as s,waitUntil as r}from"@open-wc/testing";import{shiftTabEvent as b,testForLitDevWarnings as d}from"../../../test/testing-helpers.js";import{spy as u}from"sinon";describe("Button",()=>{d(async()=>await o(s`
|
|
16
2
|
<sp-button tabindex="0">Button</sp-button>
|
|
17
|
-
`))
|
|
18
|
-
it("loads default", async () => {
|
|
19
|
-
const el = await fixture(html`
|
|
3
|
+
`)),it("loads default",async()=>{const t=await o(s`
|
|
20
4
|
<sp-button tabindex="0">Button</sp-button>
|
|
21
|
-
`);
|
|
22
|
-
await elementUpdated(el);
|
|
23
|
-
expect(el).to.not.be.undefined;
|
|
24
|
-
expect(el.textContent).to.include("Button");
|
|
25
|
-
await expect(el).to.be.accessible();
|
|
26
|
-
});
|
|
27
|
-
it("loads default w/ element content", async () => {
|
|
28
|
-
const el = await fixture(html`
|
|
5
|
+
`);await n(t),a(t).to.not.be.undefined,a(t.textContent).to.include("Button"),await a(t).to.be.accessible()}),it("loads default w/ element content",async()=>{const t=await o(s`
|
|
29
6
|
<sp-button label="Button"><svg></svg></sp-button>
|
|
30
|
-
`);
|
|
31
|
-
await elementUpdated(el);
|
|
32
|
-
expect(el).to.not.be.undefined;
|
|
33
|
-
await expect(el).to.be.accessible();
|
|
34
|
-
});
|
|
35
|
-
it("loads default w/ an icon", async () => {
|
|
36
|
-
const el = await fixture(html`
|
|
7
|
+
`);await n(t),a(t).to.not.be.undefined,await a(t).to.be.accessible()}),it("loads default w/ an icon",async()=>{const t=await o(s`
|
|
37
8
|
<sp-button label="">
|
|
38
9
|
Button
|
|
39
10
|
<svg slot="icon"></svg>
|
|
40
11
|
</sp-button>
|
|
41
|
-
`);
|
|
42
|
-
await elementUpdated(el);
|
|
43
|
-
expect(el).to.not.be.undefined;
|
|
44
|
-
expect(el.textContent).to.include("Button");
|
|
45
|
-
expect(!el.hasIcon);
|
|
46
|
-
await expect(el).to.be.accessible();
|
|
47
|
-
});
|
|
48
|
-
it("loads default only icon", async () => {
|
|
49
|
-
const el = await fixture(html`
|
|
12
|
+
`);await n(t),a(t).to.not.be.undefined,a(t.textContent).to.include("Button"),a(!t.hasIcon),await a(t).to.be.accessible()}),it("loads default only icon",async()=>{const t=await o(s`
|
|
50
13
|
<sp-button label="Button">
|
|
51
14
|
<svg slot="icon"></svg>
|
|
52
15
|
</sp-button>
|
|
53
|
-
`);
|
|
54
|
-
await elementUpdated(el);
|
|
55
|
-
expect(el).to.not.be.undefined;
|
|
56
|
-
await expect(el).to.be.accessible();
|
|
57
|
-
});
|
|
58
|
-
it('manages "role"', async () => {
|
|
59
|
-
const el = await fixture(html`
|
|
16
|
+
`);await n(t),a(t).to.not.be.undefined,await a(t).to.be.accessible()}),it('manages "role"',async()=>{const t=await o(s`
|
|
60
17
|
<sp-button>Button</sp-button>
|
|
61
|
-
`);
|
|
62
|
-
await elementUpdated(el);
|
|
63
|
-
expect(el.getAttribute("role")).to.equal("button");
|
|
64
|
-
el.href = "#";
|
|
65
|
-
await elementUpdated(el);
|
|
66
|
-
expect(el.getAttribute("role")).to.equal("link");
|
|
67
|
-
el.removeAttribute("href");
|
|
68
|
-
await elementUpdated(el);
|
|
69
|
-
expect(el.getAttribute("role")).to.equal("button");
|
|
70
|
-
});
|
|
71
|
-
it("allows label to be toggled", async () => {
|
|
72
|
-
const testNode = document.createTextNode("Button");
|
|
73
|
-
const el = await fixture(html`
|
|
18
|
+
`);await n(t),a(t.getAttribute("role")).to.equal("button"),t.href="#",await n(t),a(t.getAttribute("role")).to.equal("link"),t.removeAttribute("href"),await n(t),a(t.getAttribute("role")).to.equal("button")}),it("allows label to be toggled",async()=>{const t=document.createTextNode("Button"),e=await o(s`
|
|
74
19
|
<sp-button>
|
|
75
|
-
${
|
|
20
|
+
${t}
|
|
76
21
|
<svg slot="icon"></svg>
|
|
77
22
|
</sp-button>
|
|
78
|
-
`);
|
|
79
|
-
await elementUpdated(el);
|
|
80
|
-
const labelTestableEl = el;
|
|
81
|
-
expect(labelTestableEl.hasLabel, "starts with label").to.be.true;
|
|
82
|
-
testNode.textContent = "";
|
|
83
|
-
await elementUpdated(el);
|
|
84
|
-
await waitUntil(() => !labelTestableEl.hasLabel, "label is removed");
|
|
85
|
-
testNode.textContent = "Button";
|
|
86
|
-
await elementUpdated(el);
|
|
87
|
-
expect(labelTestableEl.hasLabel, "label is returned").to.be.true;
|
|
88
|
-
});
|
|
89
|
-
it("loads with href", async () => {
|
|
90
|
-
const el = await fixture(html`
|
|
23
|
+
`);await n(e);const i=e;a(i.hasLabel,"starts with label").to.be.true,t.textContent="",await n(e),await r(()=>!i.hasLabel,"label is removed"),t.textContent="Button",await n(e),a(i.hasLabel,"label is returned").to.be.true}),it("loads with href",async()=>{const t=await o(s`
|
|
91
24
|
<sp-button href="test_url">With Href</sp-button>
|
|
92
|
-
`);
|
|
93
|
-
await elementUpdated(el);
|
|
94
|
-
expect(el).to.not.be.undefined;
|
|
95
|
-
expect(el.textContent).to.include("With Href");
|
|
96
|
-
});
|
|
97
|
-
it("loads with href and target", async () => {
|
|
98
|
-
const el = await fixture(html`
|
|
25
|
+
`);await n(t),a(t).to.not.be.undefined,a(t.textContent).to.include("With Href")}),it("loads with href and target",async()=>{const t=await o(s`
|
|
99
26
|
<sp-button href="test_url" target="_blank">
|
|
100
27
|
With Target
|
|
101
28
|
</sp-button>
|
|
102
|
-
`);
|
|
103
|
-
await elementUpdated(el);
|
|
104
|
-
expect(el).to.not.be.undefined;
|
|
105
|
-
expect(el.textContent).to.include("With Target");
|
|
106
|
-
});
|
|
107
|
-
it("accepts shit+tab interactions", async () => {
|
|
108
|
-
let focusedCount = 0;
|
|
109
|
-
const el = await fixture(html`
|
|
29
|
+
`);await n(t),a(t).to.not.be.undefined,a(t.textContent).to.include("With Target")}),it("accepts shit+tab interactions",async()=>{let t=0;const e=await o(s`
|
|
110
30
|
<sp-button href="test_url" target="_blank">
|
|
111
31
|
With Target
|
|
112
32
|
</sp-button>
|
|
113
|
-
`);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
focusElement.addEventListener("focus", () => focusedCount += 1);
|
|
117
|
-
expect(focusedCount).to.equal(0);
|
|
118
|
-
el.focus();
|
|
119
|
-
await elementUpdated(el);
|
|
120
|
-
expect(focusedCount).to.equal(1);
|
|
121
|
-
el.dispatchEvent(shiftTabEvent());
|
|
122
|
-
el.dispatchEvent(new Event("focusin"));
|
|
123
|
-
await elementUpdated(el);
|
|
124
|
-
expect(focusedCount).to.equal(1);
|
|
125
|
-
});
|
|
126
|
-
it("manages `disabled`", async () => {
|
|
127
|
-
const clickSpy = spy();
|
|
128
|
-
const el = await fixture(html`
|
|
129
|
-
<sp-button @click=${() => clickSpy()}>Button</sp-button>
|
|
130
|
-
`);
|
|
131
|
-
await elementUpdated(el);
|
|
132
|
-
el.click();
|
|
133
|
-
await elementUpdated(el);
|
|
134
|
-
expect(clickSpy.calledOnce).to.be.true;
|
|
135
|
-
clickSpy.resetHistory();
|
|
136
|
-
el.disabled = true;
|
|
137
|
-
await elementUpdated(el);
|
|
138
|
-
el.click();
|
|
139
|
-
await elementUpdated(el);
|
|
140
|
-
expect(clickSpy.callCount).to.equal(0);
|
|
141
|
-
clickSpy.resetHistory();
|
|
142
|
-
await elementUpdated(el);
|
|
143
|
-
el.dispatchEvent(new Event("click", {}));
|
|
144
|
-
await elementUpdated(el);
|
|
145
|
-
expect(clickSpy.callCount).to.equal(0);
|
|
146
|
-
clickSpy.resetHistory();
|
|
147
|
-
el.disabled = false;
|
|
148
|
-
el.click();
|
|
149
|
-
await elementUpdated(el);
|
|
150
|
-
expect(clickSpy.calledOnce).to.be.true;
|
|
151
|
-
});
|
|
152
|
-
it("manages `aria-disabled`", async () => {
|
|
153
|
-
const el = await fixture(html`
|
|
33
|
+
`);await n(e),e.focusElement.addEventListener("focus",()=>t+=1),a(t).to.equal(0),e.focus(),await n(e),a(t).to.equal(1),e.dispatchEvent(b()),e.dispatchEvent(new Event("focusin")),await n(e),a(t).to.equal(1)}),it("manages `disabled`",async()=>{const t=u(),e=await o(s`
|
|
34
|
+
<sp-button @click=${()=>t()}>Button</sp-button>
|
|
35
|
+
`);await n(e),e.click(),await n(e),a(t.calledOnce).to.be.true,t.resetHistory(),e.disabled=!0,await n(e),e.click(),await n(e),a(t.callCount).to.equal(0),t.resetHistory(),await n(e),e.dispatchEvent(new Event("click",{})),await n(e),a(t.callCount).to.equal(0),t.resetHistory(),e.disabled=!1,e.click(),await n(e),a(t.calledOnce).to.be.true}),it("manages `aria-disabled`",async()=>{const t=await o(s`
|
|
154
36
|
<sp-button href="test_url" target="_blank">
|
|
155
37
|
With Target
|
|
156
38
|
</sp-button>
|
|
157
|
-
`);
|
|
158
|
-
await elementUpdated(el);
|
|
159
|
-
expect(el.hasAttribute("aria-disabled"), "initially not").to.be.false;
|
|
160
|
-
el.disabled = true;
|
|
161
|
-
await elementUpdated(el);
|
|
162
|
-
expect(el.getAttribute("aria-disabled")).to.equal("true");
|
|
163
|
-
el.disabled = false;
|
|
164
|
-
await elementUpdated(el);
|
|
165
|
-
expect(el.hasAttribute("aria-disabled"), "finally not").to.be.false;
|
|
166
|
-
});
|
|
167
|
-
it("manages tabIndex while disabled", async () => {
|
|
168
|
-
const el = await fixture(html`
|
|
39
|
+
`);await n(t),a(t.hasAttribute("aria-disabled"),"initially not").to.be.false,t.disabled=!0,await n(t),a(t.getAttribute("aria-disabled")).to.equal("true"),t.disabled=!1,await n(t),a(t.hasAttribute("aria-disabled"),"finally not").to.be.false}),it("manages tabIndex while disabled",async()=>{const t=await o(s`
|
|
169
40
|
<sp-button href="test_url" target="_blank">
|
|
170
41
|
With Target
|
|
171
42
|
</sp-button>
|
|
172
|
-
`);
|
|
173
|
-
|
|
174
|
-
expect(el.tabIndex).to.equal(0);
|
|
175
|
-
el.disabled = true;
|
|
176
|
-
await elementUpdated(el);
|
|
177
|
-
expect(el.tabIndex).to.equal(-1);
|
|
178
|
-
el.tabIndex = 2;
|
|
179
|
-
await elementUpdated(el);
|
|
180
|
-
expect(el.tabIndex).to.equal(-1);
|
|
181
|
-
el.disabled = false;
|
|
182
|
-
await elementUpdated(el);
|
|
183
|
-
expect(el.tabIndex).to.equal(2);
|
|
184
|
-
});
|
|
185
|
-
it("swallows `click` interaction when `[disabled]`", async () => {
|
|
186
|
-
const clickSpy = spy();
|
|
187
|
-
const el = await fixture(html`
|
|
188
|
-
<sp-button disabled @click=${() => clickSpy()}>
|
|
43
|
+
`);await n(t),a(t.tabIndex).to.equal(0),t.disabled=!0,await n(t),a(t.tabIndex).to.equal(-1),t.tabIndex=2,await n(t),a(t.tabIndex).to.equal(-1),t.disabled=!1,await n(t),a(t.tabIndex).to.equal(2)}),it("swallows `click` interaction when `[disabled]`",async()=>{const t=u(),e=await o(s`
|
|
44
|
+
<sp-button disabled @click=${()=>t()}>
|
|
189
45
|
Button
|
|
190
46
|
</sp-button>
|
|
191
|
-
`);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
el.click();
|
|
195
|
-
await elementUpdated(el);
|
|
196
|
-
expect(clickSpy.callCount).to.equal(0);
|
|
197
|
-
});
|
|
198
|
-
it("translates keyboard interactions to click", async () => {
|
|
199
|
-
const clickSpy = spy();
|
|
200
|
-
const el = await fixture(html`
|
|
201
|
-
<sp-button @click=${() => clickSpy()}>Button</sp-button>
|
|
202
|
-
`);
|
|
203
|
-
await elementUpdated(el);
|
|
204
|
-
el.dispatchEvent(new KeyboardEvent("keypress", {
|
|
205
|
-
bubbles: true,
|
|
206
|
-
composed: true,
|
|
207
|
-
cancelable: true,
|
|
208
|
-
code: "Enter",
|
|
209
|
-
key: "Enter"
|
|
210
|
-
}));
|
|
211
|
-
await elementUpdated(el);
|
|
212
|
-
expect(clickSpy.callCount).to.equal(1);
|
|
213
|
-
clickSpy.resetHistory();
|
|
214
|
-
el.dispatchEvent(new KeyboardEvent("keypress", {
|
|
215
|
-
bubbles: true,
|
|
216
|
-
composed: true,
|
|
217
|
-
cancelable: true,
|
|
218
|
-
code: "NumpadEnter",
|
|
219
|
-
key: "NumpadEnter"
|
|
220
|
-
}));
|
|
221
|
-
await elementUpdated(el);
|
|
222
|
-
expect(clickSpy.callCount).to.equal(1);
|
|
223
|
-
clickSpy.resetHistory();
|
|
224
|
-
el.dispatchEvent(new KeyboardEvent("keypress", {
|
|
225
|
-
bubbles: true,
|
|
226
|
-
composed: true,
|
|
227
|
-
cancelable: true,
|
|
228
|
-
code: "Space",
|
|
229
|
-
key: "Space"
|
|
230
|
-
}));
|
|
231
|
-
await elementUpdated(el);
|
|
232
|
-
expect(clickSpy.callCount).to.equal(0);
|
|
233
|
-
clickSpy.resetHistory();
|
|
234
|
-
el.dispatchEvent(new KeyboardEvent("keydown", {
|
|
235
|
-
bubbles: true,
|
|
236
|
-
composed: true,
|
|
237
|
-
cancelable: true,
|
|
238
|
-
code: "Space",
|
|
239
|
-
key: "Space"
|
|
240
|
-
}));
|
|
241
|
-
el.dispatchEvent(new KeyboardEvent("keyup", {
|
|
242
|
-
bubbles: true,
|
|
243
|
-
composed: true,
|
|
244
|
-
cancelable: true,
|
|
245
|
-
code: "Space",
|
|
246
|
-
key: "Space"
|
|
247
|
-
}));
|
|
248
|
-
await elementUpdated(el);
|
|
249
|
-
expect(clickSpy.callCount).to.equal(1);
|
|
250
|
-
clickSpy.resetHistory();
|
|
251
|
-
el.dispatchEvent(new KeyboardEvent("keydown", {
|
|
252
|
-
bubbles: true,
|
|
253
|
-
composed: true,
|
|
254
|
-
cancelable: true,
|
|
255
|
-
code: "Space",
|
|
256
|
-
key: "Space"
|
|
257
|
-
}));
|
|
258
|
-
el.dispatchEvent(new KeyboardEvent("keyup", {
|
|
259
|
-
bubbles: true,
|
|
260
|
-
composed: true,
|
|
261
|
-
cancelable: true,
|
|
262
|
-
code: "KeyG",
|
|
263
|
-
key: "g"
|
|
264
|
-
}));
|
|
265
|
-
await elementUpdated(el);
|
|
266
|
-
expect(clickSpy.callCount).to.equal(0);
|
|
267
|
-
el.dispatchEvent(new KeyboardEvent("keyup", {
|
|
268
|
-
bubbles: true,
|
|
269
|
-
composed: true,
|
|
270
|
-
cancelable: true,
|
|
271
|
-
code: "Space",
|
|
272
|
-
key: "Space"
|
|
273
|
-
}));
|
|
274
|
-
clickSpy.resetHistory();
|
|
275
|
-
el.dispatchEvent(new KeyboardEvent("keydown", {
|
|
276
|
-
bubbles: true,
|
|
277
|
-
composed: true,
|
|
278
|
-
cancelable: true,
|
|
279
|
-
code: "KeyG",
|
|
280
|
-
key: "g"
|
|
281
|
-
}));
|
|
282
|
-
el.dispatchEvent(new KeyboardEvent("keyup", {
|
|
283
|
-
bubbles: true,
|
|
284
|
-
composed: true,
|
|
285
|
-
cancelable: true,
|
|
286
|
-
code: "Space",
|
|
287
|
-
key: "Space"
|
|
288
|
-
}));
|
|
289
|
-
await elementUpdated(el);
|
|
290
|
-
expect(clickSpy.callCount).to.equal(0);
|
|
291
|
-
});
|
|
292
|
-
it('proxies clicks by "type"', async () => {
|
|
293
|
-
const submitSpy = spy();
|
|
294
|
-
const resetSpy = spy();
|
|
295
|
-
const test = await fixture(html`
|
|
47
|
+
`);await n(e),a(t.callCount).to.equal(0),e.click(),await n(e),a(t.callCount).to.equal(0)}),it("translates keyboard interactions to click",async()=>{const t=u(),e=await o(s`
|
|
48
|
+
<sp-button @click=${()=>t()}>Button</sp-button>
|
|
49
|
+
`);await n(e),e.dispatchEvent(new KeyboardEvent("keypress",{bubbles:!0,composed:!0,cancelable:!0,code:"Enter",key:"Enter"})),await n(e),a(t.callCount).to.equal(1),t.resetHistory(),e.dispatchEvent(new KeyboardEvent("keypress",{bubbles:!0,composed:!0,cancelable:!0,code:"NumpadEnter",key:"NumpadEnter"})),await n(e),a(t.callCount).to.equal(1),t.resetHistory(),e.dispatchEvent(new KeyboardEvent("keypress",{bubbles:!0,composed:!0,cancelable:!0,code:"Space",key:"Space"})),await n(e),a(t.callCount).to.equal(0),t.resetHistory(),e.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,composed:!0,cancelable:!0,code:"Space",key:"Space"})),e.dispatchEvent(new KeyboardEvent("keyup",{bubbles:!0,composed:!0,cancelable:!0,code:"Space",key:"Space"})),await n(e),a(t.callCount).to.equal(1),t.resetHistory(),e.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,composed:!0,cancelable:!0,code:"Space",key:"Space"})),e.dispatchEvent(new KeyboardEvent("keyup",{bubbles:!0,composed:!0,cancelable:!0,code:"KeyG",key:"g"})),await n(e),a(t.callCount).to.equal(0),e.dispatchEvent(new KeyboardEvent("keyup",{bubbles:!0,composed:!0,cancelable:!0,code:"Space",key:"Space"})),t.resetHistory(),e.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,composed:!0,cancelable:!0,code:"KeyG",key:"g"})),e.dispatchEvent(new KeyboardEvent("keyup",{bubbles:!0,composed:!0,cancelable:!0,code:"Space",key:"Space"})),await n(e),a(t.callCount).to.equal(0)}),it('proxies clicks by "type"',async()=>{const t=u(),e=u(),l=(await o(s`
|
|
296
50
|
<form
|
|
297
|
-
@submit=${(
|
|
298
|
-
|
|
299
|
-
submitSpy();
|
|
300
|
-
}}
|
|
301
|
-
@reset=${(event) => {
|
|
302
|
-
event.preventDefault();
|
|
303
|
-
resetSpy();
|
|
304
|
-
}}
|
|
51
|
+
@submit=${c=>{c.preventDefault(),t()}}
|
|
52
|
+
@reset=${c=>{c.preventDefault(),e()}}
|
|
305
53
|
>
|
|
306
54
|
<sp-button>Button</sp-button>
|
|
307
55
|
</form>
|
|
308
|
-
`);
|
|
309
|
-
const el = test.querySelector("sp-button");
|
|
310
|
-
await elementUpdated(el);
|
|
311
|
-
el.type = "submit";
|
|
312
|
-
await elementUpdated(el);
|
|
313
|
-
el.click();
|
|
314
|
-
expect(submitSpy.callCount).to.equal(1);
|
|
315
|
-
expect(resetSpy.callCount).to.equal(0);
|
|
316
|
-
el.type = "reset";
|
|
317
|
-
await elementUpdated(el);
|
|
318
|
-
el.click();
|
|
319
|
-
expect(submitSpy.callCount).to.equal(1);
|
|
320
|
-
expect(resetSpy.callCount).to.equal(1);
|
|
321
|
-
el.type = "button";
|
|
322
|
-
await elementUpdated(el);
|
|
323
|
-
el.click();
|
|
324
|
-
expect(submitSpy.callCount).to.equal(1);
|
|
325
|
-
expect(resetSpy.callCount).to.equal(1);
|
|
326
|
-
});
|
|
327
|
-
it("proxies click by [href]", async () => {
|
|
328
|
-
const clickSpy = spy();
|
|
329
|
-
const el = await fixture(html`
|
|
56
|
+
`)).querySelector("sp-button");await n(l),l.type="submit",await n(l),l.click(),a(t.callCount).to.equal(1),a(e.callCount).to.equal(0),l.type="reset",await n(l),l.click(),a(t.callCount).to.equal(1),a(e.callCount).to.equal(1),l.type="button",await n(l),l.click(),a(t.callCount).to.equal(1),a(e.callCount).to.equal(1)}),it("proxies click by [href]",async()=>{const t=u(),e=await o(s`
|
|
330
57
|
<sp-button href="test_url">With Href</sp-button>
|
|
331
|
-
`);
|
|
332
|
-
await elementUpdated(el);
|
|
333
|
-
el.anchorElement.addEventListener("click", (event) => {
|
|
334
|
-
event.preventDefault();
|
|
335
|
-
event.stopPropagation();
|
|
336
|
-
clickSpy();
|
|
337
|
-
});
|
|
338
|
-
expect(clickSpy.callCount).to.equal(0);
|
|
339
|
-
el.click();
|
|
340
|
-
await elementUpdated(el);
|
|
341
|
-
expect(clickSpy.callCount).to.equal(1);
|
|
342
|
-
});
|
|
343
|
-
it('manages "active" while focused', async () => {
|
|
344
|
-
const el = await fixture(html`
|
|
58
|
+
`);await n(e),e.anchorElement.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),t()}),a(t.callCount).to.equal(0),e.click(),await n(e),a(t.callCount).to.equal(1)}),it('manages "active" while focused',async()=>{const t=await o(s`
|
|
345
59
|
<sp-button label="Button">
|
|
346
60
|
<svg slot="icon"></svg>
|
|
347
61
|
</sp-button>
|
|
348
|
-
`);
|
|
349
|
-
await elementUpdated(el);
|
|
350
|
-
el.active = true;
|
|
351
|
-
await elementUpdated(el);
|
|
352
|
-
el.dispatchEvent(new FocusEvent("focusout"));
|
|
353
|
-
await elementUpdated(el);
|
|
354
|
-
expect(el.active).to.be.false;
|
|
355
|
-
});
|
|
356
|
-
describe("deprecated variants and attributes", () => {
|
|
357
|
-
it("manages [quiet]", async () => {
|
|
358
|
-
const el = await fixture(html`
|
|
62
|
+
`);await n(t),t.active=!0,await n(t),t.dispatchEvent(new FocusEvent("focusout")),await n(t),a(t.active).to.be.false}),describe("deprecated variants and attributes",()=>{it("manages [quiet]",async()=>{const t=await o(s`
|
|
359
63
|
<sp-button quiet>Button</sp-button>
|
|
360
|
-
`);
|
|
361
|
-
await elementUpdated(el);
|
|
362
|
-
expect(el.treatment).to.equal("outline");
|
|
363
|
-
el.quiet = false;
|
|
364
|
-
await elementUpdated(el);
|
|
365
|
-
expect(el.treatment).to.equal("fill");
|
|
366
|
-
});
|
|
367
|
-
it('upgrades [variant="cta"] to [variant="accent"]', async () => {
|
|
368
|
-
const el = await fixture(html`
|
|
64
|
+
`);await n(t),a(t.treatment).to.equal("outline"),t.quiet=!1,await n(t),a(t.treatment).to.equal("fill")}),it('upgrades [variant="cta"] to [variant="accent"]',async()=>{const t=await o(s`
|
|
369
65
|
<sp-button variant="cta">Button</sp-button>
|
|
370
|
-
`);
|
|
371
|
-
await elementUpdated(el);
|
|
372
|
-
expect(el.variant).to.equal("accent");
|
|
373
|
-
});
|
|
374
|
-
it('manages [variant="overBackground"]', async () => {
|
|
375
|
-
const el = await fixture(html`
|
|
66
|
+
`);await n(t),a(t.variant).to.equal("accent")}),it('manages [variant="overBackground"]',async()=>{const t=await o(s`
|
|
376
67
|
<sp-button variant="overBackground">Button</sp-button>
|
|
377
|
-
`);
|
|
378
|
-
await elementUpdated(el);
|
|
379
|
-
expect(el.variant).to.equal("white");
|
|
380
|
-
expect(el.treatment).to.equal("outline");
|
|
381
|
-
});
|
|
382
|
-
it('forces [variant="accent"]', async () => {
|
|
383
|
-
const el = await fixture(html`
|
|
68
|
+
`);await n(t),a(t.variant).to.equal("white"),a(t.treatment).to.equal("outline")}),it('forces [variant="accent"]',async()=>{const t=await o(s`
|
|
384
69
|
<sp-button variant="not-supported">Button</sp-button>
|
|
385
|
-
`);
|
|
386
|
-
await elementUpdated(el);
|
|
387
|
-
expect(el.variant).to.equal("accent");
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
});
|
|
70
|
+
`);await n(t),a(t.variant).to.equal("accent")})})});
|
|
391
71
|
//# sourceMappingURL=button.test.js.map
|