@spectrum-web-components/switch 0.10.0 → 0.11.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/README.md +38 -1
- package/custom-elements.json +6 -0
- package/package.json +4 -4
- package/sp-switch.dev.js +1 -0
- package/sp-switch.dev.js.map +1 -1
- package/sp-switch.js +1 -1
- package/sp-switch.js.map +2 -2
- package/src/Switch.d.ts +6 -1
- package/src/Switch.dev.js +8 -3
- package/src/Switch.dev.js.map +2 -2
- package/src/Switch.js +1 -1
- package/src/Switch.js.map +3 -3
- package/src/index.dev.js +1 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-config.js +23 -0
- package/src/spectrum-switch.css.dev.js +270 -110
- package/src/spectrum-switch.css.dev.js.map +2 -2
- package/src/spectrum-switch.css.js +271 -112
- package/src/spectrum-switch.css.js.map +3 -3
- package/src/switch-legacy.css.dev.js +1 -0
- package/src/switch-legacy.css.dev.js.map +1 -1
- package/src/switch-legacy.css.js +1 -1
- package/src/switch-legacy.css.js.map +2 -2
- package/src/switch.css.dev.js +270 -112
- package/src/switch.css.dev.js.map +2 -2
- package/src/switch.css.js +271 -114
- package/src/switch.css.js.map +3 -3
- package/stories/switch-sizes.stories.js +23 -0
- package/stories/switch-sizes.stories.js.map +7 -0
- package/stories/switch.stories.js +68 -9
- package/stories/switch.stories.js.map +2 -2
- package/test/benchmark/test-basic.js +5 -1
- package/test/benchmark/test-basic.js.map +1 -1
- package/test/switch-sizes.test-vrt.js +5 -0
- package/test/switch-sizes.test-vrt.js.map +7 -0
- package/test/switch.test-vrt.js +4 -1
- package/test/switch.test-vrt.js.map +1 -1
- package/test/switch.test.js +36 -5
- package/test/switch.test.js.map +1 -1
|
@@ -1,18 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/switch/sp-switch.js";
|
|
3
|
+
import { html } from "@spectrum-web-components/base";
|
|
4
|
+
import { spreadProps } from "../../../test/lit-helpers.js";
|
|
5
|
+
export default {
|
|
6
|
+
component: "sp-switch",
|
|
7
|
+
title: "Switch",
|
|
8
|
+
argTypes: {
|
|
9
|
+
size: {
|
|
10
|
+
name: "size",
|
|
11
|
+
type: { name: "string", required: false },
|
|
12
|
+
description: "The size at which to display the Switch element",
|
|
13
|
+
table: {
|
|
14
|
+
type: { summary: '"s" | "m" | "l" | "xl"' },
|
|
15
|
+
defaultValue: { summary: "m" }
|
|
16
|
+
},
|
|
17
|
+
control: {
|
|
18
|
+
type: "text"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
args: {
|
|
23
|
+
size: "m"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function renderSwitch(args) {
|
|
27
|
+
return html`
|
|
28
|
+
<sp-switch ${spreadProps(args)}>Switch</sp-switch>
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
export const Default = (args) => renderSwitch(args);
|
|
32
|
+
export const Checked = () => {
|
|
33
|
+
return html`
|
|
4
34
|
<sp-switch checked>Switch</sp-switch>
|
|
5
|
-
|
|
35
|
+
`;
|
|
36
|
+
};
|
|
37
|
+
export const Sizes = () => {
|
|
38
|
+
return html`
|
|
39
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
40
|
+
<sp-switch size="s">Small</sp-switch>
|
|
41
|
+
<sp-switch size="m">Medium</sp-switch>
|
|
42
|
+
<sp-switch size="l">Large</sp-switch>
|
|
43
|
+
<sp-switch size="xl">Extra-Large</sp-switch>
|
|
44
|
+
</div>
|
|
45
|
+
`;
|
|
46
|
+
};
|
|
47
|
+
export const readonly = () => {
|
|
48
|
+
return html`
|
|
6
49
|
<sp-switch checked readonly>Switch</sp-switch>
|
|
7
|
-
|
|
50
|
+
`;
|
|
51
|
+
};
|
|
52
|
+
export const emphasized = () => {
|
|
53
|
+
return html`
|
|
8
54
|
<sp-switch emphasized>Switch</sp-switch>
|
|
9
|
-
|
|
55
|
+
`;
|
|
56
|
+
};
|
|
57
|
+
export const emphasizedChecked = () => {
|
|
58
|
+
return html`
|
|
10
59
|
<sp-switch emphasized checked>Switch</sp-switch>
|
|
11
|
-
|
|
60
|
+
`;
|
|
61
|
+
};
|
|
62
|
+
export const Autofocus = () => {
|
|
63
|
+
return html`
|
|
12
64
|
<sp-switch autofocus>Switch</sp-switch>
|
|
13
|
-
|
|
65
|
+
`;
|
|
66
|
+
};
|
|
67
|
+
export const Disabled = () => {
|
|
68
|
+
return html`
|
|
14
69
|
<sp-switch disabled>Switch</sp-switch>
|
|
15
|
-
|
|
70
|
+
`;
|
|
71
|
+
};
|
|
72
|
+
export const disabledChecked = () => {
|
|
73
|
+
return html`
|
|
16
74
|
<sp-switch disabled checked>Switch</sp-switch>
|
|
17
75
|
`;
|
|
76
|
+
};
|
|
18
77
|
//# sourceMappingURL=switch.stories.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["switch.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\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport '@spectrum-web-components/switch/sp-switch.js';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\n\nexport default {\n component: 'sp-switch',\n title: 'Switch',\n};\n\nexport const Default = (): TemplateResult => {\n return html`\n <sp-switch>Switch</sp-switch>\n `;\n};\n\nexport const
|
|
5
|
-
"mappings": "AAWA,
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport '@spectrum-web-components/switch/sp-switch.js';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { spreadProps } from '../../../test/lit-helpers.js';\n\nexport default {\n component: 'sp-switch',\n title: 'Switch',\n\n argTypes: {\n size: {\n name: 'size',\n type: { name: 'string', required: false },\n description: 'The size at which to display the Switch element',\n table: {\n type: { summary: '\"s\" | \"m\" | \"l\" | \"xl\"' },\n defaultValue: { summary: 'm' },\n },\n control: {\n type: 'text',\n },\n },\n },\n args: {\n size: 'm',\n },\n};\n\nexport interface StoryArgs {\n Autofocus?: boolean;\n checked?: boolean;\n Disabled?: boolean;\n disabledChecked?: boolean;\n emphasized?: boolean;\n readonly?: boolean;\n size?: 's' | 'm' | 'l' | 'xl';\n [prop: string]: unknown;\n}\n\nfunction renderSwitch(args: StoryArgs): TemplateResult {\n return html`\n <sp-switch ${spreadProps(args)}>Switch</sp-switch>\n `;\n}\n\nexport const Default = (args: StoryArgs): TemplateResult => renderSwitch(args);\n\nexport const Checked = (): TemplateResult => {\n return html`\n <sp-switch checked>Switch</sp-switch>\n `;\n};\n\nexport const Sizes = (): TemplateResult => {\n return html`\n <div style=\"display: flex; align-items: center; gap: 8px;\">\n <sp-switch size=\"s\">Small</sp-switch>\n <sp-switch size=\"m\">Medium</sp-switch>\n <sp-switch size=\"l\">Large</sp-switch>\n <sp-switch size=\"xl\">Extra-Large</sp-switch>\n </div>\n `;\n};\n\nexport const readonly = (): TemplateResult => {\n return html`\n <sp-switch checked readonly>Switch</sp-switch>\n `;\n};\n\nexport const emphasized = (): TemplateResult => {\n return html`\n <sp-switch emphasized>Switch</sp-switch>\n `;\n};\n\nexport const emphasizedChecked = (): TemplateResult => {\n return html`\n <sp-switch emphasized checked>Switch</sp-switch>\n `;\n};\n\nexport const Autofocus = (): TemplateResult => {\n return html`\n <sp-switch autofocus>Switch</sp-switch>\n `;\n};\n\nexport const Disabled = (): TemplateResult => {\n return html`\n <sp-switch disabled>Switch</sp-switch>\n `;\n};\n\nexport const disabledChecked = (): TemplateResult => {\n return html`\n <sp-switch disabled checked>Switch</sp-switch>\n `;\n};\n"],
|
|
5
|
+
"mappings": ";AAWA,OAAO;AACP,SAAS,YAA4B;AACrC,SAAS,mBAAmB;AAE5B,eAAe;AAAA,EACX,WAAW;AAAA,EACX,OAAO;AAAA,EAEP,UAAU;AAAA,IACN,MAAM;AAAA,MACF,MAAM;AAAA,MACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,MACxC,aAAa;AAAA,MACb,OAAO;AAAA,QACH,MAAM,EAAE,SAAS,yBAAyB;AAAA,QAC1C,cAAc,EAAE,SAAS,IAAI;AAAA,MACjC;AAAA,MACA,SAAS;AAAA,QACL,MAAM;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,IACF,MAAM;AAAA,EACV;AACJ;AAaA,SAAS,aAAa,MAAiC;AACnD,SAAO;AAAA,qBACU,YAAY,IAAI;AAAA;AAErC;AAEO,aAAM,UAAU,CAAC,SAAoC,aAAa,IAAI;AAEtE,aAAM,UAAU,MAAsB;AACzC,SAAO;AAAA;AAAA;AAGX;AAEO,aAAM,QAAQ,MAAsB;AACvC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQX;AAEO,aAAM,WAAW,MAAsB;AAC1C,SAAO;AAAA;AAAA;AAGX;AAEO,aAAM,aAAa,MAAsB;AAC5C,SAAO;AAAA;AAAA;AAGX;AAEO,aAAM,oBAAoB,MAAsB;AACnD,SAAO;AAAA;AAAA;AAGX;AAEO,aAAM,YAAY,MAAsB;AAC3C,SAAO;AAAA;AAAA;AAGX;AAEO,aAAM,WAAW,MAAsB;AAC1C,SAAO;AAAA;AAAA;AAGX;AAEO,aAAM,kBAAkB,MAAsB;AACjD,SAAO;AAAA;AAAA;AAGX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/switch/sp-switch.js";
|
|
3
|
+
import { html } from "lit";
|
|
4
|
+
import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
|
|
5
|
+
measureFixtureCreation(html`
|
|
2
6
|
<sp-switch>Switch</sp-switch>
|
|
3
7
|
`);
|
|
4
8
|
//# sourceMappingURL=test-basic.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["test-basic.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 '@spectrum-web-components/switch/sp-switch.js';\nimport { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-switch>Switch</sp-switch>\n`);\n"],
|
|
5
|
-
"mappings": "AAYA,
|
|
5
|
+
"mappings": ";AAYA,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,8BAA8B;AAEvC,uBAAuB;AAAA;AAAA,CAEtB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["switch-sizes.test-vrt.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/switch-sizes.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('SwitchSizesStories', stories);\n"],
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAE/B,eAAe,sBAAsB,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/test/switch.test-vrt.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import * as stories from "../stories/switch.stories.js";
|
|
3
|
+
import { regressVisuals } from "../../../test/visual/test.js";
|
|
4
|
+
regressVisuals("SwitchStories", stories);
|
|
2
5
|
//# sourceMappingURL=switch.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["switch.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/switch.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('SwitchStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAE/B,eAAe,iBAAiB,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/switch.test.js
CHANGED
|
@@ -1,10 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/switch/sp-switch.js";
|
|
3
|
+
import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
|
|
4
|
+
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
5
|
+
describe("Switch", () => {
|
|
6
|
+
testForLitDevWarnings(
|
|
7
|
+
async () => await fixture(
|
|
8
|
+
html`
|
|
2
9
|
<sp-switch>Not Checked</sp-switch>
|
|
3
|
-
`
|
|
10
|
+
`
|
|
11
|
+
)
|
|
12
|
+
);
|
|
13
|
+
it("loads default switch accessibly", async () => {
|
|
14
|
+
const el = await fixture(
|
|
15
|
+
html`
|
|
4
16
|
<sp-switch>Not Checked</sp-switch>
|
|
5
|
-
`
|
|
17
|
+
`
|
|
18
|
+
);
|
|
19
|
+
await elementUpdated(el);
|
|
20
|
+
await expect(el).to.be.accessible();
|
|
21
|
+
});
|
|
22
|
+
it("loads `checked` switch accessibly", async () => {
|
|
23
|
+
const el = await fixture(
|
|
24
|
+
html`
|
|
6
25
|
<sp-switch checked>Checked</sp-switch>
|
|
7
|
-
`
|
|
26
|
+
`
|
|
27
|
+
);
|
|
28
|
+
await elementUpdated(el);
|
|
29
|
+
await expect(el).to.be.accessible();
|
|
30
|
+
});
|
|
31
|
+
it("maintains its value when [readonly]", async () => {
|
|
32
|
+
const el = await fixture(html`
|
|
8
33
|
<sp-switch checked readonly>Component</sp-switch>
|
|
9
|
-
`);
|
|
34
|
+
`);
|
|
35
|
+
expect(el.checked).to.be.true;
|
|
36
|
+
el.focusElement.click();
|
|
37
|
+
await elementUpdated(el);
|
|
38
|
+
expect(el.checked).to.be.true;
|
|
39
|
+
});
|
|
40
|
+
});
|
|
10
41
|
//# sourceMappingURL=switch.test.js.map
|
package/test/switch.test.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["switch.test.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 '@spectrum-web-components/switch/sp-switch.js';\nimport { Switch } from '@spectrum-web-components/switch';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Switch', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Switch>(\n html`\n <sp-switch>Not Checked</sp-switch>\n `\n )\n );\n it('loads default switch accessibly', async () => {\n const el = await fixture<Switch>(\n html`\n <sp-switch>Not Checked</sp-switch>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `checked` switch accessibly', async () => {\n const el = await fixture<Switch>(\n html`\n <sp-switch checked>Checked</sp-switch>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n\n it('maintains its value when [readonly]', async () => {\n const el = await fixture<Switch>(html`\n <sp-switch checked readonly>Component</sp-switch>\n `);\n expect(el.checked).to.be.true;\n\n el.focusElement.click();\n await elementUpdated(el);\n\n expect(el.checked).to.be.true;\n });\n});\n"],
|
|
5
|
-
"mappings": "AAYA,
|
|
5
|
+
"mappings": ";AAYA,OAAO;AAEP,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AACtD,SAAS,6BAA6B;AAEtC,SAAS,UAAU,MAAM;AACrB;AAAA,IACI,YACI,MAAM;AAAA,MACF;AAAA;AAAA;AAAA,IAGJ;AAAA,EACR;AACA,KAAG,mCAAmC,YAAY;AAC9C,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,qCAAqC,YAAY;AAChD,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AAED,KAAG,uCAAuC,YAAY;AAClD,UAAM,KAAK,MAAM,QAAgB;AAAA;AAAA,SAEhC;AACD,WAAO,GAAG,OAAO,EAAE,GAAG,GAAG;AAEzB,OAAG,aAAa,MAAM;AACtB,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,OAAO,EAAE,GAAG,GAAG;AAAA,EAC7B,CAAC;AACL,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|