@lobehub/ui 1.94.7 → 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 (47) hide show
  1. package/README.md +96 -49
  2. package/es/ColorScales/index.d.ts +1 -1
  3. package/es/ConfigProvider/index.d.ts +13 -0
  4. package/es/ConfigProvider/index.js +40 -0
  5. package/es/FluentEmoji/index.js +2 -1
  6. package/es/FontLoader/index.js +5 -2
  7. package/es/Giscus/style.js +1 -1
  8. package/es/Highlighter/theme.js +1 -1
  9. package/es/Logo/index.js +5 -3
  10. package/es/Logo/style.d.ts +10 -2
  11. package/es/Logo/style.js +4 -5
  12. package/es/ThemeProvider/GlobalStyle/antdOverride.js +2 -1
  13. package/es/ThemeProvider/Meta.js +2 -1
  14. package/es/ThemeProvider/index.d.ts +8 -23
  15. package/es/ThemeProvider/index.js +41 -28
  16. package/es/index.d.ts +1 -0
  17. package/es/index.js +1 -0
  18. package/es/styles/{algorithms → colors}/generateColorPalette.d.ts +1 -1
  19. package/es/styles/customTheme.js +2 -2
  20. package/es/styles/index.d.ts +6 -8
  21. package/es/styles/index.js +6 -8
  22. package/es/styles/theme/algorithms/darkAlgorithm.d.ts +2 -0
  23. package/es/styles/theme/algorithms/darkAlgorithm.js +32 -0
  24. package/es/styles/theme/algorithms/lightAlgorithm.d.ts +2 -0
  25. package/es/styles/{algorithms/generateCustomTheme.js → theme/algorithms/lightAlgorithm.js} +15 -17
  26. package/es/styles/theme/antdTheme.d.ts +15 -0
  27. package/es/styles/{algorithms/generateTheme.js → theme/antdTheme.js} +22 -16
  28. package/es/styles/{algorithms/generateCustomToken.js → theme/customToken.js} +1 -3
  29. package/es/styles/theme/{dark.js → token/dark.js} +3 -4
  30. package/es/styles/theme/{light.js → token/light.js} +3 -4
  31. package/es/utils/genCdnUrl.d.ts +1 -2
  32. package/es/utils/genCdnUrl.js +11 -2
  33. package/package.json +3 -2
  34. package/es/styles/algorithms/generateCustomTheme.d.ts +0 -9
  35. package/es/styles/algorithms/generateTheme.d.ts +0 -5
  36. /package/es/styles/{colors.d.ts → colors/colors.d.ts} +0 -0
  37. /package/es/styles/{colors.js → colors/colors.js} +0 -0
  38. /package/es/styles/{algorithms → colors}/generateColorPalette.js +0 -0
  39. /package/es/styles/{neutralColors.d.ts → colors/neutralColors.d.ts} +0 -0
  40. /package/es/styles/{neutralColors.js → colors/neutralColors.js} +0 -0
  41. /package/es/styles/{algorithms/generateCustomStylish.d.ts → theme/customStylish.d.ts} +0 -0
  42. /package/es/styles/{algorithms/generateCustomStylish.js → theme/customStylish.js} +0 -0
  43. /package/es/styles/{algorithms/generateCustomToken.d.ts → theme/customToken.d.ts} +0 -0
  44. /package/es/styles/theme/{base.d.ts → token/base.d.ts} +0 -0
  45. /package/es/styles/theme/{base.js → token/base.js} +0 -0
  46. /package/es/styles/theme/{dark.d.ts → token/dark.d.ts} +0 -0
  47. /package/es/styles/theme/{light.d.ts → token/light.d.ts} +0 -0
package/README.md CHANGED
@@ -10,20 +10,24 @@
10
10
 
11
11
  Lobe UI is an open-source UI component library for building _AIGC_ web apps
12
12
 
13
- [Changelog](./CHANGELOG.md) · [Report Bug][issues-url] · [Request Feature][issues-url]
13
+ [Changelog](./CHANGELOG.md) · [Report Bug][github-issues-link] · [Request Feature][github-issues-link]
14
14
 
15
15
  <!-- SHIELD GROUP -->
16
16
 
