@lobehub/ui 1.38.1 → 1.38.2

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.
@@ -3,7 +3,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  import { App } from 'antd';
5
5
  import { ThemeProvider as AntdThemeProvider, StyleProvider, setupStyled } from 'antd-style';
6
- import { memo } from 'react';
6
+ import { memo, useCallback, useEffect } from 'react';
7
7
  import { ThemeContext } from 'styled-components';
8
8
  import FontLoader from "../FontLoader";
9
9
  import { lobeCustomStylish, lobeCustomToken, lobeTheme } from "../styles";
@@ -14,21 +14,31 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
14
14
  var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
15
15
  var children = _ref.children,
16
16
  themeMode = _ref.themeMode,
17
- _ref$customStylish = _ref.customStylish,
18
- _customStylish = _ref$customStylish === void 0 ? function () {
19
- return {};
20
- } : _ref$customStylish,
21
- _ref$customToken = _ref.customToken,
22
- _customToken = _ref$customToken === void 0 ? function () {
23
- return {};
24
- } : _ref$customToken,
17
+ customStylish = _ref.customStylish,
18
+ customToken = _ref.customToken,
25
19
  _ref$enableWebfonts = _ref.enableWebfonts,
26
20
  enableWebfonts = _ref$enableWebfonts === void 0 ? true : _ref$enableWebfonts,
27
21
  _ref$webfonts = _ref.webfonts,
28
22
  webfonts = _ref$webfonts === void 0 ? ['https://npm.elemecdn.com/@lobehub/webfont-mono/css/index.css', 'https://npm.elemecdn.com/@lobehub/webfont-harmony-sans/css/index.css', 'https://npm.elemecdn.com/@lobehub/webfont-harmony-sans-sc/css/index.css'] : _ref$webfonts;
29
- setupStyled({
30
- ThemeContext: ThemeContext
31
- });
23
+ useEffect(function () {
24
+ setupStyled({
25
+ ThemeContext: ThemeContext
26
+ });
27
+ }, []);
28
+ var stylish = useCallback(function (theme) {
29
+ var stylish = {};
30
+ if (customStylish) {
31
+ stylish = customStylish(theme);
32
+ }
33
+ return _objectSpread(_objectSpread({}, lobeCustomStylish(theme)), stylish);
34
+ }, [customStylish]);
35
+ var token = useCallback(function (theme) {
36
+ var token = {};
37
+ if (customToken) {
38
+ token = customToken(theme);
39
+ }
40
+ return _objectSpread(_objectSpread({}, lobeCustomToken(theme)), token);
41
+ }, [customToken]);
32
42
  return /*#__PURE__*/_jsxs(_Fragment, {
33
43
  children: [enableWebfonts && (webfonts === null || webfonts === void 0 ? void 0 : webfonts.length) > 0 && webfonts.map(function (webfont, index) {
34
44
  return /*#__PURE__*/_jsx(FontLoader, {
@@ -37,12 +47,8 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
37
47
  }), /*#__PURE__*/_jsx(StyleProvider, {
38
48
  speedy: process.env.NODE_ENV === 'production',
39
49
  children: /*#__PURE__*/_jsxs(AntdThemeProvider, {
40
- customStylish: function customStylish(theme) {
41
- return _objectSpread(_objectSpread({}, lobeCustomStylish(theme)), _customStylish(theme));
42
- },
43
- customToken: function customToken(theme) {
44
- return _objectSpread(_objectSpread({}, lobeCustomToken(theme)), _customToken(theme));
45
- },
50
+ customStylish: stylish,
51
+ customToken: token,
46
52
  theme: lobeTheme,
47
53
  themeMode: themeMode,
48
54
  children: [/*#__PURE__*/_jsx(GlobalStyle, {}), /*#__PURE__*/_jsx(App, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.38.1",
3
+ "version": "1.38.2",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",