@beppla/tapas-ui 1.5.2 → 1.5.6
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/commonjs/Alert/README.md +75 -0
- package/commonjs/BarChart/README.md +172 -0
- package/commonjs/Button/README.md +108 -0
- package/commonjs/Calendar/Calendar.base.js +1 -1
- package/commonjs/Calendar/Calendar.base.js.map +1 -1
- package/commonjs/Calendar/README.md +410 -0
- package/commonjs/Card/README.md +126 -0
- package/commonjs/CheckBox/README.md +147 -0
- package/commonjs/CircularProgress/README.md +70 -0
- package/commonjs/Collapsible/README.md +140 -0
- package/commonjs/ComboChart/README.md +124 -0
- package/commonjs/DashboardCard/README.md +120 -0
- package/commonjs/DataTable/README.md +159 -0
- package/commonjs/DeviceSelectionModal/README.md +124 -0
- package/commonjs/DraggableFlatList/README.md +35 -0
- package/commonjs/Drawer/README.md +175 -0
- package/commonjs/Dropdown/README.md +230 -0
- package/commonjs/ExternalLink/README.md +81 -0
- package/commonjs/Gantt/README.md +155 -0
- package/commonjs/Grid/README.md +197 -0
- package/commonjs/Header/README.md +109 -0
- package/commonjs/HelloWave/README.md +28 -0
- package/commonjs/Hoverable/Hoverable.js.map +1 -1
- package/commonjs/IconText/README.md +99 -0
- package/commonjs/Image/PreviewImg/README.md +100 -0
- package/commonjs/Image/README.md +88 -0
- package/commonjs/Input/Input.js +60 -4
- package/commonjs/Input/Input.js.map +1 -1
- package/commonjs/Layout/README.md +174 -0
- package/commonjs/LineChart/README.md +181 -0
- package/commonjs/ListItem/README.md +122 -0
- package/commonjs/MessageBox/MessageBox.js +7 -1
- package/commonjs/MessageBox/MessageBox.js.map +1 -1
- package/commonjs/MessageBox/README.md +120 -0
- package/commonjs/Navigation/README.md +197 -0
- package/commonjs/NumericInput/README.md +95 -0
- package/commonjs/Overlay/README.md +84 -0
- package/commonjs/Pagination/README.md +106 -0
- package/commonjs/PieChart/README.md +212 -0
- package/commonjs/Popover/README.md +82 -0
- package/commonjs/Progress/README.md +106 -0
- package/commonjs/RadioButton/README.md +85 -0
- package/commonjs/ScanButton/README.md +72 -0
- package/commonjs/SearchInput/SearchInput.js.map +1 -1
- package/commonjs/SheetTitle/README.md +89 -0
- package/commonjs/Shell/README.md +152 -0
- package/commonjs/Shell/Shell.js.map +1 -1
- package/commonjs/StatisticCard/README.md +129 -0
- package/commonjs/Status/README.md +75 -0
- package/commonjs/Steps/README.md +76 -0
- package/commonjs/Switch/Switch.js +101 -0
- package/commonjs/Switch/Switch.js.map +1 -0
- package/commonjs/Tab/README.md +161 -0
- package/commonjs/Tag/README.md +93 -0
- package/commonjs/Task/README.md +110 -0
- package/commonjs/Text/README.md +97 -0
- package/commonjs/TextArea/README.md +127 -0
- package/commonjs/TextArea/TextArea.js +4 -2
- package/commonjs/TextArea/TextArea.js.map +1 -1
- package/commonjs/Theme/README.md +161 -0
- package/commonjs/Theme/makeStyles.js +30 -0
- package/commonjs/Theme/makeStyles.js.map +1 -0
- package/commonjs/Theme/withTheme.js +91 -0
- package/commonjs/Theme/withTheme.js.map +1 -0
- package/commonjs/Timeline/README.md +111 -0
- package/commonjs/Toast/README.md +96 -0
- package/commonjs/Upload/Upload.js +126 -0
- package/commonjs/Upload/Upload.js.map +1 -0
- package/commonjs/index.js +24 -4
- package/commonjs/index.js.map +1 -1
- package/module/Alert/README.md +75 -0
- package/module/BarChart/README.md +172 -0
- package/module/Button/README.md +108 -0
- package/module/Calendar/Calendar.base.js +1 -1
- package/module/Calendar/Calendar.base.js.map +1 -1
- package/module/Calendar/README.md +410 -0
- package/module/Card/README.md +126 -0
- package/module/CheckBox/README.md +147 -0
- package/module/CircularProgress/README.md +70 -0
- package/module/Collapsible/README.md +140 -0
- package/module/ComboChart/README.md +124 -0
- package/module/DashboardCard/README.md +120 -0
- package/module/DataTable/README.md +159 -0
- package/module/DeviceSelectionModal/README.md +124 -0
- package/module/DraggableFlatList/README.md +35 -0
- package/module/Drawer/README.md +175 -0
- package/module/Dropdown/README.md +230 -0
- package/module/ExternalLink/README.md +81 -0
- package/module/Gantt/README.md +155 -0
- package/module/Grid/README.md +197 -0
- package/module/Header/README.md +109 -0
- package/module/HelloWave/README.md +28 -0
- package/module/Hoverable/Hoverable.js.map +1 -1
- package/module/IconText/README.md +99 -0
- package/module/Image/PreviewImg/README.md +100 -0
- package/module/Image/README.md +88 -0
- package/module/Input/Input.js +60 -4
- package/module/Input/Input.js.map +1 -1
- package/module/Layout/README.md +174 -0
- package/module/LineChart/README.md +181 -0
- package/module/ListItem/README.md +122 -0
- package/module/MessageBox/MessageBox.js +8 -2
- package/module/MessageBox/MessageBox.js.map +1 -1
- package/module/MessageBox/README.md +120 -0
- package/module/Navigation/README.md +197 -0
- package/module/NumericInput/README.md +95 -0
- package/module/Overlay/README.md +84 -0
- package/module/Pagination/README.md +106 -0
- package/module/PieChart/README.md +212 -0
- package/module/Popover/README.md +82 -0
- package/module/Progress/README.md +106 -0
- package/module/RadioButton/README.md +85 -0
- package/module/ScanButton/README.md +72 -0
- package/module/SearchInput/SearchInput.js.map +1 -1
- package/module/SheetTitle/README.md +89 -0
- package/module/Shell/README.md +152 -0
- package/module/Shell/Shell.js.map +1 -1
- package/module/StatisticCard/README.md +129 -0
- package/module/Status/README.md +75 -0
- package/module/Steps/README.md +76 -0
- package/module/Switch/Switch.js +96 -0
- package/module/Switch/Switch.js.map +1 -0
- package/module/Tab/README.md +161 -0
- package/module/Tag/README.md +93 -0
- package/module/Task/README.md +110 -0
- package/module/Text/README.md +97 -0
- package/module/TextArea/README.md +127 -0
- package/module/TextArea/TextArea.js +4 -2
- package/module/TextArea/TextArea.js.map +1 -1
- package/module/Theme/README.md +161 -0
- package/module/Theme/makeStyles.js +24 -0
- package/module/Theme/makeStyles.js.map +1 -0
- package/module/Theme/withTheme.js +82 -0
- package/module/Theme/withTheme.js.map +1 -0
- package/module/Timeline/README.md +111 -0
- package/module/Toast/README.md +96 -0
- package/module/Upload/Upload.js +121 -0
- package/module/Upload/Upload.js.map +1 -0
- package/module/index.js +11 -3
- package/module/index.js.map +1 -1
- package/package.json +1 -1
- package/typescript/Grid/FixedSizeGrid.d.ts +1 -3
- package/typescript/Grid/FixedSizeGrid.d.ts.map +1 -1
- package/typescript/Grid/Grid.base.d.ts +1 -3
- package/typescript/Grid/Grid.base.d.ts.map +1 -1
- package/typescript/Grid/VariableSizeGrid.d.ts +1 -3
- package/typescript/Grid/VariableSizeGrid.d.ts.map +1 -1
- package/typescript/Input/Input.d.ts +5 -0
- package/typescript/Input/Input.d.ts.map +1 -1
- package/typescript/MessageBox/MessageBox.d.ts.map +1 -1
- package/typescript/SearchInput/SearchInput.d.ts +4 -0
- package/typescript/SearchInput/SearchInput.d.ts.map +1 -1
- package/typescript/Switch/Switch.d.ts +15 -0
- package/typescript/Switch/Switch.d.ts.map +1 -0
- package/typescript/TextArea/TextArea.d.ts +2 -0
- package/typescript/TextArea/TextArea.d.ts.map +1 -1
- package/typescript/Theme/makeStyles.d.ts +11 -0
- package/typescript/Theme/makeStyles.d.ts.map +1 -0
- package/typescript/Theme/withTheme.d.ts +12 -0
- package/typescript/Theme/withTheme.d.ts.map +1 -0
- package/typescript/Upload/Upload.d.ts +25 -0
- package/typescript/Upload/Upload.d.ts.map +1 -0
- package/typescript/WebViewBridge/useWebViewBridge.d.ts +1 -1
- package/typescript/WebViewBridge/useWebViewBridge.d.ts.map +1 -1
- package/typescript/common/hooks/useBridgelessFix.d.ts +1 -1
- package/typescript/index.d.ts +7 -1
- package/typescript/index.d.ts.map +1 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# DeviceSelectionModal
|
|
2
|
+
|
|
3
|
+
设备选择模态对话框组件,用于从设备列表中选择一个设备。支持加载状态、错误处理、重试机制和文本国际化,适合打印机选择、终端绑定等硬件设备关联场景。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 单选设备列表(Radio Button 样式)
|
|
8
|
+
- ✅ 加载中状态展示(ActivityIndicator)
|
|
9
|
+
- ✅ 错误状态展示 + 重试按钮
|
|
10
|
+
- ✅ 空列表提示
|
|
11
|
+
- ✅ 设备描述信息展示
|
|
12
|
+
- ✅ 未选择时确认按钮自动禁用
|
|
13
|
+
- ✅ 关闭时恢复原始选中状态
|
|
14
|
+
- ✅ 全部文本支持国际化(i18n props)
|
|
15
|
+
- ✅ 淡入淡出动画
|
|
16
|
+
- ✅ 主题色适配
|
|
17
|
+
|
|
18
|
+
## 安装使用
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { DeviceSelectionModal } from '@beppla/tapas-ui';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Props
|
|
25
|
+
|
|
26
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
27
|
+
|------|------|--------|------|
|
|
28
|
+
| visible | `boolean` | - | 是否显示(必填) |
|
|
29
|
+
| devices | `Device[]` | - | 设备列表(必填) |
|
|
30
|
+
| selectedDeviceId | `string` | - | 当前选中的设备 ID |
|
|
31
|
+
| onClose | `() => void` | - | 关闭回调(必填) |
|
|
32
|
+
| onConfirm | `(deviceId: string) => void` | - | 确认选择回调(必填) |
|
|
33
|
+
| title | `string` | - | 对话框标题 |
|
|
34
|
+
| isLoading | `boolean` | `false` | 是否加载中 |
|
|
35
|
+
| error | `string \| null` | `null` | 错误信息 |
|
|
36
|
+
| onRetry | `() => void` | - | 重试按钮回调 |
|
|
37
|
+
| selectDeviceText | `string` | `'Select Device'` | 标题文本 |
|
|
38
|
+
| pleaseSelectDeviceText | `string` | `'Please select a device'` | 副标题文本 |
|
|
39
|
+
| loadingDevicesText | `string` | `'Loading devices...'` | 加载中文本 |
|
|
40
|
+
| noDevicesAvailableText | `string` | `'No devices available'` | 空列表文本 |
|
|
41
|
+
| closeText | `string` | `'Close'` | 关闭按钮文本 |
|
|
42
|
+
| confirmText | `string` | `'Confirm'` | 确认按钮文本 |
|
|
43
|
+
| retryText | `string` | `'Retry'` | 重试按钮文本 |
|
|
44
|
+
| testID | `string` | - | 测试标识 |
|
|
45
|
+
|
|
46
|
+
### Device 接口
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
interface Device {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 使用示例
|
|
57
|
+
|
|
58
|
+
### 基础用法
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
const [visible, setVisible] = useState(false);
|
|
62
|
+
const devices = [
|
|
63
|
+
{ id: '1', name: 'Printer A', description: 'Kitchen printer' },
|
|
64
|
+
{ id: '2', name: 'Printer B', description: 'Receipt printer' },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
<DeviceSelectionModal
|
|
68
|
+
visible={visible}
|
|
69
|
+
devices={devices}
|
|
70
|
+
onClose={() => setVisible(false)}
|
|
71
|
+
onConfirm={(deviceId) => {
|
|
72
|
+
console.log('Selected:', deviceId);
|
|
73
|
+
setVisible(false);
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 加载状态
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<DeviceSelectionModal
|
|
82
|
+
visible={true}
|
|
83
|
+
devices={[]}
|
|
84
|
+
isLoading={true}
|
|
85
|
+
onClose={() => setVisible(false)}
|
|
86
|
+
onConfirm={() => {}}
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 错误状态 + 重试
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
<DeviceSelectionModal
|
|
94
|
+
visible={true}
|
|
95
|
+
devices={[]}
|
|
96
|
+
error="Failed to load devices"
|
|
97
|
+
onRetry={() => fetchDevices()}
|
|
98
|
+
onClose={() => setVisible(false)}
|
|
99
|
+
onConfirm={() => {}}
|
|
100
|
+
/>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 国际化
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<DeviceSelectionModal
|
|
107
|
+
visible={true}
|
|
108
|
+
devices={devices}
|
|
109
|
+
selectDeviceText="Select Printer"
|
|
110
|
+
pleaseSelectDeviceText="Choose a printer for this station"
|
|
111
|
+
confirmText="Bind"
|
|
112
|
+
closeText="Cancel"
|
|
113
|
+
onClose={() => setVisible(false)}
|
|
114
|
+
onConfirm={handleConfirm}
|
|
115
|
+
/>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## 注意事项
|
|
119
|
+
|
|
120
|
+
- 关闭对话框时会将内部选中状态恢复为 `selectedDeviceId`(即取消未确认的选择)
|
|
121
|
+
- 未选中设备时确认按钮禁用(灰色样式)
|
|
122
|
+
- 对话框最大宽度 400px,设备列表最大高度 300px
|
|
123
|
+
- `title` 和 `selectDeviceText` 同时存在时,`title` 优先
|
|
124
|
+
- 需在 `ThemeProvider` 内使用
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# DraggableFlatList
|
|
2
|
+
|
|
3
|
+
可拖拽列表组件占位符。当前为空实现,预留用于后续开发支持拖拽排序的列表功能。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 组件骨架已搭建,导出可用
|
|
8
|
+
- (待开发) 拖拽排序
|
|
9
|
+
- (待开发) 拖拽动画
|
|
10
|
+
- (待开发) 自定义渲染
|
|
11
|
+
|
|
12
|
+
## 安装使用
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { DraggableFlatList } from '@beppla/tapas-ui';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Props
|
|
19
|
+
|
|
20
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
21
|
+
|------|------|--------|------|
|
|
22
|
+
| testID | `string` | - | 测试标识 |
|
|
23
|
+
|
|
24
|
+
## 使用示例
|
|
25
|
+
|
|
26
|
+
### 基础用法
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
<DraggableFlatList testID="draggable-list" />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 注意事项
|
|
33
|
+
|
|
34
|
+
- 当前为空 View 占位实现,无实际拖拽功能
|
|
35
|
+
- 后续计划集成 `react-native-draggable-flatlist` 或自定义实现
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Drawer
|
|
2
|
+
|
|
3
|
+
抽屉面板组件,从屏幕右侧滑出的浮层面板,支持自定义头部、内容区域和页脚,常用于筛选、详情展示等场景。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 从右侧滑出的 Overlay 抽屉面板
|
|
8
|
+
- 响应式宽度(桌面端 55%,移动端 100%)
|
|
9
|
+
- 可自定义标题、标题图标和状态标签(Status 组件)
|
|
10
|
+
- 支持 showHeader / showFooter 控制头部和页脚显示
|
|
11
|
+
- 支持自定义 headerComponent 和 footerComponent 完全替换
|
|
12
|
+
- 点击背景遮罩自动关闭(onBackdropPress)
|
|
13
|
+
- 内容区域自动 ScrollView 滚动
|
|
14
|
+
- 移动端自动适配 Safe Area(useSafeAreaInsets)
|
|
15
|
+
- 页脚包含左侧文本按钮和右侧主按钮
|
|
16
|
+
|
|
17
|
+
## 安装使用
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { Drawer } from '@beppla/tapas-ui';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
26
|
+
|------|------|--------|------|
|
|
27
|
+
| visible | `boolean` | `false` | 抽屉是否可见 |
|
|
28
|
+
| title | `string` | - | 抽屉标题 |
|
|
29
|
+
| titleIcon | `string` | - | 标题左侧图标名称 |
|
|
30
|
+
| titleIconOnPress | `() => void` | - | 标题图标点击回调 |
|
|
31
|
+
| titleStatus | `string` | - | 状态标签文本 |
|
|
32
|
+
| statusType | `STATUS_TYPE` | `'unavailable'` | 状态类型(success/warning/unavailable 等) |
|
|
33
|
+
| showHeader | `boolean` | `true` | 是否显示头部 |
|
|
34
|
+
| showFooter | `boolean` | `false` | 是否显示页脚 |
|
|
35
|
+
| onClose | `() => void` | - | 关闭回调(背景遮罩点击时触发) |
|
|
36
|
+
| onClear | `() => void` | - | 清空按钮回调(未设时回退到 onClose) |
|
|
37
|
+
| clearText | `string` | - | 清空按钮文本 |
|
|
38
|
+
| clearDisable | `boolean` | `true` | 清空按钮是否禁用 |
|
|
39
|
+
| overlayStyle | `StyleProp<ViewStyle>` | - | 抽屉覆盖层自定义样式 |
|
|
40
|
+
| middleSectionStyle | `StyleProp<ViewStyle>` | - | 内容区域自定义样式 |
|
|
41
|
+
| leftButtonText | `string` | - | 页脚左侧按钮文本 |
|
|
42
|
+
| leftButtonTextStyle | `StyleProp<ViewStyle>` | - | 页脚左侧按钮文本样式 |
|
|
43
|
+
| leftButtonOnPress | `() => void` | - | 页脚左侧按钮回调 |
|
|
44
|
+
| rightButtonText | `string` | - | 页脚右侧按钮文本 |
|
|
45
|
+
| rightButtonStyle | `StyleProp<ViewStyle>` | - | 页脚右侧按钮样式 |
|
|
46
|
+
| rightButtonOnPress | `() => void` | - | 页脚右侧按钮回调 |
|
|
47
|
+
| component | `React.ReactNode` | - | 内容组件(渲染在 children 之前) |
|
|
48
|
+
| children | `React.ReactNode` | - | 内容子组件 |
|
|
49
|
+
| headerComponent | `React.ReactNode` | - | 自定义头部组件(替换默认头部) |
|
|
50
|
+
| footerComponent | `React.ReactNode` | - | 自定义页脚组件(额外渲染在 showFooter 之后) |
|
|
51
|
+
| testID | `string` | - | 测试 ID |
|
|
52
|
+
|
|
53
|
+
## 使用示例
|
|
54
|
+
|
|
55
|
+
### 基础用法
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { Drawer } from '@beppla/tapas-ui';
|
|
59
|
+
import { useState } from 'react';
|
|
60
|
+
import { Text, Button } from 'react-native';
|
|
61
|
+
|
|
62
|
+
export default function App() {
|
|
63
|
+
const [visible, setVisible] = useState(false);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<Button title="Open Drawer" onPress={() => setVisible(true)} />
|
|
68
|
+
<Drawer
|
|
69
|
+
visible={visible}
|
|
70
|
+
title="Filters"
|
|
71
|
+
onClose={() => setVisible(false)}
|
|
72
|
+
>
|
|
73
|
+
<Text>Drawer content here</Text>
|
|
74
|
+
</Drawer>
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 带状态标签和图标
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<Drawer
|
|
84
|
+
visible={visible}
|
|
85
|
+
title="Order Details"
|
|
86
|
+
titleIcon="back"
|
|
87
|
+
titleIconOnPress={() => setVisible(false)}
|
|
88
|
+
titleStatus="Active"
|
|
89
|
+
statusType="success"
|
|
90
|
+
onClose={() => setVisible(false)}
|
|
91
|
+
>
|
|
92
|
+
<Text>Order information</Text>
|
|
93
|
+
</Drawer>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 完整功能(头部 + 内容 + 页脚)
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
<Drawer
|
|
100
|
+
visible={visible}
|
|
101
|
+
title="Filters"
|
|
102
|
+
titleIcon="back"
|
|
103
|
+
titleIconOnPress={() => setVisible(false)}
|
|
104
|
+
clearText="Clear"
|
|
105
|
+
clearDisable={false}
|
|
106
|
+
onClear={() => resetFilters()}
|
|
107
|
+
onClose={() => setVisible(false)}
|
|
108
|
+
showFooter={true}
|
|
109
|
+
leftButtonText="Close"
|
|
110
|
+
leftButtonOnPress={() => setVisible(false)}
|
|
111
|
+
rightButtonText="Show all results"
|
|
112
|
+
rightButtonOnPress={() => applyFilters()}
|
|
113
|
+
>
|
|
114
|
+
<Text>Filter options here</Text>
|
|
115
|
+
</Drawer>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 自定义头部和页脚
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
<Drawer
|
|
122
|
+
visible={visible}
|
|
123
|
+
headerComponent={
|
|
124
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 16 }}>
|
|
125
|
+
<Text style={{ fontSize: 18, fontWeight: 'bold' }}>Custom Header</Text>
|
|
126
|
+
<Button title="X" onPress={() => setVisible(false)} />
|
|
127
|
+
</View>
|
|
128
|
+
}
|
|
129
|
+
footerComponent={
|
|
130
|
+
<View style={{ flexDirection: 'row', justifyContent: 'flex-end', gap: 8 }}>
|
|
131
|
+
<Button title="Cancel" onPress={() => setVisible(false)} />
|
|
132
|
+
<Button title="Save" onPress={() => handleSave()} />
|
|
133
|
+
</View>
|
|
134
|
+
}
|
|
135
|
+
onClose={() => setVisible(false)}
|
|
136
|
+
>
|
|
137
|
+
<Text>Content with custom header and footer</Text>
|
|
138
|
+
</Drawer>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 通过 DrawerContext 使用
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { useContext } from 'react';
|
|
145
|
+
import { DrawerContext } from '@beppla/tapas-ui/components/Layout/DrawerContext';
|
|
146
|
+
|
|
147
|
+
function MyComponent() {
|
|
148
|
+
const { open, close } = useContext(DrawerContext);
|
|
149
|
+
|
|
150
|
+
const showDrawer = () => {
|
|
151
|
+
open({
|
|
152
|
+
title: 'Dynamic Drawer',
|
|
153
|
+
component: <Text>Dynamic content</Text>,
|
|
154
|
+
showFooter: true,
|
|
155
|
+
rightButtonText: 'Confirm',
|
|
156
|
+
rightButtonOnPress: () => {
|
|
157
|
+
handleConfirm();
|
|
158
|
+
close();
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return <Button title="Open" onPress={showDrawer} />;
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 注意事项
|
|
168
|
+
|
|
169
|
+
- 桌面端抽屉宽度为屏幕的 55%,移动端为 100%
|
|
170
|
+
- `clearDisable` 默认为 `true`(禁用状态),需显式设为 `false` 才能启用清空按钮
|
|
171
|
+
- `onClear` 未设置时,清空按钮会回退使用 `onClose` 回调
|
|
172
|
+
- `showFooter` 默认为 `false`,需显式设为 `true` 以显示页脚按钮区域
|
|
173
|
+
- `footerComponent` 独立于 `showFooter`,即使 `showFooter=false`,`footerComponent` 仍会渲染
|
|
174
|
+
- 内容区域使用 ScrollView 包裹,`contentContainerStyle` 设置了 `flexGrow: 1`
|
|
175
|
+
- 移动端会通过 `useSafeAreaInsets` 自动添加顶部安全区域间距
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Dropdown / CustomDropdown / InputDropdown
|
|
2
|
+
|
|
3
|
+
下拉选择组件系列。Dropdown 是主组件,支持普通下拉和 Modal 弹出两种模式;CustomDropdown 是底层下拉容器;InputDropdown 是带搜索输入框的下拉组件。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 两种模式:CustomDropdown 弹出模式和 Modal 弹出模式
|
|
8
|
+
- ✅ 支持搜索过滤选项
|
|
9
|
+
- ✅ 响应式定位,自动检测上下空间选择弹出方向
|
|
10
|
+
- ✅ 移动端自动切换为 BottomSheet 样式
|
|
11
|
+
- ✅ 支持自定义按钮(customButton)
|
|
12
|
+
- ✅ 支持自定义弹出内容(customPopoverContent)
|
|
13
|
+
- ✅ 浮动标签动画(Modal 模式)
|
|
14
|
+
- ✅ 错误状态和状态消息显示
|
|
15
|
+
- ✅ 支持必填标识
|
|
16
|
+
- ✅ InputDropdown 支持输入搜索、清空、只读模式
|
|
17
|
+
- ✅ 支持扩展按钮(extendBtn)
|
|
18
|
+
- ✅ 多种定位方式:left、center、right、upLeft、upRight、upCenter、auto
|
|
19
|
+
|
|
20
|
+
## 安装使用
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import Dropdown from '@beppla/tapas-ui/components/Dropdown/Dropdown';
|
|
24
|
+
import CustomDropdown from '@beppla/tapas-ui/components/Dropdown/CustomDropdown';
|
|
25
|
+
import InputDropdown from '@beppla/tapas-ui/components/Dropdown/InputDropdown';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Props
|
|
29
|
+
|
|
30
|
+
### Dropdown Props(核心属性)
|
|
31
|
+
|
|
32
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
33
|
+
|------|------|--------|------|
|
|
34
|
+
| options | `ItemProps[]` | - | 选项列表 |
|
|
35
|
+
| value | `ItemProps` | - | 当前选中值 |
|
|
36
|
+
| onChange | `(value: ItemProps) => void` | - | 选中变化回调 |
|
|
37
|
+
| prefix | `string` | `''` | 显示值前缀 |
|
|
38
|
+
| width | `number` | - | 按钮宽度 |
|
|
39
|
+
| subWidth | `number` | - | 弹出框宽度 |
|
|
40
|
+
| subHeight | `number` | `150` | 弹出框高度 |
|
|
41
|
+
| type | `'button' \| 'option'` | `'option'` | 类型,button 模式不更新选中值 |
|
|
42
|
+
| onClose | `() => void` | - | 关闭回调 |
|
|
43
|
+
| onPress | `() => void` | - | 按钮点击回调 |
|
|
44
|
+
| onItemPress | `(value: string \| number) => void` | - | button 类型下的选项点击回调 |
|
|
45
|
+
| disabled | `boolean` | - | 是否禁用 |
|
|
46
|
+
| showSearchBar | `boolean` | - | 是否显示搜索栏 |
|
|
47
|
+
| placeholder | `string` | - | 搜索栏占位文字 |
|
|
48
|
+
| onSearchChange | `(value: string) => void` | - | 搜索内容变化回调 |
|
|
49
|
+
| testID | `string` | - | 测试标识 |
|
|
50
|
+
|
|
51
|
+
### Dropdown Modal 模式属性
|
|
52
|
+
|
|
53
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
54
|
+
|------|------|--------|------|
|
|
55
|
+
| useModal | `boolean` | `false` | 是否使用 Modal 弹出模式 |
|
|
56
|
+
| dropdownItems | `TapasDropDownItem[]` | `[]` | Modal 模式下的选项列表 |
|
|
57
|
+
| selected | `string` | - | 选中项的 key |
|
|
58
|
+
| showSelectedValue | `boolean` | `false` | 是否显示选中值文字 |
|
|
59
|
+
| dropdownType | `'clear' \| 'solid'` | `'clear'` | 下拉按钮类型 |
|
|
60
|
+
| arrowIcon | `boolean` | `false` | 是否显示箭头图标 |
|
|
61
|
+
| onSelect | `(item: TapasDropDownItem) => void` | - | Modal 模式选择回调 |
|
|
62
|
+
| label | `string` | - | 标签文字 |
|
|
63
|
+
| required | `boolean` | - | 是否必填 |
|
|
64
|
+
| state | `'normal' \| 'error'` | `'normal'` | 状态 |
|
|
65
|
+
| stateMsg | `string` | - | 状态消息 |
|
|
66
|
+
| showStateMsg | `boolean` | `false` | 是否显示状态消息 |
|
|
67
|
+
| showCheckedStatusInList | `boolean` | `false` | 列表中是否高亮选中项 |
|
|
68
|
+
| noLabelAnim | `boolean` | `false` | 是否禁用标签动画 |
|
|
69
|
+
| radius | `number` | `12` | 圆角半径 |
|
|
70
|
+
| backgroundColor | `string` | - | 背景颜色 |
|
|
71
|
+
| labelColor | `string` | - | 标签颜色 |
|
|
72
|
+
| emptyText | `string` | `'No options'` | 空列表提示文字 |
|
|
73
|
+
| extendBtn | `string` | - | 扩展按钮文字 |
|
|
74
|
+
| extendBtnIcon | `string` | - | 扩展按钮图标 |
|
|
75
|
+
| onExtendBtnPress | `() => void` | - | 扩展按钮回调 |
|
|
76
|
+
| customPopoverContent | `React.ReactNode` | - | 自定义弹出内容 |
|
|
77
|
+
| modalVisible | `boolean` | - | 控制 Modal 可见性 |
|
|
78
|
+
| setModalVisible | `(val: boolean) => void` | - | 设置 Modal 可见性回调 |
|
|
79
|
+
| iconStyle | `ViewStyle \| TextStyle` | - | 图标样式 |
|
|
80
|
+
| offsetWidth | `number` | `0` | 偏移宽度 |
|
|
81
|
+
|
|
82
|
+
### CustomDropdown Props
|
|
83
|
+
|
|
84
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
85
|
+
|------|------|--------|------|
|
|
86
|
+
| children | `React.ReactNode` | - | 弹出框内容 |
|
|
87
|
+
| value | `string` | - | 按钮显示文字 |
|
|
88
|
+
| onPress | `() => void` | - | 按钮点击回调 |
|
|
89
|
+
| onClose | `() => void` | - | 关闭回调 |
|
|
90
|
+
| isVisible | `boolean` | - | 是否展开 |
|
|
91
|
+
| width | `number` | `80` | 按钮宽度 |
|
|
92
|
+
| subWidth | `number` | `250` | 弹出框宽度 |
|
|
93
|
+
| subHeight | `number` | `258` | 弹出框高度 |
|
|
94
|
+
| icon | `any` | - | 自定义图标 |
|
|
95
|
+
| subContainerPosition | `TDropdownPosition` | `'left'` | 弹出位置 |
|
|
96
|
+
| subContainerTop | `number` | - | 自定义 top 值(优先级最高) |
|
|
97
|
+
| subContainerLeft | `number` | - | 自定义 left 值(优先级最高) |
|
|
98
|
+
| customButton | `React.ReactNode` | - | 自定义触发按钮 |
|
|
99
|
+
| dropdownButtonStyle | `StyleProp<ViewStyle>` | - | 按钮样式 |
|
|
100
|
+
| dropdownButtonSelectedStyle | `StyleProp<ViewStyle>` | - | 选中时按钮样式 |
|
|
101
|
+
| dropdownButtonHoverStyle | `StyleProp<ViewStyle>` | - | hover 时按钮样式 |
|
|
102
|
+
| sheetTitlePros | `SheetTileProps` | - | 移动端 BottomSheet 标题配置 |
|
|
103
|
+
| dropdownBackgroundColor | `string` | - | 自定义弹出框背景色 |
|
|
104
|
+
|
|
105
|
+
### InputDropdown Props
|
|
106
|
+
|
|
107
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
108
|
+
|------|------|--------|------|
|
|
109
|
+
| label | `string` | - | 输入框标签(必填) |
|
|
110
|
+
| value | `ItemProps` | - | 当前选中值 |
|
|
111
|
+
| options | `ItemProps[]` | - | 选项列表 |
|
|
112
|
+
| onChange | `(value?: ItemProps) => void` | - | 选中变化回调 |
|
|
113
|
+
| onSearch | `(value: string) => void` | - | 搜索回调 |
|
|
114
|
+
| required | `boolean` | - | 是否必填 |
|
|
115
|
+
| readOnly | `boolean` | - | 是否只读 |
|
|
116
|
+
| clearable | `boolean` | - | 是否可清空 |
|
|
117
|
+
| disabled | `boolean` | - | 是否禁用 |
|
|
118
|
+
| defaultShowLabel | `boolean` | - | 默认是否显示标签 |
|
|
119
|
+
| labelBg | `string` | - | 标签背景色 |
|
|
120
|
+
| labelColor | `string` | - | 标签颜色 |
|
|
121
|
+
| allCreate | `boolean` | - | 是否允许自定义输入值 |
|
|
122
|
+
| labelPosition | `'top' \| 'middle'` | - | 标签位置 |
|
|
123
|
+
| children | `React.ReactNode` | - | 自定义下拉内容 |
|
|
124
|
+
|
|
125
|
+
### TapasDropDownItem 数据类型
|
|
126
|
+
|
|
127
|
+
| 属性 | 类型 | 说明 |
|
|
128
|
+
|------|------|------|
|
|
129
|
+
| key | `string \| number` | 选项唯一标识 |
|
|
130
|
+
| value | `string` | 选项显示文字 |
|
|
131
|
+
| secondaryValue | `string` | 次要显示文字(可选) |
|
|
132
|
+
|
|
133
|
+
## 使用示例
|
|
134
|
+
|
|
135
|
+
### 基础下拉
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
139
|
+
const [value, setValue] = useState(options[0]);
|
|
140
|
+
|
|
141
|
+
<Dropdown
|
|
142
|
+
title="Name"
|
|
143
|
+
options={options}
|
|
144
|
+
value={value}
|
|
145
|
+
width={150}
|
|
146
|
+
subWidth={150}
|
|
147
|
+
onChange={(val) => { setValue(val); setIsVisible(false); }}
|
|
148
|
+
isVisible={isVisible}
|
|
149
|
+
onClose={() => setIsVisible(false)}
|
|
150
|
+
onPress={() => setIsVisible(!isVisible)}
|
|
151
|
+
/>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 带搜索的下拉
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
<Dropdown
|
|
158
|
+
title="Name"
|
|
159
|
+
options={options}
|
|
160
|
+
value={value}
|
|
161
|
+
showSearchBar={true}
|
|
162
|
+
subWidth={200}
|
|
163
|
+
onSearchChange={(val) => console.log(val)}
|
|
164
|
+
isVisible={isVisible}
|
|
165
|
+
onClose={() => setIsVisible(false)}
|
|
166
|
+
onPress={() => setIsVisible(!isVisible)}
|
|
167
|
+
onChange={(val) => setValue(val)}
|
|
168
|
+
/>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### InputDropdown(可搜索输入下拉)
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
<InputDropdown
|
|
175
|
+
label="选择名称"
|
|
176
|
+
options={options}
|
|
177
|
+
value={selectedValue}
|
|
178
|
+
clearable
|
|
179
|
+
labelBg="#fff"
|
|
180
|
+
isVisible={isVisible}
|
|
181
|
+
onClose={() => setIsVisible(false)}
|
|
182
|
+
onPress={() => setIsVisible(!isVisible)}
|
|
183
|
+
onChange={(val) => setValue(val)}
|
|
184
|
+
/>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 自定义按钮
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
<Dropdown
|
|
191
|
+
options={options}
|
|
192
|
+
value={value}
|
|
193
|
+
customButton={
|
|
194
|
+
<View style={{ width: 48, height: 40, justifyContent: 'center', alignItems: 'center' }}>
|
|
195
|
+
<Icon name="more_vert" size={20} />
|
|
196
|
+
</View>
|
|
197
|
+
}
|
|
198
|
+
isVisible={isVisible}
|
|
199
|
+
onClose={() => setIsVisible(false)}
|
|
200
|
+
onPress={() => setIsVisible(!isVisible)}
|
|
201
|
+
onChange={(val) => setValue(val)}
|
|
202
|
+
/>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Modal 模式
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
<Dropdown
|
|
209
|
+
useModal={true}
|
|
210
|
+
dropdownItems={[
|
|
211
|
+
{ key: '1', value: '选项一' },
|
|
212
|
+
{ key: '2', value: '选项二' },
|
|
213
|
+
]}
|
|
214
|
+
selected="1"
|
|
215
|
+
showSelectedValue={true}
|
|
216
|
+
dropdownType="solid"
|
|
217
|
+
label="选择"
|
|
218
|
+
onSelect={(item) => console.log(item)}
|
|
219
|
+
/>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## 注意事项
|
|
223
|
+
|
|
224
|
+
- 普通模式下需要手动管理 `isVisible` 状态
|
|
225
|
+
- Web 端点击外部会自动关闭弹出框(通过 document click 事件)
|
|
226
|
+
- 移动端自动使用 BottomSheet 展示
|
|
227
|
+
- `subContainerTop` 和 `subContainerLeft` 优先级高于 `subContainerPosition`
|
|
228
|
+
- Modal 模式下弹出位置会自动检测屏幕空间,优先向下展示
|
|
229
|
+
- `type="button"` 时点击选项不会更新选中值,仅触发 `onItemPress`
|
|
230
|
+
- InputDropdown 在 `allCreate` 为 false 时,失焦后会恢复为选中值
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# ExternalLink
|
|
2
|
+
|
|
3
|
+
外部链接组件,用于打开外部 URL。自动适配 Web(window.open)和移动端(Linking.openURL)平台差异,提供统一的外链交互体验。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 跨平台链接打开:Web 新标签页、移动端外部浏览器
|
|
8
|
+
- ✅ 移动端自动检测 URL 可用性(Linking.canOpenURL)
|
|
9
|
+
- ✅ 支持自定义点击行为(onPress 覆盖默认行为)
|
|
10
|
+
- ✅ 文本子元素自动包装 Text 组件
|
|
11
|
+
- ✅ 自定义链接和文本样式
|
|
12
|
+
- ✅ 默认下划线链接样式
|
|
13
|
+
- ✅ 主题色适配(primary 色)
|
|
14
|
+
|
|
15
|
+
## 安装使用
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { ExternalLink } from '@beppla/tapas-ui';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Props
|
|
22
|
+
|
|
23
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
24
|
+
|------|------|--------|------|
|
|
25
|
+
| href | `string` | - | 目标 URL(必填) |
|
|
26
|
+
| children | `React.ReactNode` | - | 链接内容(必填) |
|
|
27
|
+
| style | `any` | - | 外层容器样式 |
|
|
28
|
+
| textStyle | `any` | - | 文本样式 |
|
|
29
|
+
| onPress | `() => void` | - | 自定义点击行为(覆盖默认打开链接) |
|
|
30
|
+
|
|
31
|
+
## 使用示例
|
|
32
|
+
|
|
33
|
+
### 基础用法
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
<ExternalLink href="https://beppla.com">
|
|
37
|
+
Visit BEPPLA
|
|
38
|
+
</ExternalLink>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 自定义样式
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<ExternalLink
|
|
45
|
+
href="https://docs.beppla.com"
|
|
46
|
+
textStyle={{ color: '#895F38', fontSize: 14 }}
|
|
47
|
+
>
|
|
48
|
+
Documentation
|
|
49
|
+
</ExternalLink>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### ReactNode 子元素
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
<ExternalLink href="https://support.beppla.com">
|
|
56
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
57
|
+
<TapasIcon name="help" size={16} />
|
|
58
|
+
<Text style={{ marginLeft: 4 }}>Help Center</Text>
|
|
59
|
+
</View>
|
|
60
|
+
</ExternalLink>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 自定义点击行为
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
<ExternalLink
|
|
67
|
+
href="https://example.com"
|
|
68
|
+
onPress={() => trackLinkClick('example')}
|
|
69
|
+
>
|
|
70
|
+
Custom handler
|
|
71
|
+
</ExternalLink>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 注意事项
|
|
75
|
+
|
|
76
|
+
- 字符串类型的 children 自动包装为 Text 组件并应用 textStyle
|
|
77
|
+
- 非字符串类型的 children 直接渲染,textStyle 不生效
|
|
78
|
+
- 移动端打开前会检查 `Linking.canOpenURL`,不支持的 URL 会在控制台警告
|
|
79
|
+
- `onPress` 存在时不会打开 href 链接
|
|
80
|
+
- 默认文本样式:主题 primary 色、下划线、fontSize 16
|
|
81
|
+
- 需在 `ThemeProvider` 内使用
|