@vaadin/accordion 24.0.0-alpha5 → 24.0.0-alpha6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,11 +10,11 @@ A web component for displaying a vertically stacked set of expandable panels.
10
10
  ```html
11
11
  <vaadin-accordion>
12
12
  <vaadin-accordion-panel theme="filled">
13
- <div slot="summary">Accordion Panel 1</div>
13
+ <vaadin-accordion-heading slot="summary">Accordion Panel 1</vaadin-accordion-heading>
14
14
  <div>Accordion is a set of expandable sections.</div>
15
15
  </vaadin-accordion-panel>
16
16
  <vaadin-accordion-panel theme="filled">
17
- <div slot="summary">Accordion Panel 2</div>
17
+ <vaadin-accordion-heading slot="summary">Accordion Panel 2</vaadin-accordion-heading>
18
18
  <div>Only one accordion panel can be opened.</div>
19
19
  </vaadin-accordion-panel>
20
20
  </vaadin-accordion>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/accordion",
3
- "version": "24.0.0-alpha5",
3
+ "version": "24.0.0-alpha6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,11 +36,11 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/component-base": "24.0.0-alpha5",
40
- "@vaadin/details": "24.0.0-alpha5",
41
- "@vaadin/vaadin-lumo-styles": "24.0.0-alpha5",
42
- "@vaadin/vaadin-material-styles": "24.0.0-alpha5",
43
- "@vaadin/vaadin-themable-mixin": "24.0.0-alpha5"
39
+ "@vaadin/component-base": "24.0.0-alpha6",
40
+ "@vaadin/details": "24.0.0-alpha6",
41
+ "@vaadin/vaadin-lumo-styles": "24.0.0-alpha6",
42
+ "@vaadin/vaadin-material-styles": "24.0.0-alpha6",
43
+ "@vaadin/vaadin-themable-mixin": "24.0.0-alpha6"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@esm-bundle/chai": "^4.3.4",
@@ -51,5 +51,5 @@
51
51
  "web-types.json",
52
52
  "web-types.lit.json"
53
53
  ],
54
- "gitHead": "fc0b1721eda9e39cb289b239e440fc9e29573a31"
54
+ "gitHead": "0004ac92b6e5f415b5fa949e0582d1d11e527b1f"
55
55
  }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2019 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { ActiveMixin } from '@vaadin/component-base/src/active-mixin.js';
7
+ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
8
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
+
10
+ /**
11
+ * The accordion heading element.
12
+ *
13
+ * `vaadin-accordion-heading` is the element for the headings in the accordion.
14
+ * As recommended by the WAI ARIA Best Practices, each heading needs to wrap a
15
+ * `<button>`. This element puts that button in the Shadow DOM, as it is more
16
+ * convenient to use and doesn’t make styling of the heading more problematic.
17
+ *
18
+ * The WAI ARIA Best Practices also recommend setting `aria-level` depending
19
+ * on what level the headings are. It is hard to determine the level of a heading
20
+ * algorithmically, and setting it is not strictly required to have an accessible
21
+ * accordion. To keep things easier to use, this element does not set `aria-level`
22
+ * attribute but leaves that to the developer creating an accordion.
23
+ *
24
+ * ### Styling
25
+ *
26
+ * The following shadow DOM parts are exposed for styling:
27
+ *
28
+ * Part name | Description
29
+ * -----------|-------------------
30
+ * `toggle` | The icon element
31
+ * `content` | The content wrapper
32
+ *
33
+ * The following state attributes are available for styling:
34
+ *
35
+ * Attribute | Description
36
+ * -------------| -----------
37
+ * `active` | Set when the element is pressed down, either with mouse, touch or the keyboard.
38
+ * `opened` | Set when the collapsible content is expanded and visible.
39
+ * `disabled` | Set when the element is disabled.
40
+ *
41
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
42
+ *
43
+ * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
44
+ */
45
+ declare class AccordionHeading extends ActiveMixin(DirMixin(ThemableMixin(HTMLElement))) {
46
+ /**
47
+ * When true, the element is opened.
48
+ */
49
+ opened: boolean;
50
+ }
51
+
52
+ declare global {
53
+ interface HTMLElementTagNameMap {
54
+ 'vaadin-accordion-heading': AccordionHeading;
55
+ }
56
+ }
57
+
58
+ export { AccordionHeading };
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2019 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
+ import { ActiveMixin } from '@vaadin/component-base/src/active-mixin.js';
8
+ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
+
11
+ /**
12
+ * The accordion heading element.
13
+ *
14
+ * `vaadin-accordion-heading` is the element for the headings in the accordion.
15
+ * As recommended by the WAI ARIA Best Practices, each heading needs to wrap a
16
+ * `<button>`. This element puts that button in the Shadow DOM, as it is more
17
+ * convenient to use and doesn’t make styling of the heading more problematic.
18
+ *
19
+ * The WAI ARIA Best Practices also recommend setting `aria-level` depending
20
+ * on what level the headings are. It is hard to determine the level of a heading
21
+ * algorithmically, and setting it is not strictly required to have an accessible
22
+ * accordion. To keep things easier to use, this element does not set `aria-level`
23
+ * attribute but leaves that to the developer creating an accordion.
24
+ *
25
+ * ### Styling
26
+ *
27
+ * The following shadow DOM parts are exposed for styling:
28
+ *
29
+ * Part name | Description
30
+ * -----------|-------------------
31
+ * `toggle` | The icon element
32
+ * `content` | The content wrapper
33
+ *
34
+ * The following state attributes are available for styling:
35
+ *
36
+ * Attribute | Description
37
+ * -------------| -----------
38
+ * `active` | Set when the element is pressed down, either with mouse, touch or the keyboard.
39
+ * `opened` | Set when the collapsible content is expanded and visible.
40
+ * `disabled` | Set when the element is disabled.
41
+ *
42
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
43
+ *
44
+ * @extends HTMLElement
45
+ * @mixes ActiveMixin
46
+ * @mixes DirMixin
47
+ * @mixes ThemableMixin
48
+ */
49
+ class AccordionHeading extends ActiveMixin(DirMixin(ThemableMixin(PolymerElement))) {
50
+ static get is() {
51
+ return 'vaadin-accordion-heading';
52
+ }
53
+
54
+ static get template() {
55
+ return html`
56
+ <style>
57
+ :host {
58
+ display: block;
59
+ outline: none;
60
+ -webkit-user-select: none;
61
+ -moz-user-select: none;
62
+ user-select: none;
63
+ }
64
+
65
+ :host([hidden]) {
66
+ display: none !important;
67
+ }
68
+
69
+ button {
70
+ display: flex;
71
+ align-items: center;
72
+ width: 100%;
73
+ margin: 0;
74
+ padding: 0;
75
+ background-color: initial;
76
+ color: inherit;
77
+ border: initial;
78
+ outline: none;
79
+ font: inherit;
80
+ text-align: inherit;
81
+ }
82
+ </style>
83
+ <button id="button" part="content" disabled$="[[disabled]]">
84
+ <span part="toggle" aria-hidden="true"></span>
85
+ <slot></slot>
86
+ </button>
87
+ `;
88
+ }
89
+
90
+ static get properties() {
91
+ return {
92
+ /**
93
+ * When true, the element is opened.
94
+ */
95
+ opened: {
96
+ type: Boolean,
97
+ reflectToAttribute: true,
98
+ },
99
+ };
100
+ }
101
+
102
+ /**
103
+ * @param {DocumentFragment} dom
104
+ * @return {null}
105
+ * @protected
106
+ * @override
107
+ */
108
+ _attachDom(dom) {
109
+ const root = this.attachShadow({ mode: 'open', delegatesFocus: true });
110
+ root.appendChild(dom);
111
+ return root;
112
+ }
113
+
114
+ /** @protected */
115
+ ready() {
116
+ super.ready();
117
+
118
+ // By default, if the user hasn't provided a custom role,
119
+ // the role attribute is set to "heading".
120
+ if (!this.hasAttribute('role')) {
121
+ this.setAttribute('role', 'heading');
122
+ }
123
+ }
124
+ }
125
+
126
+ customElements.define(AccordionHeading.is, AccordionHeading);
127
+
128
+ export { AccordionHeading };
@@ -3,7 +3,10 @@
3
3
  * Copyright (c) 2019 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Details } from '@vaadin/details/src/vaadin-details.js';
6
+ import { DetailsMixin } from '@vaadin/details/src/vaadin-details-mixin.js';
7
+ import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
8
+ import { DelegateStateMixin } from '@vaadin/field-base/src/delegate-state-mixin.js';
9
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
7
10
 
8
11
  /**
9
12
  * Fired when the `opened` property changes.
@@ -25,9 +28,6 @@ export type AccordionPanelEventMap = AccordionPanelCustomEventMap & HTMLElementE
25
28
  *
26
29
  * Part name | Description
27
30
  * -----------------|----------------
28
- * `summary` | The element used to open and close collapsible content.
29
- * `toggle` | The element used as indicator, can represent an icon.
30
- * `summary-content`| The wrapper for the slotted summary content.
31
31
  * `content` | The wrapper for the collapsible panel content.
32
32
  *
33
33
  * The following attributes are exposed for styling:
@@ -43,7 +43,7 @@ export type AccordionPanelEventMap = AccordionPanelCustomEventMap & HTMLElementE
43
43
  *
44
44
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
45
45
  */
46
- declare class AccordionPanel extends Details {
46
+ declare class AccordionPanel extends DetailsMixin(DelegateFocusMixin(DelegateStateMixin(ThemableMixin(HTMLElement)))) {
47
47
  addEventListener<K extends keyof AccordionPanelEventMap>(
48
48
  type: K,
49
49
  listener: (this: AccordionPanel, ev: AccordionPanelEventMap[K]) => void,
@@ -3,7 +3,28 @@
3
3
  * Copyright (c) 2019 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Details } from '@vaadin/details/src/vaadin-details.js';
6
+ import './vaadin-accordion-heading.js';
7
+ import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
8
+ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
9
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
10
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
11
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
12
+ import { DetailsMixin } from '@vaadin/details/src/vaadin-details-mixin.js';
13
+ import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
14
+ import { DelegateStateMixin } from '@vaadin/field-base/src/delegate-state-mixin.js';
15
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
16
+
17
+ class SummaryController extends SlotController {
18
+ constructor(host) {
19
+ super(host, 'summary', 'vaadin-accordion-heading', {
20
+ useUniqueId: true,
21
+ initializer: (node, host) => {
22
+ host._setFocusElement(node);
23
+ host.stateTarget = node;
24
+ },
25
+ });
26
+ }
27
+ }
7
28
 
8
29
  /**
9
30
  * The accordion panel element.
@@ -14,9 +35,6 @@ import { Details } from '@vaadin/details/src/vaadin-details.js';
14
35
  *
15
36
  * Part name | Description
16
37
  * -----------------|----------------
17
- * `summary` | The element used to open and close collapsible content.
18
- * `toggle` | The element used as indicator, can represent an icon.
19
- * `summary-content`| The wrapper for the slotted summary content.
20
38
  * `content` | The wrapper for the collapsible panel content.
21
39
  *
22
40
  * The following attributes are exposed for styling:
@@ -32,10 +50,98 @@ import { Details } from '@vaadin/details/src/vaadin-details.js';
32
50
  *
33
51
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
34
52
  */
35
- class AccordionPanel extends Details {
53
+ class AccordionPanel extends DetailsMixin(
54
+ DelegateFocusMixin(DelegateStateMixin(ThemableMixin(ControllerMixin(PolymerElement)))),
55
+ ) {
36
56
  static get is() {
37
57
  return 'vaadin-accordion-panel';
38
58
  }
59
+
60
+ static get template() {
61
+ return html`
62
+ <style>
63
+ :host {
64
+ display: block;
65
+ }
66
+
67
+ :host([hidden]) {
68
+ display: none !important;
69
+ }
70
+
71
+ [part='content'] {
72
+ display: none;
73
+ overflow: hidden;
74
+ }
75
+
76
+ :host([opened]) [part='content'] {
77
+ display: block;
78
+ overflow: visible;
79
+ }
80
+ </style>
81
+
82
+ <slot name="summary"></slot>
83
+
84
+ <div part="content">
85
+ <slot></slot>
86
+ </div>
87
+
88
+ <slot name="tooltip"></slot>
89
+ `;
90
+ }
91
+
92
+ static get properties() {
93
+ return {
94
+ /**
95
+ * A content element.
96
+ *
97
+ * @protected
98
+ */
99
+ _collapsible: {
100
+ type: Object,
101
+ },
102
+ };
103
+ }
104
+
105
+ static get delegateAttrs() {
106
+ return ['theme'];
107
+ }
108
+
109
+ static get delegateProps() {
110
+ return ['disabled', 'opened'];
111
+ }
112
+
113
+ /** @protected */
114
+ ready() {
115
+ super.ready();
116
+
117
+ // TODO: Generate unique IDs for a heading and a content panel when added to the slot,
118
+ // and use them to set `aria-controls` and `aria-labelledby` attributes, respectively.
119
+
120
+ this._collapsible = this.shadowRoot.querySelector('[part="content"]');
121
+ this.addController(new SummaryController(this));
122
+
123
+ this._tooltipController = new TooltipController(this);
124
+ this.addController(this._tooltipController);
125
+
126
+ this._tooltipController.setTarget(this.focusElement);
127
+ this._tooltipController.setPosition('bottom-start');
128
+
129
+ // Wait for heading element render to complete
130
+ afterNextRender(this, () => {
131
+ this._toggleElement = this.focusElement.$.button;
132
+ });
133
+ }
134
+
135
+ /**
136
+ * Override method inherited from `DisabledMixin`
137
+ * to not set `aria-disabled` on the host element.
138
+ *
139
+ * @protected
140
+ * @override
141
+ */
142
+ _setAriaDisabled() {
143
+ // The `aria-disabled` is set on the details summary.
144
+ }
39
145
  }
40
146
 
41
147
  customElements.define(AccordionPanel.is, AccordionPanel);
@@ -41,12 +41,12 @@ export type AccordionEventMap = AccordionCustomEventMap & HTMLElementEventMap;
41
41
  * ```
