@unif/react-native-ui 0.2.2 → 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.
- package/lib/commonjs/action-sheet/style/index.js.map +1 -1
- package/lib/commonjs/avatar/index.js.map +1 -1
- package/lib/commonjs/chip/index.js +2 -7
- package/lib/commonjs/chip/index.js.map +1 -1
- package/lib/commonjs/chip/style/index.js +5 -0
- package/lib/commonjs/chip/style/index.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/input/index.js.map +1 -1
- package/lib/commonjs/list-item/index.js.map +1 -1
- package/lib/commonjs/popover/index.js.map +1 -1
- package/lib/commonjs/space/index.js.map +1 -1
- package/lib/commonjs/text/index.js.map +1 -1
- package/lib/commonjs/wave-animation/index.js.map +1 -1
- package/lib/module/action-sheet/style/index.js.map +1 -1
- package/lib/module/avatar/index.js.map +1 -1
- package/lib/module/chip/index.js +2 -7
- package/lib/module/chip/index.js.map +1 -1
- package/lib/module/chip/style/index.js +5 -0
- package/lib/module/chip/style/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/input/index.js.map +1 -1
- package/lib/module/list-item/index.js.map +1 -1
- package/lib/module/popover/index.js.map +1 -1
- package/lib/module/space/index.js.map +1 -1
- package/lib/module/text/index.js.map +1 -1
- package/lib/module/wave-animation/index.js.map +1 -1
- package/lib/typescript/commonjs/docs-src/components/ExpoSnack.d.ts +11 -0
- package/lib/typescript/commonjs/docs-src/components/ExpoSnack.d.ts.map +1 -0
- package/lib/typescript/commonjs/docusaurus.config.d.ts +4 -0
- package/lib/typescript/commonjs/docusaurus.config.d.ts.map +1 -0
- package/lib/typescript/commonjs/sidebars.d.ts +4 -0
- package/lib/typescript/commonjs/sidebars.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/action-sheet/style/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/avatar/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/chip/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/chip/style/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/chip/style/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/input/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/list-item/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/popover/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/space/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/text/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/wave-animation/index.d.ts.map +1 -1
- package/lib/typescript/module/docs-src/components/ExpoSnack.d.ts +11 -0
- package/lib/typescript/module/docs-src/components/ExpoSnack.d.ts.map +1 -0
- package/lib/typescript/module/docusaurus.config.d.ts +4 -0
- package/lib/typescript/module/docusaurus.config.d.ts.map +1 -0
- package/lib/typescript/module/sidebars.d.ts +4 -0
- package/lib/typescript/module/sidebars.d.ts.map +1 -0
- package/lib/typescript/module/src/action-sheet/style/index.d.ts.map +1 -1
- package/lib/typescript/module/src/avatar/index.d.ts.map +1 -1
- package/lib/typescript/module/src/chip/index.d.ts.map +1 -1
- package/lib/typescript/module/src/chip/style/index.d.ts +1 -0
- package/lib/typescript/module/src/chip/style/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/input/index.d.ts.map +1 -1
- package/lib/typescript/module/src/list-item/index.d.ts.map +1 -1
- package/lib/typescript/module/src/popover/index.d.ts.map +1 -1
- package/lib/typescript/module/src/space/index.d.ts.map +1 -1
- package/lib/typescript/module/src/text/index.d.ts.map +1 -1
- package/lib/typescript/module/src/wave-animation/index.d.ts.map +1 -1
- package/package.json +16 -2
- package/src/action-sheet/index.tsx +1 -1
- package/src/action-sheet/style/index.tsx +1 -3
- package/src/avatar/index.tsx +5 -2
- package/src/button/index.tsx +2 -2
- package/src/button/style/index.tsx +1 -1
- package/src/chip/index.tsx +12 -4
- package/src/chip/style/index.tsx +7 -1
- package/src/index.tsx +4 -1
- package/src/input/index.tsx +59 -54
- package/src/list-item/index.tsx +3 -4
- package/src/popover/index.tsx +6 -7
- package/src/space/index.tsx +1 -3
- package/src/text/index.tsx +6 -1
- package/src/wave-animation/index.tsx +7 -4
- package/lib/commonjs/action-sheet/index.md +0 -69
- package/lib/commonjs/avatar/index.md +0 -51
- package/lib/commonjs/button/index.md +0 -90
- package/lib/commonjs/center/index.md +0 -28
- package/lib/commonjs/chip/index.md +0 -60
- package/lib/commonjs/column/index.md +0 -34
- package/lib/commonjs/divider/index.md +0 -44
- package/lib/commonjs/hooks/index.md +0 -71
- package/lib/commonjs/input/index.md +0 -73
- package/lib/commonjs/list-item/index.md +0 -101
- package/lib/commonjs/popover/index.md +0 -57
- package/lib/commonjs/row/index.md +0 -46
- package/lib/commonjs/space/index.md +0 -31
- package/lib/commonjs/text/index.md +0 -63
- package/lib/commonjs/touchable/index.md +0 -42
- package/lib/commonjs/wave-animation/index.md +0 -50
- package/lib/module/action-sheet/index.md +0 -69
- package/lib/module/avatar/index.md +0 -51
- package/lib/module/button/index.md +0 -90
- package/lib/module/center/index.md +0 -28
- package/lib/module/chip/index.md +0 -60
- package/lib/module/column/index.md +0 -34
- package/lib/module/divider/index.md +0 -44
- package/lib/module/hooks/index.md +0 -71
- package/lib/module/input/index.md +0 -73
- package/lib/module/list-item/index.md +0 -101
- package/lib/module/popover/index.md +0 -57
- package/lib/module/row/index.md +0 -46
- package/lib/module/space/index.md +0 -31
- package/lib/module/text/index.md +0 -63
- package/lib/module/touchable/index.md +0 -42
- package/lib/module/wave-animation/index.md +0 -50
- package/src/action-sheet/index.md +0 -69
- package/src/avatar/index.md +0 -51
- package/src/button/index.md +0 -90
- package/src/center/index.md +0 -28
- package/src/chip/index.md +0 -60
- package/src/column/index.md +0 -34
- package/src/divider/index.md +0 -44
- package/src/hooks/index.md +0 -71
- package/src/input/index.md +0 -73
- package/src/list-item/index.md +0 -101
- package/src/popover/index.md +0 -57
- package/src/row/index.md +0 -46
- package/src/space/index.md +0 -31
- package/src/text/index.md +0 -63
- package/src/touchable/index.md +0 -42
- package/src/wave-animation/index.md +0 -50
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Text 语义化文字
|
|
2
|
-
|
|
3
|
-
通过 `variant` 驱动排版样式。继承 RN `Text`,支持嵌套。
|
|
4
|
-
|
|
5
|
-
## 何时使用
|
|
6
|
-
|
|
7
|
-
- 替代直接写 `fontSize` + `fontWeight` + `color` 的 `<Text>` 组合
|
|
8
|
-
- 需要统一排版规范时
|
|
9
|
-
|
|
10
|
-
## 代码演示
|
|
11
|
-
|
|
12
|
-
```tsx
|
|
13
|
-
// 基础用法
|
|
14
|
-
<Text variant="title">标题文字</Text>
|
|
15
|
-
<Text variant="caption" secondary>辅助说明</Text>
|
|
16
|
-
|
|
17
|
-
// 颜色与字重
|
|
18
|
-
<Text variant="caption" primary weight="bold">¥88.00</Text>
|
|
19
|
-
|
|
20
|
-
// 嵌套 Text
|
|
21
|
-
<Text variant="body" numberOfLines={1}>
|
|
22
|
-
<Text primary weight="semibold">新 </Text>
|
|
23
|
-
{productName}
|
|
24
|
-
</Text>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## API
|
|
28
|
-
|
|
29
|
-
| 属性 | 说明 | 类型 | 默认值 |
|
|
30
|
-
|------|------|------|--------|
|
|
31
|
-
| variant | 排版变体 | `'title'` \| `'heading'` \| `'body'` \| `'caption'` \| `'micro'` | `'body'` |
|
|
32
|
-
| secondary | 次要色(colorTextSecondary) | `boolean` | `false` |
|
|
33
|
-
| primary | 主题色(colorPrimary) | `boolean` | `false` |
|
|
34
|
-
| color | 自定义颜色 | `string` | - |
|
|
35
|
-
| weight | 字重 | `'medium'` \| `'semibold'` \| `'bold'` | - |
|
|
36
|
-
|
|
37
|
-
> 继承所有 RN `TextProps`(`numberOfLines`、`ellipsizeMode`、`onPress`、`style` 等)
|
|
38
|
-
|
|
39
|
-
## Variant 规格
|
|
40
|
-
|
|
41
|
-
| variant | fontSize | lineHeight | fontWeight | 场景 |
|
|
42
|
-
|---------|----------|------------|------------|------|
|
|
43
|
-
| title | 20 | 26 | 600 | 页面标题、问候语 |
|
|
44
|
-
| heading | 16 | 22 | 600 | 弹窗标题、区块标题 |
|
|
45
|
-
| body | 15 | 22 | 正常 | 默认正文 |
|
|
46
|
-
| caption | 13 | 18 | 正常 | 信息行、标签 |
|
|
47
|
-
| micro | 12 | 18 | 正常 | 地址、规格、描述 |
|
|
48
|
-
|
|
49
|
-
## Weight 映射
|
|
50
|
-
|
|
51
|
-
| weight | fontWeight | 场景 |
|
|
52
|
-
|--------|----------|------|
|
|
53
|
-
| medium | 500 | 产品名、模型名 |
|
|
54
|
-
| semibold | 600 | 标题、按钮文字、客户名 |
|
|
55
|
-
| bold | 700 | 价格金额 |
|
|
56
|
-
|
|
57
|
-
## 样式优先级
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
VARIANT_MAP → secondary/primary → color → weight → style
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
后传入的属性覆盖先传入的,`style` prop 拥有最高优先级。
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# Touchable 统一触摸反馈
|
|
2
|
-
|
|
3
|
-
基于 `Pressable`,统一替代 `TouchableOpacity`。按下时降低透明度,支持自定义 `activeOpacity`。
|
|
4
|
-
|
|
5
|
-
## 何时使用
|
|
6
|
-
|
|
7
|
-
- 替代所有 `TouchableOpacity` 的场景
|
|
8
|
-
- 需要可点击区域(非按钮语义)时
|
|
9
|
-
|
|
10
|
-
## 代码演示
|
|
11
|
-
|
|
12
|
-
```tsx
|
|
13
|
-
// 基础用法
|
|
14
|
-
<Touchable onPress={handlePress}>
|
|
15
|
-
<Row gap={10}>
|
|
16
|
-
<Icon name="settings" />
|
|
17
|
-
<Text>设置</Text>
|
|
18
|
-
</Row>
|
|
19
|
-
</Touchable>
|
|
20
|
-
|
|
21
|
-
// 自定义按下透明度
|
|
22
|
-
<Touchable onPress={handlePress} activeOpacity={0.5}>
|
|
23
|
-
<Text>更明显的按下效果</Text>
|
|
24
|
-
</Touchable>
|
|
25
|
-
|
|
26
|
-
// 长按
|
|
27
|
-
<Touchable onPress={handlePress} onLongPress={handleLongPress}>
|
|
28
|
-
<Text>支持长按</Text>
|
|
29
|
-
</Touchable>
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## API
|
|
33
|
-
|
|
34
|
-
| 属性 | 说明 | 类型 | 默认值 |
|
|
35
|
-
|------|------|------|--------|
|
|
36
|
-
| onPress | 点击回调 | `() => void` | - |
|
|
37
|
-
| onLongPress | 长按回调 | `() => void` | - |
|
|
38
|
-
| disabled | 禁用状态 | `boolean` | `false` |
|
|
39
|
-
| activeOpacity | 按下态透明度 | `number` | `0.7` |
|
|
40
|
-
| testID | 测试标识 | `string` | - |
|
|
41
|
-
|
|
42
|
-
> 继承所有 RN `ViewProps`
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: WaveAnimation
|
|
3
|
-
nav:
|
|
4
|
-
title: 组件
|
|
5
|
-
order: 1
|
|
6
|
-
group:
|
|
7
|
-
title: 原子
|
|
8
|
-
order: 1
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# WaveAnimation 声波动画
|
|
12
|
-
|
|
13
|
-
柱状声波动画,适用于语音录制等场景的视觉反馈。
|
|
14
|
-
|
|
15
|
-
## 何时使用
|
|
16
|
-
|
|
17
|
-
- 语音录制时展示声波效果
|
|
18
|
-
- 需要节奏性动画反馈时
|
|
19
|
-
|
|
20
|
-
## 代码演示
|
|
21
|
-
|
|
22
|
-
```tsx
|
|
23
|
-
import { WaveAnimation } from '@unif/react-native-ui';
|
|
24
|
-
|
|
25
|
-
// 基本用法
|
|
26
|
-
<WaveAnimation active={isRecording} />
|
|
27
|
-
|
|
28
|
-
// 自定义参数
|
|
29
|
-
<WaveAnimation
|
|
30
|
-
active={true}
|
|
31
|
-
color="#EB6E00"
|
|
32
|
-
barCount={5}
|
|
33
|
-
barWidth={4}
|
|
34
|
-
minHeight={4}
|
|
35
|
-
maxHeight={24}
|
|
36
|
-
/>
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## API
|
|
40
|
-
|
|
41
|
-
| 属性 | 说明 | 类型 | 默认值 |
|
|
42
|
-
| --------- | ------------ | ---------- | ----------- |
|
|
43
|
-
| active | 控制动画启停 | `boolean` | - |
|
|
44
|
-
| color | 柱体颜色 | `string` | `'#FFFFFF'` |
|
|
45
|
-
| barCount | 柱数 | `number` | `4` |
|
|
46
|
-
| barWidth | 柱宽 | `number` | `3` |
|
|
47
|
-
| minHeight | 最小高度 | `number` | `6` |
|
|
48
|
-
| maxHeight | 最大高度 | `number` | `20` |
|
|
49
|
-
| style | 容器样式 | `ViewStyle`| - |
|
|
50
|
-
| testID | 测试标识 | `string` | - |
|
|
@@ -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`,无额外属性。
|
package/lib/module/chip/index.md
DELETED
|
@@ -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 | 工具栏容器 |
|