@spectrum-web-components/accordion 1.0.2 → 1.0.3
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/LICENSE +201 -0
- package/package.json +8 -7
- package/stories/accordion-densities-compact.stories.js +11 -0
- package/stories/accordion-densities-compact.stories.js.map +7 -0
- package/stories/accordion-densities-spacious.stories.js +11 -0
- package/stories/accordion-densities-spacious.stories.js.map +7 -0
- package/stories/accordion-sizes.stories.js +11 -0
- package/stories/accordion-sizes.stories.js.map +7 -0
- package/stories/accordion.stories.js +32 -0
- package/stories/accordion.stories.js.map +7 -0
- package/stories/args.js +61 -0
- package/stories/args.js.map +7 -0
- package/stories/index.js +42 -0
- package/stories/index.js.map +7 -0
- package/stories/template.js +4 -0
- package/stories/template.js.map +7 -0
- package/test/a11y-tree.test.js +24 -0
- package/test/a11y-tree.test.js.map +7 -0
- package/test/accordion-densities-compact.test-vrt.js +5 -0
- package/test/accordion-densities-compact.test-vrt.js.map +7 -0
- package/test/accordion-densities-spacious.test-vrt.js +5 -0
- package/test/accordion-densities-spacious.test-vrt.js.map +7 -0
- package/test/accordion-sizes.test-vrt.js +5 -0
- package/test/accordion-sizes.test-vrt.js.map +7 -0
- package/test/accordion.test-vrt.js +5 -0
- package/test/accordion.test-vrt.js.map +7 -0
- package/test/benchmark/basic-test.js +28 -0
- package/test/benchmark/basic-test.js.map +7 -0
- package/test/controlled.test.js +30 -0
- package/test/controlled.test.js.map +7 -0
- package/test/declarative.test.js +62 -0
- package/test/declarative.test.js.map +7 -0
- package/test/dev-mode.test.js +8 -0
- package/test/dev-mode.test.js.map +7 -0
- package/test/imperative.test.js +112 -0
- package/test/imperative.test.js.map +7 -0
- package/test/keyboard.test.js +199 -0
- package/test/keyboard.test.js.map +7 -0
- package/test/memory.test.js +7 -0
- package/test/memory.test.js.map +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/accordion",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"lit-html"
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@spectrum-web-components/base": "^1.0.
|
|
72
|
-
"@spectrum-web-components/icon": "^1.0.
|
|
73
|
-
"@spectrum-web-components/icons-ui": "^1.0.
|
|
74
|
-
"@spectrum-web-components/reactive-controllers": "^1.0.
|
|
75
|
-
"@spectrum-web-components/shared": "^1.0.
|
|
71
|
+
"@spectrum-web-components/base": "^1.0.1",
|
|
72
|
+
"@spectrum-web-components/icon": "^1.0.3",
|
|
73
|
+
"@spectrum-web-components/icons-ui": "^1.0.3",
|
|
74
|
+
"@spectrum-web-components/reactive-controllers": "^1.0.3",
|
|
75
|
+
"@spectrum-web-components/shared": "^1.0.1"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@spectrum-css/accordion": "^6.0.0-s2-foundations.16"
|
|
@@ -82,5 +82,6 @@
|
|
|
82
82
|
"sideEffects": [
|
|
83
83
|
"./sp-*.js",
|
|
84
84
|
"./**/*.dev.js"
|
|
85
|
-
]
|
|
85
|
+
],
|
|
86
|
+
"gitHead": "f102bde98b9dca7ef2ad602dc31ce986560891ad"
|
|
86
87
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { AccordionMarkup } from "./";
|
|
3
|
+
export default {
|
|
4
|
+
title: "Accordion/Densities/Compact",
|
|
5
|
+
component: "sp-accordion"
|
|
6
|
+
};
|
|
7
|
+
export const s = () => AccordionMarkup({ density: "compact", size: "s" });
|
|
8
|
+
export const m = () => AccordionMarkup({ density: "compact", size: "m" });
|
|
9
|
+
export const l = () => AccordionMarkup({ density: "compact", size: "l" });
|
|
10
|
+
export const xl = () => AccordionMarkup({ density: "compact", size: "xl" });
|
|
11
|
+
//# sourceMappingURL=accordion-densities-compact.stories.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["accordion-densities-compact.stories.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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 { TemplateResult } from '@spectrum-web-components/base';\nimport { AccordionMarkup } from './';\n\nexport default {\n title: 'Accordion/Densities/Compact',\n component: 'sp-accordion',\n};\n\nexport const s = (): TemplateResult =>\n AccordionMarkup({ density: 'compact', size: 's' });\nexport const m = (): TemplateResult =>\n AccordionMarkup({ density: 'compact', size: 'm' });\nexport const l = (): TemplateResult =>\n AccordionMarkup({ density: 'compact', size: 'l' });\nexport const xl = (): TemplateResult =>\n AccordionMarkup({ density: 'compact', size: 'xl' });\n"],
|
|
5
|
+
"mappings": ";AAaA,SAAS,uBAAuB;AAEhC,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AACf;AAEO,aAAM,IAAI,MACb,gBAAgB,EAAE,SAAS,WAAW,MAAM,IAAI,CAAC;AAC9C,aAAM,IAAI,MACb,gBAAgB,EAAE,SAAS,WAAW,MAAM,IAAI,CAAC;AAC9C,aAAM,IAAI,MACb,gBAAgB,EAAE,SAAS,WAAW,MAAM,IAAI,CAAC;AAC9C,aAAM,KAAK,MACd,gBAAgB,EAAE,SAAS,WAAW,MAAM,KAAK,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { AccordionMarkup } from "./";
|
|
3
|
+
export default {
|
|
4
|
+
title: "Accordion/Densities/Spacious",
|
|
5
|
+
component: "sp-accordion"
|
|
6
|
+
};
|
|
7
|
+
export const s = () => AccordionMarkup({ density: "spacious", size: "s" });
|
|
8
|
+
export const m = () => AccordionMarkup({ density: "spacious", size: "m" });
|
|
9
|
+
export const l = () => AccordionMarkup({ density: "spacious", size: "l" });
|
|
10
|
+
export const xl = () => AccordionMarkup({ density: "spacious", size: "xl" });
|
|
11
|
+
//# sourceMappingURL=accordion-densities-spacious.stories.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["accordion-densities-spacious.stories.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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 { TemplateResult } from '@spectrum-web-components/base';\nimport { AccordionMarkup } from './';\n\nexport default {\n title: 'Accordion/Densities/Spacious',\n component: 'sp-accordion',\n};\n\nexport const s = (): TemplateResult =>\n AccordionMarkup({ density: 'spacious', size: 's' });\nexport const m = (): TemplateResult =>\n AccordionMarkup({ density: 'spacious', size: 'm' });\nexport const l = (): TemplateResult =>\n AccordionMarkup({ density: 'spacious', size: 'l' });\nexport const xl = (): TemplateResult =>\n AccordionMarkup({ density: 'spacious', size: 'xl' });\n"],
|
|
5
|
+
"mappings": ";AAaA,SAAS,uBAAuB;AAEhC,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AACf;AAEO,aAAM,IAAI,MACb,gBAAgB,EAAE,SAAS,YAAY,MAAM,IAAI,CAAC;AAC/C,aAAM,IAAI,MACb,gBAAgB,EAAE,SAAS,YAAY,MAAM,IAAI,CAAC;AAC/C,aAAM,IAAI,MACb,gBAAgB,EAAE,SAAS,YAAY,MAAM,IAAI,CAAC;AAC/C,aAAM,KAAK,MACd,gBAAgB,EAAE,SAAS,YAAY,MAAM,KAAK,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { AccordionMarkup } from "./";
|
|
3
|
+
export default {
|
|
4
|
+
title: "Accordion/Sizes",
|
|
5
|
+
component: "sp-accordion"
|
|
6
|
+
};
|
|
7
|
+
export const s = () => AccordionMarkup({ size: "s" });
|
|
8
|
+
export const m = () => AccordionMarkup({ size: "m" });
|
|
9
|
+
export const l = () => AccordionMarkup({ size: "l" });
|
|
10
|
+
export const xl = () => AccordionMarkup({ size: "xl" });
|
|
11
|
+
//# sourceMappingURL=accordion-sizes.stories.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["accordion-sizes.stories.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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 { TemplateResult } from '@spectrum-web-components/base';\nimport { AccordionMarkup } from './';\n\nexport default {\n title: 'Accordion/Sizes',\n component: 'sp-accordion',\n};\n\nexport const s = (): TemplateResult => AccordionMarkup({ size: 's' });\nexport const m = (): TemplateResult => AccordionMarkup({ size: 'm' });\nexport const l = (): TemplateResult => AccordionMarkup({ size: 'l' });\nexport const xl = (): TemplateResult => AccordionMarkup({ size: 'xl' });\n"],
|
|
5
|
+
"mappings": ";AAaA,SAAS,uBAAuB;AAEhC,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AACf;AAEO,aAAM,IAAI,MAAsB,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAC7D,aAAM,IAAI,MAAsB,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAC7D,aAAM,IAAI,MAAsB,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAC7D,aAAM,KAAK,MAAsB,gBAAgB,EAAE,MAAM,KAAK,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { AccordionMarkup } from "./";
|
|
3
|
+
import { argTypes } from "./args.js";
|
|
4
|
+
import "@spectrum-web-components/accordion/sp-accordion.js";
|
|
5
|
+
import "@spectrum-web-components/accordion/sp-accordion-item.js";
|
|
6
|
+
import "@spectrum-web-components/link/sp-link.js";
|
|
7
|
+
export default {
|
|
8
|
+
title: "Accordion",
|
|
9
|
+
component: "sp-accordion",
|
|
10
|
+
args: {
|
|
11
|
+
open: false,
|
|
12
|
+
size: "m",
|
|
13
|
+
density: void 0
|
|
14
|
+
},
|
|
15
|
+
argTypes
|
|
16
|
+
};
|
|
17
|
+
export const Default = (args) => AccordionMarkup(args);
|
|
18
|
+
export const Open = (args) => AccordionMarkup(args);
|
|
19
|
+
Open.args = {
|
|
20
|
+
open: true,
|
|
21
|
+
allowMultiple: false,
|
|
22
|
+
disabled: false
|
|
23
|
+
};
|
|
24
|
+
export const AllowMultiple = (args) => AccordionMarkup(args);
|
|
25
|
+
AllowMultiple.args = {
|
|
26
|
+
allowMultiple: true
|
|
27
|
+
};
|
|
28
|
+
export const Disabled = (args) => AccordionMarkup(args);
|
|
29
|
+
Disabled.args = {
|
|
30
|
+
disabled: true
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=accordion.stories.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["accordion.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*/\n\nimport { TemplateResult } from '@spectrum-web-components/base';\nimport { AccordionMarkup } from './';\nimport { argTypes } from './args.js';\n\nimport '@spectrum-web-components/accordion/sp-accordion.js';\nimport '@spectrum-web-components/accordion/sp-accordion-item.js';\nimport '@spectrum-web-components/link/sp-link.js';\n\nexport default {\n title: 'Accordion',\n component: 'sp-accordion',\n args: {\n open: false,\n size: 'm',\n density: undefined,\n },\n argTypes,\n};\n\ntype Properties = {\n allowMultiple?: boolean;\n disabled?: boolean;\n open?: boolean;\n density?: 'compact' | 'spacious' | undefined;\n size?: 's' | 'm' | 'l' | 'xl';\n};\n\nexport const Default = (args?: Properties): TemplateResult =>\n AccordionMarkup(args);\n\nexport const Open = (args?: Properties): TemplateResult =>\n AccordionMarkup(args);\nOpen.args = {\n open: true,\n allowMultiple: false,\n disabled: false,\n};\n\nexport const AllowMultiple = (args?: Properties): TemplateResult =>\n AccordionMarkup(args);\nAllowMultiple.args = {\n allowMultiple: true,\n};\n\nexport const Disabled = (args?: Properties): TemplateResult =>\n AccordionMarkup(args);\nDisabled.args = {\n disabled: true,\n};\n"],
|
|
5
|
+
"mappings": ";AAaA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAEzB,OAAO;AACP,OAAO;AACP,OAAO;AAEP,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM;AAAA,IACF,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACb;AAAA,EACA;AACJ;AAUO,aAAM,UAAU,CAAC,SACpB,gBAAgB,IAAI;AAEjB,aAAM,OAAO,CAAC,SACjB,gBAAgB,IAAI;AACxB,KAAK,OAAO;AAAA,EACR,MAAM;AAAA,EACN,eAAe;AAAA,EACf,UAAU;AACd;AAEO,aAAM,gBAAgB,CAAC,SAC1B,gBAAgB,IAAI;AACxB,cAAc,OAAO;AAAA,EACjB,eAAe;AACnB;AAEO,aAAM,WAAW,CAAC,SACrB,gBAAgB,IAAI;AACxB,SAAS,OAAO;AAAA,EACZ,UAAU;AACd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/stories/args.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
export const argTypes = {
|
|
3
|
+
open: {
|
|
4
|
+
name: "open",
|
|
5
|
+
type: { name: "boolean", required: false },
|
|
6
|
+
description: "Whether the second accordion item is open.",
|
|
7
|
+
table: {
|
|
8
|
+
type: { summary: "boolean" },
|
|
9
|
+
defaultValue: { summary: false }
|
|
10
|
+
},
|
|
11
|
+
control: {
|
|
12
|
+
type: "boolean"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
allowMultiple: {
|
|
16
|
+
name: "allowMultiple",
|
|
17
|
+
type: { name: "boolean", required: false },
|
|
18
|
+
description: "Whether multipel Accordion Items can be open at the same time.",
|
|
19
|
+
table: {
|
|
20
|
+
type: { summary: "boolean" },
|
|
21
|
+
defaultValue: { summary: false }
|
|
22
|
+
},
|
|
23
|
+
control: {
|
|
24
|
+
type: "boolean"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
density: {
|
|
28
|
+
name: "density",
|
|
29
|
+
type: { name: "string", required: false },
|
|
30
|
+
description: "The density at which to display accordion items.",
|
|
31
|
+
table: {
|
|
32
|
+
defaultValue: { summary: "default" }
|
|
33
|
+
},
|
|
34
|
+
control: {
|
|
35
|
+
labels: {
|
|
36
|
+
compact: "Compact",
|
|
37
|
+
spacious: "Spacious",
|
|
38
|
+
default: "Default"
|
|
39
|
+
},
|
|
40
|
+
type: "select"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
name: "size",
|
|
45
|
+
type: { name: "string", required: false },
|
|
46
|
+
description: "The size at which to display accordion items.",
|
|
47
|
+
table: {
|
|
48
|
+
defaultValue: { summary: "m" }
|
|
49
|
+
},
|
|
50
|
+
control: {
|
|
51
|
+
labels: {
|
|
52
|
+
s: "Small",
|
|
53
|
+
m: "Medium",
|
|
54
|
+
l: "Large",
|
|
55
|
+
xl: "Extra large"
|
|
56
|
+
},
|
|
57
|
+
type: "select"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=args.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["args.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2024 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\nexport const argTypes = {\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the second accordion item is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n allowMultiple: {\n name: 'allowMultiple',\n type: { name: 'boolean', required: false },\n description:\n 'Whether multipel Accordion Items can be open at the same time.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n density: {\n name: 'density',\n type: { name: 'string', required: false },\n description: 'The density at which to display accordion items.',\n table: {\n defaultValue: { summary: 'default' },\n },\n control: {\n labels: {\n compact: 'Compact',\n spacious: 'Spacious',\n default: 'Default',\n },\n type: 'select',\n },\n },\n size: {\n name: 'size',\n type: { name: 'string', required: false },\n description: 'The size at which to display accordion items.',\n table: {\n defaultValue: { summary: 'm' },\n },\n control: {\n labels: {\n s: 'Small',\n m: 'Medium',\n l: 'Large',\n xl: 'Extra large',\n },\n type: 'select',\n },\n },\n};\n"],
|
|
5
|
+
"mappings": ";AAYO,aAAM,WAAW;AAAA,EACpB,MAAM;AAAA,IACF,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,WAAW,UAAU,MAAM;AAAA,IACzC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,UAAU;AAAA,MAC3B,cAAc,EAAE,SAAS,MAAM;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,eAAe;AAAA,IACX,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,WAAW,UAAU,MAAM;AAAA,IACzC,aACI;AAAA,IACJ,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,UAAU;AAAA,MAC3B,cAAc,EAAE,SAAS,MAAM;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,SAAS;AAAA,IACL,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,IACxC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,cAAc,EAAE,SAAS,UAAU;AAAA,IACvC;AAAA,IACA,SAAS;AAAA,MACL,QAAQ;AAAA,QACJ,SAAS;AAAA,QACT,UAAU;AAAA,QACV,SAAS;AAAA,MACb;AAAA,MACA,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,IACF,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,IACxC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,cAAc,EAAE,SAAS,IAAI;AAAA,IACjC;AAAA,IACA,SAAS;AAAA,MACL,QAAQ;AAAA,QACJ,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,IAAI;AAAA,MACR;AAAA,MACA,MAAM;AAAA,IACV;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/stories/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { html } from "@spectrum-web-components/base";
|
|
3
|
+
import "@spectrum-web-components/accordion/sp-accordion.js";
|
|
4
|
+
import "@spectrum-web-components/accordion/sp-accordion-item.js";
|
|
5
|
+
import "@spectrum-web-components/link/sp-link.js";
|
|
6
|
+
export const AccordionMarkup = ({
|
|
7
|
+
allowMultiple = false,
|
|
8
|
+
disabled = false,
|
|
9
|
+
open = false,
|
|
10
|
+
size = "m",
|
|
11
|
+
density = void 0
|
|
12
|
+
} = {}) => {
|
|
13
|
+
return html`
|
|
14
|
+
<sp-accordion
|
|
15
|
+
?allow-multiple=${allowMultiple}
|
|
16
|
+
density=${density}
|
|
17
|
+
size=${size}
|
|
18
|
+
>
|
|
19
|
+
<sp-accordion-item label="Heading 1" ?disabled=${disabled}>
|
|
20
|
+
<div>Item 1</div>
|
|
21
|
+
</sp-accordion-item>
|
|
22
|
+
<sp-accordion-item label="Heading 2" ?open=${open}>
|
|
23
|
+
Item 2
|
|
24
|
+
</sp-accordion-item>
|
|
25
|
+
<sp-accordion-item label="Heading 3">
|
|
26
|
+
<p>
|
|
27
|
+
This is content that has a
|
|
28
|
+
<sp-link
|
|
29
|
+
href="http://opensource.adobe.com/spectrum-web-components"
|
|
30
|
+
target="_blank"
|
|
31
|
+
>
|
|
32
|
+
link back to Spectrum Web Components
|
|
33
|
+
</sp-link>
|
|
34
|
+
so that it is easy to test that "Space" and "Enter"
|
|
35
|
+
interactions on focusable content does NOT toggle the
|
|
36
|
+
Accordion Item.
|
|
37
|
+
</p>
|
|
38
|
+
</sp-accordion-item>
|
|
39
|
+
</sp-accordion>
|
|
40
|
+
`;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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/accordion/sp-accordion.js';\nimport '@spectrum-web-components/accordion/sp-accordion-item.js';\nimport '@spectrum-web-components/link/sp-link.js';\n\nexport const AccordionMarkup = ({\n allowMultiple = false,\n disabled = false,\n open = false,\n size = 'm',\n density = undefined as unknown,\n} = {}): TemplateResult => {\n return html`\n <sp-accordion\n ?allow-multiple=${allowMultiple}\n density=${density}\n size=${size}\n >\n <sp-accordion-item label=\"Heading 1\" ?disabled=${disabled}>\n <div>Item 1</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 2\" ?open=${open}>\n Item 2\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 3\">\n <p>\n This is content that has a\n <sp-link\n href=\"http://opensource.adobe.com/spectrum-web-components\"\n target=\"_blank\"\n >\n link back to Spectrum Web Components\n </sp-link>\n so that it is easy to test that \"Space\" and \"Enter\"\n interactions on focusable content does NOT toggle the\n Accordion Item.\n </p>\n </sp-accordion-item>\n </sp-accordion>\n `;\n};\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,YAA4B;AAErC,OAAO;AACP,OAAO;AACP,OAAO;AAEA,aAAM,kBAAkB,CAAC;AAAA,EAC5B,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,OAAO;AAAA,EACP,OAAO;AAAA,EACP,UAAU;AACd,IAAI,CAAC,MAAsB;AACvB,SAAO;AAAA;AAAA,8BAEmB,aAAa;AAAA,sBACrB,OAAO;AAAA,mBACV,IAAI;AAAA;AAAA,6DAEsC,QAAQ;AAAA;AAAA;AAAA,yDAGZ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmB7D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["template.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2024 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 { AccordionMarkup } from './';\n\nexport const Template = AccordionMarkup;\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,uBAAuB;AAEzB,aAAM,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { html } from "@spectrum-web-components/base";
|
|
3
|
+
import { elementUpdated, expect, fixture } from "@open-wc/testing";
|
|
4
|
+
import "@spectrum-web-components/accordion/sp-accordion-item.js";
|
|
5
|
+
import { Default } from "../stories/accordion.stories.js";
|
|
6
|
+
describe("Accordion - a11y tree", () => {
|
|
7
|
+
it("renders with items accessibly", async () => {
|
|
8
|
+
const el = await fixture(Default());
|
|
9
|
+
await elementUpdated(el);
|
|
10
|
+
await expect(el).to.be.accessible();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
describe("Accordion Item - a11y tree", () => {
|
|
14
|
+
it("can exist with no parent accessibly", async () => {
|
|
15
|
+
const el = await fixture(html`
|
|
16
|
+
<sp-accordion-item label="item">
|
|
17
|
+
<div>Item 1</div>
|
|
18
|
+
</sp-accordion-item>
|
|
19
|
+
`);
|
|
20
|
+
await elementUpdated(el);
|
|
21
|
+
await expect(el).to.be.accessible();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=a11y-tree.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["a11y-tree.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { html } from '@spectrum-web-components/base';\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\n\nimport { Accordion, AccordionItem } from '@spectrum-web-components/accordion';\nimport '@spectrum-web-components/accordion/sp-accordion-item.js';\n\nimport { Default } from '../stories/accordion.stories.js';\n\ndescribe('Accordion - a11y tree', () => {\n it('renders with items accessibly', async () => {\n const el = await fixture<Accordion>(Default());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n});\n\ndescribe('Accordion Item - a11y tree', () => {\n it('can exist with no parent accessibly', async () => {\n const el = await fixture<AccordionItem>(html`\n <sp-accordion-item label=\"item\">\n <div>Item 1</div>\n </sp-accordion-item>\n `);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,YAAY;AACrB,SAAS,gBAAgB,QAAQ,eAAe;AAGhD,OAAO;AAEP,SAAS,eAAe;AAExB,SAAS,yBAAyB,MAAM;AACpC,KAAG,iCAAiC,YAAY;AAC5C,UAAM,KAAK,MAAM,QAAmB,QAAQ,CAAC;AAE7C,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACL,CAAC;AAED,SAAS,8BAA8B,MAAM;AACzC,KAAG,uCAAuC,YAAY;AAClD,UAAM,KAAK,MAAM,QAAuB;AAAA;AAAA;AAAA;AAAA,SAIvC;AAED,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import * as stories from "../stories/accordion-densities-compact.stories.js";
|
|
3
|
+
import { regressVisuals } from "../../../test/visual/test.js";
|
|
4
|
+
regressVisuals("AccordionDensitiesCompactStories", stories);
|
|
5
|
+
//# sourceMappingURL=accordion-densities-compact.test-vrt.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["accordion-densities-compact.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/accordion-densities-compact.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('AccordionDensitiesCompactStories', stories as unknown as TestsType);\n"],
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,oCAAoC,OAA+B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import * as stories from "../stories/accordion-densities-spacious.stories.js";
|
|
3
|
+
import { regressVisuals } from "../../../test/visual/test.js";
|
|
4
|
+
regressVisuals("AccordionDensitiesSpaciousStories", stories);
|
|
5
|
+
//# sourceMappingURL=accordion-densities-spacious.test-vrt.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["accordion-densities-spacious.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/accordion-densities-spacious.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('AccordionDensitiesSpaciousStories', stories as unknown as TestsType);\n"],
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,qCAAqC,OAA+B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["accordion-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/accordion-sizes.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('AccordionSizesStories', stories as unknown as TestsType);\n"],
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,yBAAyB,OAA+B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["accordion.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/accordion.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('AccordionStories', stories as unknown as TestsType);\n"],
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,oBAAoB,OAA+B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/accordion/sp-accordion.js";
|
|
3
|
+
import "@spectrum-web-components/accordion/sp-accordion-item.js";
|
|
4
|
+
import { html } from "lit";
|
|
5
|
+
import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
|
|
6
|
+
measureFixtureCreation(html`
|
|
7
|
+
<sp-accordion>
|
|
8
|
+
<sp-accordion-item label="Heading 1">
|
|
9
|
+
<div>Item 1</div>
|
|
10
|
+
</sp-accordion-item>
|
|
11
|
+
<sp-accordion-item label="Heading 2">
|
|
12
|
+
<div>Item 2</div>
|
|
13
|
+
</sp-accordion-item>
|
|
14
|
+
<sp-accordion-item label="Heading 3">
|
|
15
|
+
<div>Item 3</div>
|
|
16
|
+
</sp-accordion-item>
|
|
17
|
+
<sp-accordion-item label="Heading 4">
|
|
18
|
+
<div>Item 4</div>
|
|
19
|
+
</sp-accordion-item>
|
|
20
|
+
<sp-accordion-item label="Heading 5">
|
|
21
|
+
<div>Item 5</div>
|
|
22
|
+
</sp-accordion-item>
|
|
23
|
+
<sp-accordion-item label="Heading 6">
|
|
24
|
+
<div>Item 6</div>
|
|
25
|
+
</sp-accordion-item>
|
|
26
|
+
</sp-accordion>
|
|
27
|
+
`);
|
|
28
|
+
//# sourceMappingURL=basic-test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["basic-test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/accordion/sp-accordion.js';\nimport '@spectrum-web-components/accordion/sp-accordion-item.js';\nimport { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-accordion>\n <sp-accordion-item label=\"Heading 1\">\n <div>Item 1</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 2\">\n <div>Item 2</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 3\">\n <div>Item 3</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 4\">\n <div>Item 4</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 5\">\n <div>Item 5</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 6\">\n <div>Item 6</div>\n </sp-accordion-item>\n </sp-accordion>\n`);\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO;AACP,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,8BAA8B;AAEvC,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAqBtB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { elementUpdated, expect, fixture } from "@open-wc/testing";
|
|
3
|
+
import { Default } from "../stories/accordion.stories.js";
|
|
4
|
+
describe("Accordion - controlled", () => {
|
|
5
|
+
it("can have `toggle` events canceled", async () => {
|
|
6
|
+
const el = await fixture(Default());
|
|
7
|
+
await elementUpdated(el);
|
|
8
|
+
const firstItem = el.querySelector(
|
|
9
|
+
"sp-accordion-item:nth-of-type(1)"
|
|
10
|
+
);
|
|
11
|
+
const secondItem = el.querySelector(
|
|
12
|
+
"sp-accordion-item:nth-of-type(2)"
|
|
13
|
+
);
|
|
14
|
+
const firstButton = firstItem.focusElement;
|
|
15
|
+
const secondButton = secondItem.focusElement;
|
|
16
|
+
firstButton.click();
|
|
17
|
+
await elementUpdated(el);
|
|
18
|
+
expect(firstItem.open).to.be.true;
|
|
19
|
+
expect(secondItem.open).to.be.false;
|
|
20
|
+
el.addEventListener(
|
|
21
|
+
"sp-accordion-item-toggle",
|
|
22
|
+
(event) => event.preventDefault()
|
|
23
|
+
);
|
|
24
|
+
secondButton.click();
|
|
25
|
+
await elementUpdated(el);
|
|
26
|
+
expect(firstItem.open).to.be.true;
|
|
27
|
+
expect(secondItem.open).to.be.false;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=controlled.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["controlled.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\n\nimport { Accordion, AccordionItem } from '@spectrum-web-components/accordion';\n\nimport { Default } from '../stories/accordion.stories.js';\n\ndescribe('Accordion - controlled', () => {\n it('can have `toggle` events canceled', async () => {\n const el = await fixture<Accordion>(Default());\n await elementUpdated(el);\n const firstItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(1)'\n ) as AccordionItem;\n const secondItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(2)'\n ) as AccordionItem;\n\n const firstButton = firstItem.focusElement;\n const secondButton = secondItem.focusElement;\n\n firstButton.click();\n await elementUpdated(el);\n expect(firstItem.open).to.be.true;\n expect(secondItem.open).to.be.false;\n\n el.addEventListener('sp-accordion-item-toggle', (event: Event) =>\n event.preventDefault()\n );\n\n secondButton.click();\n await elementUpdated(el);\n expect(firstItem.open).to.be.true;\n expect(secondItem.open).to.be.false;\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,gBAAgB,QAAQ,eAAe;AAIhD,SAAS,eAAe;AAExB,SAAS,0BAA0B,MAAM;AACrC,KAAG,qCAAqC,YAAY;AAChD,UAAM,KAAK,MAAM,QAAmB,QAAQ,CAAC;AAC7C,UAAM,eAAe,EAAE;AACvB,UAAM,YAAY,GAAG;AAAA,MACjB;AAAA,IACJ;AACA,UAAM,aAAa,GAAG;AAAA,MAClB;AAAA,IACJ;AAEA,UAAM,cAAc,UAAU;AAC9B,UAAM,eAAe,WAAW;AAEhC,gBAAY,MAAM;AAClB,UAAM,eAAe,EAAE;AACvB,WAAO,UAAU,IAAI,EAAE,GAAG,GAAG;AAC7B,WAAO,WAAW,IAAI,EAAE,GAAG,GAAG;AAE9B,OAAG;AAAA,MAAiB;AAAA,MAA4B,CAAC,UAC7C,MAAM,eAAe;AAAA,IACzB;AAEA,iBAAa,MAAM;AACnB,UAAM,eAAe,EAAE;AACvB,WAAO,UAAU,IAAI,EAAE,GAAG,GAAG;AAC7B,WAAO,WAAW,IAAI,EAAE,GAAG,GAAG;AAAA,EAClC,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { html } from "@spectrum-web-components/base";
|
|
3
|
+
import { elementUpdated, expect, fixture } from "@open-wc/testing";
|
|
4
|
+
import { spy } from "sinon";
|
|
5
|
+
import "@spectrum-web-components/accordion/sp-accordion.js";
|
|
6
|
+
import "@spectrum-web-components/accordion/sp-accordion-item.js";
|
|
7
|
+
describe("Accordion - declarative", () => {
|
|
8
|
+
it("does not accept focus when empty", async () => {
|
|
9
|
+
const el = await fixture(html`
|
|
10
|
+
<sp-accordion></sp-accordion>
|
|
11
|
+
`);
|
|
12
|
+
await elementUpdated(el);
|
|
13
|
+
expect(document.activeElement === el).to.be.false;
|
|
14
|
+
el.focus();
|
|
15
|
+
await elementUpdated(el);
|
|
16
|
+
expect(document.activeElement === el).to.be.false;
|
|
17
|
+
});
|
|
18
|
+
it("does not accept focus when all children [disabled]", async () => {
|
|
19
|
+
const el = await fixture(html`
|
|
20
|
+
<sp-accordion>
|
|
21
|
+
<sp-accordion-item disabled label="Heading 1">
|
|
22
|
+
<div>Item 1</div>
|
|
23
|
+
</sp-accordion-item>
|
|
24
|
+
<sp-accordion-item disabled label="Heading 2">
|
|
25
|
+
<div>Item 2</div>
|
|
26
|
+
</sp-accordion-item>
|
|
27
|
+
</sp-accordion>
|
|
28
|
+
`);
|
|
29
|
+
await elementUpdated(el);
|
|
30
|
+
expect(document.activeElement === el).to.be.false;
|
|
31
|
+
el.focus();
|
|
32
|
+
await elementUpdated(el);
|
|
33
|
+
expect(document.activeElement === el).to.be.false;
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe("Accordion Item - declarative", () => {
|
|
37
|
+
it("can be `[disabled]`", async () => {
|
|
38
|
+
const toggleSpy = spy();
|
|
39
|
+
const handleToggle = () => toggleSpy();
|
|
40
|
+
const el = await fixture(html`
|
|
41
|
+
<sp-accordion-item
|
|
42
|
+
disabled
|
|
43
|
+
@sp-accordion-item-toggle=${handleToggle}
|
|
44
|
+
>
|
|
45
|
+
<div>Item 1</div>
|
|
46
|
+
</sp-accordion-item>
|
|
47
|
+
`);
|
|
48
|
+
const root = el.shadowRoot;
|
|
49
|
+
const button = root.querySelector("#header");
|
|
50
|
+
await elementUpdated(el);
|
|
51
|
+
expect(toggleSpy.callCount).to.equal(0);
|
|
52
|
+
button.click();
|
|
53
|
+
await elementUpdated(el);
|
|
54
|
+
expect(toggleSpy.callCount).to.equal(0);
|
|
55
|
+
el.disabled = false;
|
|
56
|
+
await elementUpdated(el);
|
|
57
|
+
button.click();
|
|
58
|
+
await elementUpdated(el);
|
|
59
|
+
expect(toggleSpy.callCount).to.equal(1);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=declarative.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["declarative.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { html } from '@spectrum-web-components/base';\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\nimport { spy } from 'sinon';\n\nimport { Accordion, AccordionItem } from '@spectrum-web-components/accordion';\nimport '@spectrum-web-components/accordion/sp-accordion.js';\nimport '@spectrum-web-components/accordion/sp-accordion-item.js';\n\ndescribe('Accordion - declarative', () => {\n it('does not accept focus when empty', async () => {\n const el = await fixture<Accordion>(html`\n <sp-accordion></sp-accordion>\n `);\n\n await elementUpdated(el);\n\n expect(document.activeElement === el).to.be.false;\n\n el.focus();\n await elementUpdated(el);\n\n expect(document.activeElement === el).to.be.false;\n });\n it('does not accept focus when all children [disabled]', async () => {\n const el = await fixture<Accordion>(html`\n <sp-accordion>\n <sp-accordion-item disabled label=\"Heading 1\">\n <div>Item 1</div>\n </sp-accordion-item>\n <sp-accordion-item disabled label=\"Heading 2\">\n <div>Item 2</div>\n </sp-accordion-item>\n </sp-accordion>\n `);\n\n await elementUpdated(el);\n\n expect(document.activeElement === el).to.be.false;\n\n el.focus();\n await elementUpdated(el);\n\n expect(document.activeElement === el).to.be.false;\n });\n});\n\ndescribe('Accordion Item - declarative', () => {\n it('can be `[disabled]`', async () => {\n const toggleSpy = spy();\n const handleToggle = (): void => toggleSpy();\n const el = await fixture<AccordionItem>(html`\n <sp-accordion-item\n disabled\n @sp-accordion-item-toggle=${handleToggle}\n >\n <div>Item 1</div>\n </sp-accordion-item>\n `);\n\n const root = el.shadowRoot as ShadowRoot;\n const button = root.querySelector('#header') as HTMLElement;\n\n await elementUpdated(el);\n\n expect(toggleSpy.callCount).to.equal(0);\n\n button.click();\n\n await elementUpdated(el);\n\n expect(toggleSpy.callCount).to.equal(0);\n\n el.disabled = false;\n await elementUpdated(el);\n\n button.click();\n\n await elementUpdated(el);\n\n expect(toggleSpy.callCount).to.equal(1);\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,YAAY;AACrB,SAAS,gBAAgB,QAAQ,eAAe;AAChD,SAAS,WAAW;AAGpB,OAAO;AACP,OAAO;AAEP,SAAS,2BAA2B,MAAM;AACtC,KAAG,oCAAoC,YAAY;AAC/C,UAAM,KAAK,MAAM,QAAmB;AAAA;AAAA,SAEnC;AAED,UAAM,eAAe,EAAE;AAEvB,WAAO,SAAS,kBAAkB,EAAE,EAAE,GAAG,GAAG;AAE5C,OAAG,MAAM;AACT,UAAM,eAAe,EAAE;AAEvB,WAAO,SAAS,kBAAkB,EAAE,EAAE,GAAG,GAAG;AAAA,EAChD,CAAC;AACD,KAAG,sDAAsD,YAAY;AACjE,UAAM,KAAK,MAAM,QAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SASnC;AAED,UAAM,eAAe,EAAE;AAEvB,WAAO,SAAS,kBAAkB,EAAE,EAAE,GAAG,GAAG;AAE5C,OAAG,MAAM;AACT,UAAM,eAAe,EAAE;AAEvB,WAAO,SAAS,kBAAkB,EAAE,EAAE,GAAG,GAAG;AAAA,EAChD,CAAC;AACL,CAAC;AAED,SAAS,gCAAgC,MAAM;AAC3C,KAAG,uBAAuB,YAAY;AAClC,UAAM,YAAY,IAAI;AACtB,UAAM,eAAe,MAAY,UAAU;AAC3C,UAAM,KAAK,MAAM,QAAuB;AAAA;AAAA;AAAA,4CAGJ,YAAY;AAAA;AAAA;AAAA;AAAA,SAI/C;AAED,UAAM,OAAO,GAAG;AAChB,UAAM,SAAS,KAAK,cAAc,SAAS;AAE3C,UAAM,eAAe,EAAE;AAEvB,WAAO,UAAU,SAAS,EAAE,GAAG,MAAM,CAAC;AAEtC,WAAO,MAAM;AAEb,UAAM,eAAe,EAAE;AAEvB,WAAO,UAAU,SAAS,EAAE,GAAG,MAAM,CAAC;AAEtC,OAAG,WAAW;AACd,UAAM,eAAe,EAAE;AAEvB,WAAO,MAAM;AAEb,UAAM,eAAe,EAAE;AAEvB,WAAO,UAAU,SAAS,EAAE,GAAG,MAAM,CAAC;AAAA,EAC1C,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { fixture } from "@open-wc/testing";
|
|
3
|
+
import { Default } from "../stories/accordion.stories.js";
|
|
4
|
+
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
5
|
+
describe("Accordion - dev mode", () => {
|
|
6
|
+
testForLitDevWarnings(async () => await fixture(Default()));
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=dev-mode.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["dev-mode.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { fixture } from '@open-wc/testing';\n\nimport { Accordion } from '@spectrum-web-components/accordion';\n\nimport { Default } from '../stories/accordion.stories.js';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Accordion - dev mode', () => {\n testForLitDevWarnings(async () => await fixture<Accordion>(Default()));\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,eAAe;AAIxB,SAAS,eAAe;AACxB,SAAS,6BAA6B;AAEtC,SAAS,wBAAwB,MAAM;AACnC,wBAAsB,YAAY,MAAM,QAAmB,QAAQ,CAAC,CAAC;AACzE,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { elementUpdated, expect, fixture } from "@open-wc/testing";
|
|
3
|
+
import { Default } from "../stories/accordion.stories.js";
|
|
4
|
+
import { AccordionMarkup } from "../stories/index.js";
|
|
5
|
+
describe("Accordion - imperative interactions", () => {
|
|
6
|
+
it("manages item size", async () => {
|
|
7
|
+
const el = await fixture(
|
|
8
|
+
AccordionMarkup({
|
|
9
|
+
size: "l"
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
const item = el.querySelector("sp-accordion-item");
|
|
13
|
+
expect(el.size).to.equal("l");
|
|
14
|
+
expect(item.size).to.equal("l");
|
|
15
|
+
el.size = "s";
|
|
16
|
+
await elementUpdated(el);
|
|
17
|
+
await elementUpdated(item);
|
|
18
|
+
expect(el.size).to.equal("s");
|
|
19
|
+
expect(item.size).to.equal("s");
|
|
20
|
+
});
|
|
21
|
+
it("only allows one open item by default", async () => {
|
|
22
|
+
const el = await fixture(Default());
|
|
23
|
+
await elementUpdated(el);
|
|
24
|
+
const firstItem = el.querySelector(
|
|
25
|
+
"sp-accordion-item:nth-of-type(1)"
|
|
26
|
+
);
|
|
27
|
+
const secondItem = el.querySelector(
|
|
28
|
+
"sp-accordion-item:nth-of-type(2)"
|
|
29
|
+
);
|
|
30
|
+
const firstButton = firstItem.focusElement;
|
|
31
|
+
const secondButton = secondItem.focusElement;
|
|
32
|
+
firstButton.click();
|
|
33
|
+
await elementUpdated(el);
|
|
34
|
+
let openItems = el.querySelectorAll("sp-accordion-item[open]");
|
|
35
|
+
expect(openItems.length).to.equal(1);
|
|
36
|
+
secondButton.click();
|
|
37
|
+
await elementUpdated(el);
|
|
38
|
+
openItems = el.querySelectorAll("sp-accordion-item[open]");
|
|
39
|
+
expect(openItems.length).to.equal(1);
|
|
40
|
+
});
|
|
41
|
+
it("allows more than one open item when `[allow-multiple]`", async () => {
|
|
42
|
+
const el = await fixture(Default());
|
|
43
|
+
el.allowMultiple = true;
|
|
44
|
+
await elementUpdated(el);
|
|
45
|
+
const firstItem = el.querySelector(
|
|
46
|
+
"sp-accordion-item:nth-of-type(1)"
|
|
47
|
+
);
|
|
48
|
+
const secondItem = el.querySelector(
|
|
49
|
+
"sp-accordion-item:nth-of-type(2)"
|
|
50
|
+
);
|
|
51
|
+
const firstButton = firstItem.focusElement;
|
|
52
|
+
const secondButton = secondItem.focusElement;
|
|
53
|
+
firstButton.click();
|
|
54
|
+
await elementUpdated(el);
|
|
55
|
+
expect(firstItem.open).to.be.true;
|
|
56
|
+
expect(secondItem.open).to.be.false;
|
|
57
|
+
secondButton.click();
|
|
58
|
+
await elementUpdated(el);
|
|
59
|
+
expect(firstItem.open).to.be.true;
|
|
60
|
+
expect(secondItem.open).to.be.true;
|
|
61
|
+
});
|
|
62
|
+
it("ensures that the correct item is open and that items can be closed", async () => {
|
|
63
|
+
const el = await fixture(Default());
|
|
64
|
+
await elementUpdated(el);
|
|
65
|
+
const firstItem = el.querySelector(
|
|
66
|
+
"sp-accordion-item:nth-of-type(1)"
|
|
67
|
+
);
|
|
68
|
+
const secondItem = el.querySelector(
|
|
69
|
+
"sp-accordion-item:nth-of-type(2)"
|
|
70
|
+
);
|
|
71
|
+
const firstButton = firstItem.focusElement;
|
|
72
|
+
const secondButton = secondItem.focusElement;
|
|
73
|
+
firstButton.click();
|
|
74
|
+
await elementUpdated(el);
|
|
75
|
+
expect(firstItem.open).to.be.true;
|
|
76
|
+
expect(secondItem.open).to.be.false;
|
|
77
|
+
secondButton.click();
|
|
78
|
+
await elementUpdated(el);
|
|
79
|
+
expect(firstItem.open).to.be.false;
|
|
80
|
+
expect(secondItem.open).to.be.true;
|
|
81
|
+
secondButton.click();
|
|
82
|
+
await elementUpdated(el);
|
|
83
|
+
expect(firstItem.open).to.be.false;
|
|
84
|
+
expect(secondItem.open).to.be.false;
|
|
85
|
+
});
|
|
86
|
+
it("ensures that the correct item is open and that items can be closed when [allow-multiple]", async () => {
|
|
87
|
+
const el = await fixture(Default());
|
|
88
|
+
el.allowMultiple = true;
|
|
89
|
+
await elementUpdated(el);
|
|
90
|
+
const firstItem = el.querySelector(
|
|
91
|
+
"sp-accordion-item:nth-of-type(1)"
|
|
92
|
+
);
|
|
93
|
+
const secondItem = el.querySelector(
|
|
94
|
+
"sp-accordion-item:nth-of-type(2)"
|
|
95
|
+
);
|
|
96
|
+
const firstButton = firstItem.focusElement;
|
|
97
|
+
const secondButton = secondItem.focusElement;
|
|
98
|
+
firstButton.click();
|
|
99
|
+
await elementUpdated(el);
|
|
100
|
+
expect(firstItem.open).to.be.true;
|
|
101
|
+
expect(secondItem.open).to.be.false;
|
|
102
|
+
secondButton.click();
|
|
103
|
+
await elementUpdated(el);
|
|
104
|
+
expect(firstItem.open).to.be.true;
|
|
105
|
+
expect(secondItem.open).to.be.true;
|
|
106
|
+
secondButton.click();
|
|
107
|
+
await elementUpdated(el);
|
|
108
|
+
expect(firstItem.open).to.be.true;
|
|
109
|
+
expect(secondItem.open).to.be.false;
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=imperative.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["imperative.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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 { elementUpdated, expect, fixture } from '@open-wc/testing';\n\nimport { Accordion, AccordionItem } from '@spectrum-web-components/accordion';\n\nimport { Default } from '../stories/accordion.stories.js';\nimport { AccordionMarkup } from '../stories/index.js';\n\ndescribe('Accordion - imperative interactions', () => {\n it('manages item size', async () => {\n const el = await fixture<Accordion>(\n AccordionMarkup({\n size: 'l',\n })\n );\n const item = el.querySelector('sp-accordion-item') as AccordionItem;\n expect(el.size).to.equal('l');\n expect(item.size).to.equal('l');\n\n el.size = 's';\n await elementUpdated(el);\n await elementUpdated(item);\n expect(el.size).to.equal('s');\n expect(item.size).to.equal('s');\n });\n it('only allows one open item by default', async () => {\n const el = await fixture<Accordion>(Default());\n await elementUpdated(el);\n const firstItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(1)'\n ) as AccordionItem;\n const secondItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(2)'\n ) as AccordionItem;\n\n const firstButton = firstItem.focusElement;\n const secondButton = secondItem.focusElement;\n\n firstButton.click();\n await elementUpdated(el);\n let openItems = el.querySelectorAll('sp-accordion-item[open]');\n expect(openItems.length).to.equal(1);\n\n secondButton.click();\n await elementUpdated(el);\n openItems = el.querySelectorAll('sp-accordion-item[open]');\n expect(openItems.length).to.equal(1);\n });\n it('allows more than one open item when `[allow-multiple]`', async () => {\n const el = await fixture<Accordion>(Default());\n el.allowMultiple = true;\n await elementUpdated(el);\n\n const firstItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(1)'\n ) as AccordionItem;\n const secondItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(2)'\n ) as AccordionItem;\n\n const firstButton = firstItem.focusElement;\n const secondButton = secondItem.focusElement;\n\n firstButton.click();\n await elementUpdated(el);\n\n expect(firstItem.open).to.be.true;\n expect(secondItem.open).to.be.false;\n\n secondButton.click();\n await elementUpdated(el);\n\n expect(firstItem.open).to.be.true;\n expect(secondItem.open).to.be.true;\n });\n it('ensures that the correct item is open and that items can be closed', async () => {\n const el = await fixture<Accordion>(Default());\n\n await elementUpdated(el);\n const firstItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(1)'\n ) as AccordionItem;\n const secondItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(2)'\n ) as AccordionItem;\n\n const firstButton = firstItem.focusElement;\n const secondButton = secondItem.focusElement;\n\n firstButton.click();\n await elementUpdated(el);\n expect(firstItem.open).to.be.true;\n expect(secondItem.open).to.be.false;\n\n secondButton.click();\n await elementUpdated(el);\n expect(firstItem.open).to.be.false;\n expect(secondItem.open).to.be.true;\n\n secondButton.click();\n await elementUpdated(el);\n expect(firstItem.open).to.be.false;\n expect(secondItem.open).to.be.false;\n });\n it('ensures that the correct item is open and that items can be closed when [allow-multiple]', async () => {\n const el = await fixture<Accordion>(Default());\n el.allowMultiple = true;\n await elementUpdated(el);\n\n const firstItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(1)'\n ) as AccordionItem;\n const secondItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(2)'\n ) as AccordionItem;\n\n const firstButton = firstItem.focusElement;\n const secondButton = secondItem.focusElement;\n\n firstButton.click();\n await elementUpdated(el);\n\n expect(firstItem.open).to.be.true;\n expect(secondItem.open).to.be.false;\n\n secondButton.click();\n await elementUpdated(el);\n\n expect(firstItem.open).to.be.true;\n expect(secondItem.open).to.be.true;\n\n secondButton.click();\n await elementUpdated(el);\n\n expect(firstItem.open).to.be.true;\n expect(secondItem.open).to.be.false;\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { html } from "@spectrum-web-components/base";
|
|
3
|
+
import { elementUpdated, expect, fixture } from "@open-wc/testing";
|
|
4
|
+
import { sendKeys } from "@web/test-runner-commands";
|
|
5
|
+
import { spy } from "sinon";
|
|
6
|
+
import { Accordion, AccordionItem } from "@spectrum-web-components/accordion";
|
|
7
|
+
import "@spectrum-web-components/accordion/sp-accordion.js";
|
|
8
|
+
import "@spectrum-web-components/accordion/sp-accordion-item.js";
|
|
9
|
+
describe("Accordion - keyboard", () => {
|
|
10
|
+
it("does not accept keyboard events when items are not present", async () => {
|
|
11
|
+
const errorSpy = spy();
|
|
12
|
+
const el = await fixture(html`
|
|
13
|
+
<sp-accordion>
|
|
14
|
+
<sp-accordion-item disabled label="Heading 2">
|
|
15
|
+
<div>Item 2</div>
|
|
16
|
+
</sp-accordion-item>
|
|
17
|
+
</sp-accordion>
|
|
18
|
+
`);
|
|
19
|
+
await elementUpdated(el);
|
|
20
|
+
const item = el.querySelector("sp-accordion-item");
|
|
21
|
+
window.addEventListener("error", () => errorSpy());
|
|
22
|
+
el.focus();
|
|
23
|
+
item.remove();
|
|
24
|
+
await elementUpdated(el);
|
|
25
|
+
el.dispatchEvent(
|
|
26
|
+
new KeyboardEvent("keydown", {
|
|
27
|
+
code: "ArrowDown"
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
expect(errorSpy.callCount).to.equal(0);
|
|
31
|
+
});
|
|
32
|
+
it("handles focus and keyboard input and ignores disabled items", async () => {
|
|
33
|
+
var _a;
|
|
34
|
+
const el = await fixture(html`
|
|
35
|
+
<sp-accordion allow-multiple>
|
|
36
|
+
<sp-accordion-item disabled label="Heading 1">
|
|
37
|
+
<div>Item 1</div>
|
|
38
|
+
</sp-accordion-item>
|
|
39
|
+
<sp-accordion-item label="Heading 2">
|
|
40
|
+
<div>Item 2</div>
|
|
41
|
+
</sp-accordion-item>
|
|
42
|
+
<sp-accordion-item label="Heading 3">
|
|
43
|
+
<div>Item 3</div>
|
|
44
|
+
</sp-accordion-item>
|
|
45
|
+
<sp-accordion-item label="Heading 4">
|
|
46
|
+
<div>Item 4</div>
|
|
47
|
+
</sp-accordion-item>
|
|
48
|
+
<sp-accordion-item label="Heading 5">
|
|
49
|
+
<div>Item 5</div>
|
|
50
|
+
</sp-accordion-item>
|
|
51
|
+
<sp-accordion-item disabled label="Heading 6">
|
|
52
|
+
<div>Item 6</div>
|
|
53
|
+
</sp-accordion-item>
|
|
54
|
+
</sp-accordion>
|
|
55
|
+
`);
|
|
56
|
+
await elementUpdated(el);
|
|
57
|
+
const secondItem = el.querySelector(
|
|
58
|
+
"sp-accordion-item:nth-of-type(2)"
|
|
59
|
+
);
|
|
60
|
+
const thirdItem = el.querySelector(
|
|
61
|
+
"sp-accordion-item:nth-of-type(3)"
|
|
62
|
+
);
|
|
63
|
+
const fourthItem = el.querySelector(
|
|
64
|
+
"sp-accordion-item:nth-of-type(4)"
|
|
65
|
+
);
|
|
66
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(
|
|
67
|
+
navigator.userAgent
|
|
68
|
+
);
|
|
69
|
+
const tab = isSafari ? "Alt+Tab" : "Tab";
|
|
70
|
+
const shiftTab = isSafari ? "Alt+Shift+Tab" : "Shift+Tab";
|
|
71
|
+
el.focus();
|
|
72
|
+
await elementUpdated(el);
|
|
73
|
+
expect(
|
|
74
|
+
document.activeElement === secondItem,
|
|
75
|
+
(_a = document.activeElement) == null ? void 0 : _a.localName
|
|
76
|
+
).to.be.true;
|
|
77
|
+
await sendKeys({
|
|
78
|
+
press: tab
|
|
79
|
+
});
|
|
80
|
+
expect(document.activeElement === thirdItem).to.be.true;
|
|
81
|
+
await sendKeys({
|
|
82
|
+
press: tab
|
|
83
|
+
});
|
|
84
|
+
expect(document.activeElement === fourthItem).to.be.true;
|
|
85
|
+
await sendKeys({
|
|
86
|
+
press: shiftTab
|
|
87
|
+
});
|
|
88
|
+
await sendKeys({
|
|
89
|
+
press: shiftTab
|
|
90
|
+
});
|
|
91
|
+
expect(document.activeElement === secondItem).to.be.true;
|
|
92
|
+
document.body.focus();
|
|
93
|
+
el.focus();
|
|
94
|
+
expect(document.activeElement === secondItem).to.be.true;
|
|
95
|
+
await sendKeys({
|
|
96
|
+
press: shiftTab
|
|
97
|
+
});
|
|
98
|
+
await elementUpdated(el);
|
|
99
|
+
const outsideFocused = document.activeElement;
|
|
100
|
+
expect(typeof outsideFocused).not.to.equal(AccordionItem);
|
|
101
|
+
expect(typeof outsideFocused).not.to.equal(Accordion);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe("Accordion Item - keyboard", () => {
|
|
105
|
+
it("dispatches toggle event on enter key", async () => {
|
|
106
|
+
let open = false;
|
|
107
|
+
const onAccordionToggle = () => {
|
|
108
|
+
open = true;
|
|
109
|
+
};
|
|
110
|
+
const el = await fixture(html`
|
|
111
|
+
<sp-accordion-item
|
|
112
|
+
disabled
|
|
113
|
+
@sp-accordion-item-toggle=${onAccordionToggle}
|
|
114
|
+
>
|
|
115
|
+
<div>Item 1</div>
|
|
116
|
+
</sp-accordion-item>
|
|
117
|
+
`);
|
|
118
|
+
await elementUpdated(el);
|
|
119
|
+
expect(open).to.be.false;
|
|
120
|
+
el.focus();
|
|
121
|
+
await sendKeys({
|
|
122
|
+
press: "Enter"
|
|
123
|
+
});
|
|
124
|
+
await elementUpdated(el);
|
|
125
|
+
expect(open).to.be.false;
|
|
126
|
+
el.disabled = false;
|
|
127
|
+
await elementUpdated(el);
|
|
128
|
+
el.focus();
|
|
129
|
+
await sendKeys({
|
|
130
|
+
press: "Enter"
|
|
131
|
+
});
|
|
132
|
+
await elementUpdated(el);
|
|
133
|
+
expect(open).to.be.true;
|
|
134
|
+
});
|
|
135
|
+
it("dispatches toggle event on space key", async () => {
|
|
136
|
+
let open = false;
|
|
137
|
+
const onAccordionToggle = () => {
|
|
138
|
+
open = true;
|
|
139
|
+
};
|
|
140
|
+
const el = await fixture(html`
|
|
141
|
+
<sp-accordion-item
|
|
142
|
+
disabled
|
|
143
|
+
@sp-accordion-item-toggle=${onAccordionToggle}
|
|
144
|
+
>
|
|
145
|
+
<div>Item 1</div>
|
|
146
|
+
</sp-accordion-item>
|
|
147
|
+
`);
|
|
148
|
+
await elementUpdated(el);
|
|
149
|
+
expect(open).to.be.false;
|
|
150
|
+
el.focus();
|
|
151
|
+
await sendKeys({
|
|
152
|
+
press: "Space"
|
|
153
|
+
});
|
|
154
|
+
await elementUpdated(el);
|
|
155
|
+
expect(open).to.be.false;
|
|
156
|
+
el.disabled = false;
|
|
157
|
+
await elementUpdated(el);
|
|
158
|
+
el.focus();
|
|
159
|
+
await sendKeys({
|
|
160
|
+
press: "Space"
|
|
161
|
+
});
|
|
162
|
+
await elementUpdated(el);
|
|
163
|
+
expect(open).to.be.true;
|
|
164
|
+
});
|
|
165
|
+
it("does not dispatch toggle events on key events in Item content", async () => {
|
|
166
|
+
let closed = false;
|
|
167
|
+
const onAccordionToggle = () => {
|
|
168
|
+
closed = true;
|
|
169
|
+
};
|
|
170
|
+
const el = await fixture(html`
|
|
171
|
+
<sp-accordion-item
|
|
172
|
+
open
|
|
173
|
+
@sp-accordion-item-toggle=${onAccordionToggle}
|
|
174
|
+
>
|
|
175
|
+
<div>
|
|
176
|
+
<button>Test Button</button>
|
|
177
|
+
</div>
|
|
178
|
+
</sp-accordion-item>
|
|
179
|
+
`);
|
|
180
|
+
const button = el.querySelector("button");
|
|
181
|
+
await elementUpdated(el);
|
|
182
|
+
expect(el.open).to.be.true;
|
|
183
|
+
expect(closed).to.be.false;
|
|
184
|
+
button.focus();
|
|
185
|
+
await sendKeys({
|
|
186
|
+
press: "Space"
|
|
187
|
+
});
|
|
188
|
+
await elementUpdated(el);
|
|
189
|
+
expect(closed).to.be.false;
|
|
190
|
+
await elementUpdated(el);
|
|
191
|
+
await sendKeys({
|
|
192
|
+
press: "Enter"
|
|
193
|
+
});
|
|
194
|
+
await elementUpdated(el);
|
|
195
|
+
expect(closed).to.be.false;
|
|
196
|
+
expect(el.open).to.be.true;
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
//# sourceMappingURL=keyboard.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["keyboard.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { html } from '@spectrum-web-components/base';\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\nimport { sendKeys } from '@web/test-runner-commands';\nimport { spy } from 'sinon';\n\nimport { Accordion, AccordionItem } from '@spectrum-web-components/accordion';\nimport '@spectrum-web-components/accordion/sp-accordion.js';\nimport '@spectrum-web-components/accordion/sp-accordion-item.js';\n\ndescribe('Accordion - keyboard', () => {\n it('does not accept keyboard events when items are not present', async () => {\n const errorSpy = spy();\n const el = await fixture<Accordion>(html`\n <sp-accordion>\n <sp-accordion-item disabled label=\"Heading 2\">\n <div>Item 2</div>\n </sp-accordion-item>\n </sp-accordion>\n `);\n\n await elementUpdated(el);\n const item = el.querySelector('sp-accordion-item') as AccordionItem;\n window.addEventListener('error', () => errorSpy());\n\n el.focus();\n item.remove();\n await elementUpdated(el);\n el.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'ArrowDown',\n })\n );\n\n expect(errorSpy.callCount).to.equal(0);\n });\n it('handles focus and keyboard input and ignores disabled items', async () => {\n const el = await fixture<Accordion>(html`\n <sp-accordion allow-multiple>\n <sp-accordion-item disabled label=\"Heading 1\">\n <div>Item 1</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 2\">\n <div>Item 2</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 3\">\n <div>Item 3</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 4\">\n <div>Item 4</div>\n </sp-accordion-item>\n <sp-accordion-item label=\"Heading 5\">\n <div>Item 5</div>\n </sp-accordion-item>\n <sp-accordion-item disabled label=\"Heading 6\">\n <div>Item 6</div>\n </sp-accordion-item>\n </sp-accordion>\n `);\n\n await elementUpdated(el);\n\n const secondItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(2)'\n ) as AccordionItem;\n const thirdItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(3)'\n ) as AccordionItem;\n const fourthItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(4)'\n ) as AccordionItem;\n const isSafari = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent\n );\n const tab = isSafari ? 'Alt+Tab' : 'Tab';\n const shiftTab = isSafari ? 'Alt+Shift+Tab' : 'Shift+Tab';\n\n el.focus();\n\n await elementUpdated(el);\n expect(\n document.activeElement === secondItem,\n document.activeElement?.localName\n ).to.be.true;\n\n await sendKeys({\n press: tab,\n });\n\n expect(document.activeElement === thirdItem).to.be.true;\n\n await sendKeys({\n press: tab,\n });\n\n expect(document.activeElement === fourthItem).to.be.true;\n\n await sendKeys({\n press: shiftTab,\n });\n await sendKeys({\n press: shiftTab,\n });\n\n expect(document.activeElement === secondItem).to.be.true;\n\n document.body.focus();\n\n el.focus();\n expect(document.activeElement === secondItem).to.be.true;\n\n await sendKeys({\n press: shiftTab,\n });\n await elementUpdated(el);\n\n const outsideFocused = document.activeElement as HTMLElement;\n\n expect(typeof outsideFocused).not.to.equal(AccordionItem);\n expect(typeof outsideFocused).not.to.equal(Accordion);\n });\n});\n\ndescribe('Accordion Item - keyboard', () => {\n it('dispatches toggle event on enter key', async () => {\n let open = false;\n const onAccordionToggle = (): void => {\n open = true;\n };\n const el = await fixture<AccordionItem>(html`\n <sp-accordion-item\n disabled\n @sp-accordion-item-toggle=${onAccordionToggle}\n >\n <div>Item 1</div>\n </sp-accordion-item>\n `);\n\n await elementUpdated(el);\n\n expect(open).to.be.false;\n\n el.focus();\n await sendKeys({\n press: 'Enter',\n });\n\n await elementUpdated(el);\n\n expect(open).to.be.false;\n\n el.disabled = false;\n await elementUpdated(el);\n\n el.focus();\n await sendKeys({\n press: 'Enter',\n });\n\n await elementUpdated(el);\n\n expect(open).to.be.true;\n });\n it('dispatches toggle event on space key', async () => {\n let open = false;\n const onAccordionToggle = (): void => {\n open = true;\n };\n const el = await fixture<AccordionItem>(html`\n <sp-accordion-item\n disabled\n @sp-accordion-item-toggle=${onAccordionToggle}\n >\n <div>Item 1</div>\n </sp-accordion-item>\n `);\n\n await elementUpdated(el);\n\n expect(open).to.be.false;\n\n el.focus();\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(open).to.be.false;\n\n el.disabled = false;\n await elementUpdated(el);\n\n el.focus();\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(open).to.be.true;\n });\n it('does not dispatch toggle events on key events in Item content', async () => {\n let closed = false;\n const onAccordionToggle = (): void => {\n closed = true;\n };\n const el = await fixture<AccordionItem>(html`\n <sp-accordion-item\n open\n @sp-accordion-item-toggle=${onAccordionToggle}\n >\n <div>\n <button>Test Button</button>\n </div>\n </sp-accordion-item>\n `);\n\n const button = el.querySelector('button') as HTMLButtonElement;\n await elementUpdated(el);\n\n expect(el.open).to.be.true;\n expect(closed).to.be.false;\n\n button.focus();\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(closed).to.be.false;\n\n await elementUpdated(el);\n\n await sendKeys({\n press: 'Enter',\n });\n\n await elementUpdated(el);\n\n expect(closed).to.be.false;\n expect(el.open).to.be.true;\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { Default } from "../stories/accordion.stories.js";
|
|
3
|
+
import { testForMemoryLeaks } from "../../../test/testing-helpers.js";
|
|
4
|
+
describe("Accordion - memory usage", () => {
|
|
5
|
+
testForMemoryLeaks(Default());
|
|
6
|
+
});
|
|
7
|
+
//# sourceMappingURL=memory.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["memory.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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 { Default } from '../stories/accordion.stories.js';\nimport { testForMemoryLeaks } from '../../../test/testing-helpers.js';\n\ndescribe('Accordion - memory usage', () => {\n testForMemoryLeaks(Default());\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,eAAe;AACxB,SAAS,0BAA0B;AAEnC,SAAS,4BAA4B,MAAM;AACvC,qBAAmB,QAAQ,CAAC;AAChC,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|