Skip to content

Commit f734901

Browse files
committed
Remove PropTypes
1 parent 9092c8f commit f734901

File tree

14 files changed

+158
-117
lines changed

14 files changed

+158
-117
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"fast-deep-equal": "^3.1.1",
5555
"invariant": "^2.2.1",
5656
"lodash.debounce": "^4.0.8",
57-
"prop-types": "^15.5.8",
5857
"scroll-into-view-if-needed": "^3.1.0",
5958
"warning": "^4.0.1"
6059
},
Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PropTypes from 'prop-types';
21
import React, { forwardRef } from 'react';
32

43
import { TypeaheadRef, useAsync, UseAsyncProps } from '../../core';
@@ -9,38 +8,4 @@ const AsyncTypeahead = forwardRef<TypeaheadRef, UseAsyncProps>((props, ref) => {
98
return <Typeahead {...useAsync(props)} ref={ref} />;
109
});
1110

12-
AsyncTypeahead.propTypes = {
13-
/**
14-
* Delay, in milliseconds, before performing search.
15-
*/
16-
delay: PropTypes.number,
17-
/**
18-
* Whether or not a request is currently pending. Necessary for the
19-
* container to know when new results are available.
20-
*/
21-
isLoading: PropTypes.bool.isRequired,
22-
/**
23-
* Number of input characters that must be entered before showing results.
24-
*/
25-
minLength: PropTypes.number,
26-
/**
27-
* Callback to perform when the search is executed.
28-
*/
29-
onSearch: PropTypes.func.isRequired,
30-
/**
31-
* Message displayed in the menu when there is no user input.
32-
*/
33-
// @ts-ignore
34-
promptText: PropTypes.node,
35-
/**
36-
* Message displayed in the menu while the request is pending.
37-
*/
38-
// @ts-ignore
39-
searchText: PropTypes.node,
40-
/**
41-
* Whether or not the component should cache query results.
42-
*/
43-
useCache: PropTypes.bool,
44-
};
45-
4611
export default AsyncTypeahead;

src/components/ClearButton/ClearButton.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
import cx from 'classnames';
2-
import PropTypes from 'prop-types';
32
import React, { HTMLProps, KeyboardEvent, MouseEvent } from 'react';
43

54
import type { Size } from '../../types';
65
import { isSizeLarge, isSizeSmall } from '../../utils';
76

