@vaadin/accordion 24.0.0-alpha6 → 24.0.0-alpha7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/vaadin-accordion-panel.js +68 -19
- package/web-types.json +40 -2
- package/web-types.lit.json +30 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/accordion",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha7",
|
|
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-
|
|
40
|
-
"@vaadin/details": "24.0.0-
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
42
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
39
|
+
"@vaadin/component-base": "24.0.0-alpha7",
|
|
40
|
+
"@vaadin/details": "24.0.0-alpha7",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha7",
|
|
42
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha7",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha7"
|
|
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": "
|
|
54
|
+
"gitHead": "aeb4535336813636736759e0a5de148b26bfc3b6"
|
|
55
55
|
}
|
|
@@ -7,17 +7,16 @@ import './vaadin-accordion-heading.js';
|
|
|
7
7
|
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
8
8
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
9
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
10
|
-
import {
|
|
10
|
+
import { SlotObserveController } from '@vaadin/component-base/src/slot-observe-controller.js';
|
|
11
11
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
12
12
|
import { DetailsMixin } from '@vaadin/details/src/vaadin-details-mixin.js';
|
|
13
13
|
import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
|
|
14
14
|
import { DelegateStateMixin } from '@vaadin/field-base/src/delegate-state-mixin.js';
|
|
15
15
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
16
16
|
|
|
17
|
-
class SummaryController extends
|
|
17
|
+
class SummaryController extends SlotObserveController {
|
|
18
18
|
constructor(host) {
|
|
19
19
|
super(host, 'summary', 'vaadin-accordion-heading', {
|
|
20
|
-
useUniqueId: true,
|
|
21
20
|
initializer: (node, host) => {
|
|
22
21
|
host._setFocusElement(node);
|
|
23
22
|
host.stateTarget = node;
|
|
@@ -26,6 +25,25 @@ class SummaryController extends SlotController {
|
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
class ContentController extends SlotObserveController {
|
|
29
|
+
/**
|
|
30
|
+
* Override method from `SlotController` to change
|
|
31
|
+
* the ID prefix for the default slot content.
|
|
32
|
+
*
|
|
33
|
+
* @param {HTMLElement} host
|
|
34
|
+
* @return {string}
|
|
35
|
+
* @protected
|
|
36
|
+
* @override
|
|
37
|
+
*/
|
|
38
|
+
static generateId(host) {
|
|
39
|
+
return super.generateId(host, 'content');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
constructor(host) {
|
|
43
|
+
super(host, '', null, { multiple: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
29
47
|
/**
|
|
30
48
|
* The accordion panel element.
|
|
31
49
|
*
|
|
@@ -114,22 +132,9 @@ class AccordionPanel extends DetailsMixin(
|
|
|
114
132
|
ready() {
|
|
115
133
|
super.ready();
|
|
116
134
|
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
});
|
|
135
|
+
this._initSummary();
|
|
136
|
+
this._initContent();
|
|
137
|
+
this._initTooltip();
|
|
133
138
|
}
|
|
134
139
|
|
|
135
140
|
/**
|
|
@@ -142,6 +147,50 @@ class AccordionPanel extends DetailsMixin(
|
|
|
142
147
|
_setAriaDisabled() {
|
|
143
148
|
// The `aria-disabled` is set on the details summary.
|
|
144
149
|
}
|
|
150
|
+
|
|
151
|
+
/** @private */
|
|
152
|
+
_initSummary() {
|
|
153
|
+
this._summaryController = new SummaryController(this);
|
|
154
|
+
this.addController(this._summaryController);
|
|
155
|
+
|
|
156
|
+
// Wait for heading element render to complete
|
|
157
|
+
afterNextRender(this, () => {
|
|
158
|
+
this._toggleElement = this.focusElement.$.button;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** @private */
|
|
163
|
+
_initContent() {
|
|
164
|
+
this._contentController = new ContentController(this);
|
|
165
|
+
this._contentController.addEventListener('slot-content-changed', (event) => {
|
|
166
|
+
// Store nodes to toggle `aria-hidden` attribute
|
|
167
|
+
const content = event.target.nodes || [];
|
|
168
|
+
this._contentElements = content;
|
|
169
|
+
|
|
170
|
+
// See https://www.w3.org/WAI/ARIA/apg/patterns/accordion/
|
|
171
|
+
const node = content[0];
|
|
172
|
+
if (node) {
|
|
173
|
+
node.setAttribute('role', 'region');
|
|
174
|
+
node.setAttribute('aria-labelledby', this.focusElement.id);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (node && node.parentNode === this && node.id) {
|
|
178
|
+
this.focusElement.setAttribute('aria-controls', node.id);
|
|
179
|
+
} else {
|
|
180
|
+
this.focusElement.removeAttribute('aria-controls');
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
this.addController(this._contentController);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** @private */
|
|
187
|
+
_initTooltip() {
|
|
188
|
+
this._tooltipController = new TooltipController(this);
|
|
189
|
+
this.addController(this._tooltipController);
|
|
190
|
+
|
|
191
|
+
this._tooltipController.setTarget(this.focusElement);
|
|
192
|
+
this._tooltipController.setPosition('bottom-start');
|
|
193
|
+
}
|
|
145
194
|
}
|
|
146
195
|
|
|
147
196
|
customElements.define(AccordionPanel.is, AccordionPanel);
|
package/web-types.json
CHANGED
|
@@ -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-
|
|
4
|
+
"version": "24.0.0-alpha7",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"name": "vaadin-accordion",
|
|
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-
|
|
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-alpha7/#/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.",
|
|
77
77
|
"attributes": [
|
|
78
78
|
{
|
|
79
79
|
"name": "opened",
|
|
@@ -98,6 +98,44 @@
|
|
|
98
98
|
],
|
|
99
99
|
"js": {
|
|
100
100
|
"properties": [
|
|
101
|
+
{
|
|
102
|
+
"name": "rootPath",
|
|
103
|
+
"description": "",
|
|
104
|
+
"value": {
|
|
105
|
+
"type": [
|
|
106
|
+
"string"
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "importPath",
|
|
112
|
+
"description": "",
|
|
113
|
+
"value": {
|
|
114
|
+
"type": [
|
|
115
|
+
"string"
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "root",
|
|
121
|
+
"description": "",
|
|
122
|
+
"value": {
|
|
123
|
+
"type": [
|
|
124
|
+
"StampedTemplate",
|
|
125
|
+
"HTMLElement",
|
|
126
|
+
"ShadowRoot"
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "$",
|
|
132
|
+
"description": "",
|
|
133
|
+
"value": {
|
|
134
|
+
"type": [
|
|
135
|
+
"Object.<string, Element>"
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
},
|
|
101
139
|
{
|
|
102
140
|
"name": "opened",
|
|
103
141
|
"description": "The index of currently opened panel. First panel is opened by\ndefault. Only one panel can be opened at the same time.\nSetting null or undefined closes all the accordion panels.",
|
package/web-types.lit.json
CHANGED
|
@@ -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-
|
|
4
|
+
"version": "24.0.0-alpha7",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -36,9 +36,37 @@
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"name": "vaadin-accordion",
|
|
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-
|
|
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-alpha7/#/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.",
|
|
40
40
|
"extension": true,
|
|
41
41
|
"attributes": [
|
|
42
|
+
{
|
|
43
|
+
"name": ".rootPath",
|
|
44
|
+
"description": "",
|
|
45
|
+
"value": {
|
|
46
|
+
"kind": "expression"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": ".importPath",
|
|
51
|
+
"description": "",
|
|
52
|
+
"value": {
|
|
53
|
+
"kind": "expression"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": ".root",
|
|
58
|
+
"description": "",
|
|
59
|
+
"value": {
|
|
60
|
+
"kind": "expression"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": ".$",
|
|
65
|
+
"description": "",
|
|
66
|
+
"value": {
|
|
67
|
+
"kind": "expression"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
42
70
|
{
|
|
43
71
|
"name": ".opened",
|
|
44
72
|
"description": "The index of currently opened panel. First panel is opened by\ndefault. Only one panel can be opened at the same time.\nSetting null or undefined closes all the accordion panels.",
|