@hh.ru/magritte-ui-chat-bubble 3.0.6 → 3.0.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.
- package/Call.d.ts +2 -2
- package/Call.js +41 -9
- package/Call.js.map +1 -1
- package/ChatBubble.d.ts +10 -10
- package/ChatBubble.js +92 -16
- package/ChatBubble.js.map +1 -1
- package/ErrorAction.js +8 -9
- package/ErrorAction.js.map +1 -1
- package/File.d.ts +2 -2
- package/File.js +59 -15
- package/File.js.map +1 -1
- package/Label.js +4 -7
- package/Label.js.map +1 -1
- package/Media.d.ts +2 -2
- package/Media.js +15 -8
- package/Media.js.map +1 -1
- package/Message.d.ts +2 -2
- package/Message.js +11 -9
- package/Message.js.map +1 -1
- package/Meta.d.ts +1 -1
- package/Meta.js +12 -10
- package/Meta.js.map +1 -1
- package/Reply.js +31 -8
- package/Reply.js.map +1 -1
- package/Snippet.js +21 -8
- package/Snippet.js.map +1 -1
- package/Status.js +28 -19
- package/Status.js.map +1 -1
- package/Tail.js +20 -5
- package/Tail.js.map +1 -1
- package/chat-bubble-BOBGge0h.js +5 -0
- package/chat-bubble-BOBGge0h.js.map +1 -0
- package/index.css +114 -114
- package/index.d.ts +11 -11
- package/index.js +1 -1
- package/index.mock.d.ts +10 -10
- package/index.mock.js +19 -19
- package/index.mock.js.map +1 -1
- package/internal/colors.d.ts +1 -1
- package/internal/colors.js +36 -37
- package/internal/colors.js.map +1 -1
- package/internal/errorMenu.js +1 -1
- package/internal/errorMenu.js.map +1 -1
- package/internal/mode.d.ts +1 -1
- package/internal/mode.js +1 -2
- package/internal/mode.js.map +1 -1
- package/internal/utils.js +10 -10
- package/internal/utils.js.map +1 -1
- package/package.json +11 -11
- package/chat-bubble-C5CrJD5o.js +0 -5
- package/chat-bubble-C5CrJD5o.js.map +0 -1
package/Call.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import { type ChatBubbleMetaHostProps } from '
|
|
2
|
+
import { type ChatBubbleMetaHostProps } from './internal/utils';
|
|
3
3
|
export type ChatBubbleCallState = 'connected' | 'not-connected';
|
|
4
4
|
type ChatBubbleCallHelper = HTMLAttributes<HTMLDivElement> & ChatBubbleMetaHostProps;
|
|
5
5
|
export interface ChatBubbleCallProps extends Omit<ChatBubbleCallHelper, 'children' | 'title'> {
|
|
@@ -20,5 +20,5 @@ export interface ChatBubbleCallProps extends Omit<ChatBubbleCallHelper, 'childre
|
|
|
20
20
|
*/
|
|
21
21
|
'data-qa'?: string;
|
|
22
22
|
}
|
|
23
|
-
export declare const ChatBubbleCall: import("react").ForwardRefExoticComponent<ChatBubbleCallProps & import("react").RefAttributes<HTMLDivElement>> & import("
|
|
23
|
+
export declare const ChatBubbleCall: import("react").ForwardRefExoticComponent<ChatBubbleCallProps & import("react").RefAttributes<HTMLDivElement>> & import("./internal/utils").MetaHostComponent;
|
|
24
24
|
export {};
|
package/Call.js
CHANGED
|
@@ -6,18 +6,50 @@ import { useChatBubbleColors } from './internal/colors.js';
|
|
|
6
6
|
import { useChatBubbleMode } from './internal/mode.js';
|
|
7
7
|
import { markMetaHost } from './internal/utils.js';
|
|
8
8
|
import { PhoneCrossFilledSize24, PhoneArrowOutFilledSize24, PhoneArrowInFilledSize24 } from '@hh.ru/magritte-ui-icon/icon';
|
|
9
|
-
import { s as styles } from './chat-bubble-
|
|
9
|
+
import { s as styles } from './chat-bubble-BOBGge0h.js';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const ChatBubbleCallComponent = forwardRef(
|
|
12
|
+
({ "data-qa": dataQa = "chat-bubble-call", title, description, meta, state = "connected", ...props }, ref) => {
|
|
13
13
|
const mode = useChatBubbleMode();
|
|
14
14
|
const colors = useChatBubbleColors();
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const connectedIcon = mode === "outgoing" ? PhoneArrowOutFilledSize24 : PhoneArrowInFilledSize24;
|
|
16
|
+
const Icon = state === "connected" ? connectedIcon : PhoneCrossFilledSize24;
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", { ...props, className: styles.file, "data-qa": dataQa, ref, children: [
|
|
18
|
+
/* @__PURE__ */ jsxs(
|
|
19
|
+
Cell,
|
|
20
|
+
{
|
|
21
|
+
align: "center",
|
|
22
|
+
horPadding: false,
|
|
23
|
+
vertPadding: false,
|
|
24
|
+
left: /* @__PURE__ */ jsx(
|
|
25
|
+
Icon,
|
|
26
|
+
{
|
|
27
|
+
initialColor: colors.fileIcon,
|
|
28
|
+
backgroundStyle: colors.fileIconBackground,
|
|
29
|
+
padding: 12,
|
|
30
|
+
borderRadius: 8
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx(CellText, { type: "title", style: colors.text, maxLines: 1, "data-qa": "chat-bubble-call-name", children: title }),
|
|
35
|
+
description && /* @__PURE__ */ jsx(
|
|
36
|
+
CellText,
|
|
37
|
+
{
|
|
38
|
+
type: "subtitle",
|
|
39
|
+
style: state === "not-connected" && mode === "incoming" ? "negative" : colors.secondaryText,
|
|
40
|
+
maxLines: 1,
|
|
41
|
+
"data-qa": "chat-bubble-call-description",
|
|
42
|
+
children: description
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
meta
|
|
49
|
+
] });
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
ChatBubbleCallComponent.displayName = "ChatBubbleCall";
|
|
21
53
|
const ChatBubbleCall = markMetaHost(ChatBubbleCallComponent);
|
|
22
54
|
|
|
23
55
|
export { ChatBubbleCall };
|
package/Call.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Call.js","sources":["src/Call.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { useChatBubbleColors } from '@hh.ru/magritte-ui-chat-bubble/internal/colors';\nimport { useChatBubbleMode } from '@hh.ru/magritte-ui-chat-bubble/internal/mode';\nimport { markMetaHost, type ChatBubbleMetaHostProps } from '@hh.ru/magritte-ui-chat-bubble/internal/utils';\nimport {\n PhoneArrowInFilledSize24,\n PhoneArrowOutFilledSize24,\n PhoneCrossFilledSize24,\n} from '@hh.ru/magritte-ui-icon/icon';\n\nimport styles from './chat-bubble.less';\n\nexport type ChatBubbleCallState = 'connected' | 'not-connected';\n\ntype ChatBubbleCallHelper = HTMLAttributes<HTMLDivElement> & ChatBubbleMetaHostProps;\n\nexport interface ChatBubbleCallProps extends Omit<ChatBubbleCallHelper, 'children' | 'title'> {\n /** Заголовок */\n title?: ReactNode;\n /**\n * Строка под заголовком (например, для длительности звонка)\n */\n description?: ReactNode;\n /**\n * Состояние звонка\n * @default connected\n */\n state?: ChatBubbleCallState;\n /**\n * Значение data-qa\n * @default chat-bubble-call\n */\n 'data-qa'?: string;\n}\n\n/** Входящий/исходящий звонок */\nconst ChatBubbleCallComponent = forwardRef<HTMLDivElement, ChatBubbleCallProps>(\n ({ 'data-qa': dataQa = 'chat-bubble-call', title, description, meta, state = 'connected', ...props }, ref) => {\n const mode = useChatBubbleMode();\n const colors = useChatBubbleColors();\n // у несостоявшегося звонка - крестик в любом режиме, иначе - стрелка по направлению\n const connectedIcon = mode === 'outgoing' ? PhoneArrowOutFilledSize24 : PhoneArrowInFilledSize24;\n const Icon = state === 'connected' ? connectedIcon : PhoneCrossFilledSize24;\n\n return (\n <div {...props} className={styles.file} data-qa={dataQa} ref={ref}>\n <Cell\n align=\"center\"\n horPadding={false}\n vertPadding={false}\n left={\n <Icon\n initialColor={colors.fileIcon}\n backgroundStyle={colors.fileIconBackground}\n padding={12}\n borderRadius={8}\n />\n }\n >\n <CellText type=\"title\" style={colors.text} maxLines={1} data-qa=\"chat-bubble-call-name\">\n {title}\n </CellText>\n {description && (\n <CellText\n type=\"subtitle\"\n style={state === 'not-connected' && mode === 'incoming' ? 'negative' : colors.secondaryText}\n maxLines={1}\n data-qa=\"chat-bubble-call-description\"\n >\n {description}\n </CellText>\n )}\n </Cell>\n {meta}\n </div>\n );\n }\n);\n\nChatBubbleCallComponent.displayName = 'ChatBubbleCall';\n\nexport const ChatBubbleCall = markMetaHost(ChatBubbleCallComponent);\n"],"names":[
|
|
1
|
+
{"version":3,"file":"Call.js","sources":["src/Call.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { useChatBubbleColors } from '@hh.ru/magritte-ui-chat-bubble/internal/colors';\nimport { useChatBubbleMode } from '@hh.ru/magritte-ui-chat-bubble/internal/mode';\nimport { markMetaHost, type ChatBubbleMetaHostProps } from '@hh.ru/magritte-ui-chat-bubble/internal/utils';\nimport {\n PhoneArrowInFilledSize24,\n PhoneArrowOutFilledSize24,\n PhoneCrossFilledSize24,\n} from '@hh.ru/magritte-ui-icon/icon';\n\nimport styles from './chat-bubble.less';\n\nexport type ChatBubbleCallState = 'connected' | 'not-connected';\n\ntype ChatBubbleCallHelper = HTMLAttributes<HTMLDivElement> & ChatBubbleMetaHostProps;\n\nexport interface ChatBubbleCallProps extends Omit<ChatBubbleCallHelper, 'children' | 'title'> {\n /** Заголовок */\n title?: ReactNode;\n /**\n * Строка под заголовком (например, для длительности звонка)\n */\n description?: ReactNode;\n /**\n * Состояние звонка\n * @default connected\n */\n state?: ChatBubbleCallState;\n /**\n * Значение data-qa\n * @default chat-bubble-call\n */\n 'data-qa'?: string;\n}\n\n/** Входящий/исходящий звонок */\nconst ChatBubbleCallComponent = forwardRef<HTMLDivElement, ChatBubbleCallProps>(\n ({ 'data-qa': dataQa = 'chat-bubble-call', title, description, meta, state = 'connected', ...props }, ref) => {\n const mode = useChatBubbleMode();\n const colors = useChatBubbleColors();\n // у несостоявшегося звонка - крестик в любом режиме, иначе - стрелка по направлению\n const connectedIcon = mode === 'outgoing' ? PhoneArrowOutFilledSize24 : PhoneArrowInFilledSize24;\n const Icon = state === 'connected' ? connectedIcon : PhoneCrossFilledSize24;\n\n return (\n <div {...props} className={styles.file} data-qa={dataQa} ref={ref}>\n <Cell\n align=\"center\"\n horPadding={false}\n vertPadding={false}\n left={\n <Icon\n initialColor={colors.fileIcon}\n backgroundStyle={colors.fileIconBackground}\n padding={12}\n borderRadius={8}\n />\n }\n >\n <CellText type=\"title\" style={colors.text} maxLines={1} data-qa=\"chat-bubble-call-name\">\n {title}\n </CellText>\n {description && (\n <CellText\n type=\"subtitle\"\n style={state === 'not-connected' && mode === 'incoming' ? 'negative' : colors.secondaryText}\n maxLines={1}\n data-qa=\"chat-bubble-call-description\"\n >\n {description}\n </CellText>\n )}\n </Cell>\n {meta}\n </div>\n );\n }\n);\n\nChatBubbleCallComponent.displayName = 'ChatBubbleCall';\n\nexport const ChatBubbleCall = markMetaHost(ChatBubbleCallComponent);\n"],"names":[],"mappings":";;;;;;;;;AAsCA,MAAM,uBAA0B,GAAA,UAAA;AAAA,EAC5B,CAAC,EAAE,SAAW,EAAA,MAAA,GAAS,kBAAoB,EAAA,KAAA,EAAO,WAAa,EAAA,IAAA,EAAM,KAAQ,GAAA,WAAA,EAAa,GAAG,KAAA,IAAS,GAAQ,KAAA;AAC1G,IAAA,MAAM,OAAO,iBAAkB,EAAA,CAAA;AAC/B,IAAA,MAAM,SAAS,mBAAoB,EAAA,CAAA;AAEnC,IAAM,MAAA,aAAA,GAAgB,IAAS,KAAA,UAAA,GAAa,yBAA4B,GAAA,wBAAA,CAAA;AACxE,IAAM,MAAA,IAAA,GAAO,KAAU,KAAA,WAAA,GAAc,aAAgB,GAAA,sBAAA,CAAA;AAErD,IACI,uBAAA,IAAA,CAAC,SAAK,GAAG,KAAA,EAAO,WAAW,MAAO,CAAA,IAAA,EAAM,SAAS,EAAA,MAAA,EAAQ,G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
4
|
-
import { ChatBubbleLabel } from '
|
|
5
|
-
import { ChatBubbleMedia } from '
|
|
6
|
-
import { ChatBubbleMessage } from '
|
|
7
|
-
import { ChatBubbleReply } from '
|
|
8
|
-
import { ChatBubbleSnippet } from '
|
|
9
|
-
import { ChatBubbleStatus } from '
|
|
10
|
-
import type { ChatBubbleProps } from '
|
|
1
|
+
import { ChatBubbleCall } from './Call';
|
|
2
|
+
import { ChatBubbleErrorAction } from './ErrorAction';
|
|
3
|
+
import { ChatBubbleFile } from './File';
|
|
4
|
+
import { ChatBubbleLabel } from './Label';
|
|
5
|
+
import { ChatBubbleMedia } from './Media';
|
|
6
|
+
import { ChatBubbleMessage } from './Message';
|
|
7
|
+
import { ChatBubbleReply } from './Reply';
|
|
8
|
+
import { ChatBubbleSnippet } from './Snippet';
|
|
9
|
+
import { ChatBubbleStatus } from './Status';
|
|
10
|
+
import type { ChatBubbleProps } from './types';
|
|
11
11
|
interface ChatBubbleComponents {
|
|
12
12
|
Call: typeof ChatBubbleCall;
|
|
13
13
|
ErrorAction: typeof ChatBubbleErrorAction;
|
package/ChatBubble.js
CHANGED
|
@@ -22,7 +22,7 @@ import { flattenFragments, isMetaHost } from './internal/utils.js';
|
|
|
22
22
|
import { ExclamationCircleFilledSize24 } from '@hh.ru/magritte-ui-icon/icon';
|
|
23
23
|
import { Menu } from '@hh.ru/magritte-ui-menu';
|
|
24
24
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
25
|
-
import { s as styles } from './chat-bubble-
|
|
25
|
+
import { s as styles } from './chat-bubble-BOBGge0h.js';
|
|
26
26
|
import '@hh.ru/magritte-ui-cell';
|
|
27
27
|
import '@hh.ru/magritte-ui-link';
|
|
28
28
|
import '@hh.ru/magritte-ui-loader';
|
|
@@ -30,7 +30,23 @@ import '@hh.ru/magritte-common-use-translation';
|
|
|
30
30
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
31
31
|
import '@hh.ru/magritte-ui-tooltip';
|
|
32
32
|
|
|
33
|
-
const ChatBubble = forwardRef(
|
|
33
|
+
const ChatBubble = forwardRef(
|
|
34
|
+
({
|
|
35
|
+
aside,
|
|
36
|
+
buttons,
|
|
37
|
+
children,
|
|
38
|
+
header,
|
|
39
|
+
edited,
|
|
40
|
+
errorActions,
|
|
41
|
+
mode = "incoming",
|
|
42
|
+
showTail = false,
|
|
43
|
+
status,
|
|
44
|
+
time,
|
|
45
|
+
error = false,
|
|
46
|
+
errorText,
|
|
47
|
+
"data-qa": dataQa = "chat-bubble",
|
|
48
|
+
className
|
|
49
|
+
}, ref) => {
|
|
34
50
|
const rowRef = useRef(null);
|
|
35
51
|
const activatorMenuRef = useRef(null);
|
|
36
52
|
const [menuVisible, setMenuVisible] = useState(false);
|
|
@@ -38,25 +54,85 @@ const ChatBubble = forwardRef(({ aside, buttons, children, header, edited, error
|
|
|
38
54
|
const [asideShow, setAsideShow] = useState(false);
|
|
39
55
|
const showAside = useCallback(() => setAsideShow(true), []);
|
|
40
56
|
const hideAside = useCallback(() => setAsideShow(false), []);
|
|
41
|
-
// скрываем aside при кликах вне
|
|
42
57
|
useCloseByClickOutside(rowRef, hideAside, asideShow);
|
|
43
58
|
const colors = getColors(mode);
|
|
44
|
-
const buttonsProps = useMemo(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
const meta = jsx(Meta, { mode: mode, status: status, time: time, edited: edited });
|
|
59
|
+
const buttonsProps = useMemo(
|
|
60
|
+
() => ({ size: "small", stretched: true, ...colors.button }),
|
|
61
|
+
[colors]
|
|
62
|
+
);
|
|
63
|
+
const meta = /* @__PURE__ */ jsx(Meta, { mode, status, time, edited });
|
|
51
64
|
const items = flattenFragments(children);
|
|
52
65
|
const lastIndex = items.length - 1;
|
|
53
66
|
const metaHosted = isMetaHost(items[lastIndex]);
|
|
54
|
-
const content = items.map(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
const content = items.map(
|
|
68
|
+
(child, index) => index === lastIndex && isMetaHost(child) ? cloneElement(child, { meta }) : child
|
|
69
|
+
);
|
|
70
|
+
return /* @__PURE__ */ jsx(ChatBubbleModeProvider, { value: mode, children: /* @__PURE__ */ jsxs(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
className: classnames(className, styles.chatBubble, styles[mode], {
|
|
74
|
+
[styles.withTail]: showTail
|
|
75
|
+
}),
|
|
76
|
+
"data-qa": dataQa,
|
|
77
|
+
ref,
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsxs(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
className: styles.row,
|
|
83
|
+
onMouseEnter: aside ? showAside : void 0,
|
|
84
|
+
onMouseLeave: aside ? hideAside : void 0,
|
|
85
|
+
onClick: aside ? showAside : void 0,
|
|
86
|
+
ref: rowRef,
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsxs("div", { className: styles.bubble, children: [
|
|
89
|
+
header,
|
|
90
|
+
content,
|
|
91
|
+
!metaHosted && meta,
|
|
92
|
+
showTail && /* @__PURE__ */ jsx(Tail, {})
|
|
93
|
+
] }),
|
|
94
|
+
mode === "outgoing" && error && /* @__PURE__ */ jsxs("div", { children: [
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
ExclamationCircleFilledSize24,
|
|
97
|
+
{
|
|
98
|
+
ref: activatorMenuRef,
|
|
99
|
+
initialColor: "negative",
|
|
100
|
+
onClick: errorActions ? () => setMenuVisible((visible) => !visible) : void 0,
|
|
101
|
+
"data-qa": "chat-bubble-error-button",
|
|
102
|
+
"aria-haspopup": errorActions ? "menu" : void 0,
|
|
103
|
+
"aria-expanded": errorActions ? menuVisible : void 0
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
errorActions && /* @__PURE__ */ jsx(
|
|
107
|
+
Menu,
|
|
108
|
+
{
|
|
109
|
+
activatorRef: activatorMenuRef,
|
|
110
|
+
onClose: closeErrorMenu,
|
|
111
|
+
placement: "bottom-right",
|
|
112
|
+
visible: menuVisible,
|
|
113
|
+
children: /* @__PURE__ */ jsx(ChatBubbleErrorMenuProvider, { value: closeErrorMenu, children: errorActions })
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] }),
|
|
117
|
+
aside && /* @__PURE__ */ jsx(
|
|
118
|
+
"div",
|
|
119
|
+
{
|
|
120
|
+
className: classnames(styles.aside, { [styles.asideRevealed]: asideShow }),
|
|
121
|
+
"data-qa": "chat-bubble-aside",
|
|
122
|
+
children: aside
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
mode === "outgoing" && error && errorText && /* @__PURE__ */ jsx("div", { className: styles.errorText, "data-qa": "chat-bubble-error-text", children: /* @__PURE__ */ jsx(Text, { typography: "label-4-regular", style: "negative", maxLines: 2, children: errorText }) }),
|
|
129
|
+
buttons && /* @__PURE__ */ jsx(ButtonDefaultPropsContext, { props: buttonsProps, children: /* @__PURE__ */ jsx("div", { className: styles.buttons, "data-qa": "chat-bubble-buttons", children: buttons }) })
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
) });
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
ChatBubble.displayName = "ChatBubble";
|
|
60
136
|
ChatBubble.Call = ChatBubbleCall;
|
|
61
137
|
ChatBubble.ErrorAction = ChatBubbleErrorAction;
|
|
62
138
|
ChatBubble.File = ChatBubbleFile;
|
package/ChatBubble.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBubble.js","sources":["src/ChatBubble.tsx"],"sourcesContent":["import { cloneElement, forwardRef, useCallback, useState, useMemo, useRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useCloseByClickOutside } from '@hh.ru/magritte-common-mouse';\nimport { ButtonDefaultPropsContext, type ButtonProps } from '@hh.ru/magritte-ui-button';\nimport { ChatBubbleCall } from '@hh.ru/magritte-ui-chat-bubble/Call';\nimport { ChatBubbleErrorAction } from '@hh.ru/magritte-ui-chat-bubble/ErrorAction';\nimport { ChatBubbleFile } from '@hh.ru/magritte-ui-chat-bubble/File';\nimport { ChatBubbleLabel } from '@hh.ru/magritte-ui-chat-bubble/Label';\nimport { ChatBubbleMedia } from '@hh.ru/magritte-ui-chat-bubble/Media';\nimport { ChatBubbleMessage } from '@hh.ru/magritte-ui-chat-bubble/Message';\nimport { Meta } from '@hh.ru/magritte-ui-chat-bubble/Meta';\nimport { ChatBubbleReply } from '@hh.ru/magritte-ui-chat-bubble/Reply';\nimport { ChatBubbleSnippet } from '@hh.ru/magritte-ui-chat-bubble/Snippet';\nimport { ChatBubbleStatus } from '@hh.ru/magritte-ui-chat-bubble/Status';\nimport { Tail } from '@hh.ru/magritte-ui-chat-bubble/Tail';\nimport { getColors } from '@hh.ru/magritte-ui-chat-bubble/internal/colors';\nimport { ChatBubbleErrorMenuProvider } from '@hh.ru/magritte-ui-chat-bubble/internal/errorMenu';\nimport { ChatBubbleModeProvider } from '@hh.ru/magritte-ui-chat-bubble/internal/mode';\nimport { isMetaHost, flattenFragments } from '@hh.ru/magritte-ui-chat-bubble/internal/utils';\nimport type { ChatBubbleProps } from '@hh.ru/magritte-ui-chat-bubble/types';\nimport { ExclamationCircleFilledSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Menu } from '@hh.ru/magritte-ui-menu';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './chat-bubble.less';\n\ninterface ChatBubbleComponents {\n Call: typeof ChatBubbleCall;\n ErrorAction: typeof ChatBubbleErrorAction;\n File: typeof ChatBubbleFile;\n Label: typeof ChatBubbleLabel;\n Media: typeof ChatBubbleMedia;\n Message: typeof ChatBubbleMessage;\n Reply: typeof ChatBubbleReply;\n Snippet: typeof ChatBubbleSnippet;\n Status: typeof ChatBubbleStatus;\n}\n\nexport const ChatBubble = forwardRef<HTMLDivElement, ChatBubbleProps>(\n (\n {\n aside,\n buttons,\n children,\n header,\n edited,\n errorActions,\n mode = 'incoming',\n showTail = false,\n status,\n time,\n error = false,\n errorText,\n 'data-qa': dataQa = 'chat-bubble',\n className,\n },\n ref\n ) => {\n const rowRef = useRef<HTMLDivElement>(null);\n const activatorMenuRef = useRef<SVGElement>(null);\n\n const [menuVisible, setMenuVisible] = useState(false);\n const closeErrorMenu = useCallback(() => setMenuVisible(false), []);\n\n const [asideShow, setAsideShow] = useState(false);\n const showAside = useCallback(() => setAsideShow(true), []);\n const hideAside = useCallback(() => setAsideShow(false), []);\n\n // скрываем aside при кликах вне\n useCloseByClickOutside(rowRef, hideAside, asideShow);\n\n const colors = getColors(mode);\n const buttonsProps: Partial<ButtonProps> = useMemo(\n () => ({ size: 'small', stretched: true, ...colors.button }),\n [colors]\n );\n /**\n * Время отдаём последнему элементу контента\n * Позиция времени меняется, в зависимости от компонента\n * Если последний ребенок не может отрисовать, вставим meta в самый конец\n */\n const meta = <Meta mode={mode} status={status} time={time} edited={edited} />;\n const items = flattenFragments(children);\n const lastIndex = items.length - 1;\n const metaHosted = isMetaHost(items[lastIndex]);\n const content = items.map((child, index) =>\n index === lastIndex && isMetaHost(child) ? cloneElement(child, { meta }) : child\n );\n return (\n <ChatBubbleModeProvider value={mode}>\n <div\n className={classnames(className, styles.chatBubble, styles[mode], {\n [styles.withTail]: showTail,\n })}\n data-qa={dataQa}\n ref={ref}\n >\n <div\n className={styles.row}\n onMouseEnter={aside ? showAside : undefined}\n onMouseLeave={aside ? hideAside : undefined}\n onClick={aside ? showAside : undefined}\n ref={rowRef}\n >\n <div className={styles.bubble}>\n {header}\n {content}\n {!metaHosted && meta}\n {showTail && <Tail />}\n </div>\n {mode === 'outgoing' && error && (\n <div>\n <ExclamationCircleFilledSize24\n ref={activatorMenuRef}\n initialColor=\"negative\"\n onClick={errorActions ? () => setMenuVisible((visible) => !visible) : undefined}\n data-qa=\"chat-bubble-error-button\"\n aria-haspopup={errorActions ? 'menu' : undefined}\n aria-expanded={errorActions ? menuVisible : undefined}\n />\n {errorActions && (\n <Menu\n activatorRef={activatorMenuRef}\n onClose={closeErrorMenu}\n placement=\"bottom-right\"\n visible={menuVisible}\n >\n <ChatBubbleErrorMenuProvider value={closeErrorMenu}>\n {errorActions}\n </ChatBubbleErrorMenuProvider>\n </Menu>\n )}\n </div>\n )}\n {aside && (\n <div\n className={classnames(styles.aside, { [styles.asideRevealed]: asideShow })}\n data-qa=\"chat-bubble-aside\"\n >\n {aside}\n </div>\n )}\n </div>\n {mode === 'outgoing' && error && errorText && (\n <div className={styles.errorText} data-qa=\"chat-bubble-error-text\">\n <Text typography=\"label-4-regular\" style=\"negative\" maxLines={2}>\n {errorText}\n </Text>\n </div>\n )}\n {buttons && (\n <ButtonDefaultPropsContext props={buttonsProps}>\n <div className={styles.buttons} data-qa=\"chat-bubble-buttons\">\n {buttons}\n </div>\n </ButtonDefaultPropsContext>\n )}\n </div>\n </ChatBubbleModeProvider>\n );\n }\n) as React.ForwardRefExoticComponent<ChatBubbleProps & React.RefAttributes<HTMLDivElement>> & ChatBubbleComponents;\n\nChatBubble.displayName = 'ChatBubble';\n\nChatBubble.Call = ChatBubbleCall;\nChatBubble.ErrorAction = ChatBubbleErrorAction;\nChatBubble.File = ChatBubbleFile;\nChatBubble.Label = ChatBubbleLabel;\nChatBubble.Media = ChatBubbleMedia;\nChatBubble.Message = ChatBubbleMessage;\nChatBubble.Reply = ChatBubbleReply;\nChatBubble.Snippet = ChatBubbleSnippet;\nChatBubble.Status = ChatBubbleStatus;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuCa,UAAU,GAAG,UAAU,CAChC,CACI,EACI,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,YAAY,EACZ,IAAI,GAAG,UAAU,EACjB,QAAQ,GAAG,KAAK,EAChB,MAAM,EACN,IAAI,EACJ,KAAK,GAAG,KAAK,EACb,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AM,CAAC,OAAO,aAAU,qBAAqB,EAAA,QAAA,EACxD,OAAO,EAAA,CACN,EACkB,CAAA,CAC/B,CACC,EAAA,CAAA,EAAA,CACe,EAC3B;AACN,CAAC,EAC8G;AAEnH,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;AAEtC,UAAU,CAAC,IAAI,GAAG,cAAc,CAAC;AACjC,UAAU,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAC/C,UAAU,CAAC,IAAI,GAAG,cAAc,CAAC;AACjC,UAAU,CAAC,KAAK,GAAG,eAAe,CAAC;AACnC,UAAU,CAAC,KAAK,GAAG,eAAe,CAAC;AACnC,UAAU,CAAC,OAAO,GAAG,iBAAiB,CAAC;AACvC,UAAU,CAAC,KAAK,GAAG,eAAe,CAAC;AACnC,UAAU,CAAC,OAAO,GAAG,iBAAiB,CAAC;AACvC,UAAU,CAAC,MAAM,GAAG,gBAAgB;;;;"}
|
|
1
|
+
{"version":3,"file":"ChatBubble.js","sources":["src/ChatBubble.tsx"],"sourcesContent":["import { cloneElement, forwardRef, useCallback, useState, useMemo, useRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useCloseByClickOutside } from '@hh.ru/magritte-common-mouse';\nimport { ButtonDefaultPropsContext, type ButtonProps } from '@hh.ru/magritte-ui-button';\nimport { ChatBubbleCall } from '@hh.ru/magritte-ui-chat-bubble/Call';\nimport { ChatBubbleErrorAction } from '@hh.ru/magritte-ui-chat-bubble/ErrorAction';\nimport { ChatBubbleFile } from '@hh.ru/magritte-ui-chat-bubble/File';\nimport { ChatBubbleLabel } from '@hh.ru/magritte-ui-chat-bubble/Label';\nimport { ChatBubbleMedia } from '@hh.ru/magritte-ui-chat-bubble/Media';\nimport { ChatBubbleMessage } from '@hh.ru/magritte-ui-chat-bubble/Message';\nimport { Meta } from '@hh.ru/magritte-ui-chat-bubble/Meta';\nimport { ChatBubbleReply } from '@hh.ru/magritte-ui-chat-bubble/Reply';\nimport { ChatBubbleSnippet } from '@hh.ru/magritte-ui-chat-bubble/Snippet';\nimport { ChatBubbleStatus } from '@hh.ru/magritte-ui-chat-bubble/Status';\nimport { Tail } from '@hh.ru/magritte-ui-chat-bubble/Tail';\nimport { getColors } from '@hh.ru/magritte-ui-chat-bubble/internal/colors';\nimport { ChatBubbleErrorMenuProvider } from '@hh.ru/magritte-ui-chat-bubble/internal/errorMenu';\nimport { ChatBubbleModeProvider } from '@hh.ru/magritte-ui-chat-bubble/internal/mode';\nimport { isMetaHost, flattenFragments } from '@hh.ru/magritte-ui-chat-bubble/internal/utils';\nimport type { ChatBubbleProps } from '@hh.ru/magritte-ui-chat-bubble/types';\nimport { ExclamationCircleFilledSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Menu } from '@hh.ru/magritte-ui-menu';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './chat-bubble.less';\n\ninterface ChatBubbleComponents {\n Call: typeof ChatBubbleCall;\n ErrorAction: typeof ChatBubbleErrorAction;\n File: typeof ChatBubbleFile;\n Label: typeof ChatBubbleLabel;\n Media: typeof ChatBubbleMedia;\n Message: typeof ChatBubbleMessage;\n Reply: typeof ChatBubbleReply;\n Snippet: typeof ChatBubbleSnippet;\n Status: typeof ChatBubbleStatus;\n}\n\nexport const ChatBubble = forwardRef<HTMLDivElement, ChatBubbleProps>(\n (\n {\n aside,\n buttons,\n children,\n header,\n edited,\n errorActions,\n mode = 'incoming',\n showTail = false,\n status,\n time,\n error = false,\n errorText,\n 'data-qa': dataQa = 'chat-bubble',\n className,\n },\n ref\n ) => {\n const rowRef = useRef<HTMLDivElement>(null);\n const activatorMenuRef = useRef<SVGElement>(null);\n\n const [menuVisible, setMenuVisible] = useState(false);\n const closeErrorMenu = useCallback(() => setMenuVisible(false), []);\n\n const [asideShow, setAsideShow] = useState(false);\n const showAside = useCallback(() => setAsideShow(true), []);\n const hideAside = useCallback(() => setAsideShow(false), []);\n\n // скрываем aside при кликах вне\n useCloseByClickOutside(rowRef, hideAside, asideShow);\n\n const colors = getColors(mode);\n const buttonsProps: Partial<ButtonProps> = useMemo(\n () => ({ size: 'small', stretched: true, ...colors.button }),\n [colors]\n );\n /**\n * Время отдаём последнему элементу контента\n * Позиция времени меняется, в зависимости от компонента\n * Если последний ребенок не может отрисовать, вставим meta в самый конец\n */\n const meta = <Meta mode={mode} status={status} time={time} edited={edited} />;\n const items = flattenFragments(children);\n const lastIndex = items.length - 1;\n const metaHosted = isMetaHost(items[lastIndex]);\n const content = items.map((child, index) =>\n index === lastIndex && isMetaHost(child) ? cloneElement(child, { meta }) : child\n );\n return (\n <ChatBubbleModeProvider value={mode}>\n <div\n className={classnames(className, styles.chatBubble, styles[mode], {\n [styles.withTail]: showTail,\n })}\n data-qa={dataQa}\n ref={ref}\n >\n <div\n className={styles.row}\n onMouseEnter={aside ? showAside : undefined}\n onMouseLeave={aside ? hideAside : undefined}\n onClick={aside ? showAside : undefined}\n ref={rowRef}\n >\n <div className={styles.bubble}>\n {header}\n {content}\n {!metaHosted && meta}\n {showTail && <Tail />}\n </div>\n {mode === 'outgoing' && error && (\n <div>\n <ExclamationCircleFilledSize24\n ref={activatorMenuRef}\n initialColor=\"negative\"\n onClick={errorActions ? () => setMenuVisible((visible) => !visible) : undefined}\n data-qa=\"chat-bubble-error-button\"\n aria-haspopup={errorActions ? 'menu' : undefined}\n aria-expanded={errorActions ? menuVisible : undefined}\n />\n {errorActions && (\n <Menu\n activatorRef={activatorMenuRef}\n onClose={closeErrorMenu}\n placement=\"bottom-right\"\n visible={menuVisible}\n >\n <ChatBubbleErrorMenuProvider value={closeErrorMenu}>\n {errorActions}\n </ChatBubbleErrorMenuProvider>\n </Menu>\n )}\n </div>\n )}\n {aside && (\n <div\n className={classnames(styles.aside, { [styles.asideRevealed]: asideShow })}\n data-qa=\"chat-bubble-aside\"\n >\n {aside}\n </div>\n )}\n </div>\n {mode === 'outgoing' && error && errorText && (\n <div className={styles.errorText} data-qa=\"chat-bubble-error-text\">\n <Text typography=\"label-4-regular\" style=\"negative\" maxLines={2}>\n {errorText}\n </Text>\n </div>\n )}\n {buttons && (\n <ButtonDefaultPropsContext props={buttonsProps}>\n <div className={styles.buttons} data-qa=\"chat-bubble-buttons\">\n {buttons}\n </div>\n </ButtonDefaultPropsContext>\n )}\n </div>\n </ChatBubbleModeProvider>\n );\n }\n) as React.ForwardRefExoticComponent<ChatBubbleProps & React.RefAttributes<HTMLDivElement>> & ChatBubbleComponents;\n\nChatBubble.displayName = 'ChatBubble';\n\nChatBubble.Call = ChatBubbleCall;\nChatBubble.ErrorAction = ChatBubbleErrorAction;\nChatBubble.File = ChatBubbleFile;\nChatBubble.Label = ChatBubbleLabel;\nChatBubble.Media = ChatBubbleMedia;\nChatBubble.Message = ChatBubbleMessage;\nChatBubble.Reply = ChatBubbleReply;\nChatBubble.Snippet = ChatBubbleSnippet;\nChatBubble.Status = ChatBubbleStatus;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCO,MAAM,UAAa,GAAA,UAAA;AAAA,EACtB,CACI;AAAA,IACI,KAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA,IAAO,GAAA,UAAA;AAAA,IACP,QAAW,GAAA,KAAA;AAAA,IACX,MAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAQ,GAAA,KAAA;AAAA,IACR,SAAA;AAAA,IACA,WAAW,MAAS,GAAA,aAAA;AAAA,IACpB,SAAA;AAAA,KAEJ,GACC,KAAA;AACD,IAAM,MAAA,MAAA,GAAS,OAAuB,IAAI,CAAA,CAAA;AAC1C,IAAM,MAAA,gBAAA,GAAmB,OAAmB,IAAI,CAAA,CAAA;AAEhD,IAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AACpD,IAAA,MAAM,iBAAiB,WAAY,CAAA,MAAM,eAAe,KAAK,CAAA,EAAG,EAAE,CAAA,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;AAEzB,UAAA,CAAW,IAAO,GAAA,cAAA,CAAA;AAClB,UAAA,CAAW,WAAc,GAAA,qBAAA,CAAA;AACzB,UAAA,CAAW,IAAO,GAAA,cAAA,CAAA;AAClB,UAAA,CAAW,KAAQ,GAAA,eAAA,CAAA;AACnB,UAAA,CAAW,KAAQ,GAAA,eAAA,CAAA;AACnB,UAAA,CAAW,OAAU,GAAA,iBAAA,CAAA;AACrB,UAAA,CAAW,KAAQ,GAAA,eAAA,CAAA;AACnB,UAAA,CAAW,OAAU,GAAA,iBAAA,CAAA;AACrB,UAAA,CAAW,MAAS,GAAA,gBAAA;;;;"}
|
package/ErrorAction.js
CHANGED
|
@@ -4,18 +4,17 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { useChatBubbleErrorMenuClose } from './internal/errorMenu.js';
|
|
5
5
|
import { Menu } from '@hh.ru/magritte-ui-menu';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
const ChatBubbleErrorAction = forwardRef(({ 'data-qa': dataQa = 'chat-bubble-error-action', onClick, ...props }, ref) => {
|
|
7
|
+
const ChatBubbleErrorAction = forwardRef(
|
|
8
|
+
({ "data-qa": dataQa = "chat-bubble-error-action", onClick, ...props }, ref) => {
|
|
11
9
|
const close = useChatBubbleErrorMenuClose();
|
|
12
10
|
const handleClick = (event) => {
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
onClick?.(event);
|
|
12
|
+
close();
|
|
15
13
|
};
|
|
16
|
-
return jsx(Menu.Item, { ...props, "data-qa": dataQa, onClick: handleClick, ref
|
|
17
|
-
}
|
|
18
|
-
|
|
14
|
+
return /* @__PURE__ */ jsx(Menu.Item, { ...props, "data-qa": dataQa, onClick: handleClick, ref });
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
ChatBubbleErrorAction.displayName = "ChatBubbleErrorAction";
|
|
19
18
|
|
|
20
19
|
export { ChatBubbleErrorAction };
|
|
21
20
|
//# sourceMappingURL=ErrorAction.js.map
|
package/ErrorAction.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorAction.js","sources":["src/ErrorAction.tsx"],"sourcesContent":["import { forwardRef, type MouseEvent } from 'react';\n\nimport { useChatBubbleErrorMenuClose } from '@hh.ru/magritte-ui-chat-bubble/internal/errorMenu';\nimport { Menu, type MenuItemProps } from '@hh.ru/magritte-ui-menu';\n\nexport interface ChatBubbleErrorActionProps extends Pick<\n MenuItemProps,\n 'children' | 'disabled' | 'icon' | 'style' | 'subtitle' | 'onClick'\n> {\n /** Значение data-qa\n * @default chat-bubble-error-action\n */\n 'data-qa'?: string;\n}\n\n/**\n * Пункт меню, которое открывается по нажатию на иконку ошибки отправки.\n */\nexport const ChatBubbleErrorAction = forwardRef<HTMLDivElement, ChatBubbleErrorActionProps>(\n ({ 'data-qa': dataQa = 'chat-bubble-error-action', onClick, ...props }, ref) => {\n const close = useChatBubbleErrorMenuClose();\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n onClick?.(event);\n close();\n };\n\n return <Menu.Item {...props} data-qa={dataQa} onClick={handleClick} ref={ref} />;\n }\n);\n\nChatBubbleErrorAction.displayName = 'ChatBubbleErrorAction';\n"],"names":[
|
|
1
|
+
{"version":3,"file":"ErrorAction.js","sources":["src/ErrorAction.tsx"],"sourcesContent":["import { forwardRef, type MouseEvent } from 'react';\n\nimport { useChatBubbleErrorMenuClose } from '@hh.ru/magritte-ui-chat-bubble/internal/errorMenu';\nimport { Menu, type MenuItemProps } from '@hh.ru/magritte-ui-menu';\n\nexport interface ChatBubbleErrorActionProps extends Pick<\n MenuItemProps,\n 'children' | 'disabled' | 'icon' | 'style' | 'subtitle' | 'onClick'\n> {\n /** Значение data-qa\n * @default chat-bubble-error-action\n */\n 'data-qa'?: string;\n}\n\n/**\n * Пункт меню, которое открывается по нажатию на иконку ошибки отправки.\n */\nexport const ChatBubbleErrorAction = forwardRef<HTMLDivElement, ChatBubbleErrorActionProps>(\n ({ 'data-qa': dataQa = 'chat-bubble-error-action', onClick, ...props }, ref) => {\n const close = useChatBubbleErrorMenuClose();\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n onClick?.(event);\n close();\n };\n\n return <Menu.Item {...props} data-qa={dataQa} onClick={handleClick} ref={ref} />;\n }\n);\n\nChatBubbleErrorAction.displayName = 'ChatBubbleErrorAction';\n"],"names":[],"mappings":";;;;;AAkBO,MAAM,qBAAwB,GAAA,UAAA;AAAA,EACjC,CAAC,EAAE,SAAW,EAAA,MAAA,GAAS,4BAA4B,OAAS,EAAA,GAAG,KAAM,EAAA,EAAG,GAAQ,KAAA;AAC5E,IAAA,MAAM,QAAQ,2BAA4B,EAAA,CAAA;AAE1C,IAAM,MAAA,WAAA,GAAc,CAAC,KAAsC,KAAA;AACvD,MAAA,OAAA,GAAU,KAAK,CAAA,CAAA;AACf,MAAM,KAAA,EAAA,CAAA;AAAA,KACV,CAAA;AAEA,IAAO,uBAAA,GAAA,CAAC,IAAK,CAAA,IAAA,EAAL,EAAW,GAAG,OAAO,SAAS,EAAA,MAAA,EAAQ,OAAS,EAAA,WAAA,EAAa,GAAU,EAAA,CAAA,CAAA;AAAA,GAClF;AACJ,EAAA;AAEA,qBAAA,CAAsB,WAAc,GAAA,uBAAA;;;;"}
|
package/File.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import { type ChatBubbleMetaHostProps } from '
|
|
2
|
+
import { type ChatBubbleMetaHostProps } from './internal/utils';
|
|
3
3
|
export type ChatBubbleFileState = 'unloaded' | 'loading' | 'preview' | 'loaded' | 'invalid';
|
|
4
4
|
type ChatBubbleFileHelper = HTMLAttributes<HTMLDivElement> & ChatBubbleMetaHostProps;
|
|
5
5
|
export interface ChatBubbleFileProps extends Omit<ChatBubbleFileHelper, 'children'> {
|
|
@@ -24,5 +24,5 @@ export interface ChatBubbleFileProps extends Omit<ChatBubbleFileHelper, 'childre
|
|
|
24
24
|
*/
|
|
25
25
|
'data-qa'?: string;
|
|
26
26
|
}
|
|
27
|
-
export declare const ChatBubbleFile: import("react").ForwardRefExoticComponent<ChatBubbleFileProps & import("react").RefAttributes<HTMLDivElement>> & import("
|
|
27
|
+
export declare const ChatBubbleFile: import("react").ForwardRefExoticComponent<ChatBubbleFileProps & import("react").RefAttributes<HTMLDivElement>> & import("./internal/utils").MetaHostComponent;
|
|
28
28
|
export {};
|
package/File.js
CHANGED
|
@@ -4,29 +4,73 @@ import { forwardRef, useMemo } from 'react';
|
|
|
4
4
|
import { Cell, CellText } from '@hh.ru/magritte-ui-cell';
|
|
5
5
|
import { useChatBubbleColors } from './internal/colors.js';
|
|
6
6
|
import { markMetaHost } from './internal/utils.js';
|
|
7
|
-
import {
|
|
7
|
+
import { ArrowDownLineOutlinedSize24, DocumentOutlinedSize24, ExclamationTriangleOutlinedSize16 } from '@hh.ru/magritte-ui-icon/icon';
|
|
8
8
|
import { LinkDefaultPropsContext } from '@hh.ru/magritte-ui-link';
|
|
9
9
|
import { Loader } from '@hh.ru/magritte-ui-loader';
|
|
10
|
-
import { s as styles } from './chat-bubble-
|
|
10
|
+
import { s as styles } from './chat-bubble-BOBGge0h.js';
|
|
11
11
|
import './internal/mode.js';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const ChatBubbleFileComponent = forwardRef(
|
|
14
|
+
({
|
|
15
|
+
"data-qa": dataQa = "chat-bubble-file",
|
|
16
|
+
description,
|
|
17
|
+
meta,
|
|
18
|
+
name,
|
|
19
|
+
preview,
|
|
20
|
+
state = "loaded",
|
|
21
|
+
previewAlt,
|
|
22
|
+
...props
|
|
23
|
+
}, ref) => {
|
|
15
24
|
const colors = useChatBubbleColors();
|
|
16
|
-
const isLoading = state ===
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
25
|
+
const isLoading = state === "loading";
|
|
26
|
+
const Icon = state === "unloaded" || isLoading ? ArrowDownLineOutlinedSize24 : DocumentOutlinedSize24;
|
|
27
|
+
const defaultLinkProps = useMemo(
|
|
28
|
+
() => ({ ...colors.link, typography: "label-3-regular", inline: true }),
|
|
29
|
+
[colors]
|
|
30
|
+
);
|
|
20
31
|
let leftSlot;
|
|
21
32
|
if (isLoading) {
|
|
22
|
-
|
|
33
|
+
leftSlot = /* @__PURE__ */ jsx(Loader, { size: 16, color: colors.secondaryIcon });
|
|
34
|
+
} else if (state === "invalid") {
|
|
35
|
+
leftSlot = /* @__PURE__ */ jsx(ExclamationTriangleOutlinedSize16, { initialColor: "negative" });
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
return /* @__PURE__ */ jsxs("div", { ...props, className: styles.file, "data-qa": dataQa, ref, children: [
|
|
38
|
+
/* @__PURE__ */ jsxs(
|
|
39
|
+
Cell,
|
|
40
|
+
{
|
|
41
|
+
align: "center",
|
|
42
|
+
horPadding: false,
|
|
43
|
+
vertPadding: false,
|
|
44
|
+
left: state === "preview" && preview ? /* @__PURE__ */ jsx("img", { className: styles.filePreview, src: preview, alt: previewAlt ?? "" }) : /* @__PURE__ */ jsx(
|
|
45
|
+
Icon,
|
|
46
|
+
{
|
|
47
|
+
initialColor: colors.fileIcon,
|
|
48
|
+
backgroundStyle: colors.fileIconBackground,
|
|
49
|
+
padding: 12,
|
|
50
|
+
borderRadius: 8
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx(CellText, { type: "title", style: colors.text, maxLines: 1, "data-qa": "chat-bubble-file-name", children: name }),
|
|
55
|
+
description && /* @__PURE__ */ jsx(
|
|
56
|
+
CellText,
|
|
57
|
+
{
|
|
58
|
+
type: "subtitle",
|
|
59
|
+
style: colors.secondaryText,
|
|
60
|
+
maxLines: 1,
|
|
61
|
+
left: leftSlot,
|
|
62
|
+
"data-qa": "chat-bubble-file-description",
|
|
63
|
+
children: /* @__PURE__ */ jsx(LinkDefaultPropsContext, { props: defaultLinkProps, children: description })
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
meta
|
|
70
|
+
] });
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
ChatBubbleFileComponent.displayName = "ChatBubbleFile";
|
|
30
74
|
const ChatBubbleFile = markMetaHost(ChatBubbleFileComponent);
|
|
31
75
|
|
|
32
76
|
export { ChatBubbleFile };
|
package/File.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.js","sources":["src/File.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes, type ReactNode, useMemo } from 'react';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { useChatBubbleColors } from '@hh.ru/magritte-ui-chat-bubble/internal/colors';\nimport { markMetaHost, type ChatBubbleMetaHostProps } from '@hh.ru/magritte-ui-chat-bubble/internal/utils';\nimport {\n ArrowDownLineOutlinedSize24,\n DocumentOutlinedSize24,\n ExclamationTriangleOutlinedSize16,\n} from '@hh.ru/magritte-ui-icon/icon';\nimport { LinkDefaultPropsContext } from '@hh.ru/magritte-ui-link';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\n\nimport styles from './chat-bubble.less';\n\nexport type ChatBubbleFileState = 'unloaded' | 'loading' | 'preview' | 'loaded' | 'invalid';\n\ntype ChatBubbleFileHelper = HTMLAttributes<HTMLDivElement> & ChatBubbleMetaHostProps;\n\nexport interface ChatBubbleFileProps extends Omit<ChatBubbleFileHelper, 'children'> {\n /** Имя файла */\n name?: ReactNode;\n /**\n * Строка под именем (например, для размера файла и действия с ним)\n */\n description?: ReactNode;\n /**\n * Состояние файла\n * @default loaded\n */\n state?: ChatBubbleFileState;\n /** Url превью файла, показывается в состоянии `preview` */\n preview?: string;\n /** Alt превью файла */\n previewAlt?: string;\n /**\n * Значение data-qa\n * @default chat-bubble-file\n */\n 'data-qa'?: string;\n}\n\n/** Прикреплённый файл */\nconst ChatBubbleFileComponent = forwardRef<HTMLDivElement, ChatBubbleFileProps>(\n (\n {\n 'data-qa': dataQa = 'chat-bubble-file',\n description,\n meta,\n name,\n preview,\n state = 'loaded',\n previewAlt,\n ...props\n },\n ref\n ) => {\n const colors = useChatBubbleColors();\n const isLoading = state === 'loading';\n // пока файл не скачан, на иконке стрелка\n const Icon = state === 'unloaded' || isLoading ? ArrowDownLineOutlinedSize24 : DocumentOutlinedSize24;\n\n const defaultLinkProps = useMemo(\n () => ({ ...colors.link, typography: 'label-3-regular' as const, inline: true }),\n [colors]\n );\n\n let leftSlot: ReactNode;\n if (isLoading) {\n leftSlot = <Loader size={16} color={colors.secondaryIcon} />;\n } else if (state === 'invalid') {\n leftSlot = <ExclamationTriangleOutlinedSize16 initialColor=\"negative\" />;\n }\n\n return (\n <div {...props} className={styles.file} data-qa={dataQa} ref={ref}>\n <Cell\n align=\"center\"\n horPadding={false}\n vertPadding={false}\n left={\n state === 'preview' && preview ? (\n <img className={styles.filePreview} src={preview} alt={previewAlt ?? ''} />\n ) : (\n <Icon\n initialColor={colors.fileIcon}\n backgroundStyle={colors.fileIconBackground}\n padding={12}\n borderRadius={8}\n />\n )\n }\n >\n <CellText type=\"title\" style={colors.text} maxLines={1} data-qa=\"chat-bubble-file-name\">\n {name}\n </CellText>\n {description && (\n <CellText\n type=\"subtitle\"\n style={colors.secondaryText}\n maxLines={1}\n left={leftSlot}\n data-qa=\"chat-bubble-file-description\"\n >\n <LinkDefaultPropsContext props={defaultLinkProps}>{description}</LinkDefaultPropsContext>\n </CellText>\n )}\n </Cell>\n {meta}\n </div>\n );\n }\n);\n\nChatBubbleFileComponent.displayName = 'ChatBubbleFile';\n\nexport const ChatBubbleFile = markMetaHost(ChatBubbleFileComponent);\n"],"names":[
|
|
1
|
+
{"version":3,"file":"File.js","sources":["src/File.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes, type ReactNode, useMemo } from 'react';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { useChatBubbleColors } from '@hh.ru/magritte-ui-chat-bubble/internal/colors';\nimport { markMetaHost, type ChatBubbleMetaHostProps } from '@hh.ru/magritte-ui-chat-bubble/internal/utils';\nimport {\n ArrowDownLineOutlinedSize24,\n DocumentOutlinedSize24,\n ExclamationTriangleOutlinedSize16,\n} from '@hh.ru/magritte-ui-icon/icon';\nimport { LinkDefaultPropsContext } from '@hh.ru/magritte-ui-link';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\n\nimport styles from './chat-bubble.less';\n\nexport type ChatBubbleFileState = 'unloaded' | 'loading' | 'preview' | 'loaded' | 'invalid';\n\ntype ChatBubbleFileHelper = HTMLAttributes<HTMLDivElement> & ChatBubbleMetaHostProps;\n\nexport interface ChatBubbleFileProps extends Omit<ChatBubbleFileHelper, 'children'> {\n /** Имя файла */\n name?: ReactNode;\n /**\n * Строка под именем (например, для размера файла и действия с ним)\n */\n description?: ReactNode;\n /**\n * Состояние файла\n * @default loaded\n */\n state?: ChatBubbleFileState;\n /** Url превью файла, показывается в состоянии `preview` */\n preview?: string;\n /** Alt превью файла */\n previewAlt?: string;\n /**\n * Значение data-qa\n * @default chat-bubble-file\n */\n 'data-qa'?: string;\n}\n\n/** Прикреплённый файл */\nconst ChatBubbleFileComponent = forwardRef<HTMLDivElement, ChatBubbleFileProps>(\n (\n {\n 'data-qa': dataQa = 'chat-bubble-file',\n description,\n meta,\n name,\n preview,\n state = 'loaded',\n previewAlt,\n ...props\n },\n ref\n ) => {\n const colors = useChatBubbleColors();\n const isLoading = state === 'loading';\n // пока файл не скачан, на иконке стрелка\n const Icon = state === 'unloaded' || isLoading ? ArrowDownLineOutlinedSize24 : DocumentOutlinedSize24;\n\n const defaultLinkProps = useMemo(\n () => ({ ...colors.link, typography: 'label-3-regular' as const, inline: true }),\n [colors]\n );\n\n let leftSlot: ReactNode;\n if (isLoading) {\n leftSlot = <Loader size={16} color={colors.secondaryIcon} />;\n } else if (state === 'invalid') {\n leftSlot = <ExclamationTriangleOutlinedSize16 initialColor=\"negative\" />;\n }\n\n return (\n <div {...props} className={styles.file} data-qa={dataQa} ref={ref}>\n <Cell\n align=\"center\"\n horPadding={false}\n vertPadding={false}\n left={\n state === 'preview' && preview ? (\n <img className={styles.filePreview} src={preview} alt={previewAlt ?? ''} />\n ) : (\n <Icon\n initialColor={colors.fileIcon}\n backgroundStyle={colors.fileIconBackground}\n padding={12}\n borderRadius={8}\n />\n )\n }\n >\n <CellText type=\"title\" style={colors.text} maxLines={1} data-qa=\"chat-bubble-file-name\">\n {name}\n </CellText>\n {description && (\n <CellText\n type=\"subtitle\"\n style={colors.secondaryText}\n maxLines={1}\n left={leftSlot}\n data-qa=\"chat-bubble-file-description\"\n >\n <LinkDefaultPropsContext props={defaultLinkProps}>{description}</LinkDefaultPropsContext>\n </CellText>\n )}\n </Cell>\n {meta}\n </div>\n );\n }\n);\n\nChatBubbleFileComponent.displayName = 'ChatBubbleFile';\n\nexport const ChatBubbleFile = markMetaHost(ChatBubbleFileComponent);\n"],"names":[],"mappings":";;;;;;;;;;;AA2CA,MAAM,uBAA0B,GAAA,UAAA;AAAA,EAC5B,CACI;AAAA,IACI,WAAW,MAAS,GAAA,kBAAA;AAAA,IACpB,WAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAQ,GAAA,QAAA;AAAA,IACR,UAAA;AAAA,IACA,GAAG,KAAA;AAAA,KAEP,GACC,KAAA;AACD,IAAA,MAAM,SAAS,mBAAoB,EAAA,CAAA;AACnC,IAAA,MAAM,YAAY,KAAU,KAAA,SAAA,CAAA;AAE5B,IAAA,MAAM,IAAO,GAAA,KAAA,KAAU,UAAc,IAAA,SAAA,GAAY,2BAA8B,GAAA,sBAAA,CAAA;AAE/E,IAAA,MAAM,gBAAmB,GAAA,OAAA;AAAA,MACrB,OAAO,EAAE,GAAG,MAAA,CAAO,MAAM,U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EAC3D,QACL,EAAA,IAAA,EAAA,CAAA;AAAA,YACC,WACG,oBAAA,GAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACG,IAAK,EAAA,UAAA;AAAA,gBACL,OAAO,MAAO,CAAA,aAAA;AAAA,gBACd,QAAU,EAAA,CAAA;AAAA,gBACV,IAAM,EAAA,QAAA;AAAA,gBACN,SAAQ,EAAA,8BAAA;AAAA,gBAER,QAAC,kBAAA,GAAA,CAAA,uBAAA,EAAA,EAAwB,KAAO,EAAA,gBAAA,EAAmB,QAAY,EAAA,WAAA,EAAA,CAAA;AAAA,eAAA;AAAA,aACnE;AAAA,WAAA;AAAA,SAAA;AAAA,OAER;AAAA,MACC,IAAA;AAAA,KACL,EAAA,CAAA,CAAA;AAAA,GAER;AACJ,CAAA,CAAA;AAEA,uBAAA,CAAwB,WAAc,GAAA,gBAAA,CAAA;AAEzB,MAAA,cAAA,GAAiB,aAAa,uBAAuB;;;;"}
|
package/Label.js
CHANGED
|
@@ -3,17 +3,14 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { useChatBubbleColors } from './internal/colors.js';
|
|
5
5
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
6
|
-
import { s as styles } from './chat-bubble-
|
|
6
|
+
import { s as styles } from './chat-bubble-BOBGge0h.js';
|
|
7
7
|
import './internal/mode.js';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Заголовок сообщения.
|
|
11
|
-
*/
|
|
12
9
|
const ChatBubbleLabel = forwardRef(({ children, ...props }, ref) => {
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const colors = useChatBubbleColors();
|
|
11
|
+
return /* @__PURE__ */ jsx("div", { ...props, className: styles.label, "data-qa": "chat-bubble-label", ref, children: /* @__PURE__ */ jsx(Text, { typography: "subtitle-2-semibold", style: colors.accentText, maxLines: 1, children }) });
|
|
15
12
|
});
|
|
16
|
-
ChatBubbleLabel.displayName =
|
|
13
|
+
ChatBubbleLabel.displayName = "ChatBubbleLabel";
|
|
17
14
|
|
|
18
15
|
export { ChatBubbleLabel };
|
|
19
16
|
//# sourceMappingURL=Label.js.map
|
package/Label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","sources":["src/Label.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from 'react';\n\nimport { useChatBubbleColors } from '@hh.ru/magritte-ui-chat-bubble/internal/colors';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './chat-bubble.less';\n\nexport interface ChatBubbleLabelProps extends HTMLAttributes<HTMLDivElement> {\n /** Имя отправителя */\n children?: ReactNode;\n}\n\n/**\n * Заголовок сообщения.\n */\nexport const ChatBubbleLabel = forwardRef<HTMLDivElement, ChatBubbleLabelProps>(({ children, ...props }, ref) => {\n const colors = useChatBubbleColors();\n\n return (\n <div {...props} className={styles.label} data-qa=\"chat-bubble-label\" ref={ref}>\n <Text typography=\"subtitle-2-semibold\" style={colors.accentText} maxLines={1}>\n {children}\n </Text>\n </div>\n );\n});\n\nChatBubbleLabel.displayName = 'ChatBubbleLabel';\n"],"names":[
|
|
1
|
+
{"version":3,"file":"Label.js","sources":["src/Label.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from 'react';\n\nimport { useChatBubbleColors } from '@hh.ru/magritte-ui-chat-bubble/internal/colors';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './chat-bubble.less';\n\nexport interface ChatBubbleLabelProps extends HTMLAttributes<HTMLDivElement> {\n /** Имя отправителя */\n children?: ReactNode;\n}\n\n/**\n * Заголовок сообщения.\n */\nexport const ChatBubbleLabel = forwardRef<HTMLDivElement, ChatBubbleLabelProps>(({ children, ...props }, ref) => {\n const colors = useChatBubbleColors();\n\n return (\n <div {...props} className={styles.label} data-qa=\"chat-bubble-label\" ref={ref}>\n <Text typography=\"subtitle-2-semibold\" style={colors.accentText} maxLines={1}>\n {children}\n </Text>\n </div>\n );\n});\n\nChatBubbleLabel.displayName = 'ChatBubbleLabel';\n"],"names":[],"mappings":";;;;;;;AAea,MAAA,eAAA,GAAkB,WAAiD,CAAC,EAAE,UAAU,GAAG,KAAA,IAAS,GAAQ,KAAA;AAC7G,EAAA,MAAM,SAAS,mBAAoB,EAAA,CAAA;AAEnC,EACI,uBAAA,GAAA,CAAC,SAAK,GAAG,KAAA,EAAO,WAAW,MAAO,CAAA,KAAA,EAAO,WAAQ,mBAAoB,EAAA,GAAA,EACjE,8BAAC,IAAK,EAAA,EAAA,UAAA,EAAW,uBAAsB,KAAO,EAAA,MAAA,CAAO,YAAY,QAAU,EAAA,CAAA,EACtE,UACL,CACJ,EAAA,CAAA,CAAA;AAER,CAAC,EAAA;AAED,eAAA,CAAgB,WAAc,GAAA,iBAAA;;;;"}
|
package/Media.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import { type ChatBubbleMetaHostProps } from '
|
|
2
|
+
import { type ChatBubbleMetaHostProps } from './internal/utils';
|
|
3
3
|
export interface ChatBubbleMediaProps extends HTMLAttributes<HTMLDivElement>, ChatBubbleMetaHostProps {
|
|
4
4
|
/** Url изображения или превью видео */
|
|
5
5
|
src?: string;
|
|
@@ -27,4 +27,4 @@ export interface ChatBubbleMediaProps extends HTMLAttributes<HTMLDivElement>, Ch
|
|
|
27
27
|
*/
|
|
28
28
|
height?: number;
|
|
29
29
|
}
|
|
30
|
-
export declare const ChatBubbleMedia: import("react").ForwardRefExoticComponent<ChatBubbleMediaProps & import("react").RefAttributes<HTMLDivElement>> & import("
|
|
30
|
+
export declare const ChatBubbleMedia: import("react").ForwardRefExoticComponent<ChatBubbleMediaProps & import("react").RefAttributes<HTMLDivElement>> & import("./internal/utils").MetaHostComponent;
|