@vaadin/component-base 25.2.0-rc2 → 25.2.1
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 +4 -4
- package/src/css-utils.js +40 -0
- package/src/define.js +1 -1
- package/src/styles/style-props.js +2 -2
- package/src/styles/user-colors.js +1 -1
- package/src/styles/add-global-styles.js +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "25.2.
|
|
3
|
+
"version": "25.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"lit": "^3.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@vaadin/chai-plugins": "25.2.
|
|
42
|
-
"@vaadin/test-runner-commands": "25.2.
|
|
41
|
+
"@vaadin/chai-plugins": "~25.2.1",
|
|
42
|
+
"@vaadin/test-runner-commands": "~25.2.1",
|
|
43
43
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
44
44
|
"sinon": "^22.0.0"
|
|
45
45
|
},
|
|
46
46
|
"customElements": "custom-elements.json",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "2a5e2ee168d3eddf191336d25768d247ea9e2f59"
|
|
48
48
|
}
|
package/src/css-utils.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2025 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Registers a CSS custom property, tolerating the case where the property has
|
|
9
|
+
* already been registered. This can happen when a module is evaluated more than
|
|
10
|
+
* once (e.g. duplicate bundle chunks or two copies of the library on the page),
|
|
11
|
+
* in which case `CSS.registerProperty` throws `InvalidModificationError`. That
|
|
12
|
+
* error is caught and logged as a warning rather than allowed to break loading.
|
|
13
|
+
*
|
|
14
|
+
* @param {PropertyDefinition} definition
|
|
15
|
+
*/
|
|
16
|
+
export function registerCSSProperty(definition) {
|
|
17
|
+
try {
|
|
18
|
+
CSS.registerProperty(definition);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
if (e instanceof DOMException && e.name === 'InvalidModificationError') {
|
|
21
|
+
console.warn(`The CSS property ${definition.name} has already been registered.`);
|
|
22
|
+
} else {
|
|
23
|
+
throw e;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Add a `<style>` block with given styles to the document.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} id the id to set on the created element, only for informational purposes
|
|
32
|
+
* @param {CSSResultGroup[]} styles the styles to add
|
|
33
|
+
*/
|
|
34
|
+
export const addGlobalStyles = (id, ...styles) => {
|
|
35
|
+
const styleTag = document.createElement('style');
|
|
36
|
+
styleTag.id = id;
|
|
37
|
+
styleTag.textContent = styles.map((style) => style.toString()).join('\n');
|
|
38
|
+
|
|
39
|
+
document.head.insertAdjacentElement('afterbegin', styleTag);
|
|
40
|
+
};
|
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.2.
|
|
16
|
+
export function defineCustomElement(CustomElement, version = '25.2.1') {
|
|
17
17
|
Object.defineProperty(CustomElement, 'version', {
|
|
18
18
|
get() {
|
|
19
19
|
return version;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { css } from 'lit';
|
|
7
|
-
import { addGlobalStyles } from '
|
|
7
|
+
import { addGlobalStyles, registerCSSProperty } from '../css-utils.js';
|
|
8
8
|
|
|
9
9
|
// NOTE: Base color CSS custom properties are explicitly registered as `<color>`
|
|
10
10
|
// here to avoid performance issues in Aura. Aura overrides these properties with
|
|
@@ -18,7 +18,7 @@ import { addGlobalStyles } from './add-global-styles.js';
|
|
|
18
18
|
'--vaadin-border-color-secondary',
|
|
19
19
|
'--vaadin-background-color',
|
|
20
20
|
].forEach((propertyName) => {
|
|
21
|
-
|
|
21
|
+
registerCSSProperty({
|
|
22
22
|
name: propertyName,
|
|
23
23
|
syntax: '<color>',
|
|
24
24
|
inherits: true,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { css } from 'lit';
|
|
7
|
-
import { addGlobalStyles } from '
|
|
7
|
+
import { addGlobalStyles } from '../css-utils.js';
|
|
8
8
|
|
|
9
9
|
addGlobalStyles(
|
|
10
10
|
'vaadin-base-user-colors',
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2025 - 2026 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Add a `<style>` block with given styles to the document.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} id the id to set on the created element, only for informational purposes
|
|
11
|
-
* @param {CSSResultGroup[]} styles the styles to add
|
|
12
|
-
*/
|
|
13
|
-
export const addGlobalStyles = (id, ...styles) => {
|
|
14
|
-
const styleTag = document.createElement('style');
|
|
15
|
-
styleTag.id = id;
|
|
16
|
-
styleTag.textContent = styles.map((style) => style.toString()).join('\n');
|
|
17
|
-
|
|
18
|
-
document.head.insertAdjacentElement('afterbegin', styleTag);
|
|
19
|
-
};
|