@lobehub/ui 1.68.0 → 1.70.0
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/ChatItem/components/Actions.d.ts +9 -0
- package/es/ChatItem/components/Actions.js +19 -0
- package/es/ChatItem/components/Avatar.d.ts +12 -0
- package/es/ChatItem/components/Avatar.js +42 -0
- package/es/ChatItem/components/BorderSpacing.d.ts +7 -0
- package/es/ChatItem/components/BorderSpacing.js +13 -0
- package/es/ChatItem/components/ErrorContent.d.ts +9 -0
- package/es/ChatItem/components/ErrorContent.js +27 -0
- package/es/ChatItem/components/Loading.d.ts +8 -0
- package/es/ChatItem/components/Loading.js +26 -0
- package/es/ChatItem/components/MessageContent.d.ts +16 -0
- package/es/ChatItem/components/MessageContent.js +45 -0
- package/es/ChatItem/components/Title.d.ts +10 -0
- package/es/ChatItem/components/Title.js +23 -0
- package/es/ChatItem/index.d.ts +3 -74
- package/es/ChatItem/index.js +44 -71
- package/es/ChatItem/style.d.ts +2 -1
- package/es/ChatItem/style.js +10 -9
- package/es/ChatItem/type.d.ts +76 -0
- package/es/ChatItem/type.js +1 -0
- package/es/ChatList/Group.d.ts +8 -0
- package/es/ChatList/Group.js +74 -0
- package/es/ChatList/Item.d.ts +9 -2
- package/es/ChatList/Item.js +20 -13
- package/es/ChatList/index.d.ts +2 -7
- package/es/ChatList/index.js +14 -5
- package/es/GridBackground/Grid.d.ts +26 -0
- package/es/GridBackground/Grid.js +99 -0
- package/es/GridBackground/GridShowcase.d.ts +8 -0
- package/es/GridBackground/GridShowcase.js +49 -0
- package/es/GridBackground/index.d.ts +16 -0
- package/es/GridBackground/index.js +87 -0
- package/es/GridBackground/style.d.ts +9 -0
- package/es/GridBackground/style.js +22 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/types/chatMessage.d.ts +5 -2
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChatItemProps } from "..";
|
|
3
|
+
export interface ActionsProps {
|
|
4
|
+
actions: ChatItemProps['actions'];
|
|
5
|
+
placement?: ChatItemProps['placement'];
|
|
6
|
+
type?: ChatItemProps['type'];
|
|
7
|
+
}
|
|
8
|
+
declare const Actions: import("react").NamedExoticComponent<ActionsProps>;
|
|
9
|
+
export default Actions;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { useStyles } from "../style";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
var Actions = /*#__PURE__*/memo(function (_ref) {
|
|
5
|
+
var actions = _ref.actions,
|
|
6
|
+
placement = _ref.placement,
|
|
7
|
+
type = _ref.type;
|
|
8
|
+
var _useStyles = useStyles({
|
|
9
|
+
placement: placement,
|
|
10
|
+
type: type
|
|
11
|
+
}),
|
|
12
|
+
styles = _useStyles.styles;
|
|
13
|
+
return /*#__PURE__*/_jsx("div", {
|
|
14
|
+
className: styles.actions,
|
|
15
|
+
role: "chat-item-actions",
|
|
16
|
+
children: actions
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
export default Actions;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ChatItemProps } from '../type';
|
|
3
|
+
export interface AvatarProps {
|
|
4
|
+
addon?: ChatItemProps['avatarAddon'];
|
|
5
|
+
avatar: ChatItemProps['avatar'];
|
|
6
|
+
loading?: ChatItemProps['loading'];
|
|
7
|
+
onClick?: ChatItemProps['onAvatarClick'];
|
|
8
|
+
placement?: ChatItemProps['placement'];
|
|
9
|
+
size?: number;
|
|
10
|
+
}
|
|
11
|
+
declare const Avatar: import("react").NamedExoticComponent<AvatarProps>;
|
|
12
|
+
export default Avatar;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { Flexbox } from 'react-layout-kit';
|
|
3
|
+
import A from "../../Avatar";
|
|
4
|
+
import { useStyles } from "../style";
|
|
5
|
+
import Loading from "./Loading";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
var Avatar = /*#__PURE__*/memo(function (_ref) {
|
|
9
|
+
var loading = _ref.loading,
|
|
10
|
+
avatar = _ref.avatar,
|
|
11
|
+
placement = _ref.placement,
|
|
12
|
+
addon = _ref.addon,
|
|
13
|
+
onClick = _ref.onClick,
|
|
14
|
+
_ref$size = _ref.size,
|
|
15
|
+
size = _ref$size === void 0 ? 40 : _ref$size;
|
|
16
|
+
var _useStyles = useStyles({
|
|
17
|
+
avatarSize: size
|
|
18
|
+
}),
|
|
19
|
+
styles = _useStyles.styles;
|
|
20
|
+
var avatarContent = /*#__PURE__*/_jsxs("div", {
|
|
21
|
+
className: styles.avatarContainer,
|
|
22
|
+
children: [/*#__PURE__*/_jsx(A, {
|
|
23
|
+
animation: loading,
|
|
24
|
+
avatar: avatar.avatar,
|
|
25
|
+
background: avatar.backgroundColor,
|
|
26
|
+
onClick: onClick,
|
|
27
|
+
size: size,
|
|
28
|
+
title: avatar.title
|
|
29
|
+
}), /*#__PURE__*/_jsx(Loading, {
|
|
30
|
+
loading: loading,
|
|
31
|
+
placement: placement
|
|
32
|
+
})]
|
|
33
|
+
});
|
|
34
|
+
if (!addon) return avatarContent;
|
|
35
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
36
|
+
align: 'center',
|
|
37
|
+
className: styles.avatarGroupContainer,
|
|
38
|
+
gap: 8,
|
|
39
|
+
children: [avatarContent, addon]
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
export default Avatar;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChatItemProps } from "..";
|
|
3
|
+
export interface BorderSpacingProps {
|
|
4
|
+
borderSpacing?: ChatItemProps['borderSpacing'];
|
|
5
|
+
}
|
|
6
|
+
declare const BorderSpacing: import("react").NamedExoticComponent<BorderSpacingProps>;
|
|
7
|
+
export default BorderSpacing;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
var BorderSpacing = /*#__PURE__*/memo(function (_ref) {
|
|
4
|
+
var borderSpacing = _ref.borderSpacing;
|
|
5
|
+
if (!borderSpacing) return null;
|
|
6
|
+
return /*#__PURE__*/_jsx("div", {
|
|
7
|
+
style: {
|
|
8
|
+
flex: 'none',
|
|
9
|
+
width: borderSpacing
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
export default BorderSpacing;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChatItemProps } from "..";
|
|
3
|
+
export interface ErrorContentProps {
|
|
4
|
+
ErrorMessage?: ChatItemProps['ErrorMessage'];
|
|
5
|
+
error?: ChatItemProps['error'];
|
|
6
|
+
placement?: ChatItemProps['placement'];
|
|
7
|
+
}
|
|
8
|
+
declare const ErrorContent: import("react").NamedExoticComponent<ErrorContentProps>;
|
|
9
|
+
export default ErrorContent;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { Alert } from 'antd';
|
|
5
|
+
import { memo } from 'react';
|
|
6
|
+
import { Flexbox } from 'react-layout-kit';
|
|
7
|
+
import { useStyles } from "../style";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
var ErrorContent = /*#__PURE__*/memo(function (_ref) {
|
|
11
|
+
var ErrorMessage = _ref.ErrorMessage,
|
|
12
|
+
error = _ref.error,
|
|
13
|
+
placement = _ref.placement;
|
|
14
|
+
var _useStyles = useStyles({
|
|
15
|
+
placement: placement
|
|
16
|
+
}),
|
|
17
|
+
styles = _useStyles.styles;
|
|
18
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
19
|
+
gap: 8,
|
|
20
|
+
children: [/*#__PURE__*/_jsx(Alert, _objectSpread({
|
|
21
|
+
className: styles.alert,
|
|
22
|
+
showIcon: true,
|
|
23
|
+
type: 'error'
|
|
24
|
+
}, error)), ErrorMessage]
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
export default ErrorContent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChatItemProps } from "..";
|
|
3
|
+
export interface LoadingProps {
|
|
4
|
+
loading?: ChatItemProps['loading'];
|
|
5
|
+
placement?: ChatItemProps['placement'];
|
|
6
|
+
}
|
|
7
|
+
declare const Loading: import("react").NamedExoticComponent<LoadingProps>;
|
|
8
|
+
export default Loading;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Loader2 } from 'lucide-react';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import Icon from "../../Icon";
|
|
4
|
+
import { useStyles } from "../style";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
var Loading = /*#__PURE__*/memo(function (_ref) {
|
|
7
|
+
var loading = _ref.loading,
|
|
8
|
+
placement = _ref.placement;
|
|
9
|
+
var _useStyles = useStyles({
|
|
10
|
+
placement: placement
|
|
11
|
+
}),
|
|
12
|
+
styles = _useStyles.styles;
|
|
13
|
+
if (!loading) return null;
|
|
14
|
+
return /*#__PURE__*/_jsx("div", {
|
|
15
|
+
className: styles.loading,
|
|
16
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
17
|
+
icon: Loader2,
|
|
18
|
+
size: {
|
|
19
|
+
fontSize: 12,
|
|
20
|
+
strokeWidth: 3
|
|
21
|
+
},
|
|
22
|
+
spin: true
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
export default Loading;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { ChatItemProps } from "..";
|
|
3
|
+
export interface LoadingProps {
|
|
4
|
+
editing?: ChatItemProps['editing'];
|
|
5
|
+
message?: ReactNode;
|
|
6
|
+
messageExtra?: ChatItemProps['messageExtra'];
|
|
7
|
+
onChange?: ChatItemProps['onChange'];
|
|
8
|
+
onEditingChange?: ChatItemProps['onEditingChange'];
|
|
9
|
+
placement?: ChatItemProps['placement'];
|
|
10
|
+
primary?: ChatItemProps['primary'];
|
|
11
|
+
renderMessage?: ChatItemProps['renderMessage'];
|
|
12
|
+
text?: ChatItemProps['text'];
|
|
13
|
+
type?: ChatItemProps['type'];
|
|
14
|
+
}
|
|
15
|
+
declare const Loading: import("react").NamedExoticComponent<LoadingProps>;
|
|
16
|
+
export default Loading;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { Flexbox } from 'react-layout-kit';
|
|
3
|
+
import EditableMessage from "../../EditableMessage";
|
|
4
|
+
import { useStyles } from "../style";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
var Loading = /*#__PURE__*/memo(function (_ref) {
|
|
8
|
+
var editing = _ref.editing,
|
|
9
|
+
onChange = _ref.onChange,
|
|
10
|
+
onEditingChange = _ref.onEditingChange,
|
|
11
|
+
text = _ref.text,
|
|
12
|
+
message = _ref.message,
|
|
13
|
+
placement = _ref.placement,
|
|
14
|
+
messageExtra = _ref.messageExtra,
|
|
15
|
+
renderMessage = _ref.renderMessage,
|
|
16
|
+
type = _ref.type,
|
|
17
|
+
primary = _ref.primary;
|
|
18
|
+
var _useStyles = useStyles({
|
|
19
|
+
placement: placement,
|
|
20
|
+
primary: primary,
|
|
21
|
+
type: type
|
|
22
|
+
}),
|
|
23
|
+
cx = _useStyles.cx,
|
|
24
|
+
styles = _useStyles.styles;
|
|
25
|
+
var content = /*#__PURE__*/_jsx(EditableMessage, {
|
|
26
|
+
classNames: {
|
|
27
|
+
input: styles.editingInput
|
|
28
|
+
},
|
|
29
|
+
editButtonSize: 'small',
|
|
30
|
+
editing: editing,
|
|
31
|
+
onChange: onChange,
|
|
32
|
+
onEditingChange: onEditingChange,
|
|
33
|
+
text: text,
|
|
34
|
+
value: String(message || '...')
|
|
35
|
+
});
|
|
36
|
+
var messageContent = renderMessage ? renderMessage(content) : content;
|
|
37
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
38
|
+
className: cx(styles.message, editing && styles.editingContainer),
|
|
39
|
+
children: [messageContent, messageExtra && !editing ? /*#__PURE__*/_jsx("div", {
|
|
40
|
+
className: styles.messageExtra,
|
|
41
|
+
children: messageExtra
|
|
42
|
+
}) : null]
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
export default Loading;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChatItemProps } from "..";
|
|
3
|
+
export interface TitleProps {
|
|
4
|
+
avatar: ChatItemProps['avatar'];
|
|
5
|
+
placement?: ChatItemProps['placement'];
|
|
6
|
+
showTitle?: ChatItemProps['showTitle'];
|
|
7
|
+
time?: ChatItemProps['time'];
|
|
8
|
+
}
|
|
9
|
+
declare const Title: import("react").NamedExoticComponent<TitleProps>;
|
|
10
|
+
export default Title;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { formatTime } from "../../utils/formatTime";
|
|
3
|
+
import { useStyles } from "../style";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
var Title = /*#__PURE__*/memo(function (_ref) {
|
|
7
|
+
var showTitle = _ref.showTitle,
|
|
8
|
+
placement = _ref.placement,
|
|
9
|
+
time = _ref.time,
|
|
10
|
+
avatar = _ref.avatar;
|
|
11
|
+
var _useStyles = useStyles({
|
|
12
|
+
placement: placement,
|
|
13
|
+
showTitle: showTitle
|
|
14
|
+
}),
|
|
15
|
+
styles = _useStyles.styles;
|
|
16
|
+
return /*#__PURE__*/_jsxs("title", {
|
|
17
|
+
className: styles.name,
|
|
18
|
+
children: [showTitle ? avatar.title || 'untitled' : undefined, time && /*#__PURE__*/_jsx("time", {
|
|
19
|
+
children: formatTime(time)
|
|
20
|
+
})]
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
export default Title;
|
package/es/ChatItem/index.d.ts
CHANGED
|
@@ -1,76 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { type EditableMessageProps } from "../EditableMessage";
|
|
4
|
-
import { MetaData } from "../types/meta";
|
|
5
|
-
export interface ChatItemProps {
|
|
6
|
-
ErrorMessage?: ReactNode;
|
|
7
|
-
/**
|
|
8
|
-
* @description Actions to be displayed in the chat item
|
|
9
|
-
*/
|
|
10
|
-
actions?: ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
* @description Metadata for the avatar
|
|
13
|
-
*/
|
|
14
|
-
avatar: MetaData;
|
|
15
|
-
/**
|
|
16
|
-
* @description Whether to add border spacing
|
|
17
|
-
*/
|
|
18
|
-
borderSpacing?: number | string;
|
|
19
|
-
/**
|
|
20
|
-
* @description Custom CSS class name for the chat item
|
|
21
|
-
*/
|
|
22
|
-
className?: string;
|
|
23
|
-
/**
|
|
24
|
-
* @description Whether the chat item is in editing mode
|
|
25
|
-
*/
|
|
26
|
-
editing?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* @description Props for Error render
|
|
29
|
-
*/
|
|
30
|
-
error?: AlertProps;
|
|
31
|
-
/**
|
|
32
|
-
* @description Whether the chat item is in loading state
|
|
33
|
-
*/
|
|
34
|
-
loading?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* @description The message content of the chat item
|
|
37
|
-
*/
|
|
38
|
-
message?: ReactNode;
|
|
39
|
-
messageExtra?: ReactNode;
|
|
40
|
-
/**
|
|
41
|
-
* @description Callback when the message content changes
|
|
42
|
-
* @param value - The new message content
|
|
43
|
-
*/
|
|
44
|
-
onChange?: (value: string) => void;
|
|
45
|
-
/**
|
|
46
|
-
* @description Callback when the editing mode changes
|
|
47
|
-
* @param editing - The new editing mode
|
|
48
|
-
*/
|
|
49
|
-
onEditingChange?: (editing: boolean) => void;
|
|
50
|
-
/**
|
|
51
|
-
* @description The placement of the chat item
|
|
52
|
-
* @default 'left'
|
|
53
|
-
*/
|
|
54
|
-
placement?: 'left' | 'right';
|
|
55
|
-
/**
|
|
56
|
-
* @description Whether the chat item is primary
|
|
57
|
-
*/
|
|
58
|
-
primary?: boolean;
|
|
59
|
-
renderMessage?: (content: ReactNode) => ReactNode;
|
|
60
|
-
/**
|
|
61
|
-
* @description Whether to show the title of the chat item
|
|
62
|
-
*/
|
|
63
|
-
showTitle?: boolean;
|
|
64
|
-
text?: EditableMessageProps['text'];
|
|
65
|
-
/**
|
|
66
|
-
* @description The timestamp of the chat item
|
|
67
|
-
*/
|
|
68
|
-
time?: number;
|
|
69
|
-
/**
|
|
70
|
-
* @description The type of the chat item
|
|
71
|
-
* @default 'block'
|
|
72
|
-
*/
|
|
73
|
-
type?: 'block' | 'pure';
|
|
74
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ChatItemProps } from './type';
|
|
75
3
|
declare const ChatItem: import("react").NamedExoticComponent<ChatItemProps>;
|
|
76
4
|
export default ChatItem;
|
|
5
|
+
export type { ChatItemProps } from './type';
|
package/es/ChatItem/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["actions", "className", "primary", "borderSpacing", "loading", "message", "placement", "type", "avatar", "error", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra", "renderMessage", "text", "ErrorMessage"];
|
|
3
|
+
var _excluded = ["avatarAddon", "onAvatarClick", "actions", "className", "primary", "borderSpacing", "loading", "message", "placement", "type", "avatar", "error", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra", "renderMessage", "text", "ErrorMessage"];
|
|
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
|
-
import { Alert } from 'antd';
|
|
7
|
-
import { Loader2 } from 'lucide-react';
|
|
8
6
|
import { memo } from 'react';
|
|
9
|
-
import
|
|
10
|
-
import Avatar from "
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
7
|
+
import Actions from "./components/Actions";
|
|
8
|
+
import Avatar from "./components/Avatar";
|
|
9
|
+
import BorderSpacing from "./components/BorderSpacing";
|
|
10
|
+
import ErrorContent from "./components/ErrorContent";
|
|
11
|
+
import MessageContent from "./components/MessageContent";
|
|
12
|
+
import Title from "./components/Title";
|
|
14
13
|
import { useStyles } from "./style";
|
|
15
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
var AVATAR_SIZE = 40;
|
|
18
16
|
var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
19
|
-
var
|
|
17
|
+
var avatarAddon = _ref.avatarAddon,
|
|
18
|
+
onAvatarClick = _ref.onAvatarClick,
|
|
19
|
+
actions = _ref.actions,
|
|
20
20
|
className = _ref.className,
|
|
21
21
|
primary = _ref.primary,
|
|
22
22
|
borderSpacing = _ref.borderSpacing,
|
|
@@ -37,9 +37,8 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
37
37
|
renderMessage = _ref.renderMessage,
|
|
38
38
|
text = _ref.text,
|
|
39
39
|
ErrorMessage = _ref.ErrorMessage,
|
|
40
|
-
|
|
40
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
41
|
var _useStyles = useStyles({
|
|
42
|
-
avatarSize: AVATAR_SIZE,
|
|
43
42
|
placement: placement,
|
|
44
43
|
primary: primary,
|
|
45
44
|
showTitle: showTitle,
|
|
@@ -48,73 +47,47 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
48
47
|
}),
|
|
49
48
|
cx = _useStyles.cx,
|
|
50
49
|
styles = _useStyles.styles;
|
|
51
|
-
var content = /*#__PURE__*/_jsx(EditableMessage, {
|
|
52
|
-
classNames: {
|
|
53
|
-
input: styles.editingInput
|
|
54
|
-
},
|
|
55
|
-
editButtonSize: 'small',
|
|
56
|
-
editing: editing,
|
|
57
|
-
onChange: onChange,
|
|
58
|
-
onEditingChange: onEditingChange,
|
|
59
|
-
text: text,
|
|
60
|
-
value: String(message || '...')
|
|
61
|
-
});
|
|
62
|
-
var messageContent = renderMessage ? renderMessage(content) : content;
|
|
63
50
|
return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
|
|
64
51
|
className: cx(styles.container, className)
|
|
65
|
-
},
|
|
66
|
-
children: [/*#__PURE__*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
size: AVATAR_SIZE,
|
|
73
|
-
title: avatar.title
|
|
74
|
-
}), loading && /*#__PURE__*/_jsx("div", {
|
|
75
|
-
className: styles.loading,
|
|
76
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
|
77
|
-
icon: Loader2,
|
|
78
|
-
size: {
|
|
79
|
-
fontSize: 12,
|
|
80
|
-
strokeWidth: 3
|
|
81
|
-
},
|
|
82
|
-
spin: true
|
|
83
|
-
})
|
|
84
|
-
})]
|
|
52
|
+
}, props), {}, {
|
|
53
|
+
children: [/*#__PURE__*/_jsx(Avatar, {
|
|
54
|
+
addon: avatarAddon,
|
|
55
|
+
avatar: avatar,
|
|
56
|
+
loading: loading,
|
|
57
|
+
onClick: onAvatarClick,
|
|
58
|
+
placement: placement
|
|
85
59
|
}), /*#__PURE__*/_jsxs("div", {
|
|
86
60
|
className: styles.messageContainer,
|
|
87
|
-
children: [/*#__PURE__*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
61
|
+
children: [/*#__PURE__*/_jsx(Title, {
|
|
62
|
+
avatar: avatar,
|
|
63
|
+
placement: placement,
|
|
64
|
+
showTitle: showTitle,
|
|
65
|
+
time: time
|
|
92
66
|
}), /*#__PURE__*/_jsxs("div", {
|
|
93
67
|
className: styles.messageContent,
|
|
94
|
-
children: [error ? /*#__PURE__*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
68
|
+
children: [error ? /*#__PURE__*/_jsx(ErrorContent, {
|
|
69
|
+
ErrorMessage: ErrorMessage,
|
|
70
|
+
error: error,
|
|
71
|
+
placement: placement
|
|
72
|
+
}) : /*#__PURE__*/_jsx(MessageContent, {
|
|
73
|
+
editing: editing,
|
|
74
|
+
message: message,
|
|
75
|
+
messageExtra: messageExtra,
|
|
76
|
+
onChange: onChange,
|
|
77
|
+
onEditingChange: onEditingChange,
|
|
78
|
+
placement: placement,
|
|
79
|
+
primary: primary,
|
|
80
|
+
renderMessage: renderMessage,
|
|
81
|
+
text: text,
|
|
82
|
+
type: type
|
|
83
|
+
}), !editing && /*#__PURE__*/_jsx(Actions, {
|
|
84
|
+
actions: actions,
|
|
85
|
+
placement: placement,
|
|
86
|
+
type: type
|
|
111
87
|
})]
|
|
112
88
|
})]
|
|
113
|
-
}),
|
|
114
|
-
|
|
115
|
-
flex: 'none',
|
|
116
|
-
width: borderSpacing
|
|
117
|
-
}
|
|
89
|
+
}), /*#__PURE__*/_jsx(BorderSpacing, {
|
|
90
|
+
borderSpacing: borderSpacing
|
|
118
91
|
})]
|
|
119
92
|
}));
|
|
120
93
|
});
|
package/es/ChatItem/style.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const useStyles: (props?: {
|
|
2
|
-
avatarSize
|
|
2
|
+
avatarSize?: number | undefined;
|
|
3
3
|
placement?: "left" | "right" | undefined;
|
|
4
4
|
primary?: boolean | undefined;
|
|
5
5
|
showTitle?: boolean | undefined;
|
|
@@ -9,6 +9,7 @@ export declare const useStyles: (props?: {
|
|
|
9
9
|
actions: import("antd-style").SerializedStyles;
|
|
10
10
|
alert: import("antd-style").SerializedStyles;
|
|
11
11
|
avatarContainer: import("antd-style").SerializedStyles;
|
|
12
|
+
avatarGroupContainer: import("antd-style").SerializedStyles;
|
|
12
13
|
container: string;
|
|
13
14
|
editingContainer: string;
|
|
14
15
|
editingInput: import("antd-style").SerializedStyles;
|
package/es/ChatItem/style.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16;
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { rgba } from 'polished';
|
|
5
5
|
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
@@ -21,14 +21,15 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
21
21
|
actions: css(_templateObject4 || (_templateObject4 = _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'),
|
|
22
22
|
alert: css(_templateObject5 || (_templateObject5 = _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 "]))),
|
|
23
23
|
avatarContainer: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
avatarGroupContainer: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), avatarSize),
|
|
25
|
+
container: cx(type === 'pure' && pureContainerStylish, css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: ", ";\n gap: 12px;\n align-items: flex-start;\n justify-content: revert;\n\n width: 100%;\n padding: 12px;\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 "])), placement === 'left' ? 'row' : 'row-reverse', token.motionEaseOut)),
|
|
26
|
+
editingContainer: cx(css(_templateObject9 || (_templateObject9 = _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(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: ", "px;\n "])), token.colorFillQuaternary, token.borderRadius)),
|
|
27
|
+
editingInput: css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n min-height: 32px;\n "]))),
|
|
28
|
+
loading: css(_templateObject12 || (_templateObject12 = _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),
|
|
29
|
+
message: cx(typeStylish, css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n position: relative;\n "])))),
|
|
30
|
+
messageContainer: css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: ", ";\n "])), placement === 'left' ? 'flex-start' : 'flex-end'),
|
|
31
|
+
messageContent: css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n position: revert;\n\n display: flex;\n flex-direction: ", ";\n gap: 8px;\n align-items: ", ";\n "])), type === 'block' ? placement === 'left' ? 'row' : 'row-reverse' : 'column', placement === 'left' ? 'flex-start' : 'flex-end'),
|
|
31
32
|
messageExtra: cx('message-extra'),
|
|
32
|
-
name: css(
|
|
33
|
+
name: css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n right: ", ";\n left: ", ";\n\n display: flex;\n flex-direction: ", ";\n gap: 4px;\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')
|
|
33
34
|
};
|
|
34
35
|
});
|