@yuntijs/ui 1.0.0-beta.60 → 1.0.0-beta.61

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,5 +1,5 @@
1
- import { MarkdownProps } from '@lobehub/ui';
2
1
  import { type ReactNode } from 'react';
2
+ import { EditableMessageProps } from "../../EditableMessage";
3
3
  import { ChatItemProps } from '../type';
4
4
  export interface MessageContentProps {
5
5
  editing?: ChatItemProps['editing'];
@@ -14,7 +14,7 @@ export interface MessageContentProps {
14
14
  renderMessage?: ChatItemProps['renderMessage'];
15
15
  text?: ChatItemProps['text'];
16
16
  type?: ChatItemProps['type'];
17
- markdownProps?: MarkdownProps;
17
+ markdownProps?: EditableMessageProps['markdownProps'];
18
18
  markdownClassname?: string;
19
19
  }
20
20
  declare const MessageContent: import("react").NamedExoticComponent<MessageContentProps>;
@@ -1,5 +1,6 @@
1
- import { AlertProps, AvatarProps, DivProps, EditableMessageProps, MarkdownProps, MetaData } from '@lobehub/ui';
1
+ import { AlertProps, AvatarProps, DivProps, MetaData } from '@lobehub/ui';
2
2
  import { ReactNode } from 'react';
3
+ import type { EditableMessageProps } from "../EditableMessage";
3
4
  export interface ChatItemProps {
4
5
  /**
5
6
  * @description Actions to be displayed in the chat item
@@ -73,7 +74,7 @@ export interface ChatItemProps {
73
74
  /**
74
75
  * @description The markdownProps of the chat item
75
76
  */
76
- markdownProps?: MarkdownProps;
77
+ markdownProps?: EditableMessageProps['markdownProps'];
77
78
  /**
78
79
  * @description The markdownClassname of the chat item
79
80
  */
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { DivProps } from 'react-layout-kit';
3
3
  import type { LazyLogProps } from './types';
4
- export interface LogViewerProps extends Omit<LazyLogProps, 'iconFilterLines' | 'iconFindNext' | 'iconFindPrevious'>, Pick<DivProps, 'className' | 'id' | 'style'> {
4
+ export interface LogViewerProps extends Omit<LazyLogProps, 'iconFilterLines' | 'iconFindNext' | 'iconFindPrevious' | 'loadingComponent'>, Pick<DivProps, 'className' | 'id' | 'style'> {
5
5
  /**
6
6
  * Timed refresh, in ms, only takes effect when url is specified and not websocket
7
7
  */
@@ -1,15 +1,16 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["className", "id", "style", "height", "onScroll", "url", "websocket", "refreshInterval"];
4
+ var _excluded = ["className", "id", "style", "height", "onScroll", "url", "websocket", "refreshInterval", "onLoad", "onError"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  import { Icon } from '@lobehub/ui';
8
8
  import { LazyLog, ScrollFollow } from '@melloware/react-logviewer';
9
- import { ArrowDown, ArrowUp, TextSearch } from 'lucide-react';
10
- import React, { useEffect, useMemo, useState } from 'react';
9
+ import { ArrowDown, ArrowUp, LoaderCircle, TextSearch } from 'lucide-react';
10
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
11
11
  import { useStyles } from "./style";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
14
  export var LogViewer = function LogViewer(_ref) {
14
15
  var className = _ref.className,
15
16
  id = _ref.id,
@@ -19,6 +20,8 @@ export var LogViewer = function LogViewer(_ref) {
19
20
  urlFromProps = _ref.url,
20
21
  websocket = _ref.websocket,
21
22
  refreshInterval = _ref.refreshInterval,
23
+ onLoad = _ref.onLoad,
24
+ onError = _ref.onError,
22
25
  props = _objectWithoutProperties(_ref, _excluded);
23
26
  var _useStyles = useStyles(),
24
27
  cx = _useStyles.cx,
@@ -27,6 +30,16 @@ export var LogViewer = function LogViewer(_ref) {
27
30
  _useState2 = _slicedToArray(_useState, 2),
28
31
  urlHash = _useState2[0],
29
32
  setUrlHash = _useState2[1];
33
+ var _useState3 = useState(false),
34
+ _useState4 = _slicedToArray(_useState3, 2),
35
+ loading = _useState4[0],
36
+ setLoading = _useState4[1];
37
+ var setLoadingTimeout = useRef();
38
+ useEffect(function () {
39
+ return function () {
40
+ clearTimeout(setLoadingTimeout.current);
41
+ };
42
+ }, []);
30
43
  useEffect(function () {
31
44
  var intervalTimeout;
32
45
  if (urlFromProps && !websocket && refreshInterval) {
@@ -41,15 +54,32 @@ export var LogViewer = function LogViewer(_ref) {
41
54
  };
42
55
  }, [refreshInterval, urlFromProps, websocket]);
43
56
  var url = useMemo(function () {
57
+ // workaround for onLoad exec twice
58
+ if (setLoadingTimeout.current) {
59
+ clearTimeout(setLoadingTimeout.current);
60
+ } else {
61
+ setLoadingTimeout.current = setTimeout(function () {
62
+ setLoading(true);
63
+ setLoadingTimeout.current = undefined;
64
+ }, 50);
65
+ }
44
66
  return "".concat(urlFromProps, "#").concat(urlHash);
45
67
  }, [urlFromProps, urlHash]);
46
- return /*#__PURE__*/_jsx("div", {
68
+ var handleOnLoad = useCallback(function () {
69
+ setLoading(false);
70
+ onLoad === null || onLoad === void 0 || onLoad();
71
+ }, [onLoad]);
72
+ var handleOnError = useCallback(function (error) {
73
+ setLoading(false);
74
+ onError === null || onError === void 0 || onError(error);
75
+ }, [onError]);
76
+ return /*#__PURE__*/_jsxs("div", {
47
77
  className: cx(styles.root, className),
48
78
  id: id,
49
79
  style: _objectSpread({
50
80
  height: height
51
81
  }, style),
52
- children: /*#__PURE__*/_jsx(ScrollFollow, {
82
+ children: [/*#__PURE__*/_jsx(ScrollFollow, {
53
83
  render: function render(_ref2) {
54
84
  var follow = _ref2.follow,
55
85
  onFollowScroll = _ref2.onScroll;
@@ -71,6 +101,8 @@ export var LogViewer = function LogViewer(_ref) {
71
101
  className: styles.searchBarIcon,
72
102
  icon: ArrowUp
73
103
  }),
104
+ onError: handleOnError,
105
+ onLoad: handleOnLoad,
74
106
  onScroll: function onScroll(args) {
75
107
  onFollowScroll(args);
76
108
  _onScroll === null || _onScroll === void 0 || _onScroll(args);
@@ -78,6 +110,10 @@ export var LogViewer = function LogViewer(_ref) {
78
110
  }));
79
111
  },
80
112
  startFollowing: true
81
- })
113
+ }), loading && /*#__PURE__*/_jsx(Icon, {
114
+ className: styles.loader,
115
+ icon: LoaderCircle,
116
+ spin: true
117
+ })]
82
118
  });
83
119
  };
@@ -1,4 +1,5 @@
1
1
  export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
2
  root: import("antd-style").SerializedStyles;
3
3
  searchBarIcon: import("antd-style").SerializedStyles;
4
+ loader: import("antd-style").SerializedStyles;
4
5
  }>;
@@ -1,13 +1,14 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2;
2
+ var _templateObject, _templateObject2, _templateObject3;
3
3
  import { createStyles } from 'antd-style';
4
4
  export var useStyles = createStyles(function (_ref) {
5
5
  var css = _ref.css,
6
6
  token = _ref.token;
7
7
  var bgColor = '#222222';
8
8
  return {
9
- root: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border-radius: ", "px;\n .react-lazylog-searchbar {\n margin-bottom: ", "px;\n padding: ", "px;\n\n background-color: ", ";\n border-bottom: 1px solid #2d2d2d;\n border-top-left-radius: ", "px;\n border-top-right-radius: ", "px;\n & > input {\n border-radius: ", "px;\n }\n & > button {\n cursor: pointer;\n padding: 2px 6px;\n border-radius: ", "px;\n }\n &-up-arrow {\n margin-right: 0;\n }\n }\n .react-lazylog {\n background-color: ", ";\n border-radius: ", "px;\n .log-number {\n margin-right: 0;\n }\n .log-content {\n margin-left: 15px;\n }\n }\n "])), bgColor, token.borderRadiusLG, token.marginXXS, token.paddingXS, bgColor, token.borderRadiusLG, token.borderRadiusLG, token.borderRadius, token.borderRadius, bgColor, token.borderRadiusLG),
10
- searchBarIcon: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 16px;\n "])))
9
+ root: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n background-color: ", ";\n border-radius: ", "px;\n\n .react-lazylog-searchbar {\n margin-bottom: ", "px;\n padding: ", "px;\n\n background-color: ", ";\n border-bottom: 1px solid #2d2d2d;\n border-top-left-radius: ", "px;\n border-top-right-radius: ", "px;\n & > input {\n border-radius: ", "px;\n }\n & > button {\n cursor: pointer;\n padding: 2px 6px;\n border-radius: ", "px;\n }\n &-up-arrow {\n margin-right: 0;\n }\n }\n .react-lazylog {\n scrollbar-color: rgba(255, 255, 255, 0.2) transparent;\n scrollbar-width: auto;\n background-color: ", ";\n border-radius: ", "px;\n\n .log-number {\n margin-right: 0;\n }\n .log-content {\n margin-left: 15px;\n }\n }\n "])), bgColor, token.borderRadiusLG, token.marginXXS, token.paddingXS, bgColor, token.borderRadiusLG, token.borderRadiusLG, token.borderRadius, token.borderRadius, bgColor, token.borderRadiusLG),
10
+ searchBarIcon: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 16px;\n "]))),
11
+ loader: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n right: ", "px;\n bottom: ", "px;\n\n font-size: ", "px;\n color: ", ";\n "])), token.marginSM, token.marginSM, token.fontSizeLG, token.colorTextTertiary)
11
12
  };
12
13
  }, {
13
14
  hashPriority: 'low'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuntijs/ui",
3
- "version": "1.0.0-beta.60",
3
+ "version": "1.0.0-beta.61",
4
4
  "description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
5
5
  "keywords": [
6
6
  "yuntijs",