@beppla/tapas-ui 1.5.2 → 1.5.7
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/Dropdown.js +60 -30
- package/commonjs/Dropdown/Dropdown.js.map +1 -1
- 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/Dropdown.js +60 -30
- package/module/Dropdown/Dropdown.js.map +1 -1
- 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/Dropdown/Dropdown.d.ts +20 -0
- package/typescript/Dropdown/Dropdown.d.ts.map +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 +8 -2
- package/typescript/index.d.ts.map +1 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Layout
|
|
2
|
+
|
|
3
|
+
应用程序主框架布局组件,整合导航栏、页眉和内容区域,并内置 Toast 和 Drawer 上下文管理。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 自动响应式布局(移动端导航隐藏,桌面端导航常驻左侧)
|
|
8
|
+
- 集成 Navigation 导航栏组件(可选显示、可自定义替换)
|
|
9
|
+
- 集成 Header 页眉组件(可自定义替换)
|
|
10
|
+
- 内置 ToastProvider 和 DrawerProvider 上下文
|
|
11
|
+
- 内容区域自动 ScrollView 滚动
|
|
12
|
+
- 移动端通过 Header 菜单按钮控制导航栏显示/隐藏
|
|
13
|
+
- 桌面端导航栏占据左侧 56px,内容区自动偏移
|
|
14
|
+
|
|
15
|
+
## 安装使用
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import Layout from '@beppla/tapas-ui/components/Layout';
|
|
19
|
+
// 或
|
|
20
|
+
import { Layout } from '@beppla/tapas-ui';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
26
|
+
|------|------|--------|------|
|
|
27
|
+
| children | `React.ReactNode` | - | 布局主体内容 |
|
|
28
|
+
| headerProps | `HeaderProps` | - | Header 组件的 Props |
|
|
29
|
+
| headerComponent | `React.ReactNode` | - | 自定义 Header 组件(替换默认 Header) |
|
|
30
|
+
| navigationProps | `NavigationProps` | - | Navigation 组件的 Props |
|
|
31
|
+
| navigationComponent | `React.ReactNode` | - | 自定义 Navigation 组件(替换默认导航) |
|
|
32
|
+
| showNavigation | `boolean` | `true` | 是否显示导航栏 |
|
|
33
|
+
| testID | `string` | - | 测试 ID |
|
|
34
|
+
|
|
35
|
+
## 上下文 API
|
|
36
|
+
|
|
37
|
+
### DrawerContext
|
|
38
|
+
|
|
39
|
+
通过 `DrawerContext` 可在 Layout 内部任意组件中控制 Drawer 的开关。
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { useContext } from 'react';
|
|
43
|
+
import { DrawerContext } from '@beppla/tapas-ui/components/Layout/DrawerContext';
|
|
44
|
+
|
|
45
|
+
const { open, close, drawerInfo, setDrawerInfo } = useContext(DrawerContext);
|
|
46
|
+
|
|
47
|
+
// 打开 Drawer
|
|
48
|
+
open({
|
|
49
|
+
title: 'Filter',
|
|
50
|
+
component: <FilterForm />,
|
|
51
|
+
showFooter: true,
|
|
52
|
+
rightButtonText: 'Apply',
|
|
53
|
+
rightButtonOnPress: () => handleApply(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// 关闭 Drawer
|
|
57
|
+
close();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### ToastContext
|
|
61
|
+
|
|
62
|
+
通过 `ToastContext` 可在 Layout 内部任意组件中显示 Toast 消息。
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { useContext } from 'react';
|
|
66
|
+
import { ToastContext } from '@beppla/tapas-ui/components/Layout/ToastContext';
|
|
67
|
+
|
|
68
|
+
const { open, close } = useContext(ToastContext);
|
|
69
|
+
|
|
70
|
+
// 显示 Toast
|
|
71
|
+
open({ message: 'Operation succeeded', visible: true });
|
|
72
|
+
|
|
73
|
+
// 关闭 Toast
|
|
74
|
+
close();
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 使用示例
|
|
78
|
+
|
|
79
|
+
### 基础用法
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import Layout from '@beppla/tapas-ui/components/Layout';
|
|
83
|
+
import { Text } from 'react-native';
|
|
84
|
+
|
|
85
|
+
const navItems = [
|
|
86
|
+
{ name: 'Product', iconName: 'product_items' },
|
|
87
|
+
{ name: 'About', iconName: 'manufacturing' },
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
export default function App() {
|
|
91
|
+
return (
|
|
92
|
+
<Layout
|
|
93
|
+
navigationProps={{
|
|
94
|
+
navItems,
|
|
95
|
+
logoImg: require('./logo.png'),
|
|
96
|
+
}}
|
|
97
|
+
headerProps={{
|
|
98
|
+
title: 'Welcome',
|
|
99
|
+
avatarSource: 'https://example.com/avatar.jpg',
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
<Text>Main content goes here</Text>
|
|
103
|
+
</Layout>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 带导航切换的完整示例
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import Layout, { NavItem } from '@beppla/tapas-ui/components/Layout';
|
|
112
|
+
import { useState } from 'react';
|
|
113
|
+
import { Text } from 'react-native';
|
|
114
|
+
|
|
115
|
+
const navItems: NavItem[] = [
|
|
116
|
+
{ name: 'Home', iconName: 'home' },
|
|
117
|
+
{ name: 'Products', iconName: 'product_items' },
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
const systemItems: NavItem[] = [
|
|
121
|
+
{ name: 'Settings', iconName: 'settings' },
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
export default function App() {
|
|
125
|
+
const [selected, setSelected] = useState('Home');
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Layout
|
|
129
|
+
navigationProps={{
|
|
130
|
+
navItems,
|
|
131
|
+
systemItems,
|
|
132
|
+
logoImg: require('./logo.png'),
|
|
133
|
+
onItemPress: (item) => setSelected(item.name),
|
|
134
|
+
}}
|
|
135
|
+
headerProps={{ title: selected }}
|
|
136
|
+
>
|
|
137
|
+
<Text>{selected} Page Content</Text>
|
|
138
|
+
</Layout>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 自定义 Header 组件
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
<Layout
|
|
147
|
+
navigationProps={{ navItems, logoImg: require('./logo.png') }}
|
|
148
|
+
headerComponent={
|
|
149
|
+
<View style={{ height: 72, justifyContent: 'center', paddingHorizontal: 16 }}>
|
|
150
|
+
<Text style={{ fontSize: 20 }}>Custom Header</Text>
|
|
151
|
+
</View>
|
|
152
|
+
}
|
|
153
|
+
>
|
|
154
|
+
<Text>Content</Text>
|
|
155
|
+
</Layout>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 隐藏导航栏
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
<Layout showNavigation={false} headerProps={{ title: 'No Navigation' }}>
|
|
162
|
+
<Text>Full width content</Text>
|
|
163
|
+
</Layout>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## 注意事项
|
|
167
|
+
|
|
168
|
+
- Layout 的 index.tsx 导出版本自动包裹 ToastProvider 和 DrawerProvider,无需手动包裹
|
|
169
|
+
- 移动端导航栏默认隐藏,通过 Header 左侧菜单按钮切换显示/隐藏
|
|
170
|
+
- 桌面端导航栏常驻左侧(宽度 56px),内容区自动左偏移 56px
|
|
171
|
+
- 自定义 `headerComponent` 会完全替代默认 Header,包括菜单按钮
|
|
172
|
+
- 自定义 `navigationComponent` 会完全替代默认 Navigation
|
|
173
|
+
- 内容区域使用 ScrollView 包裹,设置了 `keyboardShouldPersistTaps="handled"`
|
|
174
|
+
- Toast 在桌面端显示在右上角,移动端显示在顶部
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# LineChart
|
|
2
|
+
|
|
3
|
+
折线图组件,支持单系列/多系列数据、多种曲线类型、自定义图例和 Tooltip。采用**双平台渲染**策略:Web 端使用 recharts,Native 端使用 react-native-svg-charts。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ **双平台渲染**:Web 使用 recharts(功能完整),Native 使用 react-native-svg-charts(基础功能)
|
|
8
|
+
- ✅ 支持单系列和多系列数据
|
|
9
|
+
- ✅ 多种曲线类型:monotone / linear / step / natural / basis
|
|
10
|
+
- ✅ 可显示/隐藏数据点(showDots)
|
|
11
|
+
- ✅ 可独立控制 X 轴和 Y 轴的显示/隐藏
|
|
12
|
+
- ✅ 图例支持 top / bottom / left / right 四个位置
|
|
13
|
+
- ✅ 自定义图例图标类型:circle / rect / square / line
|
|
14
|
+
- ✅ 自定义图例图标尺寸和文本样式
|
|
15
|
+
- ✅ 自定义 Tooltip:完全自定义渲染(customTooltip)或数据格式化(tooltipFormatter)
|
|
16
|
+
- ✅ 数据点点击事件回调(onLineClick)
|
|
17
|
+
- ✅ Y 轴 / X 轴格式化函数
|
|
18
|
+
- ✅ 响应式容器(Web 端 ResponsiveContainer)
|
|
19
|
+
|
|
20
|
+
## 安装使用
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { LineChart } from '@beppla/tapas-ui/components/LineChart';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Props
|
|
27
|
+
|
|
28
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
29
|
+
|------|------|--------|------|
|
|
30
|
+
| data | `LineChartDataPoint[] \| LineChartSeriesData[]` | (必填) | 数据源 |
|
|
31
|
+
| width | `number` | - | 图表宽度 |
|
|
32
|
+
| height | `number` | `300` | 图表高度 |
|
|
33
|
+
| color | `string` | `'#0066CC'` | 单系列线条颜色 |
|
|
34
|
+
| colors | `string[]` | - | 多系列颜色方案 |
|
|
35
|
+
| showGrid | `boolean` | `true` | 是否显示网格线 |
|
|
36
|
+
| showLabels | `boolean` | `true` | 是否显示标签 |
|
|
37
|
+
| showXAxis | `boolean` | `true` | 是否显示 X 轴 |
|
|
38
|
+
| showYAxis | `boolean` | `true` | 是否显示 Y 轴 |
|
|
39
|
+
| showLegend | `boolean` | `true` | 是否显示图例 |
|
|
40
|
+
| legendPosition | `'top' \| 'bottom' \| 'left' \| 'right'` | `'bottom'` | 图例位置 |
|
|
41
|
+
| legendIconType | `'circle' \| 'rect' \| 'square' \| 'line'` | `'rect'` | 图例图标类型 |
|
|
42
|
+
| legendIconSize | `{ width: number; height: number }` | `{ width: 18, height: 8 }` | 图例图标尺寸 |
|
|
43
|
+
| legendTextStyle | `{ fontFamily?: string; fontSize?: number; fontWeight?: string \| number; letterSpacing?: number }` | Bricolage Grotesque 10px | 图例文本样式 |
|
|
44
|
+
| curveType | `'monotone' \| 'linear' \| 'step' \| 'natural' \| 'basis'` | `'monotone'` | 曲线类型 |
|
|
45
|
+
| showDots | `boolean` | `true` | 是否显示数据点 |
|
|
46
|
+
| showArea | `boolean` | - | 是否显示面积填充 |
|
|
47
|
+
| customTooltip | `(data: TooltipData) => ReactElement \| null` | - | 自定义 Tooltip 渲染函数 |
|
|
48
|
+
| tooltipFormatter | `(data: TooltipData) => { title?: string; items?: Array<{ label: string; value: string \| number }> }` | - | Tooltip 数据格式化函数 |
|
|
49
|
+
| contentInset | `{ top?: number; bottom?: number; left?: number; right?: number }` | `{ top: 20, bottom: 20, left: 20, right: 20 }` | 内容边距 |
|
|
50
|
+
| yAxisFormat | `(value: number) => string` | - | Y 轴格式化 |
|
|
51
|
+
| xAxisFormat | `(value: number, index: number) => string` | - | X 轴格式化 |
|
|
52
|
+
| onLineClick | `(seriesLabel: string, dataPoint: LineChartDataPoint, dataIndex: number) => void` | - | 数据点点击回调 |
|
|
53
|
+
| style | `any` | - | 容器样式 |
|
|
54
|
+
| testID | `string` | - | 测试标识 |
|
|
55
|
+
|
|
56
|
+
### LineChartDataPoint
|
|
57
|
+
|
|
58
|
+
| 属性 | 类型 | 说明 |
|
|
59
|
+
|------|------|------|
|
|
60
|
+
| value | `number` | 数值(必填) |
|
|
61
|
+
| label | `string` | 标签 |
|
|
62
|
+
|
|
63
|
+
### LineChartSeriesData
|
|
64
|
+
|
|
65
|
+
| 属性 | 类型 | 说明 |
|
|
66
|
+
|------|------|------|
|
|
67
|
+
| data | `LineChartDataPoint[]` | 数据点数组(必填) |
|
|
68
|
+
| color | `string` | 线条颜色 |
|
|
69
|
+
| label | `string` | 系列标签(显示在图例中) |
|
|
70
|
+
|
|
71
|
+
### TooltipData
|
|
72
|
+
|
|
73
|
+
| 属性 | 类型 | 说明 |
|
|
74
|
+
|------|------|------|
|
|
75
|
+
| label | `string` | 当前数据点标签 |
|
|
76
|
+
| value | `number` | 当前数据点值 |
|
|
77
|
+
| dataIndex | `number` | 数据索引 |
|
|
78
|
+
| seriesLabel | `string` | 系列标签 |
|
|
79
|
+
|
|
80
|
+
## 使用示例
|
|
81
|
+
|
|
82
|
+
### 基础用法
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
<LineChart
|
|
86
|
+
data={[
|
|
87
|
+
{ value: 50, label: 'Jan' },
|
|
88
|
+
{ value: 75, label: 'Feb' },
|
|
89
|
+
{ value: 65, label: 'Mar' },
|
|
90
|
+
{ value: 90, label: 'Apr' },
|
|
91
|
+
]}
|
|
92
|
+
height={300}
|
|
93
|
+
color="#0066CC"
|
|
94
|
+
/>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 多系列数据
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<LineChart
|
|
101
|
+
data={[
|
|
102
|
+
{
|
|
103
|
+
label: 'Product A',
|
|
104
|
+
color: '#00BFA5',
|
|
105
|
+
data: [
|
|
106
|
+
{ value: 120, label: 'Mon' },
|
|
107
|
+
{ value: 150, label: 'Tue' },
|
|
108
|
+
{ value: 110, label: 'Wed' },
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: 'Product B',
|
|
113
|
+
color: '#FF6B00',
|
|
114
|
+
data: [
|
|
115
|
+
{ value: 100, label: 'Mon' },
|
|
116
|
+
{ value: 110, label: 'Tue' },
|
|
117
|
+
{ value: 90, label: 'Wed' },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
]}
|
|
121
|
+
showLegend
|
|
122
|
+
legendPosition="top"
|
|
123
|
+
height={400}
|
|
124
|
+
/>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 极简设计图风格
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<LineChart
|
|
131
|
+
data={multiSeriesData}
|
|
132
|
+
curveType="linear"
|
|
133
|
+
showDots={false}
|
|
134
|
+
showYAxis={false}
|
|
135
|
+
showLegend
|
|
136
|
+
legendPosition="top"
|
|
137
|
+
legendIconType="rect"
|
|
138
|
+
legendIconSize={{ width: 18, height: 8 }}
|
|
139
|
+
legendTextStyle={{
|
|
140
|
+
fontFamily: 'Bricolage Grotesque, sans-serif',
|
|
141
|
+
fontSize: 10,
|
|
142
|
+
fontWeight: 400,
|
|
143
|
+
letterSpacing: 0.1,
|
|
144
|
+
}}
|
|
145
|
+
/>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 自定义 Tooltip
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
<LineChart
|
|
152
|
+
data={storeData}
|
|
153
|
+
tooltipFormatter={(data) => ({
|
|
154
|
+
title: data.label,
|
|
155
|
+
items: [
|
|
156
|
+
{ label: 'Stores', value: data.value },
|
|
157
|
+
{ label: 'Revenue', value: `$${revenue[data.dataIndex]}` },
|
|
158
|
+
],
|
|
159
|
+
})}
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 数据点点击事件
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
<LineChart
|
|
167
|
+
data={sampleData}
|
|
168
|
+
onLineClick={(seriesLabel, dataPoint, dataIndex) => {
|
|
169
|
+
console.log(`${seriesLabel}: ${dataPoint.label} = ${dataPoint.value}`);
|
|
170
|
+
}}
|
|
171
|
+
/>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 注意事项
|
|
175
|
+
|
|
176
|
+
- **双平台渲染**:Web 端使用 recharts(功能完整),Native 端使用 react-native-svg-charts(功能受限)
|
|
177
|
+
- Native 端多系列数据**仅渲染第一个系列**
|
|
178
|
+
- Native 端不支持自定义 Tooltip、图例自定义、曲线类型选择
|
|
179
|
+
- 图例仅在多系列数据时显示
|
|
180
|
+
- `customTooltip` 和 `tooltipFormatter` 仅 Web 端有效(鼠标悬停触发)
|
|
181
|
+
- 需安装对应平台依赖:Web 需要 `recharts`,Native 需要 `react-native-svg-charts` + `react-native-svg`
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# ListItem
|
|
2
|
+
|
|
3
|
+
列表项组件,基于 @rneui/themed ListItem 封装,支持选中状态、搜索高亮、描述文本、数量角标等功能,适合构建可交互的选择列表。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 选中状态指示(背景色变化 + 勾选图标)
|
|
8
|
+
- ✅ 搜索关键字高亮显示(name 和 desc 同时高亮)
|
|
9
|
+
- ✅ 支持主标题和描述文本
|
|
10
|
+
- ✅ 数量角标(number 属性,圆形背景主题色)
|
|
11
|
+
- ✅ 鼠标悬停效果(Web 端 Hoverable)
|
|
12
|
+
- ✅ 禁用状态,颜色置灰且不可点击
|
|
13
|
+
- ✅ 首末项圆角支持(isFirst / isLast,12px 圆角)
|
|
14
|
+
- ✅ 高度自定义样式:容器、标题、描述、搜索高亮
|
|
15
|
+
- ✅ 文本自适应宽度,自动单行截断
|
|
16
|
+
|
|
17
|
+
## 安装使用
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import ListItem from '@beppla/tapas-ui/components/ListItem/ListItem';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
26
|
+
|------|------|--------|------|
|
|
27
|
+
| item | `ItemProps` | (必填) | 列表项数据 |
|
|
28
|
+
| selected | `ItemProps` | (必填) | 当前选中项(通过 value 比较) |
|
|
29
|
+
| key | `number \| string` | (必填) | 唯一标识 |
|
|
30
|
+
| onItemPress | `(item: ItemProps) => void` | (必填) | 点击回调 |
|
|
31
|
+
| disabled | `boolean` | - | 是否禁用 |
|
|
32
|
+
| isFirst | `boolean` | - | 是否为第一项(添加顶部圆角) |
|
|
33
|
+
| isLast | `boolean` | - | 是否为最后一项(添加底部圆角) |
|
|
34
|
+
| search | `string` | - | 搜索关键字,匹配部分高亮 |
|
|
35
|
+
| containerStyle | `StyleProp<ViewStyle>` | - | 外层容器样式 |
|
|
36
|
+
| itemContainerStyle | `StyleProp<ViewStyle>` | - | 项容器样式 |
|
|
37
|
+
| titleContainerStyle | `StyleProp<ViewStyle>` | - | 标题容器样式 |
|
|
38
|
+
| searchHighlightStyle | `StyleProp<TextStyle>` | - | 搜索高亮文本样式 |
|
|
39
|
+
| titleStyle | `StyleProp<TextStyle>` | - | 标题文本样式 |
|
|
40
|
+
| descStyle | `StyleProp<TextStyle>` | - | 描述文本样式 |
|
|
41
|
+
| testID | `string` | - | 测试标识 |
|
|
42
|
+
|
|
43
|
+
### ItemProps 接口
|
|
44
|
+
|
|
45
|
+
| 属性 | 类型 | 说明 |
|
|
46
|
+
|------|------|------|
|
|
47
|
+
| name | `string` | 显示名称(必填) |
|
|
48
|
+
| value | `string \| number` | 值(必填),用于比较选中状态 |
|
|
49
|
+
| id | `string \| number` | 唯一标识 |
|
|
50
|
+
| hide | `boolean` | 是否隐藏 |
|
|
51
|
+
| desc | `string` | 描述文本 |
|
|
52
|
+
| number | `number` | 数量角标 |
|
|
53
|
+
|
|
54
|
+
## 使用示例
|
|
55
|
+
|
|
56
|
+
### 基础用法
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const data = [
|
|
60
|
+
{ name: 'Apple', value: 'apple' },
|
|
61
|
+
{ name: 'Banana', value: 'banana' },
|
|
62
|
+
{ name: 'Cherry', value: 'cherry' },
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const [selected, setSelected] = useState(data[0]);
|
|
66
|
+
|
|
67
|
+
{data.map((item, index) => (
|
|
68
|
+
<ListItem
|
|
69
|
+
key={index}
|
|
70
|
+
item={item}
|
|
71
|
+
selected={selected}
|
|
72
|
+
onItemPress={(value) => setSelected(value)}
|
|
73
|
+
isFirst={index === 0}
|
|
74
|
+
isLast={index === data.length - 1}
|
|
75
|
+
/>
|
|
76
|
+
))}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 带描述和搜索高亮
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<ListItem
|
|
83
|
+
key={0}
|
|
84
|
+
item={{ name: 'John', value: 'john', desc: 'Manager' }}
|
|
85
|
+
selected={selected}
|
|
86
|
+
onItemPress={setSelected}
|
|
87
|
+
search="jo"
|
|
88
|
+
searchHighlightStyle={{ color: 'red' }}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 带数量角标
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<ListItem
|
|
96
|
+
key={0}
|
|
97
|
+
item={{ name: 'Orders', value: 'orders', number: 5 }}
|
|
98
|
+
selected={selected}
|
|
99
|
+
onItemPress={setSelected}
|
|
100
|
+
/>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 禁用状态
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<ListItem
|
|
107
|
+
key={0}
|
|
108
|
+
item={{ name: 'Unavailable', value: 'unavailable' }}
|
|
109
|
+
selected={selected}
|
|
110
|
+
onItemPress={setSelected}
|
|
111
|
+
disabled
|
|
112
|
+
/>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 注意事项
|
|
116
|
+
|
|
117
|
+
- 选中状态通过比较 `selected.value === item.value` 判断
|
|
118
|
+
- 当 `item.number` 存在时显示数量角标(白字主题色背景),否则选中时显示勾选图标
|
|
119
|
+
- 禁用状态下点击不会触发 `onItemPress`
|
|
120
|
+
- `isFirst` / `isLast` 用于列表首末项圆角(12px),需手动传入
|
|
121
|
+
- 搜索高亮使用正则分割文本,大小写不敏感,同时作用于 name 和 desc 字段
|
|
122
|
+
- 列表项固定高度 48px
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useEffect, useState, useCallback, useMemo } from "react";
|
|
4
|
-
import { View, Text, Modal, Pressable } from "react-native";
|
|
4
|
+
import { View, Text, Modal, Pressable, useWindowDimensions } from "react-native";
|
|
5
5
|
import { withTheme, makeStyles, useTheme } from "@rneui/themed";
|
|
6
6
|
import TapasIcon from "../Icons/TapasIcon";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -22,6 +22,10 @@ const MessageBox = ({
|
|
|
22
22
|
onConfirm
|
|
23
23
|
}) => {
|
|
24
24
|
const theme = useTheme();
|
|
25
|
+
const {
|
|
26
|
+
width: windowWidth
|
|
27
|
+
} = useWindowDimensions();
|
|
28
|
+
const isPhone = windowWidth <= 430;
|
|
25
29
|
const styles = useStyles();
|
|
26
30
|
const [modalVisible, setModalVisible] = useState(false);
|
|
27
31
|
useEffect(() => {
|
|
@@ -63,7 +67,9 @@ const MessageBox = ({
|
|
|
63
67
|
children: /*#__PURE__*/_jsx(View, {
|
|
64
68
|
style: styles.modalContainer,
|
|
65
69
|
children: /*#__PURE__*/_jsxs(View, {
|
|
66
|
-
style: styles.modalContent,
|
|
70
|
+
style: [styles.modalContent, isPhone && {
|
|
71
|
+
width: windowWidth - 32
|
|
72
|
+
}],
|
|
67
73
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
68
74
|
style: styles.messagebox_header,
|
|
69
75
|
children: [stateIcon ? /*#__PURE__*/_jsx(View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useState","useCallback","useMemo","View","Text","Modal","Pressable","withTheme","makeStyles","useTheme","TapasIcon","jsx","_jsx","jsxs","_jsxs","MessageBox","state","title","text","icon","visible","confirmBtnText","closeBtnText","hideFooter","hideCloseBtn","hideConfirmBtn","descNumberOfLines","onVisibilityChange","onClose","onConfirm","theme","styles","useStyles","modalVisible","setModalVisible","Boolean","stateIcon","handleClose","handleConfirm","handleRequestClose","animationType","transparent","onRequestClose","children","style","modalContainer","modalContent","messagebox_header","messagebox_header_icon","name","size","color","colors","primary","messagebox_header_txt_con","messagebox_header_txt","numberOfLines","ellipsizeMode","messagebox_main","messagebox_main_txt","messagebox_footer","messagebox_btn","onPress","messagebox_btn_txt","backgroundColor","white","flex","justifyContent","alignItems","zIndex","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","useCallback","useMemo","View","Text","Modal","Pressable","useWindowDimensions","withTheme","makeStyles","useTheme","TapasIcon","jsx","_jsx","jsxs","_jsxs","MessageBox","state","title","text","icon","visible","confirmBtnText","closeBtnText","hideFooter","hideCloseBtn","hideConfirmBtn","descNumberOfLines","onVisibilityChange","onClose","onConfirm","theme","width","windowWidth","isPhone","styles","useStyles","modalVisible","setModalVisible","Boolean","stateIcon","handleClose","handleConfirm","handleRequestClose","animationType","transparent","onRequestClose","children","style","modalContainer","modalContent","messagebox_header","messagebox_header_icon","name","size","color","colors","primary","messagebox_header_txt_con","messagebox_header_txt","numberOfLines","ellipsizeMode","messagebox_main","messagebox_main_txt","messagebox_footer","messagebox_btn","onPress","messagebox_btn_txt","backgroundColor","white","flex","justifyContent","alignItems","zIndex","borderRadius","display","flexDirection","padding","gap","height","alignContent","overflow","fontSize","fontWeight","secondary","paddingLeft","paddingRight"],"sourceRoot":"../../../components","sources":["MessageBox/MessageBox.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACxE,SAASC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAEC,SAAS,EAAEC,mBAAmB,QAAQ,cAAc;AAChF,SAASC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,eAAe;AAC/D,OAAOC,SAAS,MAAM,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAoB3C,MAAMC,UAAqC,GAAGA,CAAC;EAC7CC,KAAK;EACLC,KAAK;EACLC,IAAI;EACJC,IAAI;EACJC,OAAO;EACPC,cAAc;EACdC,YAAY;EACZC,UAAU,GAAG,KAAK;EAClBC,YAAY,GAAG,KAAK;EACpBC,cAAc,GAAG,KAAK;EACtBC,iBAAiB,GAA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,iBAAiB,EAAE;IACjBW,OAAO,EAAE,MAAM;IACfC,aAAa,EAAE,KAAK;IACpBL,cAAc,EAAE,UAAU;IAC1BO,GAAG,EAAE,CAAC;IACNC,MAAM,EAAE;EACV,CAAC;EACDd,cAAc,EAAE;IACdc,MAAM,EAAE,EAAE;IACVJ,OAAO,EAAE,MAAM;IACfC,aAAa,EAAE,KAAK;IACpBL,cAAc,EAAE,QAAQ;IACxBS,YAAY,EAAE,QAAQ;IACtBR,UAAU,EAAE,QAAQ;IACpBa,WAAW,EAAE,EAAE;IACfC,YAAY,EAAE,EAAE;IAChBZ,YAAY,EAAE;EAChB,CAAC;EACDP,kBAAkB,EAAE;IAClBe,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC,CAAC;AAEH,eAAe3E,SAAS,CAACQ,UAAU,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# MessageBox
|
|
2
|
+
|
|
3
|
+
模态对话框组件,用于显示重要信息和获取用户确认。支持 success、warning、error 三种状态,提供灵活的按钮配置(隐藏确认/取消按钮、隐藏整个底部栏),适合操作确认、错误提示、成功反馈等场景。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 支持 success、warning、error 三种状态
|
|
8
|
+
- ✅ 状态自动匹配图标(check_circle / warning / error)
|
|
9
|
+
- ✅ 可自定义图标名称覆盖默认状态图标
|
|
10
|
+
- ✅ 灵活的按钮配置:隐藏确认按钮、隐藏取消按钮、隐藏整个底部栏
|
|
11
|
+
- ✅ 自定义确认和取消按钮文本
|
|
12
|
+
- ✅ 描述文本行数限制(descNumberOfLines)
|
|
13
|
+
- ✅ 淡入淡出动画(animationType="fade")
|
|
14
|
+
- ✅ 透明遮罩背景
|
|
15
|
+
- ✅ 支持 onVisibilityChange 双向绑定控制
|
|
16
|
+
|
|
17
|
+
## 安装使用
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { MessageBox } from '@beppla/tapas-ui';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
26
|
+
|------|------|--------|------|
|
|
27
|
+
| visible | `boolean` | - | 是否显示对话框 |
|
|
28
|
+
| state | `'success' \| 'warning' \| 'error'` | - | 状态类型 |
|
|
29
|
+
| icon | `string` | 根据 state 自动选择 | 自定义图标名称 |
|
|
30
|
+
| title | `string` | - | 标题文本 |
|
|
31
|
+
| text | `string` | - | 描述内容 |
|
|
32
|
+
| hideFooter | `boolean` | `false` | 是否隐藏整个底部按钮栏 |
|
|
33
|
+
| hideCloseBtn | `boolean` | `false` | 是否隐藏取消按钮 |
|
|
34
|
+
| hideConfirmBtn | `boolean` | `false` | 是否隐藏确认按钮 |
|
|
35
|
+
| confirmBtnText | `string` | `'Confirm'` | 确认按钮文本 |
|
|
36
|
+
| closeBtnText | `string` | `'Close'` | 取消按钮文本 |
|
|
37
|
+
| descNumberOfLines | `number` | `3` | 描述文本最大行数 |
|
|
38
|
+
| onVisibilityChange | `(val: boolean) => void` | - | 可见状态变化回调 |
|
|
39
|
+
| onConfirm | `() => void` | - | 确认按钮点击回调 |
|
|
40
|
+
| onClose | `() => void` | - | 取消按钮点击回调 |
|
|
41
|
+
|
|
42
|
+
## 使用示例
|
|
43
|
+
|
|
44
|
+
### 基础用法
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
const [visible, setVisible] = useState(false);
|
|
48
|
+
|
|
49
|
+
<MessageBox
|
|
50
|
+
visible={visible}
|
|
51
|
+
title="Confirm"
|
|
52
|
+
text="Are you sure you want to proceed?"
|
|
53
|
+
confirmBtnText="OK"
|
|
54
|
+
closeBtnText="Cancel"
|
|
55
|
+
onVisibilityChange={setVisible}
|
|
56
|
+
onConfirm={() => {
|
|
57
|
+
handleConfirm();
|
|
58
|
+
setVisible(false);
|
|
59
|
+
}}
|
|
60
|
+
onClose={() => setVisible(false)}
|
|
61
|
+
/>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 不同状态
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<MessageBox
|
|
68
|
+
visible={visible}
|
|
69
|
+
state="success"
|
|
70
|
+
title="Success"
|
|
71
|
+
text="Operation completed!"
|
|
72
|
+
hideCloseBtn
|
|
73
|
+
confirmBtnText="OK"
|
|
74
|
+
onConfirm={() => setVisible(false)}
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<MessageBox
|
|
78
|
+
visible={visible}
|
|
79
|
+
state="error"
|
|
80
|
+
title="Error"
|
|
81
|
+
text="Operation failed, please retry."
|
|
82
|
+
confirmBtnText="Retry"
|
|
83
|
+
closeBtnText="Close"
|
|
84
|
+
onConfirm={() => handleRetry()}
|
|
85
|
+
onClose={() => setVisible(false)}
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 仅确认按钮
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<MessageBox
|
|
93
|
+
visible={visible}
|
|
94
|
+
title="Notice"
|
|
95
|
+
text="This is a notification."
|
|
96
|
+
hideCloseBtn={true}
|
|
97
|
+
confirmBtnText="Got it"
|
|
98
|
+
onConfirm={() => setVisible(false)}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 无按钮(点击遮罩关闭)
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<MessageBox
|
|
106
|
+
visible={visible}
|
|
107
|
+
title="Info"
|
|
108
|
+
text="Click backdrop to close."
|
|
109
|
+
hideFooter={true}
|
|
110
|
+
onVisibilityChange={setVisible}
|
|
111
|
+
/>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 注意事项
|
|
115
|
+
|
|
116
|
+
- 组件内部维护 `modalVisible` 状态,与外部 `visible` 同步
|
|
117
|
+
- 关闭优先级:`onClose` > `onVisibilityChange` > 内部 `setModalVisible(false)`
|
|
118
|
+
- 对话框固定宽度 392px,居中显示
|
|
119
|
+
- 需在 `ThemeProvider` 内使用
|
|
120
|
+
- 确认按钮使用主题 `primary` 色,取消按钮无背景色
|