@@ -16,38 +16,24 @@ export interface PaginatedTableWithLayoutProps {
1616 noBatching ?: boolean ;
1717}
1818
19- /**
20- * Hook to enhance table wrapper props with sort-dependent scroll behavior
21- */
22- const useTableWrapperPropsWithSortDependency = (
23- tableWrapperProps ?: TableWrapperProps ,
24- ) : TableWrapperProps => {
19+ const TableWrapper = ( {
20+ table,
21+ tableWrapperProps,
22+ } : {
23+ table : React . ReactNode ;
24+ tableWrapperProps ?: TableWrapperProps ;
25+ } ) => {
2526 const { tableState} = usePaginatedTableState ( ) ;
2627 const { sortParams} = tableState ;
2728
28- return React . useMemo ( ( ) => {
29+ const enhancedTableWrapperProps = React . useMemo ( ( ) => {
2930 const existingScrollDependencies = tableWrapperProps ?. scrollDependencies || [ ] ;
3031
3132 return {
3233 ...tableWrapperProps ,
3334 scrollDependencies : [ ...existingScrollDependencies , sortParams ] ,
3435 } ;
3536 } , [ tableWrapperProps , sortParams ] ) ;
36- } ;
37-
38- /**
39- * Internal component that wraps the table with sort-dependent scrolling behavior.
40- * This component has access to the paginated table context and automatically
41- * scrolls to top when sort parameters change.
42- */
43- const TableWrapper = ( {
44- table,
45- tableWrapperProps,
46- } : {
47- table : React . ReactNode ;
48- tableWrapperProps ?: TableWrapperProps ;
49- } ) => {
50- const enhancedTableWrapperProps = useTableWrapperPropsWithSortDependency ( tableWrapperProps ) ;
5137
5238 return (
5339 < TableWithControlsLayout . Table { ...enhancedTableWrapperProps } >
@@ -56,9 +42,6 @@ const TableWrapper = ({
5642 ) ;
5743} ;
5844
59- /**
60- * Renders the controls section if controls are provided
61- */
6245const ControlsSection = ( { controls} : { controls ?: React . ReactNode } ) => {
6346 if ( ! controls ) {
6447 return null ;
@@ -67,9 +50,6 @@ const ControlsSection = ({controls}: {controls?: React.ReactNode}) => {
6750 return < TableWithControlsLayout . Controls > { controls } </ TableWithControlsLayout . Controls > ;
6851} ;
6952
70- /**
71- * Renders the error section if an error is provided
72- */
7353const ErrorSection = ( { error} : { error ?: React . ReactNode } ) => {
7454 if ( ! error ) {
7555 return null ;
@@ -78,16 +58,6 @@ const ErrorSection = ({error}: {error?: React.ReactNode}) => {
7858 return < React . Fragment > { error } </ React . Fragment > ;
7959} ;
8060
81- /**
82- * A complete table layout component that provides pagination context and
83- * integrates with TableWithControlsLayout for consistent styling and behavior.
84- *
85- * Features:
86- * - Provides pagination context to child components
87- * - Automatic scroll-to-top on sort changes
88- * - Optional controls and error display
89- * - Configurable height behavior
90- */
9161export const PaginatedTableWithLayout = ( {
9262 controls,
9363 table,
0 commit comments