@vaadin/card 24.7.1 → 24.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/vaadin-card.d.ts +15 -3
- package/src/vaadin-card.js +114 -2
- package/web-types.json +48 -3
- package/web-types.lit.json +18 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/card",
|
|
3
|
-
"version": "24.7.
|
|
3
|
+
"version": "24.7.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"web-component"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@vaadin/component-base": "~24.7.
|
|
38
|
-
"@vaadin/vaadin-lumo-styles": "~24.7.
|
|
39
|
-
"@vaadin/vaadin-material-styles": "~24.7.
|
|
40
|
-
"@vaadin/vaadin-themable-mixin": "~24.7.
|
|
37
|
+
"@vaadin/component-base": "~24.7.3",
|
|
38
|
+
"@vaadin/vaadin-lumo-styles": "~24.7.3",
|
|
39
|
+
"@vaadin/vaadin-material-styles": "~24.7.3",
|
|
40
|
+
"@vaadin/vaadin-themable-mixin": "~24.7.3",
|
|
41
41
|
"lit": "^3.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@vaadin/chai-plugins": "~24.7.
|
|
45
|
-
"@vaadin/test-runner-commands": "~24.7.
|
|
44
|
+
"@vaadin/chai-plugins": "~24.7.3",
|
|
45
|
+
"@vaadin/test-runner-commands": "~24.7.3",
|
|
46
46
|
"@vaadin/testing-helpers": "^1.1.0",
|
|
47
47
|
"sinon": "^18.0.0"
|
|
48
48
|
},
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"web-types.json",
|
|
51
51
|
"web-types.lit.json"
|
|
52
52
|
],
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "07e8e8a103cbba1906fb7332eaf1114b8e4d3907"
|
|
54
54
|
}
|
package/src/vaadin-card.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
9
9
|
/**
|
|
10
10
|
* `<vaadin-card>` is a versatile container for grouping related content and actions.
|
|
11
11
|
* It presents information in a structured and visually appealing manner, with
|
|
12
|
-
* customization options to fit various design requirements.
|
|
12
|
+
* customization options to fit various design requirements. The default ARIA role is `region`.
|
|
13
13
|
*
|
|
14
14
|
* ```html
|
|
15
|
-
* <vaadin-card theme="outlined cover-media">
|
|
15
|
+
* <vaadin-card role="region" theme="outlined cover-media">
|
|
16
16
|
* <img slot="media" width="200" src="..." alt="">
|
|
17
17
|
* <div slot="title">Lapland</div>
|
|
18
18
|
* <div slot="subtitle">The Exotic North</div>
|
|
@@ -41,7 +41,19 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
41
41
|
*
|
|
42
42
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
43
43
|
*/
|
|
44
|
-
declare class Card extends ElementMixin(ThemableMixin(HTMLElement)) {
|
|
44
|
+
declare class Card extends ElementMixin(ThemableMixin(HTMLElement)) {
|
|
45
|
+
/**
|
|
46
|
+
* The title of the card. When set, any custom slotted title is removed and this string-based title is used instead. If this title is used, an `aria-labelledby` attribute that points to the generated title element is set.
|
|
47
|
+
* @attr {string} card-title
|
|
48
|
+
*/
|
|
49
|
+
cardTitle: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sets the heading level (`aria-level`) for the string-based title. If not set, the level defaults to 2. Setting values outside the range [1, 6] can cause accessibility issues.
|
|
53
|
+
* @attr {number} title-heading-level
|
|
54
|
+
*/
|
|
55
|
+
titleHeadingLevel: number | null | undefined;
|
|
56
|
+
}
|
|
45
57
|
|
|
46
58
|
declare global {
|
|
47
59
|
interface HTMLElementTagNameMap {
|
package/src/vaadin-card.js
CHANGED
|
@@ -7,15 +7,16 @@ import { css, html, LitElement } from 'lit';
|
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
9
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
10
11
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* `<vaadin-card>` is a versatile container for grouping related content and actions.
|
|
14
15
|
* It presents information in a structured and visually appealing manner, with
|
|
15
|
-
* customization options to fit various design requirements.
|
|
16
|
+
* customization options to fit various design requirements. The default ARIA role is `region`.
|
|
16
17
|
*
|
|
17
18
|
* ```html
|
|
18
|
-
* <vaadin-card theme="outlined cover-media">
|
|
19
|
+
* <vaadin-card role="region" theme="outlined cover-media">
|
|
19
20
|
* <img slot="media" width="200" src="..." alt="">
|
|
20
21
|
* <div slot="title">Lapland</div>
|
|
21
22
|
* <div slot="subtitle">The Exotic North</div>
|
|
@@ -235,6 +236,8 @@ class Card extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
|
235
236
|
height: auto;
|
|
236
237
|
aspect-ratio: var(--vaadin-card-media-aspect-ratio, 16/9);
|
|
237
238
|
object-fit: cover;
|
|
239
|
+
/* Fixes an issue where an icon overflows the card boundaries on Firefox: https://github.com/vaadin/web-components/issues/8641 */
|
|
240
|
+
overflow: hidden;
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
:host([theme~='horizontal']:is([theme~='cover-media'], [theme~='stretch-media'])) {
|
|
@@ -279,10 +282,46 @@ class Card extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
|
279
282
|
`;
|
|
280
283
|
}
|
|
281
284
|
|
|
285
|
+
static get properties() {
|
|
286
|
+
return {
|
|
287
|
+
/**
|
|
288
|
+
* The title of the card. When set, any custom slotted title is removed and this string-based title is used instead. If this title is used, an `aria-labelledby` attribute that points to the generated title element is set.
|
|
289
|
+
*
|
|
290
|
+
* @attr {string} card-title
|
|
291
|
+
*/
|
|
292
|
+
cardTitle: {
|
|
293
|
+
type: String,
|
|
294
|
+
observer: '__cardTitleChanged',
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Sets the heading level (`aria-level`) for the string-based title. If not set, the level defaults to 2. Setting values outside the range [1, 6] can cause accessibility issues.
|
|
299
|
+
*
|
|
300
|
+
* @attr {number} title-heading-level
|
|
301
|
+
*/
|
|
302
|
+
titleHeadingLevel: {
|
|
303
|
+
type: Number,
|
|
304
|
+
reflectToAttribute: true,
|
|
305
|
+
observer: '__titleHeadingLevelChanged',
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
282
310
|
static get experimental() {
|
|
283
311
|
return true;
|
|
284
312
|
}
|
|
285
313
|
|
|
314
|
+
/** @protected */
|
|
315
|
+
ready() {
|
|
316
|
+
super.ready();
|
|
317
|
+
|
|
318
|
+
// By default, if the user hasn't provided a custom role,
|
|
319
|
+
// the role attribute is set to "region".
|
|
320
|
+
if (!this.hasAttribute('role')) {
|
|
321
|
+
this.setAttribute('role', 'region');
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
286
325
|
/** @protected */
|
|
287
326
|
render() {
|
|
288
327
|
return html`
|
|
@@ -322,6 +361,79 @@ class Card extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
|
322
361
|
this.toggleAttribute('_hs', this.querySelector(':scope > [slot="header-suffix"]'));
|
|
323
362
|
this.toggleAttribute('_c', this.querySelector(':scope > :not([slot])'));
|
|
324
363
|
this.toggleAttribute('_f', this.querySelector(':scope > [slot="footer"]'));
|
|
364
|
+
if (this.__getCustomTitleElement()) {
|
|
365
|
+
this.__clearStringTitle();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** @private */
|
|
370
|
+
__clearStringTitle() {
|
|
371
|
+
const stringTitleElement = this.__getStringTitleElement();
|
|
372
|
+
if (stringTitleElement) {
|
|
373
|
+
this.removeChild(stringTitleElement);
|
|
374
|
+
}
|
|
375
|
+
const ariaLabelledby = this.getAttribute('aria-labelledby');
|
|
376
|
+
if (ariaLabelledby && ariaLabelledby.startsWith('card-title-')) {
|
|
377
|
+
this.removeAttribute('aria-labelledby');
|
|
378
|
+
}
|
|
379
|
+
if (this.cardTitle) {
|
|
380
|
+
this.cardTitle = '';
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** @private */
|
|
385
|
+
__getCustomTitleElement() {
|
|
386
|
+
return Array.from(this.querySelectorAll('[slot="title"]')).find((el) => {
|
|
387
|
+
return !el.hasAttribute('card-string-title');
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** @private */
|
|
392
|
+
__cardTitleChanged(title) {
|
|
393
|
+
if (!title) {
|
|
394
|
+
this.__clearStringTitle();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
const customTitleElement = this.__getCustomTitleElement();
|
|
398
|
+
if (customTitleElement) {
|
|
399
|
+
this.removeChild(customTitleElement);
|
|
400
|
+
}
|
|
401
|
+
let stringTitleElement = this.__getStringTitleElement();
|
|
402
|
+
if (!stringTitleElement) {
|
|
403
|
+
stringTitleElement = this.__createStringTitleElement();
|
|
404
|
+
this.appendChild(stringTitleElement);
|
|
405
|
+
this.setAttribute('aria-labelledby', stringTitleElement.id);
|
|
406
|
+
}
|
|
407
|
+
stringTitleElement.textContent = title;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** @private */
|
|
411
|
+
__createStringTitleElement() {
|
|
412
|
+
const stringTitleElement = document.createElement('div');
|
|
413
|
+
stringTitleElement.setAttribute('slot', 'title');
|
|
414
|
+
stringTitleElement.setAttribute('role', 'heading');
|
|
415
|
+
this.__setTitleHeadingLevel(stringTitleElement, this.titleHeadingLevel);
|
|
416
|
+
stringTitleElement.setAttribute('card-string-title', '');
|
|
417
|
+
stringTitleElement.id = `card-title-${generateUniqueId()}`;
|
|
418
|
+
return stringTitleElement;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** @private */
|
|
422
|
+
__titleHeadingLevelChanged(titleHeadingLevel) {
|
|
423
|
+
const stringTitleElement = this.__getStringTitleElement();
|
|
424
|
+
if (stringTitleElement) {
|
|
425
|
+
this.__setTitleHeadingLevel(stringTitleElement, titleHeadingLevel);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** @private */
|
|
430
|
+
__setTitleHeadingLevel(stringTitleElement, titleHeadingLevel) {
|
|
431
|
+
stringTitleElement.setAttribute('aria-level', titleHeadingLevel || 2);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** @private */
|
|
435
|
+
__getStringTitleElement() {
|
|
436
|
+
return this.querySelector('[slot="title"][card-string-title]');
|
|
325
437
|
}
|
|
326
438
|
|
|
327
439
|
/**
|
package/web-types.json
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/card",
|
|
4
|
-
"version": "24.7.
|
|
4
|
+
"version": "24.7.3",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-card",
|
|
11
|
-
"description": "`<vaadin-card>` is a versatile container for grouping related content and actions.\nIt presents information in a structured and visually appealing manner, with\ncustomization options to fit various design requirements
|
|
11
|
+
"description": "`<vaadin-card>` is a versatile container for grouping related content and actions.\nIt presents information in a structured and visually appealing manner, with\ncustomization options to fit various design requirements. The default ARIA role is `region`.\n\n```html\n<vaadin-card role=\"region\" theme=\"outlined cover-media\">\n <img slot=\"media\" width=\"200\" src=\"...\" alt=\"\">\n <div slot=\"title\">Lapland</div>\n <div slot=\"subtitle\">The Exotic North</div>\n <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>\n <vaadin-button slot=\"footer\">Book Vacation</vaadin-button>\n</vaadin-card>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|-------------\n`media` | The container for the media element (e.g., image, video, icon). Shown above of before the card content.\n`header` | The container for title and subtitle - or for custom header content - and header prefix and suffix elements.\n`content` | The container for the card content (usually text content).\n`footer` | The container for footer elements. This part is always at the bottom of the card.\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n----------------|-------------|-------------\n`--vaadin-card-padding` | The space between the card edge and its content. Needs to a unified value for all edges, i.e., a single length value. | `1em`\n`--vaadin-card-gap` | The space between content elements within the card. | `1em`\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
12
12
|
"attributes": [
|
|
13
|
+
{
|
|
14
|
+
"name": "card-title",
|
|
15
|
+
"description": "The title of the card. When set, any custom slotted title is removed and this string-based title is used instead. If this title is used, an `aria-labelledby` attribute that points to the generated title element is set.",
|
|
16
|
+
"value": {
|
|
17
|
+
"type": [
|
|
18
|
+
"string",
|
|
19
|
+
"null",
|
|
20
|
+
"undefined"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "title-heading-level",
|
|
26
|
+
"description": "Sets the heading level (`aria-level`) for the string-based title. If not set, the level defaults to 2. Setting values outside the range [1, 6] can cause accessibility issues.",
|
|
27
|
+
"value": {
|
|
28
|
+
"type": [
|
|
29
|
+
"number",
|
|
30
|
+
"null",
|
|
31
|
+
"undefined"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
13
35
|
{
|
|
14
36
|
"name": "theme",
|
|
15
37
|
"description": "The theme variants to apply to the component.",
|
|
@@ -23,7 +45,30 @@
|
|
|
23
45
|
}
|
|
24
46
|
],
|
|
25
47
|
"js": {
|
|
26
|
-
"properties": [
|
|
48
|
+
"properties": [
|
|
49
|
+
{
|
|
50
|
+
"name": "cardTitle",
|
|
51
|
+
"description": "The title of the card. When set, any custom slotted title is removed and this string-based title is used instead. If this title is used, an `aria-labelledby` attribute that points to the generated title element is set.",
|
|
52
|
+
"value": {
|
|
53
|
+
"type": [
|
|
54
|
+
"string",
|
|
55
|
+
"null",
|
|
56
|
+
"undefined"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "titleHeadingLevel",
|
|
62
|
+
"description": "Sets the heading level (`aria-level`) for the string-based title. If not set, the level defaults to 2. Setting values outside the range [1, 6] can cause accessibility issues.",
|
|
63
|
+
"value": {
|
|
64
|
+
"type": [
|
|
65
|
+
"number",
|
|
66
|
+
"null",
|
|
67
|
+
"undefined"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
],
|
|
27
72
|
"events": []
|
|
28
73
|
}
|
|
29
74
|
}
|
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/card",
|
|
4
|
-
"version": "24.7.
|
|
4
|
+
"version": "24.7.3",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,9 +16,24 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-card",
|
|
19
|
-
"description": "`<vaadin-card>` is a versatile container for grouping related content and actions.\nIt presents information in a structured and visually appealing manner, with\ncustomization options to fit various design requirements
|
|
19
|
+
"description": "`<vaadin-card>` is a versatile container for grouping related content and actions.\nIt presents information in a structured and visually appealing manner, with\ncustomization options to fit various design requirements. The default ARIA role is `region`.\n\n```html\n<vaadin-card role=\"region\" theme=\"outlined cover-media\">\n <img slot=\"media\" width=\"200\" src=\"...\" alt=\"\">\n <div slot=\"title\">Lapland</div>\n <div slot=\"subtitle\">The Exotic North</div>\n <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>\n <vaadin-button slot=\"footer\">Book Vacation</vaadin-button>\n</vaadin-card>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|-------------\n`media` | The container for the media element (e.g., image, video, icon). Shown above of before the card content.\n`header` | The container for title and subtitle - or for custom header content - and header prefix and suffix elements.\n`content` | The container for the card content (usually text content).\n`footer` | The container for footer elements. This part is always at the bottom of the card.\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n----------------|-------------|-------------\n`--vaadin-card-padding` | The space between the card edge and its content. Needs to a unified value for all edges, i.e., a single length value. | `1em`\n`--vaadin-card-gap` | The space between content elements within the card. | `1em`\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
|
-
"attributes": [
|
|
21
|
+
"attributes": [
|
|
22
|
+
{
|
|
23
|
+
"name": ".cardTitle",
|
|
24
|
+
"description": "The title of the card. When set, any custom slotted title is removed and this string-based title is used instead. If this title is used, an `aria-labelledby` attribute that points to the generated title element is set.",
|
|
25
|
+
"value": {
|
|
26
|
+
"kind": "expression"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": ".titleHeadingLevel",
|
|
31
|
+
"description": "Sets the heading level (`aria-level`) for the string-based title. If not set, the level defaults to 2. Setting values outside the range [1, 6] can cause accessibility issues.",
|
|
32
|
+
"value": {
|
|
33
|
+
"kind": "expression"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
22
37
|
}
|
|
23
38
|
]
|
|
24
39
|
}
|