@lobehub/ui 1.94.5 → 1.94.7

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.
@@ -1,4 +1,5 @@
1
1
  import { memo } from 'react';
2
+ import { Flexbox } from 'react-layout-kit';
2
3
  import { useStyles } from "../style";
3
4
  import { jsx as _jsx } from "react/jsx-runtime";
4
5
  var Actions = /*#__PURE__*/memo(function (_ref) {
@@ -12,7 +13,8 @@ var Actions = /*#__PURE__*/memo(function (_ref) {
12
13
  type: type
13
14
  }),
14
15
  styles = _useStyles.styles;
15
- return /*#__PURE__*/_jsx("div", {
16
+ return /*#__PURE__*/_jsx(Flexbox, {
17
+ align: 'flex-start',
16
18
  className: styles.actions,
17
19
  role: "chat-item-actions",
18
20
  children: actions
@@ -1,5 +1,6 @@
1
1
  import { Loader2 } from 'lucide-react';
2
2
  import { memo } from 'react';
3
+ import { Flexbox } from 'react-layout-kit';
3
4
  import Icon from "../../Icon";
4
5
  import { useStyles } from "../style";
5
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -11,8 +12,10 @@ var Loading = /*#__PURE__*/memo(function (_ref) {
11
12
  }),
12
13
  styles = _useStyles.styles;
13
14
  if (!loading) return null;
14
- return /*#__PURE__*/_jsx("div", {
15
+ return /*#__PURE__*/_jsx(Flexbox, {
16
+ align: 'center',
15
17
  className: styles.loading,
18
+ justify: 'center',
16
19
  children: /*#__PURE__*/_jsx(Icon, {
17
20
  icon: Loader2,
18
21
  size: {
@@ -16,8 +16,8 @@ var Title = /*#__PURE__*/memo(function (_ref) {
16
16
  styles = _useStyles.styles;
17
17
  return /*#__PURE__*/_jsxs(Flexbox, {
18
18
  className: styles.name,
19
+ direction: placement === 'left' ? 'horizontal' : 'horizontal-reverse',
19
20
  gap: 4,
20
- horizontal: true,
21
21
  children: [showTitle ? avatar.title || 'untitled' : undefined, time && /*#__PURE__*/_jsx("time", {
22
22
  children: formatTime(time)
23
23
  })]
@@ -54,8 +54,8 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
54
54
  styles = _useStyles.styles;
55
55
  return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
56
56
  className: cx(styles.container, className),
57
- gap: mobile ? 6 : 12,
58
- horizontal: true
57
+ direction: placement === 'left' ? 'horizontal' : 'horizontal-reverse',
58
+ gap: mobile ? 6 : 12
59
59
  }, props), {}, {
60
60
  children: [/*#__PURE__*/_jsx(Avatar, {
61
61
  addon: avatarAddon,
@@ -65,6 +65,7 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
65
65
  placement: placement,
66
66
  size: mobile ? MOBILE_AVATAR_SIZE : undefined
67
67
  }), /*#__PURE__*/_jsxs(Flexbox, {
68
+ align: placement === 'left' ? 'flex-start' : 'flex-end',
68
69
  className: styles.messageContainer,
69
70
  children: [/*#__PURE__*/_jsx(Title, {
70
71
  avatar: avatar,
@@ -72,7 +73,9 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
72
73
  showTitle: showTitle,
73
74
  time: time
74
75
  }), /*#__PURE__*/_jsxs(Flexbox, {
76
+ align: placement === 'left' ? 'flex-start' : 'flex-end',
75
77
  className: styles.messageContent,
78
+ direction: type === 'block' ? placement === 'left' ? 'horizontal' : 'horizontal-reverse' : 'vertical',
76
79
  gap: 8,
77
80
  children: [error ? /*#__PURE__*/_jsx(ErrorContent, {
78
81
  ErrorMessage: ErrorMessage,
@@ -20,18 +20,18 @@ export var useStyles = createStyles(function (_ref, _ref2) {
20
20
  var typeStylish = type === 'block' ? blockStylish : pureStylish;
21
21
  var editingStylish = editing && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n "])));
22
22
  return {
23
- actions: cx(css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n align-items: flex-start;\n align-self: ", ";\n justify-content: ", ";\n "])), type === 'block' ? 'flex-end' : placement === 'left' ? 'flex-start' : 'flex-end', placement === 'left' ? 'flex-end' : 'flex-start'), editing && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n pointer-events: none !important;\n opacity: 0 !important;\n "])))),
23
+ actions: cx(css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n align-self: ", ";\n justify-content: ", ";\n "])), type === 'block' ? 'flex-end' : placement === 'left' ? 'flex-start' : 'flex-end', placement === 'left' ? 'flex-end' : 'flex-start'), editing && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n pointer-events: none !important;\n opacity: 0 !important;\n "])))),
24
24
  alert: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n span[role='img'] {\n align-self: flex-start;\n width: 16px;\n height: 16px;\n margin-top: 3px;\n }\n\n .ant-alert-description {\n text-align: justify;\n word-break: break-all;\n word-wrap: break-word;\n }\n\n &.ant-alert-with-description {\n padding-block: 12px;\n padding-inline: 12px;\n\n .ant-alert-message {\n font-size: 14px;\n font-weight: 600;\n text-align: justify;\n word-break: break-all;\n word-wrap: break-word;\n }\n }\n "]))),
25
25
  avatarContainer: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
26
26
  avatarGroupContainer: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), avatarSize),
27
- container: cx(type === 'pure' && pureContainerStylish, css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: ", ";\n justify-content: revert;\n\n width: 100%;\n max-width: 100vw;\n padding: 12px 16px;\n\n time {\n display: inline-block;\n white-space: nowrap;\n }\n\n div[role='chat-item-actions'] {\n display: flex;\n }\n\n time,\n div[role='chat-item-actions'] {\n pointer-events: none;\n opacity: 0;\n transition: opacity 200ms ", ";\n }\n\n &:hover {\n time,\n div[role='chat-item-actions'] {\n pointer-events: unset;\n opacity: 1;\n }\n }\n\n ", " {\n padding: 4px 16px;\n }\n "])), placement === 'left' ? 'row' : 'row-reverse', token.motionEaseOut, responsive.mobile)),
27
+ container: cx(type === 'pure' && pureContainerStylish, css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n max-width: 100vw;\n padding: 12px 16px;\n\n time {\n display: inline-block;\n white-space: nowrap;\n }\n\n div[role='chat-item-actions'] {\n display: flex;\n }\n\n time,\n div[role='chat-item-actions'] {\n pointer-events: none;\n opacity: 0;\n transition: opacity 200ms ", ";\n }\n\n &:hover {\n time,\n div[role='chat-item-actions'] {\n pointer-events: unset;\n opacity: 1;\n }\n }\n\n ", " {\n padding: 4px 16px;\n }\n "])), token.motionEaseOut, responsive.mobile)),
28
28
  editingContainer: cx(editingStylish, css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n padding: 8px 12px 12px;\n border: 1px solid ", ";\n\n &:active,\n &:hover {\n border-color: ", ";\n }\n "])), token.colorBorderSecondary, token.colorBorder), type === 'pure' && css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: ", "px;\n "])), token.colorFillQuaternary, token.borderRadius)),
29
29
  editingInput: css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n width: 100%;\n "]))),
30
- loading: css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n position: absolute;\n right: ", ";\n bottom: 0;\n left: ", ";\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 16px;\n height: 16px;\n\n color: ", ";\n\n background: ", ";\n border-radius: 50%;\n "])), placement === 'left' ? '-4px' : 'unset', placement === 'right' ? '-4px' : 'unset', token.colorBgLayout, token.colorPrimary),
30
+ loading: css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n position: absolute;\n right: ", ";\n bottom: 0;\n left: ", ";\n\n width: 16px;\n height: 16px;\n\n color: ", ";\n\n background: ", ";\n border-radius: 50%;\n "])), placement === 'left' ? '-4px' : 'unset', placement === 'right' ? '-4px' : 'unset', token.colorBgLayout, token.colorPrimary),
31
31
  message: cx(typeStylish, css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n position: relative;\n "])))),
32
- messageContainer: cx(editingStylish, css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n position: relative;\n align-items: ", ";\n "])), placement === 'left' ? 'flex-start' : 'flex-end')),
33
- messageContent: cx(editingStylish, css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n position: relative;\n overflow-x: hidden;\n flex-direction: ", ";\n align-items: ", ";\n\n ", " {\n flex-direction: column;\n }\n "])), type === 'block' ? placement === 'left' ? 'row' : 'row-reverse' : 'column', placement === 'left' ? 'flex-start' : 'flex-end', responsive.mobile)),
32
+ messageContainer: cx(editingStylish, css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n position: relative;\n "])))),
33
+ messageContent: cx(editingStylish, css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n position: relative;\n overflow-x: hidden;\n\n ", " {\n flex-direction: column !important;\n }\n "])), responsive.mobile)),
34
34
  messageExtra: cx('message-extra'),
35
- name: css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n right: ", ";\n left: ", ";\n\n flex-direction: ", ";\n\n margin-bottom: 6px;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-align: ", ";\n "])), showTitle ? 'relative' : 'absolute', showTitle ? 'unset' : '-16px', placement === 'right' ? '0' : 'unset', placement === 'left' ? '0' : 'unset', placement === 'left' ? 'row' : 'row-reverse', token.colorTextDescription, placement === 'left' ? 'left' : 'right')
35
+ name: css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n right: ", ";\n left: ", ";\n\n margin-bottom: 6px;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-align: ", ";\n "])), showTitle ? 'relative' : 'absolute', showTitle ? 'unset' : '-16px', placement === 'right' ? '0' : 'unset', placement === 'left' ? '0' : 'unset', token.colorTextDescription, placement === 'left' ? 'left' : 'right')
36
36
  };
37
37
  });
@@ -22,10 +22,14 @@ var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
22
22
  data = _useHighlight.data,
23
23
  isLoading = _useHighlight.isLoading;
24
24
  return /*#__PURE__*/_jsxs(_Fragment, {
25
- children: [isLoading ? /*#__PURE__*/_jsx("code", {
25
+ children: [isLoading ? /*#__PURE__*/_jsx("div", {
26
26
  className: cx(styles.unshiki, className),
27
27
  style: style,
28
- children: children
28
+ children: /*#__PURE__*/_jsx("pre", {
29
+ children: /*#__PURE__*/_jsx("code", {
30
+ children: children
31
+ })
32
+ })
29
33
  }) : /*#__PURE__*/_jsx("div", {
30
34
  className: cx(styles.shiki, className),
31
35
  dangerouslySetInnerHTML: {
@@ -12,6 +12,6 @@ export var useStyles = createStyles(function (_ref) {
12
12
  loading: cx(stylish.blur, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 10;\n top: 0;\n right: 0;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n height: 34px;\n padding: 0 8px;\n\n font-family: ", ";\n color: ", ";\n\n border-radius: ", ";\n "])), token.fontFamilyCode, token.colorTextTertiary, token.borderRadius)),
13
13
  prism: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n pre {\n overflow: auto;\n font-family: ", " !important;\n }\n "])), token.fontFamilyCode),
14
14
  shiki: cx("".concat(prefix, "-shiki"), css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin: 0;\n padding: 0;\n\n .shiki {\n overflow-x: auto;\n margin: 0;\n padding: 0;\n background: none !important;\n }\n "])))),
15
- unshiki: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 8px;\n "])))
15
+ unshiki: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorTextDescription)
16
16
  };
17
17
  });
@@ -16,6 +16,6 @@ export var useStyles = createStyles(function (_ref, type) {
16
16
  container: cx(prefix, type !== 'pure' && typeStylish, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n overflow: auto;\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n .", " {\n opacity: 1;\n }\n\n .", " {\n opacity: 1;\n }\n }\n\n .prism-code {\n background: none !important;\n }\n\n pre {\n margin: 0 !important;\n padding: ", " !important;\n background: none !important;\n }\n\n code {\n background: transparent !important;\n }\n "])), token.borderRadius, token.motionEaseOut, buttonHoverCls, langHoverCls, type === 'pure' ? 0 : "16px 24px")),
17
17
  header: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 4px 8px;\n background: ", ";\n "])), token.colorFillQuaternary),
18
18
  lang: cx(langHoverCls, stylish.blur, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 2;\n right: 0;\n bottom: 8px;\n\n font-family: ", ";\n color: ", ";\n\n opacity: 0;\n\n transition: opacity 0.1s;\n "])), token.fontFamilyCode, token.colorTextSecondary)),
19
- select: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n .ant-select-selection-item {\n min-width: 100px;\n padding-inline-end: 0 !important;\n color: ", ";\n text-align: center;\n }\n\n input {\n text-align: center;\n }\n "])), token.colorTextDescription)
19
+ select: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n .ant-select-selection-item {\n min-width: 100px;\n padding-inline-end: 0 !important;\n color: ", ";\n text-align: center;\n }\n "])), token.colorTextDescription)
20
20
  };
21
21
  });
@@ -1,2 +1,2 @@
1
- declare const _default: string[];
1
+ declare const _default: readonly ["abap", "actionscript-3", "ada", "apache", "apex", "apl", "applescript", "ara", "asm", "astro", "awk", "ballerina", "bat", "beancount", "berry", "bibtex", "bicep", "blade", "c", "cadence", "clarity", "clojure", "cmake", "cobol", "codeql", "coffee", "cpp", "crystal", "csharp", "css", "cue", "cypher", "d", "dart", "dax", "diff", "docker", "dream-maker", "elixir", "elm", "erb", "erlang", "fish", "fsharp", "gdresource", "gdscript", "gdshader", "gherkin", "git-commit", "git-rebase", "glimmer-js", "glimmer-ts", "glsl", "gnuplot", "go", "graphql", "groovy", "hack", "haml", "handlebars", "haskell", "hcl", "hjson", "hlsl", "html", "http", "imba", "ini", "java", "javascript", "jinja-html", "jison", "json", "json5", "jsonc", "jsonl", "jsonnet", "jssm", "jsx", "julia", "kotlin", "kusto", "latex", "less", "liquid", "lisp", "logo", "lua", "make", "markdown", "marko", "matlab", "mdc", "mdx", "mermaid", "mojo", "narrat", "nextflow", "nginx", "nim", "nix", "objective-c", "objective-cpp", "ocaml", "pascal", "perl", "php", "plsql", "postcss", "powerquery", "powershell", "prisma", "prolog", "proto", "pug", "puppet", "purescript", "python", "r", "raku", "razor", "reg", "rel", "riscv", "rst", "ruby", "rust", "sas", "sass", "scala", "scheme", "scss", "shaderlab", "shellscript", "shellsession", "smalltalk", "solidity", "sparql", "splunk", "sql", "ssh-config", "stata", "stylus", "svelte", "swift", "system-verilog", "tasl", "tcl", "tex", "toml", "tsx", "turtle", "twig", "typescript", "v", "vb", "verilog", "vhdl", "viml", "vue", "vue-html", "vyper", "wasm", "wenyan", "wgsl", "wolfram", "xml", "xsl", "yaml", "zenscript", "zig", "bash", "batch", "be", "c#", "cdc", "clj", "cmd", "console", "cql", "cs", "dockerfile", "erl", "f#", "fs", "fsl", "gjs", "gts", "hbs", "hs", "jade", "js", "kql", "makefile", "md", "nar", "nf", "objc", "perl6", "properties", "ps", "ps1", "py", "ql", "rb", "rs", "sh", "shader", "shell", "spl", "styl", "ts", "vim", "vimscript", "vy", "yml", "zsh", "文言"];
2
2
  export default _default;
@@ -3,89 +3,67 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { getHighlighter } from 'shikiji';
4
4
  import useSWR from 'swr';
5
5
  import { themeConfig } from "../Highlighter/theme";
6
- import languageMap from "./languageMap";
7
6
  export var FALLBACK_LANG = 'markdown';
8
- var FALLBACK_LANGS = ['ts', 'typescript', 'js', 'javascript', 'markdown', 'md'];
9
- var THEME = [themeConfig(true), themeConfig(false)];
7
+ var FALLBACK_LANGS = [FALLBACK_LANG];
10
8
  var cacheHighlighter;
11
9
  var initHighlighter = /*#__PURE__*/function () {
12
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
10
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(lang) {
13
11
  var highlighter;
14
12
  return _regeneratorRuntime.wrap(function _callee$(_context) {
15
13
  while (1) switch (_context.prev = _context.next) {
16
14
  case 0:
17
15
  highlighter = cacheHighlighter;
18
- if (!highlighter) {
16
+ if (!(highlighter && FALLBACK_LANGS.includes(lang))) {
19
17
  _context.next = 5;
20
18
  break;
21
19
  }
22
20
  return _context.abrupt("return", highlighter);
23
21
  case 5:
24
- _context.next = 7;
22
+ FALLBACK_LANGS.push(lang);
23
+ _context.next = 8;
25
24
  return getHighlighter({
26
25
  langs: FALLBACK_LANGS,
27
- themes: THEME
26
+ themes: [themeConfig(true), themeConfig(false)]
28
27
  });
29
- case 7:
28
+ case 8:
30
29
  highlighter = _context.sent;
31
30
  cacheHighlighter = highlighter;
32
31
  return _context.abrupt("return", highlighter);
33
- case 10:
32
+ case 11:
34
33
  case "end":
35
34
  return _context.stop();
36
35
  }
37
36
  }, _callee);
38
37
  }));
39
- return function initHighlighter() {
38
+ return function initHighlighter(_x) {
40
39
  return _ref.apply(this, arguments);
41
40
  };
42
41
  }();
43
42
  export var useHighlight = function useHighlight(text, language, isDarkMode) {
44
43
  return useSWR([text, language, Number(isDarkMode)].join('-'), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
45
- var theme, lang, highlighter, html;
44
+ var highlighter, html;
46
45
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
47
46
  while (1) switch (_context2.prev = _context2.next) {
48
47
  case 0:
49
- theme = isDarkMode ? 'dark' : 'light';
50
- lang = language;
51
- _context2.prev = 2;
52
- _context2.next = 5;
53
- return initHighlighter();
54
- case 5:
48
+ _context2.prev = 0;
49
+ _context2.next = 3;
50
+ return initHighlighter(language);
51
+ case 3:
55
52
  highlighter = _context2.sent;
56
- if (FALLBACK_LANGS.includes(lang)) {
57
- _context2.next = 13;
58
- break;
59
- }
60
- if (!languageMap.includes(lang)) {
61
- _context2.next = 12;
62
- break;
63
- }
64
- _context2.next = 10;
65
- return highlighter === null || highlighter === void 0 ? void 0 : highlighter.loadLanguage(lang);
66
- case 10:
67
- _context2.next = 13;
68
- break;
69
- case 12:
70
- lang = FALLBACK_LANG;
71
- case 13:
72
- _context2.next = 15;
73
- return highlighter === null || highlighter === void 0 ? void 0 : highlighter.codeToHtml(text, {
74
- lang: lang,
75
- theme: theme
53
+ html = highlighter === null || highlighter === void 0 ? void 0 : highlighter.codeToHtml(text, {
54
+ lang: language,
55
+ theme: isDarkMode ? 'dark' : 'light'
76
56
  });
77
- case 15:
78
- html = _context2.sent;
79
57
  return _context2.abrupt("return", html);
80
- case 19:
81
- _context2.prev = 19;
82
- _context2.t0 = _context2["catch"](2);
83
- return _context2.abrupt("return", "<code>".concat(text, "</code>"));
84
- case 22:
58
+ case 8:
59
+ _context2.prev = 8;
60
+ _context2.t0 = _context2["catch"](0);
61
+ return _context2.abrupt("return", "<pre><code>".concat(text, "</code></pre>"));
62
+ case 11:
85
63
  case "end":
86
64
  return _context2.stop();
87
65
  }
88
- }, _callee2, null, [[2, 19]]);
66
+ }, _callee2, null, [[0, 8]]);
89
67
  })));
90
68
  };
91
69
  export { default as languageMap } from "./languageMap";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.94.5",
3
+ "version": "1.94.7",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",