@unif/react-native-chat 3.7.0 → 4.1.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.
Files changed (84) hide show
  1. package/lib/module/components/Attachments/AttachmentItem.js +13 -12
  2. package/lib/module/components/Attachments/AttachmentItem.js.map +1 -1
  3. package/lib/module/components/Attachments/constants.js +5 -4
  4. package/lib/module/components/Attachments/constants.js.map +1 -1
  5. package/lib/module/components/Composer/Composer.js +6 -5
  6. package/lib/module/components/Composer/Composer.js.map +1 -1
  7. package/lib/module/components/Composer/ComposerIconAction.js +3 -3
  8. package/lib/module/components/Composer/ComposerIconAction.js.map +1 -1
  9. package/lib/module/components/Confirmation/Confirmation.js +4 -3
  10. package/lib/module/components/Confirmation/Confirmation.js.map +1 -1
  11. package/lib/module/components/Feedback/Feedback.js +4 -3
  12. package/lib/module/components/Feedback/Feedback.js.map +1 -1
  13. package/lib/module/components/Feedback/constants.js +5 -4
  14. package/lib/module/components/Feedback/constants.js.map +1 -1
  15. package/lib/module/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.js +6 -3
  16. package/lib/module/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.js.map +1 -1
  17. package/lib/module/components/Message/Message.js +2 -1
  18. package/lib/module/components/Message/Message.js.map +1 -1
  19. package/lib/module/components/MessageList/MessageListEndButton.js +2 -1
  20. package/lib/module/components/MessageList/MessageListEndButton.js.map +1 -1
  21. package/lib/module/components/Process/Process.js +5 -3
  22. package/lib/module/components/Process/Process.js.map +1 -1
  23. package/lib/module/components/Process/ProcessCompactStep.js +17 -12
  24. package/lib/module/components/Process/ProcessCompactStep.js.map +1 -1
  25. package/lib/module/components/Process/ProcessTimelineStep.js +3 -3
  26. package/lib/module/components/Process/ProcessTimelineStep.js.map +1 -1
  27. package/lib/module/components/Process/constants.js +6 -5
  28. package/lib/module/components/Process/constants.js.map +1 -1
  29. package/lib/module/components/Process/styles.js +8 -0
  30. package/lib/module/components/Process/styles.js.map +1 -1
  31. package/lib/module/components/Sources/Sources.js +6 -3
  32. package/lib/module/components/Sources/Sources.js.map +1 -1
  33. package/lib/module/components/Suggestions/Suggestions.js +2 -3
  34. package/lib/module/components/Suggestions/Suggestions.js.map +1 -1
  35. package/lib/typescript/src/actions/types.d.ts +3 -2
  36. package/lib/typescript/src/actions/types.d.ts.map +1 -1
  37. package/lib/typescript/src/components/Attachments/AttachmentItem.d.ts.map +1 -1
  38. package/lib/typescript/src/components/Attachments/constants.d.ts +3 -2
  39. package/lib/typescript/src/components/Attachments/constants.d.ts.map +1 -1
  40. package/lib/typescript/src/components/Composer/Composer.d.ts.map +1 -1
  41. package/lib/typescript/src/components/Composer/types.d.ts +4 -2
  42. package/lib/typescript/src/components/Composer/types.d.ts.map +1 -1
  43. package/lib/typescript/src/components/Confirmation/Confirmation.d.ts.map +1 -1
  44. package/lib/typescript/src/components/Feedback/Feedback.d.ts.map +1 -1
  45. package/lib/typescript/src/components/Feedback/constants.d.ts +3 -2
  46. package/lib/typescript/src/components/Feedback/constants.d.ts.map +1 -1
  47. package/lib/typescript/src/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.d.ts.map +1 -1
  48. package/lib/typescript/src/components/Message/Message.d.ts.map +1 -1
  49. package/lib/typescript/src/components/MessageList/MessageListEndButton.d.ts.map +1 -1
  50. package/lib/typescript/src/components/Process/Process.d.ts.map +1 -1
  51. package/lib/typescript/src/components/Process/ProcessCompactStep.d.ts +1 -1
  52. package/lib/typescript/src/components/Process/ProcessCompactStep.d.ts.map +1 -1
  53. package/lib/typescript/src/components/Process/constants.d.ts +3 -2
  54. package/lib/typescript/src/components/Process/constants.d.ts.map +1 -1
  55. package/lib/typescript/src/components/Process/styles.d.ts +8 -0
  56. package/lib/typescript/src/components/Process/styles.d.ts.map +1 -1
  57. package/lib/typescript/src/components/Process/types.d.ts +7 -0
  58. package/lib/typescript/src/components/Process/types.d.ts.map +1 -1
  59. package/lib/typescript/src/components/Sources/Sources.d.ts.map +1 -1
  60. package/lib/typescript/src/components/Suggestions/Suggestions.d.ts.map +1 -1
  61. package/lib/typescript/src/components/Suggestions/types.d.ts +3 -2
  62. package/lib/typescript/src/components/Suggestions/types.d.ts.map +1 -1
  63. package/package.json +5 -3
  64. package/src/actions/types.ts +3 -2
  65. package/src/components/Attachments/AttachmentItem.tsx +14 -20
  66. package/src/components/Attachments/constants.ts +14 -6
  67. package/src/components/Composer/Composer.tsx +14 -5
  68. package/src/components/Composer/ComposerIconAction.tsx +3 -3
  69. package/src/components/Composer/types.ts +4 -2
  70. package/src/components/Confirmation/Confirmation.tsx +12 -12
  71. package/src/components/Feedback/Feedback.tsx +3 -2
  72. package/src/components/Feedback/constants.ts +16 -6
  73. package/src/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.tsx +4 -2
  74. package/src/components/Message/Message.tsx +2 -1
  75. package/src/components/MessageList/MessageListEndButton.tsx +2 -1
  76. package/src/components/Process/Process.tsx +5 -3
  77. package/src/components/Process/ProcessCompactStep.tsx +37 -21
  78. package/src/components/Process/ProcessTimelineStep.tsx +2 -2
  79. package/src/components/Process/constants.ts +16 -7
  80. package/src/components/Process/styles.ts +2 -0
  81. package/src/components/Process/types.ts +8 -0
  82. package/src/components/Sources/Sources.tsx +6 -2
  83. package/src/components/Suggestions/Suggestions.tsx +2 -6
  84. package/src/components/Suggestions/types.ts +4 -2
