@spectrum-web-components/accordion 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -298,7 +298,8 @@
298
298
  "name": "sp-accordion-item-toggle",
299
299
  "type": {
300
300
  "text": "CustomEvent"
301
- }
301
+ },
302
+ "description": "Announce that an accordion item has been toggled while allowing the event to be cancelled."
302
303
  }
303
304
  ],
304
305
  "attributes": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/accordion",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,19 +46,19 @@
46
46
  "lit-html"
47
47
  ],
48
48
  "dependencies": {
49
- "@spectrum-web-components/base": "^0.5.0",
50
- "@spectrum-web-components/icon": "^0.11.0",
51
- "@spectrum-web-components/icons-ui": "^0.8.0",
52
- "@spectrum-web-components/shared": "^0.13.0",
49
+ "@spectrum-web-components/base": "^0.5.1",
50
+ "@spectrum-web-components/icon": "^0.11.1",
51
+ "@spectrum-web-components/icons-ui": "^0.8.1",
52
+ "@spectrum-web-components/shared": "^0.13.1",
53
53
  "tslib": "^2.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@spectrum-css/accordion": "^3.0.5"
56
+ "@spectrum-css/accordion": "^3.0.10"
57
57
  },
58
58
  "types": "./src/index.d.ts",
59
59
  "customElements": "custom-elements.json",
60
60
  "sideEffects": [
61
61
  "./sp-*.js"
62
62
  ],
63
- "gitHead": "7ce77352f6894043bceac9ef92b21e5f85420969"
63
+ "gitHead": "df3f333ee26a45f9fc247716b6e8ef051dca630b"
64
64
  }
@@ -4,6 +4,7 @@ import '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';
4
4
  /**
5
5
  * @element sp-accordion-item
6
6
  * @slot - The content of the item that is hidden when the item is not open
7
+ * @fires sp-accordion-item-toggle - Announce that an accordion item has been toggled while allowing the event to be cancelled.
7
8
  */
