@rttui/skin-anocca 1.0.16 → 1.0.18
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/dist/cjs/HeaderPinButtons.cjs +109 -0
- package/dist/cjs/HeaderPinButtons.cjs.map +10 -0
- package/dist/cjs/RowPinButtons.cjs +75 -0
- package/dist/cjs/RowPinButtons.cjs.map +10 -0
- package/dist/cjs/index.cjs +383 -0
- package/dist/cjs/index.cjs.map +10 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/stories/ReactTanstackTableUiStory.stories.cjs +276 -0
- package/dist/cjs/stories/ReactTanstackTableUiStory.stories.cjs.map +10 -0
- package/dist/cjs/stories/ReactTanstackTableUiStoryComponent.cjs +186 -0
- package/dist/cjs/stories/ReactTanstackTableUiStoryComponent.cjs.map +10 -0
- package/dist/cjs/stories/createSourceCode.cjs +92 -0
- package/dist/cjs/stories/createSourceCode.cjs.map +10 -0
- package/dist/mjs/HeaderPinButtons.mjs +79 -0
- package/dist/mjs/HeaderPinButtons.mjs.map +10 -0
- package/dist/mjs/RowPinButtons.mjs +45 -0
- package/dist/mjs/RowPinButtons.mjs.map +10 -0
- package/dist/mjs/index.mjs +352 -0
- package/dist/mjs/index.mjs.map +10 -0
- package/dist/mjs/package.json +5 -0
- package/dist/mjs/stories/ReactTanstackTableUiStory.stories.mjs +246 -0
- package/dist/mjs/stories/ReactTanstackTableUiStory.stories.mjs.map +10 -0
- package/dist/mjs/stories/ReactTanstackTableUiStoryComponent.mjs +155 -0
- package/dist/mjs/stories/ReactTanstackTableUiStoryComponent.mjs.map +10 -0
- package/{src/stories/createSourceCode.ts → dist/mjs/stories/createSourceCode.mjs} +13 -4
- package/dist/mjs/stories/createSourceCode.mjs.map +10 -0
- package/dist/types/HeaderPinButtons.d.ts +1 -0
- package/dist/types/RowPinButtons.d.ts +4 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/stories/ReactTanstackTableUiStory.stories.d.ts +78 -0
- package/dist/types/stories/ReactTanstackTableUiStoryComponent.d.ts +17 -0
- package/dist/types/stories/createSourceCode.d.ts +5 -0
- package/package.json +5 -2
- package/.storybook/main.ts +0 -18
- package/.storybook/preview.ts +0 -14
- package/CHANGELOG.md +0 -126
- package/index.html +0 -13
- package/src/HeaderPinButtons.tsx +0 -81
- package/src/RowPinButtons.tsx +0 -40
- package/src/index.tsx +0 -460
- package/src/stories/ReactTanstackTableUiStory.mdx +0 -147
- package/src/stories/ReactTanstackTableUiStory.stories.tsx +0 -207
- package/src/stories/ReactTanstackTableUiStoryComponent.tsx +0 -113
- package/src/stories/ScrollbarWidthSpecified.mdx +0 -42
- package/tsconfig.json +0 -34
- package/tsconfig.types.json +0 -9
- package/vite.config.ts +0 -23
package/src/index.tsx
DELETED
@@ -1,460 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
Box,
|
3
|
-
Paper,
|
4
|
-
SxProps,
|
5
|
-
TableBody,
|
6
|
-
TableCell,
|
7
|
-
TableFooter,
|
8
|
-
TableHead,
|
9
|
-
TableRow,
|
10
|
-
Theme,
|
11
|
-
useTheme,
|
12
|
-
} from "@mui/material";
|
13
|
-
import {
|
14
|
-
Skin,
|
15
|
-
useTableContext,
|
16
|
-
useTableCssVars,
|
17
|
-
VirtualHeader,
|
18
|
-
} from "@rttui/core";
|
19
|
-
import React, { CSSProperties } from "react";
|
20
|
-
import { flexRender } from "@tanstack/react-table";
|
21
|
-
|
22
|
-
const AnoccaSkin: Skin = {
|
23
|
-
rowHeight: 32,
|
24
|
-
headerRowHeight: 32,
|
25
|
-
footerRowHeight: 32,
|
26
|
-
OverlayContainer: ({ children }) => {
|
27
|
-
const { width, height } = useTableContext();
|
28
|
-
const cssVars = useTableCssVars();
|
29
|
-
return (
|
30
|
-
<div
|
31
|
-
className="rttui-overlay-container"
|
32
|
-
style={{
|
33
|
-
position: "relative",
|
34
|
-
width: width + "px",
|
35
|
-
height: height + "px",
|
36
|
-
...cssVars,
|
37
|
-
}}
|
38
|
-
>
|
39
|
-
{children}
|
40
|
-
</div>
|
41
|
-
);
|
42
|
-
},
|
43
|
-
OuterContainer: ({ children }) => {
|
44
|
-
const { tableContainerRef } = useTableContext();
|
45
|
-
|
46
|
-
return (
|
47
|
-
<Paper
|
48
|
-
ref={tableContainerRef}
|
49
|
-
className="outer-container"
|
50
|
-
elevation={2}
|
51
|
-
sx={{
|
52
|
-
overflow: "auto",
|
53
|
-
width: "var(--table-container-width)",
|
54
|
-
height: "var(--table-container-height)",
|
55
|
-
position: "relative",
|
56
|
-
contain: "paint",
|
57
|
-
willChange: "transform",
|
58
|
-
borderRadius: 1,
|
59
|
-
}}
|
60
|
-
>
|
61
|
-
{children}
|
62
|
-
</Paper>
|
63
|
-
);
|
64
|
-
},
|
65
|
-
TableScroller: () => {
|
66
|
-
return (
|
67
|
-
<div
|
68
|
-
className="table-scroller"
|
69
|
-
style={{
|
70
|
-
width: "var(--table-width)",
|
71
|
-
height:
|
72
|
-
"calc(var(--table-height) + var(--header-height) + var(--footer-height))",
|
73
|
-
position: "absolute",
|
74
|
-
}}
|
75
|
-
></div>
|
76
|
-
);
|
77
|
-
},
|
78
|
-
TableHeader: ({ children }) => {
|
79
|
-
return (
|
80
|
-
<TableHead
|
81
|
-
component="div"
|
82
|
-
className="thead"
|
83
|
-
sx={{
|
84
|
-
position: "sticky",
|
85
|
-
top: 0,
|
86
|
-
width: "var(--table-width)",
|
87
|
-
zIndex: 2,
|
88
|
-
backgroundColor: (theme) => theme.palette.background.paper,
|
89
|
-
boxShadow: (theme) => `0 1px 0 ${theme.palette.divider}`,
|
90
|
-
display: "flex",
|
91
|
-
flexDirection: "column",
|
92
|
-
justifyContent: "flex-start",
|
93
|
-
alignItems: "stretch",
|
94
|
-
}}
|
95
|
-
>
|
96
|
-
{children}
|
97
|
-
</TableHead>
|
98
|
-
);
|
99
|
-
},
|
100
|
-
TableFooter: ({ children }) => {
|
101
|
-
return (
|
102
|
-
<TableFooter
|
103
|
-
component="div"
|
104
|
-
className="table-footer"
|
105
|
-
sx={{
|
106
|
-
position: "sticky",
|
107
|
-
bottom: -1,
|
108
|
-
width: "var(--table-width)",
|
109
|
-
zIndex: 2,
|
110
|
-
backgroundColor: (theme) => theme.palette.background.paper,
|
111
|
-
boxShadow: (theme) => `0 -1px 0 ${theme.palette.divider}`,
|
112
|
-
}}
|
113
|
-
>
|
114
|
-
{children}
|
115
|
-
</TableFooter>
|
116
|
-
);
|
117
|
-
},
|
118
|
-
HeaderRow: TableHeaderRow,
|
119
|
-
HeaderCell: React.forwardRef((props, ref) => {
|
120
|
-
return <TableHeaderCell {...props} ref={ref} />;
|
121
|
-
}),
|
122
|
-
TableBody: ({ children }) => {
|
123
|
-
return (
|
124
|
-
<TableBody
|
125
|
-
component="div"
|
126
|
-
className="table-body"
|
127
|
-
sx={{
|
128
|
-
position: "relative",
|
129
|
-
width: "var(--table-width)",
|
130
|
-
height: "var(--table-height)",
|
131
|
-
display: "flex",
|
132
|
-
flexDirection: "column",
|
133
|
-
justifyContent: "flex-start",
|
134
|
-
alignItems: "stretch",
|
135
|
-
}}
|
136
|
-
>
|
137
|
-
{children}
|
138
|
-
</TableBody>
|
139
|
-
);
|
140
|
-
},
|
141
|
-
PinnedRows: ({ children, position, pinned }) => {
|
142
|
-
if (pinned.length === 0) {
|
143
|
-
return null;
|
144
|
-
}
|
145
|
-
|
146
|
-
const style: SxProps<Theme> = {
|
147
|
-
position: "sticky",
|
148
|
-
zIndex: 3,
|
149
|
-
};
|
150
|
-
if (position === "top") {
|
151
|
-
style.top = "var(--header-height)";
|
152
|
-
style.borderBottom = (theme) => `1px solid ${theme.palette.divider}`;
|
153
|
-
style.boxShadow =
|
154
|
-
"0 4px 8px -4px rgba(0, 0, 0, 0.15), 0 6px 12px -6px rgba(0, 0, 0, 0.1)";
|
155
|
-
} else if (position === "bottom") {
|
156
|
-
style.bottom = "var(--footer-height)";
|
157
|
-
style.borderTop = (theme) => `1px solid ${theme.palette.divider}`;
|
158
|
-
style.boxShadow =
|
159
|
-
"0 -4px 8px -4px rgba(0, 0, 0, 0.15), 0 -6px 12px -6px rgba(0, 0, 0, 0.1)";
|
160
|
-
}
|
161
|
-
|
162
|
-
const Component = position === "top" ? TableHead : TableFooter;
|
163
|
-
|
164
|
-
return (
|
165
|
-
<Component
|
166
|
-
component="div"
|
167
|
-
className={`sticky-${position}-rows`}
|
168
|
-
sx={style}
|
169
|
-
>
|
170
|
-
{children}
|
171
|
-
</Component>
|
172
|
-
);
|
173
|
-
},
|
174
|
-
PinnedCols: ({ children, position, pinned }) => {
|
175
|
-
if (pinned.length === 0) {
|
176
|
-
return null;
|
177
|
-
}
|
178
|
-
|
179
|
-
const style: SxProps<Theme> = {
|
180
|
-
position: "sticky",
|
181
|
-
zIndex: 3,
|
182
|
-
display: "flex",
|
183
|
-
};
|
184
|
-
|
185
|
-
if (position === "left") {
|
186
|
-
style.left = 0;
|
187
|
-
} else if (position === "right") {
|
188
|
-
style.right = 0;
|
189
|
-
}
|
190
|
-
|
191
|
-
return (
|
192
|
-
<Box component="div" className={`sticky-${position}-cols`} sx={style}>
|
193
|
-
{children}
|
194
|
-
</Box>
|
195
|
-
);
|
196
|
-
},
|
197
|
-
|
198
|
-
TableRowWrapper: React.forwardRef(
|
199
|
-
({ children, flatIndex, dndStyle }, ref) => {
|
200
|
-
const theme = useTheme();
|
201
|
-
const backgroundColor = (theme: Theme) => {
|
202
|
-
const baseColor =
|
203
|
-
flatIndex % 2 === 0
|
204
|
-
? theme.palette.background.paper
|
205
|
-
: theme.palette.mode === "dark"
|
206
|
-
? theme.palette.grey[900]
|
207
|
-
: theme.palette.grey[100];
|
208
|
-
return baseColor;
|
209
|
-
};
|
210
|
-
|
211
|
-
const vars: Record<string, string> = {
|
212
|
-
"--row-background-color": backgroundColor(theme),
|
213
|
-
};
|
214
|
-
|
215
|
-
return (
|
216
|
-
<Box
|
217
|
-
sx={{
|
218
|
-
...dndStyle,
|
219
|
-
...vars,
|
220
|
-
width: "var(--table-width)",
|
221
|
-
display: "flex",
|
222
|
-
flexDirection: "column",
|
223
|
-
justifyContent: "flex-start",
|
224
|
-
alignItems: "stretch",
|
225
|
-
}}
|
226
|
-
data-index={flatIndex}
|
227
|
-
ref={ref}
|
228
|
-
>
|
229
|
-
{children}
|
230
|
-
</Box>
|
231
|
-
);
|
232
|
-
},
|
233
|
-
),
|
234
|
-
TableRow: ({ children }) => {
|
235
|
-
return (
|
236
|
-
<TableRow
|
237
|
-
component="div"
|
238
|
-
className="table-row"
|
239
|
-
sx={{
|
240
|
-
position: "relative",
|
241
|
-
width: "var(--table-width)",
|
242
|
-
display: "flex",
|
243
|
-
height: "var(--row-height)",
|
244
|
-
zIndex: 1,
|
245
|
-
boxSizing: "border-box",
|
246
|
-
backgroundColor: "var(--row-background-color)",
|
247
|
-
"&:hover": {
|
248
|
-
backgroundColor: (theme) => {
|
249
|
-
// Always use solid background colors for all cells on hover
|
250
|
-
return theme.palette.mode === "dark"
|
251
|
-
? "#1e1e52" // Dark blue solid color
|
252
|
-
: "#E3F2FD"; // Light blue solid color
|
253
|
-
},
|
254
|
-
},
|
255
|
-
}}
|
256
|
-
>
|
257
|
-
{children}
|
258
|
-
</TableRow>
|
259
|
-
);
|
260
|
-
},
|
261
|
-
TableRowExpandedContent: ({ children }) => {
|
262
|
-
const { table } = useTableContext();
|
263
|
-
return (
|
264
|
-
<TableRow
|
265
|
-
component="div"
|
266
|
-
className="expanded-row"
|
267
|
-
sx={{
|
268
|
-
backgroundColor: (theme) => theme.palette.background.default,
|
269
|
-
}}
|
270
|
-
>
|
271
|
-
<TableCell
|
272
|
-
component="div"
|
273
|
-
className="expanded-cell"
|
274
|
-
colSpan={table.getAllLeafColumns().length}
|
275
|
-
sx={{
|
276
|
-
padding: 2,
|
277
|
-
}}
|
278
|
-
>
|
279
|
-
{children}
|
280
|
-
</TableCell>
|
281
|
-
</TableRow>
|
282
|
-
);
|
283
|
-
},
|
284
|
-
Cell: React.forwardRef(
|
285
|
-
(
|
286
|
-
{ children, header, isMeasuring, isLastPinned, isLast, isLastCenter },
|
287
|
-
ref,
|
288
|
-
) => {
|
289
|
-
const { isPinned } = header;
|
290
|
-
const { table } = useTableContext();
|
291
|
-
return (
|
292
|
-
<TableCell
|
293
|
-
className="td"
|
294
|
-
component="div"
|
295
|
-
ref={ref}
|
296
|
-
sx={{
|
297
|
-
height: "var(--row-height)",
|
298
|
-
width: isMeasuring ? "auto" : header.width,
|
299
|
-
overflow: "hidden",
|
300
|
-
textOverflow: "ellipsis",
|
301
|
-
whiteSpace: "nowrap",
|
302
|
-
zIndex: isPinned ? 5 : 0,
|
303
|
-
boxSizing: "border-box",
|
304
|
-
fontSize: "0.875rem",
|
305
|
-
color: "text.primary",
|
306
|
-
alignItems: "center",
|
307
|
-
gap: "8px",
|
308
|
-
display: "flex",
|
309
|
-
justifyContent: "flex-start",
|
310
|
-
alignContent: "center",
|
311
|
-
padding: "6px 12px",
|
312
|
-
backgroundColor: "var(--row-background-color)",
|
313
|
-
borderBottom: "none",
|
314
|
-
flexShrink: 0,
|
315
|
-
position: "relative",
|
316
|
-
borderRight:
|
317
|
-
((isPinned === "start" && !isLastPinned) || !isPinned) &&
|
318
|
-
!isLast &&
|
319
|
-
!(isLastCenter && table.getIsSomeColumnsPinned("right"))
|
320
|
-
? (theme) => `1px solid ${theme.palette.divider}`
|
321
|
-
: undefined,
|
322
|
-
borderLeft:
|
323
|
-
isPinned === "end" && !isLastPinned
|
324
|
-
? (theme) => `1px solid ${theme.palette.divider}`
|
325
|
-
: undefined,
|
326
|
-
".table-row:hover &": {
|
327
|
-
backgroundColor: (theme) => {
|
328
|
-
// Always use solid background colors for all cells on hover
|
329
|
-
return theme.palette.mode === "dark"
|
330
|
-
? "#1e1e52" // Dark blue solid color
|
331
|
-
: "#E3F2FD"; // Light blue solid color
|
332
|
-
},
|
333
|
-
zIndex: isPinned ? 2 : 0,
|
334
|
-
},
|
335
|
-
}}
|
336
|
-
>
|
337
|
-
{children}
|
338
|
-
</TableCell>
|
339
|
-
);
|
340
|
-
},
|
341
|
-
),
|
342
|
-
PinnedColsOverlay: ({ position }) => {
|
343
|
-
const { table } = useTableContext();
|
344
|
-
if (!table.getIsSomeColumnsPinned(position)) {
|
345
|
-
return null;
|
346
|
-
}
|
347
|
-
const width =
|
348
|
-
position === "left"
|
349
|
-
? table.getLeftTotalSize()
|
350
|
-
: table.getRightTotalSize();
|
351
|
-
|
352
|
-
const style: CSSProperties = {
|
353
|
-
width,
|
354
|
-
[position]: 0,
|
355
|
-
position: "sticky",
|
356
|
-
top: 0,
|
357
|
-
bottom: 0,
|
358
|
-
zIndex: 20,
|
359
|
-
pointerEvents: "none",
|
360
|
-
};
|
361
|
-
|
362
|
-
if (position === "left") {
|
363
|
-
style.boxShadow =
|
364
|
-
"4px 0 8px -4px rgba(0, 0, 0, 0.15), 6px 0 12px -6px rgba(0, 0, 0, 0.1)";
|
365
|
-
} else if (position === "right") {
|
366
|
-
style.boxShadow =
|
367
|
-
"-4px 0 8px -4px rgba(0, 0, 0, 0.15), -6px 0 12px -6px rgba(0, 0, 0, 0.1)";
|
368
|
-
}
|
369
|
-
return <div className={`pinned-${position}-overlay`} style={style} />;
|
370
|
-
},
|
371
|
-
};
|
372
|
-
|
373
|
-
const TableHeaderCell = React.forwardRef<
|
374
|
-
HTMLDivElement,
|
375
|
-
VirtualHeader & {
|
376
|
-
type: "header" | "footer";
|
377
|
-
isLast: boolean;
|
378
|
-
isFirst: boolean;
|
379
|
-
isLastPinned: boolean;
|
380
|
-
isFirstPinned: boolean;
|
381
|
-
isLastCenter: boolean;
|
382
|
-
isFirstCenter: boolean;
|
383
|
-
isMeasuring: boolean;
|
384
|
-
}
|
385
|
-
>(
|
386
|
-
(
|
387
|
-
{
|
388
|
-
headerId,
|
389
|
-
isPinned,
|
390
|
-
width,
|
391
|
-
header,
|
392
|
-
type,
|
393
|
-
isLast,
|
394
|
-
isLastPinned,
|
395
|
-
isLastCenter,
|
396
|
-
isMeasuring,
|
397
|
-
},
|
398
|
-
ref,
|
399
|
-
) => {
|
400
|
-
const { table } = useTableContext();
|
401
|
-
return (
|
402
|
-
<TableCell
|
403
|
-
ref={ref}
|
404
|
-
component="div"
|
405
|
-
className="th"
|
406
|
-
data-header-id={headerId}
|
407
|
-
data-is-pinned={isPinned}
|
408
|
-
sx={{
|
409
|
-
transition: "background-color 0.2s ease",
|
410
|
-
whiteSpace: "nowrap",
|
411
|
-
zIndex: isPinned ? 1 : 0,
|
412
|
-
display: "flex",
|
413
|
-
overflow: "hidden",
|
414
|
-
height: "var(--header-row-height)",
|
415
|
-
width: isMeasuring ? "auto" : width,
|
416
|
-
position: "relative",
|
417
|
-
flexShrink: 0,
|
418
|
-
alignItems: "center",
|
419
|
-
gap: "8px",
|
420
|
-
justifyContent: "space-between",
|
421
|
-
padding: "6px 12px",
|
422
|
-
boxSizing: "border-box",
|
423
|
-
fontWeight: 600,
|
424
|
-
backgroundColor: isPinned
|
425
|
-
? (theme) => theme.palette.background.paper
|
426
|
-
: "transparent",
|
427
|
-
borderRight:
|
428
|
-
((isPinned === "start" && !isLastPinned) || !isPinned) &&
|
429
|
-
!isLast &&
|
430
|
-
!(isLastCenter && table.getIsSomeColumnsPinned("right"))
|
431
|
-
? (theme) => `1px solid ${theme.palette.divider}`
|
432
|
-
: undefined,
|
433
|
-
borderLeft:
|
434
|
-
isPinned === "end" && !isLastPinned
|
435
|
-
? (theme) => `1px solid ${theme.palette.divider}`
|
436
|
-
: undefined,
|
437
|
-
}}
|
438
|
-
>
|
439
|
-
<div style={{ flex: 1, display: "flex", justifyContent: "flex-start" }}>
|
440
|
-
{header && !header.isPlaceholder
|
441
|
-
? flexRender(header.column.columnDef[type], header.getContext())
|
442
|
-
: null}
|
443
|
-
</div>
|
444
|
-
</TableCell>
|
445
|
-
);
|
446
|
-
},
|
447
|
-
);
|
448
|
-
|
449
|
-
export { AnoccaSkin };
|
450
|
-
|
451
|
-
function TableHeaderRow({ children }: { children: React.ReactNode }) {
|
452
|
-
return (
|
453
|
-
<TableRow
|
454
|
-
component="div"
|
455
|
-
sx={{ height: "var(--row-height)", display: "flex" }}
|
456
|
-
>
|
457
|
-
{children}
|
458
|
-
</TableRow>
|
459
|
-
);
|
460
|
-
}
|
@@ -1,147 +0,0 @@
|
|
1
|
-
import { Canvas, Meta, Story, Source, Controls } from '@storybook/blocks';
|
2
|
-
|
3
|
-
import * as RttuiStories from './ReactTanstackTableUiStory.stories';
|
4
|
-
|
5
|
-
<Meta of={RttuiStories} />
|
6
|
-
|
7
|
-
# Column sizing
|
8
|
-
By default columns uses the size defined in the columns. By default that is 150px in tanstack table.
|
9
|
-
|
10
|
-
You can override this by setting the `size` prop on the column.
|
11
|
-
```tsx
|
12
|
-
columnHelper.accessor("age", {
|
13
|
-
header: "Age",
|
14
|
-
size: 50,
|
15
|
-
})
|
16
|
-
```
|
17
|
-
|
18
|
-
<Canvas of={RttuiStories.Basic} />
|
19
|
-
|
20
|
-
### Auto crush columns
|
21
|
-
|
22
|
-
You can also use the `autoCrushColumns` prop to automatically crush columns to fit the largest header in the column.
|
23
|
-
|
24
|
-
```tsx
|
25
|
-
<ReactTanstackTableUi
|
26
|
-
autoCrushColumns
|
27
|
-
/>
|
28
|
-
```
|
29
|
-
|
30
|
-
To prevent a particular column from being crushed, you can set the `autoCrush` meta option to `false`.
|
31
|
-
|
32
|
-
```tsx
|
33
|
-
columnHelper.accessor("name", {
|
34
|
-
header: "Name",
|
35
|
-
meta: { autoCrush: false },
|
36
|
-
})
|
37
|
-
```
|
38
|
-
|
39
|
-
<Canvas of={RttuiStories.AutoCrushColumnsExceptName} />
|
40
|
-
|
41
|
-
### Crush behavior
|
42
|
-
|
43
|
-
By default the crush behavior is to crush the column based on the largest header.
|
44
|
-
You can change this by setting the `crushMinSizeBy` prop to `header`, `cell` or `both`.
|
45
|
-
|
46
|
-
```tsx
|
47
|
-
<ReactTanstackTableUi
|
48
|
-
autoCrushColumns
|
49
|
-
crushMinSizeBy="cell"
|
50
|
-
/>
|
51
|
-
```
|
52
|
-
|
53
|
-
<Story of={RttuiStories.SizeByLargestHeader} />
|
54
|
-
|
55
|
-
You can also use meta to configure the crush behavior for a particular column.
|
56
|
-
|
57
|
-
```tsx
|
58
|
-
columnHelper.accessor("age", {
|
59
|
-
header: "Age",
|
60
|
-
meta: { crushMinSizeBy: "cell" },
|
61
|
-
});
|
62
|
-
|
63
|
-
<ReactTanstackTableUi
|
64
|
-
autoCrushColumns
|
65
|
-
enableColumnPinning
|
66
|
-
crushMinSizeBy="header"
|
67
|
-
/>
|
68
|
-
```
|
69
|
-
|
70
|
-
<Story of={RttuiStories.SizeByLargestHeaderWithMeta} />
|
71
|
-
|
72
|
-
<br /><br />
|
73
|
-
|
74
|
-
|
75
|
-
### Fill available space after crush
|
76
|
-
|
77
|
-
If you don't have so many columns and you want the columns to fill all the available space,
|
78
|
-
you can set the `autoCrushColumns` prop to `true` and set the `fillAvailableSpaceAfterCrush` prop to `true`.
|
79
|
-
[If you don't want a horizontal scrollbar to appear](?path=/docs/reacttanstacktableui--scrollbarwidthspecified) you also need to specify the `scrollbarWidth` prop which is the width of the vertical scrollbar.
|
80
|
-
|
81
|
-
|
82
|
-
```tsx
|
83
|
-
<ReactTanstackTableUi
|
84
|
-
autoCrushColumns
|
85
|
-
fillAvailableSpaceAfterCrush
|
86
|
-
scrollbarWidth={16}
|
87
|
-
/>
|
88
|
-
```
|
89
|
-
|
90
|
-
To prevent a particular column from being expanded, you can set the `fillAvailableSpaceAfterCrush` meta option to `false`.
|
91
|
-
|
92
|
-
```ts
|
93
|
-
columnHelper.accessor("name", {
|
94
|
-
header: "Name",
|
95
|
-
meta: { fillAvailableSpaceAfterCrush: false },
|
96
|
-
})
|
97
|
-
```
|
98
|
-
|
99
|
-
<Canvas of={RttuiStories.FillAvailableSpaceAfterCrushExceptName} />
|
100
|
-
|
101
|
-
# Column Pinning
|
102
|
-
|
103
|
-
By default columns are pinned relative to the other columns:
|
104
|
-
|
105
|
-
<Story of={RttuiStories.PinRelativeToCols} />
|
106
|
-
|
107
|
-
```tsx
|
108
|
-
<ReactTanstackTableUi
|
109
|
-
autoCrushColumns
|
110
|
-
pinColsRelativeTo="cols"
|
111
|
-
/>
|
112
|
-
```
|
113
|
-
|
114
|
-
You can also pin columns relative to the table:
|
115
|
-
|
116
|
-
<Story of={RttuiStories.PinRelativeToTable} />
|
117
|
-
|
118
|
-
```tsx
|
119
|
-
<ReactTanstackTableUi
|
120
|
-
autoCrushColumns
|
121
|
-
pinColsRelativeTo="table"
|
122
|
-
/>
|
123
|
-
```
|
124
|
-
|
125
|
-
# Row Pinning
|
126
|
-
|
127
|
-
By default rows are pinned relative to the other rows:
|
128
|
-
|
129
|
-
<Story of={RttuiStories.CanPinRowsRelativeToRows} />
|
130
|
-
|
131
|
-
```tsx
|
132
|
-
<ReactTanstackTableUi
|
133
|
-
enableRowPinning
|
134
|
-
pinRowsRelativeTo="rows"
|
135
|
-
/>
|
136
|
-
```
|
137
|
-
|
138
|
-
You can also pin rows relative to the table:
|
139
|
-
|
140
|
-
<Story of={RttuiStories.CanPinRowsRelativeToTable} />
|
141
|
-
|
142
|
-
```tsx
|
143
|
-
<ReactTanstackTableUi
|
144
|
-
enableRowPinning
|
145
|
-
pinRowsRelativeTo="table"
|
146
|
-
/>
|
147
|
-
```
|