@@ -12,7 +12,7 @@ import {
1212 MiddlewareFunction ,
1313 IdReducerFunctions ,
1414} from '@table-library/react-table-library/types/common' ;
15- import { Data , TableNode } from '@table-library/react-table-library/types/table' ;
15+ import { Data , Identifier , TableNode } from '@table-library/react-table-library/types/table' ;
1616
1717const addById = ( state : State , action : Action ) => {
1818 return {
@@ -142,7 +142,7 @@ const getMergedOptions = (options: Record<string, any>) => ({
142142 ...options ,
143143} ) ;
144144
145- const getRecursiveIds = ( id : string , nodes : TableNode [ ] ) => {
145+ const getRecursiveIds = ( id : Identifier , nodes : TableNode [ ] ) => {
146146 const node = findNodeById ( nodes , id ) ;
147147
148148 return [ node , ...fromTreeToList ( node ?. nodes ) ] . map ( ( item ) => item ! . id ) ;
@@ -163,7 +163,10 @@ const useIdReducer = <T extends TableNode>(
163163 ) ;
164164
165165 // exclusive for select feature
166- const shiftToggle = React . useRef ( {
166+ const shiftToggle = React . useRef < {
167+ lastToggledId : Identifier | null ;
168+ currentShiftIds : Identifier [ ] ;
169+ } > ( {
167170 lastToggledId : null ,
168171 currentShiftIds : [ ] ,
169172 } ) ;
@@ -178,7 +181,7 @@ const useIdReducer = <T extends TableNode>(
178181 ) ;
179182
180183 const onAddById = React . useCallback (
181- ( id ) =>
184+ ( id : Identifier ) =>
182185 dispatchWithMiddleware ( {
183186 type : ADD_BY_ID ,
184187 payload : { id } ,
@@ -187,7 +190,7 @@ const useIdReducer = <T extends TableNode>(
187190 ) ;
188191
189192 const onRemoveById = React . useCallback (
190- ( id ) =>
193+ ( id : Identifier ) =>
191194 dispatchWithMiddleware ( {
192195 type : REMOVE_BY_ID ,
193196 payload : { id } ,
@@ -196,7 +199,7 @@ const useIdReducer = <T extends TableNode>(
196199 ) ;
197200
198201 const onToggleById = React . useCallback (
199- ( id ) => {
202+ ( id : Identifier ) => {
200203 if ( state . ids . includes ( id ) ) {
201204 onRemoveById ( id ) ;
202205 } else {
@@ -210,7 +213,7 @@ const useIdReducer = <T extends TableNode>(
210213 ) ;
211214
212215 const onAddByIds = React . useCallback (
213- ( ids , options ) => {
216+ ( ids : Identifier [ ] , options ) => {
214217 const mergedOptions = getMergedOptions ( options ) ;
215218
216219 dispatchWithMiddleware ( {
@@ -225,7 +228,7 @@ const useIdReducer = <T extends TableNode>(
225228 ) ;
226229
227230 const onRemoveByIds = React . useCallback (
228- ( ids ) => {
231+ ( ids : Identifier [ ] ) => {
229232 dispatchWithMiddleware ( {
230233 type : REMOVE_BY_IDS ,
231234 payload : { ids } ,
@@ -235,7 +238,7 @@ const useIdReducer = <T extends TableNode>(
235238 ) ;
236239
237240 const onToggleByIdRecursively = React . useCallback (
238- ( id , options ) => {
241+ ( id : Identifier , options ) => {
239242 const mergedOptions = getMergedOptions ( options ) ;
240243
241244 const ids = getRecursiveIds ( id , data . nodes ) ;
@@ -274,7 +277,7 @@ const useIdReducer = <T extends TableNode>(
274277 ) ;
275278
276279 const onRemoveByIdRecursively = React . useCallback (
277- ( id ) => {
280+ ( id : Identifier ) => {
278281 const ids = getRecursiveIds ( id , data . nodes ) ;
279282
280283 onRemoveByIds ( ids ) ;
@@ -283,7 +286,7 @@ const useIdReducer = <T extends TableNode>(
283286 ) ;
284287
285288 const onAddByIdExclusively = React . useCallback (
286- ( id ) => {
289+ ( id : Identifier ) => {
287290 dispatchWithMiddleware ( {
288291 type : ADD_BY_ID_EXCLUSIVELY ,
289292 payload : { id } ,
@@ -299,7 +302,7 @@ const useIdReducer = <T extends TableNode>(
299302 } , [ dispatchWithMiddleware ] ) ;
300303
301304 const onToggleByIdExclusively = React . useCallback (
302- ( id ) => {
305+ ( id : Identifier ) => {
303306 if ( id === state . id ) {
304307 onRemoveByIdExclusively ( ) ;
305308 } else {
0 commit comments