@ceed/ads 1.35.0 → 1.36.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/README.md +85 -95
- package/dist/components/Accordions/Accordions.d.ts +1 -0
- package/dist/components/Alert/Alert.d.ts +5 -5
- package/dist/components/Autocomplete/Autocomplete.d.ts +2 -2
- package/dist/components/Avatar/Avatar.d.ts +7 -17
- package/dist/components/Box/Box.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +6 -5
- package/dist/components/Button/Button.d.ts +3 -2
- package/dist/components/Calendar/Calendar.d.ts +1 -0
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/Chip/Chip.d.ts +1 -0
- package/dist/components/Container/Container.d.ts +6 -1
- package/dist/components/DialogActions/DialogActions.d.ts +1 -0
- package/dist/components/DialogContent/DialogContent.d.ts +1 -0
- package/dist/components/DialogFrame/DialogFrame.d.ts +1 -1
- package/dist/components/DialogTitle/DialogTitle.d.ts +1 -0
- package/dist/components/Divider/Divider.d.ts +1 -0
- package/dist/components/Dropdown/Dropdown.d.ts +28 -1
- package/dist/components/FilterMenu/components/MonthRange.d.ts +11 -0
- package/dist/components/FilterMenu/types.d.ts +5 -1
- package/dist/components/FormControl/FormControl.d.ts +1 -0
- package/dist/components/FormHelperText/FormHelperText.d.ts +1 -0
- package/dist/components/FormLabel/FormLabel.d.ts +1 -0
- package/dist/components/Grid/Grid.d.ts +1 -0
- package/dist/components/IconButton/IconButton.d.ts +3 -2
- package/dist/components/IconMenuButton/IconMenuButton.d.ts +7 -6
- package/dist/components/InfoSign/InfoSign.d.ts +3 -2
- package/dist/components/Input/Input.d.ts +8 -22
- package/dist/components/InsetDrawer/InsetDrawer.d.ts +1 -0
- package/dist/components/Markdown/Markdown.d.ts +9 -24
- package/dist/components/Menu/Menu.d.ts +2 -1
- package/dist/components/MenuButton/MenuButton.d.ts +10 -8
- package/dist/components/Modal/Modal.d.ts +4 -2
- package/dist/components/NavigationGroup/NavigationGroup.d.ts +3 -2
- package/dist/components/NavigationItem/NavigationItem.d.ts +3 -2
- package/dist/components/Navigator/Navigator.d.ts +5 -4
- package/dist/components/Pagination/Pagination.d.ts +1 -1
- package/dist/components/ProfileMenu/ProfileMenu.d.ts +2 -2
- package/dist/components/Radio/Radio.d.ts +1 -0
- package/dist/components/RadioList/RadioList.d.ts +3 -2
- package/dist/components/SearchBar/SearchBar.d.ts +6 -5
- package/dist/components/SearchBar/index.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +12 -10
- package/dist/components/Sheet/Sheet.d.ts +1 -0
- package/dist/components/Stack/Stack.d.ts +1 -0
- package/dist/components/Stepper/Stepper.d.ts +2 -1
- package/dist/components/Switch/Switch.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +7 -5
- package/dist/components/Tabs/Tabs.d.ts +1 -0
- package/dist/components/Textarea/Textarea.d.ts +8 -20
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +4 -2
- package/dist/components/Tooltip/Tooltip.d.ts +1 -0
- package/dist/components/Typography/Typography.d.ts +1 -0
- package/dist/components/Uploader/Uploader.d.ts +18 -17
- package/dist/components/data-display/Avatar.md +60 -72
- package/dist/components/data-display/Badge.md +197 -181
- package/dist/components/data-display/Chip.md +164 -142
- package/dist/components/data-display/DataTable.md +843 -338
- package/dist/components/data-display/InfoSign.md +1 -3
- package/dist/components/data-display/Markdown.md +93 -125
- package/dist/components/data-display/Table.md +1453 -1007
- package/dist/components/data-display/Typography.md +101 -104
- package/dist/components/feedback/Alert.md +80 -86
- package/dist/components/feedback/CircularProgress.md +32 -36
- package/dist/components/feedback/Dialog.md +25 -17
- package/dist/components/feedback/Modal.md +296 -265
- package/dist/components/feedback/Skeleton.md +125 -89
- package/dist/components/index.d.ts +61 -3
- package/dist/components/inputs/Autocomplete.md +191 -95
- package/dist/components/inputs/Button.md +83 -83
- package/dist/components/inputs/ButtonGroup.md +195 -185
- package/dist/components/inputs/Calendar.md +25 -28
- package/dist/components/inputs/Checkbox.md +11 -29
- package/dist/components/inputs/CurrencyInput.md +4 -4
- package/dist/components/inputs/DatePicker.md +229 -110
- package/dist/components/inputs/DateRangePicker.md +248 -137
- package/dist/components/inputs/FilterMenu.md +138 -8
- package/dist/components/inputs/FilterableCheckboxGroup.md +115 -55
- package/dist/components/inputs/FormControl.md +75 -69
- package/dist/components/inputs/IconButton.md +229 -205
- package/dist/components/inputs/Input.md +131 -98
- package/dist/components/inputs/MonthPicker.md +186 -84
- package/dist/components/inputs/MonthRangePicker.md +73 -49
- package/dist/components/inputs/PercentageInput.md +15 -31
- package/dist/components/inputs/RadioButton.md +320 -256
- package/dist/components/inputs/RadioList.md +66 -50
- package/dist/components/inputs/RadioTileGroup.md +287 -170
- package/dist/components/inputs/SearchBar.md +154 -55
- package/dist/components/inputs/Select.md +106 -95
- package/dist/components/inputs/Slider.md +153 -102
- package/dist/components/inputs/Switch.md +193 -138
- package/dist/components/inputs/Textarea.md +15 -20
- package/dist/components/inputs/Uploader/Uploader.md +68 -39
- package/dist/components/layout/Box.md +841 -662
- package/dist/components/layout/Container.md +3 -11
- package/dist/components/layout/Grid.md +480 -394
- package/dist/components/layout/Stack.md +739 -566
- package/dist/components/navigation/Breadcrumbs.md +182 -116
- package/dist/components/navigation/Dropdown.md +732 -391
- package/dist/components/navigation/IconMenuButton.md +14 -6
- package/dist/components/navigation/InsetDrawer.md +550 -378
- package/dist/components/navigation/Link.md +104 -94
- package/dist/components/navigation/Menu.md +623 -502
- package/dist/components/navigation/MenuButton.md +18 -10
- package/dist/components/navigation/NavigationGroup.md +19 -50
- package/dist/components/navigation/NavigationItem.md +6 -6
- package/dist/components/navigation/Navigator.md +26 -28
- package/dist/components/navigation/Pagination.md +86 -75
- package/dist/components/navigation/ProfileMenu.md +65 -43
- package/dist/components/navigation/Stepper.md +2 -12
- package/dist/components/navigation/Tabs.md +209 -183
- package/dist/components/surfaces/Accordions.md +89 -172
- package/dist/components/surfaces/Card.md +1094 -709
- package/dist/components/surfaces/Divider.md +562 -412
- package/dist/components/surfaces/Sheet.md +700 -518
- package/dist/guides/ThemeProvider.md +65 -40
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +4 -4
- package/dist/index.cjs +1653 -1560
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1316 -1215
- package/framer/index.js +1 -1
- package/package.json +32 -35
|
@@ -228,9 +228,13 @@ A link type. Renders as a clickable link.
|
|
|
228
228
|
A type for row-level action buttons.
|
|
229
229
|
|
|
230
230
|
```tsx
|
|
231
|
-
<DataTable
|
|
232
|
-
|
|
233
|
-
}
|
|
231
|
+
<DataTable
|
|
232
|
+
rows={rows4}
|
|
233
|
+
columns={columns}
|
|
234
|
+
pinnedColumns={{
|
|
235
|
+
right: ["actions"]
|
|
236
|
+
}}
|
|
237
|
+
/>
|
|
234
238
|
```
|
|
235
239
|
|
|
236
240
|
```tsx
|
|
@@ -312,24 +316,42 @@ const [selectionModel, setSelectionModel] = useState<string[]>([]);
|
|
|
312
316
|
|
|
313
317
|
```tsx
|
|
314
318
|
<Stack height="500px" gap={1}>
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
319
|
+
<Typography level="title-sm" textColor="text.secondary">
|
|
320
|
+
status가 Closed인 행은 선택할 수 없습니다.
|
|
321
|
+
</Typography>
|
|
322
|
+
<DataTable
|
|
323
|
+
checkboxSelection
|
|
324
|
+
stripe="even"
|
|
325
|
+
hoverRow
|
|
326
|
+
stickyHeader
|
|
327
|
+
rows={rows3}
|
|
328
|
+
columns={columns}
|
|
329
|
+
selectionModel={selectionModel}
|
|
330
|
+
onSelectionModelChange={(newSelection) => setSelectionModel(newSelection)}
|
|
331
|
+
isRowSelectable={({ row }) => row.status !== "Closed"}
|
|
332
|
+
/>
|
|
333
|
+
</Stack>
|
|
322
334
|
```
|
|
323
335
|
|
|
324
336
|
### Disabling Click Selection
|
|
325
337
|
|
|
326
338
|
```tsx
|
|
327
339
|
<Stack height="500px">
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
340
|
+
<Typography level="title-sm" textColor="text.secondary">
|
|
341
|
+
Disable selection on click.
|
|
342
|
+
</Typography>
|
|
343
|
+
<DataTable
|
|
344
|
+
checkboxSelection
|
|
345
|
+
stripe="even"
|
|
346
|
+
hoverRow
|
|
347
|
+
selectionModel={selectedId}
|
|
348
|
+
stickyHeader
|
|
349
|
+
onSelectionModelChange={(newSelection) => setSelectedId(newSelection)}
|
|
350
|
+
disableSelectionOnClick
|
|
351
|
+
rows={rows4}
|
|
352
|
+
columns={columns}
|
|
353
|
+
/>
|
|
354
|
+
</Stack>
|
|
333
355
|
```
|
|
334
356
|
|
|
335
357
|
### Total Selection (isTotalSelected)
|
|
@@ -338,22 +360,39 @@ Used to manage the total selection state including data beyond the current page
|
|
|
338
360
|
|
|
339
361
|
```tsx
|
|
340
362
|
<Stack gap={2}>
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
363
|
+
<Box
|
|
364
|
+
sx={{
|
|
365
|
+
p: 2,
|
|
366
|
+
bgcolor: "primary.50",
|
|
367
|
+
borderRadius: "8px"
|
|
368
|
+
}}
|
|
369
|
+
>
|
|
370
|
+
<Typography level="body-sm">
|
|
371
|
+
{isTotalSelected
|
|
372
|
+
? `All ${allRows.length} items are selected (across all pages)`
|
|
373
|
+
: `${selectionModel.length} items selected on current page`}
|
|
374
|
+
</Typography>
|
|
375
|
+
</Box>
|
|
376
|
+
<DataTable
|
|
377
|
+
rows={pagedRows}
|
|
378
|
+
columns={columns}
|
|
379
|
+
checkboxSelection
|
|
380
|
+
selectionModel={selectionModel}
|
|
381
|
+
onSelectionModelChange={(newSelection, totalSelected) => {
|
|
382
|
+
setSelectionModel(newSelection);
|
|
383
|
+
if (totalSelected !== undefined) {
|
|
384
|
+
setIsTotalSelected(totalSelected);
|
|
385
|
+
}
|
|
386
|
+
}}
|
|
387
|
+
isTotalSelected={isTotalSelected}
|
|
388
|
+
pagination
|
|
389
|
+
paginationMode="server"
|
|
390
|
+
rowCount={allRows.length}
|
|
391
|
+
paginationModel={paginationModel}
|
|
392
|
+
onPaginationModelChange={setPaginationModel}
|
|
393
|
+
noWrap
|
|
394
|
+
/>
|
|
395
|
+
</Stack>
|
|
357
396
|
```
|
|
358
397
|
|
|
359
398
|
```tsx
|
|
@@ -388,13 +427,17 @@ The selection state is applied based on the last clicked checkbox's resulting st
|
|
|
388
427
|
|
|
389
428
|
```tsx
|
|
390
429
|
<Stack spacing={2}>
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
430
|
+
<Typography level="body-sm">
|
|
431
|
+
Hold Shift and click checkboxes to select a range of rows. The selection state is applied
|
|
432
|
+
based on the first clicked checkbox's resulting state.
|
|
433
|
+
</Typography>
|
|
434
|
+
<DataTable
|
|
435
|
+
{...args}
|
|
436
|
+
selectionModel={selectionModel}
|
|
437
|
+
onSelectionModelChange={setSelectionModel}
|
|
438
|
+
/>
|
|
439
|
+
<Typography level="body-xs">Selected IDs: {selectionModel.join(", ") || "None"}</Typography>
|
|
440
|
+
</Stack>
|
|
398
441
|
```
|
|
399
442
|
|
|
400
443
|
**How it works:**
|
|
@@ -415,14 +458,18 @@ When a row has focus, use keyboard shortcuts to navigate and interact with rows.
|
|
|
415
458
|
|
|
416
459
|
```tsx
|
|
417
460
|
<Stack spacing={2}>
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
461
|
+
<Typography level="body-sm">
|
|
462
|
+
Click a row to focus, then use keyboard to navigate. Arrow Up/Down to move, Space to toggle
|
|
463
|
+
selection, Home/End to jump to first/last row, PageUp/PageDown to move by 10 rows. Hold Shift
|
|
464
|
+
with any navigation key to extend selection.
|
|
465
|
+
</Typography>
|
|
466
|
+
<DataTable
|
|
467
|
+
{...args}
|
|
468
|
+
selectionModel={selectionModel}
|
|
469
|
+
onSelectionModelChange={setSelectionModel}
|
|
470
|
+
/>
|
|
471
|
+
<Typography level="body-xs">Selected IDs: {selectionModel.join(", ") || "None"}</Typography>
|
|
472
|
+
</Stack>
|
|
426
473
|
```
|
|
427
474
|
|
|
428
475
|
**Supported keys:**
|
|
@@ -452,7 +499,20 @@ When a row has focus, use keyboard shortcuts to navigate and interact with rows.
|
|
|
452
499
|
### Back Office Style
|
|
453
500
|
|
|
454
501
|
```tsx
|
|
455
|
-
<DataTable
|
|
502
|
+
<DataTable
|
|
503
|
+
rows={args.rows}
|
|
504
|
+
columns={args.columns}
|
|
505
|
+
checkboxSelection={args.checkboxSelection}
|
|
506
|
+
hoverRow={args.hoverRow}
|
|
507
|
+
noWrap={args.noWrap}
|
|
508
|
+
stripe={args.stripe}
|
|
509
|
+
stickyHeader={args.stickyHeader}
|
|
510
|
+
slots={args.slots}
|
|
511
|
+
slotProps={args.slotProps}
|
|
512
|
+
selectionModel={selectionModel}
|
|
513
|
+
onSelectionModelChange={setSelectionModel}
|
|
514
|
+
pagination={args.pagination}
|
|
515
|
+
/>
|
|
456
516
|
```
|
|
457
517
|
|
|
458
518
|
#### Commonly Used Table Options
|
|
@@ -490,21 +550,218 @@ When a row has focus, use keyboard shortcuts to navigate and interact with rows.
|
|
|
490
550
|
|
|
491
551
|
```tsx
|
|
492
552
|
<Stack height="500px">
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
553
|
+
<Typography level="title-sm" textColor="text.secondary">
|
|
554
|
+
Virtualized DataTable
|
|
555
|
+
</Typography>
|
|
556
|
+
<DataTable
|
|
557
|
+
checkboxSelection
|
|
558
|
+
stripe="even"
|
|
559
|
+
hoverRow
|
|
560
|
+
selectionModel={selectedId}
|
|
561
|
+
stickyHeader
|
|
562
|
+
onSelectionModelChange={(newSelection) => setSelectedId(newSelection)}
|
|
563
|
+
rows={[
|
|
564
|
+
...rows4,
|
|
565
|
+
...rows4,
|
|
566
|
+
...rows4,
|
|
567
|
+
...rows4,
|
|
568
|
+
...rows4,
|
|
569
|
+
...rows4,
|
|
570
|
+
...rows4,
|
|
571
|
+
...rows4,
|
|
572
|
+
...rows4,
|
|
573
|
+
...rows4,
|
|
574
|
+
...rows4,
|
|
575
|
+
...rows4,
|
|
576
|
+
...rows4,
|
|
577
|
+
...rows4,
|
|
578
|
+
...rows4,
|
|
579
|
+
...rows4,
|
|
580
|
+
...rows4,
|
|
581
|
+
...rows4,
|
|
582
|
+
...rows4,
|
|
583
|
+
...rows4,
|
|
584
|
+
...rows4,
|
|
585
|
+
...rows4,
|
|
586
|
+
...rows4,
|
|
587
|
+
...rows4,
|
|
588
|
+
...rows4,
|
|
589
|
+
...rows4,
|
|
590
|
+
...rows4,
|
|
591
|
+
...rows4,
|
|
592
|
+
...rows4,
|
|
593
|
+
...rows4,
|
|
594
|
+
...rows4,
|
|
595
|
+
...rows4,
|
|
596
|
+
...rows4,
|
|
597
|
+
...rows4,
|
|
598
|
+
...rows4,
|
|
599
|
+
...rows4,
|
|
600
|
+
...rows4,
|
|
601
|
+
...rows4,
|
|
602
|
+
...rows4,
|
|
603
|
+
...rows4,
|
|
604
|
+
...rows4,
|
|
605
|
+
...rows4,
|
|
606
|
+
...rows4,
|
|
607
|
+
...rows4,
|
|
608
|
+
...rows4,
|
|
609
|
+
...rows4,
|
|
610
|
+
...rows4,
|
|
611
|
+
...rows4,
|
|
612
|
+
...rows4,
|
|
613
|
+
...rows4,
|
|
614
|
+
...rows4,
|
|
615
|
+
...rows4,
|
|
616
|
+
...rows4,
|
|
617
|
+
...rows4,
|
|
618
|
+
...rows4,
|
|
619
|
+
...rows4,
|
|
620
|
+
...rows4,
|
|
621
|
+
...rows4,
|
|
622
|
+
...rows4,
|
|
623
|
+
...rows4,
|
|
624
|
+
...rows4,
|
|
625
|
+
...rows4,
|
|
626
|
+
...rows4,
|
|
627
|
+
...rows4,
|
|
628
|
+
...rows4,
|
|
629
|
+
...rows4,
|
|
630
|
+
...rows4,
|
|
631
|
+
...rows4,
|
|
632
|
+
...rows4,
|
|
633
|
+
...rows4,
|
|
634
|
+
...rows4,
|
|
635
|
+
...rows4,
|
|
636
|
+
...rows4,
|
|
637
|
+
...rows4,
|
|
638
|
+
...rows4,
|
|
639
|
+
...rows4,
|
|
640
|
+
...rows4,
|
|
641
|
+
...rows4,
|
|
642
|
+
...rows4,
|
|
643
|
+
...rows4,
|
|
644
|
+
...rows4,
|
|
645
|
+
...rows4,
|
|
646
|
+
...rows4,
|
|
647
|
+
...rows4,
|
|
648
|
+
...rows4,
|
|
649
|
+
...rows4,
|
|
650
|
+
...rows4,
|
|
651
|
+
...rows4,
|
|
652
|
+
...rows4,
|
|
653
|
+
...rows4,
|
|
654
|
+
...rows4,
|
|
655
|
+
...rows4,
|
|
656
|
+
...rows4,
|
|
657
|
+
...rows4,
|
|
658
|
+
...rows4,
|
|
659
|
+
...rows4,
|
|
660
|
+
...rows4,
|
|
661
|
+
...rows4,
|
|
662
|
+
...rows4,
|
|
663
|
+
...rows4,
|
|
664
|
+
...rows4,
|
|
665
|
+
...rows4,
|
|
666
|
+
...rows4,
|
|
667
|
+
...rows4,
|
|
668
|
+
...rows4,
|
|
669
|
+
...rows4,
|
|
670
|
+
...rows4,
|
|
671
|
+
...rows4,
|
|
672
|
+
...rows4,
|
|
673
|
+
...rows4,
|
|
674
|
+
...rows4,
|
|
675
|
+
...rows4,
|
|
676
|
+
...rows4,
|
|
677
|
+
...rows4,
|
|
678
|
+
...rows4,
|
|
679
|
+
...rows4,
|
|
680
|
+
...rows4,
|
|
681
|
+
...rows4,
|
|
682
|
+
...rows4,
|
|
683
|
+
...rows4,
|
|
684
|
+
...rows4,
|
|
685
|
+
...rows4,
|
|
686
|
+
...rows4,
|
|
687
|
+
...rows4,
|
|
688
|
+
...rows4,
|
|
689
|
+
...rows4,
|
|
690
|
+
...rows4,
|
|
691
|
+
...rows4,
|
|
692
|
+
...rows4,
|
|
693
|
+
...rows4,
|
|
694
|
+
...rows4,
|
|
695
|
+
...rows4,
|
|
696
|
+
...rows4,
|
|
697
|
+
...rows4,
|
|
698
|
+
...rows4,
|
|
699
|
+
...rows4,
|
|
700
|
+
...rows4,
|
|
701
|
+
...rows4,
|
|
702
|
+
...rows4,
|
|
703
|
+
...rows4,
|
|
704
|
+
...rows4,
|
|
705
|
+
...rows4,
|
|
706
|
+
...rows4,
|
|
707
|
+
...rows4,
|
|
708
|
+
...rows4,
|
|
709
|
+
...rows4,
|
|
710
|
+
...rows4,
|
|
711
|
+
...rows4,
|
|
712
|
+
...rows4,
|
|
713
|
+
...rows4,
|
|
714
|
+
...rows4,
|
|
715
|
+
...rows4,
|
|
716
|
+
...rows4,
|
|
717
|
+
...rows4,
|
|
718
|
+
...rows4,
|
|
719
|
+
...rows4,
|
|
720
|
+
...rows4,
|
|
721
|
+
...rows4,
|
|
722
|
+
...rows4,
|
|
723
|
+
...rows4,
|
|
724
|
+
...rows4,
|
|
725
|
+
...rows4,
|
|
726
|
+
...rows4,
|
|
727
|
+
...rows4,
|
|
728
|
+
...rows4,
|
|
729
|
+
...rows4,
|
|
730
|
+
...rows4,
|
|
731
|
+
...rows4,
|
|
732
|
+
...rows4,
|
|
733
|
+
...rows4,
|
|
734
|
+
...rows4,
|
|
735
|
+
...rows4,
|
|
736
|
+
...rows4,
|
|
737
|
+
...rows4,
|
|
738
|
+
...rows4,
|
|
739
|
+
...rows4,
|
|
740
|
+
...rows4,
|
|
741
|
+
...rows4,
|
|
742
|
+
...rows4,
|
|
743
|
+
...rows4,
|
|
744
|
+
...rows4,
|
|
745
|
+
...rows4,
|
|
746
|
+
...rows4,
|
|
747
|
+
...rows4
|
|
748
|
+
].map((row, i) => ({
|
|
749
|
+
...row,
|
|
750
|
+
id: i
|
|
751
|
+
}))}
|
|
752
|
+
columns={columns}
|
|
753
|
+
initialState={{
|
|
754
|
+
sorting: {
|
|
755
|
+
sortModel: [
|
|
756
|
+
{
|
|
757
|
+
field: "number",
|
|
758
|
+
sort: "asc"
|
|
759
|
+
}
|
|
760
|
+
]
|
|
761
|
+
}
|
|
762
|
+
}}
|
|
763
|
+
/>
|
|
764
|
+
</Stack>
|
|
508
765
|
```
|
|
509
766
|
|
|
510
767
|
## Slots & SlotProps Customization
|
|
@@ -524,9 +781,16 @@ DataTable allows customization of various parts through `slots` and `slotProps`.
|
|
|
524
781
|
### Custom Toolbar
|
|
525
782
|
|
|
526
783
|
```tsx
|
|
527
|
-
<DataTable
|
|
528
|
-
|
|
529
|
-
}
|
|
784
|
+
<DataTable
|
|
785
|
+
rows={filteredRows}
|
|
786
|
+
columns={columns}
|
|
787
|
+
slots={{
|
|
788
|
+
toolbar: CustomToolbar
|
|
789
|
+
}}
|
|
790
|
+
noWrap
|
|
791
|
+
stickyHeader
|
|
792
|
+
stripe="even"
|
|
793
|
+
/>
|
|
530
794
|
```
|
|
531
795
|
|
|
532
796
|
```tsx
|
|
@@ -543,9 +807,14 @@ const CustomToolbar = () => (
|
|
|
543
807
|
### Custom Footer
|
|
544
808
|
|
|
545
809
|
```tsx
|
|
546
|
-
<DataTable
|
|
547
|
-
|
|
548
|
-
}
|
|
810
|
+
<DataTable
|
|
811
|
+
rows={tableRows}
|
|
812
|
+
columns={columns}
|
|
813
|
+
slots={{
|
|
814
|
+
footer: CustomFooter
|
|
815
|
+
}}
|
|
816
|
+
noWrap
|
|
817
|
+
/>
|
|
549
818
|
```
|
|
550
819
|
|
|
551
820
|
```tsx
|
|
@@ -562,17 +831,26 @@ const CustomFooter = () => (
|
|
|
562
831
|
|
|
563
832
|
```tsx
|
|
564
833
|
<Stack gap={2}>
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
834
|
+
<Button onClick={() => setLoading(!loading)}>
|
|
835
|
+
{loading ? "Stop Loading" : "Start Loading"}
|
|
836
|
+
</Button>
|
|
837
|
+
<DataTable
|
|
838
|
+
rows={tableRows}
|
|
839
|
+
columns={columns}
|
|
840
|
+
loading={loading}
|
|
841
|
+
slots={{
|
|
842
|
+
loadingOverlay: CustomLoadingOverlay
|
|
843
|
+
}}
|
|
844
|
+
noWrap
|
|
845
|
+
slotProps={{
|
|
846
|
+
background: {
|
|
847
|
+
style: {
|
|
848
|
+
height: "300px"
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}}
|
|
852
|
+
/>
|
|
853
|
+
</Stack>
|
|
576
854
|
```
|
|
577
855
|
|
|
578
856
|
```tsx
|
|
@@ -626,13 +904,19 @@ When `rows` is empty and `loading` is not `true`, a no rows overlay is displayed
|
|
|
626
904
|
You can customize the empty state UI using `slots.noRowsOverlay`.
|
|
627
905
|
|
|
628
906
|
```tsx
|
|
629
|
-
<DataTable
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
}}
|
|
907
|
+
<DataTable
|
|
908
|
+
rows={[]}
|
|
909
|
+
columns={tableColumns}
|
|
910
|
+
noWrap
|
|
911
|
+
slots={{
|
|
912
|
+
noRowsOverlay: CustomOverlay
|
|
913
|
+
}}
|
|
914
|
+
slotProps={{
|
|
915
|
+
noRowsOverlay: {
|
|
916
|
+
message: "Custom message via slotProps"
|
|
917
|
+
}
|
|
918
|
+
}}
|
|
919
|
+
/>
|
|
636
920
|
```
|
|
637
921
|
|
|
638
922
|
```tsx
|
|
@@ -695,18 +979,26 @@ When `loading` is `true`, the loading overlay takes priority over the no rows ov
|
|
|
695
979
|
|
|
696
980
|
```tsx
|
|
697
981
|
<Stack gap={2}>
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
982
|
+
<Button onClick={() => setLoading(!loading)}>
|
|
983
|
+
{loading ? "Stop Loading" : "Start Loading"}
|
|
984
|
+
</Button>
|
|
985
|
+
<Typography level="body-sm">
|
|
986
|
+
{loading ? "Loading overlay is shown (noRowsOverlay hidden)" : "NoRowsOverlay is shown"}
|
|
987
|
+
</Typography>
|
|
988
|
+
<DataTable
|
|
989
|
+
rows={[]}
|
|
990
|
+
columns={tableColumns}
|
|
991
|
+
loading={loading}
|
|
992
|
+
noWrap
|
|
993
|
+
slotProps={{
|
|
994
|
+
background: {
|
|
995
|
+
style: {
|
|
996
|
+
height: "300px"
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}}
|
|
1000
|
+
/>
|
|
1001
|
+
</Stack>
|
|
710
1002
|
```
|
|
711
1003
|
|
|
712
1004
|
### Combined Custom Loading + No Rows Overlay
|
|
@@ -715,31 +1007,48 @@ Both `loadingOverlay` and `noRowsOverlay` slots can be customized simultaneously
|
|
|
715
1007
|
|
|
716
1008
|
```tsx
|
|
717
1009
|
<Stack gap={2}>
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
1010
|
+
<Stack direction="row" gap={1} alignItems="center">
|
|
1011
|
+
<Button onClick={() => setLoading(!loading)}>
|
|
1012
|
+
{loading ? "Stop Loading" : "Start Loading"}
|
|
1013
|
+
</Button>
|
|
1014
|
+
<Typography level="body-xs" textColor="text.tertiary">
|
|
1015
|
+
{loading ? "Custom loading overlay shown" : "Custom no rows overlay shown"}
|
|
1016
|
+
</Typography>
|
|
1017
|
+
</Stack>
|
|
1018
|
+
<DataTable
|
|
1019
|
+
rows={[]}
|
|
1020
|
+
columns={tableColumns}
|
|
1021
|
+
loading={loading}
|
|
1022
|
+
noWrap
|
|
1023
|
+
slots={{
|
|
1024
|
+
loadingOverlay: CustomLoadingOverlay,
|
|
1025
|
+
noRowsOverlay: CustomNoRowsOverlay
|
|
1026
|
+
}}
|
|
1027
|
+
slotProps={{
|
|
1028
|
+
background: {
|
|
1029
|
+
style: {
|
|
1030
|
+
height: "300px"
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}}
|
|
1034
|
+
/>
|
|
723
1035
|
</Stack>
|
|
724
|
-
<DataTable rows={[]} columns={tableColumns} loading={loading} noWrap slots={{
|
|
725
|
-
loadingOverlay: CustomLoadingOverlay,
|
|
726
|
-
noRowsOverlay: CustomNoRowsOverlay
|
|
727
|
-
}} slotProps={{
|
|
728
|
-
background: {
|
|
729
|
-
style: {
|
|
730
|
-
height: '300px'
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
}} />
|
|
734
|
-
</Stack>
|
|
735
1036
|
```
|
|
736
1037
|
|
|
737
1038
|
### Custom Checkbox
|
|
738
1039
|
|
|
739
1040
|
```tsx
|
|
740
|
-
<DataTable
|
|
741
|
-
|
|
742
|
-
}
|
|
1041
|
+
<DataTable
|
|
1042
|
+
rows={tableRows}
|
|
1043
|
+
columns={columns}
|
|
1044
|
+
checkboxSelection
|
|
1045
|
+
selectionModel={selectionModel}
|
|
1046
|
+
onSelectionModelChange={(newSelection) => setSelectionModel(newSelection)}
|
|
1047
|
+
slots={{
|
|
1048
|
+
checkbox: CustomCheckbox
|
|
1049
|
+
}}
|
|
1050
|
+
noWrap
|
|
1051
|
+
/>
|
|
743
1052
|
```
|
|
744
1053
|
|
|
745
1054
|
```tsx
|
|
@@ -791,16 +1100,57 @@ You can style the table background area using `slotProps.background`. Height spe
|
|
|
791
1100
|
### Customizing Column Rendering
|
|
792
1101
|
|
|
793
1102
|
```tsx
|
|
794
|
-
<DataTable
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
1103
|
+
<DataTable
|
|
1104
|
+
rows={useMemo(
|
|
1105
|
+
() =>
|
|
1106
|
+
[
|
|
1107
|
+
...rows3,
|
|
1108
|
+
...rows3,
|
|
1109
|
+
...rows3,
|
|
1110
|
+
...rows3,
|
|
1111
|
+
...rows3,
|
|
1112
|
+
...rows3,
|
|
1113
|
+
...rows3,
|
|
1114
|
+
...rows3,
|
|
1115
|
+
...rows3,
|
|
1116
|
+
...rows3,
|
|
1117
|
+
...rows3,
|
|
1118
|
+
...rows3,
|
|
1119
|
+
...rows3,
|
|
1120
|
+
...rows3,
|
|
1121
|
+
...rows3,
|
|
1122
|
+
...rows3,
|
|
1123
|
+
...rows3,
|
|
1124
|
+
...rows3,
|
|
1125
|
+
...rows3,
|
|
1126
|
+
...rows3,
|
|
1127
|
+
...rows3,
|
|
1128
|
+
...rows3,
|
|
1129
|
+
...rows3,
|
|
1130
|
+
...rows3,
|
|
1131
|
+
...rows3,
|
|
1132
|
+
...rows3,
|
|
1133
|
+
...rows3,
|
|
1134
|
+
...rows3
|
|
1135
|
+
].map((row, i) => ({
|
|
1136
|
+
...row,
|
|
1137
|
+
id: i + 1
|
|
1138
|
+
})),
|
|
1139
|
+
[]
|
|
1140
|
+
)}
|
|
1141
|
+
columns={columns}
|
|
1142
|
+
checkboxSelection
|
|
1143
|
+
stickyHeader
|
|
1144
|
+
stripe="even"
|
|
1145
|
+
noWrap
|
|
1146
|
+
slotProps={{
|
|
1147
|
+
background: {
|
|
1148
|
+
style: {
|
|
1149
|
+
height: "600px"
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}}
|
|
1153
|
+
/>
|
|
804
1154
|
```
|
|
805
1155
|
|
|
806
1156
|
### Complex UI in Cells
|
|
@@ -1026,23 +1376,44 @@ Hidden columns are completely removed from the DOM for optimal rendering perform
|
|
|
1026
1376
|
|
|
1027
1377
|
```tsx
|
|
1028
1378
|
<Stack spacing={2}>
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1379
|
+
<Stack
|
|
1380
|
+
direction="row"
|
|
1381
|
+
spacing={1}
|
|
1382
|
+
sx={{
|
|
1383
|
+
flexWrap: "wrap"
|
|
1384
|
+
}}
|
|
1385
|
+
>
|
|
1386
|
+
{allColumns.map((col) => (
|
|
1387
|
+
<label
|
|
1388
|
+
key={col.field as string}
|
|
1389
|
+
style={{
|
|
1390
|
+
display: "flex",
|
|
1391
|
+
alignItems: "center",
|
|
1392
|
+
gap: 4
|
|
1393
|
+
}}
|
|
1394
|
+
>
|
|
1395
|
+
<input
|
|
1396
|
+
type="checkbox"
|
|
1397
|
+
checked={visibilityModel[col.field as string] !== false}
|
|
1398
|
+
onChange={(e) =>
|
|
1399
|
+
setVisibilityModel((prev) => ({
|
|
1400
|
+
...prev,
|
|
1401
|
+
[col.field as string]: e.target.checked
|
|
1402
|
+
}))
|
|
1403
|
+
}
|
|
1404
|
+
/>
|
|
1405
|
+
{col.headerName}
|
|
1406
|
+
</label>
|
|
1407
|
+
))}
|
|
1408
|
+
</Stack>
|
|
1409
|
+
<DataTable
|
|
1410
|
+
rows={rows2}
|
|
1411
|
+
columns={allColumns}
|
|
1412
|
+
columnVisibilityModel={visibilityModel}
|
|
1413
|
+
onColumnVisibilityModelChange={setVisibilityModel}
|
|
1414
|
+
noWrap
|
|
1415
|
+
/>
|
|
1416
|
+
</Stack>
|
|
1046
1417
|
```
|
|
1047
1418
|
|
|
1048
1419
|
#### Controlled Mode
|
|
@@ -1055,7 +1426,7 @@ const [visibilityModel, setVisibilityModel] = useState({ fat: false });
|
|
|
1055
1426
|
columns={columns}
|
|
1056
1427
|
columnVisibilityModel={visibilityModel}
|
|
1057
1428
|
onColumnVisibilityModelChange={setVisibilityModel}
|
|
1058
|
-
|
|
1429
|
+
/>;
|
|
1059
1430
|
```
|
|
1060
1431
|
|
|
1061
1432
|
#### Uncontrolled Mode (initialState)
|
|
@@ -1074,41 +1445,73 @@ const [visibilityModel, setVisibilityModel] = useState({ fat: false });
|
|
|
1074
1445
|
|
|
1075
1446
|
```tsx
|
|
1076
1447
|
<Stack spacing={2}>
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1448
|
+
<Stack
|
|
1449
|
+
direction="row"
|
|
1450
|
+
spacing={1}
|
|
1451
|
+
sx={{
|
|
1452
|
+
flexWrap: "wrap"
|
|
1453
|
+
}}
|
|
1454
|
+
>
|
|
1455
|
+
{columns.map((col) => (
|
|
1456
|
+
<label
|
|
1457
|
+
key={col.field as string}
|
|
1458
|
+
style={{
|
|
1459
|
+
display: "flex",
|
|
1460
|
+
alignItems: "center",
|
|
1461
|
+
gap: 4
|
|
1462
|
+
}}
|
|
1463
|
+
>
|
|
1464
|
+
<input
|
|
1465
|
+
type="checkbox"
|
|
1466
|
+
checked={visibilityModel[col.field as string] !== false}
|
|
1467
|
+
onChange={(e) =>
|
|
1468
|
+
setVisibilityModel((prev) => ({
|
|
1469
|
+
...prev,
|
|
1470
|
+
[col.field as string]: e.target.checked
|
|
1471
|
+
}))
|
|
1472
|
+
}
|
|
1473
|
+
/>
|
|
1474
|
+
{col.headerName}
|
|
1475
|
+
</label>
|
|
1476
|
+
))}
|
|
1477
|
+
</Stack>
|
|
1478
|
+
<DataTable
|
|
1479
|
+
rows={rows4}
|
|
1480
|
+
columns={columns}
|
|
1481
|
+
columnGroupingModel={[
|
|
1482
|
+
{
|
|
1483
|
+
groupId: "group1",
|
|
1484
|
+
headerName: "Group 1",
|
|
1485
|
+
children: [
|
|
1486
|
+
{
|
|
1487
|
+
field: "id"
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
field: "number"
|
|
1491
|
+
},
|
|
1492
|
+
{
|
|
1493
|
+
field: "string"
|
|
1494
|
+
}
|
|
1495
|
+
]
|
|
1496
|
+
},
|
|
1497
|
+
{
|
|
1498
|
+
groupId: "group2",
|
|
1499
|
+
headerName: "Group 2",
|
|
1500
|
+
children: [
|
|
1501
|
+
{
|
|
1502
|
+
field: "date"
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
field: "object"
|
|
1506
|
+
}
|
|
1507
|
+
]
|
|
1508
|
+
}
|
|
1509
|
+
]}
|
|
1510
|
+
columnVisibilityModel={visibilityModel}
|
|
1511
|
+
onColumnVisibilityModelChange={setVisibilityModel}
|
|
1512
|
+
noWrap
|
|
1513
|
+
/>
|
|
1514
|
+
</Stack>
|
|
1112
1515
|
```
|
|
1113
1516
|
|
|
1114
1517
|
#### Notes
|
|
@@ -1124,11 +1527,11 @@ Setting `resizable: true` on a column allows you to adjust the column width by d
|
|
|
1124
1527
|
|
|
1125
1528
|
```tsx
|
|
1126
1529
|
<Stack gap={1}>
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
</Stack>
|
|
1530
|
+
<Typography level="body-sm" textColor="text.secondary">
|
|
1531
|
+
Drag the column borders to resize columns
|
|
1532
|
+
</Typography>
|
|
1533
|
+
<DataTable rows={tableRows} columns={columns} noWrap />
|
|
1534
|
+
</Stack>
|
|
1132
1535
|
```
|
|
1133
1536
|
|
|
1134
1537
|
```tsx
|
|
@@ -1153,45 +1556,58 @@ const columns = [
|
|
|
1153
1556
|
Setting `headerLineClamp: 2` on a column allows the header text to wrap up to 2 lines. Text exceeding 2 lines is truncated with an ellipsis, and a tooltip is displayed on hover when truncation occurs.
|
|
1154
1557
|
|
|
1155
1558
|
```tsx
|
|
1156
|
-
<Box
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
},
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1559
|
+
<Box
|
|
1560
|
+
sx={{
|
|
1561
|
+
width: 500
|
|
1562
|
+
}}
|
|
1563
|
+
>
|
|
1564
|
+
<DataTable
|
|
1565
|
+
rows={manyRows}
|
|
1566
|
+
columns={[
|
|
1567
|
+
{
|
|
1568
|
+
field: "dessert",
|
|
1569
|
+
headerName: "Dessert Name (100g serving)",
|
|
1570
|
+
headerLineClamp: 2,
|
|
1571
|
+
width: "120px"
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
field: "calories",
|
|
1575
|
+
headerName: "Calories (kcal)",
|
|
1576
|
+
headerLineClamp: 2,
|
|
1577
|
+
type: "number",
|
|
1578
|
+
width: "80px"
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
field: "fat",
|
|
1582
|
+
headerName: "Fat Content (grams)",
|
|
1583
|
+
headerLineClamp: 2,
|
|
1584
|
+
type: "number",
|
|
1585
|
+
width: "80px"
|
|
1586
|
+
},
|
|
1587
|
+
{
|
|
1588
|
+
field: "carbs",
|
|
1589
|
+
headerName: "Total Carbohydrates (g)",
|
|
1590
|
+
headerLineClamp: 2,
|
|
1591
|
+
type: "number",
|
|
1592
|
+
width: "90px"
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
field: "protein",
|
|
1596
|
+
headerName: "Protein Amount (g)",
|
|
1597
|
+
type: "number",
|
|
1598
|
+
width: "120px"
|
|
1599
|
+
}
|
|
1600
|
+
]}
|
|
1601
|
+
stickyHeader
|
|
1602
|
+
slotProps={{
|
|
1603
|
+
background: {
|
|
1604
|
+
style: {
|
|
1605
|
+
height: "400px"
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}}
|
|
1609
|
+
/>
|
|
1610
|
+
</Box>
|
|
1195
1611
|
```
|
|
1196
1612
|
|
|
1197
1613
|
```tsx
|
|
@@ -1212,7 +1628,7 @@ const columns = [
|
|
|
1212
1628
|
},
|
|
1213
1629
|
{
|
|
1214
1630
|
field: 'protein',
|
|
1215
|
-
headerName: 'Protein (g)',
|
|
1631
|
+
headerName: 'Protein (g)', // no headerLineClamp — single line (default)
|
|
1216
1632
|
type: 'number',
|
|
1217
1633
|
},
|
|
1218
1634
|
];
|
|
@@ -1230,14 +1646,16 @@ const columns = [
|
|
|
1230
1646
|
|
|
1231
1647
|
```tsx
|
|
1232
1648
|
<div>
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1649
|
+
<DataTable rows={rows3} columns={columns} checkboxSelection={false} noWrap editMode />
|
|
1650
|
+
<Button
|
|
1651
|
+
onClick={() => {
|
|
1652
|
+
console.log(editedRows);
|
|
1653
|
+
setIsCellEditable(true);
|
|
1654
|
+
}}
|
|
1655
|
+
>
|
|
1656
|
+
Submit
|
|
1657
|
+
</Button>
|
|
1658
|
+
</div>
|
|
1241
1659
|
```
|
|
1242
1660
|
|
|
1243
1661
|
#### Edit Types
|
|
@@ -1272,16 +1690,18 @@ const columns = [
|
|
|
1272
1690
|
|
|
1273
1691
|
```tsx
|
|
1274
1692
|
<div>
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1693
|
+
<Typography level="title-lg" textColor="text.secondary">
|
|
1694
|
+
expectedSales 100초과만 수정 가능
|
|
1695
|
+
</Typography>
|
|
1696
|
+
<DataTable rows={rows} columns={columns} checkboxSelection={false} noWrap editMode />
|
|
1697
|
+
<Button
|
|
1698
|
+
onClick={() => {
|
|
1699
|
+
console.log(rows);
|
|
1700
|
+
}}
|
|
1701
|
+
>
|
|
1702
|
+
Submit
|
|
1703
|
+
</Button>
|
|
1704
|
+
</div>
|
|
1285
1705
|
```
|
|
1286
1706
|
|
|
1287
1707
|
### Real-time Data Updates
|
|
@@ -1296,11 +1716,11 @@ Setting `required: true` on a column displays a required indicator (\*) in the h
|
|
|
1296
1716
|
|
|
1297
1717
|
```tsx
|
|
1298
1718
|
<Stack gap={1}>
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
</Stack>
|
|
1719
|
+
<Typography level="body-sm" textColor="text.secondary">
|
|
1720
|
+
Fields marked with * are required
|
|
1721
|
+
</Typography>
|
|
1722
|
+
<DataTable rows={tableRows} columns={columns} editMode noWrap />
|
|
1723
|
+
</Stack>
|
|
1304
1724
|
```
|
|
1305
1725
|
|
|
1306
1726
|
```tsx
|
|
@@ -1352,26 +1772,37 @@ You can use `onCellEditStart` and `onCellEditStop` to detect when editing starts
|
|
|
1352
1772
|
|
|
1353
1773
|
```tsx
|
|
1354
1774
|
<Stack gap={2}>
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
</Typography>
|
|
1373
|
-
|
|
1374
|
-
|
|
1775
|
+
<DataTable rows={tableRows} columns={columns} editMode noWrap />
|
|
1776
|
+
<Box
|
|
1777
|
+
sx={{
|
|
1778
|
+
p: 2,
|
|
1779
|
+
bgcolor: "neutral.100",
|
|
1780
|
+
borderRadius: "8px",
|
|
1781
|
+
fontFamily: "monospace",
|
|
1782
|
+
fontSize: "12px"
|
|
1783
|
+
}}
|
|
1784
|
+
>
|
|
1785
|
+
<Typography
|
|
1786
|
+
level="title-sm"
|
|
1787
|
+
sx={{
|
|
1788
|
+
mb: 1
|
|
1789
|
+
}}
|
|
1790
|
+
>
|
|
1791
|
+
Edit Log:
|
|
1792
|
+
</Typography>
|
|
1793
|
+
{editLog.length === 0 ? (
|
|
1794
|
+
<Typography level="body-xs" textColor="text.secondary">
|
|
1795
|
+
No edits yet. Click on a cell to edit.
|
|
1796
|
+
</Typography>
|
|
1797
|
+
) : (
|
|
1798
|
+
editLog.map((log) => (
|
|
1799
|
+
<Typography key={log} level="body-xs">
|
|
1800
|
+
{log}
|
|
1801
|
+
</Typography>
|
|
1802
|
+
))
|
|
1803
|
+
)}
|
|
1804
|
+
</Box>
|
|
1805
|
+
</Stack>
|
|
1375
1806
|
```
|
|
1376
1807
|
|
|
1377
1808
|
```tsx
|
|
@@ -1397,21 +1828,29 @@ Handles row click events. Useful for implementing Inspector patterns or detail v
|
|
|
1397
1828
|
|
|
1398
1829
|
```tsx
|
|
1399
1830
|
<Stack gap={2}>
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1831
|
+
<DataTable
|
|
1832
|
+
rows={tableRows}
|
|
1833
|
+
columns={columns}
|
|
1834
|
+
hoverRow
|
|
1835
|
+
onRowClick={({ row }) => setSelectedRow(row)}
|
|
1836
|
+
noWrap
|
|
1837
|
+
/>
|
|
1838
|
+
{selectedRow && (
|
|
1839
|
+
<Box
|
|
1840
|
+
sx={{
|
|
1841
|
+
p: 2,
|
|
1842
|
+
border: "1px solid",
|
|
1843
|
+
borderColor: "neutral.300",
|
|
1844
|
+
borderRadius: "8px"
|
|
1845
|
+
}}
|
|
1846
|
+
>
|
|
1847
|
+
<Typography level="title-md">Selected Employee Details</Typography>
|
|
1848
|
+
<Typography level="body-sm">Name: {selectedRow.name}</Typography>
|
|
1849
|
+
<Typography level="body-sm">Email: {selectedRow.email}</Typography>
|
|
1850
|
+
<Typography level="body-sm">Department: {selectedRow.department}</Typography>
|
|
1851
|
+
</Box>
|
|
1852
|
+
)}
|
|
1853
|
+
</Stack>
|
|
1415
1854
|
```
|
|
1416
1855
|
|
|
1417
1856
|
```tsx
|
|
@@ -1511,7 +1950,12 @@ const [selectedRow, setSelectedRow] = useState(null);
|
|
|
1511
1950
|
#### Controlled Sort
|
|
1512
1951
|
|
|
1513
1952
|
```tsx
|
|
1514
|
-
<DataTable
|
|
1953
|
+
<DataTable
|
|
1954
|
+
rows={rows4}
|
|
1955
|
+
columns={columns}
|
|
1956
|
+
sortModel={sortModel}
|
|
1957
|
+
onSortModelChange={handleSortModelChange}
|
|
1958
|
+
/>
|
|
1515
1959
|
```
|
|
1516
1960
|
|
|
1517
1961
|
```tsx
|
|
@@ -1610,19 +2054,34 @@ const [sortModel, setSortModel] = useState([{ field: 'calories', sort: 'asc' }])
|
|
|
1610
2054
|
### Sorting + Pagination
|
|
1611
2055
|
|
|
1612
2056
|
```tsx
|
|
1613
|
-
<DataTable
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
2057
|
+
<DataTable
|
|
2058
|
+
rows={rows}
|
|
2059
|
+
columns={columns}
|
|
2060
|
+
pagination
|
|
2061
|
+
slotProps={{
|
|
2062
|
+
background: {
|
|
2063
|
+
style: {
|
|
2064
|
+
height: "300px"
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}}
|
|
2068
|
+
getId={(row: RowForSort) => row.id}
|
|
2069
|
+
/>
|
|
1620
2070
|
```
|
|
1621
2071
|
|
|
1622
2072
|
### Server Pagination
|
|
1623
2073
|
|
|
1624
2074
|
```tsx
|
|
1625
|
-
<DataTable
|
|
2075
|
+
<DataTable
|
|
2076
|
+
rows={pagedRows}
|
|
2077
|
+
columns={columns as any}
|
|
2078
|
+
pagination
|
|
2079
|
+
paginationMode="server"
|
|
2080
|
+
rowCount={allRows.length}
|
|
2081
|
+
paginationModel={paginationModel}
|
|
2082
|
+
onPaginationModelChange={setPaginationModel}
|
|
2083
|
+
loading={loading}
|
|
2084
|
+
/>
|
|
1626
2085
|
```
|
|
1627
2086
|
|
|
1628
2087
|
You can specify the total row count using `paginationMode="server"` and `rowCount`.
|
|
@@ -1643,12 +2102,12 @@ You can specify the total row count using `paginationMode="server"` and `rowCoun
|
|
|
1643
2102
|
|
|
1644
2103
|
```tsx
|
|
1645
2104
|
<Stack gap={4} height="500px">
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
2105
|
+
<Stack direction="row" gap={2}>
|
|
2106
|
+
<Button onClick={handleIncrease}>Increase</Button>
|
|
2107
|
+
<Button onClick={handleDecrease}>Decrease</Button>
|
|
2108
|
+
</Stack>
|
|
2109
|
+
<DataTable rows={rows} columns={columns} pagination getId={(row: RowForSort) => row.id} />
|
|
1649
2110
|
</Stack>
|
|
1650
|
-
<DataTable rows={rows} columns={columns} pagination getId={(row: RowForSort) => row.id} />
|
|
1651
|
-
</Stack>
|
|
1652
2111
|
```
|
|
1653
2112
|
|
|
1654
2113
|
## Advanced Layout
|
|
@@ -1656,7 +2115,17 @@ You can specify the total row count using `paginationMode="server"` and `rowCoun
|
|
|
1656
2115
|
### Pinned Columns
|
|
1657
2116
|
|
|
1658
2117
|
```tsx
|
|
1659
|
-
<DataTable
|
|
2118
|
+
<DataTable
|
|
2119
|
+
rows={args.rows}
|
|
2120
|
+
columns={args.columns}
|
|
2121
|
+
pinnedColumns={args.pinnedColumns}
|
|
2122
|
+
stickyHeader={args.stickyHeader}
|
|
2123
|
+
stripe={args.stripe}
|
|
2124
|
+
noWrap={args.noWrap}
|
|
2125
|
+
hoverRow={args.hoverRow}
|
|
2126
|
+
selectionModel={selectionModel}
|
|
2127
|
+
onSelectionModelChange={setSelectionModel}
|
|
2128
|
+
/>
|
|
1660
2129
|
```
|
|
1661
2130
|
|
|
1662
2131
|
```tsx
|
|
@@ -1679,51 +2148,87 @@ interface DataTableApi {
|
|
|
1679
2148
|
### Scrolling/Focusing to a Specific Row
|
|
1680
2149
|
|
|
1681
2150
|
```tsx
|
|
1682
|
-
<Box
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
2151
|
+
<Box
|
|
2152
|
+
sx={{
|
|
2153
|
+
height: "400px"
|
|
2154
|
+
}}
|
|
2155
|
+
>
|
|
2156
|
+
<DataTable
|
|
2157
|
+
ref={ref}
|
|
2158
|
+
rows={args.rows}
|
|
2159
|
+
columns={args.columns}
|
|
2160
|
+
checkboxSelection={args.checkboxSelection}
|
|
2161
|
+
disableSelectionOnClick={args.disableSelectionOnClick}
|
|
2162
|
+
selectionModel={args.selectionModel}
|
|
2163
|
+
isTotalSelected={args.isTotalSelected}
|
|
2164
|
+
pagination={args.pagination}
|
|
2165
|
+
paginationMode={args.paginationMode}
|
|
2166
|
+
paginationModel={args.paginationModel}
|
|
2167
|
+
noWrap={args.noWrap}
|
|
2168
|
+
hoverRow={args.hoverRow}
|
|
2169
|
+
stripe={args.stripe}
|
|
2170
|
+
stickyHeader={args.stickyHeader}
|
|
2171
|
+
initialState={args.initialState}
|
|
2172
|
+
/>
|
|
2173
|
+
</Box>
|
|
1687
2174
|
```
|
|
1688
2175
|
|
|
1689
2176
|
### Inspector Pattern
|
|
1690
2177
|
|
|
1691
2178
|
```tsx
|
|
1692
|
-
<Stack
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
<
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
{selectedRowId
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
2179
|
+
<Stack
|
|
2180
|
+
sx={{
|
|
2181
|
+
height: "100vh"
|
|
2182
|
+
}}
|
|
2183
|
+
>
|
|
2184
|
+
<Typography level="title-sm" textColor="text.secondary">
|
|
2185
|
+
Virtualized & Inspector DataTable
|
|
2186
|
+
</Typography>
|
|
2187
|
+
<Button onClick={() => apiRef.current?.setCellFocus("0")}>Row ID 0 Focus</Button>
|
|
2188
|
+
<Button onClick={() => apiRef.current?.setCellFocus("100")}>Row ID 100 Focus</Button>
|
|
2189
|
+
<div
|
|
2190
|
+
style={{
|
|
2191
|
+
flex: 1,
|
|
2192
|
+
maxHeight: "100%",
|
|
2193
|
+
overflow: "auto"
|
|
2194
|
+
}}
|
|
2195
|
+
>
|
|
2196
|
+
<DataTable
|
|
2197
|
+
ref={apiRef}
|
|
2198
|
+
rows={args.rows}
|
|
2199
|
+
columns={args.columns}
|
|
2200
|
+
stripe={args.stripe}
|
|
2201
|
+
hoverRow={args.hoverRow}
|
|
2202
|
+
stickyHeader={args.stickyHeader}
|
|
2203
|
+
disableSelectionOnClick={args.disableSelectionOnClick}
|
|
2204
|
+
checkboxSelection={args.checkboxSelection}
|
|
2205
|
+
noWrap={args.noWrap}
|
|
2206
|
+
selectionModel={selectedRowId === -1 ? [] : [selectedRowId]}
|
|
2207
|
+
onRowClick={({ rowId }) => {
|
|
2208
|
+
if (selectedRowId === rowId) {
|
|
2209
|
+
setSelectedRowId(-1);
|
|
2210
|
+
} else {
|
|
2211
|
+
console.log(rowId);
|
|
2212
|
+
setSelectedRowId(rowId);
|
|
2213
|
+
setTimeout(() => {
|
|
2214
|
+
apiRef.current?.setCellFocus(String(rowId));
|
|
2215
|
+
}, 0);
|
|
2216
|
+
}
|
|
2217
|
+
}}
|
|
2218
|
+
/>
|
|
2219
|
+
</div>
|
|
2220
|
+
{selectedRowId !== -1 && (
|
|
2221
|
+
<Box
|
|
2222
|
+
sx={{
|
|
2223
|
+
backgroundColor: "aqua",
|
|
2224
|
+
border: "black 1px solid",
|
|
2225
|
+
height: "300px"
|
|
2226
|
+
}}
|
|
2227
|
+
>
|
|
2228
|
+
This is inspector: {selectedRowId}
|
|
2229
|
+
</Box>
|
|
2230
|
+
)}
|
|
2231
|
+
</Stack>
|
|
1727
2232
|
```
|
|
1728
2233
|
|
|
1729
2234
|
## Props and Customization
|