@vaadin/vaadin-themable-mixin 23.2.16 → 23.2.18

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/vaadin-themable-mixin",
3
- "version": "23.2.16",
3
+ "version": "23.2.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,8 +37,8 @@
37
37
  "devDependencies": {
38
38
  "@esm-bundle/chai": "^4.3.4",
39
39
  "@polymer/polymer": "^3.0.0",
40
- "@vaadin/testing-helpers": "^0.4.0",
40
+ "@vaadin/testing-helpers": "^0.3.2",
41
41
  "sinon": "^13.0.2"
42
42
  },
43
- "gitHead": "57010013e59a3ecdc70ceef4377dbc3b1ac03fb3"
43
+ "gitHead": "0633266344f3b8eaae21f5c1365b682f163dd0cb"
44
44
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  export { registerStyles, css, unsafeCSS } from './vaadin-themable-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  export { registerStyles, css, unsafeCSS } from './vaadin-themable-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { css, CSSResult, unsafeCSS } from 'lit';
@@ -23,40 +23,6 @@ export { css, unsafeCSS };
23
23
  */
24
24
  const themeRegistry = [];
25
25
 
26
- /**
27
- * Check if the custom element type has themes applied.
28
- * @param {Function} elementClass
29
- * @returns {boolean}
30
- */
31
- function classHasThemes(elementClass) {
32
- return elementClass && Object.prototype.hasOwnProperty.call(elementClass, '__themes');
33
- }
34
-
35
- /**
36
- * Check if the custom element type has themes applied.
37
- * @param {string} tagName
38
- * @returns {boolean}
39
- */
40
- function hasThemes(tagName) {
41
- return classHasThemes(customElements.get(tagName));
42
- }
43
-
44
- /**
45
- * Flattens the styles into a single array of styles.
46
- * @param {CSSResultGroup} styles
47
- * @param {CSSResult[]} result
48
- * @returns {CSSResult[]}
49
- */
50
- function flattenStyles(styles = []) {
51
- return [styles].flat(Infinity).filter((style) => {
52
- if (style instanceof CSSResult) {
53
- return true;
54
- }
55
- console.warn('An item in styles is not of type CSSResult. Use `unsafeCSS` or `css`.');
56
- return false;
57
- });
58
- }
59
-
60
26
  /**
61
27
  * Registers CSS styles for a component type. Make sure to register the styles before
62
28
  * the first instance of a component of the type is attached to DOM.
@@ -111,7 +77,7 @@ function getAllThemes() {
111
77
  */
112
78
  function matchesThemeFor(themeFor, tagName) {
113
79
  return (themeFor || '').split(' ').some((themeForToken) => {
114
- return new RegExp(`^${themeForToken.split('*').join('.*')}$`, 'u').test(tagName);
80
+ return new RegExp(`^${themeForToken.split('*').join('.*')}$`).test(tagName);
115
81
  });
116
82
  }
117
83
 
@@ -131,6 +97,22 @@ function getIncludePriority(moduleName = '') {
131
97
  return includePriority;
132
98
  }
133
99
 
