@beppla/tapas-ui 1.2.34 → 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/README.md +178 -0
- package/components/StatisticsTable/StatisticsTable.tsx +451 -45
- package/components/StatisticsTable/index.tsx +4 -1
- package/components/index.tsx +10 -2
- package/package/commonjs/StatisticsTable/README.md +178 -0
- 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/README.md +178 -0
- 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
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# StatisticsTable
|
|
2
|
+
|
|
3
|
+
A versatile table component for displaying matrix data with optional row and column statistics (Sum/Mean).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ Matrix data display (rows × columns)
|
|
8
|
+
- ✅ Row statistics (Sum/Mean columns)
|
|
9
|
+
- ✅ Column statistics (Sum/Mean rows)
|
|
10
|
+
- ✅ Horizontal and vertical scrolling
|
|
11
|
+
- ✅ Pagination support
|
|
12
|
+
- ✅ Loading state
|
|
13
|
+
- ✅ Empty state
|
|
14
|
+
- ✅ Customizable styling
|
|
15
|
+
- ✅ TypeScript support
|
|
16
|
+
- ✅ Cross-platform (Web & Mobile)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add @beppla/tapas-ui
|
|
22
|
+
# or
|
|
23
|
+
npm install @beppla/tapas-ui
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Basic Usage
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { StatisticsTable } from '@beppla/tapas-ui';
|
|
30
|
+
|
|
31
|
+
const rows = [
|
|
32
|
+
{ key: '2024-12-01', label: 'Dec 1, 2024' },
|
|
33
|
+
{ key: '2024-12-02', label: 'Dec 2, 2024' },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const columns = [
|
|
37
|
+
{ key: 'store1', title: 'Store A', width: 150 },
|
|
38
|
+
{ key: 'store2', title: 'Store B', width: 150 },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const cells = [
|
|
42
|
+
{ rowKey: '2024-12-01', columnKey: 'store1', quantity: 100, amount: 500.00 },
|
|
43
|
+
{ rowKey: '2024-12-01', columnKey: 'store2', quantity: 150, amount: 750.00 },
|
|
44
|
+
{ rowKey: '2024-12-02', columnKey: 'store1', quantity: 120, amount: 600.00 },
|
|
45
|
+
{ rowKey: '2024-12-02', columnKey: 'store2', quantity: 180, amount: 900.00 },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
<StatisticsTable
|
|
49
|
+
rows={rows}
|
|
50
|
+
columns={columns}
|
|
51
|
+
cells={cells}
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## With Row Statistics
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<StatisticsTable
|
|
59
|
+
rows={rows}
|
|
60
|
+
columns={columns}
|
|
61
|
+
cells={cells}
|
|
62
|
+
showRowStats={true}
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## With Column Statistics
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<StatisticsTable
|
|
70
|
+
rows={rows}
|
|
71
|
+
columns={columns}
|
|
72
|
+
cells={cells}
|
|
73
|
+
showColumnStats={true}
|
|
74
|
+
/>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## With Both Statistics
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
<StatisticsTable
|
|
81
|
+
rows={rows}
|
|
82
|
+
columns={columns}
|
|
83
|
+
cells={cells}
|
|
84
|
+
showRowStats={true}
|
|
85
|
+
showColumnStats={true}
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## With Pagination
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<StatisticsTable
|
|
93
|
+
rows={rows}
|
|
94
|
+
columns={columns}
|
|
95
|
+
cells={cells}
|
|
96
|
+
pagination={{
|
|
97
|
+
current: 1,
|
|
98
|
+
pageSize: 10,
|
|
99
|
+
total: 100,
|
|
100
|
+
onChange: (page, pageSize) => {
|
|
101
|
+
console.log('Page:', page, 'PageSize:', pageSize);
|
|
102
|
+
},
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Props
|
|
108
|
+
|
|
109
|
+
| Prop | Type | Default | Description |
|
|
110
|
+
|------|------|---------|-------------|
|
|
111
|
+
| `rows` | `Array<{ key: string; label: string }>` | Required | Row definitions |
|
|
112
|
+
| `columns` | `StatisticsTableColumn[]` | Required | Column definitions |
|
|
113
|
+
| `cells` | `StatisticsTableCell[]` | Required | Cell data |
|
|
114
|
+
| `showRowStats` | `boolean` | `false` | Show row statistics (Sum/Mean columns) |
|
|
115
|
+
| `showColumnStats` | `boolean` | `false` | Show column statistics (Sum/Mean rows) |
|
|
116
|
+
| `pagination` | `PaginationConfig \| false` | `false` | Pagination configuration |
|
|
117
|
+
| `loading` | `boolean` | `false` | Show loading state |
|
|
118
|
+
| `emptyText` | `string` | `'No data'` | Text for empty state |
|
|
119
|
+
| `maxHeight` | `number` | `500` | Maximum table body height |
|
|
120
|
+
| `rowLabelWidth` | `number` | `150` | Width of first column (row labels) |
|
|
121
|
+
| `style` | `ViewStyle` | - | Custom container styles |
|
|
122
|
+
|
|
123
|
+
## Type Definitions
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
interface StatisticsTableColumn {
|
|
127
|
+
key: string;
|
|
128
|
+
title: string;
|
|
129
|
+
width?: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface StatisticsTableCell {
|
|
133
|
+
rowKey: string;
|
|
134
|
+
columnKey: string;
|
|
135
|
+
quantity: number;
|
|
136
|
+
amount: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface PaginationConfig {
|
|
140
|
+
current: number;
|
|
141
|
+
pageSize: number;
|
|
142
|
+
total: number;
|
|
143
|
+
onChange?: (page: number, pageSize: number) => void;
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Use Cases
|
|
148
|
+
|
|
149
|
+
- **Metadata Details**: Display sales/wastage data by date and store
|
|
150
|
+
- **Performance Reports**: Show metrics across time periods and locations
|
|
151
|
+
- **Financial Tables**: Display revenue/cost data with totals and averages
|
|
152
|
+
- **Analytics Dashboards**: Present multi-dimensional data with statistics
|
|
153
|
+
|
|
154
|
+
## Backward Compatibility
|
|
155
|
+
|
|
156
|
+
This component is fully compatible with:
|
|
157
|
+
- React Native 0.76+
|
|
158
|
+
- React 18.3+
|
|
159
|
+
- TypeScript 5.0+
|
|
160
|
+
- Expo SDK 52+
|
|
161
|
+
|
|
162
|
+
## Accessibility
|
|
163
|
+
|
|
164
|
+
- Proper semantic structure
|
|
165
|
+
- Scrollable content indicators
|
|
166
|
+
- Screen reader friendly
|
|
167
|
+
- Keyboard navigation support (Web)
|
|
168
|
+
|
|
169
|
+
## Performance
|
|
170
|
+
|
|
171
|
+
- Optimized with `useMemo` for large datasets
|
|
172
|
+
- Efficient re-rendering
|
|
173
|
+
- Virtualization-ready (future enhancement)
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT
|
|
178
|
+
|