42
42
  * <vaadin-accordion>
43
43
  * <vaadin-accordion-panel>
44
- * <div slot="summary">Panel 1</div>
45
- * This panel is opened, so the text is visible by default.
44
+ * <vaadin-accordion-heading slot="summary">Panel 1</vaadin-accordion-heading>
45
+ * <div>This panel is opened, so the text is visible by default.</div>
46
46
  * </vaadin-accordion-panel>
47
47
  * <vaadin-accordion-panel>
48
- * <div slot="summary">Panel 2</div>
49
- * After opening this panel, the first one becomes closed.
48
+ * <vaadin-accordion-heading slot="summary">Panel 2</vaadin-accordion-heading>
49
+ * <div>After opening this panel, the first one becomes closed.</div>
50
50
  * </vaadin-accordion-panel>
51
51
  * </vaadin-accordion>
52
52
  * ```
@@ -6,6 +6,7 @@
6
6
  import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
7
7
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
8
8
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
9
+ import { isElementFocused } from '@vaadin/component-base/src/focus-utils.js';
9
10
  import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
10
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
12
  import { AccordionPanel } from './vaadin-accordion-panel.js';
@@ -25,12 +26,12 @@ import { AccordionPanel } from './vaadin-accordion-panel.js';
25
26
  * ```
