@lobehub/ui 1.151.6 → 1.152.0
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.
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { ThemeProviderProps as AntdThemeProviderProps, CustomStylishParams, CustomTokenParams } from 'antd-style';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
3
|
import { NeutralColors, PrimaryColors } from "../styles";
|
|
4
|
-
export interface ThemeProviderProps extends
|
|
4
|
+
export interface ThemeProviderProps extends AntdThemeProviderProps<any> {
|
|
5
5
|
className?: string;
|
|
6
|
+
/**
|
|
7
|
+
* @description Webfont loader css strings
|
|
8
|
+
*/
|
|
9
|
+
customFonts?: string[];
|
|
6
10
|
customStylish?: (theme: CustomStylishParams) => {
|
|
7
11
|
[key: string]: any;
|
|
8
12
|
};
|
|
@@ -16,13 +20,9 @@ export interface ThemeProviderProps extends Omit<AntdThemeProviderProps<any>, 't
|
|
|
16
20
|
customToken?: (theme: CustomTokenParams) => {
|
|
17
21
|
[key: string]: any;
|
|
18
22
|
};
|
|
23
|
+
enableCustomFonts?: boolean;
|
|
19
24
|
enableGlobalStyle?: boolean;
|
|
20
|
-
enableWebfonts?: boolean;
|
|
21
25
|
style?: CSSProperties;
|
|
22
|
-
/**
|
|
23
|
-
* @description Webfont loader css strings
|
|
24
|
-
*/
|
|
25
|
-
webfonts?: string[];
|
|
26
26
|
}
|
|
27
27
|
declare const ThemeProvider: import("react").NamedExoticComponent<ThemeProviderProps>;
|
|
28
28
|
export default ThemeProvider;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["children", "customStylish", "customToken", "
|
|
5
|
+
var _excluded = ["children", "customStylish", "customToken", "enableCustomFonts", "enableGlobalStyle", "customFonts", "customTheme", "className", "style", "theme"];
|
|
6
6
|
import { App } from 'antd';
|
|
7
7
|
import { ThemeProvider as AntdThemeProvider, StyleProvider } from 'antd-style';
|
|
8
|
+
import { merge } from 'lodash-es';
|
|
8
9
|
import { memo, useCallback } from 'react';
|
|
9
10
|
import { useCdnFn } from "../ConfigProvider";
|
|
10
11
|
import FontLoader from "../FontLoader";
|
|
@@ -18,18 +19,19 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
|
|
|
18
19
|
var children = _ref.children,
|
|
19
20
|
customStylish = _ref.customStylish,
|
|
20
21
|
customToken = _ref.customToken,
|
|
21
|
-
_ref$
|
|
22
|
-
|
|
22
|
+
_ref$enableCustomFont = _ref.enableCustomFonts,
|
|
23
|
+
enableCustomFonts = _ref$enableCustomFont === void 0 ? true : _ref$enableCustomFont,
|
|
23
24
|
_ref$enableGlobalStyl = _ref.enableGlobalStyle,
|
|
24
25
|
enableGlobalStyle = _ref$enableGlobalStyl === void 0 ? true : _ref$enableGlobalStyl,
|
|
25
|
-
|
|
26
|
+
customFonts = _ref.customFonts,
|
|
26
27
|
_ref$customTheme = _ref.customTheme,
|
|
27
28
|
customTheme = _ref$customTheme === void 0 ? {} : _ref$customTheme,
|
|
28
29
|
className = _ref.className,
|
|
29
30
|
style = _ref.style,
|
|
31
|
+
antdTheme = _ref.theme,
|
|
30
32
|
res = _objectWithoutProperties(_ref, _excluded);
|
|
31
33
|
var genCdnUrl = useCdnFn();
|
|
32
|
-
var webfontUrls =
|
|
34
|
+
var webfontUrls = customFonts || [genCdnUrl({
|
|
33
35
|
path: 'css/index.css',
|
|
34
36
|
pkg: '@lobehub/webfont-mono',
|
|
35
37
|
version: '1.0.0'
|
|
@@ -53,14 +55,15 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
|
|
|
53
55
|
return _objectSpread(_objectSpread({}, lobeCustomToken(theme)), customToken === null || customToken === void 0 ? void 0 : customToken(theme));
|
|
54
56
|
}, [customToken]);
|
|
55
57
|
var theme = useCallback(function (appearance) {
|
|
56
|
-
|
|
58
|
+
var lobeTheme = createLobeAntdTheme({
|
|
57
59
|
appearance: appearance,
|
|
58
60
|
neutralColor: customTheme.neutralColor,
|
|
59
61
|
primaryColor: customTheme.primaryColor
|
|
60
62
|
});
|
|
61
|
-
|
|
63
|
+
return merge(lobeTheme, antdTheme);
|
|
64
|
+
}, [customTheme.primaryColor, customTheme.neutralColor, antdTheme]);
|
|
62
65
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
63
|
-
children: [
|
|
66
|
+
children: [enableCustomFonts && (webfontUrls === null || webfontUrls === void 0 ? void 0 : webfontUrls.length) > 0 && webfontUrls.map(function (webfont) {
|
|
64
67
|
return /*#__PURE__*/_jsx(FontLoader, {
|
|
65
68
|
url: webfont
|
|
66
69
|
}, webfont);
|