@unif/react-native-ui 0.2.0 → 0.2.11

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 (139) hide show
  1. package/lib/commonjs/action-sheet/style/index.js.map +1 -1
  2. package/lib/commonjs/avatar/index.js.map +1 -1
  3. package/lib/commonjs/chip/index.js +2 -7
  4. package/lib/commonjs/chip/index.js.map +1 -1
  5. package/lib/commonjs/chip/style/index.js +5 -0
  6. package/lib/commonjs/chip/style/index.js.map +1 -1
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/commonjs/input/index.js.map +1 -1
  9. package/lib/commonjs/list-item/index.js.map +1 -1
  10. package/lib/commonjs/menu/index.js +3 -5
  11. package/lib/commonjs/menu/index.js.map +1 -1
  12. package/lib/commonjs/popover/index.js.map +1 -1
  13. package/lib/commonjs/popover/style/index.js +3 -3
  14. package/lib/commonjs/popover/style/index.js.map +1 -1
  15. package/lib/commonjs/space/index.js.map +1 -1
  16. package/lib/commonjs/text/index.js.map +1 -1
  17. package/lib/commonjs/wave-animation/index.js.map +1 -1
  18. package/lib/module/action-sheet/style/index.js.map +1 -1
  19. package/lib/module/avatar/index.js.map +1 -1
  20. package/lib/module/chip/index.js +2 -7
  21. package/lib/module/chip/index.js.map +1 -1
  22. package/lib/module/chip/style/index.js +5 -0
  23. package/lib/module/chip/style/index.js.map +1 -1
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/input/index.js.map +1 -1
  26. package/lib/module/list-item/index.js.map +1 -1
  27. package/lib/module/menu/index.js +3 -5
  28. package/lib/module/menu/index.js.map +1 -1
  29. package/lib/module/popover/index.js.map +1 -1
  30. package/lib/module/popover/style/index.js +3 -3
  31. package/lib/module/popover/style/index.js.map +1 -1
  32. package/lib/module/space/index.js.map +1 -1
  33. package/lib/module/text/index.js.map +1 -1
  34. package/lib/module/wave-animation/index.js.map +1 -1
  35. package/lib/typescript/commonjs/docs-src/components/ExpoSnack.d.ts +11 -0
  36. package/lib/typescript/commonjs/docs-src/components/ExpoSnack.d.ts.map +1 -0
  37. package/lib/typescript/commonjs/docusaurus.config.d.ts +4 -0
  38. package/lib/typescript/commonjs/docusaurus.config.d.ts.map +1 -0
  39. package/lib/typescript/commonjs/sidebars.d.ts +4 -0
  40. package/lib/typescript/commonjs/sidebars.d.ts.map +1 -0
  41. package/lib/typescript/commonjs/src/action-sheet/style/index.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/src/avatar/index.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/src/chip/index.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/src/chip/style/index.d.ts +1 -0
  45. package/lib/typescript/commonjs/src/chip/style/index.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/src/index.d.ts +1 -1
  47. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/src/input/index.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/src/list-item/index.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/src/menu/index.d.ts.map +1 -1
  51. package/lib/typescript/commonjs/src/popover/index.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/src/space/index.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/src/text/index.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/src/wave-animation/index.d.ts.map +1 -1
  55. package/lib/typescript/module/docs-src/components/ExpoSnack.d.ts +11 -0
  56. package/lib/typescript/module/docs-src/components/ExpoSnack.d.ts.map +1 -0
  57. package/lib/typescript/module/docusaurus.config.d.ts +4 -0
  58. package/lib/typescript/module/docusaurus.config.d.ts.map +1 -0
  59. package/lib/typescript/module/sidebars.d.ts +4 -0
  60. package/lib/typescript/module/sidebars.d.ts.map +1 -0
  61. package/lib/typescript/module/src/action-sheet/style/index.d.ts.map +1 -1
  62. package/lib/typescript/module/src/avatar/index.d.ts.map +1 -1
  63. package/lib/typescript/module/src/chip/index.d.ts.map +1 -1
  64. package/lib/typescript/module/src/chip/style/index.d.ts +1 -0
  65. package/lib/typescript/module/src/chip/style/index.d.ts.map +1 -1
  66. package/lib/typescript/module/src/index.d.ts +1 -1
  67. package/lib/typescript/module/src/index.d.ts.map +1 -1
  68. package/lib/typescript/module/src/input/index.d.ts.map +1 -1
  69. package/lib/typescript/module/src/list-item/index.d.ts.map +1 -1
  70. package/lib/typescript/module/src/menu/index.d.ts.map +1 -1
  71. package/lib/typescript/module/src/popover/index.d.ts.map +1 -1
  72. package/lib/typescript/module/src/space/index.d.ts.map +1 -1
  73. package/lib/typescript/module/src/text/index.d.ts.map +1 -1
  74. package/lib/typescript/module/src/wave-animation/index.d.ts.map +1 -1
  75. package/package.json +16 -2
  76. package/src/action-sheet/index.tsx +1 -1
  77. package/src/action-sheet/style/index.tsx +1 -3
  78. package/src/avatar/index.tsx +5 -2
  79. package/src/button/index.tsx +2 -2
  80. package/src/button/style/index.tsx +1 -1
  81. package/src/chip/index.tsx +12 -4
  82. package/src/chip/style/index.tsx +7 -1
  83. package/src/index.tsx +4 -1
  84. package/src/input/index.tsx +59 -54
  85. package/src/list-item/index.tsx +3 -4
  86. package/src/menu/index.tsx +1 -4
  87. package/src/popover/index.tsx +6 -7
  88. package/src/popover/style/index.tsx +3 -3
  89. package/src/space/index.tsx +1 -3
  90. package/src/text/index.tsx +6 -1
  91. package/src/wave-animation/index.tsx +7 -4
  92. package/lib/commonjs/action-sheet/index.md +0 -69
  93. package/lib/commonjs/avatar/index.md +0 -51
  94. package/lib/commonjs/button/index.md +0 -90
  95. package/lib/commonjs/center/index.md +0 -28
  96. package/lib/commonjs/chip/index.md +0 -60
  97. package/lib/commonjs/column/index.md +0 -34
  98. package/lib/commonjs/divider/index.md +0 -44
  99. package/lib/commonjs/hooks/index.md +0 -71
  100. package/lib/commonjs/input/index.md +0 -73
  101. package/lib/commonjs/list-item/index.md +0 -101
  102. package/lib/commonjs/popover/index.md +0 -57
  103. package/lib/commonjs/row/index.md +0 -46
  104. package/lib/commonjs/space/index.md +0 -31
  105. package/lib/commonjs/text/index.md +0 -63
  106. package/lib/commonjs/touchable/index.md +0 -42
  107. package/lib/commonjs/wave-animation/index.md +0 -50
  108. package/lib/module/action-sheet/index.md +0 -69
  109. package/lib/module/avatar/index.md +0 -51
  110. package/lib/module/button/index.md +0 -90
  111. package/lib/module/center/index.md +0 -28
  112. package/lib/module/chip/index.md +0 -60
  113. package/lib/module/column/index.md +0 -34
  114. package/lib/module/divider/index.md +0 -44
  115. package/lib/module/hooks/index.md +0 -71
  116. package/lib/module/input/index.md +0 -73
  117. package/lib/module/list-item/index.md +0 -101
  118. package/lib/module/popover/index.md +0 -57
  119. package/lib/module/row/index.md +0 -46
  120. package/lib/module/space/index.md +0 -31
  121. package/lib/module/text/index.md +0 -63
  122. package/lib/module/touchable/index.md +0 -42
  123. package/lib/module/wave-animation/index.md +0 -50
  124. package/src/action-sheet/index.md +0 -69
  125. package/src/avatar/index.md +0 -51
  126. package/src/button/index.md +0 -90
  127. package/src/center/index.md +0 -28
  128. package/src/chip/index.md +0 -60
  129. package/src/column/index.md +0 -34
  130. package/src/divider/index.md +0 -44
  131. package/src/hooks/index.md +0 -71
  132. package/src/input/index.md +0 -73
  133. package/src/list-item/index.md +0 -101
  134. package/src/popover/index.md +0 -57
  135. package/src/row/index.md +0 -46
  136. package/src/space/index.md +0 -31
  137. package/src/text/index.md +0 -63
  138. package/src/touchable/index.md +0 -42
  139. package/src/wave-animation/index.md +0 -50
