@lobehub/ui 1.31.0 → 1.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Form/index.d.ts +13 -2
- package/es/Form/index.js +27 -10
- package/es/Highlighter/SyntaxHighlighter/index.d.ts +7 -2
- package/es/Highlighter/SyntaxHighlighter/index.js +4 -3
- package/es/ThemeProvider/GlobalStyle.js +13 -1
- package/es/ThemeProvider/index.d.ts +1 -0
- package/es/ThemeProvider/index.js +3 -1
- package/es/components/ControlInput.js +7 -9
- package/es/hooks/useHighlight.d.ts +2 -2
- package/es/hooks/useHighlight.js +4 -4
- package/package.json +2 -2
package/es/Form/index.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { FormProps as AntFormProps } from 'antd';
|
|
3
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
3
|
-
export
|
|
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,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);
|
|
@@ -6,22 +6,21 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
6
6
|
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; }
|
|
7
7
|
import { ConfigProvider, Space } from 'antd';
|
|
8
8
|
import { RotateCcw, Save } from 'lucide-react';
|
|
9
|
-
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { forwardRef, memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
10
10
|
import ActionIcon from "../ActionIcon";
|
|
11
11
|
import { Input } from "../Input";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
14
|
+
export var ControlInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, reference) {
|
|
15
15
|
var value = _ref.value,
|
|
16
16
|
onChange = _ref.onChange,
|
|
17
17
|
onValueChanging = _ref.onValueChanging,
|
|
18
18
|
onChangeEnd = _ref.onChangeEnd,
|
|
19
|
-
|
|
19
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
20
20
|
var _useState = useState(value || ''),
|
|
21
21
|
_useState2 = _slicedToArray(_useState, 2),
|
|
22
22
|
input = _useState2[0],
|
|
23
23
|
setInput = _useState2[1];
|
|
24
|
-
var inputReference = useRef();
|
|
25
24
|
var isChineseInput = useRef(false);
|
|
26
25
|
var isFocusing = useRef(false);
|
|
27
26
|
var updateValue = useCallback(function () {
|
|
@@ -30,9 +29,7 @@ export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
30
29
|
useEffect(function () {
|
|
31
30
|
if (value !== undefined) setInput(value);
|
|
32
31
|
}, [value]);
|
|
33
|
-
return /*#__PURE__*/_jsx(Input, _objectSpread(
|
|
34
|
-
ref: inputReference
|
|
35
|
-
}, properties), {}, {
|
|
32
|
+
return /*#__PURE__*/_jsx(Input, _objectSpread({
|
|
36
33
|
onBlur: function onBlur() {
|
|
37
34
|
isFocusing.current = false;
|
|
38
35
|
onChangeEnd === null || onChangeEnd === void 0 ? void 0 : onChangeEnd(input);
|
|
@@ -58,6 +55,7 @@ export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
58
55
|
onChangeEnd === null || onChangeEnd === void 0 ? void 0 : onChangeEnd(input);
|
|
59
56
|
}
|
|
60
57
|
},
|
|
58
|
+
ref: reference,
|
|
61
59
|
suffix: value === input ? /*#__PURE__*/_jsx("span", {}) : /*#__PURE__*/_jsx(ConfigProvider, {
|
|
62
60
|
theme: {
|
|
63
61
|
token: {
|
|
@@ -82,5 +80,5 @@ export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
82
80
|
})
|
|
83
81
|
}),
|
|
84
82
|
value: input
|
|
85
|
-
}));
|
|
86
|
-
});
|
|
83
|
+
}, props));
|
|
84
|
+
}));
|
|
@@ -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 {};
|
package/es/hooks/useHighlight.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.31.2",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building chatbot web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"react-simple-code-editor": "^0",
|
|
99
99
|
"remark-gfm": "^3",
|
|
100
100
|
"shiki-es": "^0",
|
|
101
|
-
"styled-components": "
|
|
101
|
+
"styled-components": "^6",
|
|
102
102
|
"ts-md5": "^1",
|
|
103
103
|
"use-merge-value": "^1",
|
|
104
104
|
"zustand": "^4",
|