@unif/react-native-ui 0.3.5 → 0.4.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 (81) hide show
  1. package/lib/commonjs/action-sheet/index.js +3 -1
  2. package/lib/commonjs/action-sheet/index.js.map +1 -1
  3. package/lib/commonjs/avatar/index.js +1 -0
  4. package/lib/commonjs/avatar/index.js.map +1 -1
  5. package/lib/commonjs/button/index.js +1 -1
  6. package/lib/commonjs/button/index.js.map +1 -1
  7. package/lib/commonjs/chip/index.js +5 -0
  8. package/lib/commonjs/chip/index.js.map +1 -1
  9. package/lib/commonjs/input/index.js +2 -1
  10. package/lib/commonjs/input/index.js.map +1 -1
  11. package/lib/commonjs/list-item/index.js +1 -0
  12. package/lib/commonjs/list-item/index.js.map +1 -1
  13. package/lib/commonjs/popover/index.js.map +1 -1
  14. package/lib/commonjs/tag/index.js.map +1 -1
  15. package/lib/commonjs/tag/style/index.js +3 -1
  16. package/lib/commonjs/tag/style/index.js.map +1 -1
  17. package/lib/commonjs/touchable/index.js +1 -0
  18. package/lib/commonjs/touchable/index.js.map +1 -1
  19. package/lib/module/action-sheet/index.js +3 -1
  20. package/lib/module/action-sheet/index.js.map +1 -1
  21. package/lib/module/avatar/index.js +1 -0
  22. package/lib/module/avatar/index.js.map +1 -1
  23. package/lib/module/button/index.js +1 -1
  24. package/lib/module/button/index.js.map +1 -1
  25. package/lib/module/chip/index.js +5 -0
  26. package/lib/module/chip/index.js.map +1 -1
  27. package/lib/module/input/index.js +2 -1
  28. package/lib/module/input/index.js.map +1 -1
  29. package/lib/module/list-item/index.js +1 -0
  30. package/lib/module/list-item/index.js.map +1 -1
  31. package/lib/module/popover/index.js.map +1 -1
  32. package/lib/module/tag/index.js.map +1 -1
  33. package/lib/module/tag/style/index.js +3 -1
  34. package/lib/module/tag/style/index.js.map +1 -1
  35. package/lib/module/touchable/index.js +1 -0
  36. package/lib/module/touchable/index.js.map +1 -1
  37. package/lib/typescript/commonjs/src/action-sheet/index.d.ts +9 -0
  38. package/lib/typescript/commonjs/src/action-sheet/index.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/src/avatar/index.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/src/button/index.d.ts +11 -0
  41. package/lib/typescript/commonjs/src/button/index.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/src/chip/index.d.ts +9 -0
  43. package/lib/typescript/commonjs/src/chip/index.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/src/input/index.d.ts +18 -0
  45. package/lib/typescript/commonjs/src/input/index.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/src/list-item/index.d.ts +12 -0
  47. package/lib/typescript/commonjs/src/list-item/index.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/src/popover/index.d.ts +9 -0
  49. package/lib/typescript/commonjs/src/popover/index.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/src/tag/index.d.ts +7 -0
  51. package/lib/typescript/commonjs/src/tag/index.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/src/tag/style/index.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/src/touchable/index.d.ts.map +1 -1
  54. package/lib/typescript/module/src/action-sheet/index.d.ts +9 -0
  55. package/lib/typescript/module/src/action-sheet/index.d.ts.map +1 -1
  56. package/lib/typescript/module/src/avatar/index.d.ts.map +1 -1
  57. package/lib/typescript/module/src/button/index.d.ts +11 -0
  58. package/lib/typescript/module/src/button/index.d.ts.map +1 -1
  59. package/lib/typescript/module/src/chip/index.d.ts +9 -0
  60. package/lib/typescript/module/src/chip/index.d.ts.map +1 -1
  61. package/lib/typescript/module/src/input/index.d.ts +18 -0
  62. package/lib/typescript/module/src/input/index.d.ts.map +1 -1
  63. package/lib/typescript/module/src/list-item/index.d.ts +12 -0
  64. package/lib/typescript/module/src/list-item/index.d.ts.map +1 -1
  65. package/lib/typescript/module/src/popover/index.d.ts +9 -0
  66. package/lib/typescript/module/src/popover/index.d.ts.map +1 -1
  67. package/lib/typescript/module/src/tag/index.d.ts +7 -0
  68. package/lib/typescript/module/src/tag/index.d.ts.map +1 -1
  69. package/lib/typescript/module/src/tag/style/index.d.ts.map +1 -1
  70. package/lib/typescript/module/src/touchable/index.d.ts.map +1 -1
  71. package/package.json +1 -1
  72. package/src/action-sheet/index.tsx +12 -1
  73. package/src/avatar/index.tsx +5 -1
  74. package/src/button/index.tsx +12 -1
  75. package/src/chip/index.tsx +11 -0
  76. package/src/input/index.tsx +20 -1
  77. package/src/list-item/index.tsx +13 -0
  78. package/src/popover/index.tsx +9 -0
  79. package/src/tag/index.tsx +7 -0
  80. package/src/tag/style/index.tsx +3 -1
  81. package/src/touchable/index.tsx +1 -0