8-
import { sizeType } from '../../propTypes';
9-
10-
const propTypes = {
11-
label: PropTypes.string,
12-
onClick: PropTypes.func,
13-
onKeyDown: PropTypes.func,
14-
size: sizeType,
15-
};
16-
177
export interface ClearButtonProps
188
extends Omit<HTMLProps<HTMLButtonElement>, 'size'> {
199
label?: string;
@@ -63,6 +53,4 @@ const ClearButton = ({
6353
</button>
6454
);
6555

66-
ClearButton.propTypes = propTypes;
67-
6856
export default ClearButton;

src/components/Highlighter/Highlighter.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32

43
import { getMatchBounds } from '../../utils';
54

6-
const propTypes = {
7-
children: PropTypes.string.isRequired,
8-
highlightClassName: PropTypes.string,
9-
search: PropTypes.string.isRequired,
10-
};
11-
125
export interface HighlighterProps {
136
children: string;
147
highlightClassName?: string;
158
search: string;
169
}
1710

1811
/**
19-
* Stripped-down version of https://github.com/helior/react-highlighter
20-
*
2112
* Results are already filtered by the time the component is used internally so
2213
* we can safely ignore case and diacritical marks for the purposes of matching.
2314
*/
@@ -66,6 +57,4 @@ const Highlighter = ({
6657
return <>{highlighterChildren}</>;
6758
};
6859

69-
Highlighter.propTypes = propTypes;
70-
7160
export default Highlighter;

src/components/Loader/Loader.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32

4-
const propTypes = {
5-
label: PropTypes.string,
6-
};
7-
83
export interface LoaderProps {
94
label?: string;
105
}
@@ -15,6 +10,4 @@ const Loader = ({ label = 'Loading...' }: LoaderProps) => (
1510
</div>
1611
);
1712

18-
Loader.propTypes = propTypes;
19-
2013
export default Loader;

src/components/Menu/Menu.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import MenuItem from '../MenuItem';
66

77
const options = [{ label: 'Item 1' }, { label: 'Item 2' }, { label: 'Item 3' }];
88

9-
// TODO: Caused by `isRequiredForA11y` validator.
10-
// @ts-ignore
119
export default {
1210
title: 'Components/Menu',
1311
component: Menu,

src/components/Menu/Menu.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import cx from 'classnames';
2-
import PropTypes from 'prop-types';
32
import React, { Children, HTMLProps, ReactNode, Ref } from 'react';
43

54
import { BaseMenuItem } from '../MenuItem';
65

6+
import { Id } from '../../types';
77
import { preventInputBlur } from '../../utils';
8-
import { checkPropType, isRequiredForA11y } from '../../propTypes';
98

109
const MenuDivider = () => <div className="dropdown-divider" role="separator" />;
1110

@@ -14,28 +13,19 @@ const MenuHeader = (props: HTMLProps<HTMLDivElement>) => (
1413
<div {...props} className="dropdown-header" role="heading" />
1514
);
1615

17-
const propTypes = {
18-
'aria-label': PropTypes.string,
16+
export interface MenuProps extends HTMLProps<HTMLDivElement> {
1917
/**
2018
* Message to display in the menu if there are no valid results.
2119
*/
22-
emptyLabel: PropTypes.node,
20+
emptyLabel?: ReactNode;
2321
/**
2422
* Needed for accessibility.
2523
*/
26-
id: checkPropType(
27-
PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
28-
isRequiredForA11y
29-
),
24+
id?: Id;
25+
innerRef?: Ref<HTMLDivElement>;
3026
/**
3127
* Maximum height of the dropdown menu.
3228
*/
33-
maxHeight: PropTypes.string,
34-
};
35-
36-
export interface MenuProps extends HTMLProps<HTMLDivElement> {
37-
emptyLabel?: ReactNode;
38-
innerRef?: Ref<HTMLDivElement>;
3929
maxHeight?: string;
4030
}
4131

@@ -82,7 +72,6 @@ const Menu = ({
8272
);
8373
};
8474

85-
Menu.propTypes = propTypes;
8675
Menu.Divider = MenuDivider;
8776
Menu.Header = MenuHeader;
8877

src/components/MenuItem/MenuItem.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import cx from 'classnames';
2-
import PropTypes from 'prop-types';
32
import React, { forwardRef, HTMLAttributes, MouseEvent } from 'react';
43

54
import { useItem, UseItemProps } from '../../core';
6-
import { optionType } from '../../propTypes';
75

86
export interface BaseMenuItemProps extends HTMLAttributes<HTMLAnchorElement> {
97
active?: boolean;
@@ -35,9 +33,4 @@ function MenuItem(props: MenuItemProps) {
3533
return <BaseMenuItem {...useItem(props)} />;
3634
}
3735

38-
MenuItem.propTypes = {
39-
option: optionType.isRequired,
40-
position: PropTypes.number,
41-
};
42-
4336
export default MenuItem;

src/components/Token/Token.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import cx from 'classnames';
2-
import PropTypes from 'prop-types';
32
import React, { forwardRef, HTMLProps, MouseEventHandler } from 'react';
43

54
import ClearButton from '../ClearButton';
65

76
import { useToken, UseTokenProps } from '../../core';
8-
import { optionType } from '../../propTypes';
97
import { isFunction } from '../../utils';
108

119
type HTMLElementProps = Omit<HTMLProps<HTMLDivElement>, 'onBlur' | 'ref'>;
@@ -97,12 +95,4 @@ const Token = ({
9795
);
9896
};
9997

100-
Token.propTypes = {
101-
onBlur: PropTypes.func,
102-
onClick: PropTypes.func,
103-
onFocus: PropTypes.func,
104-
onRemove: PropTypes.func,
105-
option: optionType.isRequired,
106-
};
107-
10898
export default Token;

src/components/TypeaheadMenu/TypeaheadMenu.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PropTypes from 'prop-types';
21
import React, { ReactNode } from 'react';
32

43
import Highlighter from '../Highlighter';
@@ -16,28 +15,22 @@ export type RenderMenuItemChildren = (
1615

1716
export interface TypeaheadMenuProps extends MenuProps {
1817
labelKey: LabelKey;
19-
newSelectionPrefix?: ReactNode;
20-
options: Option[];
21-
paginationText?: ReactNode;
22-
renderMenuItemChildren?: RenderMenuItemChildren;
23-
text: string;
24-
}
25-
26-
const propTypes = {
2718
/**
2819
* Provides the ability to specify a prefix before the user-entered text to
2920
* indicate that the selection will be new. No-op unless `allowNew={true}`.
3021
*/
31-
newSelectionPrefix: PropTypes.node,
22+
newSelectionPrefix?: ReactNode;
23+
options: Option[];
3224
/**
3325
* Prompt displayed when large data sets are paginated.
3426
*/
35-
paginationText: PropTypes.node,
27+
paginationText?: ReactNode;
3628
/**
3729
* Provides a hook for customized rendering of menu item contents.
3830
*/
39-
renderMenuItemChildren: PropTypes.func,
40-
};
31+
renderMenuItemChildren?: RenderMenuItemChildren;
32+
text: string;
33+
}
4134

4235
function defaultRenderMenuItemChildren(
4336
option: Option,
@@ -122,6 +115,4 @@ const TypeaheadMenu = (props: TypeaheadMenuProps) => {
122115
);
123116
};
124117

125-
TypeaheadMenu.propTypes = propTypes;
126-
127118
export default TypeaheadMenu;

0 commit comments

Comments
 (0)