Skip to content

Commit e243272

Browse files
authored
refactor: port setupGetInstanceId to typescript (#19104)
1 parent 3c21fb1 commit e243272

File tree

6 files changed

+23
-24
lines changed

6 files changed

+23
-24
lines changed

packages/react/src/components/DataTable/DataTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -16,7 +16,7 @@ import { getCellId } from './tools/cells';
1616
import denormalize from './tools/denormalize';
1717
import { composeEventHandlers } from '../../tools/events';
1818
import { defaultFilterRows } from './tools/filter';
19-
import setupGetInstanceId from '../../tools/setupGetInstanceId';
19+
import { setupGetInstanceId } from '../../tools/setupGetInstanceId';
2020
import Table from './Table';
2121
import TableActionList from './TableActionList';
2222
import TableBatchAction from './TableBatchAction';

packages/react/src/components/DataTable/TableToolbarSearch.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -17,7 +17,6 @@ import React, {
1717
RefObject,
1818
} from 'react';
1919
import Search, { SearchProps } from '../Search';
20-
import setupGetInstanceId from '../../tools/setupGetInstanceId';
2120
import { useId } from '../../internal/useId';
2221
import { usePrefix } from '../../internal/usePrefix';
2322
import { noopFn } from '../../internal/noopFn';

packages/react/src/components/OverflowMenu/OverflowMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { noopFn } from '../../internal/noopFn';
3939
import { PrefixContext } from '../../internal/usePrefix';
4040
import deprecate from '../../prop-types/deprecate';
4141
import mergeRefs from '../../tools/mergeRefs';
42-
import setupGetInstanceId from '../../tools/setupGetInstanceId';
42+
import { setupGetInstanceId } from '../../tools/setupGetInstanceId';
4343
import { IconButton } from '../IconButton';
4444
import { OverflowMenuItemProps } from '../OverflowMenuItem/OverflowMenuItem';
4545
import { useOutsideClick } from '../../internal/useOutsideClick';

packages/react/src/internal/useId.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -33,7 +33,7 @@
3333
// lower, `useCompatibleId` is used.
3434

3535
import React, { useEffect, useLayoutEffect, useState } from 'react';
36-
import setupGetInstanceId from '../tools/setupGetInstanceId';
36+
import { setupGetInstanceId } from '../tools/setupGetInstanceId';
3737
import { canUseDOM } from './environment';
3838
import { useIdPrefix } from './useIdPrefix';
3939

packages/react/src/tools/setupGetInstanceId.js

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright IBM Corp. 2016, 2025
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
/**
9+
* Creates an instance ID generator.
10+
*
11+
* @returns A function that returns a unique sequential ID on each call.
12+
*/
13+
export const setupGetInstanceId = () => {
14+
let instanceId = 0;
15+
16+
return () => ++instanceId;
17+
};

0 commit comments

Comments
 (0)