26
27
  * <vaadin-accordion>
27
28
  * <vaadin-accordion-panel>
28
- * <div slot="summary">Panel 1</div>
29
- * This panel is opened, so the text is visible by default.
29
+ * <vaadin-accordion-heading slot="summary">Panel 1</vaadin-accordion-heading>
30
+ * <div>This panel is opened, so the text is visible by default.</div>
30
31
  * </vaadin-accordion-panel>
31
32
  * <vaadin-accordion-panel>
32
- * <div slot="summary">Panel 2</div>
33
- * After opening this panel, the first one becomes closed.
33
+ * <vaadin-accordion-heading slot="summary">Panel 2</vaadin-accordion-heading>
34
+ * <div>After opening this panel, the first one becomes closed.</div>
34
35
  * </vaadin-accordion-panel>
35
36
  * </vaadin-accordion>
36
37
  * ```
@@ -141,6 +142,18 @@ class Accordion extends KeyboardDirectionMixin(ThemableMixin(ElementMixin(Polyme
141
142
  });
142
143
  }
143
144
 
145
+ /**
146
+ * Override getter from `KeyboardDirectionMixin`
147
+ * to check if the heading element has focus.
148
+ *
149
+ * @return {Element | null}
150
+ * @protected
151
+ * @override
152
+ */
153
+ get focused() {
154
+ return (this._getItems() || []).find((item) => isElementFocused(item._toggleElement));
155
+ }
156
+
144
157
  /**
145
158
  * Override method inherited from `KeyboardDirectionMixin`
146
159
  * to use the stored list of accordion panels as items.
@@ -182,8 +195,9 @@ class Accordion extends KeyboardDirectionMixin(ThemableMixin(ElementMixin(Polyme
182
195
  */
183
196
  _onKeyDown(event) {
184
197
  // Only check keyboard events on details toggle buttons
185
- const item = event.composedPath()[0];
186
- if (!this.items.some((el) => el.focusElement === item)) {
198
+ const target = event.composedPath()[0];
199
+
200
+ if (!this.items.some((item) => item._toggleElement === target)) {
187
201
  return;
188
202
  }
189
203
 
@@ -0,0 +1,14 @@
1
+ import { detailsSummary } from '@vaadin/details/theme/lumo/vaadin-details-summary-styles.js';
2
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
+
4
+ const accordionHeading = css`
5
+ :host {
6
+ padding: 0;
7
+ }
8
+
9
+ [part='content'] {
10
+ padding: var(--lumo-space-s) 0;
11
+ }
12
+ `;
13
+
14
+ registerStyles('vaadin-accordion-heading', [detailsSummary, accordionHeading], { moduleId: 'lumo-accordion-heading' });
@@ -1,2 +1,3 @@
1
+ import './vaadin-accordion-heading-styles.js';
1
2
  import './vaadin-accordion-panel-styles.js';
2
3
  import '../../src/vaadin-accordion-panel.js';
@@ -0,0 +1,44 @@
1
+ import '@vaadin/vaadin-material-styles/color.js';
2
+ import { detailsSummary } from '@vaadin/details/theme/material/vaadin-details-summary-styles.js';
3
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
4
+
5
+ const accordionHeading = css`
6
+ :host(:not([opened]))::after {
7
+ content: '';
8
+ position: absolute;
9
+ bottom: -1px;
10
+ left: 0;
11
+ right: 0;
12
+ height: 1px;
13
+ opacity: 1;
14
+ z-index: 1;
15
+ background-color: var(--material-divider-color);
16
+ }
17
+
18
+ :host([opened])::before {
19
+ opacity: 0;
20
+ }
21
+
22
+ [part='content'] {
23
+ font-weight: normal;
24
+ }
25
+
26
+ [part='content'] ::slotted(*) {
27
+ display: flex;
28
+ margin-right: 16px;
29
+ color: var(--material-body-text-color);
30
+ }
31
+
32
+ [part='content'] ::slotted([theme='primary']) {
33
+ flex-basis: 33.33%;
34
+ flex-shrink: 0;
35
+ }
36
+
37
+ [part='content'] ::slotted([theme='secondary']) {
38
+ color: var(--material-secondary-text-color);
39
+ }
40
+ `;
41
+
42
+ registerStyles('vaadin-accordion-heading', [detailsSummary, accordionHeading], {
43
+ moduleId: 'material-accordion-heading',
44
+ });
@@ -3,22 +3,6 @@ import { details } from '@vaadin/details/theme/material/vaadin-details-styles.js
3
3
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
4
4
 
5
5
  const accordionPanel = css`
