react-gridix 0.2.4 → 0.2.5
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 +247 -16
- package/dist/client-40__X0_a.cjs +1 -0
- package/dist/client-DUlru6F3.js +51 -0
- package/dist/index.d.ts +331 -9
- package/dist/react-gridix.cjs +21 -2
- package/dist/react-gridix.js +1871 -1106
- package/dist/style.css +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -11,7 +11,8 @@ A React `DataGrid` with row selection, server-side mode, typed per-column filter
|
|
|
11
11
|
5. [Checkbox](#5-checkbox)
|
|
12
12
|
6. [DataGrid](#6-datagrid)
|
|
13
13
|
7. [Demos](#7-demos)
|
|
14
|
-
8. [Troubleshooting](#
|
|
14
|
+
8. [Troubleshooting](#9-troubleshooting)
|
|
15
|
+
|
|
15
16
|
---
|
|
16
17
|
|
|
17
18
|
## 1. Overview
|
|
@@ -42,12 +43,13 @@ A React `DataGrid` with row selection, server-side mode, typed per-column filter
|
|
|
42
43
|
|
|
43
44
|
Everything is written in TypeScript, ships its own type definitions, and uses plain CSS (no CSS-in-JS runtime). The grid is 100% of its container's width by default. There is deliberately **no column reordering**.
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-

|
|
48
|
+

|
|
49
|
+

|
|
50
|
+

|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
---
|
|
51
53
|
|
|
52
54
|
## 2. Installation
|
|
53
55
|
|
|
@@ -65,14 +67,67 @@ import "react-gridix/style.css";
|
|
|
65
67
|
|
|
66
68
|
The library does not inject CSS by itself. If the grid looks unstyled, this import is missing.
|
|
67
69
|
|
|
68
|
-
**Optional: PDF export.** CSV, Excel (`.xlsx`) and JSON export need nothing extra. PDF export uses three small libraries
|
|
70
|
+
**Optional: PDF export.** CSV, Excel (`.xlsx`) and JSON export need nothing extra. PDF export uses three small libraries. The grid does **not** import them (so your app builds and runs without them); you install them and hand them over, ideally through a function that imports them only when someone exports a PDF:
|
|
69
71
|
|
|
70
72
|
```bash
|
|
71
73
|
npm install jspdf jspdf-autotable # the PDF itself and its table
|
|
72
74
|
npm install html2canvas # only if the PDF header / footer is a React element (it is drawn to a picture)
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
```tsx
|
|
78
|
+
<DataGrid
|
|
79
|
+
exportable={{
|
|
80
|
+
formats: ["csv", "pdf"],
|
|
81
|
+
pdf: {
|
|
82
|
+
libraries: async () => ({
|
|
83
|
+
jsPDF: (await import("jspdf")).jsPDF,
|
|
84
|
+
autoTable: (await import("jspdf-autotable")).default,
|
|
85
|
+
html2canvas: (await import("html2canvas")).default, // only for a header / footer element
|
|
86
|
+
}),
|
|
87
|
+
},
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
Read more about stying pdf here [stying pdf here](https://github.com/simonbengtsson/jsPDF-AutoTable). Use the style property in `autoTableOptions` for styling cells
|
|
92
|
+
|
|
93
|
+
Adding `Header` and `Footer` component
|
|
94
|
+
```tsx
|
|
95
|
+
import logo from "./logo.png";
|
|
96
|
+
|
|
97
|
+
<DataGrid
|
|
98
|
+
columns={columns}
|
|
99
|
+
rows={rows}
|
|
100
|
+
getRowId={(r) => r.id}
|
|
101
|
+
exportable={{
|
|
102
|
+
formats: ["pdf"],
|
|
103
|
+
pdf: {
|
|
104
|
+
libraries: async () => ({
|
|
105
|
+
jsPDF: (await import("jspdf")).jsPDF,
|
|
106
|
+
autoTable: (await import("jspdf-autotable")).default,
|
|
107
|
+
html2canvas: (await import("html2canvas")).default, // required for an element
|
|
108
|
+
}),
|
|
109
|
+
|
|
110
|
+
header: (
|
|
111
|
+
<div style={{ display: "flex", alignItems: "center", gap: 12, borderBottom: "3px solid #4f46e5", paddingBottom: 6 }}>
|
|
112
|
+
<img src={logo} alt="" width={40} height={40} style={{ borderRadius: 8 }} />
|
|
113
|
+
<div>
|
|
114
|
+
<div style={{ fontSize: 20, fontWeight: 700, color: "#312e81" }}>Acme Corporation</div>
|
|
115
|
+
<div style={{ fontSize: 12, color: "#6b7280" }}>People & Culture report</div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
),
|
|
119
|
+
|
|
120
|
+
footer: (
|
|
121
|
+
<div style={{ textAlign: "center", fontSize: 11, color: "#6b7280" }}>
|
|
122
|
+
Confidential. Do not share.
|
|
123
|
+
</div>
|
|
124
|
+
),
|
|
125
|
+
},
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
``
|
|
129
|
+
|
|
130
|
+
Without `libraries`, or if an import fails, a PDF export reports an error that says what to install (see `onExportError`) and everything else keeps working.
|
|
76
131
|
|
|
77
132
|
---
|
|
78
133
|
|
|
@@ -1943,7 +1998,7 @@ The menu has two parts. **Rows to export** lets the user pick *Visible rows* (wh
|
|
|
1943
1998
|
| `"csv"` | Text of the displayed values, opens in any spreadsheet | nothing |
|
|
1944
1999
|
| `"xlsx"` | A real Excel workbook: bold coloured header row that stays in place while you scroll, auto-filter, sized columns, real numbers, real dates and real booleans | nothing (written by the library itself) |
|
|
1945
2000
|
| `"json"` | An array of objects, one per row, with real numbers and booleans and ISO dates (`"2026-11-05"`) | nothing |
|
|
1946
|
-
| `"pdf"` | A paged table with an optional title, header, footer and "Page 1 of 3" | `jspdf` and `jspdf-autotable` (and `html2canvas` for a header / footer element) |
|
|
2001
|
+
| `"pdf"` | A paged table with an optional title, header, footer and "Page 1 of 3" | `jspdf` and `jspdf-autotable` (and `html2canvas` for a header / footer element), given in `pdf.libraries` |
|
|
1947
2002
|
|
|
1948
2003
|
The same exports are available from code, for your own buttons:
|
|
1949
2004
|
|
|
@@ -1971,6 +2026,89 @@ const csv: string = api.current!.getCsv();
|
|
|
1971
2026
|
/>
|
|
1972
2027
|
```
|
|
1973
2028
|
|
|
2029
|
+
To export pdf, install supporting pdf libraries
|
|
2030
|
+
```bash
|
|
2031
|
+
npm install jspdf jspdf-autotable # the PDF itself and its table
|
|
2032
|
+
npm install html2canvas # only if the PDF header / footer is a React element (it is drawn to a picture)
|
|
2033
|
+
```
|
|
2034
|
+
|
|
2035
|
+
```tsx
|
|
2036
|
+
<DataGrid
|
|
2037
|
+
exportable={{
|
|
2038
|
+
formats: ["csv", "pdf"],
|
|
2039
|
+
pdf: {
|
|
2040
|
+
libraries: async () => ({
|
|
2041
|
+
jsPDF: (await import("jspdf")).jsPDF,
|
|
2042
|
+
autoTable: (await import("jspdf-autotable")).default,
|
|
2043
|
+
html2canvas: (await import("html2canvas")).default, // only for a header / footer element
|
|
2044
|
+
}),
|
|
2045
|
+
},
|
|
2046
|
+
}}
|
|
2047
|
+
/>
|
|
2048
|
+
```
|
|
2049
|
+
|
|
2050
|
+
```tsx
|
|
2051
|
+
<DataGrid
|
|
2052
|
+
rowSelection
|
|
2053
|
+
pagination
|
|
2054
|
+
columns={columns}
|
|
2055
|
+
rows={rows}
|
|
2056
|
+
getRowId={(r) => r.id}
|
|
2057
|
+
exportable={{
|
|
2058
|
+
filename: "employees",
|
|
2059
|
+
formats: ["csv", "xlsx", "json", "pdf"],
|
|
2060
|
+
pdf: {
|
|
2061
|
+
// required for PDF (npm install jspdf jspdf-autotable html2canvas)
|
|
2062
|
+
libraries: async () => ({
|
|
2063
|
+
jsPDF: (await import("jspdf")).jsPDF,
|
|
2064
|
+
autoTable: (await import("jspdf-autotable")).default,
|
|
2065
|
+
html2canvas: (await import("html2canvas")).default,
|
|
2066
|
+
}),
|
|
2067
|
+
|
|
2068
|
+
title: <TitleComponent />,
|
|
2069
|
+
margin: { top: 60, right: 30, bottom: 50, left: 30 },
|
|
2070
|
+
tableTheme: "grid", // "striped" | "grid" | "plain"
|
|
2071
|
+
|
|
2072
|
+
style: {
|
|
2073
|
+
headColor: "#f59e0b", // header row background
|
|
2074
|
+
headTextColor: "#111827",
|
|
2075
|
+
stripeColors: ["#ffffff", "#f1f5f9"], // rows alternate between these
|
|
2076
|
+
bodyTextColor: "#1f2937",
|
|
2077
|
+
borderColor: "#cbd5e1",
|
|
2078
|
+
borderWidth: 0.4,
|
|
2079
|
+
cellPadding: { top: 6, bottom: 6, left: 8, right: 8 },
|
|
2080
|
+
fontSize: 10,
|
|
2081
|
+
pageBackground: "#ffffff", // try "#0f172a" for a dark page
|
|
2082
|
+
columns: { // per column, by its field
|
|
2083
|
+
salary: { fontStyle: "bold", align: "right" },
|
|
2084
|
+
name: { width: 120 },
|
|
2085
|
+
},
|
|
2086
|
+
},
|
|
2087
|
+
},
|
|
2088
|
+
}}
|
|
2089
|
+
/>
|
|
2090
|
+
```
|
|
2091
|
+
Setting Border bottom
|
|
2092
|
+
```tsx
|
|
2093
|
+
pdf: {
|
|
2094
|
+
libraries:async () => ({
|
|
2095
|
+
jsPDF: (await import("jspdf")).jsPDF,
|
|
2096
|
+
autoTable: (await import("jspdf-autotable")).default,
|
|
2097
|
+
html2canvas: (await import("html2canvas")).default,
|
|
2098
|
+
}),
|
|
2099
|
+
//
|
|
2100
|
+
tableTheme: "plain", // plain draws no lines, so only your bottom border shows
|
|
2101
|
+
autoTableOptions: {
|
|
2102
|
+
styles: {
|
|
2103
|
+
lineWidth: { bottom: 0.5 }, // points; only the bottom side
|
|
2104
|
+
lineColor: [203, 213, 225], // [r, g, b]
|
|
2105
|
+
},
|
|
2106
|
+
},
|
|
2107
|
+
}
|
|
2108
|
+
```
|
|
2109
|
+
Read more about stying pdf here [stying pdf here](https://github.com/simonbengtsson/jsPDF-AutoTable). Use the style property in `autoTableOptions` for styling cells
|
|
2110
|
+
|
|
2111
|
+
|
|
1974
2112
|
**Which rows.** `scope` accepts `"filtered"` (default), `"visible"` or `"page"` (the same: the rows on screen) and `"selected"`. A page export continues the row numbers of a `sequence` column (page 2 starts at 11) unless the column has `sequenceRestartEachPage`.
|
|
1975
2113
|
|
|
1976
2114
|
**What each format writes.** CSV and PDF write the displayed text (`valueFormatter` applied, `Yes` / `No` for booleans, dates as `YYYY-MM-DD`). Excel and JSON write real values: a number column stays a number (`52000`, not `"$52,000"`), a boolean column stays `true` / `false`, a date column is a real Excel date, a column with a `valueFormatter` that changes text (for example codes shown as names) writes the shown text. A column's `exportValue(value, row)` overrides all of this in every format.
|
|
@@ -1985,7 +2123,7 @@ const csv: string = api.current!.getCsv();
|
|
|
1985
2123
|
exportable={{
|
|
1986
2124
|
formats: ["pdf"],
|
|
1987
2125
|
pdf: {
|
|
1988
|
-
title:
|
|
2126
|
+
title: <TitleComponent />,
|
|
1989
2127
|
header: "Acme Corporation, People report ({date})",
|
|
1990
2128
|
footer: "Confidential, page {page} of {pages}",
|
|
1991
2129
|
},
|
|
@@ -2027,15 +2165,19 @@ Other `pdf` options:
|
|
|
2027
2165
|
|
|
2028
2166
|
| Option | Default | Meaning |
|
|
2029
2167
|
| --- | --- | --- |
|
|
2168
|
+
| `libraries` | | **Required.** `{ jsPDF, autoTable, html2canvas? }` or a function returning them (see Installation) |
|
|
2030
2169
|
| `title` | | A heading above the table on the first page |
|
|
2031
2170
|
| `header`, `footer` | | A string or element, on every page |
|
|
2032
2171
|
| `headerAlign`, `footerAlign` | `"left"`, `"center"` | Where a **string** goes: `"left"`, `"center"`, `"right"` |
|
|
2033
2172
|
| `orientation` | `"auto"` | `"portrait"`, `"landscape"`, or `"auto"` (landscape when there are more than 6 columns) |
|
|
2034
2173
|
| `pageSize` | `"a4"` | `"a3"`, `"a4"`, `"a5"`, `"letter"`, `"legal"` |
|
|
2035
|
-
| `margin` | `36` | Points around the page (72 points = 1 inch) |
|
|
2174
|
+
| `margin` | `36` | Points around the page (72 points = 1 inch): a number, or `{ top, right, bottom, left }` |
|
|
2036
2175
|
| `fontSize` | `9` | Table text size in points |
|
|
2037
2176
|
| `tableTheme` | `"striped"` | `"striped"`, `"grid"` or `"plain"` |
|
|
2038
|
-
| `headColor`, `headTextColor` | `"#4f46e5"`, `"#ffffff"` | Colours of the table's header row
|
|
2177
|
+
| `headColor`, `headTextColor` | `"#4f46e5"`, `"#ffffff"` | Colours of the table's header row (any CSS colour) |
|
|
2178
|
+
| `matchGridStyle` | `false` | Copy the grid's on-screen look into the PDF. See [PDF styling](#pdf-styling) |
|
|
2179
|
+
| `style` | | Colours, stripes, borders, padding, page background, per-column looks. See [PDF styling](#pdf-styling) |
|
|
2180
|
+
| `autoTableOptions` | | Raw options for jspdf-autotable, merged last, for anything not covered |
|
|
2039
2181
|
| `pageNumbers` | `true` | "Page 1 of 3" in the bottom right |
|
|
2040
2182
|
| `maxImageHeight` | `90` | Tallest header / footer picture, in points |
|
|
2041
2183
|
| `fontName`, `beforeRender` | | Use another font (see below) |
|
|
@@ -2052,6 +2194,72 @@ pdf: {
|
|
|
2052
2194
|
}
|
|
2053
2195
|
```
|
|
2054
2196
|
|
|
2197
|
+
#### PDF styling
|
|
2198
|
+
|
|
2199
|
+
By default the PDF has its own look (indigo header, light stripes). Two ways to change it, and they combine.
|
|
2200
|
+
|
|
2201
|
+
**1. Copy the grid's look, only when you ask.** `matchGridStyle: true` reads the grid as it is on screen when the export runs: the header's background and text colour, the text colour and size of the rows, the two stripe colours (with `striped`), the row borders, and the grid's own background (which matters for dark themes). It reads real elements, so it follows `theme`, Tailwind classes and your CSS. Without the option nothing is read.
|
|
2202
|
+
|
|
2203
|
+
```tsx
|
|
2204
|
+
<DataGrid theme="midnight" striped exportable={{ formats: ["pdf"], pdf: { libraries, matchGridStyle: true } }} />
|
|
2205
|
+
```
|
|
2206
|
+
|
|
2207
|
+
Fonts are not copied: jsPDF cannot use a web font without its file (see `fontName`).
|
|
2208
|
+
|
|
2209
|
+
**2. Set it yourself with `style`.** Every field is optional, and colours are any CSS colour (`"#4f46e5"`, `"rgb(79,70,229)"`, `"tomato"`).
|
|
2210
|
+
|
|
2211
|
+
```tsx
|
|
2212
|
+
pdf: {
|
|
2213
|
+
libraries,
|
|
2214
|
+
margin: { top: 60, right: 30, bottom: 50, left: 30 },
|
|
2215
|
+
tableTheme: "grid", // "striped" | "grid" | "plain"
|
|
2216
|
+
style: {
|
|
2217
|
+
pageBackground: "#0f172a", // colour behind everything, on every page
|
|
2218
|
+
headColor: "#f59e0b",
|
|
2219
|
+
headTextColor: "#111827",
|
|
2220
|
+
stripeColors: ["#1e293b", "#334155"], // rows alternate between these two
|
|
2221
|
+
bodyTextColor: "#e2e8f0",
|
|
2222
|
+
borderColor: "#475569",
|
|
2223
|
+
borderWidth: 0.4, // points
|
|
2224
|
+
cellPadding: { top: 6, bottom: 6, left: 8, right: 8 },
|
|
2225
|
+
fontSize: 10,
|
|
2226
|
+
columns: { // per column, by its `field`
|
|
2227
|
+
salary: { fontStyle: "bold", textColor: "#fbbf24", align: "right" },
|
|
2228
|
+
name: { width: 120 },
|
|
2229
|
+
},
|
|
2230
|
+
},
|
|
2231
|
+
}
|
|
2232
|
+
```
|
|
2233
|
+
|
|
2234
|
+
| `style` field | Meaning |
|
|
2235
|
+
| --- | --- |
|
|
2236
|
+
| `headColor`, `headTextColor`, `headFontSize`, `headFontStyle` | The table's header row (`headFontStyle`: `"normal"`, `"bold"` (default), `"italic"`, `"bolditalic"`) |
|
|
2237
|
+
| `bodyColor` | Background of every body row (when there are no `stripeColors`) |
|
|
2238
|
+
| `stripeColors` | `[colorA, colorB]`: rows alternate, starting with A |
|
|
2239
|
+
| `bodyTextColor` | Text colour of body rows |
|
|
2240
|
+
| `borderColor`, `borderWidth` | Lines between cells (points) |
|
|
2241
|
+
| `cellPadding` | Space inside cells: a number or `{ top, right, bottom, left }`. Default 4 |
|
|
2242
|
+
| `minRowHeight` | Smallest row height in points |
|
|
2243
|
+
| `fontSize`, `fontName` | Table text size (default 9) and a font you registered |
|
|
2244
|
+
| `pageBackground` | Paper colour. Header, footer, title and table text turn light by themselves when it is dark |
|
|
2245
|
+
| `textColor`, `titleColor`, `titleSize` | Header / footer / page-number text, and the `title` |
|
|
2246
|
+
| `margin` | Same as the `margin` option |
|
|
2247
|
+
| `columns` | `{ [field]: { width, align, textColor, backgroundColor, fontStyle, fontSize } }`. `width` is points, `"auto"` or `"wrap"` |
|
|
2248
|
+
|
|
2249
|
+
**Which wins.** Weakest to strongest: built-in defaults, the grid's look (`matchGridStyle`), the flat options (`headColor`, `fontSize`, `margin`, ...), then `style`. So you can copy the grid and still force one colour:
|
|
2250
|
+
|
|
2251
|
+
```tsx
|
|
2252
|
+
pdf: { matchGridStyle: true, style: { headColor: "#0f766e" } } // the grid's look, but a teal header
|
|
2253
|
+
```
|
|
2254
|
+
|
|
2255
|
+
**Anything else.** `autoTableOptions` is handed to jspdf-autotable last, and its `styles`, `headStyles`, `bodyStyles`, `alternateRowStyles` and `margin` are merged key by key into ours:
|
|
2256
|
+
|
|
2257
|
+
```tsx
|
|
2258
|
+
pdf: { autoTableOptions: { rowPageBreak: "avoid", didParseCell: (data) => { if (data.column.index === 5 && Number(data.cell.raw.replace(/\D/g, "")) > 100000) data.cell.styles.textColor = [220, 38, 38]; } } }
|
|
2259
|
+
```
|
|
2260
|
+
|
|
2261
|
+
Header and footer *elements* are drawn on the page's colour, so they blend into a `pageBackground`.
|
|
2262
|
+
|
|
2055
2263
|
#### Export options
|
|
2056
2264
|
|
|
2057
2265
|
| `ExportOptions` | Default | Meaning |
|
|
@@ -2470,6 +2678,7 @@ Behaviours to be aware of:
|
|
|
2470
2678
|
- In `serverSide` mode the grid cannot export or select rows it has never loaded.
|
|
2471
2679
|
- The date calendar starts weeks on Sunday and has no week numbers or time of day.
|
|
2472
2680
|
- Excel export writes one worksheet. It does not carry the grid's colours or fonts, only a styled header row.
|
|
2681
|
+
- The PDF is styled by its own `pdf` options. It only copies the grid's look when `matchGridStyle` is on, and then only colours, stripes, borders and text size, not fonts or exact spacing.
|
|
2473
2682
|
- PDF text uses jsPDF's built-in Western European fonts unless you register another one (`pdf.fontName`). A PDF header / footer element is a picture: its text cannot be selected.
|
|
2474
2683
|
- Rows that leave play their exit animation as a copy in place; the table closes the gap when the animation ends instead of sliding the rows below up.
|
|
2475
2684
|
|
|
@@ -2509,8 +2718,7 @@ The Styling demo loads Tailwind from its CDN, so it needs an internet connection
|
|
|
2509
2718
|
|
|
2510
2719
|
---
|
|
2511
2720
|
|
|
2512
|
-
|
|
2513
|
-
## 8. Troubleshooting
|
|
2721
|
+
## 9. Troubleshooting
|
|
2514
2722
|
|
|
2515
2723
|
| Problem | Cause and fix |
|
|
2516
2724
|
| --- | --- |
|
|
@@ -2524,7 +2732,7 @@ The Styling demo loads Tailwind from its CDN, so it needs an internet connection
|
|
|
2524
2732
|
| The date calendar never opens | The cell must be editable (`editable` on the grid or the column), then double-click it or press Enter / F2 |
|
|
2525
2733
|
| A sequence column shows nothing or a type error | Give it `type: "sequence"` and a `field` that starts with `#`, for example `{ field: "#", type: "sequence" }` |
|
|
2526
2734
|
| My custom row animation does nothing | `animateRows` is `false`, `virtualize` is on, or your class does not set `animation`. Check that the keyframes exist and that the class name is spelled the same in CSS |
|
|
2527
|
-
| PDF export fails with `needs the
|
|
2735
|
+
| PDF export fails with `needs the jspdf and jspdf-autotable libraries` | Install `jspdf jspdf-autotable` (and `html2canvas` for a header / footer element) and pass them in `exportable.pdf.libraries`. Handle the error with `onExportError` |
|
|
2528
2736
|
| The PDF header / footer element has no image | The image must be loadable by the browser without being blocked: a bundled asset, a data URL, or a server that sends CORS headers |
|
|
2529
2737
|
| The comparison drop-down does not show in the filter popup | Add `filterOperators: true` (or a list) to that column. It applies to text columns only, and not with a custom `filterRenderer` |
|
|
2530
2738
|
| The wrong row animates out when I delete one | Give the grid `getRowId={(row) => row.id}`. Without it rows are identified by position |
|
|
@@ -2557,4 +2765,27 @@ The Styling demo loads Tailwind from its CDN, so it needs an internet connection
|
|
|
2557
2765
|
| A checkbox in a boolean column is greyed out and won't toggle | The cell isn't editable. Set `editable` on the grid, or `editable: true` on that column |
|
|
2558
2766
|
| Type error: `field` not assignable | `field` must be a key of your row type. Check the spelling, and that `ColumnDef<T>` uses the same `T` as `rows` |
|
|
2559
2767
|
|
|
2560
|
-
---
|
|
2768
|
+
---
|
|
2769
|
+
### Changed defaults
|
|
2770
|
+
|
|
2771
|
+
Three defaults changed so that every feature is opt-in.
|
|
2772
|
+
|
|
2773
|
+
| Before | Now | What to do |
|
|
2774
|
+
| --- | --- | --- |
|
|
2775
|
+
| Grid prop `sortable` (default `true`), column `sortable` override | **Column** `sortable` only, default `false`. The grid-level prop is gone | Add `sortable: true` to each column that should sort. Remove `sortable` / `sortable={false}` from the grid |
|
|
2776
|
+
| `defaultSort` / `onSortChange` used one `SortModel` or `null` | `defaultSort` takes one `SortModel` **or an array**. `onSortChange` receives an **array** (empty when unsorted) | Change `(sort) => sort?.field` to `(sort) => sort[0]?.field` |
|
|
2777
|
+
| `searchable` default `true` | Default `false` | Add `searchable` to grids that should show the search box |
|
|
2778
|
+
| `pagination` default `true` | Default `false`. With it off there is no footer and no row count | Add `pagination` to grids that should page |
|
|
2779
|
+
| Filters were text only | Filter kinds: text, exact, number, date, select | Nothing to change. Number columns now get a Min / Max popup, boolean columns a checkbox list |
|
|
2780
|
+
| `FilterRendererProps` | Unchanged (`value: string`) | |
|
|
2781
|
+
|
|
2782
|
+
A quick way to get the old behaviour everywhere:
|
|
2783
|
+
|
|
2784
|
+
```tsx
|
|
2785
|
+
// before: <DataGrid columns={columns} rows={rows} />
|
|
2786
|
+
const withSorting = (cols: ColumnDef<Row>[]) => cols.map((c) => ({ sortable: true, ...c }));
|
|
2787
|
+
|
|
2788
|
+
<DataGrid columns={withSorting(columns)} rows={rows} searchable pagination />
|
|
2789
|
+
```
|
|
2790
|
+
|
|
2791
|
+
Everything else in this document is new and optional.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const y=require("react-dom");function f(t,e){for(var o=0;o<e.length;o++){const n=e[o];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in t)){const u=Object.getOwnPropertyDescriptor(n,a);u&&Object.defineProperty(t,a,u.get?u:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var r={},l,s,i=y;if(process.env.NODE_ENV==="production")s=r.createRoot=i.createRoot,l=r.hydrateRoot=i.hydrateRoot;else{var c=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;s=r.createRoot=function(t,e){c.usingClientEntryPoint=!0;try{return i.createRoot(t,e)}finally{c.usingClientEntryPoint=!1}},l=r.hydrateRoot=function(t,e,o){c.usingClientEntryPoint=!0;try{return i.hydrateRoot(t,e,o)}finally{c.usingClientEntryPoint=!1}}}const _=f({__proto__:null,get createRoot(){return s},default:r,get hydrateRoot(){return l}},[r]);exports.client=_;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import f from "react-dom";
|
|
2
|
+
function s(t, e) {
|
|
3
|
+
for (var o = 0; o < e.length; o++) {
|
|
4
|
+
const n = e[o];
|
|
5
|
+
if (typeof n != "string" && !Array.isArray(n)) {
|
|
6
|
+
for (const a in n)
|
|
7
|
+
if (a !== "default" && !(a in t)) {
|
|
8
|
+
const u = Object.getOwnPropertyDescriptor(n, a);
|
|
9
|
+
u && Object.defineProperty(t, a, u.get ? u : {
|
|
10
|
+
enumerable: !0,
|
|
11
|
+
get: () => n[a]
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return Object.freeze(Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }));
|
|
17
|
+
}
|
|
18
|
+
var r = {}, l, y, i = f;
|
|
19
|
+
if (process.env.NODE_ENV === "production")
|
|
20
|
+
y = r.createRoot = i.createRoot, l = r.hydrateRoot = i.hydrateRoot;
|
|
21
|
+
else {
|
|
22
|
+
var c = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
23
|
+
y = r.createRoot = function(t, e) {
|
|
24
|
+
c.usingClientEntryPoint = !0;
|
|
25
|
+
try {
|
|
26
|
+
return i.createRoot(t, e);
|
|
27
|
+
} finally {
|
|
28
|
+
c.usingClientEntryPoint = !1;
|
|
29
|
+
}
|
|
30
|
+
}, l = r.hydrateRoot = function(t, e, o) {
|
|
31
|
+
c.usingClientEntryPoint = !0;
|
|
32
|
+
try {
|
|
33
|
+
return i.hydrateRoot(t, e, o);
|
|
34
|
+
} finally {
|
|
35
|
+
c.usingClientEntryPoint = !1;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const R = /* @__PURE__ */ s({
|
|
40
|
+
__proto__: null,
|
|
41
|
+
get createRoot() {
|
|
42
|
+
return y;
|
|
43
|
+
},
|
|
44
|
+
default: r,
|
|
45
|
+
get hydrateRoot() {
|
|
46
|
+
return l;
|
|
47
|
+
}
|
|
48
|
+
}, [r]);
|
|
49
|
+
export {
|
|
50
|
+
R as c
|
|
51
|
+
};
|