@unif/react-native-chat 3.2.4 → 3.3.1
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/lib/module/components/Attachments/AttachmentItem.js +8 -4
- package/lib/module/components/Attachments/AttachmentItem.js.map +1 -1
- package/lib/module/components/Attachments/Attachments.js +1 -0
- package/lib/module/components/Attachments/Attachments.js.map +1 -1
- package/lib/module/components/Attachments/constants.js +1 -0
- package/lib/module/components/Attachments/constants.js.map +1 -1
- package/lib/module/components/Attachments/styles.js +10 -5
- package/lib/module/components/Attachments/styles.js.map +1 -1
- package/lib/module/components/Composer/Composer.js +13 -9
- package/lib/module/components/Composer/Composer.js.map +1 -1
- package/lib/module/components/Composer/styles.js +1 -0
- package/lib/module/components/Composer/styles.js.map +1 -1
- package/lib/module/components/Confirmation/Confirmation.js +29 -13
- package/lib/module/components/Confirmation/Confirmation.js.map +1 -1
- package/lib/module/components/Confirmation/styles.js +17 -6
- package/lib/module/components/Confirmation/styles.js.map +1 -1
- package/lib/module/components/Message/MarkdownContent/styles.js +29 -33
- package/lib/module/components/Message/MarkdownContent/styles.js.map +1 -1
- package/lib/module/components/Message/Message.js +37 -24
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageWaiting.js +53 -0
- package/lib/module/components/Message/MessageWaiting.js.map +1 -0
- package/lib/module/components/Message/constants.js +3 -0
- package/lib/module/components/Message/constants.js.map +1 -1
- package/lib/module/components/Message/styles.js +41 -3
- package/lib/module/components/Message/styles.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +60 -31
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageList/MessageListEndButton.js +60 -0
- package/lib/module/components/MessageList/MessageListEndButton.js.map +1 -0
- package/lib/module/components/MessageList/MessageListRow.js +9 -2
- package/lib/module/components/MessageList/MessageListRow.js.map +1 -1
- package/lib/module/components/MessageList/styles.js +6 -0
- package/lib/module/components/MessageList/styles.js.map +1 -1
- package/lib/module/components/MessageList/useMessageListScroll.js +218 -13
- package/lib/module/components/MessageList/useMessageListScroll.js.map +1 -1
- package/lib/module/components/Process/Process.js +15 -5
- package/lib/module/components/Process/Process.js.map +1 -1
- package/lib/module/components/Process/ProcessCompactStep.js +21 -12
- package/lib/module/components/Process/ProcessCompactStep.js.map +1 -1
- package/lib/module/components/Process/ProcessTimelineStep.js +79 -0
- package/lib/module/components/Process/ProcessTimelineStep.js.map +1 -0
- package/lib/module/components/Process/styles.js +63 -3
- package/lib/module/components/Process/styles.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/Attachments/AttachmentItem.d.ts +1 -1
- package/lib/typescript/src/components/Attachments/AttachmentItem.d.ts.map +1 -1
- package/lib/typescript/src/components/Attachments/Attachments.d.ts.map +1 -1
- package/lib/typescript/src/components/Attachments/constants.d.ts +1 -0
- package/lib/typescript/src/components/Attachments/constants.d.ts.map +1 -1
- package/lib/typescript/src/components/Attachments/styles.d.ts +5 -0
- package/lib/typescript/src/components/Attachments/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/Attachments/types.d.ts +2 -1
- package/lib/typescript/src/components/Attachments/types.d.ts.map +1 -1
- package/lib/typescript/src/components/Composer/Composer.d.ts.map +1 -1
- package/lib/typescript/src/components/Composer/styles.d.ts +1 -0
- package/lib/typescript/src/components/Composer/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/Confirmation/Confirmation.d.ts.map +1 -1
- package/lib/typescript/src/components/Confirmation/styles.d.ts +13 -2
- package/lib/typescript/src/components/Confirmation/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/Message/MarkdownContent/styles.d.ts +32 -66
- package/lib/typescript/src/components/Message/MarkdownContent/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/Message/Message.d.ts.map +1 -1
- package/lib/typescript/src/components/Message/MessageWaiting.d.ts +3 -0
- package/lib/typescript/src/components/Message/MessageWaiting.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/constants.d.ts +3 -0
- package/lib/typescript/src/components/Message/constants.d.ts.map +1 -1
- package/lib/typescript/src/components/Message/styles.d.ts +40 -2
- package/lib/typescript/src/components/Message/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/Message/types.d.ts +5 -0
- package/lib/typescript/src/components/Message/types.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageList/MessageList.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageList/MessageListEndButton.d.ts +3 -0
- package/lib/typescript/src/components/MessageList/MessageListEndButton.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/MessageListRow.d.ts +2 -8
- package/lib/typescript/src/components/MessageList/MessageListRow.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageList/index.d.ts +1 -1
- package/lib/typescript/src/components/MessageList/index.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageList/styles.d.ts +6 -0
- package/lib/typescript/src/components/MessageList/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageList/types.d.ts +41 -2
- package/lib/typescript/src/components/MessageList/types.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageList/useMessageListScroll.d.ts +14 -3
- package/lib/typescript/src/components/MessageList/useMessageListScroll.d.ts.map +1 -1
- package/lib/typescript/src/components/Process/Process.d.ts.map +1 -1
- package/lib/typescript/src/components/Process/ProcessCompactStep.d.ts +1 -1
- package/lib/typescript/src/components/Process/ProcessCompactStep.d.ts.map +1 -1
- package/lib/typescript/src/components/Process/ProcessTimelineStep.d.ts +5 -0
- package/lib/typescript/src/components/Process/ProcessTimelineStep.d.ts.map +1 -0
- package/lib/typescript/src/components/Process/styles.d.ts +62 -2
- package/lib/typescript/src/components/Process/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/Process/types.d.ts +7 -2
- package/lib/typescript/src/components/Process/types.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Attachments/AttachmentItem.tsx +16 -5
- package/src/components/Attachments/Attachments.tsx +1 -0
- package/src/components/Attachments/constants.ts +1 -0
- package/src/components/Attachments/styles.ts +7 -4
- package/src/components/Attachments/types.ts +2 -1
- package/src/components/Composer/Composer.tsx +34 -8
- package/src/components/Composer/styles.ts +1 -0
- package/src/components/Confirmation/Confirmation.tsx +50 -14
- package/src/components/Confirmation/styles.ts +13 -6
- package/src/components/Message/MarkdownContent/styles.ts +18 -44
- package/src/components/Message/Message.tsx +53 -33
- package/src/components/Message/MessageWaiting.tsx +68 -0
- package/src/components/Message/constants.ts +4 -0
- package/src/components/Message/styles.ts +25 -2
- package/src/components/Message/types.ts +6 -0
- package/src/components/MessageList/MessageList.tsx +107 -35
- package/src/components/MessageList/MessageListEndButton.tsx +61 -0
- package/src/components/MessageList/MessageListRow.tsx +12 -12
- package/src/components/MessageList/index.ts +1 -0
- package/src/components/MessageList/styles.ts +6 -0
- package/src/components/MessageList/types.ts +52 -2
- package/src/components/MessageList/useMessageListScroll.ts +296 -21
- package/src/components/Process/Process.tsx +38 -5
- package/src/components/Process/ProcessCompactStep.tsx +32 -16
- package/src/components/Process/ProcessTimelineStep.tsx +109 -0
- package/src/components/Process/styles.ts +48 -3
- package/src/components/Process/types.ts +7 -2
- package/src/index.tsx +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { StyleSheet } from 'react-native';
|
|
4
|
-
import { type,
|
|
4
|
+
import { type, fw } from '@unif/react-native-design';
|
|
5
5
|
const makeMarkdownStyles = (colors, outgoing) => {
|
|
6
6
|
const textColor = outgoing ? colors.onPrimary : colors.foreground;
|
|
7
7
|
const body = {
|
|
@@ -12,78 +12,74 @@ const makeMarkdownStyles = (colors, outgoing) => {
|
|
|
12
12
|
return StyleSheet.create({
|
|
13
13
|
text: body,
|
|
14
14
|
em: {
|
|
15
|
-
|
|
15
|
+
color: textColor,
|
|
16
16
|
fontStyle: 'italic'
|
|
17
17
|
},
|
|
18
18
|
strong: {
|
|
19
|
-
|
|
19
|
+
color: textColor,
|
|
20
20
|
fontWeight: 'bold'
|
|
21
21
|
},
|
|
22
22
|
strikethrough: {
|
|
23
|
-
|
|
23
|
+
color: textColor,
|
|
24
24
|
textDecorationLine: 'line-through'
|
|
25
25
|
},
|
|
26
26
|
link: {
|
|
27
|
-
...body,
|
|
28
27
|
color: outgoing ? colors.onPrimary : colors.primary,
|
|
29
28
|
textDecorationLine: 'underline'
|
|
30
29
|
},
|
|
31
|
-
li:
|
|
30
|
+
li: {
|
|
31
|
+
color: textColor,
|
|
32
|
+
fontSize: type.sm
|
|
33
|
+
},
|
|
32
34
|
codespan: {
|
|
33
|
-
...body,
|
|
34
|
-
fontFamily: fontMono,
|
|
35
35
|
color: colors.foreground,
|
|
36
36
|
backgroundColor: colors.surfaceContainer
|
|
37
37
|
},
|
|
38
38
|
h1: {
|
|
39
|
-
fontSize: type.
|
|
40
|
-
|
|
41
|
-
color: textColor
|
|
42
|
-
borderBottomColor: colors.outline
|
|
39
|
+
fontSize: type.h2,
|
|
40
|
+
fontWeight: fw.bold,
|
|
41
|
+
color: textColor
|
|
43
42
|
},
|
|
44
43
|
h2: {
|
|
45
|
-
fontSize: type.
|
|
46
|
-
|
|
47
|
-
color: textColor
|
|
48
|
-
borderBottomColor: colors.outline
|
|
44
|
+
fontSize: type.h3,
|
|
45
|
+
fontWeight: fw.bold,
|
|
46
|
+
color: textColor
|
|
49
47
|
},
|
|
50
48
|
h3: {
|
|
51
|
-
fontSize: type.
|
|
52
|
-
|
|
49
|
+
fontSize: type.body,
|
|
50
|
+
fontWeight: fw.semi,
|
|
53
51
|
color: textColor
|
|
54
52
|
},
|
|
55
53
|
h4: {
|
|
56
|
-
fontSize: type.
|
|
57
|
-
|
|
54
|
+
fontSize: type.sm,
|
|
55
|
+
fontWeight: fw.semi,
|
|
58
56
|
color: textColor
|
|
59
57
|
},
|
|
60
58
|
h5: {
|
|
61
59
|
fontSize: type.sm,
|
|
62
|
-
|
|
60
|
+
fontWeight: fw.semi,
|
|
63
61
|
color: textColor
|
|
64
62
|
},
|
|
65
63
|
h6: {
|
|
66
|
-
fontSize: type.
|
|
67
|
-
|
|
64
|
+
fontSize: type.sm,
|
|
65
|
+
fontWeight: fw.semi,
|
|
68
66
|
color: textColor
|
|
69
67
|
},
|
|
70
|
-
paragraph: {
|
|
71
|
-
paddingVertical: space[1]
|
|
72
|
-
},
|
|
73
68
|
code: {
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
backgroundColor: colors.surfaceContainer,
|
|
70
|
+
borderColor: colors.outline,
|
|
71
|
+
borderWidth: 1
|
|
76
72
|
},
|
|
77
73
|
codeText: {
|
|
78
|
-
|
|
79
|
-
color: colors.foreground,
|
|
80
|
-
fontFamily: fontMono
|
|
74
|
+
color: colors.foreground
|
|
81
75
|
},
|
|
82
76
|
blockquote: {
|
|
83
|
-
|
|
77
|
+
borderColor: colors.outline,
|
|
78
|
+
borderLeftWidth: 3
|
|
84
79
|
},
|
|
85
80
|
hr: {
|
|
86
|
-
|
|
81
|
+
backgroundColor: colors.outline,
|
|
82
|
+
height: 1
|
|
87
83
|
},
|
|
88
84
|
table: {
|
|
89
85
|
borderColor: colors.outline
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","type","
|
|
1
|
+
{"version":3,"names":["StyleSheet","type","fw","makeMarkdownStyles","colors","outgoing","textColor","onPrimary","foreground","body","fontSize","sm","lineHeight","color","create","text","em","fontStyle","strong","fontWeight","strikethrough","textDecorationLine","link","primary","li","codespan","backgroundColor","surfaceContainer","h1","h2","bold","h3","semi","h4","h5","h6","code","borderColor","outline","borderWidth","codeText","blockquote","borderLeftWidth","hr","height","table","createStyles","createOutgoingStyles"],"sourceRoot":"../../../../../src","sources":["components/Message/MarkdownContent/styles.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,IAAI,EAAEC,EAAE,QAAQ,2BAA2B;AAGpD,MAAMC,kBAAkB,GA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'react-native';
|
|
4
|
-
import { Button, IconButton,
|
|
4
|
+
import { Button, IconButton, useThemedStyles, useColors } from '@unif/react-native-design';
|
|
5
5
|
import { MarkdownContent } from "./MarkdownContent/MarkdownContent.js";
|
|
6
6
|
import { createStyles } from "./styles.js";
|
|
7
7
|
import { isNestedAction } from "./isNestedAction.js";
|
|
8
|
+
import { MessageWaiting } from "./MessageWaiting.js";
|
|
8
9
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
export function Message(props) {
|
|
10
11
|
const {
|
|
@@ -18,6 +19,7 @@ export function Message(props) {
|
|
|
18
19
|
header,
|
|
19
20
|
footer,
|
|
20
21
|
actions = [],
|
|
22
|
+
failureAction,
|
|
21
23
|
onPress,
|
|
22
24
|
onLongPress,
|
|
23
25
|
style,
|
|
@@ -27,7 +29,8 @@ export function Message(props) {
|
|
|
27
29
|
const colors = useColors();
|
|
28
30
|
const hasContent = Boolean(props.text?.length) || props.children !== undefined && props.children !== null && props.children !== false || header !== undefined && header !== null && header !== false || footer !== undefined && footer !== null && footer !== false;
|
|
29
31
|
const waiting = (status === 'pending' || status === 'streaming') && !hasContent;
|
|
30
|
-
const
|
|
32
|
+
const failedAction = status === 'failed' ? failureAction : undefined;
|
|
33
|
+
const contentStyle = [styles.content, fullWidth && styles.fullWidth, surface === 'bubble' && [styles.bubble, placement === 'end' && styles.outgoing], surface === 'outlined' && styles.outlined, status === 'failed' && styles.failed, waiting && surface === 'bubble' && placement === 'start' && styles.waitingBubble, failedAction && styles.failureContent, failedAction && fullWidth && styles.failureFullWidth];
|
|
31
34
|
const content = /*#__PURE__*/_jsxs(_Fragment, {
|
|
32
35
|
children: [header, props.text !== undefined ? props.format === 'markdown' ? /*#__PURE__*/_jsx(MarkdownContent, {
|
|
33
36
|
text: props.text,
|
|
@@ -38,18 +41,27 @@ export function Message(props) {
|
|
|
38
41
|
style: [styles.text, surface === 'bubble' && placement === 'end' && styles.outgoingText],
|
|
39
42
|
numberOfLines: props.numberOfLines,
|
|
40
43
|
children: props.text
|
|
41
|
-
}) : props.children, waiting ? /*#__PURE__*/_jsx(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
accessibilityState: {
|
|
45
|
-
busy: true
|
|
46
|
-
},
|
|
47
|
-
children: /*#__PURE__*/_jsx(Spinner, {})
|
|
48
|
-
}) : null, statusText ? /*#__PURE__*/_jsx(Text, {
|
|
44
|
+
}) : props.children, waiting ? /*#__PURE__*/_jsx(MessageWaiting, {
|
|
45
|
+
label: statusText
|
|
46
|
+
}) : null, statusText && !waiting ? /*#__PURE__*/_jsx(Text, {
|
|
49
47
|
style: [styles.status, status === 'failed' && styles.errorText],
|
|
50
48
|
children: statusText
|
|
51
49
|
}) : null, footer]
|
|
52
50
|
});
|
|
51
|
+
const bubble = onPress || onLongPress ? /*#__PURE__*/_jsx(Pressable, {
|
|
52
|
+
style: contentStyle,
|
|
53
|
+
onPress: onPress ? event => {
|
|
54
|
+
if (!isNestedAction(event)) onPress();
|
|
55
|
+
} : undefined,
|
|
56
|
+
onLongPress: onLongPress ? event => {
|
|
57
|
+
if (!isNestedAction(event)) onLongPress();
|
|
58
|
+
} : undefined,
|
|
59
|
+
accessible: false,
|
|
60
|
+
children: content
|
|
61
|
+
}) : /*#__PURE__*/_jsx(View, {
|
|
62
|
+
style: contentStyle,
|
|
63
|
+
children: content
|
|
64
|
+
});
|
|
53
65
|
return /*#__PURE__*/_jsxs(View, {
|
|
54
66
|
style: [styles.root, placement === 'end' && styles.end, style],
|
|
55
67
|
testID: testID,
|
|
@@ -58,20 +70,21 @@ export function Message(props) {
|
|
|
58
70
|
children: [name ? /*#__PURE__*/_jsx(Text, {
|
|
59
71
|
style: styles.name,
|
|
60
72
|
children: name
|
|
61
|
-
}) : null,
|
|
62
|
-
style:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
}) : null, failedAction ? /*#__PURE__*/_jsxs(View, {
|
|
74
|
+
style: [styles.failureRow, placement === 'end' && styles.end],
|
|
75
|
+
children: [bubble, /*#__PURE__*/_jsx(IconButton, {
|
|
76
|
+
icon: "alert",
|
|
77
|
+
size: "sm",
|
|
78
|
+
variant: "ghost",
|
|
79
|
+
color: colors.error,
|
|
80
|
+
style: styles.failureAction,
|
|
81
|
+
accessibilityLabel: failedAction.label,
|
|
82
|
+
accessibilityHint: failedAction.accessibilityHint,
|
|
83
|
+
disabled: failedAction.disabled,
|
|
84
|
+
loading: failedAction.loading,
|
|
85
|
+
onPress: failedAction.onPress
|
|
86
|
+
})]
|
|
87
|
+
}) : bubble, actions.length ? /*#__PURE__*/_jsx(View, {
|
|
75
88
|
style: styles.actions,
|
|
76
89
|
children: actions.map(action => action.icon ? /*#__PURE__*/_jsx(IconButton, {
|
|
77
90
|
icon: action.icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Pressable","Text","View","Button","IconButton","
|
|
1
|
+
{"version":3,"names":["Pressable","Text","View","Button","IconButton","useThemedStyles","useColors","MarkdownContent","createStyles","isNestedAction","MessageWaiting","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","Message","props","placement","avatar","name","surface","fullWidth","status","statusText","header","footer","actions","failureAction","onPress","onLongPress","style","testID","styles","colors","hasContent","Boolean","text","length","children","undefined","waiting","failedAction","contentStyle","content","bubble","outgoing","outlined","failed","waitingBubble","failureContent","failureFullWidth","format","onLinkPress","selectable","outgoingText","numberOfLines","label","errorText","event","accessible","root","end","column","columnEnd","failureRow","icon","size","variant","color","error","accessibilityLabel","accessibilityHint","disabled","loading","map","action","foregroundSubtle","id","leftIcon"],"sourceRoot":"../../../../src","sources":["components/Message/Message.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACpD,SACEC,MAAM,E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CAAC,gBAEFnE,IAAA,CAACT,MAAM;UAELuD,KAAK,EAAEmB,MAAM,CAACnB,KAAM;UACpBsB,QAAQ,EAAEH,MAAM,CAACV,IAAK;UACtBO,QAAQ,EAAEG,MAAM,CAACH,QAAS;UAC1BC,OAAO,EAAEE,MAAM,CAACF,OAAQ;UACxBF,iBAAiB,EAAEI,MAAM,CAACJ,iBAAkB;UAC5CJ,OAAO,EAAC,MAAM;UACdvC,OAAO,EAAE+C,MAAM,CAAC/C;QAAQ,GAPnB+C,MAAM,CAACE,EAQb,CAEL;MAAC,CACG,CAAC,GACL,IAAI;IAAA,CACJ,CAAC;EAAA,CACH,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { Animated, Easing, Platform, Text, View } from 'react-native';
|
|
5
|
+
import { usePrefersReducedMotion, useThemedStyles } from '@unif/react-native-design';
|
|
6
|
+
import { MESSAGE_WAITING_DOT_DELAYS, MESSAGE_WAITING_DOT_DURATION, MESSAGE_WAITING_DOT_MIN_OPACITY } from "./constants.js";
|
|
7
|
+
import { createStyles } from "./styles.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
export function MessageWaiting({
|
|
10
|
+
label
|
|
11
|
+
}) {
|
|
12
|
+
const styles = useThemedStyles(createStyles);
|
|
13
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
14
|
+
const [values] = useState(() => MESSAGE_WAITING_DOT_DELAYS.map(() => new Animated.Value(1)));
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const animations = MESSAGE_WAITING_DOT_DELAYS.map((delay, index) => {
|
|
17
|
+
const value = values[index];
|
|
18
|
+
value.setValue(reducedMotion ? 1 : MESSAGE_WAITING_DOT_MIN_OPACITY);
|
|
19
|
+
return Animated.sequence([Animated.delay(delay), Animated.loop(Animated.sequence([1, MESSAGE_WAITING_DOT_MIN_OPACITY].map(toValue => Animated.timing(value, {
|
|
20
|
+
toValue,
|
|
21
|
+
duration: MESSAGE_WAITING_DOT_DURATION,
|
|
22
|
+
easing: Easing.inOut(Easing.ease),
|
|
23
|
+
useNativeDriver: Platform.OS !== 'web'
|
|
24
|
+
}))))]);
|
|
25
|
+
});
|
|
26
|
+
if (!reducedMotion) animations.forEach(animation => animation.start());
|
|
27
|
+
return () => animations.forEach(animation => animation.stop());
|
|
28
|
+
}, [reducedMotion, values]);
|
|
29
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
30
|
+
style: styles.waitingRow,
|
|
31
|
+
accessible: true,
|
|
32
|
+
accessibilityLabel: label || '正在等待回复',
|
|
33
|
+
accessibilityState: {
|
|
34
|
+
busy: true
|
|
35
|
+
},
|
|
36
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
37
|
+
style: styles.waitingDots,
|
|
38
|
+
pointerEvents: "none",
|
|
39
|
+
accessibilityElementsHidden: true,
|
|
40
|
+
importantForAccessibility: "no-hide-descendants",
|
|
41
|
+
children: values.map((opacity, index) => /*#__PURE__*/_jsx(Animated.View, {
|
|
42
|
+
testID: `message-waiting-dot-${index}`,
|
|
43
|
+
style: [styles.waitingDot, {
|
|
44
|
+
opacity
|
|
45
|
+
}]
|
|
46
|
+
}, index))
|
|
47
|
+
}), label ? /*#__PURE__*/_jsx(Text, {
|
|
48
|
+
style: styles.waitingLabel,
|
|
49
|
+
children: label
|
|
50
|
+
}) : null]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=MessageWaiting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useState","Animated","Easing","Platform","Text","View","usePrefersReducedMotion","useThemedStyles","MESSAGE_WAITING_DOT_DELAYS","MESSAGE_WAITING_DOT_DURATION","MESSAGE_WAITING_DOT_MIN_OPACITY","createStyles","jsx","_jsx","jsxs","_jsxs","MessageWaiting","label","styles","reducedMotion","values","map","Value","animations","delay","index","value","setValue","sequence","loop","toValue","timing","duration","easing","inOut","ease","useNativeDriver","OS","forEach","animation","start","stop","style","waitingRow","accessible","accessibilityLabel","accessibilityState","busy","children","waitingDots","pointerEvents","accessibilityElementsHidden","importantForAccessibility","opacity","testID","waitingDot","waitingLabel"],"sourceRoot":"../../../../src","sources":["components/Message/MessageWaiting.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACrE,SACEC,uBAAuB,EACvBC,eAAe,QACV,2BAA2B;AAClC,SACEC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,+BAA+B,QAC1B,gBAAa;AACpB,SAASC,YAAY,QAAQ,aAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGxC,OAAO,SAASC,cAAcA,CAAC;EAAEC;AAA2B,CAAC,EAAE;EAC7D,MAAMC,MAAM,GAAGX,eAAe,CAACI,YAAY,CAAC;EAC5C,MAAMQ,aAAa,GAAGb,uBAAuB,CAAC,CAAC;EAC/C,MAAM,CAACc,MAAM,CAAC,GAAGpB,QAAQ,CAAC,MACxBQ,0BAA0B,CAACa,GAAG,CAAC,MAAM,IAAIpB,QAAQ,CAACqB,KAAK,CAAC,CAAC,CAAC,CAC5D,CAAC;EACDvB,SAAS,CAAC,MAAM;IACd,MAAMwB,UAAU,GAAGf,0BAA0B,CAACa,GAAG,CAAC,CAACG,KAAK,EAAEC,KAAK,KAAK;MAClE,MAAMC,KAAK,GAAGN,MAAM,CAACK,KAAK,CAAE;MAC5BC,KAAK,CAACC,QAAQ,CAACR,aAAa,GAAG,CAAC,GAAGT,+BAA+B,CAAC;MACnE,OAAOT,QAAQ,CAAC2B,QAAQ,CAAC,CACvB3B,QAAQ,CAACuB,KAAK,CAACA,KAAK,CAAC,EACrBvB,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5B,KAGN,CACF;IAAC,CACE,CAAC,EACNR,KAAK,gBAAGJ,IAAA,CAACT,IAAI;MAACsC,KAAK,EAAExB,MAAM,CAACsC,YAAa;MAAAR,QAAA,EAAE/B;IAAK,CAAO,CAAC,GAAG,IAAI;EAAA,CAC5D,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export const INTERACTIVE_CONTENT_SELECTOR = 'button,a,input,textarea,select,[role="button"],[role="link"],[role="checkbox"],[role="switch"],[role="menuitem"],[role="tab"]';
|
|
4
|
+
export const MESSAGE_WAITING_DOT_DELAYS = [0, 150, 300];
|
|
5
|
+
export const MESSAGE_WAITING_DOT_DURATION = 600;
|
|
6
|
+
export const MESSAGE_WAITING_DOT_MIN_OPACITY = 0.3;
|
|
4
7
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["INTERACTIVE_CONTENT_SELECTOR"],"sourceRoot":"../../../../src","sources":["components/Message/constants.ts"],"mappings":";;AAAA,OAAO,MAAMA,4BAA4B,GACvC,+HAA+H","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["INTERACTIVE_CONTENT_SELECTOR","MESSAGE_WAITING_DOT_DELAYS","MESSAGE_WAITING_DOT_DURATION","MESSAGE_WAITING_DOT_MIN_OPACITY"],"sourceRoot":"../../../../src","sources":["components/Message/constants.ts"],"mappings":";;AAAA,OAAO,MAAMA,4BAA4B,GACvC,+HAA+H;AAEjI,OAAO,MAAMC,0BAA0B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAU;AAChE,OAAO,MAAMC,4BAA4B,GAAG,GAAG;AAC/C,OAAO,MAAMC,+BAA+B,GAAG,GAAG","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { StyleSheet } from 'react-native';
|
|
4
|
-
import { radius, space, type } from '@unif/react-native-design';
|
|
4
|
+
import { r, radius, space, type } from '@unif/react-native-design';
|
|
5
5
|
export const createStyles = colors => StyleSheet.create({
|
|
6
6
|
root: {
|
|
7
7
|
flexDirection: 'row',
|
|
@@ -50,8 +50,46 @@ export const createStyles = colors => StyleSheet.create({
|
|
|
50
50
|
borderColor: colors.outline
|
|
51
51
|
},
|
|
52
52
|
failed: {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
opacity: 0.7
|
|
54
|
+
},
|
|
55
|
+
failureRow: {
|
|
56
|
+
flexDirection: 'row',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
alignSelf: 'stretch',
|
|
59
|
+
gap: space[2]
|
|
60
|
+
},
|
|
61
|
+
failureContent: {
|
|
62
|
+
flexShrink: 1
|
|
63
|
+
},
|
|
64
|
+
failureAction: {
|
|
65
|
+
alignSelf: 'center'
|
|
66
|
+
},
|
|
67
|
+
failureFullWidth: {
|
|
68
|
+
flex: 1
|
|
69
|
+
},
|
|
70
|
+
waitingBubble: {
|
|
71
|
+
width: r(240),
|
|
72
|
+
borderTopLeftRadius: 0
|
|
73
|
+
},
|
|
74
|
+
waitingRow: {
|
|
75
|
+
flexDirection: 'row',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
gap: space[2]
|
|
78
|
+
},
|
|
79
|
+
waitingDots: {
|
|
80
|
+
flexDirection: 'row',
|
|
81
|
+
gap: r(3)
|
|
82
|
+
},
|
|
83
|
+
waitingDot: {
|
|
84
|
+
width: r(6),
|
|
85
|
+
height: r(6),
|
|
86
|
+
borderRadius: r(3),
|
|
87
|
+
backgroundColor: colors.foregroundSubtle
|
|
88
|
+
},
|
|
89
|
+
waitingLabel: {
|
|
90
|
+
fontSize: type.xxs,
|
|
91
|
+
color: colors.foregroundSubtle,
|
|
92
|
+
flexShrink: 1
|
|
55
93
|
},
|
|
56
94
|
text: {
|
|
57
95
|
fontSize: type.sm,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","radius","space","type","createStyles","colors","create","root","flexDirection","alignItems","gap","minWidth","end","column","flex","maxWidth","columnEnd","fullWidth","alignSelf","content","bubble","paddingHorizontal","paddingVertical","borderRadius","backgroundColor","surface","outgoing","primary","outgoingText","color","onPrimary","outlined","borderWidth","borderColor","outline","failed","
|
|
1
|
+
{"version":3,"names":["StyleSheet","r","radius","space","type","createStyles","colors","create","root","flexDirection","alignItems","gap","minWidth","end","column","flex","maxWidth","columnEnd","fullWidth","alignSelf","content","bubble","paddingHorizontal","paddingVertical","borderRadius","backgroundColor","surface","outgoing","primary","outgoingText","color","onPrimary","outlined","borderWidth","borderColor","outline","failed","opacity","failureRow","failureContent","flexShrink","failureAction","failureFullWidth","waitingBubble","width","borderTopLeftRadius","waitingRow","waitingDots","waitingDot","height","foregroundSubtle","waitingLabel","fontSize","xxs","text","sm","lineHeight","foreground","name","foregroundMuted","status","errorText","error","actions","flexWrap","marginTop"],"sourceRoot":"../../../../src","sources":["components/Message/styles.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,CAAC,EAAEC,MAAM,EAAEC,KAAK,EAAEC,IAAI,QAAQ,2BAA2B;AAGlE,OAAO,MAAMC,YAAY,GAAIC,MAAmB,IAC9CN,UAAU,CAACO,MAAM,CAAC;EAChBC,IAAI,EAAE;IACJC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,YAAY;IACxBC,GAAG,EAAER,KAAK,CAAC,CAAC,CAAC;IACbS,QAAQ,EAAE;EACZ,CAAC;EACDC,GAAG,EAAE;IAAEJ,aAAa,EAAE;EAAc,CAAC;EACrCK,MAAM,EAAE;IACNC,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,MAAM;IAChBL,GAAG,EAAER,KAAK,CAAC,CAAC,CAAC;IACbO,UAAU,EAAE;EACd,CAAC;EACDO,SAAS,EAAE;IAAEP,UAAU,EAAE;EAAW,CAAC;EACrCQ,SAAS,EAAE;IAAEC,SAAS,EAAE,SA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allback, useImperativeHandle, useMemo, useRef } from 'react';
|
|
4
|
-
import { FlatList, View } from 'react-native';
|
|
5
|
-
import { Button,
|
|
3
|
+
import { useCallback, useImperativeHandle, useLayoutEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { FlatList, StyleSheet, View } from 'react-native';
|
|
5
|
+
import { Button, useThemedStyles } from '@unif/react-native-design';
|
|
6
6
|
import { DEFAULT_END_THRESHOLD } from "./constants.js";
|
|
7
7
|
import { createStyles } from "./styles.js";
|
|
8
8
|
import { useWebPrependAnchor } from "./webPrependAnchor/index.js";
|
|
9
9
|
import { useMessageListScroll } from "./useMessageListScroll.js";
|
|
10
10
|
import { MessageListRow } from "./MessageListRow.js";
|
|
11
|
+
import { MessageListEndButton } from "./MessageListEndButton.js";
|
|
11
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
13
|
const MAINTAIN_VISIBLE_POSITION = {
|
|
13
14
|
minIndexForVisible: 0
|
|
@@ -39,6 +40,9 @@ export function MessageList({
|
|
|
39
40
|
}) {
|
|
40
41
|
const styles = useThemedStyles(createStyles);
|
|
41
42
|
const listRef = useRef(null);
|
|
43
|
+
const listTestID = useRef(testID);
|
|
44
|
+
listTestID.current = testID;
|
|
45
|
+
const contentStyle = StyleSheet.flatten(contentContainerStyle);
|
|
42
46
|
const keys = useMemo(() => items.map(keyExtractor), [items, keyExtractor]);
|
|
43
47
|
const {
|
|
44
48
|
getRowNativeID,
|
|
@@ -51,11 +55,19 @@ export function MessageList({
|
|
|
51
55
|
});
|
|
52
56
|
const {
|
|
53
57
|
atEnd,
|
|
58
|
+
anchorMinimumHeight,
|
|
59
|
+
anchorToItem,
|
|
60
|
+
onCellLayout,
|
|
61
|
+
onItemLayout,
|
|
62
|
+
onCellUnmount,
|
|
63
|
+
onFooterLayout,
|
|
64
|
+
onScrollToIndexFailed,
|
|
54
65
|
scrollToEnd,
|
|
55
66
|
onLayout,
|
|
56
67
|
onContentSizeChange,
|
|
57
68
|
onScroll,
|
|
58
69
|
onUserScrollBegin,
|
|
70
|
+
onMomentumScrollBegin,
|
|
59
71
|
onScrollEndDrag,
|
|
60
72
|
onMomentumScrollEnd
|
|
61
73
|
} = useMessageListScroll({
|
|
@@ -65,24 +77,53 @@ export function MessageList({
|
|
|
65
77
|
followOutput,
|
|
66
78
|
endThreshold,
|
|
67
79
|
onAtEndChange,
|
|
80
|
+
hasFooter: !!footer,
|
|
81
|
+
contentMinimumHeight: contentStyle?.minHeight,
|
|
82
|
+
contentBottomPadding: contentStyle?.paddingBottom ?? contentStyle?.paddingVertical ?? contentStyle?.padding,
|
|
68
83
|
preservingPrependRef,
|
|
69
84
|
cancelPrependPreservation
|
|
70
85
|
});
|
|
71
86
|
useImperativeHandle(ref, () => ({
|
|
72
|
-
scrollToEnd
|
|
73
|
-
|
|
87
|
+
scrollToEnd,
|
|
88
|
+
anchorToItem
|
|
89
|
+
}), [scrollToEnd, anchorToItem]);
|
|
90
|
+
const CellRenderer = useCallback(function MessageListCell({
|
|
91
|
+
cellKey,
|
|
92
|
+
index,
|
|
93
|
+
children,
|
|
94
|
+
style: cellStyle,
|
|
95
|
+
onLayout: reportLayout,
|
|
96
|
+
onFocusCapture
|
|
97
|
+
}) {
|
|
98
|
+
const currentIndex = useRef(index);
|
|
99
|
+
currentIndex.current = index;
|
|
100
|
+
useLayoutEffect(() => () => onCellUnmount(cellKey, currentIndex.current), [cellKey]);
|
|
101
|
+
return /*#__PURE__*/_jsx(View, {
|
|
102
|
+
style: cellStyle,
|
|
103
|
+
onFocusCapture: onFocusCapture,
|
|
104
|
+
testID: listTestID.current ? `${listTestID.current}-cell-${encodeURIComponent(cellKey)}` : undefined,
|
|
105
|
+
onLayout: event => {
|
|
106
|
+
reportLayout?.(event);
|
|
107
|
+
onCellLayout(cellKey, index, event.nativeEvent.layout);
|
|
108
|
+
},
|
|
109
|
+
children: children
|
|
110
|
+
});
|
|
111
|
+
}, [onCellLayout, onCellUnmount]);
|
|
74
112
|
const renderRow = useCallback(({
|
|
75
113
|
item,
|
|
76
114
|
index
|
|
77
115
|
}) => /*#__PURE__*/_jsx(MessageListRow, {
|
|
78
116
|
item: item,
|
|
79
117
|
index: index,
|
|
118
|
+
itemKey: keys[index],
|
|
119
|
+
onItemLayout: onItemLayout,
|
|
120
|
+
testID: testID ? `${testID}-item-${encodeURIComponent(keys[index])}` : undefined,
|
|
80
121
|
previous: renderSeparator ? items[index - 1] : undefined,
|
|
81
122
|
nativeID: getRowNativeID(keys[index]),
|
|
82
123
|
renderItem: renderItem,
|
|
83
124
|
renderSeparator: renderSeparator,
|
|
84
125
|
extraData: extraData
|
|
85
|
-
}), [extraData, getRowNativeID, items, keys, renderItem, renderSeparator]);
|
|
126
|
+
}), [extraData, getRowNativeID, items, keys, onItemLayout, renderItem, renderSeparator, testID]);
|
|
86
127
|
const history = hasEarlier && onRequestEarlier;
|
|
87
128
|
const hasHeader = Boolean(header || history);
|
|
88
129
|
const listHeader = useMemo(() => hasHeader ? /*#__PURE__*/_jsxs(View, {
|
|
@@ -94,8 +135,9 @@ export function MessageList({
|
|
|
94
135
|
}) : null]
|
|
95
136
|
}) : undefined, [hasHeader, header, history, loadingEarlier, onRequestEarlier]);
|
|
96
137
|
const listFooter = useMemo(() => footer ? /*#__PURE__*/_jsx(View, {
|
|
138
|
+
onLayout: onFooterLayout,
|
|
97
139
|
children: footer
|
|
98
|
-
}) : undefined, [footer]);
|
|
140
|
+
}) : undefined, [footer, onFooterLayout]);
|
|
99
141
|
const listEmpty = useMemo(() => empty ? /*#__PURE__*/_jsx(_Fragment, {
|
|
100
142
|
children: empty
|
|
101
143
|
}) : undefined, [empty]);
|
|
@@ -110,12 +152,15 @@ export function MessageList({
|
|
|
110
152
|
keyExtractor: keyExtractor,
|
|
111
153
|
extraData: extraData,
|
|
112
154
|
renderItem: renderRow,
|
|
155
|
+
CellRendererComponent: CellRenderer,
|
|
113
156
|
ListHeaderComponent: listHeader,
|
|
114
157
|
ListFooterComponent: listFooter,
|
|
115
158
|
ListEmptyComponent: listEmpty,
|
|
116
|
-
maintainVisibleContentPosition: items.length > 0 ? MAINTAIN_VISIBLE_POSITION : undefined,
|
|
159
|
+
maintainVisibleContentPosition: items.length > 0 && anchorMinimumHeight === undefined ? MAINTAIN_VISIBLE_POSITION : undefined,
|
|
117
160
|
keyboardDismissMode: keyboardDismissMode,
|
|
118
|
-
contentContainerStyle: contentContainerStyle,
|
|
161
|
+
contentContainerStyle: anchorMinimumHeight ? [contentContainerStyle, {
|
|
162
|
+
minHeight: anchorMinimumHeight
|
|
163
|
+
}] : contentContainerStyle,
|
|
119
164
|
showsVerticalScrollIndicator: showsVerticalScrollIndicator,
|
|
120
165
|
keyboardShouldPersistTaps: "handled",
|
|
121
166
|
scrollEventThrottle: 16,
|
|
@@ -123,29 +168,13 @@ export function MessageList({
|
|
|
123
168
|
onContentSizeChange: onContentSizeChange,
|
|
124
169
|
onScroll: onScroll,
|
|
125
170
|
onScrollBeginDrag: onUserScrollBegin,
|
|
126
|
-
onMomentumScrollBegin:
|
|
171
|
+
onMomentumScrollBegin: onMomentumScrollBegin,
|
|
127
172
|
onScrollEndDrag: onScrollEndDrag,
|
|
128
|
-
onMomentumScrollEnd: onMomentumScrollEnd
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
style: styles.returnProgress,
|
|
134
|
-
pointerEvents: "none",
|
|
135
|
-
children: /*#__PURE__*/_jsx(Spinner, {
|
|
136
|
-
size: 44,
|
|
137
|
-
thickness: 2
|
|
138
|
-
})
|
|
139
|
-
}) : null, /*#__PURE__*/_jsx(IconButton, {
|
|
140
|
-
icon: "arrow-down",
|
|
141
|
-
accessibilityLabel: scrollToEndBusy ? '回到最新消息,正在处理' : '回到最新消息',
|
|
142
|
-
variant: "ghost",
|
|
143
|
-
size: "md",
|
|
144
|
-
surfaceSize: 36,
|
|
145
|
-
iconSize: 18,
|
|
146
|
-
style: styles.returnButton,
|
|
147
|
-
onPress: () => scrollToEnd()
|
|
148
|
-
})]
|
|
173
|
+
onMomentumScrollEnd: onMomentumScrollEnd,
|
|
174
|
+
onScrollToIndexFailed: onScrollToIndexFailed
|
|
175
|
+
}), showScrollToEnd && items.length > 0 && !atEnd ? /*#__PURE__*/_jsx(MessageListEndButton, {
|
|
176
|
+
busy: scrollToEndBusy,
|
|
177
|
+
onPress: () => scrollToEnd()
|
|
149
178
|
}) : null]
|
|
150
179
|
});
|
|
151
180
|
}
|