6
- :host(:not([opened])) [part='summary']::after {
7
- content: '';
8
- position: absolute;
9
- bottom: -1px;
10
- left: 0;
11
- right: 0;
12
- height: 1px;
13
- opacity: 1;
14
- z-index: 1;
15
- background-color: var(--material-divider-color);
16
- }
17
-
18
- :host([opened]) [part='summary']::before {
19
- opacity: 0;
20
- }
21
-
22
6
  :host([opened]:not(:first-child)) {
23
7
  margin-top: 16px;
24
8
  }
@@ -26,27 +10,6 @@ const accordionPanel = css`
26
10
  :host([opened]:not(:last-child)) {
27
11
  margin-bottom: 16px;
28
12
  }
29
-
30
- [part='summary-content'] {
31
- display: flex;
32
- width: 100%;
33
- font-weight: normal;
34
- }
35
-
36
- [part='summary-content'] ::slotted(*) {
37
- display: flex;
38
- margin-right: 16px;
39
- color: var(--material-body-text-color);
40
- }
41
-
42
- [part='summary-content'] ::slotted([theme='primary']) {
43
- flex-basis: 33.33%;
44
- flex-shrink: 0;
45
- }
46
-
47
- [part='summary-content'] ::slotted([theme='secondary']) {
48
- color: var(--material-secondary-text-color);
49
- }
50
13
  `;
