pace-table-lib 1.0.0 → 1.0.2
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/README.md +181 -4
- package/dist/pace-table-lib.es.js +3271 -3246
- package/dist/pace-table-lib.umd.js +16 -16
- package/dist/stats.html +4687 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,12 +1,189 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
# pace-table-lib
|
|
2
4
|
|
|
3
|
-
A lightweight
|
|
5
|
+
A lightweight React component library for rendering **highly-configurable, Excel-like static tables** with fixed headers, custom styles, and flexible measure formatting.
|
|
4
6
|
|
|
5
7
|
---
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
* **Fixed left columns** (freeze columns/rows for better readability)
|
|
12
|
+
* **Grand total, row total, and column total support**
|
|
13
|
+
* **Custom number formatting** (comma separators, precision, display units, etc.)
|
|
14
|
+
* Flexible styling via a single `tableStyleProps` object
|
|
15
|
+
* Fully typed with **TypeScript**
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 📦 Installation
|
|
10
20
|
|
|
11
21
|
```bash
|
|
12
22
|
npm install pace-table-lib
|
|
23
|
+
# or
|
|
24
|
+
yarn add pace-table-lib
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🔑 Basic Usage
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import React from "react";
|
|
33
|
+
import { StaticTable } from "pace-table-lib";
|
|
34
|
+
import { createMeasureFormattingMapping } from "./measureFormatHelper";
|
|
35
|
+
|
|
36
|
+
export default function App() {
|
|
37
|
+
const tableData = /* your JSON from API or file */;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<StaticTable
|
|
41
|
+
tableData={tableData?.TableData}
|
|
42
|
+
leftFixedCellNameList={tableData?.leftFixedCellNameList ?? [""]}
|
|
43
|
+
tableStyleProps={tableData?.TableStyle?.TableStyle?.Style}
|
|
44
|
+
tableWidth={800}
|
|
45
|
+
tableHeight={600}
|
|
46
|
+
measureFormatConfigs={() => createMeasureFormattingMapping()}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ⚙️ Props
|
|
55
|
+
|
|
56
|
+
| Prop | Type | Required | Description |
|
|
57
|
+
| ------------------------- | --------------------------- | -------- | ----------------------------------------------------------- |
|
|
58
|
+
| **tableData** | `TableData` | ✅ | Data object describing rows, columns, totals, and measures. |
|
|
59
|
+
| **leftFixedCellNameList** | `string[]` | ❌ | Names of columns to freeze on the left. |
|
|
60
|
+
| **tableStyleProps** | `object` | ❌ | Style configuration (colors, fonts, borders, etc.). |
|
|
61
|
+
| **tableWidth** | `number` | ✅ | Total table width in pixels. |
|
|
62
|
+
| **tableHeight** | `number` | ✅ | Total table height in pixels. |
|
|
63
|
+
| **measureFormatConfigs** | `() => MeasureFormatConfig` | ✅ | Function returning measure formatting rules. |
|
|
64
|
+
|
|
65
|
+
### `MeasureFormatConfig`
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
{
|
|
69
|
+
measureName: string; // e.g., "New Patients"
|
|
70
|
+
numberFormat: string; // e.g., "Comma Separated"
|
|
71
|
+
displayUnit: string; // e.g., "None", "K", "M"
|
|
72
|
+
decimalPrecision: number; // e.g., 2
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Example:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
export const createMeasureFormattingMapping = () => ({
|
|
80
|
+
measureName: "New Patients",
|
|
81
|
+
numberFormat: "Comma Separated",
|
|
82
|
+
displayUnit: "None",
|
|
83
|
+
decimalPrecision: 2
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 📐 Table Data Structure
|
|
90
|
+
|
|
91
|
+
The component expects a JSON object similar to:
|
|
92
|
+
|
|
93
|
+
```jsonc
|
|
94
|
+
{
|
|
95
|
+
"TableData": {
|
|
96
|
+
"customSortRowwise": ["1L", "2L", "Adj"],
|
|
97
|
+
"grandTotal": 400701,
|
|
98
|
+
"measuresBySlice": [
|
|
99
|
+
{
|
|
100
|
+
"sliceMark": ["1L", "Base"],
|
|
101
|
+
"measures": [0, 0, 81087],
|
|
102
|
+
"rowTotal": 81087
|
|
103
|
+
},
|
|
104
|
+
...
|
|
105
|
+
],
|
|
106
|
+
"columnTotalRow": [
|
|
107
|
+
{ "columnTotal": 148247, "maxValueInColumn": 89526, "minValueInColumn": 0 }
|
|
108
|
+
],
|
|
109
|
+
"dimensionMarks": [["HCC"], ["RCC"], ["SCLC"]],
|
|
110
|
+
"totalNumberOfRows": 9
|
|
111
|
+
},
|
|
112
|
+
"leftFixedCellNameList": ["LOT", "Scenario"],
|
|
113
|
+
"TableStyle": {
|
|
114
|
+
"TableStyle": {
|
|
115
|
+
"Style": { /* font, color, border config */ }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Use your own API or static file to populate this structure.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 🖌 Styling
|
|
126
|
+
|
|
127
|
+
Pass the `tableStyleProps` from your data:
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
tableStyleProps={tableData?.TableStyle?.TableStyle?.Style}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
It supports:
|
|
134
|
+
|
|
135
|
+
* **Row/Column header colors**
|
|
136
|
+
* Borders & grid lines
|
|
137
|
+
* Conditional formatting (if enabled in your data)
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 🧩 TypeScript Support
|
|
142
|
+
|
|
143
|
+
The library ships with full type definitions. Import types as needed:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { TableData, MeasureFormatConfig } from "pace-table-lib";
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 🛠 Development
|
|
152
|
+
|
|
153
|
+
Clone the repo and run:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm install
|
|
157
|
+
npm run dev
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 📄 License
|
|
163
|
+
|
|
164
|
+
MIT © 2025
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### Quick Example
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
<StaticTable
|
|
172
|
+
tableData={mockData.TableData}
|
|
173
|
+
leftFixedCellNameList={["LOT", "Scenario"]}
|
|
174
|
+
tableStyleProps={mockData.TableStyle.TableStyle.Style}
|
|
175
|
+
tableWidth={1000}
|
|
176
|
+
tableHeight={600}
|
|
177
|
+
measureFormatConfigs={() => ({
|
|
178
|
+
measureName: "New Patients",
|
|
179
|
+
numberFormat: "Comma Separated",
|
|
180
|
+
displayUnit: "None",
|
|
181
|
+
decimalPrecision: 2
|
|
182
|
+
})}
|
|
183
|
+
/>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
This will render a scrollable, Excel-like table with frozen left columns and comma-separated numbers.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|