@ceed/ads 1.27.0 → 1.28.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/dist/components/DataTable/styled.d.ts +1 -0
- package/dist/components/DataTable/types.d.ts +4 -0
- package/dist/components/data-display/DataTable.md +155 -6
- package/dist/index.browser.js +2 -2
- package/dist/index.browser.js.map +2 -2
- package/dist/index.cjs +23 -2
- package/dist/index.js +28 -7
- package/framer/index.js +1 -1
- package/package.json +1 -1
|
@@ -280,4 +280,5 @@ export declare const MotionSortIcon: import("framer-motion").CustomDomComponent<
|
|
|
280
280
|
ref?: ((instance: SVGSVGElement | null) => void) | React.RefObject<SVGSVGElement> | null | undefined;
|
|
281
281
|
}, "style" | "children" | "color" | "fontSize" | "shapeRendering" | "className" | "sx" | "viewBox" | "classes" | "htmlColor" | "inheritViewBox" | "titleAccess">>;
|
|
282
282
|
export declare const DefaultLoadingOverlay: () => React.JSX.Element;
|
|
283
|
+
export declare const DefaultNoRowsOverlay: () => React.JSX.Element;
|
|
283
284
|
export declare const Resizer: (ref: RefObject<HTMLTableCellElement>, targetRef?: RefObject<any>) => React.JSX.Element;
|
|
@@ -237,6 +237,7 @@ export type DataTableProps<T extends Record<PropertyKey, any>, GetId extends ((r
|
|
|
237
237
|
toolbar?: React.ElementType;
|
|
238
238
|
footer?: React.ElementType;
|
|
239
239
|
loadingOverlay?: React.ElementType;
|
|
240
|
+
noRowsOverlay?: React.ElementType;
|
|
240
241
|
};
|
|
241
242
|
slotProps?: {
|
|
242
243
|
checkbox?: Partial<{
|
|
@@ -249,6 +250,9 @@ export type DataTableProps<T extends Record<PropertyKey, any>, GetId extends ((r
|
|
|
249
250
|
background?: Partial<{
|
|
250
251
|
[key: string]: any;
|
|
251
252
|
}>;
|
|
253
|
+
noRowsOverlay?: Partial<{
|
|
254
|
+
[key: string]: any;
|
|
255
|
+
}>;
|
|
252
256
|
};
|
|
253
257
|
} & ComponentProps<typeof Table>;
|
|
254
258
|
export {};
|
|
@@ -509,12 +509,13 @@ DataTable allows customization of various parts through `slots` and `slotProps`.
|
|
|
509
509
|
|
|
510
510
|
### Available Slots
|
|
511
511
|
|
|
512
|
-
| Slot | Description
|
|
513
|
-
| ---------------- |
|
|
514
|
-
| `checkbox` | Customize checkbox component
|
|
515
|
-
| `toolbar` | Table top toolbar
|
|
516
|
-
| `footer` | Table bottom footer
|
|
517
|
-
| `loadingOverlay` | Loading overlay
|
|
512
|
+
| Slot | Description |
|
|
513
|
+
| ---------------- | ----------------------------- |
|
|
514
|
+
| `checkbox` | Customize checkbox component |
|
|
515
|
+
| `toolbar` | Table top toolbar |
|
|
516
|
+
| `footer` | Table bottom footer |
|
|
517
|
+
| `loadingOverlay` | Loading overlay |
|
|
518
|
+
| `noRowsOverlay` | Empty state overlay (no rows) |
|
|
518
519
|
|
|
519
520
|
### Custom Toolbar
|
|
520
521
|
|
|
@@ -581,6 +582,154 @@ const CustomLoadingOverlay = () => (
|
|
|
581
582
|
<DataTable rows={rows} columns={columns} loading slots={{ loadingOverlay: CustomLoadingOverlay }} />;
|
|
582
583
|
```
|
|
583
584
|
|
|
585
|
+
### No Rows Overlay
|
|
586
|
+
|
|
587
|
+
When `rows` is empty and `loading` is not `true`, a no rows overlay is displayed in the table body.
|
|
588
|
+
|
|
589
|
+
```tsx
|
|
590
|
+
<DataTable
|
|
591
|
+
onPaginationModelChange={fn()}
|
|
592
|
+
onSelectionModelChange={fn()}
|
|
593
|
+
onRowClick={fn()}
|
|
594
|
+
columns={[{
|
|
595
|
+
field: 'dessert',
|
|
596
|
+
headerName: 'Dessert (100g serving)',
|
|
597
|
+
width: '40%'
|
|
598
|
+
}, {
|
|
599
|
+
field: 'calories',
|
|
600
|
+
headerName: 'Calories',
|
|
601
|
+
type: 'number'
|
|
602
|
+
}, {
|
|
603
|
+
field: 'fat',
|
|
604
|
+
headerName: 'Fat (g)',
|
|
605
|
+
type: 'number'
|
|
606
|
+
}, {
|
|
607
|
+
field: 'carbs',
|
|
608
|
+
headerName: 'Carbs (g)',
|
|
609
|
+
type: 'number'
|
|
610
|
+
}, {
|
|
611
|
+
field: 'protein',
|
|
612
|
+
headerName: 'Protein (g)',
|
|
613
|
+
type: 'number'
|
|
614
|
+
}]}
|
|
615
|
+
rows={[]}
|
|
616
|
+
noWrap
|
|
617
|
+
/>
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
### Custom No Rows Overlay
|
|
621
|
+
|
|
622
|
+
You can customize the empty state UI using `slots.noRowsOverlay`.
|
|
623
|
+
|
|
624
|
+
```tsx
|
|
625
|
+
<DataTable rows={[]} columns={tableColumns} noWrap slots={{
|
|
626
|
+
noRowsOverlay: CustomOverlay
|
|
627
|
+
}} slotProps={{
|
|
628
|
+
noRowsOverlay: {
|
|
629
|
+
message: 'Custom message via slotProps'
|
|
630
|
+
}
|
|
631
|
+
}} />
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
```tsx
|
|
635
|
+
const CustomNoRowsOverlay = ({ message }: { message?: string }) => (
|
|
636
|
+
<Stack alignItems="center" spacing={1}>
|
|
637
|
+
<Typography level="title-md">No data available</Typography>
|
|
638
|
+
<Typography level="body-sm" textColor="text.secondary">
|
|
639
|
+
{message || 'Try adding new records.'}
|
|
640
|
+
</Typography>
|
|
641
|
+
</Stack>
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
<DataTable
|
|
645
|
+
rows={[]}
|
|
646
|
+
columns={columns}
|
|
647
|
+
slots={{ noRowsOverlay: CustomNoRowsOverlay }}
|
|
648
|
+
slotProps={{ noRowsOverlay: { message: 'Custom message via slotProps' } }}
|
|
649
|
+
/>;
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
### No Rows Overlay with Checkbox
|
|
653
|
+
|
|
654
|
+
The overlay correctly spans the full table width including the checkbox column.
|
|
655
|
+
|
|
656
|
+
```tsx
|
|
657
|
+
<DataTable
|
|
658
|
+
onPaginationModelChange={fn()}
|
|
659
|
+
onSelectionModelChange={fn()}
|
|
660
|
+
onRowClick={fn()}
|
|
661
|
+
columns={[{
|
|
662
|
+
field: 'dessert',
|
|
663
|
+
headerName: 'Dessert (100g serving)',
|
|
664
|
+
width: '40%'
|
|
665
|
+
}, {
|
|
666
|
+
field: 'calories',
|
|
667
|
+
headerName: 'Calories',
|
|
668
|
+
type: 'number'
|
|
669
|
+
}, {
|
|
670
|
+
field: 'fat',
|
|
671
|
+
headerName: 'Fat (g)',
|
|
672
|
+
type: 'number'
|
|
673
|
+
}, {
|
|
674
|
+
field: 'carbs',
|
|
675
|
+
headerName: 'Carbs (g)',
|
|
676
|
+
type: 'number'
|
|
677
|
+
}, {
|
|
678
|
+
field: 'protein',
|
|
679
|
+
headerName: 'Protein (g)',
|
|
680
|
+
type: 'number'
|
|
681
|
+
}]}
|
|
682
|
+
rows={[]}
|
|
683
|
+
noWrap
|
|
684
|
+
checkboxSelection
|
|
685
|
+
/>
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
### No Rows Overlay Loading Priority
|
|
689
|
+
|
|
690
|
+
When `loading` is `true`, the loading overlay takes priority over the no rows overlay.
|
|
691
|
+
|
|
692
|
+
```tsx
|
|
693
|
+
<Stack gap={2}>
|
|
694
|
+
<Button onClick={() => setLoading(!loading)}>{loading ? 'Stop Loading' : 'Start Loading'}</Button>
|
|
695
|
+
<Typography level="body-sm">
|
|
696
|
+
{loading ? 'Loading overlay is shown (noRowsOverlay hidden)' : 'NoRowsOverlay is shown'}
|
|
697
|
+
</Typography>
|
|
698
|
+
<DataTable rows={[]} columns={tableColumns} loading={loading} noWrap slotProps={{
|
|
699
|
+
background: {
|
|
700
|
+
style: {
|
|
701
|
+
height: '300px'
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}} />
|
|
705
|
+
</Stack>
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
### Combined Custom Loading + No Rows Overlay
|
|
709
|
+
|
|
710
|
+
Both `loadingOverlay` and `noRowsOverlay` slots can be customized simultaneously.
|
|
711
|
+
|
|
712
|
+
```tsx
|
|
713
|
+
<Stack gap={2}>
|
|
714
|
+
<Stack direction="row" gap={1} alignItems="center">
|
|
715
|
+
<Button onClick={() => setLoading(!loading)}>{loading ? 'Stop Loading' : 'Start Loading'}</Button>
|
|
716
|
+
<Typography level="body-xs" textColor="text.tertiary">
|
|
717
|
+
{loading ? 'Custom loading overlay shown' : 'Custom no rows overlay shown'}
|
|
718
|
+
</Typography>
|
|
719
|
+
</Stack>
|
|
720
|
+
<DataTable rows={[]} columns={tableColumns} loading={loading} noWrap slots={{
|
|
721
|
+
loadingOverlay: CustomLoadingOverlay,
|
|
722
|
+
noRowsOverlay: CustomNoRowsOverlay
|
|
723
|
+
}} slotProps={{
|
|
724
|
+
background: {
|
|
725
|
+
style: {
|
|
726
|
+
height: '300px'
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}} />
|
|
730
|
+
</Stack>
|
|
731
|
+
```
|
|
732
|
+
|
|
584
733
|
### Custom Checkbox
|
|
585
734
|
|
|
586
735
|
```tsx
|