@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.
Files changed (124) hide show
  1. package/lib/module/components/Attachments/AttachmentItem.js +8 -4
  2. package/lib/module/components/Attachments/AttachmentItem.js.map +1 -1
  3. package/lib/module/components/Attachments/Attachments.js +1 -0
  4. package/lib/module/components/Attachments/Attachments.js.map +1 -1
  5. package/lib/module/components/Attachments/constants.js +1 -0
  6. package/lib/module/components/Attachments/constants.js.map +1 -1
  7. package/lib/module/components/Attachments/styles.js +10 -5
  8. package/lib/module/components/Attachments/styles.js.map +1 -1
  9. package/lib/module/components/Composer/Composer.js +13 -9
  10. package/lib/module/components/Composer/Composer.js.map +1 -1
  11. package/lib/module/components/Composer/styles.js +1 -0
  12. package/lib/module/components/Composer/styles.js.map +1 -1
  13. package/lib/module/components/Confirmation/Confirmation.js +29 -13
  14. package/lib/module/components/Confirmation/Confirmation.js.map +1 -1
  15. package/lib/module/components/Confirmation/styles.js +17 -6
  16. package/lib/module/components/Confirmation/styles.js.map +1 -1
  17. package/lib/module/components/Message/MarkdownContent/styles.js +29 -33
  18. package/lib/module/components/Message/MarkdownContent/styles.js.map +1 -1
  19. package/lib/module/components/Message/Message.js +37 -24
  20. package/lib/module/components/Message/Message.js.map +1 -1
  21. package/lib/module/components/Message/MessageWaiting.js +53 -0
  22. package/lib/module/components/Message/MessageWaiting.js.map +1 -0
  23. package/lib/module/components/Message/constants.js +3 -0
  24. package/lib/module/components/Message/constants.js.map +1 -1
  25. package/lib/module/components/Message/styles.js +41 -3
  26. package/lib/module/components/Message/styles.js.map +1 -1
  27. package/lib/module/components/MessageList/MessageList.js +60 -31
  28. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  29. package/lib/module/components/MessageList/MessageListEndButton.js +60 -0
  30. package/lib/module/components/MessageList/MessageListEndButton.js.map +1 -0
  31. package/lib/module/components/MessageList/MessageListRow.js +9 -2
  32. package/lib/module/components/MessageList/MessageListRow.js.map +1 -1
  33. package/lib/module/components/MessageList/styles.js +6 -0
  34. package/lib/module/components/MessageList/styles.js.map +1 -1
  35. package/lib/module/components/MessageList/useMessageListScroll.js +218 -13
  36. package/lib/module/components/MessageList/useMessageListScroll.js.map +1 -1
  37. package/lib/module/components/Process/Process.js +15 -5
  38. package/lib/module/components/Process/Process.js.map +1 -1
  39. package/lib/module/components/Process/ProcessCompactStep.js +21 -12
  40. package/lib/module/components/Process/ProcessCompactStep.js.map +1 -1
  41. package/lib/module/components/Process/ProcessTimelineStep.js +79 -0
  42. package/lib/module/components/Process/ProcessTimelineStep.js.map +1 -0
  43. package/lib/module/components/Process/styles.js +63 -3
  44. package/lib/module/components/Process/styles.js.map +1 -1
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/typescript/src/components/Attachments/AttachmentItem.d.ts +1 -1
  47. package/lib/typescript/src/components/Attachments/AttachmentItem.d.ts.map +1 -1
  48. package/lib/typescript/src/components/Attachments/Attachments.d.ts.map +1 -1
  49. package/lib/typescript/src/components/Attachments/constants.d.ts +1 -0
  50. package/lib/typescript/src/components/Attachments/constants.d.ts.map +1 -1
  51. package/lib/typescript/src/components/Attachments/styles.d.ts +5 -0
  52. package/lib/typescript/src/components/Attachments/styles.d.ts.map +1 -1
  53. package/lib/typescript/src/components/Attachments/types.d.ts +2 -1
  54. package/lib/typescript/src/components/Attachments/types.d.ts.map +1 -1
  55. package/lib/typescript/src/components/Composer/Composer.d.ts.map +1 -1
  56. package/lib/typescript/src/components/Composer/styles.d.ts +1 -0
  57. package/lib/typescript/src/components/Composer/styles.d.ts.map +1 -1
  58. package/lib/typescript/src/components/Confirmation/Confirmation.d.ts.map +1 -1
  59. package/lib/typescript/src/components/Confirmation/styles.d.ts +13 -2
  60. package/lib/typescript/src/components/Confirmation/styles.d.ts.map +1 -1
  61. package/lib/typescript/src/components/Message/MarkdownContent/styles.d.ts +32 -66
  62. package/lib/typescript/src/components/Message/MarkdownContent/styles.d.ts.map +1 -1
  63. package/lib/typescript/src/components/Message/Message.d.ts.map +1 -1
  64. package/lib/typescript/src/components/Message/MessageWaiting.d.ts +3 -0
  65. package/lib/typescript/src/components/Message/MessageWaiting.d.ts.map +1 -0
  66. package/lib/typescript/src/components/Message/constants.d.ts +3 -0
  67. package/lib/typescript/src/components/Message/constants.d.ts.map +1 -1
  68. package/lib/typescript/src/components/Message/styles.d.ts +40 -2
  69. package/lib/typescript/src/components/Message/styles.d.ts.map +1 -1
  70. package/lib/typescript/src/components/Message/types.d.ts +5 -0
  71. package/lib/typescript/src/components/Message/types.d.ts.map +1 -1
  72. package/lib/typescript/src/components/MessageList/MessageList.d.ts.map +1 -1
  73. package/lib/typescript/src/components/MessageList/MessageListEndButton.d.ts +3 -0
  74. package/lib/typescript/src/components/MessageList/MessageListEndButton.d.ts.map +1 -0
  75. package/lib/typescript/src/components/MessageList/MessageListRow.d.ts +2 -8
  76. package/lib/typescript/src/components/MessageList/MessageListRow.d.ts.map +1 -1
  77. package/lib/typescript/src/components/MessageList/index.d.ts +1 -1
  78. package/lib/typescript/src/components/MessageList/index.d.ts.map +1 -1
  79. package/lib/typescript/src/components/MessageList/styles.d.ts +6 -0
  80. package/lib/typescript/src/components/MessageList/styles.d.ts.map +1 -1
  81. package/lib/typescript/src/components/MessageList/types.d.ts +41 -2
  82. package/lib/typescript/src/components/MessageList/types.d.ts.map +1 -1
  83. package/lib/typescript/src/components/MessageList/useMessageListScroll.d.ts +14 -3
  84. package/lib/typescript/src/components/MessageList/useMessageListScroll.d.ts.map +1 -1
  85. package/lib/typescript/src/components/Process/Process.d.ts.map +1 -1
  86. package/lib/typescript/src/components/Process/ProcessCompactStep.d.ts +1 -1
  87. package/lib/typescript/src/components/Process/ProcessCompactStep.d.ts.map +1 -1
  88. package/lib/typescript/src/components/Process/ProcessTimelineStep.d.ts +5 -0
  89. package/lib/typescript/src/components/Process/ProcessTimelineStep.d.ts.map +1 -0
  90. package/lib/typescript/src/components/Process/styles.d.ts +62 -2
  91. package/lib/typescript/src/components/Process/styles.d.ts.map +1 -1
  92. package/lib/typescript/src/components/Process/types.d.ts +7 -2
  93. package/lib/typescript/src/components/Process/types.d.ts.map +1 -1
  94. package/lib/typescript/src/index.d.ts +1 -1
  95. package/lib/typescript/src/index.d.ts.map +1 -1
  96. package/package.json +1 -1
  97. package/src/components/Attachments/AttachmentItem.tsx +16 -5
  98. package/src/components/Attachments/Attachments.tsx +1 -0
  99. package/src/components/Attachments/constants.ts +1 -0
  100. package/src/components/Attachments/styles.ts +7 -4
  101. package/src/components/Attachments/types.ts +2 -1
  102. package/src/components/Composer/Composer.tsx +34 -8
  103. package/src/components/Composer/styles.ts +1 -0
  104. package/src/components/Confirmation/Confirmation.tsx +50 -14
  105. package/src/components/Confirmation/styles.ts +13 -6
  106. package/src/components/Message/MarkdownContent/styles.ts +18 -44
  107. package/src/components/Message/Message.tsx +53 -33
  108. package/src/components/Message/MessageWaiting.tsx +68 -0
  109. package/src/components/Message/constants.ts +4 -0
  110. package/src/components/Message/styles.ts +25 -2
  111. package/src/components/Message/types.ts +6 -0
  112. package/src/components/MessageList/MessageList.tsx +107 -35
  113. package/src/components/MessageList/MessageListEndButton.tsx +61 -0
  114. package/src/components/MessageList/MessageListRow.tsx +12 -12
  115. package/src/components/MessageList/index.ts +1 -0
  116. package/src/components/MessageList/styles.ts +6 -0
  117. package/src/components/MessageList/types.ts +52 -2
  118. package/src/components/MessageList/useMessageListScroll.ts +296 -21
  119. package/src/components/Process/Process.tsx +38 -5
  120. package/src/components/Process/ProcessCompactStep.tsx +32 -16
  121. package/src/components/Process/ProcessTimelineStep.tsx +109 -0
  122. package/src/components/Process/styles.ts +48 -3
  123. package/src/components/Process/types.ts +7 -2
  124. 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
- compactDetails: {
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 为完整步骤面板;compact 为可整行展开、有界详情的轻量过程展示。 */
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;
package/src/index.tsx CHANGED
@@ -28,6 +28,7 @@ export type {
28
28
  } from './components/Message';
29
29
  export { MessageList } from './components/MessageList';
30
30
  export type {
31
+ MessageListAnchorOptions,
31
32
  MessageListHandle,
32
33
  MessageListProps,
33
34
  MessageListScrollOptions,