@empathyco/x-archetype-utils 2.0.0-alpha.6 → 2.0.0-alpha.7
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.
|
@@ -28,21 +28,19 @@ class CssInjector {
|
|
|
28
28
|
return instance;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Adds the
|
|
31
|
+
* Adds the style to the host element.
|
|
32
32
|
*
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
33
|
+
* @param style - The styles to be added.
|
|
34
|
+
* @param style.source - Styles source.
|
|
35
35
|
*/
|
|
36
|
-
addStyle(
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const styleTag = document.createElement('style');
|
|
41
|
-
styleTag.textContent = styles;
|
|
42
|
-
this.host.appendChild(styleTag);
|
|
43
|
-
});
|
|
44
|
-
this.stylesQueue = [];
|
|
36
|
+
addStyle(style) {
|
|
37
|
+
if (!this.host) {
|
|
38
|
+
this.stylesQueue.push(style);
|
|
39
|
+
return;
|
|
45
40
|
}
|
|
41
|
+
const styleTag = document.createElement('style');
|
|
42
|
+
styleTag.textContent = style.source;
|
|
43
|
+
this.host.appendChild(styleTag);
|
|
46
44
|
}
|
|
47
45
|
/**
|
|
48
46
|
* Sets the host element.
|
|
@@ -51,6 +49,9 @@ class CssInjector {
|
|
|
51
49
|
*/
|
|
52
50
|
setHost(host) {
|
|
53
51
|
this.host = host;
|
|
52
|
+
// Add all pending styles to the host element
|
|
53
|
+
this.stylesQueue.forEach(style => this.addStyle(style));
|
|
54
|
+
this.stylesQueue = [];
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* Sets the injector instance in the window object.
|
|
@@ -26,21 +26,19 @@ class CssInjector {
|
|
|
26
26
|
return instance;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Adds the
|
|
29
|
+
* Adds the style to the host element.
|
|
30
30
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
31
|
+
* @param style - The styles to be added.
|
|
32
|
+
* @param style.source - Styles source.
|
|
33
33
|
*/
|
|
34
|
-
addStyle(
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const styleTag = document.createElement('style');
|
|
39
|
-
styleTag.textContent = styles;
|
|
40
|
-
this.host.appendChild(styleTag);
|
|
41
|
-
});
|
|
42
|
-
this.stylesQueue = [];
|
|
34
|
+
addStyle(style) {
|
|
35
|
+
if (!this.host) {
|
|
36
|
+
this.stylesQueue.push(style);
|
|
37
|
+
return;
|
|
43
38
|
}
|
|
39
|
+
const styleTag = document.createElement('style');
|
|
40
|
+
styleTag.textContent = style.source;
|
|
41
|
+
this.host.appendChild(styleTag);
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
46
44
|
* Sets the host element.
|
|
@@ -49,6 +47,9 @@ class CssInjector {
|
|
|
49
47
|
*/
|
|
50
48
|
setHost(host) {
|
|
51
49
|
this.host = host;
|
|
50
|
+
// Add all pending styles to the host element
|
|
51
|
+
this.stylesQueue.forEach(style => this.addStyle(style));
|
|
52
|
+
this.stylesQueue = [];
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* Sets the injector instance in the window object.
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { XCSSInjector } from './css-injector.types';
|
|
2
|
+
/**
|
|
3
|
+
* The style interface that will be used to inject styles into the host element.
|
|
4
|
+
*/
|
|
5
|
+
interface Style {
|
|
6
|
+
source: string;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* Custom CSS injector that allows to inject styles into a host element.
|
|
4
10
|
*
|
|
5
11
|
* @public
|
|
6
12
|
*/
|
|
7
13
|
export declare class CssInjector implements XCSSInjector {
|
|
8
|
-
protected host: Element | ShadowRoot;
|
|
9
|
-
protected stylesQueue:
|
|
14
|
+
protected host: Element | ShadowRoot | undefined;
|
|
15
|
+
protected stylesQueue: Style[];
|
|
10
16
|
/**
|
|
11
17
|
* Initializes the instance of the injector if it's not already initialized and sets it in the
|
|
12
18
|
* window object if it's required.
|
|
@@ -15,14 +21,12 @@ export declare class CssInjector implements XCSSInjector {
|
|
|
15
21
|
*/
|
|
16
22
|
constructor(setInWindow?: boolean);
|
|
17
23
|
/**
|
|
18
|
-
* Adds the
|
|
24
|
+
* Adds the style to the host element.
|
|
19
25
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
26
|
+
* @param style - The styles to be added.
|
|
27
|
+
* @param style.source - Styles source.
|
|
22
28
|
*/
|
|
23
|
-
addStyle(
|
|
24
|
-
source: string;
|
|
25
|
-
}): void;
|
|
29
|
+
addStyle(style: Style): void;
|
|
26
30
|
/**
|
|
27
31
|
* Sets the host element.
|
|
28
32
|
*
|
|
@@ -46,3 +50,4 @@ export declare class CssInjector implements XCSSInjector {
|
|
|
46
50
|
* @public
|
|
47
51
|
*/
|
|
48
52
|
export declare const cssInjector: CssInjector;
|
|
53
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-archetype-utils",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.7",
|
|
4
4
|
"description": "Utilities for x-archetype",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@empathyco/x-deep-merge": "^2.0.3-alpha.4",
|
|
48
|
-
"@empathyco/x-utils": "^1.0.3-alpha.
|
|
48
|
+
"@empathyco/x-utils": "^1.0.3-alpha.3",
|
|
49
49
|
"tslib": "~2.6.0",
|
|
50
50
|
"vue-i18n": "~9.14.0"
|
|
51
51
|
},
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "5af8c786e0efa0fa965d0ea8f14b76dc6b4271c9"
|
|
70
70
|
}
|