@lobehub/ui 1.31.1 → 1.31.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- <img width="160" src="https://npm.elemecdn.com/@lobehub/assets-logo/assets/logo-3d.webp">
5
+ <img width="160" src="https://npm.elemecdn.com/@lobehub/assets-logo@1.0.0/assets/logo-3d.webp">
6
6
 
7
7
  <h1>Lobe UI</h1>
8
8
 
@@ -1,5 +1,16 @@
1
- /// <reference types="react" />
2
1
  import { FormProps as AntFormProps } from 'antd';
3
- export declare type FormProps = AntFormProps;
2
+ import { LucideIcon } from 'lucide-react';
3
+ import { type ReactNode } from 'react';
4
+ import { FormItemProps } from './components/FormItem';
5
+ export interface ItemGroup {
6
+ children: FormItemProps[];
7
+ icon: LucideIcon;
8
+ title: string;
9
+ }
10
+ export interface FormProps extends AntFormProps {
11
+ children?: ReactNode;
12
+ footer?: ReactNode;
13
+ items?: ItemGroup[];
14
+ }
4
15
  declare const Form: import("react").NamedExoticComponent<FormProps>;
5
16
  export default Form;
package/es/Form/index.js CHANGED
@@ -1,26 +1,43 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["className"];
3
+ var _excluded = ["className", "footer", "items", "children"];
4
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; }
5
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; }
6
6
  import { Form as AntForm } from 'antd';
7
7
  import { memo } from 'react';
8
+ import FormFooter from "./components/FormFooter";
9
+ import FormGroup from "./components/FormGroup";
10
+ import FormItem from "./components/FormItem";
8
11
  import { useStyles } from "./style";
9
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
14
  var Form = /*#__PURE__*/memo(function (_ref) {
11
15
  var className = _ref.className,
16
+ footer = _ref.footer,
17
+ items = _ref.items,
18
+ children = _ref.children,
12
19
  props = _objectWithoutProperties(_ref, _excluded);
13
20
  var _useStyles = useStyles(),
14
21
  cx = _useStyles.cx,
15
22
  styles = _useStyles.styles;
16
- return (
17
- /*#__PURE__*/
18
- // @ts-ignore
19
- _jsx(AntForm, _objectSpread({
20
- className: cx(styles.form, className),
21
- colon: false,
22
- layout: "horizontal"
23
- }, props))
24
- );
23
+ return /*#__PURE__*/_jsxs(AntForm, _objectSpread(_objectSpread({
24
+ className: cx(styles.form, className),
25
+ colon: false,
26
+ layout: "horizontal"
27
+ }, props), {}, {
28
+ children: [items === null || items === void 0 ? void 0 : items.map(function (group, groupIndex) {
29
+ return /*#__PURE__*/_jsx(FormGroup, {
30
+ icon: group.icon,
31
+ title: group.title,
32
+ children: group.children.map(function (item, itemIndex) {
33
+ return /*#__PURE__*/_jsx(FormItem, _objectSpread({
34
+ divider: itemIndex !== 0
35
+ }, item), itemIndex);
36
+ })
37
+ }, groupIndex);
38
+ }), children, footer && /*#__PURE__*/_jsx(FormFooter, {
39
+ children: footer
40
+ })]
41
+ }));
25
42
  });
26
43
  export default Form;
@@ -1,5 +1,10 @@
1
1
  /// <reference types="react" />
2
- import type { HighlighterProps } from '../index';
3
- export declare type SyntaxHighlighterProps = Pick<HighlighterProps, 'language' | 'children' | 'theme'>;
2
+ import { HighlighterOptions } from 'shiki-es';
3
+ export interface SyntaxHighlighterProps {
4
+ children: string;
5
+ language: string;
6
+ options?: HighlighterOptions;
7
+ theme?: 'dark' | 'light';
8
+ }
4
9
  declare const SyntaxHighlighter: import("react").NamedExoticComponent<SyntaxHighlighterProps>;
5
10
  export default SyntaxHighlighter;
@@ -12,7 +12,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
12
12
  import { Fragment as _Fragment } from "react/jsx-runtime";
13
13
  var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
14
14
  var children = _ref.children,
15
- language = _ref.language;
15
+ language = _ref.language,
16
+ options = _ref.options;
16
17
  var _useStyles = useStyles(),
17
18
  styles = _useStyles.styles;
18
19
  var _useThemeMode = useThemeMode(),
@@ -24,8 +25,8 @@ var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
24
25
  codeToHtml = _useHighlight2[0],
25
26
  isLoading = _useHighlight2[1];
