react-admin-base-bootstrap 0.9.1 → 0.9.3
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.
|
@@ -6,15 +6,15 @@ export default function ThemeProvider({ themes, defaultTheme, children }: {
|
|
|
6
6
|
defaultTheme: any;
|
|
7
7
|
children: any;
|
|
8
8
|
}): React.JSX.Element;
|
|
9
|
-
export declare function rawCssLoader(cb: any):
|
|
9
|
+
export declare function rawCssLoader(cb: any): () => {
|
|
10
10
|
default: {
|
|
11
11
|
use: () => Promise<void>;
|
|
12
12
|
unuse: () => void;
|
|
13
13
|
};
|
|
14
|
-
}
|
|
15
|
-
export declare function urlCssLoader(link: any):
|
|
14
|
+
};
|
|
15
|
+
export declare function urlCssLoader(link: any): () => {
|
|
16
16
|
default: {
|
|
17
17
|
use: () => void;
|
|
18
18
|
unuse: () => void;
|
|
19
19
|
};
|
|
20
|
-
}
|
|
20
|
+
};
|
|
@@ -22,7 +22,7 @@ export default function ThemeProvider({ themes, defaultTheme, children }) {
|
|
|
22
22
|
const [theme, setTheme] = state;
|
|
23
23
|
const rTheme = theme || defaultTheme || 'light';
|
|
24
24
|
useEffect(function () {
|
|
25
|
-
const promise = (themes[rTheme] || themes[defaultTheme]).css()
|
|
25
|
+
const promise = Promise.resolve((themes[rTheme] || themes[defaultTheme]).css())
|
|
26
26
|
.then(css => {
|
|
27
27
|
css.default.use();
|
|
28
28
|
return css;
|
|
@@ -36,42 +36,39 @@ export default function ThemeProvider({ themes, defaultTheme, children }) {
|
|
|
36
36
|
React.createElement(ThemeContext.Provider, { value: val }, children));
|
|
37
37
|
}
|
|
38
38
|
export function rawCssLoader(cb) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
39
|
+
const styleTag = document.createElement('style');
|
|
40
|
+
let loaded = false;
|
|
41
|
+
return () => ({
|
|
42
|
+
default: {
|
|
43
|
+
use: function () {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
document.head.appendChild(styleTag);
|
|
46
|
+
if (!loaded) {
|
|
47
|
+
loaded = true;
|
|
48
|
+
const res = yield cb();
|
|
49
|
+
styleTag.innerHTML = (res === null || res === void 0 ? void 0 : res.default) || res;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
unuse: function () {
|
|
54
|
+
document.head.removeChild(styleTag);
|
|
56
55
|
}
|
|
57
|
-
}
|
|
56
|
+
}
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
59
|
export function urlCssLoader(link) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
document.head.removeChild(linkTag);
|
|
73
|
-
}
|
|
60
|
+
const linkTag = document.createElement('link');
|
|
61
|
+
linkTag.rel = 'stylesheet';
|
|
62
|
+
linkTag.type = 'text/css';
|
|
63
|
+
linkTag.href = link;
|
|
64
|
+
return () => ({
|
|
65
|
+
default: {
|
|
66
|
+
use: function () {
|
|
67
|
+
document.head.appendChild(linkTag);
|
|
68
|
+
},
|
|
69
|
+
unuse: function () {
|
|
70
|
+
document.head.removeChild(linkTag);
|
|
74
71
|
}
|
|
75
|
-
}
|
|
72
|
+
}
|
|
76
73
|
});
|
|
77
74
|
}
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ export default function ThemeProvider({ themes, defaultTheme, children }) {
|
|
|
19
19
|
const rTheme = theme || defaultTheme || 'light';
|
|
20
20
|
|
|
21
21
|
useEffect(function() {
|
|
22
|
-
const promise = (themes[rTheme] || themes[defaultTheme]).css()
|
|
22
|
+
const promise = Promise.resolve((themes[rTheme] || themes[defaultTheme]).css())
|
|
23
23
|
.then(css => {
|
|
24
24
|
css.default.use();
|
|
25
25
|
return css;
|
|
@@ -39,35 +39,37 @@ export default function ThemeProvider({ themes, defaultTheme, children }) {
|
|
|
39
39
|
</AllThemesContext.Provider>;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export
|
|
42
|
+
export function rawCssLoader(cb) {
|
|
43
43
|
const styleTag = document.createElement('style');
|
|
44
44
|
|
|
45
45
|
let loaded = false;
|
|
46
46
|
|
|
47
|
-
return {
|
|
47
|
+
return () => ({
|
|
48
48
|
default: {
|
|
49
49
|
use: async function() {
|
|
50
50
|
document.head.appendChild(styleTag);
|
|
51
51
|
|
|
52
52
|
if (!loaded) {
|
|
53
53
|
loaded = true;
|
|
54
|
-
|
|
54
|
+
|
|
55
|
+
const res = await cb();
|
|
56
|
+
styleTag.innerHTML = res?.default || res;
|
|
55
57
|
}
|
|
56
58
|
},
|
|
57
59
|
unuse: function() {
|
|
58
60
|
document.head.removeChild(styleTag);
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
};
|
|
63
|
+
});
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
export
|
|
66
|
+
export function urlCssLoader(link) {
|
|
65
67
|
const linkTag = document.createElement('link');
|
|
66
68
|
linkTag.rel = 'stylesheet';
|
|
67
69
|
linkTag.type = 'text/css';
|
|
68
70
|
linkTag.href = link;
|
|
69
71
|
|
|
70
|
-
return {
|
|
72
|
+
return () => ({
|
|
71
73
|
default: {
|
|
72
74
|
use: function() {
|
|
73
75
|
document.head.appendChild(linkTag);
|
|
@@ -76,5 +78,5 @@ export async function urlCssLoader(link) {
|
|
|
76
78
|
document.head.removeChild(linkTag);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
};
|
|
81
|
+
});
|
|
80
82
|
}
|