@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,161 @@
|
|
|
1
|
+
# ThemeProvider
|
|
2
|
+
|
|
3
|
+
主题提供组件,基于 `@rneui/themed` 的 ThemeProvider 封装,为整个应用提供统一的设计令牌(Design Tokens)。包含颜色、间距、圆角、字体、阴影等完整的主题配置,为换肤功能做好预备。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 统一主题注入:colors、spacing、radius、fonts、elevation
|
|
8
|
+
- ✅ 支持 light / dark 模式切换(预留)
|
|
9
|
+
- ✅ 80+ 颜色令牌:涵盖文本、表面、边框、图标、状态、图表等
|
|
10
|
+
- ✅ 12 级间距系统(4px ~ 112px)
|
|
11
|
+
- ✅ 3 级圆角系统(mini: 4 / rounded: 12 / full: 360)
|
|
12
|
+
- ✅ 完整字体配置:5 级字号、5 级字重、行高、字间距
|
|
13
|
+
- ✅ 4 级阴影/elevation 系统
|
|
14
|
+
- ✅ Figma Design Token 对齐
|
|
15
|
+
- ✅ 中文字体支持(MiSans VF / PingFang SC)
|
|
16
|
+
- ✅ 组件级别主题覆盖(components.Button)
|
|
17
|
+
|
|
18
|
+
## 安装使用
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { TapasThemeProvider } from '@beppla/tapas-ui';
|
|
22
|
+
// 或
|
|
23
|
+
import ThemeProvider from '@beppla/tapas-ui/components/Theme/ThemeProvider';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## ThemeProvider Props
|
|
27
|
+
|
|
28
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
29
|
+
|------|------|--------|------|
|
|
30
|
+
| mode | `'light' \| 'dark'` | `'dark'` | 主题模式 |
|
|
31
|
+
| children | `React.ReactNode` | - | 子组件 |
|
|
32
|
+
| testID | `string` | - | 测试标识 |
|
|
33
|
+
|
|
34
|
+
## defaultTheme 函数
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { defaultTheme } from '@beppla/tapas-ui';
|
|
38
|
+
|
|
39
|
+
const theme = defaultTheme({ mode: 'dark' });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### ThemeOptions
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
interface ThemeOptions {
|
|
46
|
+
mode?: 'light' | 'dark';
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 主题令牌一览
|
|
51
|
+
|
|
52
|
+
### 颜色(theme.colors)
|
|
53
|
+
|
|
54
|
+
| 分类 | 主要令牌 | 示例 |
|
|
55
|
+
|------|---------|------|
|
|
56
|
+
| 基础色 | primary, secondary, background, white, black | `rgba(0,0,0,0.87)` |
|
|
57
|
+
| 灰阶 | grey0 ~ grey5, greyOutline | `rgba(0,0,0,0.04)` ~ `rgba(0,0,0,0.87)` |
|
|
58
|
+
| 语义色 | success, warning, error, info | `#57B07B`, `#B81F1E`, `#007AFF` |
|
|
59
|
+
| 文本色 | colorTextPrimary, colorTextSecondary, colorTextBrand, colorTextAccent | `#895F38`, `#F55523` |
|
|
60
|
+
| 表面色 | colorSurface ~ colorSurface11 | `#F9F2E8` ~ `rgba(255,255,255,0.30)` |
|
|
61
|
+
| 边框色 | colorPrimaryBorder, colorBorder1, colorBorder2, colorErrorBorder, colorActiveBorder | `rgba(0,0,0,0.12)` |
|
|
62
|
+
| 图标色 | colorNormalIcon, colorActiveIcon, colorDisabledIcon, colorAccentIcon | `#F55523` |
|
|
63
|
+
| 状态色 | colorStatusAvailable, colorStatusOccupied, colorStatusReserved 等 | `#57B07B`, `#B81F1E` |
|
|
64
|
+
| 图表色 | colorChartCategoryTeal, colorChartProductBrown 等 | `#1FBCAD`, `#895F38` |
|
|
65
|
+
|
|
66
|
+
### 间距(theme.spacing)
|
|
67
|
+
|
|
68
|
+
| 令牌 | 值 | Figma 别名 |
|
|
69
|
+
|------|------|-----------|
|
|
70
|
+
| tp2xs | 4 | spacing2xs |
|
|
71
|
+
| tpXs | 8 | spacingXs |
|
|
72
|
+
| tpSm | 12 | spacingSm |
|
|
73
|
+
| tpRg | 16 | spacingRg |
|
|
74
|
+
| tpMd | 24 | spacingMd |
|
|
75
|
+
| tpLg | 32 | spacingLg |
|
|
76
|
+
| tpXl | 48 | spacingXl |
|
|
77
|
+
| tp2xl | 88 | spacingBlg |
|
|
78
|
+
| tp3xl | 112 | spacingBlgger |
|
|
79
|
+
|
|
80
|
+
### 圆角(theme.radius)
|
|
81
|
+
|
|
82
|
+
| 令牌 | 值 | 用途 |
|
|
83
|
+
|------|------|------|
|
|
84
|
+
| mini | 4 | 卡片、标签 |
|
|
85
|
+
| rounded | 12 | 按钮、输入框 |
|
|
86
|
+
| full | 360 | 圆形头像、胶囊按钮 |
|
|
87
|
+
|
|
88
|
+
### 字体(theme.fonts)
|
|
89
|
+
|
|
90
|
+
| 令牌 | 值 | 说明 |
|
|
91
|
+
|------|------|------|
|
|
92
|
+
| fontFamily | `BricolageGrotesque-Regular` | 英文主字体 |
|
|
93
|
+
| fontFamilyCN | `MiSans VF` | 中文主字体 |
|
|
94
|
+
| h1 ~ h4 | 44 / 32 / 24 / 21 | 标题字号 |
|
|
95
|
+
| sizeL / sizeM / sizeS / sizeXs | 16 / 14 / 12 / 10 | 正文字号 |
|
|
96
|
+
| weightL / weightM / weightS / weightR | 700 / 600 / 500 / 400 | 字重 |
|
|
97
|
+
|
|
98
|
+
### 阴影(theme.elevation)
|
|
99
|
+
|
|
100
|
+
| 令牌 | shadowRadius | elevation | 场景 |
|
|
101
|
+
|------|-------------|-----------|------|
|
|
102
|
+
| e1 | 3 | 2 | 卡片 |
|
|
103
|
+
| e2 | 6 | 4 | 浮动按钮 |
|
|
104
|
+
| e3 | 12 | 8 | 弹窗 |
|
|
105
|
+
| e4 | 24 | 16 | 对话框 |
|
|
106
|
+
|
|
107
|
+
## 使用示例
|
|
108
|
+
|
|
109
|
+
### 应用根节点
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { TapasThemeProvider } from '@beppla/tapas-ui';
|
|
113
|
+
|
|
114
|
+
export default function App() {
|
|
115
|
+
return (
|
|
116
|
+
<TapasThemeProvider mode="dark">
|
|
117
|
+
<MainNavigator />
|
|
118
|
+
</TapasThemeProvider>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 在组件中使用主题
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { useTheme, makeStyles } from '@rneui/themed';
|
|
127
|
+
|
|
128
|
+
const MyComponent = () => {
|
|
129
|
+
const { theme } = useTheme();
|
|
130
|
+
return <View style={{ backgroundColor: theme.colors.background }} />;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// 或使用 makeStyles
|
|
134
|
+
const useStyles = makeStyles((theme) => ({
|
|
135
|
+
container: {
|
|
136
|
+
padding: theme.spacing.tpRg,
|
|
137
|
+
borderRadius: theme.radius.rounded,
|
|
138
|
+
},
|
|
139
|
+
}));
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Storybook 中使用
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
export const decorators = [
|
|
146
|
+
(Story) => (
|
|
147
|
+
<TapasThemeProvider mode="dark">
|
|
148
|
+
<Story />
|
|
149
|
+
</TapasThemeProvider>
|
|
150
|
+
),
|
|
151
|
+
];
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## 注意事项
|
|
155
|
+
|
|
156
|
+
- 当前 `light` 和 `dark` 模式使用相同的颜色值(darkColors = colors),待设计师确认后更新
|
|
157
|
+
- 所有 tapas-ui 组件都需要在 ThemeProvider 内使用
|
|
158
|
+
- 主题对象通过 `@rneui/themed` 的 `useTheme` / `makeStyles` / `withTheme` 消费
|
|
159
|
+
- `defaultTheme` 返回的是完整配置对象,不是 React 组件
|
|
160
|
+
- 字体文件需要在应用层加载(expo-font 或原生配置)
|
|
161
|
+
- 组件级覆盖目前仅配置了 Button 的默认样式
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeStyles = exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _ThemeProvider = require("@rneui/themed/dist/config/ThemeProvider");
|
|
10
|
+
/**
|
|
11
|
+
* React 19 compatible makeStyles
|
|
12
|
+
*
|
|
13
|
+
* Drop-in replacement for @rneui/themed's makeStyles.
|
|
14
|
+
* Uses useContext hook (safe in React 19) instead of relying on
|
|
15
|
+
* ThemeConsumer (Context.Consumer pattern).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const makeStyles = styles => {
|
|
19
|
+
return (props = {}) => {
|
|
20
|
+
const context = (0, _react.useContext)(_ThemeProvider.ThemeContext);
|
|
21
|
+
const theme = context?.theme;
|
|
22
|
+
return (0, _react.useMemo)(() => {
|
|
23
|
+
const css = typeof styles === 'function' ? styles(theme, props) : styles;
|
|
24
|
+
return _reactNative.StyleSheet.create(css);
|
|
25
|
+
}, [props, theme]);
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.makeStyles = makeStyles;
|
|
29
|
+
var _default = exports.default = makeStyles;
|
|
30
|
+
//# sourceMappingURL=makeStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_ThemeProvider","makeStyles","styles","props","context","useContext","ThemeContext","theme","useMemo","css","StyleSheet","create","exports","_default","default"],"sourceRoot":"../../../components","sources":["Theme/makeStyles.ts"],"mappings":";;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQO,MAAMG,UAAU,GACrBC,MAA0C,IACvC;EACH,OAAO,CAACC,KAAQ,GAAG,CAAC,CAAM,KAAK;IAC7B,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACC,2BAAY,CAAC;IACxC,MAAMC,KAAK,GAAIH,OAAO,EAAUG,KAAU;IAE1C,OAAO,IAAAC,cAAO,EAAC,MAAM;MACnB,MAAMC,GAAG,GAAG,OAAOP,MAAM,KAAK,UAAU,GACnCA,MAAM,CAAyBK,KAAK,EAAEJ,KAAK,CAAC,GAC7CD,MAAM;MACV,OAAOQ,uBAAU,CAACC,MAAM,CAACF,GAAG,CAAC;IAC/B,CAAC,EAAE,CAACN,KAAK,EAAEI,KAAK,CAAC,CAAC;EACpB,CAAC;AACH,CAAC;AAACK,OAAA,CAAAX,UAAA,GAAAA,UAAA;AAAA,IAAAY,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAEab,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.withTheme = withTheme;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
10
|
+
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
11
|
+
var _ThemeProvider = require("@rneui/themed/dist/config/ThemeProvider");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
/**
|
|
16
|
+
* React 19 compatible withTheme HOC
|
|
17
|
+
*
|
|
18
|
+
* Replaces @rneui/themed's withTheme which uses Context.Consumer (render props pattern)
|
|
19
|
+
* that crashes in React 19. This version uses useContext hook instead.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// @ts-ignore -- hoist-non-react-statics has no type declarations in this project
|
|
23
|
+
|
|
24
|
+
const isClassComponent = Component => Boolean(Component?.prototype?.isReactComponent);
|
|
25
|
+
const combineByStyles = (propName = '') => {
|
|
26
|
+
if (propName.endsWith('Style') || propName.endsWith('style')) {
|
|
27
|
+
return (prop1, prop2) => [prop1, prop2].flat();
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
};
|
|
31
|
+
const ThemedComponent = (WrappedComponent, themeKey, displayName) => {
|
|
32
|
+
const Component = (props, forwardedRef) => {
|
|
33
|
+
const {
|
|
34
|
+
children,
|
|
35
|
+
...rest
|
|
36
|
+
} = props;
|
|
37
|
+
const context = (0, _react.useContext)(_ThemeProvider.ThemeContext);
|
|
38
|
+
const {
|
|
39
|
+
theme,
|
|
40
|
+
updateTheme,
|
|
41
|
+
replaceTheme
|
|
42
|
+
} = context;
|
|
43
|
+
if (!theme) {
|
|
44
|
+
const newProps = {
|
|
45
|
+
...rest,
|
|
46
|
+
theme: {
|
|
47
|
+
colors: {},
|
|
48
|
+
spacing: {}
|
|
49
|
+
},
|
|
50
|
+
children
|
|
51
|
+
};
|
|
52
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
|
|
53
|
+
ref: forwardedRef,
|
|
54
|
+
...newProps
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const themeObj = theme;
|
|
58
|
+
const {
|
|
59
|
+
components: comps,
|
|
60
|
+
...restTheme
|
|
61
|
+
} = themeObj;
|
|
62
|
+
const themedProps = typeof comps?.[themeKey] === 'function' ? comps[themeKey](rest, restTheme) : comps?.[themeKey];
|
|
63
|
+
const merged = (0, _deepmerge.default)(themedProps || {}, rest, {
|
|
64
|
+
customMerge: combineByStyles,
|
|
65
|
+
clone: false
|
|
66
|
+
});
|
|
67
|
+
const newProps = {
|
|
68
|
+
theme: restTheme,
|
|
69
|
+
updateTheme,
|
|
70
|
+
replaceTheme,
|
|
71
|
+
...merged,
|
|
72
|
+
children
|
|
73
|
+
};
|
|
74
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
|
|
75
|
+
ref: forwardedRef,
|
|
76
|
+
...newProps
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
Component.displayName = displayName;
|
|
80
|
+
return Component;
|
|
81
|
+
};
|
|
82
|
+
function withTheme(WrappedComponent, themeKey) {
|
|
83
|
+
const name = themeKey ? `Themed.${themeKey}` : `Themed.${WrappedComponent.displayName || WrappedComponent.name || 'Component'}`;
|
|
84
|
+
const Component = ThemedComponent(WrappedComponent, themeKey, name);
|
|
85
|
+
if (isClassComponent(WrappedComponent)) {
|
|
86
|
+
return (0, _hoistNonReactStatics.default)(/*#__PURE__*/(0, _react.forwardRef)(Component), WrappedComponent);
|
|
87
|
+
}
|
|
88
|
+
return /*#__PURE__*/(0, _react.forwardRef)(Component);
|
|
89
|
+
}
|
|
90
|
+
var _default = exports.default = withTheme;
|
|
91
|
+
//# sourceMappingURL=withTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_deepmerge","_interopRequireDefault","_hoistNonReactStatics","_ThemeProvider","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","isClassComponent","Component","Boolean","prototype","isReactComponent","combineByStyles","propName","endsWith","prop1","prop2","flat","undefined","ThemedComponent","WrappedComponent","themeKey","displayName","props","forwardedRef","children","rest","context","useContext","ThemeContext","theme","updateTheme","replaceTheme","newProps","colors","spacing","jsx","ref","themeObj","components","comps","restTheme","themedProps","merged","deepmerge","customMerge","clone","withTheme","name","hoistNonReactStatics","forwardRef","_default","exports"],"sourceRoot":"../../../components","sources":["Theme/withTheme.tsx"],"mappings":";;;;;;;AAMA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,qBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAAuE,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAO,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAS,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAG,CAAA,OAAAK,CAAA,CAAAI,GAAA,IAAAJ,CAAA,CAAAK,GAAA,IAAAN,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AAA2C,QAAA,GAAAC,OAAA,CAAA9D,OAAA,GAEcyD,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Timeline
|
|
2
|
+
|
|
3
|
+
时间线组件,用于展示按时间排列的事件或活动列表。每个事件节点包含时间和描述,支持多种状态(选中、禁用、错误),并提供 Hover 交互效果和点击回调。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 纵向时间线布局,节点 + 连接线
|
|
8
|
+
- ✅ 四种节点状态:默认、selected(选中)、disabled(禁用)、error(错误)
|
|
9
|
+
- ✅ 状态对应不同的颜色和线条样式(实线/虚线)
|
|
10
|
+
- ✅ 错误状态显示警告图标
|
|
11
|
+
- ✅ Hover 高亮效果(Hoverable 组件)
|
|
12
|
+
- ✅ 支持点击事件回调
|
|
13
|
+
- ✅ 标题 + 滚动内容区域
|
|
14
|
+
- ✅ 自定义容器和内容区域样式
|
|
15
|
+
- ✅ 主题色适配
|
|
16
|
+
|
|
17
|
+
## 安装使用
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { Timeline } from '@beppla/tapas-ui';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
26
|
+
|------|------|--------|------|
|
|
27
|
+
| data | `IData` | - | 时间线数据(必填) |
|
|
28
|
+
| itemContainerStyle | `StyleProp<ViewStyle>` | - | 事件列表容器样式(必填) |
|
|
29
|
+
| onPress | `(item: Item) => void` | - | 事件项点击回调 |
|
|
30
|
+
| selected | `boolean` | `false` | 全局选中状态(预留) |
|
|
31
|
+
| disabled | `boolean` | - | 全局禁用状态(预留) |
|
|
32
|
+
| containerStyle | `StyleProp<ViewStyle>` | - | 最外层容器样式 |
|
|
33
|
+
| testID | `string` | - | 测试标识 |
|
|
34
|
+
|
|
35
|
+
### IData
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
interface IData {
|
|
39
|
+
title: string;
|
|
40
|
+
items: Item[];
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Item
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
interface Item {
|
|
48
|
+
id: string;
|
|
49
|
+
time: string;
|
|
50
|
+
description: string;
|
|
51
|
+
selected?: boolean;
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
error?: boolean;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 使用示例
|
|
58
|
+
|
|
59
|
+
### 基础用法
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
const data = {
|
|
63
|
+
title: 'Order History',
|
|
64
|
+
items: [
|
|
65
|
+
{ id: '1', time: '09:00', description: 'Order placed', selected: true },
|
|
66
|
+
{ id: '2', time: '10:30', description: 'Payment confirmed' },
|
|
67
|
+
{ id: '3', time: '14:00', description: 'Shipped' },
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
<Timeline
|
|
72
|
+
data={data}
|
|
73
|
+
itemContainerStyle={{ minHeight: 200 }}
|
|
74
|
+
onPress={(item) => console.log('Clicked:', item.id)}
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 错误状态
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
const data = {
|
|
82
|
+
title: 'Delivery Status',
|
|
83
|
+
items: [
|
|
84
|
+
{ id: '1', time: '08:00', description: 'Dispatched', selected: true },
|
|
85
|
+
{ id: '2', time: '12:00', description: 'Delivery failed', error: true },
|
|
86
|
+
{ id: '3', time: '15:00', description: 'Rescheduled', disabled: true },
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
<Timeline data={data} itemContainerStyle={{ minHeight: 300 }} />
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 自定义样式
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<Timeline
|
|
97
|
+
data={data}
|
|
98
|
+
itemContainerStyle={{ minHeight: 400 }}
|
|
99
|
+
containerStyle={{ width: 300, backgroundColor: '#FFF' }}
|
|
100
|
+
onPress={handleItemPress}
|
|
101
|
+
/>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 注意事项
|
|
105
|
+
|
|
106
|
+
- 容器默认宽度 192px,可通过 `containerStyle` 覆盖
|
|
107
|
+
- 事件列表在 ScrollView 内,支持滚动
|
|
108
|
+
- Hover 效果基于 Hoverable 组件实现,仅在 Web 端生效
|
|
109
|
+
- 连接线在 `disabled` 状态下为虚线样式
|
|
110
|
+
- 节点状态在 item 级别控制(item.selected / item.disabled / item.error)
|
|
111
|
+
- 需在 `ThemeProvider` 内使用
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
轻量级消息提示组件,用于显示临时通知。支持自动消失、多种状态类型、描述文本和操作按钮,适合操作反馈场景。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 支持 Success、Error、Warning、Info 四种类型
|
|
8
|
+
- ✅ 自动消失机制,可自定义持续时间(duration)
|
|
9
|
+
- ✅ 支持副标题/描述文本(description)
|
|
10
|
+
- ✅ 支持操作按钮(actionText + onActionPress)
|
|
11
|
+
- ✅ 不同状态自动匹配对应图标和颜色
|
|
12
|
+
- ✅ Web/移动端自适应最大宽度
|
|
13
|
+
- ✅ 通过 visible 控制显示/隐藏
|
|
14
|
+
- ✅ 主题色适配
|
|
15
|
+
|
|
16
|
+
## 安装使用
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { Toast } from '@beppla/tapas-ui';
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Props
|
|
23
|
+
|
|
24
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
25
|
+
|------|------|--------|------|
|
|
26
|
+
| visible | `boolean` | `false` | 是否显示(必填) |
|
|
27
|
+
| message | `string` | - | 消息文本(必填) |
|
|
28
|
+
| duration | `number` | `2000` | 自动消失时间(毫秒) |
|
|
29
|
+
| type | `'Error' \| 'Warning' \| 'Success' \| 'Info'` | `'Info'` | 消息类型 |
|
|
30
|
+
| description | `string` | - | 描述/副标题文本 |
|
|
31
|
+
| actionText | `string` | - | 操作按钮文本 |
|
|
32
|
+
| onActionPress | `() => void` | - | 操作按钮点击回调 |
|
|
33
|
+
| hideToast | `() => void` | - | 隐藏 Toast 的回调 |
|
|
34
|
+
| style | `any` | - | 自定义外层样式 |
|
|
35
|
+
|
|
36
|
+
## 使用示例
|
|
37
|
+
|
|
38
|
+
### 基础用法
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
const [visible, setVisible] = useState(false);
|
|
42
|
+
|
|
43
|
+
<Toast
|
|
44
|
+
visible={visible}
|
|
45
|
+
message="Operation successful"
|
|
46
|
+
type="Success"
|
|
47
|
+
hideToast={() => setVisible(false)}
|
|
48
|
+
/>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 带描述文本
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<Toast
|
|
55
|
+
visible={true}
|
|
56
|
+
message="Order created"
|
|
57
|
+
description="Order #12345 has been placed"
|
|
58
|
+
type="Info"
|
|
59
|
+
duration={3000}
|
|
60
|
+
hideToast={() => setVisible(false)}
|
|
61
|
+
/>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 带操作按钮
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<Toast
|
|
68
|
+
visible={true}
|
|
69
|
+
message="Item deleted"
|
|
70
|
+
type="Warning"
|
|
71
|
+
actionText="Undo"
|
|
72
|
+
onActionPress={() => handleUndo()}
|
|
73
|
+
hideToast={() => setVisible(false)}
|
|
74
|
+
/>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 错误提示
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
<Toast
|
|
81
|
+
visible={true}
|
|
82
|
+
message="Network error"
|
|
83
|
+
description="Please check your connection"
|
|
84
|
+
type="Error"
|
|
85
|
+
duration={5000}
|
|
86
|
+
hideToast={() => setVisible(false)}
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 注意事项
|
|
91
|
+
|
|
92
|
+
- `visible` 变为 `true` 时启动定时器,到时自动调用 `hideToast`
|
|
93
|
+
- 外部需自行管理 `visible` 状态,组件本身不维护显隐
|
|
94
|
+
- 类型名称首字母大写:`'Success'`、`'Error'`、`'Warning'`、`'Info'`
|
|
95
|
+
- Web 端最大宽度 450px,移动端最大宽度 375px
|
|
96
|
+
- 有 `actionText` 时容器会自动拉伸(flex: 1)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _themed = require("@rneui/themed");
|
|
10
|
+
var _TapasIcon = _interopRequireDefault(require("../Icons/TapasIcon"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const TapasUpload = ({
|
|
14
|
+
onFileSelect,
|
|
15
|
+
attachSelectedFile,
|
|
16
|
+
btnText = 'Upload',
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
accept,
|
|
20
|
+
disabled = false,
|
|
21
|
+
testID,
|
|
22
|
+
containerStyle
|
|
23
|
+
}) => {
|
|
24
|
+
const styles = useStyles();
|
|
25
|
+
const uniqueId = `fileInput-${Math.random().toString(36).substr(2, 9)}`;
|
|
26
|
+
const handleFile = onFileSelect ?? attachSelectedFile;
|
|
27
|
+
const handleSelectFile = () => {
|
|
28
|
+
if (disabled) return;
|
|
29
|
+
if (_reactNative.Platform.OS === 'web') {
|
|
30
|
+
document.getElementById(uniqueId)?.click();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const handleFileInputChange = event => {
|
|
34
|
+
const selectedFile = event.target.files[0];
|
|
35
|
+
if (selectedFile && handleFile) {
|
|
36
|
+
handleFile(selectedFile);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const handleDrop = event => {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
if (disabled) return;
|
|
42
|
+
const files = event.dataTransfer.files;
|
|
43
|
+
if (files?.length > 0 && handleFile) {
|
|
44
|
+
handleFile(files[0]);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
48
|
+
testID: testID,
|
|
49
|
+
onPress: handleSelectFile,
|
|
50
|
+
style: [styles.container, width != null && {
|
|
51
|
+
width
|
|
52
|
+
}, height != null && {
|
|
53
|
+
height
|
|
54
|
+
}, disabled && styles.disabled, containerStyle],
|
|
55
|
+
children: _reactNative.Platform.OS === 'web' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
56
|
+
style: {
|
|
57
|
+
display: 'flex',
|
|
58
|
+
flexDirection: 'row',
|
|
59
|
+
justifyContent: 'center',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
width: '100%',
|
|
62
|
+
height: '100%',
|
|
63
|
+
gap: 8
|
|
64
|
+
},
|
|
65
|
+
onDragEnter: e => e.preventDefault(),
|
|
66
|
+
onDragOver: e => e.preventDefault(),
|
|
67
|
+
onDragLeave: e => e.preventDefault(),
|
|
68
|
+
onDrop: handleDrop,
|
|
69
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
70
|
+
type: "file",
|
|
71
|
+
id: uniqueId,
|
|
72
|
+
accept: accept,
|
|
73
|
+
style: {
|
|
74
|
+
display: 'none'
|
|
75
|
+
},
|
|
76
|
+
onChange: handleFileInputChange
|
|
77
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TapasIcon.default, {
|
|
78
|
+
size: 20,
|
|
79
|
+
color: styles.icon.color,
|
|
80
|
+
name: "upload"
|
|
81
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
82
|
+
style: styles.text,
|
|
83
|
+
children: btnText
|
|
84
|
+
})]
|
|
85
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
86
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TapasIcon.default, {
|
|
87
|
+
size: 20,
|
|
88
|
+
color: styles.icon.color,
|
|
89
|
+
name: "upload"
|
|
90
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
91
|
+
style: styles.text,
|
|
92
|
+
children: btnText
|
|
93
|
+
})]
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const useStyles = (0, _themed.makeStyles)(theme => ({
|
|
98
|
+
container: {
|
|
99
|
+
display: 'flex',
|
|
100
|
+
flexDirection: 'row',
|
|
101
|
+
height: 48,
|
|
102
|
+
borderStyle: 'dashed',
|
|
103
|
+
borderWidth: 1,
|
|
104
|
+
borderColor: theme.colors.grey2,
|
|
105
|
+
borderRadius: 12,
|
|
106
|
+
flexGrow: 1,
|
|
107
|
+
overflow: 'hidden',
|
|
108
|
+
justifyContent: 'center',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
gap: 8,
|
|
111
|
+
paddingHorizontal: 16
|
|
112
|
+
},
|
|
113
|
+
disabled: {
|
|
114
|
+
opacity: 0.5
|
|
115
|
+
},
|
|
116
|
+
icon: {
|
|
117
|
+
color: theme.colors.grey2
|
|
118
|
+
},
|
|
119
|
+
text: {
|
|
120
|
+
fontSize: 12,
|
|
121
|
+
fontWeight: '400',
|
|
122
|
+
color: theme.colors.secondary
|
|
123
|
+
}
|
|
124
|
+
}));
|
|
125
|
+
var _default = exports.default = (0, _themed.withTheme)(/*#__PURE__*/_react.default.memo(TapasUpload));
|
|
126
|
+
//# sourceMappingURL=Upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_themed","_TapasIcon","_jsxRuntime","e","__esModule","default","TapasUpload","onFileSelect","attachSelectedFile","btnText","width","height","accept","disabled","testID","containerStyle","styles","useStyles","uniqueId","Math","random","toString","substr","handleFile","handleSelectFile","Platform","OS","document","getElementById","click","handleFileInputChange","event","selectedFile","target","files","handleDrop","preventDefault","dataTransfer","length","jsx","Pressable","onPress","style","container","children","jsxs","display","flexDirection","justifyContent","alignItems","gap","onDragEnter","onDragOver","onDragLeave","onDrop","type","id","onChange","size","color","icon","name","Text","text","Fragment","makeStyles","theme","borderStyle","borderWidth","borderColor","colors","grey2","borderRadius","flexGrow","overflow","paddingHorizontal","opacity","fontSize","fontWeight","secondary","_default","exports","withTheme","React","memo"],"sourceRoot":"../../../components","sources":["Upload/Upload.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAA2C,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAuB3C,MAAMG,WAAuC,GAAGA,CAAC;EAC/CC,YAAY;EACZC,kBAAkB;EAClBC,OAAO,GAAG,QAAQ;EAClBC,KAAK;EACLC,MAAM;EACNC,MAAM;EACNC,QAAQ,GAAG,KAAK;EAChBC,MAAM;EACNC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGC,SAAS,CAAC,CAAC;EAC1B,MAA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