@vaadin/details 24.2.0-alpha1 → 24.2.0-alpha10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/details",
3
- "version": "24.2.0-alpha1",
3
+ "version": "24.2.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,6 +21,10 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
+ "!src/vaadin-lit-details-summary.d.ts",
25
+ "!src/vaadin-lit-details-summary.js",
26
+ "!src/vaadin-lit-details.d.ts",
27
+ "!src/vaadin-lit-details.js",
24
28
  "theme",
25
29
  "vaadin-*.d.ts",
26
30
  "vaadin-*.js",
@@ -37,21 +41,21 @@
37
41
  "dependencies": {
38
42
  "@open-wc/dedupe-mixin": "^1.3.0",
39
43
  "@polymer/polymer": "^3.0.0",
40
- "@vaadin/a11y-base": "24.2.0-alpha1",
41
- "@vaadin/button": "24.2.0-alpha1",
42
- "@vaadin/component-base": "24.2.0-alpha1",
43
- "@vaadin/vaadin-lumo-styles": "24.2.0-alpha1",
44
- "@vaadin/vaadin-material-styles": "24.2.0-alpha1",
45
- "@vaadin/vaadin-themable-mixin": "24.2.0-alpha1"
44
+ "@vaadin/a11y-base": "24.2.0-alpha10",
45
+ "@vaadin/button": "24.2.0-alpha10",
46
+ "@vaadin/component-base": "24.2.0-alpha10",
47
+ "@vaadin/vaadin-lumo-styles": "24.2.0-alpha10",
48
+ "@vaadin/vaadin-material-styles": "24.2.0-alpha10",
49
+ "@vaadin/vaadin-themable-mixin": "24.2.0-alpha10"
46
50
  },
47
51
  "devDependencies": {
48
52
  "@esm-bundle/chai": "^4.3.4",
49
- "@vaadin/testing-helpers": "^0.4.2",
53
+ "@vaadin/testing-helpers": "^0.5.0",
50
54
  "sinon": "^13.0.2"
51
55
  },
52
56
  "web-types": [
53
57
  "web-types.json",
54
58
  "web-types.lit.json"
55
59
  ],
56
- "gitHead": "0dbb118320203ab6c0c07450a3e718815367589f"
60
+ "gitHead": "ca16b5f88b00ae05fb6d7c7e9874525048e389f0"
57
61
  }
@@ -64,6 +64,15 @@ export const CollapsibleMixin = (superClass) =>
64
64
  // Only handle click and not keydown, because `vaadin-details-summary` uses `ButtonMixin`
65
65
  // that already covers this logic, and `vaadin-accordion-heading` uses native `<button>`.
