@beppla/tapas-ui 1.2.35 → 1.2.36
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 +451 -45
- package/components/StatisticsTable/index.tsx +4 -1
- package/components/index.tsx +10 -2
- package/package/commonjs/StatisticsTable/StatisticsTable.js +390 -75
- package/package/commonjs/StatisticsTable/StatisticsTable.js.map +1 -1
- package/package/commonjs/index.js.map +1 -1
- package/package/module/StatisticsTable/StatisticsTable.js +393 -78
- package/package/module/StatisticsTable/StatisticsTable.js.map +1 -1
- package/package/module/index.js.map +1 -1
- package/package/package.json +1 -1
- package/package/typescript/StatisticsTable/StatisticsTable.d.ts +29 -1
- package/package/typescript/StatisticsTable/StatisticsTable.d.ts.map +1 -1
- package/package/typescript/StatisticsTable/index.d.ts +1 -1
- package/package/typescript/StatisticsTable/index.d.ts.map +1 -1
- package/package/typescript/index.d.ts +3 -2
- package/package/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
4
|
-
import { View, ScrollView, StyleSheet, Platform } from 'react-native';
|
|
3
|
+
import React, { useMemo, useCallback, useState, useRef } from 'react';
|
|
4
|
+
import { View, ScrollView, StyleSheet, Platform, TouchableOpacity } from 'react-native';
|
|
5
5
|
import Text from '../Text/Text';
|
|
6
6
|
import Pagination from '../Pagination/Pagination';
|
|
7
|
-
import { jsx as _jsx,
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
8
|
export function StatisticsTable({
|
|
9
9
|
rows,
|
|
10
10
|
columns,
|
|
@@ -16,8 +16,32 @@ export function StatisticsTable({
|
|
|
16
16
|
emptyText = 'No data',
|
|
17
17
|
maxHeight = 500,
|
|
18
18
|
rowLabelWidth = 150,
|
|
19
|
-
style
|
|
19
|
+
style,
|
|
20
|
+
formatQuantity = q => q.toLocaleString(),
|
|
21
|
+
formatAmount = a => `€${a.toFixed(2)}`,
|
|
22
|
+
enableVirtualization = false,
|
|
23
|
+
virtualRowHeight = 60,
|
|
24
|
+
onRowPress,
|
|
25
|
+
rowActions,
|
|
26
|
+
rowHeight = 60,
|
|
27
|
+
getRowHeight,
|
|
28
|
+
getColumnWidth,
|
|
29
|
+
enableScrollShadow = true,
|
|
30
|
+
scrollShadowColor = 'rgba(0, 0, 0, 0.1)',
|
|
31
|
+
scrollShadowSize = 8
|
|
20
32
|
}) {
|
|
33
|
+
// 滚动状态
|
|
34
|
+
const [horizontalScrollState, setHorizontalScrollState] = useState({
|
|
35
|
+
isAtStart: true,
|
|
36
|
+
isAtEnd: false
|
|
37
|
+
});
|
|
38
|
+
const [verticalScrollState, setVerticalScrollState] = useState({
|
|
39
|
+
isAtStart: true,
|
|
40
|
+
isAtEnd: false
|
|
41
|
+
});
|
|
42
|
+
const horizontalScrollRef = useRef(null);
|
|
43
|
+
const verticalScrollRef = useRef(null);
|
|
44
|
+
|
|
21
45
|
// 构建矩阵数据
|
|
22
46
|
const matrix = useMemo(() => {
|
|
23
47
|
const data = {};
|
|
@@ -40,7 +64,8 @@ export function StatisticsTable({
|
|
|
40
64
|
const rowStats = useMemo(() => {
|
|
41
65
|
if (!showRowStats) return null;
|
|
42
66
|
return rows.map(row => {
|
|
43
|
-
const rowCells = columns.
|
|
67
|
+
const rowCells = columns.filter(col => !col.isAction) // 排除 action 列
|
|
68
|
+
.map(col => matrix[row.key]?.[col.key] || {
|
|
44
69
|
quantity: 0,
|
|
45
70
|
amount: 0
|
|
46
71
|
});
|
|
@@ -61,7 +86,8 @@ export function StatisticsTable({
|
|
|
61
86
|
// 计算列统计(每列的总和和平均值)
|
|
62
87
|
const columnStats = useMemo(() => {
|
|
63
88
|
if (!showColumnStats) return null;
|
|
64
|
-
return columns.
|
|
89
|
+
return columns.filter(col => !col.isAction) // 排除 action 列
|
|
90
|
+
.map(col => {
|
|
65
91
|
const colCells = rows.map(row => matrix[row.key]?.[col.key] || {
|
|
66
92
|
quantity: 0,
|
|
67
93
|
amount: 0
|
|
@@ -79,6 +105,103 @@ export function StatisticsTable({
|
|
|
79
105
|
};
|
|
80
106
|
});
|
|
81
107
|
}, [rows, columns, matrix, showColumnStats]);
|
|
108
|
+
|
|
109
|
+
// 获取列宽
|
|
110
|
+
const getColWidth = useCallback(column => {
|
|
111
|
+
if (getColumnWidth) {
|
|
112
|
+
return getColumnWidth(column.key, column);
|
|
113
|
+
}
|
|
114
|
+
return column.width || 150;
|
|
115
|
+
}, [getColumnWidth]);
|
|
116
|
+
|
|
117
|
+
// 获取行高
|
|
118
|
+
const getRowHeightValue = useCallback(row => {
|
|
119
|
+
if (row.height) return row.height;
|
|
120
|
+
if (getRowHeight) {
|
|
121
|
+
return getRowHeight(row.key, row.data);
|
|
122
|
+
}
|
|
123
|
+
return rowHeight;
|
|
124
|
+
}, [rowHeight, getRowHeight]);
|
|
125
|
+
|
|
126
|
+
// 处理水平滚动
|
|
127
|
+
const handleHorizontalScroll = useCallback(event => {
|
|
128
|
+
const {
|
|
129
|
+
contentOffset,
|
|
130
|
+
contentSize,
|
|
131
|
+
layoutMeasurement
|
|
132
|
+
} = event.nativeEvent;
|
|
133
|
+
const isAtStart = contentOffset.x <= 0;
|
|
134
|
+
const isAtEnd = contentOffset.x + layoutMeasurement.width >= contentSize.width - 1;
|
|
135
|
+
setHorizontalScrollState({
|
|
136
|
+
isAtStart,
|
|
137
|
+
isAtEnd
|
|
138
|
+
});
|
|
139
|
+
}, []);
|
|
140
|
+
|
|
141
|
+
// 处理垂直滚动
|
|
142
|
+
const handleVerticalScroll = useCallback(event => {
|
|
143
|
+
const {
|
|
144
|
+
contentOffset,
|
|
145
|
+
contentSize,
|
|
146
|
+
layoutMeasurement
|
|
147
|
+
} = event.nativeEvent;
|
|
148
|
+
const isAtStart = contentOffset.y <= 0;
|
|
149
|
+
const isAtEnd = contentOffset.y + layoutMeasurement.height >= contentSize.height - 1;
|
|
150
|
+
setVerticalScrollState({
|
|
151
|
+
isAtStart,
|
|
152
|
+
isAtEnd
|
|
153
|
+
});
|
|
154
|
+
}, []);
|
|
155
|
+
|
|
156
|
+
// 获取单元格对齐方式
|
|
157
|
+
const getCellAlignment = useCallback((column, isHeader = false) => {
|
|
158
|
+
if (column.align) return column.align;
|
|
159
|
+
if (isHeader) return 'center';
|
|
160
|
+
// 默认:数字右对齐,文本左对齐
|
|
161
|
+
if (column.dataType === 'number' || column.dataType === 'currency') {
|
|
162
|
+
return 'right';
|
|
163
|
+
}
|
|
164
|
+
return 'left';
|
|
165
|
+
}, []);
|
|
166
|
+
|
|
167
|
+
// 渲染单元格内容
|
|
168
|
+
const renderCellContent = useCallback((column, cell, rowData) => {
|
|
169
|
+
// 自定义渲染
|
|
170
|
+
if (column.render) {
|
|
171
|
+
return column.render(cell, rowData);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Action 列
|
|
175
|
+
if (column.isAction && rowActions) {
|
|
176
|
+
return /*#__PURE__*/_jsx(View, {
|
|
177
|
+
style: styles.actionContainer,
|
|
178
|
+
children: rowActions.map((action, index) => /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
179
|
+
style: styles.actionButton,
|
|
180
|
+
onPress: () => action.onPress(cell.rowKey, rowData),
|
|
181
|
+
activeOpacity: 0.7,
|
|
182
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
183
|
+
style: styles.actionButtonText,
|
|
184
|
+
children: action.label
|
|
185
|
+
})
|
|
186
|
+
}, index))
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 默认渲染
|
|
191
|
+
const align = getCellAlignment(column);
|
|
192
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
193
|
+
style: [styles.cellContentContainer, {
|
|
194
|
+
alignItems: align === 'left' ? 'flex-start' : align === 'right' ? 'flex-end' : 'center'
|
|
195
|
+
}],
|
|
196
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
197
|
+
style: [styles.cellQuantity, align === 'right' && styles.cellQuantityRight],
|
|
198
|
+
children: formatQuantity(cell.quantity)
|
|
199
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
200
|
+
style: [styles.cellAmount, align === 'right' && styles.cellAmountRight],
|
|
201
|
+
children: formatAmount(cell.amount)
|
|
202
|
+
})]
|
|
203
|
+
});
|
|
204
|
+
}, [rowActions, getCellAlignment, formatQuantity, formatAmount]);
|
|
82
205
|
if (loading) {
|
|
83
206
|
return /*#__PURE__*/_jsx(View, {
|
|
84
207
|
style: [styles.container, style],
|
|
@@ -102,13 +225,37 @@ export function StatisticsTable({
|
|
|
102
225
|
})
|
|
103
226
|
});
|
|
104
227
|
}
|
|
228
|
+
|
|
229
|
+
// 虚拟滚动实现(简化版)
|
|
230
|
+
const visibleRows = enableVirtualization ? rows.slice(0, Math.ceil(maxHeight / virtualRowHeight)) : rows;
|
|
105
231
|
return /*#__PURE__*/_jsxs(View, {
|
|
106
232
|
style: [styles.container, style],
|
|
107
|
-
children: [/*#__PURE__*/_jsx(
|
|
233
|
+
children: [enableScrollShadow && !horizontalScrollState.isAtStart && /*#__PURE__*/_jsx(View, {
|
|
234
|
+
style: [styles.shadowLeft, {
|
|
235
|
+
width: scrollShadowSize,
|
|
236
|
+
backgroundColor: 'transparent',
|
|
237
|
+
shadowColor: scrollShadowColor
|
|
238
|
+
}]
|
|
239
|
+
}), enableScrollShadow && !horizontalScrollState.isAtEnd && /*#__PURE__*/_jsx(View, {
|
|
240
|
+
style: [styles.shadowRight, {
|
|
241
|
+
width: scrollShadowSize,
|
|
242
|
+
backgroundColor: 'transparent',
|
|
243
|
+
shadowColor: scrollShadowColor
|
|
244
|
+
}]
|
|
245
|
+
}), /*#__PURE__*/_jsx(ScrollView, {
|
|
246
|
+
ref: horizontalScrollRef,
|
|
108
247
|
horizontal: true,
|
|
109
248
|
showsHorizontalScrollIndicator: Platform.OS === 'web',
|
|
249
|
+
onScroll: handleHorizontalScroll,
|
|
250
|
+
scrollEventThrottle: 16,
|
|
110
251
|
children: /*#__PURE__*/_jsxs(View, {
|
|
111
|
-
children: [/*#__PURE__*/
|
|
252
|
+
children: [enableScrollShadow && !verticalScrollState.isAtStart && /*#__PURE__*/_jsx(View, {
|
|
253
|
+
style: [styles.shadowTop, {
|
|
254
|
+
height: scrollShadowSize,
|
|
255
|
+
backgroundColor: 'transparent',
|
|
256
|
+
shadowColor: scrollShadowColor
|
|
257
|
+
}]
|
|
258
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
112
259
|
style: styles.header,
|
|
113
260
|
children: [/*#__PURE__*/_jsx(View, {
|
|
114
261
|
style: [styles.headerCell, {
|
|
@@ -117,15 +264,21 @@ export function StatisticsTable({
|
|
|
117
264
|
children: /*#__PURE__*/_jsx(Text, {
|
|
118
265
|
style: styles.headerText
|
|
119
266
|
})
|
|
120
|
-
}), columns.map(column =>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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, {
|
|
129
282
|
children: [/*#__PURE__*/_jsx(View, {
|
|
130
283
|
style: [styles.headerCell, {
|
|
131
284
|
width: 120
|
|
@@ -145,17 +298,29 @@ export function StatisticsTable({
|
|
|
145
298
|
})]
|
|
146
299
|
})]
|
|
147
300
|
}), /*#__PURE__*/_jsxs(ScrollView, {
|
|
301
|
+
ref: verticalScrollRef,
|
|
148
302
|
style: {
|
|
149
303
|
maxHeight
|
|
150
304
|
},
|
|
151
305
|
showsVerticalScrollIndicator: Platform.OS === 'web',
|
|
152
|
-
|
|
306
|
+
removeClippedSubviews: enableVirtualization,
|
|
307
|
+
onScroll: handleVerticalScroll,
|
|
308
|
+
scrollEventThrottle: 16,
|
|
309
|
+
children: [visibleRows.map((row, rowIndex) => {
|
|
153
310
|
const rowStat = rowStats?.[rowIndex];
|
|
154
|
-
|
|
155
|
-
|
|
311
|
+
const isClickable = !!onRowPress;
|
|
312
|
+
const currentRowHeight = getRowHeightValue(row);
|
|
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,
|
|
156
320
|
children: [/*#__PURE__*/_jsx(View, {
|
|
157
321
|
style: [styles.cell, {
|
|
158
|
-
width: rowLabelWidth
|
|
322
|
+
width: rowLabelWidth,
|
|
323
|
+
minHeight: currentRowHeight
|
|
159
324
|
}],
|
|
160
325
|
children: /*#__PURE__*/_jsx(Text, {
|
|
161
326
|
style: styles.rowLabel,
|
|
@@ -164,43 +329,50 @@ export function StatisticsTable({
|
|
|
164
329
|
}), columns.map(column => {
|
|
165
330
|
const cell = matrix[row.key]?.[column.key] || {
|
|
166
331
|
quantity: 0,
|
|
167
|
-
amount: 0
|
|
332
|
+
amount: 0,
|
|
333
|
+
rowKey: row.key,
|
|
334
|
+
columnKey: column.key
|
|
168
335
|
};
|
|
169
|
-
|
|
336
|
+
const align = getCellAlignment(column);
|
|
337
|
+
const colWidth = getColWidth(column);
|
|
338
|
+
return /*#__PURE__*/_jsx(View, {
|
|
170
339
|
style: [styles.cell, {
|
|
171
|
-
width:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
style: styles.cellAmount,
|
|
178
|
-
children: ["\u20AC", cell.amount.toFixed(2)]
|
|
179
|
-
})]
|
|
340
|
+
width: colWidth,
|
|
341
|
+
minWidth: column.minWidth,
|
|
342
|
+
maxWidth: column.maxWidth,
|
|
343
|
+
minHeight: currentRowHeight
|
|
344
|
+
}, align === 'right' && styles.cellRight, align === 'left' && styles.cellLeft],
|
|
345
|
+
children: renderCellContent(column, cell, row.data)
|
|
180
346
|
}, column.key);
|
|
181
347
|
}), showRowStats && rowStat && /*#__PURE__*/_jsxs(_Fragment, {
|
|
182
|
-
children: [/*#__PURE__*/
|
|
183
|
-
style: [styles.cell, {
|
|
348
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
349
|
+
style: [styles.cell, styles.cellRight, {
|
|
184
350
|
width: 120
|
|
185
351
|
}],
|
|
186
|
-
children:
|
|
187
|
-
style: styles.
|
|
188
|
-
children:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
352
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
353
|
+
style: styles.cellContentContainer,
|
|
354
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
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
|
+
})]
|
|
361
|
+
})
|
|
362
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
363
|
+
style: [styles.cell, styles.cellRight, {
|
|
195
364
|
width: 120
|
|
196
365
|
}],
|
|
197
|
-
children:
|
|
198
|
-
style: styles.
|
|
199
|
-
children:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
366
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
367
|
+
style: styles.cellContentContainer,
|
|
368
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
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
|
+
})]
|
|
375
|
+
})
|
|
204
376
|
})]
|
|
205
377
|
})]
|
|
206
378
|
}, row.key);
|
|
@@ -215,19 +387,35 @@ export function StatisticsTable({
|
|
|
215
387
|
style: styles.statsLabel,
|
|
216
388
|
children: "Sum"
|
|
217
389
|
})
|
|
218
|
-
}), columns.map(
|
|
219
|
-
const
|
|
220
|
-
|
|
390
|
+
}), columns.map(column => {
|
|
391
|
+
const colWidth = getColWidth(column);
|
|
392
|
+
if (column.isAction) {
|
|
393
|
+
return /*#__PURE__*/_jsx(View, {
|
|
394
|
+
style: [styles.cell, {
|
|
395
|
+
width: colWidth,
|
|
396
|
+
minWidth: column.minWidth,
|
|
397
|
+
maxWidth: column.maxWidth
|
|
398
|
+
}]
|
|
399
|
+
}, column.key);
|
|
400
|
+
}
|
|
401
|
+
const stat = columnStats[columns.filter(c => !c.isAction).indexOf(column)];
|
|
402
|
+
const align = getCellAlignment(column);
|
|
403
|
+
return /*#__PURE__*/_jsx(View, {
|
|
221
404
|
style: [styles.cell, {
|
|
222
|
-
width:
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
405
|
+
width: colWidth,
|
|
406
|
+
minWidth: column.minWidth,
|
|
407
|
+
maxWidth: column.maxWidth
|
|
408
|
+
}, align === 'right' && styles.cellRight, align === 'left' && styles.cellLeft],
|
|
409
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
410
|
+
style: styles.cellContentContainer,
|
|
411
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
412
|
+
style: [styles.cellQuantity, align === 'right' && styles.cellQuantityRight],
|
|
413
|
+
children: formatQuantity(stat?.sumQuantity || 0)
|
|
414
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
415
|
+
style: [styles.cellAmount, align === 'right' && styles.cellAmountRight],
|
|
416
|
+
children: formatAmount(stat?.sumAmount || 0)
|
|
417
|
+
})]
|
|
418
|
+
})
|
|
231
419
|
}, column.key);
|
|
232
420
|
}), showRowStats && /*#__PURE__*/_jsxs(_Fragment, {
|
|
233
421
|
children: [/*#__PURE__*/_jsx(View, {
|
|
@@ -250,19 +438,35 @@ export function StatisticsTable({
|
|
|
250
438
|
style: styles.statsLabel,
|
|
251
439
|
children: "Mean"
|
|
252
440
|
})
|
|
253
|
-
}), columns.map(
|
|
254
|
-
const
|
|
255
|
-
|
|
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, {
|
|
256
455
|
style: [styles.cell, {
|
|
257
|
-
width:
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
})
|
|
266
470
|
}, column.key);
|
|
267
471
|
}), showRowStats && /*#__PURE__*/_jsxs(_Fragment, {
|
|
268
472
|
children: [/*#__PURE__*/_jsx(View, {
|
|
@@ -277,6 +481,12 @@ export function StatisticsTable({
|
|
|
277
481
|
})]
|
|
278
482
|
})]
|
|
279
483
|
})]
|
|
484
|
+
}), enableScrollShadow && !verticalScrollState.isAtEnd && /*#__PURE__*/_jsx(View, {
|
|
485
|
+
style: [styles.shadowBottom, {
|
|
486
|
+
height: scrollShadowSize,
|
|
487
|
+
backgroundColor: 'transparent',
|
|
488
|
+
shadowColor: scrollShadowColor
|
|
489
|
+
}]
|
|
280
490
|
})]
|
|
281
491
|
})
|
|
282
492
|
}), pagination !== false && pagination && /*#__PURE__*/_jsx(View, {
|
|
@@ -312,12 +522,26 @@ const styles = StyleSheet.create({
|
|
|
312
522
|
padding: 12,
|
|
313
523
|
borderRightWidth: 1,
|
|
314
524
|
borderRightColor: '#E0E0E0',
|
|
315
|
-
justifyContent: 'center'
|
|
525
|
+
justifyContent: 'center',
|
|
526
|
+
alignItems: 'center'
|
|
527
|
+
},
|
|
528
|
+
headerCellLeft: {
|
|
529
|
+
alignItems: 'flex-start'
|
|
530
|
+
},
|
|
531
|
+
headerCellRight: {
|
|
532
|
+
alignItems: 'flex-end'
|
|
316
533
|
},
|
|
317
534
|
headerText: {
|
|
318
535
|
fontSize: 14,
|
|
319
536
|
fontWeight: '600',
|
|
320
|
-
color: '#2C3E50'
|
|
537
|
+
color: '#2C3E50',
|
|
538
|
+
textAlign: 'center'
|
|
539
|
+
},
|
|
540
|
+
headerTextLeft: {
|
|
541
|
+
textAlign: 'left'
|
|
542
|
+
},
|
|
543
|
+
headerTextRight: {
|
|
544
|
+
textAlign: 'right'
|
|
321
545
|
},
|
|
322
546
|
row: {
|
|
323
547
|
flexDirection: 'row',
|
|
@@ -331,9 +555,19 @@ const styles = StyleSheet.create({
|
|
|
331
555
|
cell: {
|
|
332
556
|
padding: 12,
|
|
333
557
|
justifyContent: 'center',
|
|
558
|
+
alignItems: 'center',
|
|
334
559
|
borderRightWidth: 1,
|
|
335
560
|
borderRightColor: '#F0F0F0'
|
|
336
561
|
},
|
|
562
|
+
cellLeft: {
|
|
563
|
+
alignItems: 'flex-start'
|
|
564
|
+
},
|
|
565
|
+
cellRight: {
|
|
566
|
+
alignItems: 'flex-end'
|
|
567
|
+
},
|
|
568
|
+
cellContentContainer: {
|
|
569
|
+
width: '100%'
|
|
570
|
+
},
|
|
337
571
|
rowLabel: {
|
|
338
572
|
fontSize: 14,
|
|
339
573
|
fontWeight: '500',
|
|
@@ -343,17 +577,41 @@ const styles = StyleSheet.create({
|
|
|
343
577
|
fontSize: 14,
|
|
344
578
|
fontWeight: '500',
|
|
345
579
|
color: '#2C3E50',
|
|
346
|
-
marginBottom: 4
|
|
580
|
+
marginBottom: 4,
|
|
581
|
+
textAlign: 'left'
|
|
582
|
+
},
|
|
583
|
+
cellQuantityRight: {
|
|
584
|
+
textAlign: 'right'
|
|
347
585
|
},
|
|
348
586
|
cellAmount: {
|
|
349
587
|
fontSize: 12,
|
|
350
|
-
color: '#7F8C8D'
|
|
588
|
+
color: '#7F8C8D',
|
|
589
|
+
textAlign: 'left'
|
|
590
|
+
},
|
|
591
|
+
cellAmountRight: {
|
|
592
|
+
textAlign: 'right'
|
|
351
593
|
},
|
|
352
594
|
statsLabel: {
|
|
353
595
|
fontSize: 14,
|
|
354
596
|
fontWeight: '600',
|
|
355
597
|
color: '#2C3E50'
|
|
356
598
|
},
|
|
599
|
+
actionContainer: {
|
|
600
|
+
flexDirection: 'row',
|
|
601
|
+
gap: 8,
|
|
602
|
+
justifyContent: 'center'
|
|
603
|
+
},
|
|
604
|
+
actionButton: {
|
|
605
|
+
paddingHorizontal: 12,
|
|
606
|
+
paddingVertical: 6,
|
|
607
|
+
backgroundColor: '#FF6B00',
|
|
608
|
+
borderRadius: 4
|
|
609
|
+
},
|
|
610
|
+
actionButtonText: {
|
|
611
|
+
fontSize: 12,
|
|
612
|
+
fontWeight: '600',
|
|
613
|
+
color: '#FFFFFF'
|
|
614
|
+
},
|
|
357
615
|
loadingRow: {
|
|
358
616
|
padding: 40,
|
|
359
617
|
justifyContent: 'center',
|
|
@@ -373,6 +631,63 @@ const styles = StyleSheet.create({
|
|
|
373
631
|
borderTopWidth: 1,
|
|
374
632
|
borderTopColor: '#E0E0E0',
|
|
375
633
|
backgroundColor: '#FAFAFA'
|
|
634
|
+
},
|
|
635
|
+
// 滚动阴影
|
|
636
|
+
shadowLeft: {
|
|
637
|
+
position: 'absolute',
|
|
638
|
+
left: 0,
|
|
639
|
+
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
|
|
649
|
+
},
|
|
650
|
+
shadowRight: {
|
|
651
|
+
position: 'absolute',
|
|
652
|
+
right: 0,
|
|
653
|
+
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
|
|
663
|
+
},
|
|
664
|
+
shadowTop: {
|
|
665
|
+
position: 'absolute',
|
|
666
|
+
left: 0,
|
|
667
|
+
right: 0,
|
|
668
|
+
top: 0,
|
|
669
|
+
zIndex: 10,
|
|
670
|
+
shadowOffset: {
|
|
671
|
+
width: 0,
|
|
672
|
+
height: 2
|
|
673
|
+
},
|
|
674
|
+
shadowOpacity: 0.15,
|
|
675
|
+
shadowRadius: 4,
|
|
676
|
+
elevation: 4
|
|
677
|
+
},
|
|
678
|
+
shadowBottom: {
|
|
679
|
+
position: 'absolute',
|
|
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
|
|
376
691
|
}
|
|
377
692
|
});
|
|
378
693
|
//# sourceMappingURL=StatisticsTable.js.map
|