@@ -18,14 +18,23 @@ import {
18
18
  } from './style';
19
19
 
20
20
  export interface ChipProps {
21
+ /** 胶囊内容 */
21
22
  children: React.ReactNode;
23
+ /** 点击回调 */
22
24
  onPress?: () => void;
25
+ /** 选中状态 */
23
26
  selected?: boolean;
27
+ /** 禁用状态 */
24
28
  disabled?: boolean;
29
+ /** 胶囊尺寸 */
25
30
  size?: 'default' | 'small';
31
+ /** 左侧图标 */
26
32
  icon?: React.ReactNode;
33
+ /** 容器样式 */
27
34
  style?: ViewStyle;
35
+ /** 语义样式覆盖 */
28
36
  styles?: Partial<ChipSemanticStyles>;
37
+ /** 测试标识 */
29
38
  testID?: string;
30
39
  }
31
40
 
@@ -83,6 +92,8 @@ const Chip: React.FC<ChipProps> = ({
83
92
  if (onPress) {
84
93
  return (
85
94
  <Pressable
95
+ accessibilityRole="button"
96
+ accessibilityState={{ disabled: !!disabled, selected: !!selected }}
86
97
  onPress={onPress}
87
98
  disabled={disabled}
88
99
  style={({ pressed }) => pressed && PRESSED_STYLE}
@@ -13,21 +13,39 @@ import type { InputSemanticStyles } from './style';
13
13
  import { createDefaultStyles } from './style';
14
14
 
15
15
  export interface InputProps {
16
+ /** 输入值 */
16
17
  value?: string;
18
+ /** 文本变更回调 */
17
19
  onChangeText?: (text: string) => void;
20
+ /** 占位提示文本 */
18
21
  placeholder?: string;
22
+ /** 是否多行输入 */
19
23
  multiline?: boolean;
24
+ /** 最大字符数 */
20
25
  maxLength?: number;
26
+ /** 多行模式下的最大高度 */
21
27
  maxHeight?: number;
28
+ /** 自动聚焦 */
22
29
  autoFocus?: boolean;
30
+ /** 键盘回车键类型 */
23
31
  returnKeyType?: ReturnKeyTypeOptions;
32
+ /** 提交编辑回调 */
24
33
  onSubmitEditing?: () => void;
34
+ /** 失焦回调 */
25
35
  onBlur?: () => void;
36
+ /** 聚焦回调 */
26
37
  onFocus?: () => void;
38
+ /** 提交时是否收起键盘 */
39
+ blurOnSubmit?: boolean;
40
+ /** 禁用状态 */
27
41
  disabled?: boolean;
42
+ /** 底部工具栏插槽 */
28
43
  toolbar?: React.ReactNode;
44
+ /** 容器样式 */
29
45
  style?: ViewStyle;
46
+ /** 语义样式覆盖 */
30
47
  styles?: Partial<InputSemanticStyles>;
48
+ /** 测试标识 */
31
49
  testID?: string;
32
50
  }
33
51
 
@@ -47,6 +65,7 @@ const Input = forwardRef<InputRef, InputProps>(
47
65
  onSubmitEditing,
48
66
  onBlur,
49
67
  onFocus,
68
+ blurOnSubmit,
50
69
  disabled,
51
70
  toolbar,
52
71
  style,
@@ -90,7 +109,7 @@ const Input = forwardRef<InputRef, InputProps>(
90
109
  onBlur={onBlur}
91
110
  onFocus={onFocus}
92
111
  editable={!disabled}
93
- blurOnSubmit={false}
112
+ blurOnSubmit={blurOnSubmit ?? !multiline}
94
113
  />
95
114
  {toolbar && <View style={s.toolbar}>{toolbar}</View>}
96
115
  </View>
@@ -13,17 +13,29 @@ import type { ListItemSemanticStyles } from './style';
13
13
  import { createDefaultStyles, lineStyle, contentWrapStyle } from './style';
14
14
 
15
15
  interface ListItemProps {
16
+ /** 左侧缩略图 */
16
17
  thumb?: React.ReactNode;
18
+ /** 标题文本或自定义节点 */
17
19
  title: string | React.ReactNode;
20
+ /** 描述文本 */
18
21
  description?: string;
22
+ /** 右侧附加内容 */
19
23
  extra?: React.ReactNode | string;
24
+ /** 是否显示右侧箭头 */
20
25
  arrow?: boolean;
26
+ /** 自定义箭头图标 */
21
27
  arrowIcon?: React.ReactNode;
28
+ /** 点击回调 */
22
29
  onPress?: () => void;
30
+ /** 长按回调 */
23
31
  onLongPress?: () => void;
32
+ /** 禁用状态 */
24
33
  disabled?: boolean;
34
+ /** 容器样式 */
25
35
  style?: ViewStyle;
36
+ /** 语义样式覆盖 */
26
37
  styles?: Partial<ListItemSemanticStyles>;
38
+ /** 测试标识 */
27
39
  testID?: string;
28
40
  }
29
41
 
@@ -80,6 +92,7 @@ const ListItem: React.FC<ListItemProps> = ({
80
92
  if (props.onPress) {
81
93
  return (
82
94
  <Pressable
95
+ accessibilityRole="button"
83
96
  onPress={props.onPress}
84
97
  onLongPress={props.onLongPress}
85
98
  disabled={props.disabled}
@@ -13,14 +13,23 @@ import type { PopoverSemanticStyles } from './style';
13
13
  import { createDefaultStyles } from './style';
14
14
 
15
15
  export interface PopoverProps {
16
+ /** 是否可见 */
16
17
  visible: boolean;
18
+ /** 关闭回调 */
17
19
  onClose: () => void;
20
+ /** 锚点元素的布局信息 */
18
21
  anchorLayout: { x: number; y: number; width: number; height: number };
22
+ /** 弹出层宽度 */
19
23
  width?: number;
24
+ /** 弹出方向 */
20
25
  placement?: 'bottom' | 'top';
26
+ /** 弹出层内容 */
21
27
  children: React.ReactNode;
28
+ /** 容器样式 */
22
29
  style?: ViewStyle;
30
+ /** 语义样式覆盖 */
23
31
  styles?: Partial<PopoverSemanticStyles>;
32
+ /** 测试标识 */
24
33
  testID?: string;
25
34
  }
26
35
 
package/src/tag/index.tsx CHANGED
@@ -25,12 +25,19 @@ import {
25
25
  } from './style';
26
26
 
27
27
  export interface TagProps {
28
+ /** 标签内容 */
28
29
  children: React.ReactNode;
30
+ /** 标签变体:浅色底 / 纯色底 / 边框 */
29
31
  variant?: 'filled' | 'solid' | 'outlined';
32
+ /** 语义色名称或自定义 hex 色值 */
30
33
  color?: string;
34
+ /** 标签尺寸 */
31
35
  size?: 'default' | 'small';
36
+ /** 容器样式 */
32
37
  style?: ViewStyle;
38
+ /** 语义样式覆盖 */
33
39
  styles?: Partial<TagSemanticStyles>;
40
+ /** 测试标识 */
34
41
  testID?: string;
35
42
  }
36
43
 
@@ -17,10 +17,12 @@ const PRESET_COLORS = {
17
17
 
18
18
  type PresetName = keyof typeof PRESET_COLORS;
19
19
 
20
+ const isPreset = (c: string): c is PresetName => c in PRESET_COLORS;
21
+
20
22
  /** 解析颜色:支持预设名或自定义 hex */
21
23
  export function resolveColor(color: string | undefined): string {
22
24
  if (!color) return PRESET_COLORS.default;
23
- if (color in PRESET_COLORS) return PRESET_COLORS[color as PresetName];
25
+ if (isPreset(color)) return PRESET_COLORS[color];
24
26
  return color;
25
27
  }
26
28
 
@@ -29,6 +29,7 @@ const Touchable: React.FC<TouchableProps> = ({
29
29
  ...rest
30
30
  }: TouchableProps) => (
31
31
  <Pressable
32
+ accessibilityRole="button"
32
33
  onPress={onPress}
33
34
  onLongPress={onLongPress}
34
35
  disabled={disabled}