@vaadin/component-base 25.4.0-dev.55bb86e155 → 25.4.0-rc1
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/custom-elements.json +2 -12
- package/package.json +4 -4
- package/src/define.js +1 -1
- package/src/directives/part-map.d.ts +6 -0
- package/src/directives/part-map.js +17 -1
- package/src/directives/slot-content.d.ts +24 -0
- package/src/directives/slot-content.js +62 -0
- package/src/gestures.js +2 -2
- package/src/resize-mixin.js +3 -0
- package/src/slot-controller.d.ts +1 -1
- package/src/slot-controller.js +5 -1
- package/src/warnings.d.ts +5 -0
package/custom-elements.json
CHANGED
|
@@ -115,20 +115,10 @@
|
|
|
115
115
|
"type": {
|
|
116
116
|
"text": "Object | undefined"
|
|
117
117
|
},
|
|
118
|
-
"description": "The object used to localize this component. To change the default\nlocalization, set this to an object that provides all properties, or\njust the individual properties you want to change.\n\nWhen not set, defaults to `undefined`.\n\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties."
|
|
119
|
-
"attribute": "i18n"
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
"attributes": [
|
|
123
|
-
{
|
|
124
|
-
"name": "i18n",
|
|
125
|
-
"type": {
|
|
126
|
-
"text": "Object | undefined"
|
|
127
|
-
},
|
|
128
|
-
"description": "The object used to localize this component. To change the default\nlocalization, set this to an object that provides all properties, or\njust the individual properties you want to change.\n\nWhen not set, defaults to `undefined`.\n\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties.",
|
|
129
|
-
"fieldName": "i18n"
|
|
118
|
+
"description": "The object used to localize this component. To change the default\nlocalization, set this to an object that provides all properties, or\njust the individual properties you want to change.\n\nWhen not set, defaults to `undefined`.\n\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties."
|
|
130
119
|
}
|
|
131
120
|
],
|
|
121
|
+
"attributes": [],
|
|
132
122
|
"parameters": [
|
|
133
123
|
{
|
|
134
124
|
"name": "superClass"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "25.4.0-
|
|
3
|
+
"version": "25.4.0-rc1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@polymer/polymer": "^3.0.0",
|
|
42
|
-
"@vaadin/chai-plugins": "25.4.0-
|
|
43
|
-
"@vaadin/test-runner-commands": "25.4.0-
|
|
42
|
+
"@vaadin/chai-plugins": "25.4.0-rc1",
|
|
43
|
+
"@vaadin/test-runner-commands": "25.4.0-rc1",
|
|
44
44
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
45
45
|
"sinon": "^22.0.0"
|
|
46
46
|
},
|
|
47
47
|
"customElements": "custom-elements.json",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "abe6d2338024cb71110c7df9bd5d97c0d110a135"
|
|
49
49
|
}
|
package/src/define.js
CHANGED
|
@@ -13,7 +13,7 @@ function dashToCamelCase(dash) {
|
|
|
13
13
|
|
|
14
14
|
const experimentalMap = {};
|
|
15
15
|
|
|
16
|
-
export function defineCustomElement(CustomElement, version = '25.4.0-
|
|
16
|
+
export function defineCustomElement(CustomElement, version = '25.4.0-rc1') {
|
|
17
17
|
Object.defineProperty(CustomElement, 'version', {
|
|
18
18
|
get() {
|
|
19
19
|
return version;
|
|
@@ -20,3 +20,9 @@ export interface PartNameInfo {
|
|
|
20
20
|
* if the property value is truthy, and removed if the value is falsy.
|
|
21
21
|
*/
|
|
22
22
|
export declare function partMap(partNameInfo: PartNameInfo): DirectiveResult;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Parses a whitespace separated list of part names
|
|
26
|
+
* into an object accepted by the `partMap` directive.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parsePartNames(partName: string | null | undefined): Record<string, boolean>;
|
|
@@ -52,7 +52,7 @@ class PartMapDirective extends Directive {
|
|
|
52
52
|
|
|
53
53
|
// Remove old parts that no longer apply
|
|
54
54
|
this.#previousParts.forEach((name) => {
|
|
55
|
-
if (!(name
|
|
55
|
+
if (!Object.hasOwn(partNameInfo, name)) {
|
|
56
56
|
partList.remove(name);
|
|
57
57
|
this.#previousParts.delete(name);
|
|
58
58
|
}
|
|
@@ -84,3 +84,19 @@ class PartMapDirective extends Directive {
|
|
|
84
84
|
* if the property value is truthy, and removed if the value is falsy.
|
|
85
85
|
*/
|
|
86
86
|
export const partMap = directive(PartMapDirective);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Parses a whitespace separated list of part names
|
|
90
|
+
* into an object accepted by the `partMap` directive.
|
|
91
|
+
*
|
|
92
|
+
* @param {string | null | undefined} partName
|
|
93
|
+
* @return {Record<string, boolean>}
|
|
94
|
+
*/
|
|
95
|
+
export function parsePartNames(partName) {
|
|
96
|
+
return Object.fromEntries(
|
|
97
|
+
(partName || '')
|
|
98
|
+
.split(/\s+/u)
|
|
99
|
+
.filter((name) => name !== '')
|
|
100
|
+
.map((name) => [name, true]),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { DirectiveResult } from 'lit/directive.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A directive that renders the content of a `<slot>` into the light DOM of
|
|
10
|
+
* the host element. The content must have the `slot` attribute of that slot.
|
|
11
|
+
*
|
|
12
|
+
* Use it as an element expression of the `<slot>` in the template returned by
|
|
13
|
+
* `render()`, e.g. `<slot name="form" ${slotContent(this._renderForm())}></slot>`.
|
|
14
|
+
*
|
|
15
|
+
* On the first render, the directive appends a comment marker to the host and
|
|
16
|
+
* renders the content before it. Children that the host already has stay before
|
|
17
|
+
* the content, and children added later go after the marker, so rendering again
|
|
18
|
+
* does not move or remove them.
|
|
19
|
+
*
|
|
20
|
+
* Always render the directive: pass `nothing` as content instead of removing it,
|
|
21
|
+
* which would leave the content in the light DOM. On the first render, the content
|
|
22
|
+
* is connected before the shadow DOM of the host.
|
|
23
|
+
*/
|
|
24
|
+
export declare function slotContent(content: unknown): DirectiveResult;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { noChange, render } from 'lit';
|
|
7
|
+
import { Directive, directive, PartType } from 'lit/directive.js';
|
|
8
|
+
|
|
9
|
+
class SlotContentDirective extends Directive {
|
|
10
|
+
// Comment node in the light DOM of the host that the content is rendered before.
|
|
11
|
+
#marker = null;
|
|
12
|
+
|
|
13
|
+
constructor(partInfo) {
|
|
14
|
+
super(partInfo);
|
|
15
|
+
if (partInfo.type !== PartType.ELEMENT) {
|
|
16
|
+
throw new Error('`slotContent()` can only be used as an element expression of a `<slot>`.');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
render(_content) {
|
|
21
|
+
return noChange;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
update(part, [content]) {
|
|
25
|
+
if (part.element.localName !== 'slot') {
|
|
26
|
+
throw new Error('`slotContent()` can only be used as an element expression of a `<slot>`.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const host = part.options?.host;
|
|
30
|
+
if (!host) {
|
|
31
|
+
throw new Error('`slotContent()` requires the template to be rendered with the `host` option.');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Create a new marker when it was removed, e.g. when the host light DOM was cleared
|
|
35
|
+
if (this.#marker?.parentNode !== host) {
|
|
36
|
+
this.#marker = document.createComment('');
|
|
37
|
+
host.appendChild(this.#marker);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render(content, host, { host, renderBefore: this.#marker });
|
|
41
|
+
|
|
42
|
+
return noChange;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A directive that renders the content of a `<slot>` into the light DOM of
|
|
48
|
+
* the host element. The content must have the `slot` attribute of that slot.
|
|
49
|
+
*
|
|
50
|
+
* Use it as an element expression of the `<slot>` in the template returned by
|
|
51
|
+
* `render()`, e.g. `<slot name="form" ${slotContent(this._renderForm())}></slot>`.
|
|
52
|
+
*
|
|
53
|
+
* On the first render, the directive appends a comment marker to the host and
|
|
54
|
+
* renders the content before it. Children that the host already has stay before
|
|
55
|
+
* the content, and children added later go after the marker, so rendering again
|
|
56
|
+
* does not move or remove them.
|
|
57
|
+
*
|
|
58
|
+
* Always render the directive: pass `nothing` as content instead of removing it,
|
|
59
|
+
* which would leave the content in the light DOM. On the first render, the content
|
|
60
|
+
* is connected before the shadow DOM of the host.
|
|
61
|
+
*/
|
|
62
|
+
export const slotContent = directive(SlotContentDirective);
|
package/src/gestures.js
CHANGED
|
@@ -808,8 +808,8 @@ function trackFire(info, target, touch) {
|
|
|
808
808
|
if (!target) {
|
|
809
809
|
return;
|
|
810
810
|
}
|
|
811
|
-
const secondlast = info.moves
|
|
812
|
-
const lastmove = info.moves
|
|
811
|
+
const secondlast = info.moves.at(-2);
|
|
812
|
+
const lastmove = info.moves.at(-1);
|
|
813
813
|
const dx = lastmove.x - info.x;
|
|
814
814
|
const dy = lastmove.y - info.y;
|
|
815
815
|
let ddx,
|
package/src/resize-mixin.js
CHANGED
package/src/slot-controller.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export class SlotController extends EventTarget implements ReactiveController {
|
|
|
14
14
|
/**
|
|
15
15
|
* The slotted node managed by the controller.
|
|
16
16
|
*/
|
|
17
|
-
node: HTMLElement;
|
|
17
|
+
node: HTMLElement | null;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The list of slotted nodes managed by the controller.
|
package/src/slot-controller.js
CHANGED
|
@@ -217,7 +217,11 @@ export class SlotController extends EventTarget {
|
|
|
217
217
|
);
|
|
218
218
|
|
|
219
219
|
if (removedNodes.length) {
|
|
220
|
-
this.
|
|
220
|
+
if (this.multiple) {
|
|
221
|
+
this.nodes = current.filter((node) => !removedNodes.includes(node));
|
|
222
|
+
} else if (removedNodes.includes(this.node)) {
|
|
223
|
+
this.node = null;
|
|
224
|
+
}
|
|
221
225
|
|
|
222
226
|
removedNodes.forEach((node) => {
|
|
223
227
|
this.teardownNode(node);
|
package/src/warnings.d.ts
CHANGED
|
@@ -8,3 +8,8 @@
|
|
|
8
8
|
* Issues a warning in the browser console if it has not been issued before.
|
|
9
9
|
*/
|
|
10
10
|
export declare function issueWarning(warning: string): void;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Clears all issued warnings. Only intended for testing purposes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function clearWarnings(): void;
|