26
27
  useEffect(function () {
27
- useHighlight.getState().initHighlighter();
28
- }, []);
28
+ useHighlight.getState().initHighlighter(options);
29
+ }, [options]);
29
30
  return /*#__PURE__*/_jsxs(_Fragment, {
30
31
  children: [isLoading ? /*#__PURE__*/_jsx("div", {
31
32
  className: styles.shiki,
@@ -1,7 +1,7 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
2
  var _templateObject;
3
3
  import { createGlobalStyle } from 'antd-style';
4
- var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\n html,body {\n --font-settings: \"cv01\", \"tnum\", \"kern\";\n --font-variations: \"opsz\" auto, tabular-nums;\n\n overflow-x: hidden;\n overflow-y: auto;\n\n margin: 0;\n padding: 0;\n\n font-family: ", ";\n font-size: ", "px;\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n line-height: 1;\n color: ", ";\n text-size-adjust: none;\n text-rendering: optimizelegibility;\n vertical-align: baseline;\n\n color-scheme: dark;\n background-color: ", ";\n\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n -webkit-overflow-scrolling:touch;\n -webkit-tap-highlight-color: transparent;\n }\n\n body {\n overflow-x: hidden;\n height: 100vh;\n }\n\n #root {\n min-height: 100vh;\n }\n\n code {\n font-family: ", " !important;\n\n span {\n font-family: ", " !important;\n }\n }\n\n p {\n text-align: justify;\n word-wrap: break-word;\n }\n\n ::selection {\n color: #000;\n background: ", ";\n\n\t -webkit-text-fill-color: unset !important;\n }\n\n * {\n\t box-sizing: border-box;\n\t vertical-align: baseline;\n }\n\n @media only screen and (min-width: 574px) {\n * {\n ::-webkit-scrollbar {\n cursor: pointer;\n width: 4px;\n height: 4px;\n background-color: transparent;\n }\n\n ::-webkit-scrollbar-thumb {\n cursor: pointer;\n background-color: transparent;\n border-radius: 2px;\n transition: background-color 500ms ", ";\n\n &:hover {\n background-color: ", ";\n }\n }\n\n ::-webkit-scrollbar-corner {\n display: none;\n width: 0;\n height: 0;\n }\n\n &:hover {\n ::-webkit-scrollbar-thumb {\n background-color: ", ";\n }\n }\n }\n }\n"])), function (_ref) {
4
+ var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\n html,body {\n --font-settings: \"cv01\", \"tnum\", \"kern\";\n --font-variations: \"opsz\" auto, tabular-nums;\n\n overflow-x: hidden;\n overflow-y: auto;\n\n margin: 0;\n padding: 0;\n\n font-family: ", ";\n font-size: ", "px;\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n line-height: 1;\n color: ", ";\n text-size-adjust: none;\n text-rendering: optimizelegibility;\n vertical-align: baseline;\n\n color-scheme: dark;\n background-color: ", ";\n\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n -webkit-overflow-scrolling:touch;\n -webkit-tap-highlight-color: transparent;\n }\n\n body {\n overflow-x: hidden;\n height: 100vh;\n }\n\n #root {\n min-height: 100vh;\n }\n\n code {\n font-family: ", " !important;\n\n span {\n font-family: ", " !important;\n }\n }\n\n p {\n text-align: justify;\n word-wrap: break-word;\n }\n\n ::selection {\n color: #000;\n background: ", ";\n\n\t -webkit-text-fill-color: unset !important;\n }\n\n * {\n\t box-sizing: border-box;\n\t vertical-align: baseline;\n }\n\n @media only screen and (min-width: 574px) {\n * {\n ::-webkit-scrollbar {\n cursor: pointer;\n width: 4px;\n height: 4px;\n background-color: transparent;\n }\n\n ::-webkit-scrollbar-thumb {\n cursor: pointer;\n background-color: transparent;\n border-radius: 2px;\n transition: background-color 500ms ", ";\n\n &:hover {\n background-color: ", ";\n }\n }\n\n ::-webkit-scrollbar-corner {\n display: none;\n width: 0;\n height: 0;\n }\n\n &:hover {\n ::-webkit-scrollbar-thumb {\n background-color: ", ";\n }\n }\n }\n }\n\n .ant-tooltip-inner {\n\t display: flex;\n\t align-items: center;\n\t justify-content: center;\n\n\t min-height: unset;\n\t padding: 4px 8px;\n\n\t color: ", ";\n\n\t background-color: ", ";\n\t border-radius: ", "px;\n }\n\n .ant-tooltip-arrow {\n\t &::before,\n\t &::after {\n\t\t background: ", ";\n\t }\n }\n"])), function (_ref) {
5
5
  var theme = _ref.theme;
6
6
  return theme.fontFamily;
7
7
  }, function (_ref2) {
@@ -31,5 +31,17 @@ var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _tagge
31
31
  }, function (_ref10) {
32
32
  var theme = _ref10.theme;
33
33
  return theme.colorFill;
34
+ }, function (_ref11) {
35
+ var theme = _ref11.theme;
36
+ return theme.colorBgLayout;
37
+ }, function (_ref12) {
38
+ var theme = _ref12.theme;
39
+ return theme.colorText;
40
+ }, function (_ref13) {
41
+ var theme = _ref13.theme;
42
+ return theme.borderRadiusSM;
43
+ }, function (_ref14) {
44
+ var theme = _ref14.theme;
45
+ return theme.colorText;
34
46
  });
35
47
  export default GlobalStyle;
@@ -22,6 +22,7 @@ export interface ThemeProviderProps {
22
22
  customToken?: (theme: CustomTokenParams) => {
23
23
  [key: string]: any;
24
24
  };
25
+ enableWebfonts?: boolean;
25
26
  /**
26
27
  * @description Whether to inline the styles on server-side rendering or not
27
28
  */
@@ -22,13 +22,15 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
22
22
  _customToken = _ref$customToken === void 0 ? function () {
23
23
  return {};
24
24
  } : _ref$customToken,
25
+ _ref$enableWebfonts = _ref.enableWebfonts,
26
+ enableWebfonts = _ref$enableWebfonts === void 0 ? true : _ref$enableWebfonts,
25
27
  _ref$webfonts = _ref.webfonts,
26
28
  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;
27
29
  setupStyled({
28
30
  ThemeContext: ThemeContext
29
31
  });
30
32
  return /*#__PURE__*/_jsxs(_Fragment, {
31
- children: [webfonts && webfonts.map(function (webfont, index) {
33
+ children: [enableWebfonts && (webfonts === null || webfonts === void 0 ? void 0 : webfonts.length) > 0 && webfonts.map(function (webfont, index) {
32
34
  return /*#__PURE__*/_jsx(FontLoader, {
33
35
  url: webfont
34
36
  }, index);
@@ -1,4 +1,4 @@
1
- import { type Highlighter } from 'shiki-es';
1
+ import { type Highlighter, type HighlighterOptions } from 'shiki-es';
2
2
  export declare const languageMap: readonly ["javascript", "js", "jsx", "json", "markdown", "md", "less", "css", "typescript", "ts", "tsx", "diff", "bash"];
3
3
  /**
4
4
  * @title 代码高亮的存储对象
@@ -20,7 +20,7 @@ interface Store {
20
20
  * @title Initialize the highlighter object
21
21
  * @returns Initialization promise object
22
22
  */
23
- initHighlighter: () => Promise<void>;
23
+ initHighlighter: (options?: HighlighterOptions) => Promise<void>;
24
24
  }
25
25
  export declare const useHighlight: import("zustand").UseBoundStore<import("zustand").StoreApi<Store>>;
26
26
  export {};
@@ -26,7 +26,7 @@ export var useHighlight = create(function (set, get) {
26
26
  },
27
27
  highlighter: undefined,
28
28
  initHighlighter: function () {
29
- var _initHighlighter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
29
+ var _initHighlighter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
30
30
  var highlighter;
31
31
  return _regeneratorRuntime.wrap(function _callee$(_context) {
32
32
  while (1) switch (_context.prev = _context.next) {
@@ -37,8 +37,8 @@ export var useHighlight = create(function (set, get) {
37
37
  }
38
38
  _context.next = 3;
39
39
  return getHighlighter({
40
- langs: languageMap,
41
- themes: [themeConfig(true), themeConfig(false)]
40
+ langs: (options === null || options === void 0 ? void 0 : options.langs) || languageMap,
41
+ themes: (options === null || options === void 0 ? void 0 : options.themes) || [themeConfig(true), themeConfig(false)]
42
42
  });
43
43
  case 3:
44
44
  highlighter = _context.sent;
@@ -51,7 +51,7 @@ export var useHighlight = create(function (set, get) {
51
51
  }
52
52
  }, _callee);
53
53
  }));
54
- function initHighlighter() {
54
+ function initHighlighter(_x) {
55
55
  return _initHighlighter.apply(this, arguments);
56
56
  }
57
57
  return initHighlighter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.31.1",
3
+ "version": "1.31.3",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",