@vaadin/vaadin-themable-mixin 25.0.0-alpha15 → 25.0.0-alpha16
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/vaadin-themable-mixin.d.ts +1 -16
- package/vaadin-themable-mixin.js +3 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/vaadin-themable-mixin",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha16",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
41
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
40
|
+
"@vaadin/chai-plugins": "25.0.0-alpha16",
|
|
41
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha16",
|
|
42
42
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
43
43
|
"sinon": "^18.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "4b316158a4a4f702f032bc9940fc82f0faa840f4"
|
|
46
46
|
}
|
|
@@ -7,9 +7,6 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
7
7
|
import type { CSSResult, CSSResultGroup } from 'lit';
|
|
8
8
|
import type { ThemePropertyMixinClass } from './vaadin-theme-property-mixin.js';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* A mixin for `nav` elements, facilitating navigation and selection of childNodes.
|
|
12
|
-
*/
|
|
13
10
|
export declare function ThemableMixin<T extends Constructor<HTMLElement>>(
|
|
14
11
|
base: T,
|
|
15
12
|
): Constructor<ThemableMixinClass> & Constructor<ThemePropertyMixinClass> & T;
|
|
@@ -29,18 +26,6 @@ export declare interface ThemableMixinClass extends ThemePropertyMixinClass {}
|
|
|
29
26
|
*/
|
|
30
27
|
declare function registerStyles(themeFor: string | null, styles: CSSResultGroup, options?: object | null): void;
|
|
31
28
|
|
|
32
|
-
type Theme = {
|
|
33
|
-
themeFor: string;
|
|
34
|
-
styles: CSSResult[];
|
|
35
|
-
moduleId?: string;
|
|
36
|
-
include?: string[] | string;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* For internal purposes only.
|
|
41
|
-
*/
|
|
42
|
-
declare const __themeRegistry: Theme[];
|
|
43
|
-
|
|
44
29
|
export { css, unsafeCSS } from 'lit';
|
|
45
30
|
|
|
46
|
-
export { registerStyles
|
|
31
|
+
export { registerStyles };
|
package/vaadin-themable-mixin.js
CHANGED
|
@@ -55,7 +55,6 @@ function hasThemes(tagName) {
|
|
|
55
55
|
/**
|
|
56
56
|
* Flattens the styles into a single array of styles.
|
|
57
57
|
* @param {CSSResultGroup} styles
|
|
58
|
-
* @param {CSSResult[]} result
|
|
59
58
|
* @returns {CSSResult[]}
|
|
60
59
|
*/
|
|
61
60
|
function flattenStyles(styles = []) {
|
|
@@ -234,18 +233,6 @@ export function registerStyles(themeFor, styles, options = {}) {
|
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
235
|
|
|
237
|
-
/**
|
|
238
|
-
* Returns all registered themes. By default the themeRegistry is returned as is.
|
|
239
|
-
* In case the style-modules adapter is imported, the themes are obtained from there instead
|
|
240
|
-
* @returns {Theme[]}
|
|
241
|
-
*/
|
|
242
|
-
function getAllThemes() {
|
|
243
|
-
if (window.Vaadin && window.Vaadin.styleModules) {
|
|
244
|
-
return window.Vaadin.styleModules.getAllThemes();
|
|
245
|
-
}
|
|
246
|
-
return themeRegistry;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
236
|
/**
|
|
250
237
|
* Maps the moduleName to an include priority number which is used for
|
|
251
238
|
* determining the order in which styles are applied.
|
|
@@ -271,7 +258,7 @@ function getIncludedStyles(theme) {
|
|
|
271
258
|
const includedStyles = [];
|
|
272
259
|
if (theme.include) {
|
|
273
260
|
[].concat(theme.include).forEach((includeModuleId) => {
|
|
274
|
-
const includedTheme =
|
|
261
|
+
const includedTheme = themeRegistry.find((s) => s.moduleId === includeModuleId);
|
|
275
262
|
if (includedTheme) {
|
|
276
263
|
includedStyles.push(...getIncludedStyles(includedTheme), ...includedTheme.styles);
|
|
277
264
|
} else {
|
|
@@ -291,7 +278,7 @@ function getIncludedStyles(theme) {
|
|
|
291
278
|
function getThemes(tagName) {
|
|
292
279
|
const defaultModuleName = `${tagName}-default-theme`;
|
|
293
280
|
|
|
294
|
-
const themes =
|
|
281
|
+
const themes = themeRegistry
|
|
295
282
|
// Filter by matching themeFor properties
|
|
296
283
|
.filter((theme) => theme.moduleId !== defaultModuleName && matchesThemeFor(theme.themeFor, tagName))
|
|
297
284
|
.map((theme) => ({
|
|
@@ -308,7 +295,7 @@ function getThemes(tagName) {
|
|
|
308
295
|
return themes;
|
|
309
296
|
}
|
|
310
297
|
// No theme modules found, return the default module if it exists
|
|
311
|
-
return
|
|
298
|
+
return themeRegistry.filter((theme) => theme.moduleId === defaultModuleName);
|
|
312
299
|
}
|
|
313
300
|
|
|
314
301
|
/**
|
|
@@ -380,5 +367,3 @@ export const ThemableMixin = (superClass) =>
|
|
|
380
367
|
return themeStyles.filter((style, index) => index === themeStyles.lastIndexOf(style));
|
|
381
368
|
}
|
|
382
369
|
};
|
|
383
|
-
|
|
384
|
-
export { themeRegistry as __themeRegistry };
|