Skip to content

Commit d5bc813

Browse files
committed
fix(ListBox): rename colliding symbols and fix prop types
1 parent 84d0e93 commit d5bc813

File tree

10 files changed

+50
-33
lines changed

10 files changed

+50
-33
lines changed

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,6 +3874,15 @@ Map {
38743874
"translateWithId": Object {
38753875
"type": "func",
38763876
},
3877+
"type": Object {
3878+
"args": Array [
3879+
Array [
3880+
"default",
3881+
"inline",
3882+
],
3883+
],
3884+
"type": "oneOf",
3885+
},
38773886
"useTitleInItem": Object {
38783887
"type": "bool",
38793888
},

packages/react/src/components/ComboBox/ComboBox.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ import {
3535
WarningFilled,
3636
} from '@carbon/icons-react';
3737
import isEqual from 'react-fast-compare';
38-
import ListBox, {
39-
PropTypes as ListBoxPropTypes,
40-
ListBoxSize,
41-
} from '../ListBox';
38+
import ListBox, { ListBoxSizePropType, type ListBoxSize } from '../ListBox';
4239
import { ListBoxTrigger, ListBoxSelection } from '../ListBox/next';
4340
import { match, keys } from '../../internal/keyboard';
4441
import { useId } from '../../internal/useId';
@@ -1390,7 +1387,7 @@ ComboBox.propTypes = {
13901387
/**
13911388
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
13921389
*/
1393-
size: ListBoxPropTypes.ListBoxSize,
1390+
size: ListBoxSizePropType,
13941391

13951392
slug: deprecate(
13961393
PropTypes.node,

packages/react/src/components/Dropdown/Dropdown.Skeleton.tsx

Lines changed: 3 additions & 3 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.
@@ -8,7 +8,7 @@
88
import PropTypes from 'prop-types';
99
import React from 'react';
1010
import cx from 'classnames';
11-
import { ListBoxSize, PropTypes as ListBoxPropTypes } from '../ListBox';
11+
import { ListBoxSizePropType, type ListBoxSize } from '../ListBox';
1212
import { usePrefix } from '../../internal/usePrefix';
1313
import { ReactAttr } from '../../types/common';
1414

@@ -69,7 +69,7 @@ DropdownSkeleton.propTypes = {
6969
/**
7070
* Specify the size of the ListBox.
7171
*/
72-
size: ListBoxPropTypes.ListBoxSize,
72+
size: ListBoxSizePropType,
7373
};
7474

7575
export default DropdownSkeleton;

packages/react/src/components/Dropdown/Dropdown.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ import {
3333
WarningFilled,
3434
} from '@carbon/icons-react';
3535
import ListBox, {
36+
ListBoxSizePropType,
37+
ListBoxTypePropType,
3638
type ListBoxMenuIconTranslationKey,
37-
ListBoxSize,
38-
ListBoxType,
39-
PropTypes as ListBoxPropTypes,
39+
type ListBoxSize,
40+
type ListBoxType,
4041
} from '../ListBox';
4142
import mergeRefs from '../../tools/mergeRefs';
4243
import deprecate from '../../prop-types/deprecate';
@@ -882,7 +883,7 @@ Dropdown.propTypes = {
882883
/**
883884
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
884885
*/
885-
size: ListBoxPropTypes.ListBoxSize,
886+
size: ListBoxSizePropType,
886887

887888
/**
888889
* **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
@@ -907,7 +908,7 @@ Dropdown.propTypes = {
907908
/**
908909
* The dropdown type, `default` or `inline`
909910
*/
910-
type: ListBoxPropTypes.ListBoxType,
911+
type: ListBoxTypePropType,
911912

912913
/**
913914
* Specify whether the control is currently in warning state

packages/react/src/components/ListBox/ListBox.tsx

Lines changed: 9 additions & 4 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.
@@ -9,7 +9,12 @@ import cx from 'classnames';
99
import React, { type KeyboardEvent, type MouseEvent, useContext } from 'react';
1010
import PropTypes from 'prop-types';
1111
import deprecate from '../../prop-types/deprecate';
12-
import { ListBoxType, ListBoxSize } from './ListBoxPropTypes';
12+
import {
13+
ListBoxSizePropType,
14+
ListBoxTypePropType,
15+
type ListBoxSize,
16+
type ListBoxType,
17+
} from '.';
1318
import { usePrefix } from '../../internal/usePrefix';
1419
import { FormContext } from '../FluidForm';
1520
import { ForwardRefReturn, ReactAttr } from '../../types/common';
@@ -207,13 +212,13 @@ ListBox.propTypes = {
207212
/**
208213
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
209214
*/
210-
size: ListBoxSize,
215+
size: ListBoxSizePropType,
211216

212217
/**
213218
* Specify the "type" of the ListBox. Currently supports either `default` or
214219
* `inline` as an option.
215220
*/
216-
type: ListBoxType,
221+
type: ListBoxTypePropType,
217222

218223
/**
219224
* Specify whether the control is currently in warning state

packages/react/src/components/ListBox/ListBoxPropTypes.ts

Lines changed: 3 additions & 3 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.
@@ -13,5 +13,5 @@ const listBoxSizes = ['sm', 'md', 'lg'] as const;
1313
export type ListBoxType = (typeof listBoxTypes)[number];
1414
export type ListBoxSize = (typeof listBoxSizes)[number];
1515

16-
export const ListBoxType = PropTypes.oneOf<ListBoxType>(listBoxTypes);
17-
export const ListBoxSize = PropTypes.oneOf<ListBoxSize>(listBoxSizes);
16+
export const ListBoxTypePropType = PropTypes.oneOf(listBoxTypes);
17+
export const ListBoxSizePropType = PropTypes.oneOf(listBoxSizes);

packages/react/src/components/ListBox/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ Currently, a `ListBox` is broken up into the following pieces:
1616
- `ListBoxMenu`: container component for the menu of options available in a
1717
`ListBox`
1818
- `ListBoxMenuItem`: container component for an option in a `ListBoxMenu`
19-
20-
In addition, we have `ListBox`-specific `prop` types in `ListBoxPropTypes`.

packages/react/src/components/ListBox/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
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.
66
*/
77

8-
export * as PropTypes from './ListBoxPropTypes';
98
export * from './ListBoxPropTypes';
109

1110
import ListBoxInternal, {

packages/react/src/components/MultiSelect/FilterableMultiSelect.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ import {
3939
type MultiSelectSortingProps,
4040
sortingPropTypes,
4141
} from './MultiSelectPropTypes';
42-
import ListBox, { PropTypes as ListBoxPropTypes } from '../ListBox';
42+
import ListBox, {
43+
ListBoxSizePropType,
44+
ListBoxTypePropType,
45+
type ListBoxSize,
46+
type ListBoxType,
47+
} from '../ListBox';
4348
import { ListBoxTrigger, ListBoxSelection } from '../ListBox/next';
4449
import { match, keys } from '../../internal/keyboard';
4550
import { defaultItemToString } from './tools/itemToString';
@@ -281,7 +286,7 @@ export interface FilterableMultiSelectProps<ItemType>
281286
* Specify the size of the ListBox.
282287
* Currently, supports either `sm`, `md` or `lg` as an option.
283288
*/
284-
size?: 'sm' | 'md' | 'lg';
289+
size?: ListBoxSize;
285290

286291
/**
287292
* @deprecated please use decorator instead.
@@ -295,7 +300,7 @@ export interface FilterableMultiSelectProps<ItemType>
295300
*/
296301
titleText?: ReactNode;
297302

298-
type?: 'default' | 'inline';
303+
type?: ListBoxType;
299304

300305
/**
301306
* Specify title to show title on hover
@@ -1180,7 +1185,7 @@ FilterableMultiSelect.propTypes = {
11801185
/**
11811186
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
11821187
*/
1183-
size: ListBoxPropTypes.ListBoxSize,
1188+
size: ListBoxSizePropType,
11841189

11851190
slug: deprecate(
11861191
PropTypes.node,
@@ -1200,6 +1205,8 @@ FilterableMultiSelect.propTypes = {
12001205
*/
12011206
translateWithId: PropTypes.func,
12021207

1208+
type: ListBoxTypePropType,
1209+
12031210
/**
12041211
* Specify title to show title on hover
12051212
*/

packages/react/src/components/MultiSelect/MultiSelect.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ import React, {
2626
useCallback,
2727
} from 'react';
2828
import ListBox, {
29-
ListBoxSize,
30-
ListBoxType,
31-
PropTypes as ListBoxPropTypes,
29+
ListBoxSizePropType,
30+
ListBoxTypePropType,
31+
type ListBoxSize,
32+
type ListBoxType,
3233
} from '../ListBox';
3334
import {
3435
MultiSelectSortingProps,
@@ -1099,7 +1100,7 @@ MultiSelect.propTypes = {
10991100
/**
11001101
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
11011102
*/
1102-
size: ListBoxPropTypes.ListBoxSize,
1103+
size: ListBoxSizePropType,
11031104

11041105
slug: deprecate(
11051106
PropTypes.node,
@@ -1142,7 +1143,7 @@ MultiSelect.propTypes = {
11421143
/**
11431144
* Specify 'inline' to create an inline multi-select.
11441145
*/
1145-
type: PropTypes.oneOf(['default', 'inline']),
1146+
type: ListBoxTypePropType,
11461147

11471148
/**
11481149
* Specify title to show title on hover

0 commit comments

Comments
 (0)