@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
package/components/index.tsx
CHANGED
|
@@ -113,7 +113,8 @@ export type { TapasTabProps } from "./Tab/TapasTab";
|
|
|
113
113
|
export type { TapasTabTitleProps } from "./TabTitle/TabTitle";
|
|
114
114
|
export type { TapasAnimatedNavItemProps } from "./AnimatedNavItem/AnimatedNavItem";
|
|
115
115
|
export type { TapasTableColumnHeaderProps, SortDirection, SortState } from "./TableColumnHeader/TableColumnHeader";
|
|
116
|
-
export type { TapasDataCellProps, DataType,
|
|
116
|
+
export type { TapasDataCellProps, DataType, StatusConfig, ActionItem } from "./DataCell/DataCell";
|
|
117
|
+
export type { CellAlignment as DataCellAlignment } from "./DataCell/DataCell";
|
|
117
118
|
export type { TapasMultiSelectorProps, TapasMultiSelectorItem } from "./MultiSelector/MultiSelector";
|
|
118
119
|
export type { TapasQuantityProps } from "./Quantity/Quantity";
|
|
119
120
|
export type { DropdownProps } from "./Dropdown/Dropdown";
|
|
@@ -176,7 +177,14 @@ export type { DataTableProps, DataTableColumn } from "./DataTable";
|
|
|
176
177
|
export { StatisticCard } from "./StatisticCard";
|
|
177
178
|
export type { StatisticCardProps } from "./StatisticCard";
|
|
178
179
|
export { StatisticsTable } from "./StatisticsTable";
|
|
179
|
-
export type {
|
|
180
|
+
export type {
|
|
181
|
+
StatisticsTableProps,
|
|
182
|
+
StatisticsTableColumn,
|
|
183
|
+
StatisticsTableCell,
|
|
184
|
+
StatisticsTableAction,
|
|
185
|
+
CellAlignment,
|
|
186
|
+
CellDataType,
|
|
187
|
+
} from "./StatisticsTable";
|
|
180
188
|
|
|
181
189
|
// 工具函数
|
|
182
190
|
export { isMobile, capitalizeFirstLetter } from "./common";
|
|
@@ -22,8 +22,32 @@ function StatisticsTable({
|
|
|
22
22
|
emptyText = 'No data',
|
|
23
23
|
maxHeight = 500,
|
|
24
24
|
rowLabelWidth = 150,
|
|
25
|
-
style
|
|
25
|
+
style,
|
|
26
|
+
formatQuantity = q => q.toLocaleString(),
|
|
27
|
+
formatAmount = a => `€${a.toFixed(2)}`,
|
|
28
|
+
enableVirtualization = false,
|
|
29
|
+
virtualRowHeight = 60,
|
|
30
|
+
onRowPress,
|
|
31
|
+
rowActions,
|
|
32
|
+
rowHeight = 60,
|
|
33
|
+
getRowHeight,
|
|
34
|
+
getColumnWidth,
|
|
35
|
+
enableScrollShadow = true,
|
|
36
|
+
scrollShadowColor = 'rgba(0, 0, 0, 0.1)',
|
|
37
|
+
scrollShadowSize = 8
|
|
26
38
|
}) {
|
|
39
|
+
// 滚动状态
|
|
40
|
+
const [horizontalScrollState, setHorizontalScrollState] = (0, _react.useState)({
|
|
41
|
+
isAtStart: true,
|
|
42
|
+
isAtEnd: false
|
|
43
|
+
});
|
|
44
|
+
const [verticalScrollState, setVerticalScrollState] = (0, _react.useState)({
|
|
45
|
+
isAtStart: true,
|
|
46
|
+
isAtEnd: false
|
|
47
|
+
});
|
|
48
|
+
const horizontalScrollRef = (0, _react.useRef)(null);
|
|
49
|
+
const verticalScrollRef = (0, _react.useRef)(null);
|
|
50
|
+
|
|
27
51
|
// 构建矩阵数据
|
|
28
52
|
const matrix = (0, _react.useMemo)(() => {
|
|
29
53
|
const data = {};
|
|
@@ -46,7 +70,8 @@ function StatisticsTable({
|
|
|
46
70
|
const rowStats = (0, _react.useMemo)(() => {
|
|
47
71
|
if (!showRowStats) return null;
|
|
48
72
|
return rows.map(row => {
|
|
49
|
-
const rowCells = columns.
|
|
73
|
+
const rowCells = columns.filter(col => !col.isAction) // 排除 action 列
|
|
74
|
+
.map(col => matrix[row.key]?.[col.key] || {
|
|
50
75
|
quantity: 0,
|
|
51
76
|
amount: 0
|
|
52
77
|
});
|
|
@@ -67,7 +92,8 @@ function StatisticsTable({
|
|
|
67
92
|
// 计算列统计(每列的总和和平均值)
|
|
68
93
|
const columnStats = (0, _react.useMemo)(() => {
|
|
69
94
|
if (!showColumnStats) return null;
|
|
70
|
-
return columns.
|
|
95
|
+
return columns.filter(col => !col.isAction) // 排除 action 列
|
|
96
|
+
.map(col => {
|
|
71
97
|
const colCells = rows.map(row => matrix[row.key]?.[col.key] || {
|
|
72
98
|
quantity: 0,
|
|
73
99
|
amount: 0
|
|
@@ -85,6 +111,103 @@ function StatisticsTable({
|
|
|
85
111
|
};
|
|
86
112
|
});
|
|
87
113
|
}, [rows, columns, matrix, showColumnStats]);
|
|
114
|
+
|
|
115
|
+
// 获取列宽
|
|
116
|
+
const getColWidth = (0, _react.useCallback)(column => {
|
|
117
|
+
if (getColumnWidth) {
|
|
118
|
+
return getColumnWidth(column.key, column);
|
|
119
|
+
}
|
|
120
|
+
return column.width || 150;
|
|
121
|
+
}, [getColumnWidth]);
|
|
122
|
+
|
|
123
|
+
// 获取行高
|
|
124
|
+
const getRowHeightValue = (0, _react.useCallback)(row => {
|
|
125
|
+
if (row.height) return row.height;
|
|
126
|
+
if (getRowHeight) {
|
|
127
|
+
return getRowHeight(row.key, row.data);
|
|
128
|
+
}
|
|
129
|
+
return rowHeight;
|
|
130
|
+
}, [rowHeight, getRowHeight]);
|
|
131
|
+
|
|
132
|
+
// 处理水平滚动
|
|
133
|
+
const handleHorizontalScroll = (0, _react.useCallback)(event => {
|
|
134
|
+
const {
|
|
135
|
+
contentOffset,
|
|
136
|
+
contentSize,
|
|
137
|
+
layoutMeasurement
|
|
138
|
+
} = event.nativeEvent;
|
|
139
|
+
const isAtStart = contentOffset.x <= 0;
|
|
140
|
+
const isAtEnd = contentOffset.x + layoutMeasurement.width >= contentSize.width - 1;
|
|
141
|
+
setHorizontalScrollState({
|
|
142
|
+
isAtStart,
|
|
143
|
+
isAtEnd
|
|
144
|
+
});
|
|
145
|
+
}, []);
|
|
146
|
+
|
|
147
|
+
// 处理垂直滚动
|
|
148
|
+
const handleVerticalScroll = (0, _react.useCallback)(event => {
|
|
149
|
+
const {
|
|
150
|
+
contentOffset,
|
|
151
|
+
contentSize,
|
|
152
|
+
layoutMeasurement
|
|
153
|
+
} = event.nativeEvent;
|
|
154
|
+
const isAtStart = contentOffset.y <= 0;
|
|
155
|
+
const isAtEnd = contentOffset.y + layoutMeasurement.height >= contentSize.height - 1;
|
|
156
|
+
setVerticalScrollState({
|
|
157
|
+
isAtStart,
|
|
158
|
+
isAtEnd
|
|
159
|
+
});
|
|
160
|
+
}, []);
|
|
161
|
+
|
|
162
|
+
// 获取单元格对齐方式
|
|
163
|
+
const getCellAlignment = (0, _react.useCallback)((column, isHeader = false) => {
|
|
164
|
+
if (column.align) return column.align;
|
|
165
|
+
if (isHeader) return 'center';
|
|
166
|
+
// 默认:数字右对齐,文本左对齐
|
|
167
|
+
if (column.dataType === 'number' || column.dataType === 'currency') {
|
|
168
|
+
return 'right';
|
|
169
|
+
}
|
|
170
|
+
return 'left';
|
|
171
|
+
}, []);
|
|
172
|
+
|
|
173
|
+
// 渲染单元格内容
|
|
174
|
+
const renderCellContent = (0, _react.useCallback)((column, cell, rowData) => {
|
|
175
|
+
// 自定义渲染
|
|
176
|
+
if (column.render) {
|
|
177
|
+
return column.render(cell, rowData);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Action 列
|
|
181
|
+
if (column.isAction && rowActions) {
|
|
182
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
183
|
+
style: styles.actionContainer,
|
|
184
|
+
children: rowActions.map((action, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
185
|
+
style: styles.actionButton,
|
|
186
|
+
onPress: () => action.onPress(cell.rowKey, rowData),
|
|
187
|
+
activeOpacity: 0.7,
|
|
188
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
189
|
+
style: styles.actionButtonText,
|
|
190
|
+
children: action.label
|
|
191
|
+
})
|
|
192
|
+
}, index))
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 默认渲染
|
|
197
|
+
const align = getCellAlignment(column);
|
|
198
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
199
|
+
style: [styles.cellContentContainer, {
|
|
200
|
+
alignItems: align === 'left' ? 'flex-start' : align === 'right' ? 'flex-end' : 'center'
|
|
201
|
+
}],
|
|
202
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
203
|
+
style: [styles.cellQuantity, align === 'right' && styles.cellQuantityRight],
|
|
204
|
+
children: formatQuantity(cell.quantity)
|
|
205
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
206
|
+
style: [styles.cellAmount, align === 'right' && styles.cellAmountRight],
|
|
207
|
+
children: formatAmount(cell.amount)
|
|
208
|
+
})]
|
|
209
|
+
});
|
|
210
|
+
}, [rowActions, getCellAlignment, formatQuantity, formatAmount]);
|
|
88
211
|
if (loading) {
|
|
89
212
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
90
213
|
style: [styles.container, style],
|
|
@@ -108,13 +231,37 @@ function StatisticsTable({
|
|
|
108
231
|
})
|
|
109
232
|
});
|
|
110
233
|
}
|
|
234
|
+
|
|
235
|
+
// 虚拟滚动实现(简化版)
|
|
236
|
+
const visibleRows = enableVirtualization ? rows.slice(0, Math.ceil(maxHeight / virtualRowHeight)) : rows;
|
|
111
237
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
112
238
|
style: [styles.container, style],
|
|
113
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.
|
|
239
|
+
children: [enableScrollShadow && !horizontalScrollState.isAtStart && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
240
|
+
style: [styles.shadowLeft, {
|
|
241
|
+
width: scrollShadowSize,
|
|
242
|
+
backgroundColor: 'transparent',
|
|
243
|
+
shadowColor: scrollShadowColor
|
|
244
|
+
}]
|
|
245
|
+
}), enableScrollShadow && !horizontalScrollState.isAtEnd && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
246
|
+
style: [styles.shadowRight, {
|
|
247
|
+
width: scrollShadowSize,
|
|
248
|
+
backgroundColor: 'transparent',
|
|
249
|
+
shadowColor: scrollShadowColor
|
|
250
|
+
}]
|
|
251
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
252
|
+
ref: horizontalScrollRef,
|
|
114
253
|
horizontal: true,
|
|
115
254
|
showsHorizontalScrollIndicator: _reactNative.Platform.OS === 'web',
|
|
255
|
+
onScroll: handleHorizontalScroll,
|
|
256
|
+
scrollEventThrottle: 16,
|
|
116
257
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
117
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
258
|
+
children: [enableScrollShadow && !verticalScrollState.isAtStart && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
259
|
+
style: [styles.shadowTop, {
|
|
260
|
+
height: scrollShadowSize,
|
|
261
|
+
backgroundColor: 'transparent',
|
|
262
|
+
shadowColor: scrollShadowColor
|
|
263
|
+
}]
|
|
264
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
118
265
|
style: styles.header,
|
|
119
266
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
120
267
|
style: [styles.headerCell, {
|
|
@@ -123,15 +270,21 @@ function StatisticsTable({
|
|
|
123
270
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
124
271
|
style: styles.headerText
|
|
125
272
|
})
|
|
126
|
-
}), columns.map(column =>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
273
|
+
}), columns.map(column => {
|
|
274
|
+
const align = getCellAlignment(column, true);
|
|
275
|
+
const colWidth = getColWidth(column);
|
|
276
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
277
|
+
style: [styles.headerCell, {
|
|
278
|
+
width: colWidth,
|
|
279
|
+
minWidth: column.minWidth,
|
|
280
|
+
maxWidth: column.maxWidth
|
|
281
|
+
}, align === 'right' && styles.headerCellRight, align === 'left' && styles.headerCellLeft],
|
|
282
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
283
|
+
style: [styles.headerText, align === 'right' && styles.headerTextRight, align === 'left' && styles.headerTextLeft],
|
|
284
|
+
children: column.title
|
|
285
|
+
})
|
|
286
|
+
}, column.key);
|
|
287
|
+
}), showRowStats && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
135
288
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
136
289
|
style: [styles.headerCell, {
|
|
137
290
|
width: 120
|
|
@@ -151,17 +304,29 @@ function StatisticsTable({
|
|
|
151
304
|
})]
|
|
152
305
|
})]
|
|
153
306
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
|
|
307
|
+
ref: verticalScrollRef,
|
|
154
308
|
style: {
|
|
155
309
|
maxHeight
|
|
156
310
|
},
|
|
157
311
|
showsVerticalScrollIndicator: _reactNative.Platform.OS === 'web',
|
|
158
|
-
|
|
312
|
+
removeClippedSubviews: enableVirtualization,
|
|
313
|
+
onScroll: handleVerticalScroll,
|
|
314
|
+
scrollEventThrottle: 16,
|
|
315
|
+
children: [visibleRows.map((row, rowIndex) => {
|
|
159
316
|
const rowStat = rowStats?.[rowIndex];
|
|
160
|
-
|
|
161
|
-
|
|
317
|
+
const isClickable = !!onRowPress;
|
|
318
|
+
const currentRowHeight = getRowHeightValue(row);
|
|
319
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
320
|
+
style: [styles.row, {
|
|
321
|
+
minHeight: currentRowHeight
|
|
322
|
+
}],
|
|
323
|
+
onPress: isClickable ? () => onRowPress(row.key, row.data) : undefined,
|
|
324
|
+
activeOpacity: isClickable ? 0.7 : 1,
|
|
325
|
+
disabled: !isClickable,
|
|
162
326
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
163
327
|
style: [styles.cell, {
|
|
164
|
-
width: rowLabelWidth
|
|
328
|
+
width: rowLabelWidth,
|
|
329
|
+
minHeight: currentRowHeight
|
|
165
330
|
}],
|
|
166
331
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
167
332
|
style: styles.rowLabel,
|
|
@@ -170,43 +335,50 @@ function StatisticsTable({
|
|
|
170
335
|
}), columns.map(column => {
|
|
171
336
|
const cell = matrix[row.key]?.[column.key] || {
|
|
172
337
|
quantity: 0,
|
|
173
|
-
amount: 0
|
|
338
|
+
amount: 0,
|
|
339
|
+
rowKey: row.key,
|
|
340
|
+
columnKey: column.key
|
|
174
341
|
};
|
|
175
|
-
|
|
342
|
+
const align = getCellAlignment(column);
|
|
343
|
+
const colWidth = getColWidth(column);
|
|
344
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
176
345
|
style: [styles.cell, {
|
|
177
|
-
width:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
style: styles.cellAmount,
|
|
184
|
-
children: ["\u20AC", cell.amount.toFixed(2)]
|
|
185
|
-
})]
|
|
346
|
+
width: colWidth,
|
|
347
|
+
minWidth: column.minWidth,
|
|
348
|
+
maxWidth: column.maxWidth,
|
|
349
|
+
minHeight: currentRowHeight
|
|
350
|
+
}, align === 'right' && styles.cellRight, align === 'left' && styles.cellLeft],
|
|
351
|
+
children: renderCellContent(column, cell, row.data)
|
|
186
352
|
}, column.key);
|
|
187
353
|
}), showRowStats && rowStat && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
188
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
189
|
-
style: [styles.cell, {
|
|
354
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
355
|
+
style: [styles.cell, styles.cellRight, {
|
|
190
356
|
width: 120
|
|
191
357
|
}],
|
|
192
|
-
children:
|
|
193
|
-
style: styles.
|
|
194
|
-
children:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
358
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
359
|
+
style: styles.cellContentContainer,
|
|
360
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
361
|
+
style: [styles.cellQuantity, styles.cellQuantityRight],
|
|
362
|
+
children: formatQuantity(rowStat.sumQuantity)
|
|
363
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
364
|
+
style: [styles.cellAmount, styles.cellAmountRight],
|
|
365
|
+
children: formatAmount(rowStat.sumAmount)
|
|
366
|
+
})]
|
|
367
|
+
})
|
|
368
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
369
|
+
style: [styles.cell, styles.cellRight, {
|
|
201
370
|
width: 120
|
|
202
371
|
}],
|
|
203
|
-
children:
|
|
204
|
-
style: styles.
|
|
205
|
-
children:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
372
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
373
|
+
style: styles.cellContentContainer,
|
|
374
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
375
|
+
style: [styles.cellQuantity, styles.cellQuantityRight],
|
|
376
|
+
children: formatQuantity(Math.round(rowStat.meanQuantity * 10) / 10)
|
|
377
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
378
|
+
style: [styles.cellAmount, styles.cellAmountRight],
|
|
379
|
+
children: formatAmount(rowStat.meanAmount)
|
|
380
|
+
})]
|
|
381
|
+
})
|
|
210
382
|
})]
|
|
211
383
|
})]
|
|
212
384
|
}, row.key);
|
|
@@ -221,19 +393,35 @@ function StatisticsTable({
|
|
|
221
393
|
style: styles.statsLabel,
|
|
222
394
|
children: "Sum"
|
|
223
395
|
})
|
|
224
|
-
}), columns.map(
|
|
225
|
-
const
|
|
226
|
-
|
|
396
|
+
}), columns.map(column => {
|
|
397
|
+
const colWidth = getColWidth(column);
|
|
398
|
+
if (column.isAction) {
|
|
399
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
400
|
+
style: [styles.cell, {
|
|
401
|
+
width: colWidth,
|
|
402
|
+
minWidth: column.minWidth,
|
|
403
|
+
maxWidth: column.maxWidth
|
|
404
|
+
}]
|
|
405
|
+
}, column.key);
|
|
406
|
+
}
|
|
407
|
+
const stat = columnStats[columns.filter(c => !c.isAction).indexOf(column)];
|
|
408
|
+
const align = getCellAlignment(column);
|
|
409
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
227
410
|
style: [styles.cell, {
|
|
228
|
-
width:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
411
|
+
width: colWidth,
|
|
412
|
+
minWidth: column.minWidth,
|
|
413
|
+
maxWidth: column.maxWidth
|
|
414
|
+
}, align === 'right' && styles.cellRight, align === 'left' && styles.cellLeft],
|
|
415
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
416
|
+
style: styles.cellContentContainer,
|
|
417
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
418
|
+
style: [styles.cellQuantity, align === 'right' && styles.cellQuantityRight],
|
|
419
|
+
children: formatQuantity(stat?.sumQuantity || 0)
|
|
420
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
421
|
+
style: [styles.cellAmount, align === 'right' && styles.cellAmountRight],
|
|
422
|
+
children: formatAmount(stat?.sumAmount || 0)
|
|
423
|
+
})]
|
|
424
|
+
})
|
|
237
425
|
}, column.key);
|
|
238
426
|
}), showRowStats && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
239
427
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
@@ -256,19 +444,35 @@ function StatisticsTable({
|
|
|
256
444
|
style: styles.statsLabel,
|
|
257
445
|
children: "Mean"
|
|
258
446
|
})
|
|
259
|
-
}), columns.map(
|
|
260
|
-
const
|
|
261
|
-
|
|
447
|
+
}), columns.map(column => {
|
|
448
|
+
const colWidth = getColWidth(column);
|
|
449
|
+
if (column.isAction) {
|
|
450
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
451
|
+
style: [styles.cell, {
|
|
452
|
+
width: colWidth,
|
|
453
|
+
minWidth: column.minWidth,
|
|
454
|
+
maxWidth: column.maxWidth
|
|
455
|
+
}]
|
|
456
|
+
}, column.key);
|
|
457
|
+
}
|
|
458
|
+
const stat = columnStats[columns.filter(c => !c.isAction).indexOf(column)];
|
|
459
|
+
const align = getCellAlignment(column);
|
|
460
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
262
461
|
style: [styles.cell, {
|
|
263
|
-
width:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
462
|
+
width: colWidth,
|
|
463
|
+
minWidth: column.minWidth,
|
|
464
|
+
maxWidth: column.maxWidth
|
|
465
|
+
}, align === 'right' && styles.cellRight, align === 'left' && styles.cellLeft],
|
|
466
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
467
|
+
style: styles.cellContentContainer,
|
|
468
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
469
|
+
style: [styles.cellQuantity, align === 'right' && styles.cellQuantityRight],
|
|
470
|
+
children: formatQuantity(Math.round((stat?.meanQuantity || 0) * 10) / 10)
|
|
471
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
472
|
+
style: [styles.cellAmount, align === 'right' && styles.cellAmountRight],
|
|
473
|
+
children: formatAmount(stat?.meanAmount || 0)
|
|
474
|
+
})]
|
|
475
|
+
})
|
|
272
476
|
}, column.key);
|
|
273
477
|
}), showRowStats && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
274
478
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
@@ -283,6 +487,12 @@ function StatisticsTable({
|
|
|
283
487
|
})]
|
|
284
488
|
})]
|
|
285
489
|
})]
|
|
490
|
+
}), enableScrollShadow && !verticalScrollState.isAtEnd && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
491
|
+
style: [styles.shadowBottom, {
|
|
492
|
+
height: scrollShadowSize,
|
|
493
|
+
backgroundColor: 'transparent',
|
|
494
|
+
shadowColor: scrollShadowColor
|
|
495
|
+
}]
|
|
286
496
|
})]
|
|
287
497
|
})
|
|
288
498
|
}), pagination !== false && pagination && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
@@ -318,12 +528,26 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
318
528
|
padding: 12,
|
|
319
529
|
borderRightWidth: 1,
|
|
320
530
|
borderRightColor: '#E0E0E0',
|
|
321
|
-
justifyContent: 'center'
|
|
531
|
+
justifyContent: 'center',
|
|
532
|
+
alignItems: 'center'
|
|
533
|
+
},
|
|
534
|
+
headerCellLeft: {
|
|
535
|
+
alignItems: 'flex-start'
|
|
536
|
+
},
|
|
537
|
+
headerCellRight: {
|
|
538
|
+
alignItems: 'flex-end'
|
|
322
539
|
},
|
|
323
540
|
headerText: {
|
|
324
541
|
fontSize: 14,
|
|
325
542
|
fontWeight: '600',
|
|
326
|
-
color: '#2C3E50'
|
|
543
|
+
color: '#2C3E50',
|
|
544
|
+
textAlign: 'center'
|
|
545
|
+
},
|
|
546
|
+
headerTextLeft: {
|
|
547
|
+
textAlign: 'left'
|
|
548
|
+
},
|
|
549
|
+
headerTextRight: {
|
|
550
|
+
textAlign: 'right'
|
|
327
551
|
},
|
|
328
552
|
row: {
|
|
329
553
|
flexDirection: 'row',
|
|
@@ -337,9 +561,19 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
337
561
|
cell: {
|
|
338
562
|
padding: 12,
|
|
339
563
|
justifyContent: 'center',
|
|
564
|
+
alignItems: 'center',
|
|
340
565
|
borderRightWidth: 1,
|
|
341
566
|
borderRightColor: '#F0F0F0'
|
|
342
567
|
},
|
|
568
|
+
cellLeft: {
|
|
569
|
+
alignItems: 'flex-start'
|
|
570
|
+
},
|
|
571
|
+
cellRight: {
|
|
572
|
+
alignItems: 'flex-end'
|
|
573
|
+
},
|
|
574
|
+
cellContentContainer: {
|
|
575
|
+
width: '100%'
|
|
576
|
+
},
|
|
343
577
|
rowLabel: {
|
|
344
578
|
fontSize: 14,
|
|
345
579
|
fontWeight: '500',
|
|
@@ -349,17 +583,41 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
349
583
|
fontSize: 14,
|
|
350
584
|
fontWeight: '500',
|
|
351
585
|
color: '#2C3E50',
|
|
352
|
-
marginBottom: 4
|
|
586
|
+
marginBottom: 4,
|
|
587
|
+
textAlign: 'left'
|
|
588
|
+
},
|
|
589
|
+
cellQuantityRight: {
|
|
590
|
+
textAlign: 'right'
|
|
353
591
|
},
|
|
354
592
|
cellAmount: {
|
|
355
593
|
fontSize: 12,
|
|
356
|
-
color: '#7F8C8D'
|
|
594
|
+
color: '#7F8C8D',
|
|
595
|
+
textAlign: 'left'
|
|
596
|
+
},
|
|
597
|
+
cellAmountRight: {
|
|
598
|
+
textAlign: 'right'
|
|
357
599
|
},
|
|
358
600
|
statsLabel: {
|
|
359
601
|
fontSize: 14,
|
|
360
602
|
fontWeight: '600',
|
|
361
603
|
color: '#2C3E50'
|
|
362
604
|
},
|
|
605
|
+
actionContainer: {
|
|
606
|
+
flexDirection: 'row',
|
|
607
|
+
gap: 8,
|
|
608
|
+
justifyContent: 'center'
|
|
609
|
+
},
|
|
610
|
+
actionButton: {
|
|
611
|
+
paddingHorizontal: 12,
|
|
612
|
+
paddingVertical: 6,
|
|
613
|
+
backgroundColor: '#FF6B00',
|
|
614
|
+
borderRadius: 4
|
|
615
|
+
},
|
|
616
|
+
actionButtonText: {
|
|
617
|
+
fontSize: 12,
|
|
618
|
+
fontWeight: '600',
|
|
619
|
+
color: '#FFFFFF'
|
|
620
|
+
},
|
|
363
621
|
loadingRow: {
|
|
364
622
|
padding: 40,
|
|
365
623
|
justifyContent: 'center',
|
|
@@ -379,6 +637,63 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
379
637
|
borderTopWidth: 1,
|
|
380
638
|
borderTopColor: '#E0E0E0',
|
|
381
639
|
backgroundColor: '#FAFAFA'
|
|
640
|
+
},
|
|
641
|
+
// 滚动阴影
|
|
642
|
+
shadowLeft: {
|
|
643
|
+
position: 'absolute',
|
|
644
|
+
left: 0,
|
|
645
|
+
top: 0,
|
|
646
|
+
bottom: 0,
|
|
647
|
+
zIndex: 10,
|
|
648
|
+
shadowOffset: {
|
|
649
|
+
width: 2,
|
|
650
|
+
height: 0
|
|
651
|
+
},
|
|
652
|
+
shadowOpacity: 0.15,
|
|
653
|
+
shadowRadius: 4,
|
|
654
|
+
elevation: 4
|
|
655
|
+
},
|
|
656
|
+
shadowRight: {
|
|
657
|
+
position: 'absolute',
|
|
658
|
+
right: 0,
|
|
659
|
+
top: 0,
|
|
660
|
+
bottom: 0,
|
|
661
|
+
zIndex: 10,
|
|
662
|
+
shadowOffset: {
|
|
663
|
+
width: -2,
|
|
664
|
+
height: 0
|
|
665
|
+
},
|
|
666
|
+
shadowOpacity: 0.15,
|
|
667
|
+
shadowRadius: 4,
|
|
668
|
+
elevation: 4
|
|
669
|
+
},
|
|
670
|
+
shadowTop: {
|
|
671
|
+
position: 'absolute',
|
|
672
|
+
left: 0,
|
|
673
|
+
right: 0,
|
|
674
|
+
top: 0,
|
|
675
|
+
zIndex: 10,
|
|
676
|
+
shadowOffset: {
|
|
677
|
+
width: 0,
|
|
678
|
+
height: 2
|
|
679
|
+
},
|
|
680
|
+
shadowOpacity: 0.15,
|
|
681
|
+
shadowRadius: 4,
|
|
682
|
+
elevation: 4
|
|
683
|
+
},
|
|
684
|
+
shadowBottom: {
|
|
685
|
+
position: 'absolute',
|
|
686
|
+
left: 0,
|
|
687
|
+
right: 0,
|
|
688
|
+
bottom: 0,
|
|
689
|
+
zIndex: 10,
|
|
690
|
+
shadowOffset: {
|
|
691
|
+
width: 0,
|
|
692
|
+
height: -2
|
|
693
|
+
},
|
|
694
|
+
shadowOpacity: 0.15,
|
|
695
|
+
shadowRadius: 4,
|
|
696
|
+
elevation: 4
|
|
382
697
|
}
|
|
383
698
|
});
|
|
384
699
|
//# sourceMappingURL=StatisticsTable.js.map
|