( state: TabListState<T> | null, key: Key | null | undefined, role: string )
| 19 | >(); |
| 20 | |
| 21 | export function generateId<T>( |
| 22 | state: TabListState<T> | null, |
| 23 | key: Key | null | undefined, |
| 24 | role: string |
| 25 | ): string { |
| 26 | if (!state) { |
| 27 | // this case should only happen in the first render before the tabs are registered |
| 28 | return ''; |
| 29 | } |
| 30 | if (typeof key === 'string') { |
| 31 | key = key.replace(/\s+/g, ''); |
| 32 | } |
| 33 | |
| 34 | let baseId = tabsIds.get(state); |
| 35 | if (process.env.NODE_ENV !== 'production' && !baseId) { |
| 36 | console.error( |
| 37 | 'There is no tab id, please check if you have rendered the tab panel before the tab list.' |
| 38 | ); |
| 39 | } |
| 40 | return `${baseId}-${role}-${key}`; |
| 41 | } |
no outgoing calls
no test coverage detected