17
- [![release][release-shield]][release-url]
18
- [![releaseDate][release-date-shield]][release-date-url]
19
- [![ciTest][ci-test-shield]][ci-test-url]
20
- [![ciRelease][ci-release-shield]][ci-release-url] <br/>
21
- [![contributors][contributors-shield]][contributors-url]
22
- [![forks][forks-shield]][forks-url]
23
- [![stargazers][stargazers-shield]][stargazers-url]
24
- [![issues][issues-shield]][issues-url]
25
-
26
- ![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
17
+ [![][npm-release-shield]][npm-release-link]
18
+ [![][vercel-shield]][vercel-link]
19
+ [![][discord-shield]][discord-link]
20
+ [![][npm-downloads-shield]][npm-downloads-link]
21
+ [![][github-releasedate-shield]][github-releasedate-link]
22
+ [![][github-action-test-shield]][github-action-test-link]
23
+ [![][github-action-release-shield]][github-action-release-link]<br/>
24
+ [![][github-contributors-shield]][github-contributors-link]
25
+ [![][github-forks-shield]][github-forks-link]
26
+ [![][github-stars-shield]][github-stars-link]
27
+ [![][github-issues-shield]][github-issues-link]
28
+ [![][github-license-shield]][github-license-link]
29
+
30
+ [![][banner]][vercel-link]
27
31
 
28
32
  </div>
29
33
 
@@ -34,8 +38,6 @@ Lobe UI is an open-source UI component library for building _AIGC_ web apps
34
38
 
35
39
  - [📦 Installation](#-installation)
36
40
 
37
- - [🤯 Usage](#-usage)
38
-
39
41
  - [Compile with NextJS](#compile-with-nextjs)
40
42
 
41
43
  - [⌨️ Local Development](#️-local-development)
@@ -50,25 +52,21 @@ Lobe UI is an open-source UI component library for building _AIGC_ web apps
50
52
 
51
53
  ## 📦 Installation
52
54
 
53
- 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).
54
57
 
55
58
  To install Lobe UI, run the following command:
56
59
 
60
+ [![][bun-shield]][bun-link]
61
+
57
62
  ```bash
58
- pnpm i -S @lobehub/ui
63
+ $ bun add @lobehub/ui
59
64
  ```
60
65
 
61
- <div align="right">
62
-
63
- [![][back-to-top]](#readme-top)
64
-
65
- </div>
66
-
67
- ## 🤯 Usage
68
-
69
66
  ### Compile with NextJS
70
67
 
71
- by work correct with nextjs ssr, add `transpilePackages: ['@lobehub/ui']` to `next.config.js`. For example:
68
+ > **Note**\
69
+ > By work correct with nextjs ssr, add `transpilePackages: ['@lobehub/ui']` to `next.config.js`. For example:
72
70
 
73
71
  ```js
74
72
  // next.config.js
@@ -85,19 +83,43 @@ const nextConfig = {
85
83
 
86
84
  </div>
87
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
+
88
110
  ## ⌨️ Local Development
89
111
 
90
- You can use Gitpod for online development:
112
+ You can use Github Codespaces for online development:
91
113
 
92
- [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)][gitpod-url]
114
+ [![][codespaces-shield]][codespaces-link]
93
115
 
94
116
  Or clone it for local development:
95
117
 
96
118
  ```bash
97
119
  $ git clone https://github.com/lobehub/lobe-ui.git
98
120
  $ cd lobe-ui
99
- $ pnpm install
100
- $ pnpm start
121
+ $ bun install
122
+ $ bun start
101
123
  ```
102
124
 
103
125
  <div align="right">
@@ -108,7 +130,11 @@ $ pnpm start
108
130
 
109
131
  ## 🤝 Contributing
110
132
 
111
- [![][contributors-contrib]][contributors-url]
133
+ Contributions of all types are more than welcome, if you are interested in contributing code, feel free to check out our GitHub [Issues][github-issues-link] to get stuck in to show us what you’re made of.
134
+
135
+ [![][pr-welcome-shield]][pr-welcome-link]
136
+
137
+ [![][contributors-contrib]][contributors-link]
112
138
 
113
139
  <div align="right">
114
140
 
@@ -131,34 +157,55 @@ $ pnpm start
131
157
 
132
158
  ---
133
159
 
134
- #### 📝 License
160
+ <details><summary><h4>📝 License</h4></summary>
161
+
162
+ [![][fossa-license-shield]][fossa-license-link]
163
+
164
+ </details>
135
165
 
136
- Copyright © 2023 [LobeHub][profile-url]. <br />
166
+ Copyright © 2023 [LobeHub][profile-link]. <br />
137
167
  This project is [MIT](./LICENSE) licensed.
138
168
 
139
169
  <!-- LINK GROUP -->
140
170
 
141
171
  [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
142
- [ci-release-shield]: https://github.com/lobehub/lobe-ui/workflows/Release%20CI/badge.svg
143
- [ci-release-url]: https://github.com/lobehub/lobe-ui/actions?query=workflow%3ARelease%20CI
144
- [ci-test-shield]: https://github.com/lobehub/lobe-ui/workflows/Test%20CI/badge.svg
145
- [ci-test-url]: https://github.com/lobehub/lobe-ui/actions?query=workflow%3ATest%20CI
172
+ [banner]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268452017-960ab8a1-e4b7-4648-beb1-77daf4b6034a.png
173
+ [bun-link]: https://bun.sh
174
+ [bun-shield]: https://img.shields.io/badge/-speedup%20with%20bun-black?logo=bun&style=for-the-badge
175
+ [codespaces-link]: https://codespaces.new/lobehub/lobe-ui
176
+ [codespaces-shield]: https://github.com/codespaces/badge.svg
146
177
  [contributors-contrib]: https://contrib.rocks/image?repo=lobehub/lobe-ui
147
- [contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-ui.svg?style=flat
148
- [contributors-url]: https://github.com/lobehub/lobe-ui/graphs/contributors
149
- [forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-ui.svg?style=flat
150
- [forks-url]: https://github.com/lobehub/lobe-ui/network/members
151
- [gitpod-url]: https://gitpod.io/#https://github.com/lobehub/lobe-ui
152
- [issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-ui.svg?style=flat
153
- [issues-url]: https://github.com/lobehub/lobe-ui/issues/new/choose
178
+ [contributors-link]: https://github.com/lobehub/lobe-ui/graphs/contributors
179
+ [discord-link]: https://discord.gg/AYFPHvv2jT
180
+ [discord-shield]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=flat-square
181
+ [fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-ui
182
+ [fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-ui.svg?type=large
183
+ [github-action-release-link]: https://github.com/actions/workflows/lobehub/lobe-ui/release.yml
184
+ [github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-ui/release.yml?label=release&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
185
+ [github-action-test-link]: https://github.com/actions/workflows/lobehub/lobe-ui/test.yml
186
+ [github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-ui/test.yml?label=test&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
187
+ [github-contributors-link]: https://github.com/lobehub/lobe-ui/graphs/contributors
188
+ [github-contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-ui?color=c4f042&labelColor=black&style=flat-square
189
+ [github-forks-link]: https://github.com/lobehub/lobe-ui/network/members
190
+ [github-forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-ui?color=8ae8ff&labelColor=black&style=flat-square
191
+ [github-issues-link]: https://github.com/lobehub/lobe-ui/issues
192
+ [github-issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-ui?color=ff80eb&labelColor=black&style=flat-square
193
+ [github-license-link]: https://github.com/lobehub/lobe-ui/blob/master/LICENSE
194
+ [github-license-shield]: https://img.shields.io/github/license/lobehub/lobe-ui?color=white&labelColor=black&style=flat-square
195
+ [github-releasedate-link]: https://github.com/lobehub/lobe-ui/releases
196
+ [github-releasedate-shield]: https://img.shields.io/github/release-date/lobehub/lobe-ui?labelColor=black&style=flat-square
197
+ [github-stars-link]: https://github.com/lobehub/lobe-ui/network/stargazers
198
+ [github-stars-shield]: https://img.shields.io/github/stars/lobehub/lobe-ui?color=ffcb47&labelColor=black&style=flat-square
154
199
  [lobe-chat]: https://github.com/lobehub/lobe-chat
155
200
  [lobe-commit]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-commit
156
201
  [lobe-i18n]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-i18n
157
202
  [lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
158
- [profile-url]: https://github.com/lobehub
159
- [release-date-shield]: https://img.shields.io/github/release-date/lobehub/lobe-ui?style=flat
160
- [release-date-url]: https://github.com/lobehub/lobe-ui/releases
161
- [release-shield]: https://img.shields.io/npm/v/@lobehub/ui?label=%F0%9F%A4%AF%20NPM
162
- [release-url]: https://www.npmjs.com/package/@lobehub/ui
163
- [stargazers-shield]: https://img.shields.io/github/stars/lobehub/lobe-ui.svg?style=flat
164
- [stargazers-url]: https://github.com/lobehub/lobe-ui/stargazers
203
+ [npm-downloads-link]: https://www.npmjs.com/package/@lobehub/ui
204
+ [npm-downloads-shield]: https://img.shields.io/npm/dt/@lobehub/ui?labelColor=black&style=flat-square
205
+ [npm-release-link]: https://www.npmjs.com/package/@lobehub/ui
206
+ [npm-release-shield]: https://img.shields.io/npm/v/@lobehub/ui?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
207
+ [pr-welcome-link]: https://github.com/lobehub/lobe-chat/pulls
208
+ [pr-welcome-shield]: https://img.shields.io/badge/🤯_pr_welcome-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
209
+ [profile-link]: https://github.com/lobehub
210
+ [vercel-link]: https://ui.lobehub.com
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
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ import { CDN, CdnApi } from "../utils/genCdnUrl";
3
+ type CdnFn = ({ pkg, version, path }: CdnApi) => string;
4
+ export interface Config {
5
+ customCdnFn?: CdnFn;
6
+ proxy: CDN | 'custom';
7
+ }
8
+ declare const ConfigProvider: import("react").NamedExoticComponent<{
9
+ children: ReactNode;
10
+ config: Config;
11
+ }>;
12
+ export declare const useCdnFn: () => CdnFn;
13
+ export default ConfigProvider;
@@ -0,0 +1,40 @@
1
+ import { createContext, memo, useContext } from 'react';
2
+ import { genCdnUrl } from "../utils/genCdnUrl";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ var ConfigContext = /*#__PURE__*/createContext(null);
5
+ var ConfigProvider = /*#__PURE__*/memo(function (_ref) {
6
+ var children = _ref.children,
7
+ config = _ref.config;
8
+ return /*#__PURE__*/_jsx(ConfigContext.Provider, {
9
+ value: config,
10
+ children: children
11
+ });
12
+ });
13
+ var fallback = function fallback(_ref2) {
14
+ var pkg = _ref2.pkg,
15
+ version = _ref2.version,
16
+ path = _ref2.path;
17
+ return genCdnUrl({
18
+ path: path,
19
+ pkg: pkg,
20
+ proxy: 'aliyun',
21
+ version: version
22
+ });
23
+ };
24
+ export var useCdnFn = function useCdnFn() {
25
+ var config = useContext(ConfigContext);
26
+ if (!config) return fallback;
27
+ if (config.proxy !== 'custom') return function (_ref3) {
28
+ var pkg = _ref3.pkg,
29
+ version = _ref3.version,
30
+ path = _ref3.path;
31
+ return genCdnUrl({
32
+ path: path,
33
+ pkg: pkg,
34
+ proxy: config.proxy,
35
+ version: version
36
+ });
37
+ };
38
+ return (config === null || config === void 0 ? void 0 : config.customCdnFn) || fallback;
39
+ };
40
+ export default ConfigProvider;
@@ -4,7 +4,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
4
4
  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; }
5
5
  import { kebabCase } from 'lodash-es';
6
6
  import { memo, useMemo, useState } from 'react';
7
- import { genCdnUrl } from "../utils/genCdnUrl";
7
+ import { useCdnFn } from "../ConfigProvider";
8
8
  import { getEmojiNameByCharacter } from "../utils/getEmojiByCharacter";
9
9
  import { useStyles } from "./style";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -16,6 +16,7 @@ var FluentEmoji = /*#__PURE__*/memo(function (_ref) {
16
16
  type = _ref$type === void 0 ? '3d' : _ref$type,
17
17
  _ref$size = _ref.size,
18
18
  size = _ref$size === void 0 ? 40 : _ref$size;
19
+ var genCdnUrl = useCdnFn();
19
20
  var _useState = useState(false),
20
21
  _useState2 = _slicedToArray(_useState, 2),
21
22
  loadingFail = _useState2[0],
@@ -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];
package/es/Logo/index.js CHANGED
@@ -6,6 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
  import { useTheme } from 'antd-style';
7
7
  import { memo } from 'react';
8
8
  import { Flexbox } from 'react-layout-kit';
9
+ import { useCdnFn } from "../ConfigProvider";
9
10
  import Divider from "./Divider";
10
11
  import LogoHighContrast from "./LogoHighContrast";
11
12
  import LogoText from "./LogoText";
@@ -22,6 +23,7 @@ var Logo = /*#__PURE__*/memo(function (_ref) {
22
23
  extra = _ref.extra,
23
24
  className = _ref.className,
24
25
  props = _objectWithoutProperties(_ref, _excluded);
26
+ var genCdnUrl = useCdnFn();
25
27
  var theme = useTheme();
26
28
  var _useStyles = useStyles(),
27
29
  styles = _useStyles.styles;
@@ -31,7 +33,7 @@ var Logo = /*#__PURE__*/memo(function (_ref) {
31
33
  {
32
34
  logoComponent = /*#__PURE__*/_jsx("img", _objectSpread({
33
35
  alt: "lobehub",
34
- src: LOGO_3D,
36
+ src: genCdnUrl(LOGO_3D),
35
37
  style: _objectSpread({
36
38
  height: size,
37
39
  width: size
@@ -43,7 +45,7 @@ var Logo = /*#__PURE__*/memo(function (_ref) {
43
45
  {
44
46
  logoComponent = /*#__PURE__*/_jsx("img", {
45
47
  alt: "lobehub",
46
- src: LOGO_FLAT,
48
+ src: genCdnUrl(LOGO_FLAT),
47
49
  style: _objectSpread({
48
50
  height: size,
49
51
  width: size
@@ -77,7 +79,7 @@ var Logo = /*#__PURE__*/memo(function (_ref) {
77
79
  logoComponent = /*#__PURE__*/_jsxs(_Fragment, {
78
80
  children: [/*#__PURE__*/_jsx("img", {
79
81
  alt: "lobehub",
80
- src: LOGO_3D,
82
+ src: genCdnUrl(LOGO_3D),
81
83
  style: {
82
84
  height: size,
83
85
  width: size
@@ -1,5 +1,13 @@
1
- export declare const LOGO_3D: string;
2
- export declare const LOGO_FLAT: string;
1
+ export declare const LOGO_3D: {
2
+ path: string;
3
+ pkg: string;
4
+ version: string;
5
+ };
6
+ export declare const LOGO_FLAT: {
7
+ path: string;
8
+ pkg: string;
9
+ version: string;
10
+ };
3
11
  export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
4
12
  extraTitle: import("antd-style").SerializedStyles;
5
13
  }>;
package/es/Logo/style.js CHANGED
@@ -1,17 +1,16 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
2
  var _templateObject;
3
3
  import { createStyles } from 'antd-style';
4
- import { genCdnUrl } from "../utils/genCdnUrl";
5
- export var LOGO_3D = genCdnUrl({
4
+ export var LOGO_3D = {
6
5
  path: 'assets/logo-3d.webp',
7
6
  pkg: '@lobehub/assets-logo',
8
7
  version: '1.1.0'
9
- });
10
- export var LOGO_FLAT = genCdnUrl({
8
+ };
9
+ export var LOGO_FLAT = {
11
10
  path: 'assets/logo-flat.svg',
12
11
  pkg: '@lobehub/assets-logo',
13
12
  version: '1.1.0'
14
- });
13
+ };
15
14
  export var useStyles = createStyles(function (_ref) {
16
15
  var css = _ref.css;
17
16
  return {
@@ -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,5 +1,5 @@
1
1
  import { memo, useCallback } from 'react';
2
- import { genCdnUrl } from "../utils/genCdnUrl";
2
+ import { useCdnFn } from "../ConfigProvider";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { Fragment as _Fragment } from "react/jsx-runtime";
5
5
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -7,6 +7,7 @@ var Meta = /*#__PURE__*/memo(function (_ref) {
7
7
  var _ref$title = _ref.title,
8
8
  title = _ref$title === void 0 ? 'LobeHub' : _ref$title,
9
9
  withManifest = _ref.withManifest;
10
+ var genCdnUrl = useCdnFn();
10
11
  var genAssets = useCallback(function (path) {
11
12
  return genCdnUrl({
12
13
  path: path,
@@ -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,42 +1,48 @@
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';
5
7
  import { ThemeProvider as AntdThemeProvider, StyleProvider, setupStyled } from 'antd-style';
6
8
  import { memo, useCallback, useEffect } from 'react';
7
9
  import { ThemeContext } from 'styled-components';
10
+ import { useCdnFn } from "../ConfigProvider";
8
11
  import FontLoader from "../FontLoader";
9
- import { lobeCustomStylish, lobeCustomToken, lobeTheme } from "../styles";
10
- import { genCdnUrl } from "../utils/genCdnUrl";
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
- _ref$webfonts = _ref.webfonts,
23
- webfonts = _ref$webfonts === void 0 ? [genCdnUrl({
24
- path: 'css/index.css',
25
- pkg: '@lobehub/webfont-mono',
26
- version: '1.0.0'
27
- }), genCdnUrl({
28
- path: 'css/index.css',
29
- pkg: '@lobehub/webfont-harmony-sans',
30
- version: '1.0.0'
31
- }), genCdnUrl({
32
- path: 'css/index.css',
33
- pkg: '@lobehub/webfont-harmony-sans-sc',
34
- version: '1.0.0'
35
- }), genCdnUrl({
36
- path: 'dist/katex.min.css',
37
- pkg: 'katex',
38
- version: '0.16.8'
39
- })] : _ref$webfonts;
24
+ webfonts = _ref.webfonts,
25
+ _ref$customTheme = _ref.customTheme,
26
+ customTheme = _ref$customTheme === void 0 ? {} : _ref$customTheme,
27
+ res = _objectWithoutProperties(_ref, _excluded);
28
+ var genCdnUrl = useCdnFn();
29
+ var webfontUrls = webfonts || [genCdnUrl({
30
+ path: 'css/index.css',
31
+ pkg: '@lobehub/webfont-mono',
32
+ version: '1.0.0'
33
+ }), genCdnUrl({
34
+ path: 'css/index.css',
35
+ pkg: '@lobehub/webfont-harmony-sans',
36
+ version: '1.0.0'
37
+ }), genCdnUrl({
38
+ path: 'css/index.css',
39
+ pkg: '@lobehub/webfont-harmony-sans-sc',
40
+ version: '1.0.0'
41
+ }), genCdnUrl({
42
+ path: 'dist/katex.min.css',
43
+ pkg: 'katex',
44
+ version: '0.16.8'
45
+ })];
40
46
  useEffect(function () {
41
47
  setupStyled({
42
48
  ThemeContext: ThemeContext
@@ -48,18 +54,25 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
48
54
  var token = useCallback(function (theme) {
49
55
  return _objectSpread(_objectSpread({}, lobeCustomToken(theme)), customToken === null || customToken === void 0 ? void 0 : customToken(theme));
50
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]);
51
64
  return /*#__PURE__*/_jsxs(_Fragment, {
52
- children: [enableWebfonts && (webfonts === null || webfonts === void 0 ? void 0 : webfonts.length) > 0 && webfonts.map(function (webfont, index) {
65
+ children: [enableWebfonts && (webfontUrls === null || webfontUrls === void 0 ? void 0 : webfontUrls.length) > 0 && webfontUrls.map(function (webfont) {
53
66
  return /*#__PURE__*/_jsx(FontLoader, {
54
67
  url: webfont
55
- }, index);
68
+ }, webfont);
56
69
  }), /*#__PURE__*/_jsx(StyleProvider, {
57
70
  speedy: process.env.NODE_ENV === 'production',
58
- children: /*#__PURE__*/_jsxs(AntdThemeProvider, {
71
+ children: /*#__PURE__*/_jsxs(AntdThemeProvider, _objectSpread(_objectSpread({
59
72
  customStylish: stylish,
60
- customToken: token,
61
- theme: lobeTheme,
62
- themeMode: themeMode,
73
+ customToken: token
74
+ }, res), {}, {
75
+ theme: theme,
63
76
  children: [/*#__PURE__*/_jsx(GlobalStyle, {}), /*#__PURE__*/_jsx(App, {
64
77
  style: {
65
78
  minHeight: 'inherit',
@@ -67,7 +80,7 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
67
80
  },
68
81
  children: children
69
82
  })]
70
- })
83
+ }))
71
84
  })]
72
85
  });
73
86
  });
package/es/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export type { ChatListProps, OnActionClick, OnMessageChange, RenderErrorMessage,
11
11
  export { default as ChatList } from './ChatList';
12
12
  export { default as CodeEditor, type CodeEditorProps } from './CodeEditor';
13
13
  export { default as ColorScales, type ColorScalesProps } from './ColorScales';
14
+ export { type Config, default as ConfigProvider, useCdnFn } from './ConfigProvider';
14
15
  export { default as ContextMenu, type ContextMenuProps } from './ContextMenu';
15
16
  export { default as CopyButton, type CopyButtonProps } from './CopyButton';
16
17
  export { default as DraggablePanel, type DraggablePanelProps } from './DraggablePanel';
package/es/index.js CHANGED
@@ -10,6 +10,7 @@ export { default as ChatItem } from "./ChatItem";
10
10
  export { default as ChatList } from "./ChatList";
11
11
  export { default as CodeEditor } from "./CodeEditor";
12
12
  export { default as ColorScales } from "./ColorScales";
13
+ export { default as ConfigProvider, useCdnFn } from "./ConfigProvider";
13
14
  export { default as ContextMenu } from "./ContextMenu";
14
15
  export { default as CopyButton } from "./CopyButton";
15
16
  export { default as DraggablePanel } from "./DraggablePanel";
@@ -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,
@@ -1,9 +1,8 @@
1
1
  export type CDN = 'aliyun' | 'unpkg';
2
- interface CdnApi {
2
+ export interface CdnApi {
3
3
  path: string;
4
4
  pkg: string;
5
5
  proxy?: CDN;
6
6
  version: string;
7
7
  }
8
8
  export declare const genCdnUrl: ({ pkg, version, path, proxy }: CdnApi) => string;
9
- export {};
@@ -1,3 +1,4 @@
1
+ import urlJoin from 'url-join';
1
2
  var UNPKG_API = 'https://unpkg.com';
2
3
  var ALIYUN_API = 'https://registry.npmmirror.com';
3
4
  export var genCdnUrl = function genCdnUrl(_ref) {
@@ -5,6 +6,14 @@ export var genCdnUrl = function genCdnUrl(_ref) {
5
6
  version = _ref.version,
6
7
  path = _ref.path,
7
8
  proxy = _ref.proxy;
8
- var api = proxy === 'unpkg' ? UNPKG_API : ALIYUN_API;
9
- return "".concat(api.replaceAll(/^\//g, ''), "/").concat(pkg, "/").concat(version, "/files/").concat(path.replaceAll(/^\//g, ''));
9
+ switch (proxy) {
10
+ case 'unpkg':
11
+ {
12
+ return urlJoin(UNPKG_API, "".concat(pkg, "@").concat(version), path);
13
+ }
14
+ default:
15
+ {
16
+ return urlJoin(ALIYUN_API, pkg, version, 'files', path);
17
+ }
18
+ }
10
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.94.7",
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",
@@ -44,7 +44,7 @@
44
44
  "pull": "git pull",
45
45
  "release": "semantic-release",
46
46
  "setup": "dumi setup",
47
- "start": "dumi dev",
47
+ "start": "npm run docs:dev",
48
48
  "test": "vitest --passWithNoTests",
49
49
  "test:coverage": "vitest run --coverage --passWithNoTests",
50
50
  "test:update": "vitest -u",
@@ -109,6 +109,7 @@
109
109
  "swr": "^2",
110
110
  "three": "^0.150",
111
111
  "ts-md5": "^1",
112
+ "url-join": "^5",
112
113
  "use-merge-value": "^1",
113
114
  "zustand": "^4.4.1",
114
115
  "zustand-utils": "^1.3.1"
@@ -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