8
9
  export declare class AccordionItem extends Focusable {
9
10
  static get styles(): CSSResultArray;
@@ -19,6 +19,7 @@ import styles from './accordion-item.css.js';
19
19
  /**
20
20
  * @element sp-accordion-item
21
21
  * @slot - The content of the item that is hidden when the item is not open
22
+ * @fires sp-accordion-item-toggle - Announce that an accordion item has been toggled while allowing the event to be cancelled.
22
23
  */
23
24
  export class AccordionItem extends Focusable {
24
25
  constructor() {
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionItem.js","sourceRoot":"","sources":["AccordionItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,GAGP,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAC7E,OAAO,+DAA+D,CAAC;AACvE,OAAO,iBAAiB,MAAM,gEAAgE,CAAC;AAE/F,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAE7C;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAkBxC;QACI,KAAK,EAAE,CAAC;QAbL,SAAI,GAAG,KAAK,CAAC;QAGb,UAAK,GAAG,EAAE,CAAC;QAGX,aAAQ,GAAG,KAAK,CAAC;QAQpB,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IApBM,MAAM,KAAK,MAAM;QACpB,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAWD,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAgB,CAAC;IACnE,CAAC;IAOO,SAAS,CAAC,KAAoB;QAClC,sBAAsB;QACtB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,OAAO;SACV;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,K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,EAAE,CAAC;4CACxB;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACnB","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';\nimport chevronIconStyles from '@spectrum-web-components/icon/src/spectrum-icon-chevron.css.js';\n\nimport styles from './accordion-item.css.js';\n\n/**\n * @element sp-accordion-item\n * @slot - The content of the item that is hidden when the item is not open\n */\nexport class AccordionItem extends Focusable {\n public static get styles(): CSSResultArray {\n return [styles, chevronIconStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String, reflect: true })\n public label = '';\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n public get focusElement(): HTMLElement {\n return this.shadowRoot.querySelector('#header') as HTMLElement;\n }\n\n constructor() {\n super();\n this.addEventListener('keydown', this.onKeyDown);\n }\n\n private onKeyDown(event: KeyboardEvent): void {\n /* c8 ignore next 3 */\n if (this.disabled) {\n return;\n }\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n this.toggle();\n }\n }\n\n private onClick(): void {\n /* c8 ignore next 3 */\n if (this.disabled) {\n return;\n }\n this.toggle();\n }\n\n private toggle(): void {\n this.open = !this.open;\n const applyDefault = this.dispatchEvent(\n new CustomEvent('sp-accordion-item-toggle', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.open = !this.open;\n }\n }\n\n protected render(): TemplateResult {\n return html`\n <h3 id=\"heading\">\n <button\n id=\"header\"\n @click=${this.onClick}\n aria-expanded=${this.open}\n aria-controls=\"content\"\n >\n ${this.label}\n </button>\n <sp-icon-chevron100\n id=\"indicator\"\n class=\"spectrum-UIIcon-ChevronRight100\"\n ></sp-icon-chevron100>\n </h3>\n <div id=\"content\" role=\"region\" aria-labelledby=\"header\">\n <slot></slot>\n </div>\n `;\n }\n\n protected updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('disabled')) {\n if (this.disabled) {\n this.setAttribute('aria-disabled', 'true');\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"AccordionItem.js","sourceRoot":"","sources":["AccordionItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,GAGP,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAC7E,OAAO,+DAA+D,CAAC;AACvE,OAAO,iBAAiB,MAAM,gEAAgE,CAAC;AAE/F,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAkBxC;QACI,KAAK,EAAE,CAAC;QAbL,SAAI,GAAG,KAAK,CAAC;QAGb,UAAK,GAAG,EAAE,CAAC;QAGX,aAAQ,GAAG,KAAK,CAAC;QAQpB,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IApBM,MAAM,KAAK,MAAM;QACpB,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACvC,CAAC;IA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IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;aACzC;SACJ;IACL,CAAC;CACJ;AAlFG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACvB;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACxB;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACnB","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';\nimport chevronIconStyles from '@spectrum-web-components/icon/src/spectrum-icon-chevron.css.js';\n\nimport styles from './accordion-item.css.js';\n\n/**\n * @element sp-accordion-item\n * @slot - The content of the item that is hidden when the item is not open\n * @fires sp-accordion-item-toggle - Announce that an accordion item has been toggled while allowing the event to be cancelled.\n */\nexport class AccordionItem extends Focusable {\n public static get styles(): CSSResultArray {\n return [styles, chevronIconStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String, reflect: true })\n public label = '';\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n public get focusElement(): HTMLElement {\n return this.shadowRoot.querySelector('#header') as HTMLElement;\n }\n\n constructor() {\n super();\n this.addEventListener('keydown', this.onKeyDown);\n }\n\n private onKeyDown(event: KeyboardEvent): void {\n /* c8 ignore next 3 */\n if (this.disabled) {\n return;\n }\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n this.toggle();\n }\n }\n\n private onClick(): void {\n /* c8 ignore next 3 */\n if (this.disabled) {\n return;\n }\n this.toggle();\n }\n\n private toggle(): void {\n this.open = !this.open;\n const applyDefault = this.dispatchEvent(\n new CustomEvent('sp-accordion-item-toggle', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.open = !this.open;\n }\n }\n\n protected render(): TemplateResult {\n return html`\n <h3 id=\"heading\">\n <button\n id=\"header\"\n @click=${this.onClick}\n aria-expanded=${this.open}\n aria-controls=\"content\"\n >\n ${this.label}\n </button>\n <sp-icon-chevron100\n id=\"indicator\"\n class=\"spectrum-UIIcon-ChevronRight100\"\n ></sp-icon-chevron100>\n </h3>\n <div id=\"content\" role=\"region\" aria-labelledby=\"header\">\n <slot></slot>\n </div>\n `;\n }\n\n protected updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('disabled')) {\n if (this.disabled) {\n this.setAttribute('aria-disabled', 'true');\n } else {\n this.removeAttribute('aria-disabled');\n }\n }\n }\n}\n"]}
@@ -1,99 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
13
- import { spy } from 'sinon';
14
- import '../sp-accordion-item.js';
15
- import { enterEvent, spaceEvent } from '../../../test/testing-helpers.js';
16
- describe('Accordion Item', () => {
17
- it('can exist with no parent accessibly', async () => {
18
- const el = await fixture(html `
19
- <sp-accordion-item label="item">
20
- <div>Item 1</div>
21
- </sp-accordion-item>
22
- `);
23
- await elementUpdated(el);
24
- await expect(el).to.be.accessible();
25
- });
26
- it('can be `[disabled]`', async () => {
27
- const toggleSpy = spy();
28
- const handleToggle = () => toggleSpy();
29
- const el = await fixture(html `
30
- <sp-accordion-item
31
- disabled
32
- @sp-accordion-item-toggle=${handleToggle}
33
- >
34
- <div>Item 1</div>
35
- </sp-accordion-item>
36
- `);
37
- const root = el.shadowRoot;
38
- const button = root.querySelector('#header');
39
- await elementUpdated(el);
40
- expect(toggleSpy.callCount).to.equal(0);
41
- button.click();
42
- await elementUpdated(el);
43
- expect(toggleSpy.callCount).to.equal(0);
44
- el.disabled = false;
45
- await elementUpdated(el);
46
- button.click();
47
- await elementUpdated(el);
48
- expect(toggleSpy.callCount).to.equal(1);
49
- });
50
- it('dispatches toggle event on enter key', async () => {
51
- let open = false;
52
- const onAccordionToggle = () => {
53
- open = true;
54
- };
55
- const el = await fixture(html `
56
- <sp-accordion-item
57
- disabled
58
- @sp-accordion-item-toggle=${onAccordionToggle}
59
- >
60
- <div>Item 1</div>
61
- </sp-accordion-item>
62
- `);
63
- await elementUpdated(el);
64
- expect(open).to.be.false;
65
- el.dispatchEvent(enterEvent);
66
- await elementUpdated(el);
67
- expect(open).to.be.false;
68
- el.disabled = false;
69
- await elementUpdated(el);
70
- el.dispatchEvent(enterEvent);
71
- await elementUpdated(el);
72
- expect(open).to.be.true;
73
- });
74
- it('dispatches toggle event on space key', async () => {
75
- let open = false;
76
- const onAccordionToggle = () => {
77
- open = true;
78
- };
79
- const el = await fixture(html `
80
- <sp-accordion-item
81
- disabled
82
- @sp-accordion-item-toggle=${onAccordionToggle}
83
- >
84
- <div>Item 1</div>
85
- </sp-accordion-item>
86
- `);
87
- await elementUpdated(el);
88
- expect(open).to.be.false;
89
- el.dispatchEvent(spaceEvent);
90
- await elementUpdated(el);
91
- expect(open).to.be.false;
92
- el.disabled = false;
93
- await elementUpdated(el);
94
- el.dispatchEvent(spaceEvent);
95
- await elementUpdated(el);
96
- expect(open).to.be.true;
97
- });
98
- });
99
- //# sourceMappingURL=accordion-item.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accordion-item.test.js","sourceRoot":"","sources":["accordion-item.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE1E,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA;;;;aAIH,CACJ,CAAC;QAEF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACjC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC;QACxB,MAAM,YAAY,GAAG,GAAS,EAAE,CAAC,SAAS,EAAE,CAAC;QAC7C,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA;;;gDAGgC,YAAY;;;;aAI/C,CACJ,CAAC;QAEF,MAAM,IAAI,GAAG,EAAE,CAAC,UAAwB,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAgB,CAAC;QAE5D,MAAM,cA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CAAC,UAAU,CAAC,CAAC;QAE7B,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QAClD,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,MAAM,iBAAiB,GAAG,GAAS,EAAE;YACjC,IAAI,GAAG,IAAI,CAAC;QAChB,CAAC,CAAC;QACF,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA;;;gDAGgC,iBAAiB;;;;aAIpD,CACJ,CAAC;QAEF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAEzB,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAE7B,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAEzB,EAAE,CAAC,QAAQ,GAAG,KAAK,CAAC;QACpB,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAE7B,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\nimport { spy } from 'sinon';\n\nimport '../sp-accordion-item.js';\nimport { AccordionItem } from '../src/AccordionItem';\nimport { enterEvent, spaceEvent } from '../../../test/testing-helpers.js';\n\ndescribe('Accordion Item', () => {\n it('can exist with no parent accessibly', async () => {\n const el = await fixture<AccordionItem>(\n html`\n <sp-accordion-item label=\"item\">\n <div>Item 1</div>\n </sp-accordion-item>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('can be `[disabled]`', async () => {\n const toggleSpy = spy();\n const handleToggle = (): void => toggleSpy();\n const el = await fixture<AccordionItem>(\n 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\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 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>(\n 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\n await elementUpdated(el);\n\n expect(open).to.be.false;\n\n el.dispatchEvent(enterEvent);\n\n await elementUpdated(el);\n\n expect(open).to.be.false;\n\n el.disabled = false;\n await elementUpdated(el);\n\n el.dispatchEvent(enterEvent);\n\n await elementUpdated(el);\n\n expect(open).to.be.true;\n });\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>(\n 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\n await elementUpdated(el);\n\n expect(open).to.be.false;\n\n el.dispatchEvent(spaceEvent);\n\n await elementUpdated(el);\n\n expect(open).to.be.false;\n\n el.disabled = false;\n await elementUpdated(el);\n\n el.dispatchEvent(spaceEvent);\n\n await elementUpdated(el);\n\n expect(open).to.be.true;\n });\n});\n"]}
@@ -1,15 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import * as stories from '../stories/accordion.stories.js';
13
- import { regressVisuals } from '../../../test/visual/test.js';
14
- regressVisuals('AccordionStories', stories);
15
- //# sourceMappingURL=accordion.test-vrt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accordion.test-vrt.js","sourceRoot":"","sources":["accordion.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/accordion.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('AccordionStories', stories);\n"]}
@@ -1,209 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
13
- import '../sp-accordion.js';
14
- import { Default } from '../stories/accordion.stories.js';
15
- import { Accordion, AccordionItem } from '@spectrum-web-components/accordion';
16
- import { arrowDownEvent, arrowUpEvent, shiftTabEvent, } from '../../../test/testing-helpers.js';
17
- import { spy } from 'sinon';
18
- describe('Accordion', () => {
19
- it('renders with items accessibly', async () => {
20
- const el = await fixture(Default());
21
- await elementUpdated(el);
22
- await expect(el).to.be.accessible();
23
- });
24
- it('does not accept focus when empty', async () => {
25
- const el = await fixture(html `
26
- <sp-accordion></sp-accordion>
27
- `);
28
- await elementUpdated(el);
29
- expect(document.activeElement === el).to.be.false;
30
- el.focus();
31
- await elementUpdated(el);
32
- expect(document.activeElement === el).to.be.false;
33
- });
34
- it('does not accept keyboard events when items are not present', async () => {
35
- const errorSpy = spy();
36
- const el = await fixture(html `
37
- <sp-accordion>
38
- <sp-accordion-item disabled label="Heading 2">
39
- <div>Item 2</div>
40
- </sp-accordion-item>
41
- </sp-accordion>
42
- `);
43
- await elementUpdated(el);
44
- const item = el.querySelector('sp-accordion-item');
45
- window.addEventListener('error', () => errorSpy());
46
- el.dispatchEvent(new FocusEvent('focusin'));
47
- item.remove();
48
- el.dispatchEvent(new KeyboardEvent('keydown', {
49
- code: 'ArrowDown',
50
- }));
51
- expect(errorSpy.callCount).to.equal(0);
52
- });
53
- it('does not accept focus when all children [disabled]', async () => {
54
- const el = await fixture(html `
55
- <sp-accordion>
56
- <sp-accordion-item disabled label="Heading 1">
57
- <div>Item 1</div>
58
- </sp-accordion-item>
59
- <sp-accordion-item disabled label="Heading 2">
60
- <div>Item 2</div>
61
- </sp-accordion-item>
62
- </sp-accordion>
63
- `);
64
- await elementUpdated(el);
65
- expect(document.activeElement === el).to.be.false;
66
- el.focus();
67
- await elementUpdated(el);
68
- expect(document.activeElement === el).to.be.false;
69
- });
70
- it('only allows one open item by default', async () => {
71
- const el = await fixture(Default());
72
- await elementUpdated(el);
73
- const firstItem = el.querySelector('sp-accordion-item:nth-of-type(1)');
74
- const secondItem = el.querySelector('sp-accordion-item:nth-of-type(2)');
75
- const firstButton = firstItem.focusElement;
76
- const secondButton = secondItem.focusElement;
77
- firstButton.click();
78
- await elementUpdated(el);
79
- let openItems = el.querySelectorAll('sp-accordion-item[open]');
80
- expect(openItems.length).to.equal(1);
81
- secondButton.click();
82
- await elementUpdated(el);
83
- openItems = el.querySelectorAll('sp-accordion-item[open]');
84
- expect(openItems.length).to.equal(1);
85
- });
86
- it('can have `toggle` events canceled', async () => {
87
- const el = await fixture(Default());
88
- await elementUpdated(el);
89
- const firstItem = el.querySelector('sp-accordion-item:nth-of-type(1)');
90
- const secondItem = el.querySelector('sp-accordion-item:nth-of-type(2)');
91
- const firstButton = firstItem.focusElement;
92
- const secondButton = secondItem.focusElement;
93
- firstButton.click();
94
- await elementUpdated(el);
95
- expect(firstItem.open).to.be.true;
96
- expect(secondItem.open).to.be.false;
97
- el.addEventListener('sp-accordion-item-toggle', (event) => event.preventDefault());
98
- secondButton.click();
99
- await elementUpdated(el);
100
- expect(firstItem.open).to.be.true;
101
- expect(secondItem.open).to.be.false;
102
- });
103
- it('allows more than one open item when `[allow-multiple]`', async () => {
104
- const el = await fixture(Default());
105
- el.allowMultiple = true;
106
- await elementUpdated(el);
107
- const firstItem = el.querySelector('sp-accordion-item:nth-of-type(1)');
108
- const secondItem = el.querySelector('sp-accordion-item:nth-of-type(2)');
109
- const firstButton = firstItem.focusElement;
110
- const secondButton = secondItem.focusElement;
111
- firstButton.click();
112
- await elementUpdated(el);
113
- expect(firstItem.open).to.be.true;
114
- expect(secondItem.open).to.be.false;
115
- secondButton.click();
116
- await elementUpdated(el);
117
- expect(firstItem.open).to.be.true;
118
- expect(secondItem.open).to.be.true;
119
- });
120
- it('ensures that the correct item is open and that items can be closed', async () => {
121
- const el = await fixture(Default());
122
- await elementUpdated(el);
123
- const firstItem = el.querySelector('sp-accordion-item:nth-of-type(1)');
124
- const secondItem = el.querySelector('sp-accordion-item:nth-of-type(2)');
125
- const firstButton = firstItem.focusElement;
126
- const secondButton = secondItem.focusElement;
127
- firstButton.click();
128
- await elementUpdated(el);
129
- expect(firstItem.open).to.be.true;
130
- expect(secondItem.open).to.be.false;
131
- secondButton.click();
132
- await elementUpdated(el);
133
- expect(firstItem.open).to.be.false;
134
- expect(secondItem.open).to.be.true;
135
- secondButton.click();
136
- await elementUpdated(el);
137
- expect(firstItem.open).to.be.false;
138
- expect(secondItem.open).to.be.false;
139
- });
140
- it('ensures that the correct item is open and that items can be closed when [allow-multiple]', async () => {
141
- const el = await fixture(Default());
142
- el.allowMultiple = true;
143
- await elementUpdated(el);
144
- const firstItem = el.querySelector('sp-accordion-item:nth-of-type(1)');
145
- const secondItem = el.querySelector('sp-accordion-item:nth-of-type(2)');
146
- const firstButton = firstItem.focusElement;
147
- const secondButton = secondItem.focusElement;
148
- firstButton.click();
149
- await elementUpdated(el);
150
- expect(firstItem.open).to.be.true;
151
- expect(secondItem.open).to.be.false;
152
- secondButton.click();
153
- await elementUpdated(el);
154
- expect(firstItem.open).to.be.true;
155
- expect(secondItem.open).to.be.true;
156
- secondButton.click();
157
- await elementUpdated(el);
158
- expect(firstItem.open).to.be.true;
159
- expect(secondItem.open).to.be.false;
160
- });
161
- it('handles focus and keyboard input and ignores disabled items', async () => {
162
- const el = await fixture(html `
163
- <sp-accordion allow-multiple>
164
- <sp-accordion-item disabled label="Heading 1">
165
- <div>Item 1</div>
166
- </sp-accordion-item>
167
- <sp-accordion-item label="Heading 2">
168
- <div>Item 2</div>
169
- </sp-accordion-item>
170
- <sp-accordion-item label="Heading 3">
171
- <div>Item 3</div>
172
- </sp-accordion-item>
173
- <sp-accordion-item label="Heading 4">
174
- <div>Item 4</div>
175
- </sp-accordion-item>
176
- <sp-accordion-item label="Heading 5">
177
- <div>Item 5</div>
178
- </sp-accordion-item>
179
- <sp-accordion-item disabled label="Heading 6">
180
- <div>Item 6</div>
181
- </sp-accordion-item>
182
- </sp-accordion>
183
- `);
184
- await elementUpdated(el);
185
- const secondItem = el.querySelector('sp-accordion-item:nth-of-type(2)');
186
- const thirdToLastItem = el.querySelector('sp-accordion-item:nth-last-of-type(3)');
187
- const secondToLastItem = el.querySelector('sp-accordion-item:nth-last-of-type(2)');
188
- el.focus();
189
- await elementUpdated(el);
190
- expect(document.activeElement === secondItem).to.be.true;
191
- el.dispatchEvent(arrowUpEvent);
192
- el.dispatchEvent(arrowUpEvent);
193
- expect(document.activeElement === thirdToLastItem).to.be.true;
194
- el.dispatchEvent(arrowDownEvent);
195
- expect(document.activeElement === secondToLastItem).to.be.true;
196
- el.dispatchEvent(arrowDownEvent);
197
- expect(document.activeElement === secondItem).to.be.true;
198
- document.body.focus();
199
- el.focus();
200
- const focused = el.focusElement;
201
- expect(document.activeElement === focused).to.be.true;
202
- focused.dispatchEvent(shiftTabEvent);
203
- await elementUpdated(el);
204
- const outsideFocused = document.activeElement;
205
- expect(typeof outsideFocused).not.to.equal(AccordionItem);
206
- expect(typeof outsideFocused).not.to.equal(Accordion);
207
- });
208
- });
209
- //# sourceMappingURL=accordion.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acc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jC,MAAM,CAAC,QAAQ,CAAC,aAAa,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAEzD,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAEtB,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,OAAO,GAAG,EAAE,CAAC,YAA6B,CAAC;QACjD,MAAM,CAAC,QAAQ,CAAC,aAAa,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAEtD,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACrC,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,cAAc,GAAG,QAAQ,CAAC,aAA4B,CAAC;QAE7D,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC1D,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nimport '../sp-accordion.js';\nimport { Default } from '../stories/accordion.stories.js';\nimport { Accordion, AccordionItem } from '@spectrum-web-components/accordion';\nimport {\n arrowDownEvent,\n arrowUpEvent,\n shiftTabEvent,\n} from '../../../test/testing-helpers.js';\nimport { spy } from 'sinon';\n\ndescribe('Accordion', () => {\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 it('does not accept focus when empty', async () => {\n const el = await fixture<Accordion>(\n html`\n <sp-accordion></sp-accordion>\n `\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 keyboard events when items are not present', async () => {\n const errorSpy = spy();\n const el = await fixture<Accordion>(\n 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\n await elementUpdated(el);\n const item = el.querySelector('sp-accordion-item') as AccordionItem;\n window.addEventListener('error', () => errorSpy());\n\n el.dispatchEvent(new FocusEvent('focusin'));\n item.remove();\n el.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'ArrowDown',\n })\n );\n\n expect(errorSpy.callCount).to.equal(0);\n });\n it('does not accept focus when all children [disabled]', async () => {\n const el = await fixture<Accordion>(\n 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\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('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('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 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\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 it('handles focus and keyboard input and ignores disabled items', async () => {\n const el = await fixture<Accordion>(\n 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\n await elementUpdated(el);\n\n const secondItem = el.querySelector(\n 'sp-accordion-item:nth-of-type(2)'\n ) as AccordionItem;\n const thirdToLastItem = el.querySelector(\n 'sp-accordion-item:nth-last-of-type(3)'\n ) as AccordionItem;\n const secondToLastItem = el.querySelector(\n 'sp-accordion-item:nth-last-of-type(2)'\n ) as AccordionItem;\n\n el.focus();\n\n await elementUpdated(el);\n expect(document.activeElement === secondItem).to.be.true;\n\n el.dispatchEvent(arrowUpEvent);\n el.dispatchEvent(arrowUpEvent);\n\n expect(document.activeElement === thirdToLastItem).to.be.true;\n\n el.dispatchEvent(arrowDownEvent);\n\n expect(document.activeElement === secondToLastItem).to.be.true;\n\n el.dispatchEvent(arrowDownEvent);\n expect(document.activeElement === secondItem).to.be.true;\n\n document.body.focus();\n\n el.focus();\n const focused = el.focusElement as AccordionItem;\n expect(document.activeElement === focused).to.be.true;\n\n focused.dispatchEvent(shiftTabEvent);\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"]}