51
14
 
52
15
  registerStyles('vaadin-accordion-panel', [details, accordionPanel], {
@@ -1,2 +1,3 @@
1
+ import './vaadin-accordion-heading-styles.js';
1
2
  import './vaadin-accordion-panel-styles.js';
2
3
  import '../../src/vaadin-accordion-panel.js';
package/web-types.json CHANGED
@@ -1,29 +1,18 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/accordion",
4
- "version": "24.0.0-alpha5",
4
+ "version": "24.0.0-alpha6",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
- "name": "vaadin-accordion-panel",
11
- "description": "The accordion panel element.\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n-----------------|----------------\n`summary` | The element used to open and close collapsible content.\n`toggle` | The element used as indicator, can represent an icon.\n`summary-content`| The wrapper for the slotted summary content.\n`content` | The wrapper for the collapsible panel content.\n\nThe following attributes are exposed for styling:\n\nAttribute | Description\n-------------| -----------\n`opened` | Set when the collapsible content is expanded and visible.\n`disabled` | Set when the element is disabled.\n`focus-ring` | Set when the element is focused using the keyboard.\n`focused` | Set when the element is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
10
+ "name": "vaadin-accordion-heading",
11
+ "description": "The accordion heading element.\n\n`vaadin-accordion-heading` is the element for the headings in the accordion.\nAs recommended by the WAI ARIA Best Practices, each heading needs to wrap a\n`<button>`. This element puts that button in the Shadow DOM, as it is more\nconvenient to use and doesn’t make styling of the heading more problematic.\n\nThe WAI ARIA Best Practices also recommend setting `aria-level` depending\non what level the headings are. It is hard to determine the level of a heading\nalgorithmically, and setting it is not strictly required to have an accessible\naccordion. To keep things easier to use, this element does not set `aria-level`\nattribute but leaves that to the developer creating an accordion.\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n-----------|-------------------\n`toggle` | The icon element\n`content` | The content wrapper\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------| -----------\n`active` | Set when the element is pressed down, either with mouse, touch or the keyboard.\n`opened` | Set when the collapsible content is expanded and visible.\n`disabled` | Set when the element is disabled.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
12
12
  "attributes": [
13
13
  {
14
- "name": "disabled",
15
- "description": "If true, the user cannot interact with this element.",
16
- "value": {
17
- "type": [
18
- "boolean",
19
- "null",
20
- "undefined"
21
- ]
22
- }
23
- },
24
- {
25
- "name": "autofocus",
26
- "description": "Specify that this control should have input focus when the page loads.",
14
+ "name": "opened",
15
+ "description": "When true, the element is opened.",
27
16
  "value": {
28
17
  "type": [
29
18
  "boolean",
@@ -32,15 +21,6 @@
32
21
  ]
33
22
  }
34
23
  },
35
- {
36
- "name": "opened",
37
- "description": "If true, the details content is visible.",
38
- "value": {
39
- "type": [
40
- "boolean"
41
- ]
42
- }
43
- },
44
24
  {
45
25
  "name": "theme",
46
26
  "description": "The theme variants to apply to the component.",
@@ -56,19 +36,8 @@
56
36
  "js": {
57
37
  "properties": [
58
38
  {
59
- "name": "disabled",
60
- "description": "If true, the user cannot interact with this element.",
61
- "value": {
62
- "type": [
63
- "boolean",
64
- "null",
65
- "undefined"
66
- ]
67
- }
68
- },
69
- {
70
- "name": "autofocus",
71
- "description": "Specify that this control should have input focus when the page loads.",
39
+ "name": "opened",
40
+ "description": "When true, the element is opened.",
72
41
  "value": {
73
42
  "type": [
74
43
  "boolean",
@@ -76,28 +45,35 @@
76
45
  "undefined"
77
46
  ]
78
47
  }
79
- },
80
- {
81
- "name": "opened",
82
- "description": "If true, the details content is visible.",
83
- "value": {
84
- "type": [
85
- "boolean"
86
- ]
87
- }
88
48
  }
89
49
  ],
90
- "events": [
91
- {
92
- "name": "opened-changed",
93
- "description": "Fired when the `opened` property changes."
50
+ "events": []
51
+ }
52
+ },
53
+ {
54
+ "name": "vaadin-accordion-panel",
55
+ "description": "The accordion panel element.\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n-----------------|----------------\n`content` | The wrapper for the collapsible panel content.\n\nThe following attributes are exposed for styling:\n\nAttribute | Description\n-------------| -----------\n`opened` | Set when the collapsible content is expanded and visible.\n`disabled` | Set when the element is disabled.\n`focus-ring` | Set when the element is focused using the keyboard.\n`focused` | Set when the element is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
56
+ "attributes": [
57
+ {
58
+ "name": "theme",
59
+ "description": "The theme variants to apply to the component.",
60
+ "value": {
61
+ "type": [
62
+ "string",
63
+ "null",
64
+ "undefined"
65
+ ]
94
66
  }
95
- ]
67
+ }
68
+ ],
69
+ "js": {
70
+ "properties": [],
71
+ "events": []
96
72
  }
97
73
  },
98
74
  {
99
75
  "name": "vaadin-accordion",
100
- "description": "`<vaadin-accordion>` is a Web Component implementing accordion widget —\na vertically stacked set of expandable panels. The component should be\nused as a wrapper for two or more `<vaadin-accordion-panel>` components.\n\nPanel headings function as controls that enable users to open (expand)\nor hide (collapse) their associated sections of content. The user can\ntoggle panels by mouse click, Enter and Space keys.\n\nOnly one panel can be opened at a time, opening a new one forces\nprevious panel to close and hide its content.\n\n```\n<vaadin-accordion>\n <vaadin-accordion-panel>\n <div slot=\"summary\">Panel 1</div>\n This panel is opened, so the text is visible by default.\n </vaadin-accordion-panel>\n <vaadin-accordion-panel>\n <div slot=\"summary\">Panel 2</div>\n After opening this panel, the first one becomes closed.\n </vaadin-accordion-panel>\n</vaadin-accordion>\n```\n\n### Styling\n\nSee the [`<vaadin-accordion-panel>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha5/#/elements/vaadin-accordion-panel)\ndocumentation for the available state attributes and stylable shadow parts.\n\n**Note:** You can apply the theme to `<vaadin-accordion>` component itself,\nespecially by using the following CSS selector:\n\n```\n:host ::slotted(vaadin-accordion-panel) {\n margin-bottom: 5px;\n}\n```\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
76
+ "description": "`<vaadin-accordion>` is a Web Component implementing accordion widget —\na vertically stacked set of expandable panels. The component should be\nused as a wrapper for two or more `<vaadin-accordion-panel>` components.\n\nPanel headings function as controls that enable users to open (expand)\nor hide (collapse) their associated sections of content. The user can\ntoggle panels by mouse click, Enter and Space keys.\n\nOnly one panel can be opened at a time, opening a new one forces\nprevious panel to close and hide its content.\n\n```\n<vaadin-accordion>\n <vaadin-accordion-panel>\n <vaadin-accordion-heading slot=\"summary\">Panel 1</vaadin-accordion-heading>\n <div>This panel is opened, so the text is visible by default.</div>\n </vaadin-accordion-panel>\n <vaadin-accordion-panel>\n <vaadin-accordion-heading slot=\"summary\">Panel 2</vaadin-accordion-heading>\n <div>After opening this panel, the first one becomes closed.</div>\n </vaadin-accordion-panel>\n</vaadin-accordion>\n```\n\n### Styling\n\nSee the [`<vaadin-accordion-panel>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha6/#/elements/vaadin-accordion-panel)\ndocumentation for the available state attributes and stylable shadow parts.\n\n**Note:** You can apply the theme to `<vaadin-accordion>` component itself,\nespecially by using the following CSS selector:\n\n```\n:host ::slotted(vaadin-accordion-panel) {\n margin-bottom: 5px;\n}\n```\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
101
77
  "attributes": [
102
78
  {
103
79
  "name": "opened",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/accordion",
4
- "version": "24.0.0-alpha5",
4
+ "version": "24.0.0-alpha6",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -15,43 +15,28 @@
15
15
  "html": {
16
16
  "elements": [
17
17
  {
18
- "name": "vaadin-accordion-panel",
19
- "description": "The accordion panel element.\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n-----------------|----------------\n`summary` | The element used to open and close collapsible content.\n`toggle` | The element used as indicator, can represent an icon.\n`summary-content`| The wrapper for the slotted summary content.\n`content` | The wrapper for the collapsible panel content.\n\nThe following attributes are exposed for styling:\n\nAttribute | Description\n-------------| -----------\n`opened` | Set when the collapsible content is expanded and visible.\n`disabled` | Set when the element is disabled.\n`focus-ring` | Set when the element is focused using the keyboard.\n`focused` | Set when the element is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
18
+ "name": "vaadin-accordion-heading",
19
+ "description": "The accordion heading element.\n\n`vaadin-accordion-heading` is the element for the headings in the accordion.\nAs recommended by the WAI ARIA Best Practices, each heading needs to wrap a\n`<button>`. This element puts that button in the Shadow DOM, as it is more\nconvenient to use and doesn’t make styling of the heading more problematic.\n\nThe WAI ARIA Best Practices also recommend setting `aria-level` depending\non what level the headings are. It is hard to determine the level of a heading\nalgorithmically, and setting it is not strictly required to have an accessible\naccordion. To keep things easier to use, this element does not set `aria-level`\nattribute but leaves that to the developer creating an accordion.\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n-----------|-------------------\n`toggle` | The icon element\n`content` | The content wrapper\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------| -----------\n`active` | Set when the element is pressed down, either with mouse, touch or the keyboard.\n`opened` | Set when the collapsible content is expanded and visible.\n`disabled` | Set when the element is disabled.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
- {
23
- "name": "?disabled",
24
- "description": "If true, the user cannot interact with this element.",
25
- "value": {
26
- "kind": "expression"
27
- }
28
- },
29
- {
30
- "name": "?autofocus",
31
- "description": "Specify that this control should have input focus when the page loads.",
32
- "value": {
33
- "kind": "expression"
34
- }
35
- },
36
22
  {
37
23
  "name": "?opened",
38
- "description": "If true, the details content is visible.",
39
- "value": {
40
- "kind": "expression"
41
- }
42
- },
43
- {
44
- "name": "@opened-changed",
45
- "description": "Fired when the `opened` property changes.",
24
+ "description": "When true, the element is opened.",
46
25
  "value": {
47
26
  "kind": "expression"
48
27
  }
49
28
  }
50
29
  ]
51
30
  },
31
+ {
32
+ "name": "vaadin-accordion-panel",
33
+ "description": "The accordion panel element.\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n-----------------|----------------\n`content` | The wrapper for the collapsible panel content.\n\nThe following attributes are exposed for styling:\n\nAttribute | Description\n-------------| -----------\n`opened` | Set when the collapsible content is expanded and visible.\n`disabled` | Set when the element is disabled.\n`focus-ring` | Set when the element is focused using the keyboard.\n`focused` | Set when the element is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
34
+ "extension": true,
35
+ "attributes": []
36
+ },
52
37
  {
53
38
  "name": "vaadin-accordion",
54
- "description": "`<vaadin-accordion>` is a Web Component implementing accordion widget —\na vertically stacked set of expandable panels. The component should be\nused as a wrapper for two or more `<vaadin-accordion-panel>` components.\n\nPanel headings function as controls that enable users to open (expand)\nor hide (collapse) their associated sections of content. The user can\ntoggle panels by mouse click, Enter and Space keys.\n\nOnly one panel can be opened at a time, opening a new one forces\nprevious panel to close and hide its content.\n\n```\n<vaadin-accordion>\n <vaadin-accordion-panel>\n <div slot=\"summary\">Panel 1</div>\n This panel is opened, so the text is visible by default.\n </vaadin-accordion-panel>\n <vaadin-accordion-panel>\n <div slot=\"summary\">Panel 2</div>\n After opening this panel, the first one becomes closed.\n </vaadin-accordion-panel>\n</vaadin-accordion>\n```\n\n### Styling\n\nSee the [`<vaadin-accordion-panel>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha5/#/elements/vaadin-accordion-panel)\ndocumentation for the available state attributes and stylable shadow parts.\n\n**Note:** You can apply the theme to `<vaadin-accordion>` component itself,\nespecially by using the following CSS selector:\n\n```\n:host ::slotted(vaadin-accordion-panel) {\n margin-bottom: 5px;\n}\n```\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
39
+ "description": "`<vaadin-accordion>` is a Web Component implementing accordion widget —\na vertically stacked set of expandable panels. The component should be\nused as a wrapper for two or more `<vaadin-accordion-panel>` components.\n\nPanel headings function as controls that enable users to open (expand)\nor hide (collapse) their associated sections of content. The user can\ntoggle panels by mouse click, Enter and Space keys.\n\nOnly one panel can be opened at a time, opening a new one forces\nprevious panel to close and hide its content.\n\n```\n<vaadin-accordion>\n <vaadin-accordion-panel>\n <vaadin-accordion-heading slot=\"summary\">Panel 1</vaadin-accordion-heading>\n <div>This panel is opened, so the text is visible by default.</div>\n </vaadin-accordion-panel>\n <vaadin-accordion-panel>\n <vaadin-accordion-heading slot=\"summary\">Panel 2</vaadin-accordion-heading>\n <div>After opening this panel, the first one becomes closed.</div>\n </vaadin-accordion-panel>\n</vaadin-accordion>\n```\n\n### Styling\n\nSee the [`<vaadin-accordion-panel>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha6/#/elements/vaadin-accordion-panel)\ndocumentation for the available state attributes and stylable shadow parts.\n\n**Note:** You can apply the theme to `<vaadin-accordion>` component itself,\nespecially by using the following CSS selector:\n\n```\n:host ::slotted(vaadin-accordion-panel) {\n margin-bottom: 5px;\n}\n```\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
55
40
  "extension": true,
56
41
  "attributes": [
57
42
  {