@lobehub/ui 1.95.0 → 1.95.1-beta.1

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.
Files changed (36) hide show
  1. package/README.md +32 -6
  2. package/es/ColorScales/index.d.ts +1 -1
  3. package/es/FontLoader/index.js +5 -2
  4. package/es/Giscus/style.js +1 -1
  5. package/es/Highlighter/theme.js +1 -1
  6. package/es/ThemeProvider/GlobalStyle/antdOverride.js +2 -1
  7. package/es/ThemeProvider/index.d.ts +8 -23
  8. package/es/ThemeProvider/index.js +22 -10
  9. package/es/styles/{algorithms → colors}/generateColorPalette.d.ts +1 -1
  10. package/es/styles/customTheme.js +2 -2
  11. package/es/styles/index.d.ts +6 -8
  12. package/es/styles/index.js +6 -8
  13. package/es/styles/theme/algorithms/darkAlgorithm.d.ts +2 -0
  14. package/es/styles/theme/algorithms/darkAlgorithm.js +32 -0
  15. package/es/styles/theme/algorithms/lightAlgorithm.d.ts +2 -0
  16. package/es/styles/{algorithms/generateCustomTheme.js → theme/algorithms/lightAlgorithm.js} +15 -17
  17. package/es/styles/theme/antdTheme.d.ts +15 -0
  18. package/es/styles/{algorithms/generateTheme.js → theme/antdTheme.js} +22 -16
  19. package/es/styles/{algorithms/generateCustomToken.js → theme/customToken.js} +1 -3
  20. package/es/styles/theme/{dark.js → token/dark.js} +3 -4
  21. package/es/styles/theme/{light.js → token/light.js} +3 -4
  22. package/package.json +1 -1
  23. package/es/styles/algorithms/generateCustomTheme.d.ts +0 -9
  24. package/es/styles/algorithms/generateTheme.d.ts +0 -5
  25. /package/es/styles/{colors.d.ts → colors/colors.d.ts} +0 -0
  26. /package/es/styles/{colors.js → colors/colors.js} +0 -0
  27. /package/es/styles/{algorithms → colors}/generateColorPalette.js +0 -0
  28. /package/es/styles/{neutralColors.d.ts → colors/neutralColors.d.ts} +0 -0
  29. /package/es/styles/{neutralColors.js → colors/neutralColors.js} +0 -0
  30. /package/es/styles/{algorithms/generateCustomStylish.d.ts → theme/customStylish.d.ts} +0 -0
  31. /package/es/styles/{algorithms/generateCustomStylish.js → theme/customStylish.js} +0 -0
  32. /package/es/styles/{algorithms/generateCustomToken.d.ts → theme/customToken.d.ts} +0 -0
  33. /package/es/styles/theme/{base.d.ts → token/base.d.ts} +0 -0
  34. /package/es/styles/theme/{base.js → token/base.js} +0 -0
  35. /package/es/styles/theme/{dark.d.ts → token/dark.d.ts} +0 -0
  36. /package/es/styles/theme/{light.d.ts → token/light.d.ts} +0 -0
package/README.md CHANGED
@@ -27,7 +27,7 @@ Lobe UI is an open-source UI component library for building _AIGC_ web apps
27
27
  [![][github-issues-shield]][github-issues-link]
28
28
  [![][github-license-shield]][github-license-link]
29
29
 
30
- ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268452017-960ab8a1-e4b7-4648-beb1-77daf4b6034a.png)
30
+ [![][banner]][vercel-link]
31
31
 
32
32
  </div>
33
33
 
@@ -52,7 +52,8 @@ Lobe UI is an open-source UI component library for building _AIGC_ web apps
52
52
 
53
53
  ## 📦 Installation
54
54
 
55
- This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
55
+ > **Important**\
56
+ > This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
56
57
 
57
58
  To install Lobe UI, run the following command:
58
59
 
