gm-datagrid 0.1.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/LICENSE +21 -0
- package/README.md +351 -0
- package/dist/GMDatagrid.d.ts +10 -0
- package/dist/GMDatagridInner.d.ts +4 -0
- package/dist/GMGridContainer.d.ts +19 -0
- package/dist/assets/clipboard.worker-B1pvzQ3O.js +2 -0
- package/dist/cells/EditCell.d.ts +16 -0
- package/dist/cells/ImageCell.d.ts +10 -0
- package/dist/cells/LabelsCell.d.ts +9 -0
- package/dist/cells/ProgressCell.d.ts +10 -0
- package/dist/cells/StatusCell.d.ts +11 -0
- package/dist/cells/ViewCell.d.ts +17 -0
- package/dist/components/GMGridEmptyState.d.ts +12 -0
- package/dist/context/GridContext.d.ts +23 -0
- package/dist/core_engine-Cnhrb_In.js +360 -0
- package/dist/dataset/useGMDataSet.d.ts +34 -0
- package/dist/engine/useEngineSync.d.ts +19 -0
- package/dist/engine/useGridEngine.d.ts +15 -0
- package/dist/features/useClipboard.d.ts +12 -0
- package/dist/features/useColumnResize.d.ts +16 -0
- package/dist/features/useExport.d.ts +12 -0
- package/dist/features/useInlineEdit.d.ts +24 -0
- package/dist/features/useKeyboardNav.d.ts +23 -0
- package/dist/features/useSelection.d.ts +19 -0
- package/dist/features/useVirtualization.d.ts +20 -0
- package/dist/gm-datagrid.js +4391 -0
- package/dist/gm-datagrid.umd.cjs +32 -0
- package/dist/index.d.ts +6 -0
- package/dist/toolbar/GridToolbar.d.ts +20 -0
- package/dist/toolbar/MobileToolbar.d.ts +18 -0
- package/dist/toolbar/ToolbarButtons.d.ts +14 -0
- package/dist/types/index.d.ts +123 -0
- package/dist/wasm/core_engine.d.ts +146 -0
- package/dist/workers/clipboard.worker.d.ts +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GM Dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# gm-datagrid
|
|
2
|
+
|
|
3
|
+
Enterprise-grade, Excel-like data grid for React — powered by a **Rust/WebAssembly** core engine.
|
|
4
|
+
|
|
5
|
+
- ⚡ Handles **100 000+ rows** at 60 FPS with canvas-free virtualization
|
|
6
|
+
- 🦀 Sorting, filtering, aggregation and Excel export run inside **Rust/Wasm** — off the main thread
|
|
7
|
+
- 📋 Excel-compatible clipboard (Ctrl+C / Ctrl+V TSV)
|
|
8
|
+
- ✏️ Inline cell editing with async validation and automatic revert on error
|
|
9
|
+
- 📊 Column subtotals updated live as filters change
|
|
10
|
+
- 📥 One-click `.xlsx` export (generated in Wasm, no server round-trip)
|
|
11
|
+
- 🎨 Built on [MUI](https://mui.com/) — inherits your existing theme automatically
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# npm
|
|
19
|
+
npm install gm-datagrid
|
|
20
|
+
|
|
21
|
+
# pnpm
|
|
22
|
+
pnpm add gm-datagrid
|
|
23
|
+
|
|
24
|
+
# yarn
|
|
25
|
+
yarn add gm-datagrid
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Peer dependencies
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install react react-dom @mui/material @mui/icons-material @emotion/react @emotion/styled
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { GMDatagrid, ColumnDataTypesEnum } from 'gm-datagrid'
|
|
40
|
+
|
|
41
|
+
const columns = [
|
|
42
|
+
{ field: 'id', headerName: 'ID', type: ColumnDataTypesEnum.ID },
|
|
43
|
+
{ field: 'name', headerName: 'Name', type: ColumnDataTypesEnum.STRING, sortable: true },
|
|
44
|
+
{ field: 'price', headerName: 'Price', type: ColumnDataTypesEnum.PRICE, calculateSubTotal: true },
|
|
45
|
+
{ field: 'stock', headerName: 'Stock', type: ColumnDataTypesEnum.INT },
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
async function fetchProducts(params) {
|
|
49
|
+
const res = await fetch('/api/products?' + new URLSearchParams(params))
|
|
50
|
+
const data = await res.json()
|
|
51
|
+
return { success: true, data }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default function ProductsPage() {
|
|
55
|
+
return (
|
|
56
|
+
<GMDatagrid
|
|
57
|
+
title="Products"
|
|
58
|
+
columns={columns}
|
|
59
|
+
sourceApi={fetchProducts}
|
|
60
|
+
apiParameters={{ active: true }}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Props
|
|
69
|
+
|
|
70
|
+
| Prop | Type | Default | Description |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| `title` | `string` | **required** | Grid heading shown in the toolbar |
|
|
73
|
+
| `columns` | `ColumnDef[]` | **required** | Column definitions (see below) |
|
|
74
|
+
| `sourceApi` | `(params) => Promise<{ success, data }>` | — | Async data fetcher. Called on mount and after every `refresh()` |
|
|
75
|
+
| `apiParameters` | `object` | `{}` | Extra params merged into every `sourceApi` call |
|
|
76
|
+
| `localData` | `Row[]` | — | Static data — skips `sourceApi` entirely |
|
|
77
|
+
| `apiContext` | `ApiContext` | — | Injected into every `sourceApi` call (e.g. `companyId`, `authToken`) |
|
|
78
|
+
| `processRowUpdate` | `(newRow, oldRow) => Row \| Promise<Row>` | — | Called when a cell is saved. Throw to reject and revert |
|
|
79
|
+
| `quickFilter` | `boolean` | `true` | Show / hide the global search input in the toolbar |
|
|
80
|
+
| `quickFilterPlaceholder` | `string` | — | Placeholder text for the quick-filter input |
|
|
81
|
+
| `rowColorGetter` | `(row) => { backgroundColor?, color? }` | — | Per-row color highlights (e.g. overdue rows in red) |
|
|
82
|
+
| `onRowDetail` | `(row) => void` | — | Called when the user opens a row detail (double-click or menu action) |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Column definition (`ColumnDef`)
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
interface ColumnDef {
|
|
90
|
+
field: string // key in the row object
|
|
91
|
+
headerName?: string // display label (falls back to field)
|
|
92
|
+
type: ColumnDataTypesEnum // controls rendering, formatting and export
|
|
93
|
+
width?: number // initial width in px
|
|
94
|
+
minWidth?: number // minimum resize width in px
|
|
95
|
+
flex?: number // flex-grow factor (like CSS flex)
|
|
96
|
+
hide?: boolean // exclude column from render
|
|
97
|
+
pin?: 'left' | 'right' // sticky pinned columns
|
|
98
|
+
sortable?: boolean // enable header click to sort
|
|
99
|
+
filterable?: boolean // include in filter panel
|
|
100
|
+
editable?: boolean // enable inline cell editing
|
|
101
|
+
calculateSubTotal?: boolean // show running sum in header
|
|
102
|
+
renderCell?: (params: CellRenderParams) => ReactNode // custom renderer
|
|
103
|
+
valueGetter?: (row: Row) => unknown // transform raw value before render
|
|
104
|
+
valueFormatter?: (value: unknown) => string // format to display string
|
|
105
|
+
statusMap?: Record<string, { label: string; color: string }> // for `status` type
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Column types (`ColumnDataTypesEnum`)
|
|
110
|
+
|
|
111
|
+
| Value | Renders as | Notes |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `STRING` | Plain text | Default |
|
|
114
|
+
| `NUMBER` | `1,234` | Right-aligned |
|
|
115
|
+
| `PRICE` | `1,234.0000` | 4 decimal places, right-aligned |
|
|
116
|
+
| `TOTAL` | `1,234.00` | 2 decimal places, right-aligned |
|
|
117
|
+
| `DISCOUNT` | Progress bar | 0–100 range |
|
|
118
|
+
| `PERCENT` | Progress bar | 0–100 range |
|
|
119
|
+
| `TAX` | Progress bar | 0–100 range |
|
|
120
|
+
| `MARGIN` | Progress bar | 0–100 range |
|
|
121
|
+
| `DATE` | `DD/MM/YYYY` | |
|
|
122
|
+
| `DATE_TIME` | `DD/MM/YYYY HH:mm:ss` | |
|
|
123
|
+
| `STATUS` | Coloured chip | Use `statusMap` to configure labels/colors |
|
|
124
|
+
| `LABELS` | Array of chips | Cell value must be `string[]` |
|
|
125
|
+
| `IMAGE` | 40 px avatar | Cell value is a URL |
|
|
126
|
+
| `ACTION` | Custom renderer | Provide `renderCell` |
|
|
127
|
+
| `MENU_ACTION` | Icon button + menu | Triggers `onRowDetail` |
|
|
128
|
+
| `ID` | Plain text | |
|
|
129
|
+
| `INT` | `1,234` | Integer, right-aligned |
|
|
130
|
+
| `CODE` | Plain text | Monospace hint |
|
|
131
|
+
| `ARRAY` | Comma-joined | Cell value is `string[]` |
|
|
132
|
+
| `TEXT` | Plain text | Multi-line friendly |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Ref API (imperative handle)
|
|
137
|
+
|
|
138
|
+
Use `GMGridContainer` when you need to refresh the grid or update its parameters from outside:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { useRef } from 'react'
|
|
142
|
+
import { GMGridContainer } from 'gm-datagrid'
|
|
143
|
+
import type { GMGridContainerRef } from 'gm-datagrid'
|
|
144
|
+
|
|
145
|
+
export default function OrdersPage() {
|
|
146
|
+
const gridRef = useRef<GMGridContainerRef>(null)
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<>
|
|
150
|
+
<button onClick={() => gridRef.current?.refresh()}>Refresh</button>
|
|
151
|
+
<button onClick={() => gridRef.current?.setParams({ status: 'PENDING' })}>
|
|
152
|
+
Show pending
|
|
153
|
+
</button>
|
|
154
|
+
|
|
155
|
+
<GMGridContainer
|
|
156
|
+
ref={gridRef}
|
|
157
|
+
title="Orders"
|
|
158
|
+
columns={columns}
|
|
159
|
+
sourceApi={fetchOrders}
|
|
160
|
+
/>
|
|
161
|
+
</>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
| Method | Signature | Description |
|
|
167
|
+
|---|---|---|
|
|
168
|
+
| `refresh()` | `() => void` | Re-fetches data with the current params |
|
|
169
|
+
| `setParams(p)` | `(params: object) => void` | Replaces `apiParameters` and re-fetches |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Context hook (`useGMGrid`)
|
|
174
|
+
|
|
175
|
+
Access the grid state from any child component rendered inside `GMDatagrid`:
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import { useGMGrid } from 'gm-datagrid'
|
|
179
|
+
|
|
180
|
+
function OrderSummary() {
|
|
181
|
+
const { data, loading, totalCount } = useGMGrid()
|
|
182
|
+
|
|
183
|
+
if (loading) return null
|
|
184
|
+
return <p>{totalCount} orders loaded</p>
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
| Field | Type | Description |
|
|
189
|
+
|---|---|---|
|
|
190
|
+
| `data` | `Row[]` | All rows currently in the dataset |
|
|
191
|
+
| `loading` | `boolean` | `true` while `sourceApi` is in flight |
|
|
192
|
+
| `totalCount` | `number` | Total filtered row count (for pagination display) |
|
|
193
|
+
| `handleRefresh` | `() => void` | Trigger a manual refresh |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Inline editing
|
|
198
|
+
|
|
199
|
+
Enable `editable: true` on a column and provide `processRowUpdate`:
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
async function saveRow(newRow, oldRow) {
|
|
203
|
+
const res = await fetch(`/api/products/${newRow.id}`, {
|
|
204
|
+
method: 'PATCH',
|
|
205
|
+
body: JSON.stringify(newRow),
|
|
206
|
+
})
|
|
207
|
+
if (!res.ok) throw new Error('Save failed')
|
|
208
|
+
return newRow
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
<GMDatagrid
|
|
212
|
+
title="Products"
|
|
213
|
+
columns={[
|
|
214
|
+
{ field: 'name', type: ColumnDataTypesEnum.STRING, editable: true },
|
|
215
|
+
{ field: 'price', type: ColumnDataTypesEnum.PRICE, editable: true },
|
|
216
|
+
]}
|
|
217
|
+
sourceApi={fetchProducts}
|
|
218
|
+
processRowUpdate={saveRow}
|
|
219
|
+
/>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Keyboard shortcuts while editing:**
|
|
223
|
+
|
|
224
|
+
| Key | Action |
|
|
225
|
+
|---|---|
|
|
226
|
+
| Any printable key | Enter edit mode, replace value |
|
|
227
|
+
| `F2` | Enter edit mode, keep current value |
|
|
228
|
+
| `Enter` | Save and move to the next row |
|
|
229
|
+
| `Tab` / `Shift+Tab` | Save and move right / left |
|
|
230
|
+
| `Escape` | Discard and exit edit mode |
|
|
231
|
+
| Arrow keys | Move focused cell (outside edit mode) |
|
|
232
|
+
|
|
233
|
+
If `processRowUpdate` throws, the cell reverts automatically to its original value.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Custom cell renderer
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
import { ColumnDataTypesEnum } from 'gm-datagrid'
|
|
241
|
+
|
|
242
|
+
const columns = [
|
|
243
|
+
{
|
|
244
|
+
field: 'status',
|
|
245
|
+
type: ColumnDataTypesEnum.ACTION,
|
|
246
|
+
renderCell: ({ row, value }) => (
|
|
247
|
+
<span style={{ color: value === 'ACTIVE' ? 'green' : 'red' }}>
|
|
248
|
+
{String(value)}
|
|
249
|
+
</span>
|
|
250
|
+
),
|
|
251
|
+
},
|
|
252
|
+
]
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
The `renderCell` function receives:
|
|
256
|
+
|
|
257
|
+
| Param | Type | Description |
|
|
258
|
+
|---|---|---|
|
|
259
|
+
| `row` | `Row` | The full row object |
|
|
260
|
+
| `field` | `string` | The column field name |
|
|
261
|
+
| `value` | `unknown` | The (possibly `valueGetter`-transformed) cell value |
|
|
262
|
+
| `colDef` | `ColumnDef` | The full column definition |
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Row colour highlights
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
<GMDatagrid
|
|
270
|
+
title="Invoices"
|
|
271
|
+
columns={columns}
|
|
272
|
+
sourceApi={fetchInvoices}
|
|
273
|
+
rowColorGetter={(row) => {
|
|
274
|
+
if (row.overdue) return { backgroundColor: '#fff3f3', color: '#c62828' }
|
|
275
|
+
if (row.status === 'PAID') return { backgroundColor: '#f3fff5' }
|
|
276
|
+
return {}
|
|
277
|
+
}}
|
|
278
|
+
/>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Multi-tenant / authenticated APIs
|
|
284
|
+
|
|
285
|
+
Use `apiContext` to inject auth tokens or tenant IDs without modifying each `sourceApi`:
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import { useSession } from './contexts/SessionContext'
|
|
289
|
+
|
|
290
|
+
function App() {
|
|
291
|
+
const { token, companyId } = useSession()
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<GMDatagrid
|
|
295
|
+
title="Customers"
|
|
296
|
+
columns={columns}
|
|
297
|
+
sourceApi={fetchCustomers}
|
|
298
|
+
apiContext={{ authToken: token, companyId }}
|
|
299
|
+
/>
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Excel export
|
|
307
|
+
|
|
308
|
+
The toolbar includes an **Export** button that generates a `.xlsx` file entirely inside the Wasm engine — no server call required. The exported file reflects the current sort and filter state.
|
|
309
|
+
|
|
310
|
+
Column formatting is preserved in the export:
|
|
311
|
+
|
|
312
|
+
- `PRICE` / `TOTAL` columns use Excel number formats
|
|
313
|
+
- `DATE` / `DATE_TIME` columns use Excel date formats
|
|
314
|
+
- Progress types (`DISCOUNT`, `PERCENT`, etc.) export as raw numbers (0–100)
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Subtotals
|
|
319
|
+
|
|
320
|
+
Set `calculateSubTotal: true` on any numeric column to display a live running sum in the column header. The subtotal updates as filters change.
|
|
321
|
+
|
|
322
|
+
```tsx
|
|
323
|
+
{ field: 'amount', type: ColumnDataTypesEnum.TOTAL, calculateSubTotal: true }
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## TypeScript
|
|
329
|
+
|
|
330
|
+
All types are exported from the package root:
|
|
331
|
+
|
|
332
|
+
```ts
|
|
333
|
+
import type {
|
|
334
|
+
ColumnDef,
|
|
335
|
+
GMDatagridProps,
|
|
336
|
+
GMGridContainerRef,
|
|
337
|
+
Row,
|
|
338
|
+
CellRenderParams,
|
|
339
|
+
FilterGroup,
|
|
340
|
+
SortKey,
|
|
341
|
+
ApiContext,
|
|
342
|
+
} from 'gm-datagrid'
|
|
343
|
+
|
|
344
|
+
import { ColumnDataTypesEnum } from 'gm-datagrid'
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## License
|
|
350
|
+
|
|
351
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GMDatagridProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* GMDatagrid — Rust/Wasm-powered enterprise grid with Excel-like editing.
|
|
4
|
+
* Drop-in replacement for GMGridContainer.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* <GMDatagrid title="Productos" sourceApi={productsApi.list} columns={columns} />
|
|
8
|
+
*/
|
|
9
|
+
export declare function GMDatagrid(props: GMDatagridProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default GMDatagrid;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GMDatagridProps } from './types';
|
|
2
|
+
export interface GMGridContainerRef {
|
|
3
|
+
refresh: () => void;
|
|
4
|
+
setParams: (params: Record<string, unknown>) => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* GMGridContainer — drop-in replacement for the legacy GMGridContainer skill.
|
|
8
|
+
*
|
|
9
|
+
* Identical prop surface: title, sourceApi, columns, apiParameters, localData
|
|
10
|
+
*
|
|
11
|
+
* Identical ref API:
|
|
12
|
+
* ref.current.refresh()
|
|
13
|
+
* ref.current.setParams(newParams)
|
|
14
|
+
*
|
|
15
|
+
* Identical context hook:
|
|
16
|
+
* const { data, loading, columns, handleRefresh } = useGMGrid()
|
|
17
|
+
*/
|
|
18
|
+
export declare const GMGridContainer: import('react').ForwardRefExoticComponent<GMDatagridProps & import('react').RefAttributes<GMGridContainerRef>>;
|
|
19
|
+
export default GMGridContainer;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){"use strict";self.onmessage=t=>{if(t.data.type!=="PARSE_TSV")return;const{text:n,columns:a}=t.data,c=n.split(`
|
|
2
|
+
`).filter(Boolean).map(s=>s.split(" ")).map(s=>{const o={};return s.forEach((f,i)=>{const e=a[i]?.field;e&&(o[e]=f)}),o});self.postMessage({type:"PARSED",rows:c})}})();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ColumnDef } from '../types';
|
|
3
|
+
interface EditCellProps {
|
|
4
|
+
rowId: string;
|
|
5
|
+
field: string;
|
|
6
|
+
column: ColumnDef;
|
|
7
|
+
editValue: string;
|
|
8
|
+
onEditValueChange: (v: string) => void;
|
|
9
|
+
onStopEditing: (save: boolean) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Inline edit cell — renders an <input> or <select> depending on column type.
|
|
13
|
+
* Controlled by the parent via editValue/onEditValueChange.
|
|
14
|
+
*/
|
|
15
|
+
declare const EditCell: React.NamedExoticComponent<EditCellProps>;
|
|
16
|
+
export default EditCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface ImageCellProps {
|
|
3
|
+
value: string | null | undefined;
|
|
4
|
+
alt?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Renders a 40px MUI Avatar for `image` column type.
|
|
8
|
+
*/
|
|
9
|
+
declare const ImageCell: React.NamedExoticComponent<ImageCellProps>;
|
|
10
|
+
export default ImageCell;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface LabelsCellProps {
|
|
3
|
+
value: string[] | null | undefined;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Renders an array of MUI Chips for the `labels` column type.
|
|
7
|
+
*/
|
|
8
|
+
declare const LabelsCell: React.NamedExoticComponent<LabelsCellProps>;
|
|
9
|
+
export default LabelsCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface ProgressCellProps {
|
|
3
|
+
value: number | null | undefined;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Renders a MUI LinearProgress bar for percent/discount/tax/margin column types.
|
|
7
|
+
* Value is expected in 0–100 range.
|
|
8
|
+
*/
|
|
9
|
+
declare const ProgressCell: React.NamedExoticComponent<ProgressCellProps>;
|
|
10
|
+
export default ProgressCell;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ColumnDef } from '../types';
|
|
3
|
+
interface StatusCellProps {
|
|
4
|
+
value: string | null | undefined;
|
|
5
|
+
column: ColumnDef;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Renders a styled MUI Chip using the column's `statusMap` definition.
|
|
9
|
+
*/
|
|
10
|
+
declare const StatusCell: React.NamedExoticComponent<StatusCellProps>;
|
|
11
|
+
export default StatusCell;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ColumnDef, Row } from '../types';
|
|
3
|
+
interface ViewCellProps {
|
|
4
|
+
row: Row;
|
|
5
|
+
column: ColumnDef;
|
|
6
|
+
isSelected: boolean;
|
|
7
|
+
isFocused: boolean;
|
|
8
|
+
onClick: (e: React.MouseEvent) => void;
|
|
9
|
+
onMouseEnter: (e: React.MouseEvent) => void;
|
|
10
|
+
onDoubleClick: (e: React.MouseEvent) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Read-only cell component. Dispatches to specialised renderers by column type.
|
|
14
|
+
* Wrapped in React.memo with a custom comparator to prevent unnecessary re-renders.
|
|
15
|
+
*/
|
|
16
|
+
declare const ViewCell: React.NamedExoticComponent<ViewCellProps>;
|
|
17
|
+
export default ViewCell;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface GMGridEmptyStateProps {
|
|
3
|
+
variant: 'empty' | 'filtered' | 'error';
|
|
4
|
+
message?: string;
|
|
5
|
+
onClear?: () => void;
|
|
6
|
+
onRetry?: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Empty/filtered/error state for the grid — never render an empty tbody.
|
|
10
|
+
*/
|
|
11
|
+
declare const GMGridEmptyState: React.NamedExoticComponent<GMGridEmptyStateProps>;
|
|
12
|
+
export default GMGridEmptyState;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Row } from '../types';
|
|
3
|
+
import { DataSetState } from '../dataset/useGMDataSet';
|
|
4
|
+
interface GridContextValue extends DataSetState {
|
|
5
|
+
pageRows: Row[];
|
|
6
|
+
totalCount: number;
|
|
7
|
+
subtotals: Record<string, number>;
|
|
8
|
+
page: number;
|
|
9
|
+
pageSize: number;
|
|
10
|
+
setPage: (p: number) => void;
|
|
11
|
+
setPageSize: (s: number) => void;
|
|
12
|
+
engineReady: boolean;
|
|
13
|
+
engineError: Error | null;
|
|
14
|
+
retryEngine: () => void;
|
|
15
|
+
}
|
|
16
|
+
interface GridProviderProps {
|
|
17
|
+
dataset: DataSetState;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
defaultPageSize?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function GridProvider({ dataset, children, defaultPageSize }: GridProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function useGMGrid(): GridContextValue;
|
|
23
|
+
export {};
|