@@ -47,12 +47,14 @@ export interface Table_Density {
4747 toggleDensity : ( value ?: DensityState ) => void
4848}
4949
50- // Here is all of the actual javascript code for our new feature
51- export const densityPlugin : TableFeature < {
50+ interface DensityPluginConstructors {
5251 Table : Table_Density
5352 TableOptions : TableOptions_Density
5453 TableState : TableState_Density
55- } > = {
54+ }
55+
56+ // Here is all of the actual javascript code for our new feature
57+ export const densityPlugin : TableFeature < DensityPluginConstructors > = {
5658 // define the new feature's initial state
5759 getInitialState : ( initialState ) => {
5860 return {
@@ -69,9 +71,7 @@ export const densityPlugin: TableFeature<{
6971 }
7072 } ,
7173 // if you need to add a default column definition...
72- // getDefaultColumnDef: <TFeatures extends TableFeatures, TData extends RowData>(): Partial<ColumnDef<TFeatures, TData>> => {
73- // return { meta: {} } //use meta instead of directly adding to the columnDef to avoid typescript stuff that's hard to workaround
74- // },
74+ // getDefaultColumnDef: () => {},
7575
7676 // define the new feature's table instance methods
7777 constructTableAPIs : ( table ) => {
@@ -83,21 +83,24 @@ export const densityPlugin: TableFeature<{
8383 return table . options . onDensityChange ?.( safeUpdater )
8484 }
8585 table . toggleDensity = ( value ) => {
86- table . setDensity ( ( old ) => {
86+ table . setDensity ?. ( ( old ) => {
8787 if ( value ) return value
8888 return old === 'lg' ? 'md' : old === 'md' ? 'sm' : 'lg' // cycle through the 3 options
8989 } )
9090 }
9191 } ,
9292
93- // // if you need to add row instance APIs...
94- // constructRowAPIs: <TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>, table: Table<TFeatures, TData>): void => {},
95- // // if you need to add cell instance APIs...
96- // constructCellAPIs: <TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(cell: Cell<TFeatures, TData, TValue>): void => {},
97- // // if you need to add column instance APIs...
98- // constructColumnAPIs: <TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): void => {},
99- // // if you need to add header instance APIs...
100- // constructHeaderAPIs: <TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(header: Header<TFeatures, TData, TValue>): void => {},
93+ // if you need to add row instance APIs...
94+ // constructRowAPIs: (row) => {},
95+
96+ // if you need to add cell instance APIs...
97+ // constructCellAPIs: (cell) => {},
98+
99+ // if you need to add column instance APIs...
100+ // constructColumnAPIs: (column) => {},
101+
102+ // if you need to add header instance APIs...
103+ // constructHeaderAPIs: (header) => {},
101104}
102105// end of custom feature code
103106
0 commit comments