@ceed/ads 1.27.0 → 1.28.1
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 +2 -1
- package/dist/components/DataTable/types.d.ts +4 -0
- package/dist/components/data-display/DataTable.md +163 -10
- package/dist/index.browser.js +2 -2
- package/dist/index.browser.js.map +2 -2
- package/dist/index.cjs +39 -6
- package/dist/index.js +44 -11
- 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
|
|
283
|
+
export declare const DefaultNoRowsOverlay: () => React.JSX.Element;
|
|
284
|
+
export declare const Resizer: (ref: RefObject<HTMLTableCellElement>, targetRef?: RefObject<any>, onResizeStateChange?: ((isResizing: boolean) => void) | undefined) => 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 {};
|
|
@@ -496,10 +496,14 @@ When a row has focus, use keyboard shortcuts to navigate and interact with rows.
|
|
|
496
496
|
<DataTable checkboxSelection stripe="even" hoverRow selectionModel={selectedId} stickyHeader onSelectionModelChange={newSelection => setSelectedId(newSelection)} rows={[...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4, ...rows4].map((row, i) => ({
|
|
497
497
|
...row,
|
|
498
498
|
id: i
|
|
499
|
-
}))} columns={columns}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
499
|
+
}))} columns={columns} initialState={{
|
|
500
|
+
sorting: {
|
|
501
|
+
sortModel: [{
|
|
502
|
+
field: 'number',
|
|
503
|
+
sort: 'asc'
|
|
504
|
+
}]
|
|
505
|
+
}
|
|
506
|
+
}} />
|
|
503
507
|
</Stack>
|
|
504
508
|
```
|
|
505
509
|
|
|
@@ -509,12 +513,13 @@ DataTable allows customization of various parts through `slots` and `slotProps`.
|
|
|
509
513
|
|
|
510
514
|
### Available Slots
|
|
511
515
|
|
|
512
|
-
| Slot | Description
|
|
513
|
-
| ---------------- |
|
|
514
|
-
| `checkbox` | Customize checkbox component
|
|
515
|
-
| `toolbar` | Table top toolbar
|
|
516
|
-
| `footer` | Table bottom footer
|
|
517
|
-
| `loadingOverlay` | Loading overlay
|
|
516
|
+
| Slot | Description |
|
|
517
|
+
| ---------------- | ----------------------------- |
|
|
518
|
+
| `checkbox` | Customize checkbox component |
|
|
519
|
+
| `toolbar` | Table top toolbar |
|
|
520
|
+
| `footer` | Table bottom footer |
|
|
521
|
+
| `loadingOverlay` | Loading overlay |
|
|
522
|
+
| `noRowsOverlay` | Empty state overlay (no rows) |
|
|
518
523
|
|
|
519
524
|
### Custom Toolbar
|
|
520
525
|
|
|
@@ -581,6 +586,154 @@ const CustomLoadingOverlay = () => (
|
|
|
581
586
|
<DataTable rows={rows} columns={columns} loading slots={{ loadingOverlay: CustomLoadingOverlay }} />;
|
|
582
587
|
```
|
|
583
588
|
|
|
589
|
+
### No Rows Overlay
|
|
590
|
+
|
|
591
|
+
When `rows` is empty and `loading` is not `true`, a no rows overlay is displayed in the table body.
|
|
592
|
+
|
|
593
|
+
```tsx
|
|
594
|
+
<DataTable
|
|
595
|
+
onPaginationModelChange={fn()}
|
|
596
|
+
onSelectionModelChange={fn()}
|
|
597
|
+
onRowClick={fn()}
|
|
598
|
+
columns={[{
|
|
599
|
+
field: 'dessert',
|
|
600
|
+
headerName: 'Dessert (100g serving)',
|
|
601
|
+
width: '40%'
|
|
602
|
+
}, {
|
|
603
|
+
field: 'calories',
|
|
604
|
+
headerName: 'Calories',
|
|
605
|
+
type: 'number'
|
|
606
|
+
}, {
|
|
607
|
+
field: 'fat',
|
|
608
|
+
headerName: 'Fat (g)',
|
|
609
|
+
type: 'number'
|
|
610
|
+
}, {
|
|
611
|
+
field: 'carbs',
|
|
612
|
+
headerName: 'Carbs (g)',
|
|
613
|
+
type: 'number'
|
|
614
|
+
}, {
|
|
615
|
+
field: 'protein',
|
|
616
|
+
headerName: 'Protein (g)',
|
|
617
|
+
type: 'number'
|
|
618
|
+
}]}
|
|
619
|
+
rows={[]}
|
|
620
|
+
noWrap
|
|
621
|
+
/>
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### Custom No Rows Overlay
|
|
625
|
+
|
|
626
|
+
You can customize the empty state UI using `slots.noRowsOverlay`.
|
|
627
|
+
|
|
628
|
+
```tsx
|
|
629
|
+
<DataTable rows={[]} columns={tableColumns} noWrap slots={{
|
|
630
|
+
noRowsOverlay: CustomOverlay
|
|
631
|
+
}} slotProps={{
|
|
632
|
+
noRowsOverlay: {
|
|
633
|
+
message: 'Custom message via slotProps'
|
|
634
|
+
}
|
|
635
|
+
}} />
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
```tsx
|
|
639
|
+
const CustomNoRowsOverlay = ({ message }: { message?: string }) => (
|
|
640
|
+
<Stack alignItems="center" spacing={1}>
|
|
641
|
+
<Typography level="title-md">No data available</Typography>
|
|
642
|
+
<Typography level="body-sm" textColor="text.secondary">
|
|
643
|
+
{message || 'Try adding new records.'}
|
|
644
|
+
</Typography>
|
|
645
|
+
</Stack>
|
|
646
|
+
);
|
|
647
|
+
|
|
648
|
+
<DataTable
|
|
649
|
+
rows={[]}
|
|
650
|
+
columns={columns}
|
|
651
|
+
slots={{ noRowsOverlay: CustomNoRowsOverlay }}
|
|
652
|
+
slotProps={{ noRowsOverlay: { message: 'Custom message via slotProps' } }}
|
|
653
|
+
/>;
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
### No Rows Overlay with Checkbox
|
|
657
|
+
|
|
658
|
+
The overlay correctly spans the full table width including the checkbox column.
|
|
659
|
+
|
|
660
|
+
```tsx
|
|
661
|
+
<DataTable
|
|
662
|
+
onPaginationModelChange={fn()}
|
|
663
|
+
onSelectionModelChange={fn()}
|
|
664
|
+
onRowClick={fn()}
|
|
665
|
+
columns={[{
|
|
666
|
+
field: 'dessert',
|
|
667
|
+
headerName: 'Dessert (100g serving)',
|
|
668
|
+
width: '40%'
|
|
669
|
+
}, {
|
|
670
|
+
field: 'calories',
|
|
671
|
+
headerName: 'Calories',
|
|
672
|
+
type: 'number'
|
|
673
|
+
}, {
|
|
674
|
+
field: 'fat',
|
|
675
|
+
headerName: 'Fat (g)',
|
|
676
|
+
type: 'number'
|
|
677
|
+
}, {
|
|
678
|
+
field: 'carbs',
|
|
679
|
+
headerName: 'Carbs (g)',
|
|
680
|
+
type: 'number'
|
|
681
|
+
}, {
|
|
682
|
+
field: 'protein',
|
|
683
|
+
headerName: 'Protein (g)',
|
|
684
|
+
type: 'number'
|
|
685
|
+
}]}
|
|
686
|
+
rows={[]}
|
|
687
|
+
noWrap
|
|
688
|
+
checkboxSelection
|
|
689
|
+
/>
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
### No Rows Overlay Loading Priority
|
|
693
|
+
|
|
694
|
+
When `loading` is `true`, the loading overlay takes priority over the no rows overlay.
|
|
695
|
+
|
|
696
|
+
```tsx
|
|
697
|
+
<Stack gap={2}>
|
|
698
|
+
<Button onClick={() => setLoading(!loading)}>{loading ? 'Stop Loading' : 'Start Loading'}</Button>
|
|
699
|
+
<Typography level="body-sm">
|
|
700
|
+
{loading ? 'Loading overlay is shown (noRowsOverlay hidden)' : 'NoRowsOverlay is shown'}
|
|
701
|
+
</Typography>
|
|
702
|
+
<DataTable rows={[]} columns={tableColumns} loading={loading} noWrap slotProps={{
|
|
703
|
+
background: {
|
|
704
|
+
style: {
|
|
705
|
+
height: '300px'
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}} />
|
|
709
|
+
</Stack>
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
### Combined Custom Loading + No Rows Overlay
|
|
713
|
+
|
|
714
|
+
Both `loadingOverlay` and `noRowsOverlay` slots can be customized simultaneously.
|
|
715
|
+
|
|
716
|
+
```tsx
|
|
717
|
+
<Stack gap={2}>
|
|
718
|
+
<Stack direction="row" gap={1} alignItems="center">
|
|
719
|
+
<Button onClick={() => setLoading(!loading)}>{loading ? 'Stop Loading' : 'Start Loading'}</Button>
|
|
720
|
+
<Typography level="body-xs" textColor="text.tertiary">
|
|
721
|
+
{loading ? 'Custom loading overlay shown' : 'Custom no rows overlay shown'}
|
|
722
|
+
</Typography>
|
|
723
|
+
</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
|
+
```
|
|
736
|
+
|
|
584
737
|
### Custom Checkbox
|
|
585
738
|
|
|
586
739
|
```tsx
|