66
66
  this.addEventListener('click', ({ target }) => {
67
+ if (this.disabled) {
68
+ return;
69
+ }
70
+
71
+ // Do not change opened on link click
72
+ if (target.localName === 'a') {
73
+ return;
74
+ }
75
+
67
76
  const summary = this.focusElement;
68
77
 
69
78
  if (summary && (target === summary || summary.contains(target))) {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2019 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { DelegateFocusMixinClass } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
8
+ import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
9
+ import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
10
+ import type { TabindexMixinClass } from '@vaadin/a11y-base/src/tabindex-mixin.js';
11
+ import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
12
+ import type { CollapsibleMixinClass } from './collapsible-mixin.js';
13
+
14
+ export declare function DetailsBaseMixin<T extends Constructor<HTMLElement>>(
15
+ base: T,
16
+ ): Constructor<CollapsibleMixinClass> &
17
+ Constructor<DelegateFocusMixinClass> &
18
+ Constructor<DelegateStateMixinClass> &
19
+ Constructor<DetailsBaseMixinClass> &
20
+ Constructor<DisabledMixinClass> &
21
+ Constructor<FocusMixinClass> &
22
+ Constructor<TabindexMixinClass> &
23
+ T;
24
+
25
+ export declare class DetailsBaseMixinClass {
26
+ /**
27
+ * A text that is displayed in the summary, if no
28
+ * element is assigned to the `summary` slot.
29
+ */
30
+ summary: string | null | undefined;
31
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
7
+ import { DelegateStateMixin } from '@vaadin/component-base/src/delegate-state-mixin.js';
8
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
9
+ import { CollapsibleMixin } from './collapsible-mixin.js';
10
+ import { SummaryController } from './summary-controller.js';
11
+
12
+ /**
13
+ * @polymerMixin
14
+ * @mixes DelegateFocusMixin
15
+ * @mixes DelegateStateMixin
16
+ * @mixes CollapsibleMixin
17
+ */
18
+ export const DetailsBaseMixin = (superClass) =>
19
+ class DetailsBaseMixin extends CollapsibleMixin(DelegateFocusMixin(DelegateStateMixin(superClass))) {
20
+ static get properties() {
21
+ return {
22
+ /**
23
+ * A text that is displayed in the summary, if no
24
+ * element is assigned to the `summary` slot.
25
+ */
26
+ summary: {
27
+ type: String,
28
+ observer: '_summaryChanged',
29
+ },
30
+ };
31
+ }
32
+
33
+ static get observers() {
34
+ return ['__updateAriaControls(focusElement, _contentElements)', '__updateAriaExpanded(focusElement, opened)'];
35
+ }
36
+
37
+ static get delegateAttrs() {
38
+ return ['theme'];
39
+ }
40
+
41
+ static get delegateProps() {
42
+ return ['disabled', 'opened'];
43
+ }
44
+
45
+ constructor() {
46
+ super();
47
+
48
+ this._summaryController = new SummaryController(this, 'vaadin-details-summary');
49
+ this._summaryController.addEventListener('slot-content-changed', (event) => {
50
+ const { node } = event.target;
51
+
52
+ this._setFocusElement(node);
53
+ this.stateTarget = node;
54
+
55
+ this._tooltipController.setTarget(node);
56
+ });
57
+
58
+ this._tooltipController = new TooltipController(this);
59
+ this._tooltipController.setPosition('bottom-start');
60
+ }
61
+
62
+ /** @protected */
63
+ ready() {
64
+ super.ready();
65
+
66
+ this.addController(this._summaryController);
67
+ this.addController(this._tooltipController);
68
+ }
69
+
70
+ /**
71
+ * Override method inherited from `DisabledMixin`
72
+ * to not set `aria-disabled` on the host element.
73
+ *
74
+ * @protected
75
+ * @override
76
+ */
77
+ _setAriaDisabled() {
78
+ // The `aria-disabled` is set on the details summary.
79
+ }
80
+
81
+ /** @private */
82
+ _summaryChanged(summary) {
83
+ this._summaryController.setSummary(summary);
84
+ }
85
+
86
+ /** @private */
87
+ __updateAriaControls(summary, contentElements) {
88
+ if (summary && contentElements) {
89
+ const node = contentElements[0];
90
+
91
+ if (node && node.id) {
92
+ summary.setAttribute('aria-controls', node.id);
93
+ } else {
94
+ summary.removeAttribute('aria-controls');
95
+ }
96
+ }
97
+ }
98
+
99
+ /** @private */
100
+ __updateAriaExpanded(focusElement, opened) {
101
+ if (focusElement) {
102
+ focusElement.setAttribute('aria-expanded', opened ? 'true' : 'false');
103
+ }
104
+ }
105
+ };
@@ -3,12 +3,10 @@
3
3
  * Copyright (c) 2019 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
7
6
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
8
- import { DelegateStateMixin } from '@vaadin/component-base/src/delegate-state-mixin.js';
9
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
10
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
- import { CollapsibleMixin } from './collapsible-mixin.js';
9
+ import { DetailsBaseMixin } from './vaadin-details-base-mixin.js';
12
10
 
13
11
  /**
14
12
  * Fired when the `opened` property changes.
@@ -55,15 +53,7 @@ export type DetailsEventMap = DetailsCustomEventMap & HTMLElementEventMap;
55
53
  *
56
54
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
57
55
  */
58
- declare class Details extends CollapsibleMixin(
59
- DelegateStateMixin(DelegateFocusMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement))))),
60
- ) {
61
- /**
62
- * A text that is displayed in the summary, if no
63
- * element is assigned to the `summary` slot.
64
- */
65
- summary: string | null | undefined;
66
-
56
+ declare class Details extends DetailsBaseMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement)))) {
67
57
  addEventListener<K extends keyof DetailsEventMap>(
68
58
  type: K,
69
59
  listener: (this: Details, ev: DetailsEventMap[K]) => void,
@@ -5,14 +5,10 @@
5
5
  */
6
6
  import './vaadin-details-summary.js';
7
7
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
8
- import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
9
8
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
10
- import { DelegateStateMixin } from '@vaadin/component-base/src/delegate-state-mixin.js';
11
9
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
12
- import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
13
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
- import { CollapsibleMixin } from './collapsible-mixin.js';
15
- import { SummaryController } from './summary-controller.js';
11
+ import { DetailsBaseMixin } from './vaadin-details-base-mixin.js';
16
12
 
17
13
  /**
18
14
  * `<vaadin-details>` is a Web Component which the creates an
@@ -49,16 +45,12 @@ import { SummaryController } from './summary-controller.js';
49
45
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
50
46
  *
51
47
  * @extends HTMLElement
52
- * @mixes CollapsibleMixin
53
48
  * @mixes ControllerMixin
54
- * @mixes DelegateFocusMixin
55
- * @mixes DelegateStateMixin
49
+ * @mixes DetailsBaseMixin
56
50
  * @mixes ElementMixin
57
51
  * @mixes ThemableMixin
58
52
  */
59
- class Details extends CollapsibleMixin(
60
- DelegateStateMixin(DelegateFocusMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))))),
61
- ) {
53
+ class Details extends DetailsBaseMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))) {
62
54
  static get template() {
63
55
  return html`
64
56
  <style>
@@ -92,92 +84,6 @@ class Details extends CollapsibleMixin(
92
84
  static get is() {
93
85
  return 'vaadin-details';
94
86
  }
95
-
96
- static get properties() {
97
- return {
98
- /**
99
- * A text that is displayed in the summary, if no
100
- * element is assigned to the `summary` slot.
101
- */
102
- summary: {
103
- type: String,
104
- observer: '_summaryChanged',
105
- },
106
- };
107
- }
108
-
109
- static get observers() {
110
- return ['__updateAriaControls(focusElement, _contentElements)', '__updateAriaExpanded(focusElement, opened)'];
111
- }
112
-
113
- static get delegateAttrs() {
114
- return ['theme'];
115
- }
116
-
117
- static get delegateProps() {
118
- return ['disabled', 'opened'];
119
- }
120
-
121
- constructor() {
122
- super();
123
-
124
- this._summaryController = new SummaryController(this, 'vaadin-details-summary');
125
- this._summaryController.addEventListener('slot-content-changed', (event) => {
126
- const { node } = event.target;
127
-
128
- this._setFocusElement(node);
129
- this.stateTarget = node;
130
-
131
- this._tooltipController.setTarget(node);
132
- });
133
-
134
- this._tooltipController = new TooltipController(this);
135
- this._tooltipController.setPosition('bottom-start');
136
- }
137
-
138
- /** @protected */
139
- ready() {
140
- super.ready();
141
-
142
- this.addController(this._summaryController);
143
- this.addController(this._tooltipController);
144
- }
145
-
146
- /**
147
- * Override method inherited from `DisabledMixin`
148
- * to not set `aria-disabled` on the host element.
149
- *
150
- * @protected
151
- * @override
152
- */
153
- _setAriaDisabled() {
154
- // The `aria-disabled` is set on the details summary.
155
- }
156
-
157
- /** @private */
158
- _summaryChanged(summary) {
159
- this._summaryController.setSummary(summary);
160
- }
161
-
162
- /** @private */
163
- __updateAriaControls(summary, contentElements) {
164
- if (summary && contentElements) {
165
- const node = contentElements[0];
166
-
167
- if (node && node.id) {
168
- summary.setAttribute('aria-controls', node.id);
169
- } else {
170
- summary.removeAttribute('aria-controls');
171
- }
172
- }
173
- }
174
-
175
- /** @private */
176
- __updateAriaExpanded(focusElement, opened) {
177
- if (focusElement) {
178
- focusElement.setAttribute('aria-expanded', opened ? 'true' : 'false');
179
- }
180
- }
181
87
  }
182
88
 
183
89
  customElements.define(Details.is, Details);
@@ -0,0 +1,2 @@
1
+ import './vaadin-details-summary-styles.js';
2
+ import '../../src/vaadin-details-summary.js';
@@ -1,3 +1,3 @@
1
- import './vaadin-details-summary-styles.js';
1
+ import './vaadin-details-summary.js';
2
2
  import './vaadin-details-styles.js';
3
3
  import '../../src/vaadin-details.js';
@@ -0,0 +1,2 @@
1
+ import './vaadin-details-summary-styles.js';
2
+ import '../../src/vaadin-details-summary.js';
@@ -1,3 +1,3 @@
1
- import './vaadin-details-summary-styles.js';
1
+ import './vaadin-details-summary.js';
2
2
  import './vaadin-details-styles.js';
3
3
  import '../../src/vaadin-details.js';
@@ -0,0 +1 @@
1
+ export * from './src/vaadin-details-summary.js';
@@ -0,0 +1,2 @@
1
+ import './theme/lumo/vaadin-details-summary.js';
2
+ export * from './src/vaadin-details-summary.js';
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/details",
4
- "version": "24.2.0-alpha1",
4
+ "version": "24.2.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -76,15 +76,6 @@
76
76
  "name": "vaadin-details",
77
77
  "description": "`<vaadin-details>` is a Web Component which the creates an\nexpandable panel similar to `<details>` HTML element.\n\n```\n<vaadin-details>\n <vaadin-details-summary slot=\"summary\">Expandable Details</vaadin-details-summary>\n <div>\n Toggle using mouse, Enter and Space keys.\n </div>\n</vaadin-details>\n```\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 details 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/styling-components) documentation.",
78
78
  "attributes": [
79
- {
80
- "name": "opened",
81
- "description": "If true, the collapsible content is visible.",
82
- "value": {
83
- "type": [
84
- "boolean"
85
- ]
86
- }
87
- },
88
79
  {
89
80
  "name": "disabled",
90
81
  "description": "If true, the user cannot interact with this element.",
@@ -107,6 +98,15 @@
107
98
  ]
108
99
  }
109
100
  },
101
+ {
102
+ "name": "opened",
103
+ "description": "If true, the collapsible content is visible.",
104
+ "value": {
105
+ "type": [
106
+ "boolean"
107
+ ]
108
+ }
109
+ },
110
110
  {
111
111
  "name": "summary",
112
112
  "description": "A text that is displayed in the summary, if no\nelement is assigned to the `summary` slot.",
@@ -132,15 +132,6 @@
132
132
  ],
133
133
  "js": {
134
134
  "properties": [
135
- {
136
- "name": "opened",
137
- "description": "If true, the collapsible content is visible.",
138
- "value": {
139
- "type": [
140
- "boolean"
141
- ]
142
- }
143
- },
144
135
  {
145
136
  "name": "disabled",
146
137
  "description": "If true, the user cannot interact with this element.",
@@ -163,6 +154,15 @@
163
154
  ]
164
155
  }
165
156
  },
157
+ {
158
+ "name": "opened",
159
+ "description": "If true, the collapsible content is visible.",
160
+ "value": {
161
+ "type": [
162
+ "boolean"
163
+ ]
164
+ }
165
+ },
166
166
  {
167
167
  "name": "summary",
168
168
  "description": "A text that is displayed in the summary, if no\nelement is assigned to the `summary` slot.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/details",
4
- "version": "24.2.0-alpha1",
4
+ "version": "24.2.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -41,22 +41,22 @@
41
41
  "extension": true,
42
42
  "attributes": [
43
43
  {
44
- "name": "?opened",
45
- "description": "If true, the collapsible content is visible.",
44
+ "name": "?disabled",
45
+ "description": "If true, the user cannot interact with this element.",
46
46
  "value": {
47
47
  "kind": "expression"
48
48
  }
49
49
  },
50
50
  {
51
- "name": "?disabled",
52
- "description": "If true, the user cannot interact with this element.",
51
+ "name": "?autofocus",
52
+ "description": "Specify that this control should have input focus when the page loads.",
53
53
  "value": {
54
54
  "kind": "expression"
55
55
  }
56
56
  },
57
57
  {
58
- "name": "?autofocus",
59
- "description": "Specify that this control should have input focus when the page loads.",
58
+ "name": "?opened",
59
+ "description": "If true, the collapsible content is visible.",
60
60
  "value": {
61
61
  "kind": "expression"
62
62
  }