@@ -1,7 +1,11 @@
1
+ import {
2
+ ChevronDownOutlined,
3
+ ChevronUpOutlined,
4
+ SparkOutlined,
5
+ } from '@unif/react-native-icons';
1
6
  import { Pressable, ScrollView, Text, View } from 'react-native';
2
7
  import {
3
8
  Button,
4
- Icon,
5
9
  Pulse,
6
10
  Reveal,
7
11
  motion,
@@ -16,6 +20,7 @@ import type { ProcessCompactStepProps } from './types';
16
20
  export function ProcessCompactStep({
17
21
  step,
18
22
  identity,
23
+ dense = false,
19
24
  expanded,
20
25
  elapsed,
21
26
  onToggle,
@@ -32,30 +37,38 @@ export function ProcessCompactStep({
32
37
  : step.status === 'failed'
33
38
  ? colors.error
34
39
  : colors.foregroundMuted;
35
- const icon = (
36
- <Icon
37
- name={
38
- running || step.status === 'completed'
39
- ? 'spark'
40
- : PROCESS_STATUS_ICONS[step.status]
41
- }
42
- size={14}
43
- color={color}
44
- />
45
- );
40
+ const Glyph =
41
+ step.icon ??
42
+ (running || step.status === 'completed'
43
+ ? SparkOutlined
44
+ : PROCESS_STATUS_ICONS[step.status]);
45
+ const icon =
46
+ step.icon === null ? null : (
47
+ <Glyph
48
+ size={14}
49
+ color={step.icon === undefined ? color : colors.foregroundMuted}
50
+ />
51
+ );
52
+ const Glyph2 = expanded ? ChevronUpOutlined : ChevronDownOutlined;
46
53
  return (
47
54
  <View>
48
55
  <Pressable
49
56
  testID={`process-step-${step.id}-toggle`}
50
57
  accessible
51
58
  accessibilityRole={hasDetails ? 'button' : undefined}
52
- accessibilityLabel={`${step.title},${statusText}${elapsed ? `,${elapsed}` : ''}`}
59
+ accessibilityLabel={[step.title, statusText, elapsed]
60
+ .filter(Boolean)
61
+ .join(',')}
53
62
  accessibilityState={hasDetails ? { expanded } : undefined}
63
+ accessibilityValue={
64
+ statusText ? undefined : { text: PROCESS_STATUS_LABELS[step.status] }
65
+ }
54
66
  disabled={!hasDetails}
55
67
  hitSlop={10}
56
68
  onPress={onToggle}
57
69
  style={({ pressed }) => [
58
70
  styles.compactHeader,
71
+ dense && styles.compactHeaderDense,
59
72
  pressed && { opacity: pressedOpacity },
60
73
  ]}
61
74
  >
@@ -65,7 +78,7 @@ export function ProcessCompactStep({
65
78
  <View style={styles.spacer} />
66
79
  </>
67
80
  ) : null}
68
- {running ? (
81
+ {running && icon ? (
69
82
  <Pulse from={0.4} duration={motion.pulse / 2}>
70
83
  {icon}
71
84
  </Pulse>
@@ -81,21 +94,24 @@ export function ProcessCompactStep({
81
94
  {step.title}
82
95
  </Text>
83
96
  ) : null}
84
- <Text style={styles.compactStatus}>{statusText}</Text>
97
+ {statusText ? (
98
+ <Text style={styles.compactStatus}>{statusText}</Text>
99
+ ) : null}
85
100
  {elapsed ? <Text style={styles.elapsed}>{elapsed}</Text> : null}
86
101
  {hasDetails ? (
87
- <Icon
88
- name={expanded ? 'chevron-up' : 'chevron-down'}
89
- size={14}
90
- color={colors.foregroundSubtle}
91
- />
102
+ <Glyph2 size={14} color={colors.foregroundSubtle} />
92
103
  ) : null}
93
104
  </Pressable>
94
105
  {step.description ? (
95
106
  <Text style={styles.compactDescription}>{step.description}</Text>
96
107
  ) : null}
97
108
  {hasDetails && expanded ? (
98
- <Reveal style={styles.compactDetailsContainer}>
109
+ <Reveal
110
+ style={[
111
+ styles.compactDetailsContainer,
112
+ dense && styles.compactDetailsDense,
113
+ ]}
114
+ >
99
115
  <ScrollView
100
116
  testID={`process-step-${step.id}-details`}
101
117
  style={styles.compactDetails}
@@ -1,7 +1,7 @@
1
+ import { CloseOutlined } from '@unif/react-native-icons';
1
2
  import { Text, View } from 'react-native';
2
3
  import {
3
4
  Button,
4
- Icon,
5
5
  StatusDot,
6
6
  icon,
7
7
  useColors,
@@ -35,7 +35,7 @@ export function ProcessTimelineStep({
35
35
  >
36
36
  <View style={styles.timelineGutter}>
37
37
  {step.status === 'cancelled' ? (
38
- <Icon name="close" size={icon.xs} color={colors.foregroundSubtle} />
38
+ <CloseOutlined size={icon.xs} color={colors.foregroundSubtle} />
39
39
  ) : (
40
40
  <StatusDot
41
41
  status={status}
@@ -1,4 +1,13 @@
1
- import type { IconName } from '@unif/react-native-design';
1
+ import {
2
+ CircleMinusOutlined,
3
+ CloseOutlined,
4
+ ErrorOutlined,
5
+ SuccessOutlined,
6
+ ThinkingOutlined,
7
+ } from '@unif/react-native-icons';
8
+ import type { ComponentType } from 'react';
9
+ import type { IconProps } from '@unif/react-native-icons';
10
+
2
11
  import type { ProcessStepStatus } from './types';
3
12
 
4
13
  export const PROCESS_STATUS_LABELS: Readonly<
@@ -12,11 +21,11 @@ export const PROCESS_STATUS_LABELS: Readonly<
12
21
  };
13
22
 
14
23
  export const PROCESS_STATUS_ICONS: Readonly<
15
- Record<ProcessStepStatus, IconName>
24
+ Record<ProcessStepStatus, ComponentType<IconProps>>
16
25
  > = {
17
- pending: 'circle-minus',
18
- running: 'thinking',
19
- completed: 'success',
20
- failed: 'error',
21
- cancelled: 'close',
26
+ pending: CircleMinusOutlined,
27
+ running: ThinkingOutlined,
28
+ completed: SuccessOutlined,
29
+ failed: ErrorOutlined,
30
+ cancelled: CloseOutlined,
22
31
  };
@@ -53,6 +53,8 @@ export const createStyles = (colors: ColorTokens) =>
53
53
  minHeight: 44,
54
54
  paddingVertical: space[1],
55
55
  },
56
+ compactHeaderDense: { minHeight: 24, paddingVertical: 0 },
57
+ compactDetailsDense: { paddingTop: space[1], paddingBottom: space[1] },
56
58
  compactTitle: {
57
59
  flex: 1,
58
60
  minWidth: 0,
@@ -1,4 +1,7 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { IconProps } from '@unif/react-native-icons';
1
3
  import type { ReactNode } from 'react';
4
+
2
5
  import type { StyleProp, ViewStyle } from 'react-native';
3
6
  import type { ChatAction } from '../../actions';
4
7
 
@@ -9,6 +12,8 @@ export interface ProcessStep {
9
12
  id: string;
10
13
  title: string;
11
14
  status: ProcessStepStatus;
15
+ /** compact 的活动图标;null 不显示,省略时沿状态呈现。 */
16
+ icon?: ComponentType<IconProps> | null;
12
17
  /** 调用者提供的状态显示文案;不改变 status 的语义。 */
13
18
  statusText?: string;
14
19
  description?: string;
@@ -20,6 +25,8 @@ export interface ProcessStep {
20
25
  export interface ProcessBaseProps {
21
26
  /** card 为状态面板;compact 为单行过程;timeline 为带状态节点的连续步骤。 */
22
27
  variant?: 'card' | 'compact' | 'timeline';
28
+ /** compact 文字密度;dense 用于与行内文字相邻的公开过程。 */
29
+ compactDensity?: 'comfortable' | 'dense';
23
30
  steps: readonly ProcessStep[];
24
31
  title?: string;
25
32
  identity?: ReactNode;
@@ -30,6 +37,7 @@ export interface ProcessBaseProps {
30
37
  }
31
38
 
32
39
  export interface ProcessCompactStepProps {
40
+ dense?: boolean;
33
41
  identity?: ReactNode;
34
42
  step: ProcessStep;
35
43
  expanded: boolean;
@@ -1,5 +1,6 @@
1
+ import { ChevronRightOutlined } from '@unif/react-native-icons';
1
2
  import { Pressable, Text, View } from 'react-native';
2
- import { Icon, useThemedStyles } from '@unif/react-native-design';
3
+ import { r, useColors, useThemedStyles } from '@unif/react-native-design';
3
4
  import { DEFAULT_SOURCES_TITLE } from './constants';
4
5
  import { createStyles } from './styles';
5
6
  import type { SourceItem, SourcesProps } from './types';
@@ -12,6 +13,7 @@ export function Sources({
12
13
  testID,
13
14
  }: SourcesProps): React.JSX.Element | null {
14
15
  const styles = useThemedStyles(createStyles);
16
+ const colors = useColors();
15
17
 
16
18
  if (items.length === 0) return null;
17
19
 
@@ -26,7 +28,9 @@ export function Sources({
26
28
  <Text style={styles.description}>{item.description}</Text>
27
29
  ) : null}
28
30
  </View>
29
- {showChevron ? <Icon name="chevron-right" /> : null}
31
+ {showChevron ? (
32
+ <ChevronRightOutlined size={r(18)} color={colors.foregroundMuted} />
33
+ ) : null}
30
34
  </>
31
35
  );
32
36
 
@@ -1,5 +1,5 @@
1
1
  import { View } from 'react-native';
2
- import { Chip, Icon, useColors } from '@unif/react-native-design';
2
+ import { Chip, useColors } from '@unif/react-native-design';
3
3
  import { SUGGESTION_ICON_SIZE } from './constants';
4
4
  import { styles } from './styles';
5
5
  import type { SuggestionsProps } from './types';
@@ -29,11 +29,7 @@ export function Suggestions({
29
29
  disabled={item.disabled}
30
30
  leading={
31
31
  item.icon ? (
32
- <Icon
33
- name={item.icon}
34
- size={SUGGESTION_ICON_SIZE}
35
- color={colors.primary}
36
- />
32
+ <item.icon size={SUGGESTION_ICON_SIZE} color={colors.primary} />
37
33
  ) : undefined
38
34
  }
39
35
  onPress={onSelect ? () => onSelect(item) : undefined}
@@ -1,11 +1,13 @@
1
- import type { IconName } from '@unif/react-native-design';
1
+ import type { ComponentType } from 'react';
2
+ import type { IconProps } from '@unif/react-native-icons';
3
+
2
4
  import type { StyleProp, ViewStyle } from 'react-native';
3
5
 
4
6
  export interface SuggestionItem {
5
7
  id: string;
6
8
  label: string;
7
9
  /** 14 布局单位的主题主色图标,普通与选中状态保持相同图标样式。 */
8
- icon?: IconName;
10
+ icon?: ComponentType<IconProps>;
9
11
  selected?: boolean;
10
12
  loading?: boolean;
11
13
  disabled?: boolean;