@rttui/skin-anocca 1.0.15 → 1.0.17

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.
Files changed (47) hide show
  1. package/dist/cjs/HeaderPinButtons.cjs +109 -0
  2. package/dist/cjs/HeaderPinButtons.cjs.map +10 -0
  3. package/dist/cjs/RowPinButtons.cjs +75 -0
  4. package/dist/cjs/RowPinButtons.cjs.map +10 -0
  5. package/dist/cjs/index.cjs +383 -0
  6. package/dist/cjs/index.cjs.map +10 -0
  7. package/dist/cjs/package.json +5 -0
  8. package/dist/cjs/stories/ReactTanstackTableUiStory.stories.cjs +234 -0
  9. package/dist/cjs/stories/ReactTanstackTableUiStory.stories.cjs.map +10 -0
  10. package/dist/cjs/stories/ReactTanstackTableUiStoryComponent.cjs +147 -0
  11. package/dist/cjs/stories/ReactTanstackTableUiStoryComponent.cjs.map +10 -0
  12. package/dist/cjs/stories/createSourceCode.cjs +92 -0
  13. package/dist/cjs/stories/createSourceCode.cjs.map +10 -0
  14. package/dist/mjs/HeaderPinButtons.mjs +79 -0
  15. package/dist/mjs/HeaderPinButtons.mjs.map +10 -0
  16. package/dist/mjs/RowPinButtons.mjs +45 -0
  17. package/dist/mjs/RowPinButtons.mjs.map +10 -0
  18. package/dist/mjs/index.mjs +352 -0
  19. package/dist/mjs/index.mjs.map +10 -0
  20. package/dist/mjs/package.json +5 -0
  21. package/dist/mjs/stories/ReactTanstackTableUiStory.stories.mjs +204 -0
  22. package/dist/mjs/stories/ReactTanstackTableUiStory.stories.mjs.map +10 -0
  23. package/dist/mjs/stories/ReactTanstackTableUiStoryComponent.mjs +110 -0
  24. package/dist/mjs/stories/ReactTanstackTableUiStoryComponent.mjs.map +10 -0
  25. package/{src/stories/createSourceCode.ts → dist/mjs/stories/createSourceCode.mjs} +13 -4
  26. package/dist/mjs/stories/createSourceCode.mjs.map +10 -0
  27. package/dist/types/HeaderPinButtons.d.ts +1 -0
  28. package/dist/types/RowPinButtons.d.ts +4 -0
  29. package/dist/types/index.d.ts +3 -0
  30. package/dist/types/stories/ReactTanstackTableUiStory.stories.d.ts +72 -0
  31. package/dist/types/stories/ReactTanstackTableUiStoryComponent.d.ts +15 -0
  32. package/dist/types/stories/createSourceCode.d.ts +5 -0
  33. package/package.json +5 -2
  34. package/.storybook/main.ts +0 -18
  35. package/.storybook/preview.ts +0 -14
  36. package/CHANGELOG.md +0 -120
  37. package/index.html +0 -13
  38. package/src/HeaderPinButtons.tsx +0 -81
  39. package/src/RowPinButtons.tsx +0 -40
  40. package/src/index.tsx +0 -460
  41. package/src/stories/ReactTanstackTableUiStory.mdx +0 -136
  42. package/src/stories/ReactTanstackTableUiStory.stories.tsx +0 -206
  43. package/src/stories/ReactTanstackTableUiStoryComponent.tsx +0 -113
  44. package/src/stories/ScrollbarWidthSpecified.mdx +0 -42
  45. package/tsconfig.json +0 -34
  46. package/tsconfig.types.json +0 -9
  47. 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,136 +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 available space.
23
-
24
- ```tsx
25
- <ReactTanstackTableUi
26
- autoCrushColumns
27
- />
28
- ```
29
-
30
- To prevent a perticular 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
- ### Fill available space after crush
42
-
43
- If you don't have so many columns and you want the columns to fill all the available space,
44
- you can set the `autoCrushColumns` prop to `true` and set the `fillAvailableSpaceAfterCrush` prop to `true`.
45
- [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.
46
-
47
-
48
- ```tsx
49
- <ReactTanstackTableUi
50
- autoCrushColumns
51
- fillAvailableSpaceAfterCrush
52
- scrollbarWidth={16}
53
- />
54
- ```
55
-
56
- To prevent a perticular column from being expanded, you can set the `fillAvailableSpaceAfterCrush` meta option to `false`.
57
-
58
- ```ts
59
- columnHelper.accessor("name", {
60
- header: "Name",
61
- meta: { fillAvailableSpaceAfterCrush: false },
62
- })
63
- ```
64
-
65
- <Canvas of={RttuiStories.FillAvailableSpaceAfterCrushExceptName} />
66
-
67
- ### Size by largest header
68
-
69
- If you want the columns to be sized by the largest header, you can set the `crushMinSizeBy` prop to `header`.
70
-
71
- ```tsx
72
- <ReactTanstackTableUi crushMinSizeBy="header" />
73
- ```
74
-
75
- <Story of={RttuiStories.SizeByLargestHeader} />
76
-
77
- You can also use meta to configure the crush behavior for a perticular column.
78
-
79
- ```ts
80
- columnHelper.accessor("age", {
81
- header: "Age",
82
- meta: { crushMinSizeBy: "cell" },
83
- })
84
- ```
85
-
86
- <Story of={RttuiStories.SizeByLargestHeaderWithMeta} />
87
-
88
- <br /><br />
89
-
90
- # Column Pinning
91
-
92
- By default columns are pinned relative to the other columns:
93
-
94
- <Story of={RttuiStories.PinRelativeToCols} />
95
-
96
- ```tsx
97
- <ReactTanstackTableUi
98
- autoCrushColumns
99
- pinColsRelativeTo="cols"
100
- />
101
- ```
102
-
103
- You can also pin columns relative to the table:
104
-
105
- <Story of={RttuiStories.PinRelativeToTable} />
106
-
107
- ```tsx
108
- <ReactTanstackTableUi
109
- autoCrushColumns
110
- pinColsRelativeTo="table"
111
- />
112
- ```
113
-
114
- # Row Pinning
115
-
116
- By default rows are pinned relative to the other rows:
117
-
118
- <Story of={RttuiStories.CanPinRowsRelativeToRows} />
119
-
120
- ```tsx
121
- <ReactTanstackTableUi
122
- enableRowPinning
123
- pinRowsRelativeTo="rows"
124
- />
125
- ```
126
-
127
- You can also pin rows relative to the table:
128
-
129
- <Story of={RttuiStories.CanPinRowsRelativeToTable} />
130
-
131
- ```tsx
132
- <ReactTanstackTableUi
133
- enableRowPinning
134
- pinRowsRelativeTo="table"
135
- />
136
- ```