@unif/react-native-chat 3.2.3 → 3.3.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/lib/module/components/Attachments/AttachmentItem.js +3 -2
- 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/styles.js +4 -0
- 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/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 -7
- 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/styles.d.ts +4 -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/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 +11 -3
- package/src/components/Attachments/Attachments.tsx +1 -0
- package/src/components/Attachments/styles.ts +1 -0
- package/src/components/Attachments/types.ts +2 -1
- package/src/components/Composer/Composer.tsx +34 -8
- 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 -13
- 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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Text, View } from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Icon,
|
|
5
|
+
StatusDot,
|
|
6
|
+
icon,
|
|
7
|
+
useColors,
|
|
8
|
+
useThemedStyles,
|
|
9
|
+
} from '@unif/react-native-design';
|
|
10
|
+
import { PROCESS_STATUS_LABELS } from './constants';
|
|
11
|
+
import { createStyles } from './styles';
|
|
12
|
+
import type { ProcessCompactStepProps } from './types';
|
|
13
|
+
|
|
14
|
+
export function ProcessTimelineStep({
|
|
15
|
+
step,
|
|
16
|
+
last,
|
|
17
|
+
expanded,
|
|
18
|
+
elapsed,
|
|
19
|
+
onToggle,
|
|
20
|
+
}: ProcessCompactStepProps & { last: boolean }) {
|
|
21
|
+
const styles = useThemedStyles(createStyles);
|
|
22
|
+
const colors = useColors();
|
|
23
|
+
const status =
|
|
24
|
+
step.status === 'running'
|
|
25
|
+
? 'active'
|
|
26
|
+
: step.status === 'completed'
|
|
27
|
+
? 'done'
|
|
28
|
+
: step.status === 'failed'
|
|
29
|
+
? 'error'
|
|
30
|
+
: 'pending';
|
|
31
|
+
return (
|
|
32
|
+
<View
|
|
33
|
+
style={styles.timelineStep}
|
|
34
|
+
accessibilityLabel={`${step.title},${step.statusText ?? PROCESS_STATUS_LABELS[step.status]}`}
|
|
35
|
+
>
|
|
36
|
+
<View style={styles.timelineGutter}>
|
|
37
|
+
{step.status === 'cancelled' ? (
|
|
38
|
+
<Icon name="close" size={icon.xs} color={colors.foregroundSubtle} />
|
|
39
|
+
) : (
|
|
40
|
+
<StatusDot
|
|
41
|
+
status={status}
|
|
42
|
+
tone="soft"
|
|
43
|
+
size={icon.xs}
|
|
44
|
+
accessibilityLabel=""
|
|
45
|
+
/>
|
|
46
|
+
)}
|
|
47
|
+
{!last ? <View style={styles.timelineLine} /> : null}
|
|
48
|
+
</View>
|
|
49
|
+
<View style={[styles.timelineBody, !last && styles.timelineBodyNotLast]}>
|
|
50
|
+
<View style={styles.stepHeader}>
|
|
51
|
+
<Text
|
|
52
|
+
testID={`process-step-title-${step.id}`}
|
|
53
|
+
style={[
|
|
54
|
+
styles.timelineTitle,
|
|
55
|
+
step.status === 'running' && styles.timelineActive,
|
|
56
|
+
step.status === 'pending' && styles.timelinePending,
|
|
57
|
+
]}
|
|
58
|
+
numberOfLines={1}
|
|
59
|
+
>
|
|
60
|
+
{step.title}
|
|
61
|
+
</Text>
|
|
62
|
+
{step.description ? (
|
|
63
|
+
<Text
|
|
64
|
+
style={[
|
|
65
|
+
styles.timelineDescription,
|
|
66
|
+
step.status === 'failed' && styles.timelineError,
|
|
67
|
+
]}
|
|
68
|
+
numberOfLines={1}
|
|
69
|
+
>
|
|
70
|
+
{step.description}
|
|
71
|
+
</Text>
|
|
72
|
+
) : null}
|
|
73
|
+
</View>
|
|
74
|
+
{elapsed ? <Text style={styles.elapsed}>{elapsed}</Text> : null}
|
|
75
|
+
{step.details != null ? (
|
|
76
|
+
<>
|
|
77
|
+
<Button
|
|
78
|
+
label={expanded ? '收起详情' : '展开详情'}
|
|
79
|
+
onPress={onToggle}
|
|
80
|
+
size="sm"
|
|
81
|
+
variant="text"
|
|
82
|
+
testID={`process-step-${step.id}-toggle`}
|
|
83
|
+
/>
|
|
84
|
+
{expanded ? (
|
|
85
|
+
<View style={styles.details}>{step.details}</View>
|
|
86
|
+
) : null}
|
|
87
|
+
</>
|
|
88
|
+
) : null}
|
|
89
|
+
{step.actions?.length ? (
|
|
90
|
+
<View style={styles.actions}>
|
|
91
|
+
{step.actions.map((action) => (
|
|
92
|
+
<Button
|
|
93
|
+
key={action.id}
|
|
94
|
+
label={action.label}
|
|
95
|
+
leftIcon={action.icon}
|
|
96
|
+
onPress={action.onPress}
|
|
97
|
+
disabled={action.disabled}
|
|
98
|
+
loading={action.loading}
|
|
99
|
+
accessibilityHint={action.accessibilityHint}
|
|
100
|
+
size="sm"
|
|
101
|
+
variant="text"
|
|
102
|
+
/>
|
|
103
|
+
))}
|
|
104
|
+
</View>
|
|
105
|
+
) : null}
|
|
106
|
+
</View>
|
|
107
|
+
</View>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -1,9 +1,48 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { fw, r, radius, space, type } from '@unif/react-native-design';
|
|
2
|
+
import { fw, icon, r, radius, space, type } from '@unif/react-native-design';
|
|
3
3
|
import type { ColorTokens } from '@unif/react-native-design';
|
|
4
4
|
|
|
5
5
|
export const createStyles = (colors: ColorTokens) =>
|
|
6
6
|
StyleSheet.create({
|
|
7
|
+
timelineRoot: {
|
|
8
|
+
backgroundColor: colors.surface,
|
|
9
|
+
borderRadius: radius.lg,
|
|
10
|
+
padding: space[5],
|
|
11
|
+
},
|
|
12
|
+
timelineStep: {
|
|
13
|
+
flexDirection: 'row',
|
|
14
|
+
alignItems: 'flex-start',
|
|
15
|
+
gap: space[4],
|
|
16
|
+
},
|
|
17
|
+
timelineGutter: {
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
width: icon.xs,
|
|
20
|
+
alignSelf: 'stretch',
|
|
21
|
+
},
|
|
22
|
+
timelineLine: {
|
|
23
|
+
width: r(1.5),
|
|
24
|
+
flex: 1,
|
|
25
|
+
backgroundColor: colors.outline,
|
|
26
|
+
marginTop: r(2),
|
|
27
|
+
minHeight: space[5],
|
|
28
|
+
},
|
|
29
|
+
timelineBody: { flex: 1 },
|
|
30
|
+
timelineBodyNotLast: { paddingBottom: space[7] },
|
|
31
|
+
timelineTitle: {
|
|
32
|
+
flex: 1,
|
|
33
|
+
fontSize: type.xs,
|
|
34
|
+
fontWeight: fw.medium,
|
|
35
|
+
color: colors.foreground,
|
|
36
|
+
lineHeight: type.xs * 1.4,
|
|
37
|
+
},
|
|
38
|
+
timelineActive: { color: colors.primary },
|
|
39
|
+
timelinePending: { color: colors.foregroundSubtle, fontWeight: fw.regular },
|
|
40
|
+
timelineDescription: {
|
|
41
|
+
flexShrink: 0,
|
|
42
|
+
fontSize: type.xs,
|
|
43
|
+
color: colors.foregroundSubtle,
|
|
44
|
+
},
|
|
45
|
+
timelineError: { color: colors.error },
|
|
7
46
|
compactRoot: { gap: space[2] },
|
|
8
47
|
compactSteps: { gap: space[2] },
|
|
9
48
|
compactAction: { minWidth: 44, minHeight: 44 },
|
|
@@ -21,16 +60,22 @@ export const createStyles = (colors: ColorTokens) =>
|
|
|
21
60
|
fontSize: type.xs,
|
|
22
61
|
fontWeight: fw.medium,
|
|
23
62
|
},
|
|
63
|
+
spacer: { flex: 1 },
|
|
64
|
+
compactStatus: {
|
|
65
|
+
fontSize: type.xs,
|
|
66
|
+
fontWeight: fw.medium,
|
|
67
|
+
color: colors.foregroundMuted,
|
|
68
|
+
},
|
|
24
69
|
compactDescription: {
|
|
25
70
|
color: colors.foregroundMuted,
|
|
26
71
|
fontSize: type.xs,
|
|
27
72
|
lineHeight: type.xs * 1.6,
|
|
28
73
|
},
|
|
29
|
-
|
|
30
|
-
maxHeight: r(180),
|
|
74
|
+
compactDetailsContainer: {
|
|
31
75
|
paddingTop: space[3],
|
|
32
76
|
paddingBottom: space[2],
|
|
33
77
|
},
|
|
78
|
+
compactDetails: { maxHeight: r(180) },
|
|
34
79
|
root: {
|
|
35
80
|
gap: space[4],
|
|
36
81
|
padding: space[5],
|
|
@@ -9,6 +9,8 @@ export interface ProcessStep {
|
|
|
9
9
|
id: string;
|
|
10
10
|
title: string;
|
|
11
11
|
status: ProcessStepStatus;
|
|
12
|
+
/** 调用者提供的状态显示文案;不改变 status 的语义。 */
|
|
13
|
+
statusText?: string;
|
|
12
14
|
description?: string;
|
|
13
15
|
elapsedMs?: number;
|
|
14
16
|
details?: ReactNode;
|
|
@@ -16,16 +18,19 @@ export interface ProcessStep {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export interface ProcessBaseProps {
|
|
19
|
-
/** card
|
|
20
|
-
variant?: 'card' | 'compact';
|
|
21
|
+
/** card 为状态面板;compact 为单行过程;timeline 为带状态节点的连续步骤。 */
|
|
22
|
+
variant?: 'card' | 'compact' | 'timeline';
|
|
21
23
|
steps: readonly ProcessStep[];
|
|
22
24
|
title?: string;
|
|
23
25
|
identity?: ReactNode;
|
|
26
|
+
/** inline 仅用于 compact 单项,让身份与状态处于同一行。 */
|
|
27
|
+
identityPlacement?: 'heading' | 'inline';
|
|
24
28
|
style?: StyleProp<ViewStyle>;
|
|
25
29
|
testID?: string;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
export interface ProcessCompactStepProps {
|
|
33
|
+
identity?: ReactNode;
|
|
29
34
|
step: ProcessStep;
|
|
30
35
|
expanded: boolean;
|
|
31
36
|
elapsed?: string;
|