@@ -60,11 +60,8 @@ const Menu: React.FC<MenuProps> = ({
60
60
  style={style}
61
61
  testID={testID}
62
62
  >
63
- {actions.map((action, index) => (
63
+ {actions.map((action) => (
64
64
  <React.Fragment key={action.key}>
65
- {index > 0 && (
66
- <View style={[ds.divider, semanticStyles?.divider]} />
67
- )}
68
65
  <Pressable
69
66
  style={[ds.item, semanticStyles?.item]}
70
67
  onPress={() => {
@@ -5,11 +5,7 @@
5
5
  */
6
6
 
7
7
  import React, { useMemo } from 'react';
8
- import {
9
- View,
10
- TouchableWithoutFeedback,
11
- Modal,
12
- } from 'react-native';
8
+ import { View, TouchableWithoutFeedback, Modal } from 'react-native';
13
9
  import type { ViewStyle } from 'react-native';
14
10
  import { mergeStyles } from '../hooks';
15
11
  import { useTokens } from '../theme/context';
@@ -46,7 +42,7 @@ const Popover: React.FC<PopoverProps> = ({
46
42
 
47
43
  const s = useMemo(
48
44
  () => mergeStyles<PopoverSemanticStyles>(defaultStyles, semanticStyles),
49
- [defaultStyles, semanticStyles],
45
+ [defaultStyles, semanticStyles]
50
46
  );
51
47
 
52
48
  if (!visible) {
@@ -55,7 +51,10 @@ const Popover: React.FC<PopoverProps> = ({
55
51
 
56
52
  const positionStyle: ViewStyle =
57
53
  placement === 'bottom'
58
- ? { top: anchorLayout.y + anchorLayout.height + GAP, left: anchorLayout.x }
54
+ ? {
55
+ top: anchorLayout.y + anchorLayout.height + GAP,
56
+ left: anchorLayout.x,
57
+ }
59
58
  : { bottom: anchorLayout.y - GAP, left: anchorLayout.x };
60
59
 
61
60
  return (
@@ -16,8 +16,8 @@ export const createDefaultStyles = (t: Tokens): PopoverSemanticStyles => ({
16
16
  borderRadius: 12,
17
17
  shadowColor: '#000',
18
18
  shadowOffset: { width: 0, height: 4 },
19
- shadowOpacity: 0.12,
20
- shadowRadius: 12,
21
- elevation: 8,
19
+ shadowOpacity: 0.08,
20
+ shadowRadius: 8,
21
+ elevation: 4,
22
22
  },
23
23
  });
@@ -18,9 +18,7 @@ export interface SpaceProps {
18
18
  const Space: React.FC<SpaceProps> = ({ size = 12, direction = 'vertical' }) => (
19
19
  <View
20
20
  style={
21
- direction === 'vertical'
22
- ? verticalStyle(size)
23
- : horizontalStyle(size)
21
+ direction === 'vertical' ? verticalStyle(size) : horizontalStyle(size)
24
22
  }
25
23
  />
26
24
  );
@@ -9,7 +9,12 @@ import { Text as RNText } from 'react-native';
9
9
  import type { TextProps as RNTextProps } from 'react-native';
10
10
  import { useTokens } from '../theme/context';
11
11
  import type { FontWeight } from './style';
12
- import { createVariantMap, WEIGHT_MAP, createSecondaryStyle, createPrimaryStyle } from './style';
12
+ import {
13
+ createVariantMap,
14
+ WEIGHT_MAP,
15
+ createSecondaryStyle,
16
+ createPrimaryStyle,
17
+ } from './style';
13
18
 
14
19
  export interface TextProps extends RNTextProps {
15
20
  variant?: 'title' | 'heading' | 'body' | 'caption' | 'micro';
@@ -30,7 +30,7 @@ const WaveAnimation: React.FC<WaveAnimationProps> = ({
30
30
  testID,
31
31
  }) => {
32
32
  const animations = useRef(
33
- Array.from({ length: barCount }, () => new Animated.Value(minHeight)),
33
+ Array.from({ length: barCount }, () => new Animated.Value(minHeight))
34
34
  ).current;
35
35
 
36
36
  useEffect(() => {
@@ -52,8 +52,8 @@ const WaveAnimation: React.FC<WaveAnimationProps> = ({
52
52
  duration: 300 + index * 100,
53
53
  useNativeDriver: false,
54
54
  }),
55
- ]),
56
- ),
55
+ ])
56
+ )
57
57
  );
58
58
 
59
59
  loops.forEach((loop) => loop.start());
@@ -64,7 +64,10 @@ const WaveAnimation: React.FC<WaveAnimationProps> = ({
64
64
  }, [active, animations, minHeight, maxHeight]);
65
65
 
66
66
  return (
67
- <View style={[styles.container, { height: maxHeight }, style]} testID={testID}>
67
+ <View
68
+ style={[styles.container, { height: maxHeight }, style]}
69
+ testID={testID}
70
+ >
68
71
  {animations.map((anim, index) => (
69
72
  <Animated.View
70
73
  key={index}
@@ -1,69 +0,0 @@
1
- ---
2
- title: ActionSheet
3
- nav:
4
- title: 组件
5
- order: 1
6
- group:
7
- title: 基础
8
- order: 2
9
- ---
10
-
11
- # ActionSheet 底部操作面板
12
-
13
- 从底部弹出的选项网格面板。
14
-
15
- ## 何时使用
16
-
17
- - 需要展示操作选项时(如拍照、选照片等)
18
- - 底部弹出式面板
19
-
20
- ## 代码演示
21
-
22
- ```tsx
23
- import { ActionSheet, Icon } from '@unif/react-native-ui';
24
-
25
- const options = [
26
- { key: 'camera', label: '拍照', icon: <Icon name="camera-outline" size={28} /> },
27
- { key: 'photo', label: '照片', icon: <Icon name="image-outline" size={28} /> },
28
- ];
29
-
30
- <ActionSheet
31
- visible={visible}
32
- onClose={() => setVisible(false)}
33
- options={options}
34
- onSelect={(key) => console.log(key)}
35
- />
36
- ```
37
-
38
- ## API
39
-
40
- | 属性 | 说明 | 类型 | 默认值 |
41
- | -------- | -------------- | ----------------------------------- | ------ |
42
- | visible | 是否可见 | `boolean` | - |
43
- | onClose | 关闭回调 | `() => void` | - |
44
- | title | 标题 | `string` | - |
45
- | options | 选项列表 | `ActionSheetOption[]` | - |
46
- | onSelect | 选择回调 | `(key: string) => void` | - |
47
- | columns | 每行列数 | `number` | `3` |
48
- | style | 面板样式 | `ViewStyle` | - |
49
- | styles | 语义样式 | `ActionSheetSemanticStyles` | - |
50
- | testID | 测试标识 | `string` | - |
51
-
52
- ## ActionSheetOption
53
-
54
- | 属性 | 说明 | 类型 |
55
- | ----- | ------ | ----------- |
56
- | key | 唯一标识 | `string` |
57
- | label | 显示文本 | `string` |
58
- | icon | 图标 | `ReactNode` |
59
-
60
- ## Semantic Styles
61
-
62
- | Slot | 说明 |
63
- | ----------- | -------------- |
64
- | overlay | 遮罩层 |
65
- | panel | 底部面板 |
66
- | grid | 网格容器 |
67
- | option | 单个选项 |
68
- | optionIcon | 选项图标容器 |
69
- | optionLabel | 选项标签文本 |
@@ -1,51 +0,0 @@
1
- ---
2
- title: Avatar
3
- nav:
4
- title: 组件
5
- order: 1
6
- group:
7
- title: 原子
8
- order: 1
9
- ---
10
-
11
- # Avatar 头像
12
-
13
- 圆形图像/图标容器,支持图片、图标、占位三种模式。
14
-
15
- ## 何时使用
16
-
17
- - 展示用户头像
18
- - 展示 AI 助手图标头像
19
-
20
- ## 代码演示
21
-
22
- ```tsx
23
- import { Avatar, Icon } from '@unif/react-native-ui';
24
-
25
- // 图片头像
26
- <Avatar size={40} source={{ uri: 'https://example.com/avatar.png' }} />
27
-
28
- // 图标头像
29
- <Avatar size={28} icon={<Icon name="sparkles" size={18} color="#EB6E00" />} />
30
-
31
- // 默认占位
32
- <Avatar size={40} />
33
- ```
34
-
35
- ## API
36
-
37
- | 属性 | 说明 | 类型 | 默认值 |
38
- | ------- | ---------------- | ---------------------- | ------ |
39
- | size | 头像尺寸 | `number` | `40` |
40
- | source | 图片来源 | `ImageSourcePropType` | - |
41
- | icon | 替代图片的图标 | `ReactNode` | - |
42
- | style | 容器样式 | `ViewStyle` | - |
43
- | styles | 语义样式 | `AvatarSemanticStyles` | - |
44
- | testID | 测试标识 | `string` | - |
45
-
46
- ## Semantic Styles
47
-
48
- | Slot | 说明 |
49
- | ----- | ---------- |
50
- | root | 外层容器 |
51
- | image | 图片元素 |
@@ -1,90 +0,0 @@
1
- # Button 语义化按钮
2
-
3
- 支持 `type` / `size` 变体和 `styles` 语义插槽覆盖。使用 `Pressable` 实现按下态反馈。
4
-
5
- ## 何时使用
6
-
7
- - 替代 `<TouchableOpacity>` + 手写按钮样式的组合
8
- - 需要统一按钮风格(主按钮、描边按钮、幽灵按钮)时
9
-
10
- ## 代码演示
11
-
12
- ```tsx
13
- // 主按钮
14
- <Button onPress={handleConfirm}>确认下单</Button>
15
-
16
- // 描边按钮
17
- <Button type="outline" onPress={handleModify}>修改</Button>
18
-
19
- // 幽灵按钮
20
- <Button type="ghost" onPress={handlePush}>推送经销商</Button>
21
-
22
- // 并排等宽
23
- <View style={{flexDirection: 'row', gap: 10}}>
24
- <Button type="outline" block onPress={handleModify}>修改</Button>
25
- <Button block onPress={handleConfirm}>确认</Button>
26
- </View>
27
-
28
- // 带图标
29
- <Button icon={<Icon name="add" size={16} color="#FFF" />} onPress={handleAdd}>
30
- 添加
31
- </Button>
32
-
33
- // 语义插槽覆盖
34
- <Button
35
- type="outline"
36
- onPress={handleAction}
37
- styles={{root: {borderColor: 'red'}, content: {color: 'red'}}}>
38
- 危险操作
39
- </Button>
40
- ```
41
-
42
- ## API
43
-
44
- | 属性 | 说明 | 类型 | 默认值 |
45
- |------|------|------|--------|
46
- | type | 按钮类型 | `'primary'` \| `'outline'` \| `'ghost'` \| `'danger'` | `'primary'` |
47
- | size | 按钮大小 | `'default'` \| `'small'` | `'default'` |
48
- | icon | 左侧图标 | `ReactNode` | - |
49
- | disabled | 禁用状态 | `boolean` | `false` |
50
- | block | 撑满父容器(flex: 1) | `boolean` | `false` |
51
- | loading | 加载状态 | `boolean` | `false` |
52
- | onPress | 点击回调 | `() => void` | **必填** |
53
- | style | 外层容器样式 | `ViewStyle` | - |
54
- | styles | 语义插槽样式 | `Partial<ButtonSemanticStyles>` | - |
55
- | testID | 测试标识 | `string` | - |
56
- | children | 按钮内容 | `ReactNode` | **必填** |
57
-
58
- ## Semantic Styles
59
-
60
- 通过 `styles` prop 精确覆盖组件内部各 slot 的样式,不侵入组件结构。
61
-
62
- | 插槽 | 类型 | 说明 |
63
- |------|------|------|
64
- | root | `ViewStyle` | 按钮容器(背景、边框、圆角等) |
65
- | icon | `ViewStyle` | 图标区域(间距等) |
66
- | content | `TextStyle` | 文字区域(字号、颜色、字重等) |
67
-
68
- ## Type 规格
69
-
70
- | type | 背景 | 文字色 | 边框 |
71
- |------|------|--------|------|
72
- | primary | colorPrimary | #FFF | 无 |
73
- | outline | 透明 | colorTextSecondary | colorBorder |
74
- | ghost | 透明 | colorPrimary | colorPrimary |
75
- | danger | colorError | #FFF | 无 |
76
-
77
- ## Size 规格
78
-
79
- | size | paddingVertical | borderRadius | fontSize |
80
- |------|----------------|--------------|----------|
81
- | default | 10 | 8 | 14 |
82
- | small | 6 | 6 | 12 |
83
-
84
- ## 样式合并顺序
85
-
86
- ```
87
- DEFAULT_STYLES → SIZE_STYLES → TYPE_STYLES → DISABLED_STYLES → BLOCK_STYLES → semanticStyles
88
- ```
89
-
90
- 内部使用 `mergeStyles` + `useMemo` 按 slot 维度合并,仅在 props 变化时重算。
@@ -1,28 +0,0 @@
1
- # Center 居中布局
2
-
3
- 内容水平 + 垂直居中。替代 `justifyContent: 'center' + alignItems: 'center'`。
4
-
5
- ## 何时使用
6
-
7
- - 圆形图标按钮、头像容器
8
- - 空状态页面居中
9
- - 任何需要内容完全居中的场景
10
-
11
- ## 代码演示
12
-
13
- ```tsx
14
- // 圆形按钮
15
- <Center style={{width: 32, height: 32, borderRadius: 16, backgroundColor: '#EB6E00'}}>
16
- <Icon name="add" size={18} color="#FFF" />
17
- </Center>
18
-
19
- // 空状态
20
- <Center style={{flex: 1}}>
21
- <Icon name="inbox" size={48} />
22
- <Text secondary>暂无数据</Text>
23
- </Center>
24
- ```
25
-
26
- ## API
27
-
28
- > 继承所有 RN `ViewProps`,无额外属性。
@@ -1,60 +0,0 @@
1
- ---
2
- title: Chip
3
- nav:
4
- title: 组件
5
- order: 1
6
- group:
7
- title: 基础
8
- order: 2
9
- ---
10
-
11
- # Chip 胶囊标签
12
-
13
- 用于展示标签或可选项的胶囊形组件。
14
-
15
- ## 何时使用
16
-
17
- - 展示快捷建议
18
- - 标签选择
19
- - 筛选项
20
-
21
- ## 代码演示
22
-
23
- ```tsx
24
- import { Chip, Icon } from '@unif/react-native-ui';
25
-
26
- // 基本用法
27
- <Chip onPress={() => {}}>标签文本</Chip>
28
-
29
- // 带图标
30
- <Chip icon={<Icon name="search-outline" size={14} />} onPress={() => {}}>
31
- 搜索
32
- </Chip>
33
-
34
- // 选中态
35
- <Chip selected onPress={() => {}}>已选中</Chip>
36
-
37
- // 小尺寸
38
- <Chip size="small">小标签</Chip>
39
- ```
40
-
41
- ## API
42
-
43
- | 属性 | 说明 | 类型 | 默认值 |
44
- | -------- | ------------ | ------------------------- | ----------- |
45
- | children | 内容 | `ReactNode` | - |
46
- | onPress | 点击回调 | `() => void` | - |
47
- | selected | 选中状态 | `boolean` | - |
48
- | disabled | 禁用状态 | `boolean` | - |
49
- | size | 尺寸 | `'default'` \| `'small'` | `'default'` |
50
- | icon | 左侧图标 | `ReactNode` | - |
51
- | style | 容器样式 | `ViewStyle` | - |
52
- | styles | 语义样式 | `ChipSemanticStyles` | - |
53
- | testID | 测试标识 | `string` | - |
54
-
55
- ## Semantic Styles
56
-
57
- | Slot | 说明 |
58
- | ------- | ---------- |
59
- | root | 外层容器 |
60
- | content | 文本样式 |
@@ -1,34 +0,0 @@
1
- # Column 垂直布局
2
-
3
- 垂直排列子元素。语义化替代裸 `<View>`,显式声明布局方向。
4
-
5
- ## 何时使用
6
-
7
- - 需要显式声明垂直布局方向时
8
- - 需要 `gap`、`align`、`justify` 等布局属性时
9
-
10
- ## 代码演示
11
-
12
- ```tsx
13
- // 基础用法
14
- <Column gap={8}>
15
- <Text variant="heading">标题</Text>
16
- <Text variant="caption" secondary>描述文字</Text>
17
- </Column>
18
-
19
- // 居中对齐
20
- <Column align="center" justify="center" style={{flex: 1}}>
21
- <Icon name="empty" />
22
- <Text>暂无数据</Text>
23
- </Column>
24
- ```
25
-
26
- ## API
27
-
28
- | 属性 | 说明 | 类型 | 默认值 |
29
- |------|------|------|--------|
30
- | align | alignItems | `ViewStyle['alignItems']` | - |
31
- | justify | justifyContent | `ViewStyle['justifyContent']` | - |
32
- | gap | 子元素间距 | `number` | - |
33
-
34
- > 继承所有 RN `ViewProps`
@@ -1,44 +0,0 @@
1
- # Divider 分割线
2
-
3
- 用于独立的视觉分隔元素。
4
-
5
- ## 何时使用
6
-
7
- - 替代独立的 `<View style={{height: 1, backgroundColor: border}} />`
8
- - 列表项之间的分隔线(如 `FlatList` 的 `ItemSeparatorComponent`)
9
-
10
- ## 何时不使用
11
-
12
- - **不替换**容器自带的 `borderBottomWidth`(内嵌 border 保留原样)
13
- - 容器 header / footer 的 `borderTopWidth` / `borderBottomWidth` 属于布局边界,改为独立 View 会影响 flex 布局
14
-
15
- | 场景 | 处理 | 原因 |
16
- |------|------|------|
17
- | `<View style={styles.separator} />` | ✅ 用 `<Divider />` | 独立分割元素 |
18
- | `styles.itemRow { borderBottomWidth }` | ❌ 保留原样 | 内嵌于容器 |
19
- | `styles.header { borderBottomWidth }` | ❌ 保留原样 | 布局边界 |
20
-
21
- ## 代码演示
22
-
23
- ```tsx
24
- // 默认 hairline
25
- <Divider />
26
-
27
- // 1px 带水平边距(列表分隔)
28
- <Divider hairline={false} marginHorizontal={12} />
29
-
30
- // 作为 FlatList 分隔
31
- const Separator = () => <Divider hairline={false} marginHorizontal={12} />;
32
- <FlatList ItemSeparatorComponent={Separator} ... />
33
-
34
- // 自定义样式
35
- <Divider style={{backgroundColor: 'red', marginVertical: 8}} />
36
- ```
37
-
38
- ## API
39
-
40
- | 属性 | 说明 | 类型 | 默认值 |
41
- |------|------|------|--------|
42
- | hairline | 使用 `StyleSheet.hairlineWidth` | `boolean` | `true` |
43
- | marginHorizontal | 水平边距 | `number` | - |
44
- | style | 自定义样式 | `ViewStyle` | - |
@@ -1,71 +0,0 @@
1
- # Hooks
2
-
3
- 基础组件库的工具 hooks。
4
-
5
- ## mergeStyles
6
-
7
- 按 slot 维度合并多来源样式的纯函数。借鉴 antd v6 `useMergeSemantic`(`components/_util/hooks/useMergeSemantic.ts:69-80`)。
8
-
9
- ### 何时使用
10
-
11
- - 组件内部合并默认样式 + 变体样式 + 用户传入的 `styles` 语义插槽
12
- - 构建支持 Semantic Styles 的自定义组件时
13
-
14
- ### 代码演示
15
-
16
- ```tsx
17
- import {mergeStyles} from '../hooks';
18
-
19
- type MySemanticStyles = {
20
- root?: ViewStyle;
21
- content?: TextStyle;
22
- };
23
-
24
- const DEFAULT: MySemanticStyles = {
25
- root: {padding: 16},
26
- content: {fontSize: 14, color: tokens.colorText},
27
- };
28
-
29
- const MyComponent = ({styles: userStyles}: {styles?: Partial<MySemanticStyles>}) => {
30
- // ✅ 配合 useMemo,仅 userStyles 变化时重算
31
- const s = useMemo(
32
- () => mergeStyles(DEFAULT, userStyles),
33
- [userStyles],
34
- );
35
-
36
- return (
37
- <View style={s.root}>
38
- <Text style={s.content}>...</Text>
39
- </View>
40
- );
41
- };
42
- ```
43
-
44
- ### API
45
-
46
- ```ts
47
- function mergeStyles<T extends Record<string, StyleValue | undefined>>(
48
- ...sources: (Partial<T> | undefined)[]
49
- ): T
50
- ```
51
-
52
- | 参数 | 说明 | 类型 |
53
- |------|------|------|
54
- | sources | 多个样式源,按顺序合并 | `(Partial<T> \| undefined)[]` |
55
-
56
- ### 合并规则
57
-
58
- - 按 slot key 维度合并(`root`、`content` 等分别合并)
59
- - 同一 slot 内使用对象展开(`{...prev, ...next}`),后传入的覆盖先传入的
60
- - `undefined` 源自动跳过
61
- - 纯函数,不包含 `useMemo`,调用方自行控制缓存
62
-
63
- ### 与 antd v6 对比
64
-
65
- | 特性 | antd v6 `mergeStyles` | RN 版 `mergeStyles` |
66
- |------|----------------------|---------------------|
67
- | classNames 合并 | ✅ | ❌(RN 无 CSS 类名) |
68
- | schema 嵌套 | ✅ | ❌(当前不需要) |
69
- | 函数形式 style | ✅ | ❌(不需要动态计算) |
70
- | slot 展开合并 | ✅ | ✅(核心逻辑一致) |
71
- | 纯函数 | ✅ | ✅ |
@@ -1,73 +0,0 @@
1
- ---
2
- title: Input
3
- nav:
4
- title: 组件
5
- order: 1
6
- group:
7
- title: 基础
8
- order: 2
9
- ---
10
-
11
- # Input 输入框
12
-
13
- TextInput 容器,支持多行输入、底部工具栏和自动聚焦。
14
-
15
- ## 何时使用
16
-
17
- - 需要文本输入时
18
- - 需要带工具栏的输入框时
19
- - 聊天输入场景
20
-
21
- ## 代码演示
22
-
23
- ```tsx
24
- import { Input, Icon } from '@unif/react-native-ui';
25
-
26
- // 基本用法
27
- <Input
28
- value={text}
29
- onChangeText={setText}
30
- placeholder="请输入..."
31
- />
32
-
33
- // 多行 + 工具栏
34
- <Input
35
- multiline
36
- maxHeight={100}
37
- autoFocus
38
- toolbar={
39
- <View style={{ flexDirection: 'row' }}>
40
- <Icon name="mic-outline" size={24} />
41
- </View>
42
- }
43
- />
44
- ```
45
-
46
- ## API
47
-
48
- | 属性 | 说明 | 类型 | 默认值 |
49
- | --------------- | ---------------- | ---------------------- | ------- |
50
- | value | 输入值 | `string` | - |
51
- | onChangeText | 文本变化回调 | `(text: string) => void` | - |
52
- | placeholder | 占位文本 | `string` | - |
53
- | multiline | 多行模式 | `boolean` | `false` |
54
- | maxLength | 最大字符数 | `number` | - |
55
- | maxHeight | 最大高度 | `number` | - |
56
- | autoFocus | 自动聚焦 | `boolean` | - |
57
- | returnKeyType | 回车键类型 | `ReturnKeyTypeOptions` | - |
58
- | onSubmitEditing | 提交回调 | `() => void` | - |
59
- | onBlur | 失焦回调 | `() => void` | - |
60
- | onFocus | 聚焦回调 | `() => void` | - |
61
- | disabled | 禁用状态 | `boolean` | - |
62
- | toolbar | 底部工具栏 | `ReactNode` | - |
63
- | style | 容器样式 | `ViewStyle` | - |
64
- | styles | 语义样式 | `InputSemanticStyles` | - |
65
- | testID | 测试标识 | `string` | - |
66
-
67
- ## Semantic Styles
68
-
69
- | Slot | 说明 |
70
- | ------- | -------------- |
71
- | root | 外层容器 |
72
- | input | TextInput 本身 |
73
- | toolbar | 工具栏容器 |