@@ -82,6 +83,30 @@ const nextConfig = {
82
83
 
83
84
  </div>
84
85
 
86
+ ## 🤯 Usage
87
+
88
+ > **Note**\
89
+ > The LobeUI components are developed based on [Antd](https://ant.design/components/overview/), fully compatible with Antd components,
90
+ > and it is recommended to use [antd-style](https://ant-design.github.io/antd-style/) as the default css-in-js styling solution.
91
+
92
+ ```tsx
93
+ import { ThemeProvider, Button } from '@lobehub/ui'
94
+ import { Button } from 'antd'
95
+
96
+ export default () => (
97
+ <ThemeProvider>
98
+ <Button>Hello AIGC</Button>
99
+ </ThemeProvider>
100
+ )
101
+ ```
102
+
103
+ <div align="right">
104
+
105
+ [![][back-to-top]](#readme-top)
106
+
107
+ </div>
108
+
109
+
85
110
  ## ⌨️ Local Development
86
111
 
87
112
  You can use Github Codespaces for online development:
@@ -109,7 +134,7 @@ Contributions of all types are more than welcome, if you are interested in contr
109
134
 
110
135
  [![][pr-welcome-shield]][pr-welcome-link]
111
136
 
112
- [![][contributors-contrib]][contributors-url]
137
+ [![][contributors-contrib]][contributors-link]
113
138
 
114
139
  <div align="right">
115
140
 
@@ -138,18 +163,19 @@ Contributions of all types are more than welcome, if you are interested in contr
138
163
 
139
164
  </details>
140
165
 
141
- Copyright © 2023 [LobeHub][profile-url]. <br />
166
+ Copyright © 2023 [LobeHub][profile-link]. <br />
142
167
  This project is [MIT](./LICENSE) licensed.
143
168
 
144
169
  <!-- LINK GROUP -->
145
170
 
146
171
  [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
172
+ [banner]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268452017-960ab8a1-e4b7-4648-beb1-77daf4b6034a.png
147
173
  [bun-link]: https://bun.sh
148
174
  [bun-shield]: https://img.shields.io/badge/-speedup%20with%20bun-black?logo=bun&style=for-the-badge
149
175
  [codespaces-link]: https://codespaces.new/lobehub/lobe-ui
150
176
  [codespaces-shield]: https://github.com/codespaces/badge.svg
151
177
  [contributors-contrib]: https://contrib.rocks/image?repo=lobehub/lobe-ui
152
- [contributors-url]: https://github.com/lobehub/lobe-ui/graphs/contributors
178
+ [contributors-link]: https://github.com/lobehub/lobe-ui/graphs/contributors
153
179
  [discord-link]: https://discord.gg/AYFPHvv2jT
154
180
  [discord-shield]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=flat-square
155
181
  [fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-ui
@@ -180,6 +206,6 @@ This project is [MIT](./LICENSE) licensed.
180
206
  [npm-release-shield]: https://img.shields.io/npm/v/@lobehub/ui?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
181
207
  [pr-welcome-link]: https://github.com/lobehub/lobe-chat/pulls
182
208
  [pr-welcome-shield]: https://img.shields.io/badge/🤯_pr_welcome-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
183
- [profile-url]: https://github.com/lobehub
209
+ [profile-link]: https://github.com/lobehub
184
210
  [vercel-link]: https://ui.lobehub.com
185
211
  [vercel-shield]: https://img.shields.io/website?down_message=offline&label=vercel&labelColor=black&logo=vercel&style=flat-square&up_message=online&url=https%3A%2F%2Fui.lobehub.com
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ColorScaleItem } from "../styles/colors";
2
+ import { ColorScaleItem } from "../styles/colors/colors";
3
3
  export interface ColorScalesProps {
4
4
  /**
5
5
  * @description Index of the mid highlight color in the scale
@@ -1,4 +1,4 @@
1
- import { memo, useEffect } from 'react';
1
+ import { memo, useEffect, useRef } from 'react';
2
2
  var createElement = function createElement(url) {
3
3
  var element = document.createElement('link');
4
4
  element.rel = 'stylesheet';
@@ -7,10 +7,13 @@ var createElement = function createElement(url) {
7
7
  };
8
8
  var FontLoader = /*#__PURE__*/memo(function (_ref) {
9
9
  var url = _ref.url;
10
+ var loadRef = useRef(false);
10
11
  useEffect(function () {
12
+ if (loadRef.current) return;
13
+ loadRef.current = true;
11
14
  var element = createElement(url);
12
15
  document.head.append(element);
13
16
  }, []);
14
- return false;
17
+ return null;
15
18
  });
16
19
  export default FontLoader;
@@ -2,7 +2,7 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLit
2
2
  var _templateObject;
3
3
  import { css } from 'antd-style';
4
4
  import { readableColor, rgba } from 'polished';
5
- import { colorScales } from "../styles/colors";
5
+ import { colorScales } from "../styles/colors/colors";
6
6
  export var genStyles = function genStyles(token, isDarkMode) {
7
7
  var type = isDarkMode ? 'dark' : 'light';
8
8
  var colorText = colorScales.gray[type][11];
@@ -1,4 +1,4 @@
1
- import { colorScales } from "../styles/colors";
1
+ import { colorScales } from "../styles/colors/colors";
2
2
  export var themeConfig = function themeConfig(isDarkMode) {
3
3
  var type = isDarkMode ? 'dark' : 'light';
4
4
  var colorText = colorScales.gray[type][11];
@@ -1,6 +1,7 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
2
  var _templateObject;
3
3
  import { css } from 'antd-style';
4
+ import { readableColor } from 'polished';
4
5
  export default (function (token) {
5
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ant-tooltip-inner {\n display: flex;\n align-items: center;\n justify-content: center;\n\n min-height: unset;\n padding: 4px 8px;\n\n color: ", " !important;\n\n background-color: ", " !important;\n border-radius: ", "px !important;\n }\n\n .ant-tooltip-arrow {\n &::before,\n &::after {\n background: ", " !important;\n }\n }\n\n .ant-switch-handle::before {\n background: ", " !important;\n }\n"])), token.colorBgLayout, token.colorText, token.borderRadiusSM, token.colorText, token.colorBgContainer);
6
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ant-btn-primary {\n color: ", " !important;\n }\n\n .ant-tooltip-inner {\n display: flex;\n align-items: center;\n justify-content: center;\n\n min-height: unset;\n padding: 4px 8px;\n\n color: ", " !important;\n\n background-color: ", " !important;\n border-radius: ", "px !important;\n }\n\n .ant-tooltip-arrow {\n &::before,\n &::after {\n background: ", " !important;\n }\n }\n\n .ant-switch-handle::before {\n background: ", " !important;\n }\n"])), readableColor(token.colorPrimary), token.colorBgLayout, token.colorText, token.borderRadiusSM, token.colorText, token.colorBgContainer);
6
7
  });
@@ -1,21 +1,14 @@
1
- import { type ThemeMode, extractStaticStyle } from 'antd-style';
2
- import type { CustomStylishParams, CustomTokenParams } from 'antd-style/lib/types/function';
3
- import { type ReactNode } from 'react';
4
- export interface ThemeProviderProps {
5
- /**
6
- * @description Cache for the extracted static styles
7
- */
8
- cache?: typeof extractStaticStyle.cache;
9
- /**
10
- * @description The children of the ThemeProvider component
11
- */
12
- children: ReactNode;
13
- /**
14
- * @description Custom stylish
15
- */
1
+ /// <reference types="react" />
2
+ import { ThemeProviderProps as AntdThemeProviderProps, CustomStylishParams, CustomTokenParams } from 'antd-style';
3
+ import { NeutralColors, PrimaryColors } from "../styles";
4
+ export interface ThemeProviderProps extends Omit<AntdThemeProviderProps<any>, 'theme'> {
16
5
  customStylish?: (theme: CustomStylishParams) => {
17
6
  [key: string]: any;
18
7
  };
8
+ customTheme?: {
9
+ neutralColor?: NeutralColors;
10
+ primaryColor?: PrimaryColors;
11
+ };
19
12
  /**
20
13
  * @description Custom extra token
21
14
  */
@@ -23,14 +16,6 @@ export interface ThemeProviderProps {
23
16
  [key: string]: any;
24
17
  };
25
18
  enableWebfonts?: boolean;
26
- /**
27
- * @description Whether to inline the styles on server-side rendering or not
28
- */
29
- ssrInline?: boolean;
30
- /**
31
- * @description The mode of the theme (light or dark)
32
- */
33
- themeMode?: ThemeMode;
34
19
  /**
35
20
  * @description Webfont loader css strings
36
21
  */
@@ -1,4 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["children", "customStylish", "customToken", "enableWebfonts", "webfonts", "customTheme"];
2
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
5
  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
6
  import { App } from 'antd';
@@ -7,19 +9,22 @@ import { memo, useCallback, useEffect } from 'react';
7
9
  import { ThemeContext } from 'styled-components';
8
10
  import { useCdnFn } from "../ConfigProvider";
9
11
  import FontLoader from "../FontLoader";
10
- import { lobeCustomStylish, lobeCustomToken, lobeTheme } from "../styles";
12
+ import { lobeCustomStylish, lobeCustomToken } from "../styles";
13
+ import { createLobeAntdTheme } from "../styles/theme/antdTheme";
11
14
  import GlobalStyle from "./GlobalStyle";
12
15
  import { jsx as _jsx } from "react/jsx-runtime";
13
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
14
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
15
18
  var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
16
19
  var children = _ref.children,
17
- themeMode = _ref.themeMode,
18
20
  customStylish = _ref.customStylish,
19
21
  customToken = _ref.customToken,
20
22
  _ref$enableWebfonts = _ref.enableWebfonts,
21
23
  enableWebfonts = _ref$enableWebfonts === void 0 ? true : _ref$enableWebfonts,
22
- webfonts = _ref.webfonts;
24
+ webfonts = _ref.webfonts,
25
+ _ref$customTheme = _ref.customTheme,
26
+ customTheme = _ref$customTheme === void 0 ? {} : _ref$customTheme,
27
+ res = _objectWithoutProperties(_ref, _excluded);
23
28
  var genCdnUrl = useCdnFn();
24
29
  var webfontUrls = webfonts || [genCdnUrl({
25
30
  path: 'css/index.css',
@@ -49,18 +54,25 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
49
54
  var token = useCallback(function (theme) {
50
55
  return _objectSpread(_objectSpread({}, lobeCustomToken(theme)), customToken === null || customToken === void 0 ? void 0 : customToken(theme));
51
56
  }, [customToken]);
57
+ var theme = useCallback(function (appearance) {
58
+ return createLobeAntdTheme({
59
+ appearance: appearance,
60
+ neutralColor: customTheme.neutralColor,
61
+ primaryColor: customTheme.primaryColor
62
+ });
63
+ }, [customTheme.primaryColor, customTheme.neutralColor]);
52
64
  return /*#__PURE__*/_jsxs(_Fragment, {
53
- children: [enableWebfonts && (webfontUrls === null || webfontUrls === void 0 ? void 0 : webfontUrls.length) > 0 && webfontUrls.map(function (webfont, index) {
65
+ children: [enableWebfonts && (webfontUrls === null || webfontUrls === void 0 ? void 0 : webfontUrls.length) > 0 && webfontUrls.map(function (webfont) {
54
66
  return /*#__PURE__*/_jsx(FontLoader, {
55
67
  url: webfont
56
- }, index);
68
+ }, webfont);
57
69
  }), /*#__PURE__*/_jsx(StyleProvider, {
58
70
  speedy: process.env.NODE_ENV === 'production',
59
- children: /*#__PURE__*/_jsxs(AntdThemeProvider, {
71
+ children: /*#__PURE__*/_jsxs(AntdThemeProvider, _objectSpread(_objectSpread({
60
72
  customStylish: stylish,
61
- customToken: token,
62
- theme: lobeTheme,
63
- themeMode: themeMode,
73
+ customToken: token
74
+ }, res), {}, {
75
+ theme: theme,
64
76
  children: [/*#__PURE__*/_jsx(GlobalStyle, {}), /*#__PURE__*/_jsx(App, {
65
77
  style: {
66
78
  minHeight: 'inherit',
@@ -68,7 +80,7 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
68
80
  },
69
81
  children: children
70
82
  })]
71
- })
83
+ }))
72
84
  })]
73
85
  });
74
86
  });
@@ -1,5 +1,5 @@
1
1
  import { AliasToken } from 'antd/es/theme/interface';
2
- import { ColorScaleItem } from "../colors";
2
+ import { ColorScaleItem } from "./colors";
3
3
  export declare const generateColorPalette: ({ type, scale, appearance, }: {
4
4
  appearance: 'light' | 'dark';
5
5
  scale: ColorScaleItem;
@@ -1,5 +1,5 @@
1
- import { colorScales } from "./colors";
2
- import { neutralColorScales } from "./neutralColors";
1
+ import { colorScales } from "./colors/colors";
2
+ import { neutralColorScales } from "./colors/neutralColors";
3
3
  export var primaryColors = {
4
4
  blue: colorScales.blue.dark[9],
5
5
  cyan: colorScales.cyan.dark[9],
@@ -1,9 +1,7 @@
1
- export { generateColorNeutralPalette, generateColorPalette, } from './algorithms/generateColorPalette';
2
- export { generateCustomStylish as lobeCustomStylish } from './algorithms/generateCustomStylish';
3
- export { generateCustomTheme as lobeCustomTheme } from './algorithms/generateCustomTheme';
4
- export { generateCustomToken as lobeCustomToken } from './algorithms/generateCustomToken';
5
- export { generateTheme as lobeTheme } from './algorithms/generateTheme';
6
- export { colorScales as colors } from './colors';
7
- export { colorScales } from './colors';
1
+ export { colorScales as colors } from './colors/colors';
2
+ export { colorScales } from './colors/colors';
3
+ export { generateColorNeutralPalette, generateColorPalette } from './colors/generateColorPalette';
4
+ export { neutralColorScales } from './colors/neutralColors';
8
5
  export * from './customTheme';
9
- export { neutralColorScales } from './neutralColors';
6
+ export { generateCustomStylish as lobeCustomStylish } from './theme/customStylish';
7
+ export { generateCustomToken as lobeCustomToken } from './theme/customToken';
@@ -1,9 +1,7 @@
1
- export { generateColorNeutralPalette, generateColorPalette } from "./algorithms/generateColorPalette";
2
- export { generateCustomStylish as lobeCustomStylish } from "./algorithms/generateCustomStylish";
3
- export { generateCustomTheme as lobeCustomTheme } from "./algorithms/generateCustomTheme";
4
- export { generateCustomToken as lobeCustomToken } from "./algorithms/generateCustomToken";
5
- export { generateTheme as lobeTheme } from "./algorithms/generateTheme";
6
- export { colorScales as colors } from "./colors";
7
- export { colorScales } from "./colors";
1
+ export { colorScales as colors } from "./colors/colors";
2
+ export { colorScales } from "./colors/colors";
3
+ export { generateColorNeutralPalette, generateColorPalette } from "./colors/generateColorPalette";
4
+ export { neutralColorScales } from "./colors/neutralColors";
8
5
  export * from "./customTheme";
9
- export { neutralColorScales } from "./neutralColors";
6
+ export { generateCustomStylish as lobeCustomStylish } from "./theme/customStylish";
7
+ export { generateCustomToken as lobeCustomToken } from "./theme/customToken";
@@ -0,0 +1,2 @@
1
+ import { MappingAlgorithm } from 'antd/es/theme/interface';
2
+ export declare const darkAlgorithm: MappingAlgorithm;
@@ -0,0 +1,32 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
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
+ import { generateColorNeutralPalette, generateColorPalette, neutralColorScales } from "../..";
5
+ import { colorScales } from "../../colors/colors";
6
+ import darkBaseToken from "../token/dark";
7
+ export var darkAlgorithm = function darkAlgorithm(seedToken, mapToken) {
8
+ var primaryColor = seedToken.primaryColor;
9
+ var neutralColor = seedToken.neutralColor;
10
+ var primaryTokens = {};
11
+ var neutralTokens = {};
12
+
13
+ // generate primary color Token with colorPrimary
14
+ var primaryScale = colorScales[primaryColor];
15
+ if (primaryScale) {
16
+ primaryTokens = generateColorPalette({
17
+ appearance: 'dark',
18
+ scale: primaryScale,
19
+ type: 'Primary'
20
+ });
21
+ }
22
+
23
+ // generate neutral color Token with colorBgBase
24
+ var neutralScale = neutralColorScales[neutralColor];
25
+ if (neutralScale) {
26
+ neutralTokens = generateColorNeutralPalette({
27
+ appearance: 'dark',
28
+ scale: neutralScale
29
+ });
30
+ }
31
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, mapToken), darkBaseToken), primaryTokens), neutralTokens);
32
+ };
@@ -0,0 +1,2 @@
1
+ import { MappingAlgorithm } from 'antd/es/theme/interface';
2
+ export declare const lightAlgorithm: MappingAlgorithm;
@@ -1,30 +1,28 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
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
- import { colorScales } from "../colors";
5
- import { neutralColorScales } from "../neutralColors";
6
- import { generateColorNeutralPalette, generateColorPalette } from "./generateColorPalette";
7
- export var generateCustomTheme = function generateCustomTheme(_ref) {
8
- var primaryColor = _ref.primaryColor,
9
- neutralColor = _ref.neutralColor,
10
- isDarkMode = _ref.isDarkMode;
11
- var appearance = isDarkMode ? 'dark' : 'light';
4
+ import { generateColorNeutralPalette, generateColorPalette, neutralColorScales } from "../..";
5
+ import { colorScales } from "../../colors/colors";
6
+ import lightBaseToken from "../token/light";
7
+ export var lightAlgorithm = function lightAlgorithm(seedToken, mapToken) {
8
+ var primaryColor = seedToken.colorPrimary;
9
+ var neutralColor = seedToken.colorBgBase;
12
10
  var primaryTokens = {};
13
11
  var neutralTokens = {};
14
- if (primaryColor) {
15
- var scale = colorScales[primaryColor];
12
+ var primaryScale = colorScales[primaryColor];
13
+ if (primaryScale) {
16
14
  primaryTokens = generateColorPalette({
17
- appearance: appearance,
18
- scale: scale,
15
+ appearance: 'light',
16
+ scale: primaryScale,
19
17
  type: 'Primary'
20
18
  });
21
19
  }
22
- if (neutralColor) {
23
- var _scale = neutralColorScales[neutralColor];
20
+ var neutralScale = neutralColorScales[neutralColor];
21
+ if (neutralScale) {
24
22
  neutralTokens = generateColorNeutralPalette({
25
- appearance: appearance,
26
- scale: _scale
23
+ appearance: 'light',
24
+ scale: neutralScale
27
25
  });
28
26
  }
29
- return _objectSpread(_objectSpread({}, primaryTokens), neutralTokens);
27
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, mapToken), lightBaseToken), primaryTokens), neutralTokens);
30
28
  };
@@ -0,0 +1,15 @@
1
+ import { ThemeConfig } from 'antd';
2
+ import { ThemeAppearance } from 'antd-style';
3
+ import { NeutralColors, PrimaryColors } from "..";
4
+ export interface LobeAntdThemeParams {
5
+ appearance: ThemeAppearance;
6
+ neutralColor?: NeutralColors;
7
+ primaryColor?: PrimaryColors;
8
+ }
9
+ /**
10
+ * create A LobeHub Style Antd Theme Object
11
+ * @param neutralColor
12
+ * @param appearance
13
+ * @param primaryColor
14
+ */
15
+ export declare const createLobeAntdTheme: ({ neutralColor, appearance, primaryColor, }: LobeAntdThemeParams) => ThemeConfig;
@@ -1,20 +1,26 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
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
- import darkBaseToken from "../theme/dark";
5
- import lightBaseToken from "../theme/light";
6
- export var lightTheme = {
7
- algorithm: function algorithm(seedToken, mapToken) {
8
- return _objectSpread(_objectSpread({}, mapToken), lightBaseToken);
9
- },
10
- token: lightBaseToken
11
- };
12
- export var darkTheme = {
13
- algorithm: function algorithm(seedToken, mapToken) {
14
- return _objectSpread(_objectSpread({}, mapToken), darkBaseToken);
15
- },
16
- token: darkBaseToken
17
- };
18
- export var generateTheme = function generateTheme(appearance) {
19
- return appearance === 'dark' ? darkTheme : lightTheme;
4
+ import { darkAlgorithm } from "./algorithms/darkAlgorithm";
5
+ import { lightAlgorithm } from "./algorithms/lightAlgorithm";
6
+ import { baseToken } from "./token/base";
7
+ /**
8
+ * create A LobeHub Style Antd Theme Object
9
+ * @param neutralColor
10
+ * @param appearance
11
+ * @param primaryColor
12
+ */
13
+ export var createLobeAntdTheme = function createLobeAntdTheme(_ref) {
14
+ var neutralColor = _ref.neutralColor,
15
+ appearance = _ref.appearance,
16
+ primaryColor = _ref.primaryColor;
17
+ var isDark = appearance === 'dark';
18
+ return {
19
+ algorithm: isDark ? darkAlgorithm : lightAlgorithm,
20
+ token: _objectSpread(_objectSpread({}, baseToken), {}, {
21
+ // @ts-ignore
22
+ neutralColor: neutralColor,
23
+ primaryColor: primaryColor
24
+ })
25
+ };
20
26
  };
@@ -6,7 +6,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
6
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
8
  import { camelCase } from 'lodash-es';
9
- import { colorScales } from "../colors";
9
+ import { colorScales } from "../colors/colors";
10
10
  var generateColorPalette = function generateColorPalette(_ref) {
11
11
  var _ref2;
12
12
  var name = _ref.name,
@@ -55,8 +55,6 @@ var generateCustomColorPalette = function generateCustomColorPalette(_ref3) {
55
55
  scale: scale
56
56
  }));
57
57
  };
58
-
59
- // @ts-ignore
60
58
  export var generateCustomToken = function generateCustomToken(_ref4) {
61
59
  var isDarkMode = _ref4.isDarkMode;
62
60
  var colorCustomToken = {};
@@ -1,9 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
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
- import { generateColorNeutralPalette, generateColorPalette } from "../algorithms/generateColorPalette";
5
- import { colorScales } from "../colors";
6
- import { baseToken } from "./base";
4
+ import { generateColorNeutralPalette, generateColorPalette } from "../../colors/generateColorPalette";
5
+ import { colorScales } from "../../colors/colors";
7
6
  var primaryToken = generateColorPalette({
8
7
  appearance: 'dark',
9
8
  scale: colorScales.bnw,
@@ -33,7 +32,7 @@ var infoToken = generateColorPalette({
33
32
  scale: colorScales.blue,
34
33
  type: 'Info'
35
34
  });
36
- var darkBaseToken = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseToken), primaryToken), neutralToken), successToken), warningToken), errorToken), infoToken), {}, {
35
+ var darkBaseToken = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, primaryToken), neutralToken), successToken), warningToken), errorToken), infoToken), {}, {
37
36
  boxShadow: '0 12px 20px 6px rgb(0 0 0 / 0.08)',
38
37
  boxShadowSecondary: '0 2px 8px 2px rgb(0 0 0 / 0.07), 0 2px 4px -1px rgb(0 0 0 / 0.04)',
39
38
  colorLink: infoToken.colorInfoText,
@@ -1,9 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
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
- import { generateColorNeutralPalette, generateColorPalette } from "../algorithms/generateColorPalette";
5
- import { colorScales } from "../colors";
6
- import { baseToken } from "./base";
4
+ import { generateColorNeutralPalette, generateColorPalette } from "../../colors/generateColorPalette";
5
+ import { colorScales } from "../../colors/colors";
7
6
  var primaryToken = generateColorPalette({
8
7
  appearance: 'light',
9
8
  scale: colorScales.bnw,
@@ -33,7 +32,7 @@ var infoToken = generateColorPalette({
33
32
  scale: colorScales.geekblue,
34
33
  type: 'Info'
35
34
  });
36
- var lightBaseToken = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseToken), primaryToken), neutralToken), successToken), warningToken), errorToken), infoToken), {}, {
35
+ var lightBaseToken = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, primaryToken), neutralToken), successToken), warningToken), errorToken), infoToken), {}, {
37
36
  boxShadow: '0 12px 20px 6px rgb(104 112 118 / 0.08)',
38
37
  boxShadowSecondary: '0 2px 8px 2px rgb(104 112 118 / 0.07), 0 2px 4px -1px rgb(104 112 118 / 0.04)',
39
38
  colorLink: infoToken.colorInfoText,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.95.0",
3
+ "version": "1.95.1-beta.1",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -1,9 +0,0 @@
1
- import { AliasToken } from 'antd/es/theme/interface';
2
- import { type NeutralColors, type PrimaryColors } from '../customTheme';
3
- interface generateCustomThemeProps {
4
- isDarkMode: boolean;
5
- neutralColor?: NeutralColors | '';
6
- primaryColor?: PrimaryColors | '';
7
- }
8
- export declare const generateCustomTheme: ({ primaryColor, neutralColor, isDarkMode, }: generateCustomThemeProps) => Partial<AliasToken>;
9
- export {};
@@ -1,5 +0,0 @@
1
- import { ThemeConfig } from 'antd';
2
- import { GetAntdTheme } from 'antd-style';
3
- export declare const lightTheme: ThemeConfig;
4
- export declare const darkTheme: ThemeConfig;
5
- export declare const generateTheme: GetAntdTheme;
File without changes
File without changes
File without changes
File without changes
File without changes