@beppla/tapas-ui 1.2.36 → 1.4.0
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/components/StatisticsTable/StatisticsTable.tsx +721 -430
- package/components/Theme/defaultTheme.ts +2 -0
- package/package/commonjs/StatisticsTable/StatisticsTable.js +714 -437
- package/package/commonjs/StatisticsTable/StatisticsTable.js.map +1 -1
- package/package/commonjs/Theme/defaultTheme.js +6 -2
- package/package/commonjs/Theme/defaultTheme.js.map +1 -1
- package/package/module/StatisticsTable/StatisticsTable.js +708 -431
- package/package/module/StatisticsTable/StatisticsTable.js.map +1 -1
- package/package/module/Theme/defaultTheme.js +6 -2
- package/package/module/Theme/defaultTheme.js.map +1 -1
- package/package/package.json +1 -1
- package/package/typescript/StatisticsTable/StatisticsTable.d.ts +53 -3
- package/package/typescript/StatisticsTable/StatisticsTable.d.ts.map +1 -1
- package/package/typescript/Theme/defaultTheme.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useMemo, useCallback, useState, useRef } from 'react';
|
|
4
|
-
import { View, ScrollView, StyleSheet, Platform, TouchableOpacity } from 'react-native';
|
|
5
|
-
import
|
|
3
|
+
import React, { useMemo, useCallback, useState, useRef, useEffect } from 'react';
|
|
4
|
+
import { View, ScrollView, StyleSheet, Platform, TouchableOpacity, Text, Animated } from 'react-native';
|
|
5
|
+
import { useTheme } from '@rneui/themed';
|
|
6
6
|
import Pagination from '../Pagination/Pagination';
|
|
7
|
+
import Hoverable from '../Hoverable/Hoverable';
|
|
8
|
+
|
|
9
|
+
// Tooltip 内容类型
|
|
7
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
// Tooltip 组件
|
|
12
|
+
const CellTooltip = ({
|
|
13
|
+
visible,
|
|
14
|
+
content,
|
|
15
|
+
style
|
|
16
|
+
}) => {
|
|
17
|
+
if (!visible || !content) return null;
|
|
18
|
+
return /*#__PURE__*/_jsx(View, {
|
|
19
|
+
style: [tooltipStyles.container, style],
|
|
20
|
+
children: content.customContent ? content.customContent : /*#__PURE__*/_jsxs(_Fragment, {
|
|
21
|
+
children: [content.title && /*#__PURE__*/_jsx(Text, {
|
|
22
|
+
style: tooltipStyles.title,
|
|
23
|
+
children: content.title
|
|
24
|
+
}), content.subtitle && /*#__PURE__*/_jsx(Text, {
|
|
25
|
+
style: tooltipStyles.subtitle,
|
|
26
|
+
children: content.subtitle
|
|
27
|
+
}), content.items?.map((item, index) => /*#__PURE__*/_jsxs(View, {
|
|
28
|
+
style: tooltipStyles.row,
|
|
29
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
30
|
+
style: tooltipStyles.label,
|
|
31
|
+
children: item.label
|
|
32
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
33
|
+
style: tooltipStyles.value,
|
|
34
|
+
children: item.value
|
|
35
|
+
})]
|
|
36
|
+
}, index))]
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const tooltipStyles = StyleSheet.create({
|
|
41
|
+
container: {
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
backgroundColor: '#FFF',
|
|
44
|
+
borderRadius: 8,
|
|
45
|
+
padding: 12,
|
|
46
|
+
shadowColor: '#000',
|
|
47
|
+
shadowOffset: {
|
|
48
|
+
width: 0,
|
|
49
|
+
height: 2
|
|
50
|
+
},
|
|
51
|
+
shadowOpacity: 0.15,
|
|
52
|
+
shadowRadius: 8,
|
|
53
|
+
elevation: 5,
|
|
54
|
+
zIndex: 100,
|
|
55
|
+
minWidth: 150
|
|
56
|
+
},
|
|
57
|
+
title: {
|
|
58
|
+
fontSize: 14,
|
|
59
|
+
fontWeight: '600',
|
|
60
|
+
color: 'rgba(0, 0, 0, 0.87)',
|
|
61
|
+
marginBottom: 4
|
|
62
|
+
},
|
|
63
|
+
subtitle: {
|
|
64
|
+
fontSize: 12,
|
|
65
|
+
color: 'rgba(0, 0, 0, 0.54)',
|
|
66
|
+
marginBottom: 8
|
|
67
|
+
},
|
|
68
|
+
row: {
|
|
69
|
+
flexDirection: 'row',
|
|
70
|
+
justifyContent: 'space-between',
|
|
71
|
+
marginTop: 4
|
|
72
|
+
},
|
|
73
|
+
label: {
|
|
74
|
+
fontSize: 12,
|
|
75
|
+
color: 'rgba(0, 0, 0, 0.54)'
|
|
76
|
+
},
|
|
77
|
+
value: {
|
|
78
|
+
fontSize: 12,
|
|
79
|
+
fontWeight: '600',
|
|
80
|
+
color: 'rgba(0, 0, 0, 0.87)'
|
|
81
|
+
}
|
|
82
|
+
});
|
|
8
83
|
export function StatisticsTable({
|
|
9
84
|
rows,
|
|
10
85
|
columns,
|
|
@@ -27,20 +102,164 @@ export function StatisticsTable({
|
|
|
27
102
|
getRowHeight,
|
|
28
103
|
getColumnWidth,
|
|
29
104
|
enableScrollShadow = true,
|
|
30
|
-
|
|
31
|
-
|
|
105
|
+
showScrollIndicator = false,
|
|
106
|
+
statsColumnWidth = 100,
|
|
107
|
+
onCellHover,
|
|
108
|
+
renderCellTooltip,
|
|
109
|
+
renderRowStatsTooltip,
|
|
110
|
+
renderColumnStatsTooltip,
|
|
111
|
+
rowStatsHeaders = {
|
|
112
|
+
sum: 'Sum (€)',
|
|
113
|
+
mean: 'Mean (€)'
|
|
114
|
+
},
|
|
115
|
+
columnStatsLabels = {
|
|
116
|
+
sum: 'Sum',
|
|
117
|
+
mean: 'Mean'
|
|
118
|
+
},
|
|
119
|
+
headerStyle,
|
|
120
|
+
rowStatsHeaderStyle,
|
|
121
|
+
columnStatsLabelStyle,
|
|
122
|
+
enableStatsAnimation = true,
|
|
123
|
+
statsAnimationDuration = 300
|
|
32
124
|
}) {
|
|
125
|
+
const {
|
|
126
|
+
theme
|
|
127
|
+
} = useTheme();
|
|
128
|
+
const colors = theme.colors;
|
|
129
|
+
|
|
130
|
+
// 动画值
|
|
131
|
+
const rowStatsAnimation = useRef(new Animated.Value(0)).current;
|
|
132
|
+
const columnStatsAnimation = useRef(new Animated.Value(0)).current;
|
|
133
|
+
|
|
33
134
|
// 滚动状态
|
|
34
|
-
const [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
const [verticalScrollState, setVerticalScrollState] = useState({
|
|
135
|
+
const [scrollState, setScrollState] = useState({
|
|
136
|
+
left: 0,
|
|
137
|
+
top: 0,
|
|
39
138
|
isAtStart: true,
|
|
40
|
-
isAtEnd: false
|
|
139
|
+
isAtEnd: false,
|
|
140
|
+
isAtTop: true,
|
|
141
|
+
isAtBottom: false
|
|
41
142
|
});
|
|
42
|
-
|
|
43
|
-
|
|
143
|
+
|
|
144
|
+
// Hover 状态
|
|
145
|
+
const [hoveredCell, setHoveredCell] = useState(null);
|
|
146
|
+
const scrollViewRef = useRef(null);
|
|
147
|
+
const bodyScrollViewRef = useRef(null);
|
|
148
|
+
const rowStatsScrollRef = useRef(null);
|
|
149
|
+
|
|
150
|
+
// Column stats 和 Row stats 是互斥的,columnStats 优先
|
|
151
|
+
const actualShowColumnStats = showColumnStats;
|
|
152
|
+
const actualShowRowStats = showRowStats && !showColumnStats;
|
|
153
|
+
|
|
154
|
+
// Row Stats 动画效果
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (enableStatsAnimation && actualShowRowStats) {
|
|
157
|
+
Animated.timing(rowStatsAnimation, {
|
|
158
|
+
toValue: 1,
|
|
159
|
+
duration: statsAnimationDuration,
|
|
160
|
+
useNativeDriver: true
|
|
161
|
+
}).start();
|
|
162
|
+
} else {
|
|
163
|
+
rowStatsAnimation.setValue(actualShowRowStats ? 1 : 0);
|
|
164
|
+
}
|
|
165
|
+
}, [actualShowRowStats, enableStatsAnimation, statsAnimationDuration, rowStatsAnimation]);
|
|
166
|
+
|
|
167
|
+
// Column Stats 动画效果
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (enableStatsAnimation && actualShowColumnStats) {
|
|
170
|
+
Animated.timing(columnStatsAnimation, {
|
|
171
|
+
toValue: 1,
|
|
172
|
+
duration: statsAnimationDuration,
|
|
173
|
+
useNativeDriver: true
|
|
174
|
+
}).start();
|
|
175
|
+
} else {
|
|
176
|
+
columnStatsAnimation.setValue(actualShowColumnStats ? 1 : 0);
|
|
177
|
+
}
|
|
178
|
+
}, [actualShowColumnStats, enableStatsAnimation, statsAnimationDuration, columnStatsAnimation]);
|
|
179
|
+
|
|
180
|
+
// 动态样式 - 根据设计图
|
|
181
|
+
const themedStyles = useMemo(() => ({
|
|
182
|
+
container: {
|
|
183
|
+
backgroundColor: colors.colorSurface // 米色背景
|
|
184
|
+
},
|
|
185
|
+
header: {
|
|
186
|
+
backgroundColor: headerStyle?.backgroundColor || colors.colorSurface,
|
|
187
|
+
// 米色
|
|
188
|
+
borderBottomColor: colors.colorTableBorder
|
|
189
|
+
},
|
|
190
|
+
headerCell: {
|
|
191
|
+
borderRightColor: colors.colorTableBorder
|
|
192
|
+
},
|
|
193
|
+
headerText: {
|
|
194
|
+
color: headerStyle?.textColor || colors.colorTextPrimary,
|
|
195
|
+
fontSize: headerStyle?.fontSize || 14,
|
|
196
|
+
fontWeight: headerStyle?.fontWeight || '500'
|
|
197
|
+
},
|
|
198
|
+
// Row Stats 表头样式
|
|
199
|
+
statsHeaderCell: {
|
|
200
|
+
backgroundColor: rowStatsHeaderStyle?.backgroundColor || 'rgba(0, 0, 0, 0.08)',
|
|
201
|
+
borderRightColor: colors.colorTableBorder,
|
|
202
|
+
borderBottomColor: colors.colorTableBorder
|
|
203
|
+
},
|
|
204
|
+
statsHeaderText: {
|
|
205
|
+
color: rowStatsHeaderStyle?.textColor || colors.colorTextPrimary,
|
|
206
|
+
fontSize: rowStatsHeaderStyle?.fontSize || 14,
|
|
207
|
+
fontWeight: rowStatsHeaderStyle?.fontWeight || '500'
|
|
208
|
+
},
|
|
209
|
+
// 数据行
|
|
210
|
+
row: {
|
|
211
|
+
borderBottomColor: colors.colorTableBorder,
|
|
212
|
+
backgroundColor: colors.colorSurface // 米色
|
|
213
|
+
},
|
|
214
|
+
// Hover 行
|
|
215
|
+
rowHovered: {
|
|
216
|
+
backgroundColor: colors.colorSurface1 // 白色
|
|
217
|
+
},
|
|
218
|
+
// Hover 单元格 - rgba(0, 0, 0, 0.08)
|
|
219
|
+
cellHovered: {
|
|
220
|
+
backgroundColor: 'rgba(0, 0, 0, 0.08)'
|
|
221
|
+
},
|
|
222
|
+
// Column Stats 行(Sum/Mean)- 纯白色背景
|
|
223
|
+
columnStatsRow: {
|
|
224
|
+
backgroundColor: '#FFFFFF',
|
|
225
|
+
// 纯白色
|
|
226
|
+
borderBottomColor: colors.colorTableBorder
|
|
227
|
+
},
|
|
228
|
+
// Row Stats 列 - 白色背景
|
|
229
|
+
rowStatsCell: {
|
|
230
|
+
backgroundColor: colors.colorSurface1,
|
|
231
|
+
// 白色
|
|
232
|
+
borderBottomColor: colors.colorTableBorder,
|
|
233
|
+
borderRightColor: colors.colorTableBorder
|
|
234
|
+
},
|
|
235
|
+
cell: {
|
|
236
|
+
borderRightColor: colors.colorTableBorder
|
|
237
|
+
},
|
|
238
|
+
rowLabel: {
|
|
239
|
+
color: colors.colorTextPrimary
|
|
240
|
+
},
|
|
241
|
+
cellQuantity: {
|
|
242
|
+
color: colors.colorTextPrimary
|
|
243
|
+
},
|
|
244
|
+
cellAmount: {
|
|
245
|
+
color: colors.colorTextSecondary
|
|
246
|
+
},
|
|
247
|
+
statsLabel: {
|
|
248
|
+
color: columnStatsLabelStyle?.textColor || colors.colorTextBrand,
|
|
249
|
+
// 棕色
|
|
250
|
+
fontSize: columnStatsLabelStyle?.fontSize || 14,
|
|
251
|
+
fontWeight: columnStatsLabelStyle?.fontWeight || '600'
|
|
252
|
+
},
|
|
253
|
+
paginationContainer: {
|
|
254
|
+
borderTopColor: colors.colorTableBorder,
|
|
255
|
+
backgroundColor: colors.colorSurface
|
|
256
|
+
},
|
|
257
|
+
// Column Stats 分隔线
|
|
258
|
+
columnStatsDivider: {
|
|
259
|
+
borderTopWidth: 2,
|
|
260
|
+
borderTopColor: colors.colorTableBorder
|
|
261
|
+
}
|
|
262
|
+
}), [colors, headerStyle, rowStatsHeaderStyle, columnStatsLabelStyle]);
|
|
44
263
|
|
|
45
264
|
// 构建矩阵数据
|
|
46
265
|
const matrix = useMemo(() => {
|
|
@@ -60,34 +279,30 @@ export function StatisticsTable({
|
|
|
60
279
|
return data;
|
|
61
280
|
}, [rows, columns, cells]);
|
|
62
281
|
|
|
63
|
-
//
|
|
282
|
+
// 计算行统计
|
|
64
283
|
const rowStats = useMemo(() => {
|
|
65
284
|
if (!showRowStats) return null;
|
|
66
285
|
return rows.map(row => {
|
|
67
|
-
const rowCells = columns.filter(col => !col.isAction)
|
|
68
|
-
.map(col => matrix[row.key]?.[col.key] || {
|
|
286
|
+
const rowCells = columns.filter(col => !col.isAction).map(col => matrix[row.key]?.[col.key] || {
|
|
69
287
|
quantity: 0,
|
|
70
288
|
amount: 0
|
|
71
289
|
});
|
|
72
290
|
const sumQuantity = rowCells.reduce((sum, cell) => sum + cell.quantity, 0);
|
|
73
291
|
const sumAmount = rowCells.reduce((sum, cell) => sum + cell.amount, 0);
|
|
74
292
|
const count = rowCells.length || 1;
|
|
75
|
-
const meanQuantity = sumQuantity / count;
|
|
76
|
-
const meanAmount = sumAmount / count;
|
|
77
293
|
return {
|
|
78
294
|
sumQuantity,
|
|
79
295
|
sumAmount,
|
|
80
|
-
meanQuantity,
|
|
81
|
-
meanAmount
|
|
296
|
+
meanQuantity: sumQuantity / count,
|
|
297
|
+
meanAmount: sumAmount / count
|
|
82
298
|
};
|
|
83
299
|
});
|
|
84
300
|
}, [rows, columns, matrix, showRowStats]);
|
|
85
301
|
|
|
86
|
-
//
|
|
302
|
+
// 计算列统计
|
|
87
303
|
const columnStats = useMemo(() => {
|
|
88
304
|
if (!showColumnStats) return null;
|
|
89
|
-
return columns.filter(col => !col.isAction)
|
|
90
|
-
.map(col => {
|
|
305
|
+
return columns.filter(col => !col.isAction).map(col => {
|
|
91
306
|
const colCells = rows.map(row => matrix[row.key]?.[col.key] || {
|
|
92
307
|
quantity: 0,
|
|
93
308
|
amount: 0
|
|
@@ -95,116 +310,157 @@ export function StatisticsTable({
|
|
|
95
310
|
const sumQuantity = colCells.reduce((sum, cell) => sum + cell.quantity, 0);
|
|
96
311
|
const sumAmount = colCells.reduce((sum, cell) => sum + cell.amount, 0);
|
|
97
312
|
const count = colCells.length || 1;
|
|
98
|
-
const meanQuantity = sumQuantity / count;
|
|
99
|
-
const meanAmount = sumAmount / count;
|
|
100
313
|
return {
|
|
101
314
|
sumQuantity,
|
|
102
315
|
sumAmount,
|
|
103
|
-
meanQuantity,
|
|
104
|
-
meanAmount
|
|
316
|
+
meanQuantity: sumQuantity / count,
|
|
317
|
+
meanAmount: sumAmount / count
|
|
105
318
|
};
|
|
106
319
|
});
|
|
107
320
|
}, [rows, columns, matrix, showColumnStats]);
|
|
108
|
-
|
|
109
|
-
// 获取列宽
|
|
110
321
|
const getColWidth = useCallback(column => {
|
|
111
|
-
if (getColumnWidth)
|
|
112
|
-
return getColumnWidth(column.key, column);
|
|
113
|
-
}
|
|
322
|
+
if (getColumnWidth) return getColumnWidth(column.key, column);
|
|
114
323
|
return column.width || 150;
|
|
115
324
|
}, [getColumnWidth]);
|
|
116
|
-
|
|
117
|
-
// 获取行高
|
|
118
325
|
const getRowHeightValue = useCallback(row => {
|
|
119
326
|
if (row.height) return row.height;
|
|
120
|
-
if (getRowHeight)
|
|
121
|
-
return getRowHeight(row.key, row.data);
|
|
122
|
-
}
|
|
327
|
+
if (getRowHeight) return getRowHeight(row.key, row.data);
|
|
123
328
|
return rowHeight;
|
|
124
329
|
}, [rowHeight, getRowHeight]);
|
|
125
330
|
|
|
126
|
-
//
|
|
127
|
-
const
|
|
331
|
+
// 处理滚动
|
|
332
|
+
const handleScroll = useCallback(event => {
|
|
128
333
|
const {
|
|
129
334
|
contentOffset,
|
|
130
335
|
contentSize,
|
|
131
336
|
layoutMeasurement
|
|
132
337
|
} = event.nativeEvent;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
isAtStart,
|
|
137
|
-
isAtEnd
|
|
338
|
+
setScrollState({
|
|
339
|
+
left: contentOffset.x,
|
|
340
|
+
top: contentOffset.y,
|
|
341
|
+
isAtStart: contentOffset.x <= 0,
|
|
342
|
+
isAtEnd: contentOffset.x + layoutMeasurement.width >= contentSize.width - 1,
|
|
343
|
+
isAtTop: contentOffset.y <= 0,
|
|
344
|
+
isAtBottom: contentOffset.y + layoutMeasurement.height >= contentSize.height - 1
|
|
138
345
|
});
|
|
139
346
|
}, []);
|
|
140
347
|
|
|
141
|
-
//
|
|
142
|
-
const
|
|
348
|
+
// 同步 Row Stats 滚动
|
|
349
|
+
const handleBodyScroll = useCallback(event => {
|
|
143
350
|
const {
|
|
144
|
-
contentOffset
|
|
145
|
-
contentSize,
|
|
146
|
-
layoutMeasurement
|
|
351
|
+
contentOffset
|
|
147
352
|
} = event.nativeEvent;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
isAtStart,
|
|
152
|
-
isAtEnd
|
|
353
|
+
rowStatsScrollRef.current?.scrollTo({
|
|
354
|
+
y: contentOffset.y,
|
|
355
|
+
animated: false
|
|
153
356
|
});
|
|
154
|
-
|
|
357
|
+
handleScroll(event);
|
|
358
|
+
}, [handleScroll]);
|
|
155
359
|
|
|
156
|
-
//
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
360
|
+
// 处理单元格 hover
|
|
361
|
+
const handleCellHover = useCallback((rowKey, columnKey, isHovered) => {
|
|
362
|
+
if (isHovered) {
|
|
363
|
+
setHoveredCell({
|
|
364
|
+
rowKey,
|
|
365
|
+
columnKey
|
|
366
|
+
});
|
|
367
|
+
} else {
|
|
368
|
+
setHoveredCell(null);
|
|
163
369
|
}
|
|
164
|
-
|
|
165
|
-
}, []);
|
|
370
|
+
onCellHover?.(rowKey, columnKey, isHovered);
|
|
371
|
+
}, [onCellHover]);
|
|
166
372
|
|
|
167
|
-
//
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return column.render(cell, rowData);
|
|
373
|
+
// 获取单元格 tooltip 内容
|
|
374
|
+
const getCellTooltipContent = useCallback((rowKey, columnKey, cell, column) => {
|
|
375
|
+
if (renderCellTooltip) {
|
|
376
|
+
return renderCellTooltip(rowKey, columnKey, cell, column);
|
|
172
377
|
}
|
|
378
|
+
return {
|
|
379
|
+
title: column.title,
|
|
380
|
+
items: [{
|
|
381
|
+
label: 'Quantity',
|
|
382
|
+
value: formatQuantity(cell.quantity)
|
|
383
|
+
}, {
|
|
384
|
+
label: 'Amount',
|
|
385
|
+
value: formatAmount(cell.amount)
|
|
386
|
+
}]
|
|
387
|
+
};
|
|
388
|
+
}, [renderCellTooltip, formatQuantity, formatAmount]);
|
|
389
|
+
|
|
390
|
+
// 获取行统计 tooltip
|
|
391
|
+
const getRowStatsTooltipContent = useCallback((rowKey, stats, storeCount) => {
|
|
392
|
+
if (renderRowStatsTooltip) {
|
|
393
|
+
return renderRowStatsTooltip(rowKey, stats, storeCount);
|
|
394
|
+
}
|
|
395
|
+
const row = rows.find(r => r.key === rowKey);
|
|
396
|
+
return {
|
|
397
|
+
title: row?.label || rowKey,
|
|
398
|
+
subtitle: `${storeCount} stores`,
|
|
399
|
+
items: [{
|
|
400
|
+
label: 'Sum',
|
|
401
|
+
value: formatAmount(stats.sumAmount)
|
|
402
|
+
}, {
|
|
403
|
+
label: 'Mean',
|
|
404
|
+
value: formatAmount(stats.meanAmount)
|
|
405
|
+
}]
|
|
406
|
+
};
|
|
407
|
+
}, [renderRowStatsTooltip, formatAmount, rows]);
|
|
173
408
|
|
|
174
|
-
|
|
409
|
+
// 获取列统计 tooltip
|
|
410
|
+
const getColumnStatsTooltipContent = useCallback((columnKey, column, stats) => {
|
|
411
|
+
if (renderColumnStatsTooltip) {
|
|
412
|
+
return renderColumnStatsTooltip(columnKey, column, stats);
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
title: column.title,
|
|
416
|
+
items: [{
|
|
417
|
+
label: 'Sum',
|
|
418
|
+
value: formatAmount(stats.sumAmount)
|
|
419
|
+
}, {
|
|
420
|
+
label: 'Mean',
|
|
421
|
+
value: formatAmount(stats.meanAmount)
|
|
422
|
+
}]
|
|
423
|
+
};
|
|
424
|
+
}, [renderColumnStatsTooltip, formatAmount]);
|
|
425
|
+
|
|
426
|
+
// 渲染单元格内容
|
|
427
|
+
const renderCellContent = useCallback((column, cell, rowData) => {
|
|
428
|
+
if (column.render) return column.render(cell, rowData);
|
|
175
429
|
if (column.isAction && rowActions) {
|
|
176
430
|
return /*#__PURE__*/_jsx(View, {
|
|
177
431
|
style: styles.actionContainer,
|
|
178
432
|
children: rowActions.map((action, index) => /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
179
|
-
style: styles.actionButton,
|
|
433
|
+
style: [styles.actionButton, {
|
|
434
|
+
backgroundColor: colors.colorTextAccent
|
|
435
|
+
}],
|
|
180
436
|
onPress: () => action.onPress(cell.rowKey, rowData),
|
|
181
437
|
activeOpacity: 0.7,
|
|
182
438
|
children: /*#__PURE__*/_jsx(Text, {
|
|
183
|
-
style: styles.actionButtonText,
|
|
439
|
+
style: [styles.actionButtonText, {
|
|
440
|
+
color: colors.colorTextInvert
|
|
441
|
+
}],
|
|
184
442
|
children: action.label
|
|
185
443
|
})
|
|
186
444
|
}, index))
|
|
187
445
|
});
|
|
188
446
|
}
|
|
189
|
-
|
|
190
|
-
// 默认渲染
|
|
191
|
-
const align = getCellAlignment(column);
|
|
192
447
|
return /*#__PURE__*/_jsxs(View, {
|
|
193
|
-
style:
|
|
194
|
-
alignItems: align === 'left' ? 'flex-start' : align === 'right' ? 'flex-end' : 'center'
|
|
195
|
-
}],
|
|
448
|
+
style: styles.cellContentContainer,
|
|
196
449
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
197
|
-
style: [styles.cellQuantity,
|
|
450
|
+
style: [styles.cellQuantity, themedStyles.cellQuantity],
|
|
198
451
|
children: formatQuantity(cell.quantity)
|
|
199
452
|
}), /*#__PURE__*/_jsx(Text, {
|
|
200
|
-
style: [styles.cellAmount,
|
|
453
|
+
style: [styles.cellAmount, themedStyles.cellAmount],
|
|
201
454
|
children: formatAmount(cell.amount)
|
|
202
455
|
})]
|
|
203
456
|
});
|
|
204
|
-
}, [rowActions,
|
|
457
|
+
}, [rowActions, formatQuantity, formatAmount, colors, themedStyles]);
|
|
458
|
+
|
|
459
|
+
// 计算统计列宽度
|
|
460
|
+
const statsColumnsWidth = actualShowRowStats ? statsColumnWidth * 2 : 0;
|
|
205
461
|
if (loading) {
|
|
206
462
|
return /*#__PURE__*/_jsx(View, {
|
|
207
|
-
style: [styles.container, style],
|
|
463
|
+
style: [styles.container, themedStyles.container, style],
|
|
208
464
|
children: /*#__PURE__*/_jsx(View, {
|
|
209
465
|
style: styles.loadingRow,
|
|
210
466
|
children: /*#__PURE__*/_jsx(Text, {
|
|
@@ -215,282 +471,361 @@ export function StatisticsTable({
|
|
|
215
471
|
}
|
|
216
472
|
if (rows.length === 0 || columns.length === 0) {
|
|
217
473
|
return /*#__PURE__*/_jsx(View, {
|
|
218
|
-
style: [styles.container, style],
|
|
474
|
+
style: [styles.container, themedStyles.container, style],
|
|
219
475
|
children: /*#__PURE__*/_jsx(View, {
|
|
220
476
|
style: styles.emptyRow,
|
|
221
477
|
children: /*#__PURE__*/_jsx(Text, {
|
|
222
|
-
style: styles.emptyText,
|
|
478
|
+
style: [styles.emptyText, {
|
|
479
|
+
color: colors.colorTextPlaceholder
|
|
480
|
+
}],
|
|
223
481
|
children: emptyText
|
|
224
482
|
})
|
|
225
483
|
})
|
|
226
484
|
});
|
|
227
485
|
}
|
|
228
|
-
|
|
229
|
-
// 虚拟滚动实现(简化版)
|
|
230
486
|
const visibleRows = enableVirtualization ? rows.slice(0, Math.ceil(maxHeight / virtualRowHeight)) : rows;
|
|
487
|
+
|
|
488
|
+
// Web 阴影样式
|
|
489
|
+
const webShadowStyle = Platform.OS === 'web' ? {
|
|
490
|
+
leftShadow: {
|
|
491
|
+
boxShadow: '2px 0 6px 4px rgba(0, 0, 0, 0.08)'
|
|
492
|
+
},
|
|
493
|
+
rightShadow: {
|
|
494
|
+
boxShadow: '-2px 0 6px 4px rgba(0, 0, 0, 0.08)'
|
|
495
|
+
},
|
|
496
|
+
topShadow: {
|
|
497
|
+
boxShadow: '0 2px 6px 4px rgba(0, 0, 0, 0.08)'
|
|
498
|
+
},
|
|
499
|
+
bottomShadow: {
|
|
500
|
+
boxShadow: '0 -2px 6px 4px rgba(0, 0, 0, 0.08)'
|
|
501
|
+
}
|
|
502
|
+
} : {};
|
|
503
|
+
|
|
504
|
+
// 隐藏滚动条的样式
|
|
505
|
+
const hideScrollbarStyle = Platform.OS === 'web' ? {
|
|
506
|
+
scrollbarWidth: 'none',
|
|
507
|
+
msOverflowStyle: 'none'
|
|
508
|
+
} : {};
|
|
509
|
+
const columnStatsHeight = actualShowColumnStats ? 120 : 0;
|
|
510
|
+
const storeCount = columns.filter(c => !c.isAction).length;
|
|
231
511
|
return /*#__PURE__*/_jsxs(View, {
|
|
232
|
-
style: [styles.container, style],
|
|
233
|
-
children: [enableScrollShadow && !
|
|
234
|
-
style: [styles.shadowLeft,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}]
|
|
239
|
-
}), enableScrollShadow && !
|
|
240
|
-
style: [styles.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}]
|
|
245
|
-
}), /*#__PURE__*/
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
shadowColor: scrollShadowColor
|
|
257
|
-
}]
|
|
258
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
259
|
-
style: styles.header,
|
|
260
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
261
|
-
style: [styles.headerCell, {
|
|
262
|
-
width: rowLabelWidth
|
|
263
|
-
}],
|
|
264
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
265
|
-
style: styles.headerText
|
|
266
|
-
})
|
|
267
|
-
}), columns.map(column => {
|
|
268
|
-
const align = getCellAlignment(column, true);
|
|
269
|
-
const colWidth = getColWidth(column);
|
|
270
|
-
return /*#__PURE__*/_jsx(View, {
|
|
271
|
-
style: [styles.headerCell, {
|
|
272
|
-
width: colWidth,
|
|
273
|
-
minWidth: column.minWidth,
|
|
274
|
-
maxWidth: column.maxWidth
|
|
275
|
-
}, align === 'right' && styles.headerCellRight, align === 'left' && styles.headerCellLeft],
|
|
276
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
277
|
-
style: [styles.headerText, align === 'right' && styles.headerTextRight, align === 'left' && styles.headerTextLeft],
|
|
278
|
-
children: column.title
|
|
279
|
-
})
|
|
280
|
-
}, column.key);
|
|
281
|
-
}), showRowStats && /*#__PURE__*/_jsxs(_Fragment, {
|
|
282
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
283
|
-
style: [styles.headerCell, {
|
|
284
|
-
width: 120
|
|
285
|
-
}],
|
|
286
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
287
|
-
style: styles.headerText,
|
|
288
|
-
children: "Sum"
|
|
289
|
-
})
|
|
290
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
291
|
-
style: [styles.headerCell, {
|
|
292
|
-
width: 120
|
|
293
|
-
}],
|
|
294
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
295
|
-
style: styles.headerText,
|
|
296
|
-
children: "Mean"
|
|
297
|
-
})
|
|
298
|
-
})]
|
|
299
|
-
})]
|
|
300
|
-
}), /*#__PURE__*/_jsxs(ScrollView, {
|
|
301
|
-
ref: verticalScrollRef,
|
|
302
|
-
style: {
|
|
303
|
-
maxHeight
|
|
304
|
-
},
|
|
305
|
-
showsVerticalScrollIndicator: Platform.OS === 'web',
|
|
306
|
-
removeClippedSubviews: enableVirtualization,
|
|
307
|
-
onScroll: handleVerticalScroll,
|
|
512
|
+
style: [styles.container, themedStyles.container, style],
|
|
513
|
+
children: [enableScrollShadow && !scrollState.isAtStart && /*#__PURE__*/_jsx(View, {
|
|
514
|
+
style: [styles.shadowBar, styles.shadowLeft, Platform.OS === 'web' && webShadowStyle.leftShadow]
|
|
515
|
+
}), enableScrollShadow && !scrollState.isAtEnd && /*#__PURE__*/_jsx(View, {
|
|
516
|
+
style: [styles.shadowBar, styles.shadowRight, {
|
|
517
|
+
right: actualShowRowStats ? statsColumnsWidth : 0
|
|
518
|
+
}, Platform.OS === 'web' && webShadowStyle.rightShadow]
|
|
519
|
+
}), enableScrollShadow && !scrollState.isAtTop && /*#__PURE__*/_jsx(View, {
|
|
520
|
+
style: [styles.shadowBarHorizontal, styles.shadowTop, Platform.OS === 'web' && webShadowStyle.topShadow]
|
|
521
|
+
}), enableScrollShadow && !scrollState.isAtBottom && /*#__PURE__*/_jsx(View, {
|
|
522
|
+
style: [styles.shadowBarHorizontal, styles.shadowBottom, {
|
|
523
|
+
bottom: actualShowColumnStats ? columnStatsHeight : 0
|
|
524
|
+
}, Platform.OS === 'web' && webShadowStyle.bottomShadow]
|
|
525
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
526
|
+
style: styles.tableContainer,
|
|
527
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
528
|
+
style: {
|
|
529
|
+
flex: 1
|
|
530
|
+
},
|
|
531
|
+
children: /*#__PURE__*/_jsx(ScrollView, {
|
|
532
|
+
ref: scrollViewRef,
|
|
533
|
+
horizontal: true,
|
|
534
|
+
showsHorizontalScrollIndicator: showScrollIndicator,
|
|
535
|
+
onScroll: handleScroll,
|
|
308
536
|
scrollEventThrottle: 16,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
314
|
-
style: [styles.row, {
|
|
315
|
-
minHeight: currentRowHeight
|
|
316
|
-
}],
|
|
317
|
-
onPress: isClickable ? () => onRowPress(row.key, row.data) : undefined,
|
|
318
|
-
activeOpacity: isClickable ? 0.7 : 1,
|
|
319
|
-
disabled: !isClickable,
|
|
537
|
+
style: hideScrollbarStyle,
|
|
538
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
539
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
540
|
+
style: [styles.header, themedStyles.header],
|
|
320
541
|
children: [/*#__PURE__*/_jsx(View, {
|
|
321
|
-
style: [styles.
|
|
322
|
-
width: rowLabelWidth
|
|
323
|
-
minHeight: currentRowHeight
|
|
542
|
+
style: [styles.headerCell, themedStyles.headerCell, {
|
|
543
|
+
width: rowLabelWidth
|
|
324
544
|
}],
|
|
325
545
|
children: /*#__PURE__*/_jsx(Text, {
|
|
326
|
-
style: styles.
|
|
327
|
-
children: row.label
|
|
546
|
+
style: [styles.headerText, themedStyles.headerText]
|
|
328
547
|
})
|
|
329
548
|
}), columns.map(column => {
|
|
330
|
-
const cell = matrix[row.key]?.[column.key] || {
|
|
331
|
-
quantity: 0,
|
|
332
|
-
amount: 0,
|
|
333
|
-
rowKey: row.key,
|
|
334
|
-
columnKey: column.key
|
|
335
|
-
};
|
|
336
|
-
const align = getCellAlignment(column);
|
|
337
549
|
const colWidth = getColWidth(column);
|
|
338
550
|
return /*#__PURE__*/_jsx(View, {
|
|
339
|
-
style: [styles.
|
|
340
|
-
width: colWidth
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
551
|
+
style: [styles.headerCell, themedStyles.headerCell, {
|
|
552
|
+
width: colWidth
|
|
553
|
+
}],
|
|
554
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
555
|
+
style: [styles.headerText, themedStyles.headerText],
|
|
556
|
+
children: column.title
|
|
557
|
+
})
|
|
346
558
|
}, column.key);
|
|
347
|
-
})
|
|
559
|
+
})]
|
|
560
|
+
}), /*#__PURE__*/_jsx(ScrollView, {
|
|
561
|
+
ref: bodyScrollViewRef,
|
|
562
|
+
style: {
|
|
563
|
+
maxHeight: maxHeight - columnStatsHeight
|
|
564
|
+
},
|
|
565
|
+
showsVerticalScrollIndicator: showScrollIndicator,
|
|
566
|
+
onScroll: handleBodyScroll,
|
|
567
|
+
scrollEventThrottle: 16,
|
|
568
|
+
children: visibleRows.map(row => {
|
|
569
|
+
const currentRowHeight = getRowHeightValue(row);
|
|
570
|
+
const isClickable = !!onRowPress;
|
|
571
|
+
const isRowHovered = hoveredCell?.rowKey === row.key;
|
|
572
|
+
return /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
573
|
+
style: [styles.row, themedStyles.row, {
|
|
574
|
+
minHeight: currentRowHeight
|
|
575
|
+
}, isRowHovered && themedStyles.rowHovered],
|
|
576
|
+
onPress: isClickable ? () => onRowPress(row.key, row.data) : undefined,
|
|
577
|
+
activeOpacity: isClickable ? 0.7 : 1,
|
|
578
|
+
disabled: !isClickable,
|
|
579
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
580
|
+
style: [styles.cell, themedStyles.cell, {
|
|
581
|
+
width: rowLabelWidth
|
|
582
|
+
}],
|
|
583
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
584
|
+
style: [styles.rowLabel, themedStyles.rowLabel],
|
|
585
|
+
children: row.label
|
|
586
|
+
})
|
|
587
|
+
}), columns.map(column => {
|
|
588
|
+
const cell = matrix[row.key]?.[column.key] || {
|
|
589
|
+
quantity: 0,
|
|
590
|
+
amount: 0,
|
|
591
|
+
rowKey: row.key,
|
|
592
|
+
columnKey: column.key
|
|
593
|
+
};
|
|
594
|
+
const colWidth = getColWidth(column);
|
|
595
|
+
const isHovered = hoveredCell?.rowKey === row.key && hoveredCell?.columnKey === column.key;
|
|
596
|
+
const tooltipContent = isHovered ? getCellTooltipContent(row.key, column.key, cell, column) : null;
|
|
597
|
+
return /*#__PURE__*/_jsx(Hoverable, {
|
|
598
|
+
onHoverIn: () => handleCellHover(row.key, column.key, true),
|
|
599
|
+
onHoverOut: () => handleCellHover(row.key, column.key, false),
|
|
600
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
601
|
+
style: [styles.cell, themedStyles.cell, {
|
|
602
|
+
width: colWidth
|
|
603
|
+
}, isHovered && themedStyles.cellHovered],
|
|
604
|
+
children: [renderCellContent(column, cell, row.data), /*#__PURE__*/_jsx(CellTooltip, {
|
|
605
|
+
visible: isHovered,
|
|
606
|
+
content: tooltipContent,
|
|
607
|
+
style: {
|
|
608
|
+
bottom: '100%',
|
|
609
|
+
left: 0,
|
|
610
|
+
marginBottom: 8
|
|
611
|
+
}
|
|
612
|
+
})]
|
|
613
|
+
})
|
|
614
|
+
}, column.key);
|
|
615
|
+
})]
|
|
616
|
+
}, row.key);
|
|
617
|
+
})
|
|
618
|
+
}), actualShowColumnStats && columnStats && /*#__PURE__*/_jsxs(Animated.View, {
|
|
619
|
+
style: [styles.columnStatsContainer, themedStyles.columnStatsDivider, enableStatsAnimation && {
|
|
620
|
+
opacity: columnStatsAnimation,
|
|
621
|
+
transform: [{
|
|
622
|
+
translateY: columnStatsAnimation.interpolate({
|
|
623
|
+
inputRange: [0, 1],
|
|
624
|
+
outputRange: [60, 0]
|
|
625
|
+
})
|
|
626
|
+
}]
|
|
627
|
+
}],
|
|
628
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
629
|
+
style: [styles.row, themedStyles.columnStatsRow],
|
|
348
630
|
children: [/*#__PURE__*/_jsx(View, {
|
|
349
|
-
style: [styles.cell,
|
|
350
|
-
width:
|
|
631
|
+
style: [styles.cell, themedStyles.cell, {
|
|
632
|
+
width: rowLabelWidth
|
|
351
633
|
}],
|
|
352
|
-
children: /*#__PURE__*/
|
|
353
|
-
style: styles.
|
|
354
|
-
children:
|
|
355
|
-
style: [styles.cellQuantity, styles.cellQuantityRight],
|
|
356
|
-
children: formatQuantity(rowStat.sumQuantity)
|
|
357
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
358
|
-
style: [styles.cellAmount, styles.cellAmountRight],
|
|
359
|
-
children: formatAmount(rowStat.sumAmount)
|
|
360
|
-
})]
|
|
634
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
635
|
+
style: [styles.statsLabel, themedStyles.statsLabel],
|
|
636
|
+
children: columnStatsLabels.sum
|
|
361
637
|
})
|
|
362
|
-
}),
|
|
363
|
-
|
|
364
|
-
|
|
638
|
+
}), columns.map(column => {
|
|
639
|
+
const colWidth = getColWidth(column);
|
|
640
|
+
if (column.isAction) {
|
|
641
|
+
return /*#__PURE__*/_jsx(View, {
|
|
642
|
+
style: [styles.cell, {
|
|
643
|
+
width: colWidth
|
|
644
|
+
}]
|
|
645
|
+
}, column.key);
|
|
646
|
+
}
|
|
647
|
+
const stat = columnStats[columns.filter(c => !c.isAction).indexOf(column)];
|
|
648
|
+
const isHovered = hoveredCell?.rowKey === '__column_sum__' && hoveredCell?.columnKey === column.key;
|
|
649
|
+
const tooltipContent = isHovered && stat ? getColumnStatsTooltipContent(column.key, column, stat) : null;
|
|
650
|
+
return /*#__PURE__*/_jsx(Hoverable, {
|
|
651
|
+
onHoverIn: () => handleCellHover('__column_sum__', column.key, true),
|
|
652
|
+
onHoverOut: () => handleCellHover('__column_sum__', column.key, false),
|
|
653
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
654
|
+
style: [styles.cell, themedStyles.cell, {
|
|
655
|
+
width: colWidth
|
|
656
|
+
}, isHovered && themedStyles.cellHovered],
|
|
657
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
658
|
+
style: styles.cellContentContainer,
|
|
659
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
660
|
+
style: [styles.cellQuantity, themedStyles.cellQuantity],
|
|
661
|
+
children: formatQuantity(stat?.sumQuantity || 0)
|
|
662
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
663
|
+
style: [styles.cellAmount, themedStyles.cellAmount],
|
|
664
|
+
children: formatAmount(stat?.sumAmount || 0)
|
|
665
|
+
})]
|
|
666
|
+
}), /*#__PURE__*/_jsx(CellTooltip, {
|
|
667
|
+
visible: isHovered,
|
|
668
|
+
content: tooltipContent,
|
|
669
|
+
style: {
|
|
670
|
+
bottom: '100%',
|
|
671
|
+
left: 0,
|
|
672
|
+
marginBottom: 8
|
|
673
|
+
}
|
|
674
|
+
})]
|
|
675
|
+
})
|
|
676
|
+
}, column.key);
|
|
677
|
+
})]
|
|
678
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
679
|
+
style: [styles.row, themedStyles.columnStatsRow],
|
|
680
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
681
|
+
style: [styles.cell, themedStyles.cell, {
|
|
682
|
+
width: rowLabelWidth
|
|
365
683
|
}],
|
|
366
|
-
children: /*#__PURE__*/
|
|
367
|
-
style: styles.
|
|
368
|
-
children:
|
|
369
|
-
style: [styles.cellQuantity, styles.cellQuantityRight],
|
|
370
|
-
children: formatQuantity(Math.round(rowStat.meanQuantity * 10) / 10)
|
|
371
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
372
|
-
style: [styles.cellAmount, styles.cellAmountRight],
|
|
373
|
-
children: formatAmount(rowStat.meanAmount)
|
|
374
|
-
})]
|
|
684
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
685
|
+
style: [styles.statsLabel, themedStyles.statsLabel],
|
|
686
|
+
children: columnStatsLabels.mean
|
|
375
687
|
})
|
|
688
|
+
}), columns.map(column => {
|
|
689
|
+
const colWidth = getColWidth(column);
|
|
690
|
+
if (column.isAction) {
|
|
691
|
+
return /*#__PURE__*/_jsx(View, {
|
|
692
|
+
style: [styles.cell, {
|
|
693
|
+
width: colWidth
|
|
694
|
+
}]
|
|
695
|
+
}, column.key);
|
|
696
|
+
}
|
|
697
|
+
const stat = columnStats[columns.filter(c => !c.isAction).indexOf(column)];
|
|
698
|
+
const isHovered = hoveredCell?.rowKey === '__column_mean__' && hoveredCell?.columnKey === column.key;
|
|
699
|
+
const tooltipContent = isHovered && stat ? getColumnStatsTooltipContent(column.key, column, stat) : null;
|
|
700
|
+
return /*#__PURE__*/_jsx(Hoverable, {
|
|
701
|
+
onHoverIn: () => handleCellHover('__column_mean__', column.key, true),
|
|
702
|
+
onHoverOut: () => handleCellHover('__column_mean__', column.key, false),
|
|
703
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
704
|
+
style: [styles.cell, themedStyles.cell, {
|
|
705
|
+
width: colWidth
|
|
706
|
+
}, isHovered && themedStyles.cellHovered],
|
|
707
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
708
|
+
style: styles.cellContentContainer,
|
|
709
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
710
|
+
style: [styles.cellQuantity, themedStyles.cellQuantity],
|
|
711
|
+
children: formatQuantity(Math.round((stat?.meanQuantity || 0) * 10) / 10)
|
|
712
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
713
|
+
style: [styles.cellAmount, themedStyles.cellAmount],
|
|
714
|
+
children: formatAmount(stat?.meanAmount || 0)
|
|
715
|
+
})]
|
|
716
|
+
}), /*#__PURE__*/_jsx(CellTooltip, {
|
|
717
|
+
visible: isHovered,
|
|
718
|
+
content: tooltipContent,
|
|
719
|
+
style: {
|
|
720
|
+
bottom: '100%',
|
|
721
|
+
left: 0,
|
|
722
|
+
marginBottom: 8
|
|
723
|
+
}
|
|
724
|
+
})]
|
|
725
|
+
})
|
|
726
|
+
}, column.key);
|
|
376
727
|
})]
|
|
377
728
|
})]
|
|
378
|
-
}
|
|
379
|
-
})
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
729
|
+
})]
|
|
730
|
+
})
|
|
731
|
+
})
|
|
732
|
+
}), actualShowRowStats && /*#__PURE__*/_jsxs(Animated.View, {
|
|
733
|
+
style: [styles.rowStatsContainer, {
|
|
734
|
+
width: statsColumnsWidth
|
|
735
|
+
}, Platform.OS === 'web' && {
|
|
736
|
+
boxShadow: '-2px 0 6px rgba(0, 0, 0, 0.08)'
|
|
737
|
+
}, enableStatsAnimation && {
|
|
738
|
+
opacity: rowStatsAnimation,
|
|
739
|
+
transform: [{
|
|
740
|
+
translateX: rowStatsAnimation.interpolate({
|
|
741
|
+
inputRange: [0, 1],
|
|
742
|
+
outputRange: [statsColumnsWidth, 0]
|
|
743
|
+
})
|
|
744
|
+
}]
|
|
745
|
+
}],
|
|
746
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
747
|
+
style: [styles.header, themedStyles.header],
|
|
748
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
749
|
+
style: [styles.headerCell, themedStyles.statsHeaderCell, {
|
|
750
|
+
width: statsColumnWidth
|
|
751
|
+
}],
|
|
752
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
753
|
+
style: [styles.headerText, themedStyles.statsHeaderText],
|
|
754
|
+
children: rowStatsHeaders.sum
|
|
755
|
+
})
|
|
756
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
757
|
+
style: [styles.headerCell, themedStyles.statsHeaderCell, {
|
|
758
|
+
width: statsColumnWidth
|
|
759
|
+
}],
|
|
760
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
761
|
+
style: [styles.headerText, themedStyles.statsHeaderText],
|
|
762
|
+
children: rowStatsHeaders.mean
|
|
763
|
+
})
|
|
764
|
+
})]
|
|
765
|
+
}), /*#__PURE__*/_jsx(ScrollView, {
|
|
766
|
+
ref: rowStatsScrollRef,
|
|
767
|
+
style: {
|
|
768
|
+
maxHeight: maxHeight - columnStatsHeight
|
|
769
|
+
},
|
|
770
|
+
showsVerticalScrollIndicator: false,
|
|
771
|
+
scrollEnabled: false,
|
|
772
|
+
children: visibleRows.map((row, rowIndex) => {
|
|
773
|
+
const rowStat = rowStats?.[rowIndex];
|
|
774
|
+
const currentRowHeight = getRowHeightValue(row);
|
|
775
|
+
const isRowHovered = hoveredCell?.rowKey === row.key;
|
|
776
|
+
const isSumHovered = hoveredCell?.rowKey === row.key && hoveredCell?.columnKey === '__row_sum__';
|
|
777
|
+
const sumTooltipContent = isSumHovered && rowStat ? getRowStatsTooltipContent(row.key, rowStat, storeCount) : null;
|
|
778
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
779
|
+
style: [styles.row, themedStyles.rowStatsCell, {
|
|
780
|
+
minHeight: currentRowHeight
|
|
781
|
+
}, isRowHovered && themedStyles.rowHovered],
|
|
782
|
+
children: [/*#__PURE__*/_jsx(Hoverable, {
|
|
783
|
+
onHoverIn: () => handleCellHover(row.key, '__row_sum__', true),
|
|
784
|
+
onHoverOut: () => handleCellHover(row.key, '__row_sum__', false),
|
|
785
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
786
|
+
style: [styles.cell, themedStyles.cell, {
|
|
787
|
+
width: statsColumnWidth
|
|
788
|
+
}],
|
|
789
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
410
790
|
style: styles.cellContentContainer,
|
|
411
791
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
412
|
-
style: [styles.cellQuantity,
|
|
413
|
-
children: formatQuantity(
|
|
792
|
+
style: [styles.cellQuantity, themedStyles.cellQuantity],
|
|
793
|
+
children: formatQuantity(rowStat?.sumQuantity || 0)
|
|
414
794
|
}), /*#__PURE__*/_jsx(Text, {
|
|
415
|
-
style: [styles.cellAmount,
|
|
416
|
-
children: formatAmount(
|
|
795
|
+
style: [styles.cellAmount, themedStyles.cellAmount],
|
|
796
|
+
children: formatAmount(rowStat?.sumAmount || 0)
|
|
417
797
|
})]
|
|
418
|
-
})
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
432
|
-
style: [styles.row, styles.statsRow],
|
|
433
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
434
|
-
style: [styles.cell, {
|
|
435
|
-
width: rowLabelWidth
|
|
798
|
+
}), /*#__PURE__*/_jsx(CellTooltip, {
|
|
799
|
+
visible: isSumHovered,
|
|
800
|
+
content: sumTooltipContent,
|
|
801
|
+
style: {
|
|
802
|
+
bottom: '100%',
|
|
803
|
+
right: 0,
|
|
804
|
+
marginBottom: 8
|
|
805
|
+
}
|
|
806
|
+
})]
|
|
807
|
+
})
|
|
808
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
809
|
+
style: [styles.cell, themedStyles.cell, {
|
|
810
|
+
width: statsColumnWidth
|
|
436
811
|
}],
|
|
437
|
-
children: /*#__PURE__*/
|
|
438
|
-
style: styles.
|
|
439
|
-
children:
|
|
812
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
813
|
+
style: styles.cellContentContainer,
|
|
814
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
815
|
+
style: [styles.cellQuantity, themedStyles.cellQuantity],
|
|
816
|
+
children: formatQuantity(Math.round((rowStat?.meanQuantity || 0) * 10) / 10)
|
|
817
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
818
|
+
style: [styles.cellAmount, themedStyles.cellAmount],
|
|
819
|
+
children: formatAmount(rowStat?.meanAmount || 0)
|
|
820
|
+
})]
|
|
440
821
|
})
|
|
441
|
-
}), columns.map(column => {
|
|
442
|
-
const colWidth = getColWidth(column);
|
|
443
|
-
if (column.isAction) {
|
|
444
|
-
return /*#__PURE__*/_jsx(View, {
|
|
445
|
-
style: [styles.cell, {
|
|
446
|
-
width: colWidth,
|
|
447
|
-
minWidth: column.minWidth,
|
|
448
|
-
maxWidth: column.maxWidth
|
|
449
|
-
}]
|
|
450
|
-
}, column.key);
|
|
451
|
-
}
|
|
452
|
-
const stat = columnStats[columns.filter(c => !c.isAction).indexOf(column)];
|
|
453
|
-
const align = getCellAlignment(column);
|
|
454
|
-
return /*#__PURE__*/_jsx(View, {
|
|
455
|
-
style: [styles.cell, {
|
|
456
|
-
width: colWidth,
|
|
457
|
-
minWidth: column.minWidth,
|
|
458
|
-
maxWidth: column.maxWidth
|
|
459
|
-
}, align === 'right' && styles.cellRight, align === 'left' && styles.cellLeft],
|
|
460
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
461
|
-
style: styles.cellContentContainer,
|
|
462
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
463
|
-
style: [styles.cellQuantity, align === 'right' && styles.cellQuantityRight],
|
|
464
|
-
children: formatQuantity(Math.round((stat?.meanQuantity || 0) * 10) / 10)
|
|
465
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
466
|
-
style: [styles.cellAmount, align === 'right' && styles.cellAmountRight],
|
|
467
|
-
children: formatAmount(stat?.meanAmount || 0)
|
|
468
|
-
})]
|
|
469
|
-
})
|
|
470
|
-
}, column.key);
|
|
471
|
-
}), showRowStats && /*#__PURE__*/_jsxs(_Fragment, {
|
|
472
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
473
|
-
style: [styles.cell, {
|
|
474
|
-
width: 120
|
|
475
|
-
}]
|
|
476
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
477
|
-
style: [styles.cell, {
|
|
478
|
-
width: 120
|
|
479
|
-
}]
|
|
480
|
-
})]
|
|
481
822
|
})]
|
|
482
|
-
})
|
|
483
|
-
})
|
|
484
|
-
}), enableScrollShadow && !verticalScrollState.isAtEnd && /*#__PURE__*/_jsx(View, {
|
|
485
|
-
style: [styles.shadowBottom, {
|
|
486
|
-
height: scrollShadowSize,
|
|
487
|
-
backgroundColor: 'transparent',
|
|
488
|
-
shadowColor: scrollShadowColor
|
|
489
|
-
}]
|
|
823
|
+
}, row.key);
|
|
824
|
+
})
|
|
490
825
|
})]
|
|
491
|
-
})
|
|
826
|
+
})]
|
|
492
827
|
}), pagination !== false && pagination && /*#__PURE__*/_jsx(View, {
|
|
493
|
-
style: styles.paginationContainer,
|
|
828
|
+
style: [styles.paginationContainer, themedStyles.paginationContainer],
|
|
494
829
|
children: /*#__PURE__*/_jsx(Pagination, {
|
|
495
830
|
totalCount: `${pagination.total} items`,
|
|
496
831
|
pageParams: {
|
|
@@ -508,93 +843,58 @@ export function StatisticsTable({
|
|
|
508
843
|
}
|
|
509
844
|
const styles = StyleSheet.create({
|
|
510
845
|
container: {
|
|
511
|
-
|
|
512
|
-
borderRadius: 8,
|
|
846
|
+
borderRadius: 12,
|
|
513
847
|
overflow: 'hidden'
|
|
514
848
|
},
|
|
849
|
+
tableContainer: {
|
|
850
|
+
flexDirection: 'row'
|
|
851
|
+
},
|
|
515
852
|
header: {
|
|
516
853
|
flexDirection: 'row',
|
|
517
|
-
|
|
518
|
-
borderBottomWidth: 2,
|
|
519
|
-
borderBottomColor: '#E0E0E0'
|
|
854
|
+
borderBottomWidth: 1
|
|
520
855
|
},
|
|
521
856
|
headerCell: {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
borderRightColor: '#E0E0E0',
|
|
857
|
+
paddingVertical: 16,
|
|
858
|
+
paddingHorizontal: 12,
|
|
525
859
|
justifyContent: 'center',
|
|
526
860
|
alignItems: 'center'
|
|
527
861
|
},
|
|
528
|
-
headerCellLeft: {
|
|
529
|
-
alignItems: 'flex-start'
|
|
530
|
-
},
|
|
531
|
-
headerCellRight: {
|
|
532
|
-
alignItems: 'flex-end'
|
|
533
|
-
},
|
|
534
862
|
headerText: {
|
|
535
863
|
fontSize: 14,
|
|
536
|
-
fontWeight: '
|
|
537
|
-
color: '#2C3E50',
|
|
864
|
+
fontWeight: '500',
|
|
538
865
|
textAlign: 'center'
|
|
539
866
|
},
|
|
540
|
-
headerTextLeft: {
|
|
541
|
-
textAlign: 'left'
|
|
542
|
-
},
|
|
543
|
-
headerTextRight: {
|
|
544
|
-
textAlign: 'right'
|
|
545
|
-
},
|
|
546
867
|
row: {
|
|
547
868
|
flexDirection: 'row',
|
|
548
|
-
borderBottomWidth: 1
|
|
549
|
-
borderBottomColor: '#F0F0F0',
|
|
550
|
-
backgroundColor: '#FFFFFF'
|
|
551
|
-
},
|
|
552
|
-
statsRow: {
|
|
553
|
-
backgroundColor: '#F9F9F9'
|
|
869
|
+
borderBottomWidth: 1
|
|
554
870
|
},
|
|
555
871
|
cell: {
|
|
556
|
-
|
|
872
|
+
paddingVertical: 16,
|
|
873
|
+
paddingHorizontal: 12,
|
|
557
874
|
justifyContent: 'center',
|
|
558
|
-
alignItems: 'center'
|
|
559
|
-
borderRightWidth: 1,
|
|
560
|
-
borderRightColor: '#F0F0F0'
|
|
561
|
-
},
|
|
562
|
-
cellLeft: {
|
|
563
|
-
alignItems: 'flex-start'
|
|
564
|
-
},
|
|
565
|
-
cellRight: {
|
|
566
|
-
alignItems: 'flex-end'
|
|
875
|
+
alignItems: 'center'
|
|
567
876
|
},
|
|
568
877
|
cellContentContainer: {
|
|
569
|
-
width: '100%'
|
|
878
|
+
width: '100%',
|
|
879
|
+
alignItems: 'center'
|
|
570
880
|
},
|
|
571
881
|
rowLabel: {
|
|
572
882
|
fontSize: 14,
|
|
573
|
-
fontWeight: '500'
|
|
574
|
-
color: '#2C3E50'
|
|
883
|
+
fontWeight: '500'
|
|
575
884
|
},
|
|
576
885
|
cellQuantity: {
|
|
577
|
-
fontSize:
|
|
578
|
-
fontWeight: '
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
textAlign: 'left'
|
|
582
|
-
},
|
|
583
|
-
cellQuantityRight: {
|
|
584
|
-
textAlign: 'right'
|
|
886
|
+
fontSize: 16,
|
|
887
|
+
fontWeight: '600',
|
|
888
|
+
marginBottom: 2,
|
|
889
|
+
textAlign: 'center'
|
|
585
890
|
},
|
|
586
891
|
cellAmount: {
|
|
587
892
|
fontSize: 12,
|
|
588
|
-
|
|
589
|
-
textAlign: 'left'
|
|
590
|
-
},
|
|
591
|
-
cellAmountRight: {
|
|
592
|
-
textAlign: 'right'
|
|
893
|
+
textAlign: 'center'
|
|
593
894
|
},
|
|
594
895
|
statsLabel: {
|
|
595
896
|
fontSize: 14,
|
|
596
|
-
fontWeight: '600'
|
|
597
|
-
color: '#2C3E50'
|
|
897
|
+
fontWeight: '600'
|
|
598
898
|
},
|
|
599
899
|
actionContainer: {
|
|
600
900
|
flexDirection: 'row',
|
|
@@ -604,13 +904,11 @@ const styles = StyleSheet.create({
|
|
|
604
904
|
actionButton: {
|
|
605
905
|
paddingHorizontal: 12,
|
|
606
906
|
paddingVertical: 6,
|
|
607
|
-
backgroundColor: '#FF6B00',
|
|
608
907
|
borderRadius: 4
|
|
609
908
|
},
|
|
610
909
|
actionButtonText: {
|
|
611
910
|
fontSize: 12,
|
|
612
|
-
fontWeight: '600'
|
|
613
|
-
color: '#FFFFFF'
|
|
911
|
+
fontWeight: '600'
|
|
614
912
|
},
|
|
615
913
|
loadingRow: {
|
|
616
914
|
padding: 40,
|
|
@@ -623,71 +921,50 @@ const styles = StyleSheet.create({
|
|
|
623
921
|
alignItems: 'center'
|
|
624
922
|
},
|
|
625
923
|
emptyText: {
|
|
626
|
-
fontSize: 14
|
|
627
|
-
color: '#999'
|
|
924
|
+
fontSize: 14
|
|
628
925
|
},
|
|
629
926
|
paginationContainer: {
|
|
630
927
|
padding: 16,
|
|
631
|
-
borderTopWidth: 1
|
|
632
|
-
borderTopColor: '#E0E0E0',
|
|
633
|
-
backgroundColor: '#FAFAFA'
|
|
928
|
+
borderTopWidth: 1
|
|
634
929
|
},
|
|
635
|
-
//
|
|
636
|
-
|
|
930
|
+
// Row Stats 容器
|
|
931
|
+
rowStatsContainer: {
|
|
932
|
+
position: 'relative'
|
|
933
|
+
},
|
|
934
|
+
// Column Stats 容器
|
|
935
|
+
columnStatsContainer: {
|
|
936
|
+
// 顶部边框由 themedStyles.columnStatsDivider 提供
|
|
937
|
+
},
|
|
938
|
+
// 垂直阴影条
|
|
939
|
+
shadowBar: {
|
|
637
940
|
position: 'absolute',
|
|
941
|
+
zIndex: 10,
|
|
942
|
+
width: 1,
|
|
943
|
+
backgroundColor: 'transparent'
|
|
944
|
+
},
|
|
945
|
+
shadowLeft: {
|
|
638
946
|
left: 0,
|
|
639
947
|
top: 0,
|
|
640
|
-
bottom: 0
|
|
641
|
-
zIndex: 10,
|
|
642
|
-
shadowOffset: {
|
|
643
|
-
width: 2,
|
|
644
|
-
height: 0
|
|
645
|
-
},
|
|
646
|
-
shadowOpacity: 0.15,
|
|
647
|
-
shadowRadius: 4,
|
|
648
|
-
elevation: 4
|
|
948
|
+
bottom: 0
|
|
649
949
|
},
|
|
650
950
|
shadowRight: {
|
|
651
|
-
position: 'absolute',
|
|
652
|
-
right: 0,
|
|
653
951
|
top: 0,
|
|
654
|
-
bottom: 0
|
|
655
|
-
zIndex: 10,
|
|
656
|
-
shadowOffset: {
|
|
657
|
-
width: -2,
|
|
658
|
-
height: 0
|
|
659
|
-
},
|
|
660
|
-
shadowOpacity: 0.15,
|
|
661
|
-
shadowRadius: 4,
|
|
662
|
-
elevation: 4
|
|
952
|
+
bottom: 0
|
|
663
953
|
},
|
|
664
|
-
|
|
954
|
+
// 水平阴影条
|
|
955
|
+
shadowBarHorizontal: {
|
|
665
956
|
position: 'absolute',
|
|
957
|
+
zIndex: 10,
|
|
958
|
+
height: 1,
|
|
666
959
|
left: 0,
|
|
667
960
|
right: 0,
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
height: 2
|
|
673
|
-
},
|
|
674
|
-
shadowOpacity: 0.15,
|
|
675
|
-
shadowRadius: 4,
|
|
676
|
-
elevation: 4
|
|
961
|
+
backgroundColor: 'transparent'
|
|
962
|
+
},
|
|
963
|
+
shadowTop: {
|
|
964
|
+
top: 56 // header height
|
|
677
965
|
},
|
|
678
966
|
shadowBottom: {
|
|
679
|
-
|
|
680
|
-
left: 0,
|
|
681
|
-
right: 0,
|
|
682
|
-
bottom: 0,
|
|
683
|
-
zIndex: 10,
|
|
684
|
-
shadowOffset: {
|
|
685
|
-
width: 0,
|
|
686
|
-
height: -2
|
|
687
|
-
},
|
|
688
|
-
shadowOpacity: 0.15,
|
|
689
|
-
shadowRadius: 4,
|
|
690
|
-
elevation: 4
|
|
967
|
+
// bottom 由动态样式设置
|
|
691
968
|
}
|
|
692
969
|
});
|
|
693
970
|
//# sourceMappingURL=StatisticsTable.js.map
|