100
+ /**
101
+ * Flattens the styles into a single array of styles.
102
+ * @param {CSSResultGroup} styles
103
+ * @param {CSSResult[]} result
104
+ * @returns {CSSResult[]}
105
+ */
106
+ function flattenStyles(styles = []) {
107
+ return [styles].flat(Infinity).filter((style) => {
108
+ if (style instanceof CSSResult) {
109
+ return true;
110
+ }
111
+ console.warn('An item in styles is not of type CSSResult. Use `unsafeCSS` or `css`.');
112
+ return false;
113
+ });
114
+ }
115
+
134
116
  /**
135
117
  * Gets an array of CSSResults matching the include property of the theme.
136
118
  * @param {Theme} theme
@@ -191,6 +173,24 @@ function getThemes(tagName) {
191
173
  return getAllThemes().filter((theme) => theme.moduleId === defaultModuleName);
192
174
  }
193
175
 
176
+ /**
177
+ * Check if the custom element type has themes applied.
178
+ * @param {string} tagName
179
+ * @returns {boolean}
180
+ */
181
+ function hasThemes(tagName) {
182
+ return classHasThemes(customElements.get(tagName));
183
+ }
184
+
185
+ /**
186
+ * Check if the custom element type has themes applied.
187
+ * @param {Function} elementClass
188
+ * @returns {boolean}
189
+ */
190
+ function classHasThemes(elementClass) {
191
+ return elementClass && Object.prototype.hasOwnProperty.call(elementClass, '__themes');
192
+ }
193
+
194
194
  /**
195
195
  * @polymerMixin
196
196
  * @mixes ThemePropertyMixin
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -16,7 +16,7 @@ export declare class ThemePropertyMixinClass {
16
16
  *
17
17
  * Enables the component implementation to propagate the `theme`
18
18
  * attribute value to the sub-components in Shadow DOM by binding
19
- * the sub-component's "theme" attribute to the `theme` property of
19
+ * the sub-components "theme" attribute to the `theme` property of
20
20
  * the host.
21
21
  *
22
22
  * **NOTE:** Extending the mixin only provides the property for binding,
@@ -25,7 +25,28 @@ export declare class ThemePropertyMixinClass {
25
25
  * See [Styling Components: Sub-components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components/#sub-components).
26
26
  * page for more information.
27
27
  *
28
+ * @deprecated The `theme` property is not supposed for public use and will be dropped in Vaadin 24.
29
+ * Please, use the `theme` attribute instead.
28
30
  * @protected
29
31
  */
30
- protected readonly _theme: string | null | undefined;
32
+ theme: string | null | undefined;
33
+
34
+ /**
35
+ * Helper property with theme attribute value facilitating propagation
36
+ * in shadow DOM.
37
+ *
38
+ * Enables the component implementation to propagate the `theme`
39
+ * attribute value to the sub-components in Shadow DOM by binding
40
+ * the sub-component’s "theme" attribute to the `theme` property of
41
+ * the host.
42
+ *
43
+ * **NOTE:** Extending the mixin only provides the property for binding,
44
+ * and does not make the propagation alone.
45
+ *
46
+ * See [Styling Components: Sub-components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components/#sub-components).
47
+ * page for more information.
48
+ *
49
+ * @protected
50
+ */
51
+ readonly _theme: string | null | undefined;
31
52
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  /**
@@ -16,7 +16,32 @@ export const ThemePropertyMixin = (superClass) =>
16
16
  *
17
17
  * Enables the component implementation to propagate the `theme`
18
18
  * attribute value to the sub-components in Shadow DOM by binding
19
- * the sub-component's "theme" attribute to the `theme` property of
19
+ * the sub-components "theme" attribute to the `theme` property of
20
+ * the host.
21
+ *
22
+ * **NOTE:** Extending the mixin only provides the property for binding,
23
+ * and does not make the propagation alone.
24
+ *
25
+ * See [Styling Components: Sub-components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components/#sub-components).
26
+ * page for more information.
27
+ *
28
+ * @deprecated The `theme` property is not supposed for public use and will be dropped in Vaadin 24.
29
+ * Please, use the `theme` attribute instead.
30
+ * @protected
31
+ */
32
+ theme: {
33
+ type: String,
34
+ reflectToAttribute: true,
35
+ observer: '__deprecatedThemePropertyChanged',
36
+ },
37
+
38
+ /**
39
+ * Helper property with theme attribute value facilitating propagation
40
+ * in shadow DOM.
41
+ *
42
+ * Enables the component implementation to propagate the `theme`
43
+ * attribute value to the sub-components in Shadow DOM by binding
44
+ * the sub-component’s "theme" attribute to the `theme` property of
20
45
  * the host.
21
46
  *
22
47
  * **NOTE:** Extending the mixin only provides the property for binding,
@@ -34,16 +59,8 @@ export const ThemePropertyMixin = (superClass) =>
34
59
  };
35
60
  }
36
61
 
37
- static get observedAttributes() {
38
- return [...super.observedAttributes, 'theme'];
39
- }
40
-
41
- /** @protected */
42
- attributeChangedCallback(name, oldValue, newValue) {
43
- super.attributeChangedCallback(name, oldValue, newValue);
44
-
45
- if (name === 'theme') {
46
- this._set_theme(newValue);
47
- }
62
+ /** @private */
63
+ __deprecatedThemePropertyChanged(theme) {
64
+ this._set_theme(theme);
48
65
  }
49
66
  };