Skip to content

Commit

Permalink
Merge branch 'remove-default-props' of github.com:tw15egan/carbon int…
Browse files Browse the repository at this point in the history
…o remove-default-props
  • Loading branch information
tw15egan committed Oct 2, 2023
2 parents eb4ec4a + 9354beb commit a235977
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 304 deletions.
104 changes: 0 additions & 104 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1557,9 +1557,6 @@ Map {
},
},
"Content" => Object {
"defaultProps": Object {
"tagName": "main",
},
"propTypes": Object {
"children": Object {
"type": "node",
Expand All @@ -1577,15 +1574,6 @@ Map {
},
"ControlledPasswordInput" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"disabled": false,
"helperText": "",
"invalid": false,
"invalidText": "",
"onChange": [Function],
"onClick": [Function],
"size": undefined,
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down Expand Up @@ -6049,9 +6037,6 @@ Map {
},
},
"ProgressStep" => Object {
"defaultProps": Object {
"translateWithId": [Function],
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down Expand Up @@ -6250,10 +6235,6 @@ Map {
},
"RadioTile" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"onChange": [Function],
"tabIndex": 0,
},
"propTypes": Object {
"checked": Object {
"type": "bool",
Expand Down Expand Up @@ -6426,9 +6407,6 @@ Map {
"render": [Function],
},
"SearchSkeleton" => Object {
"defaultProps": Object {
"small": false,
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down Expand Up @@ -6459,14 +6437,6 @@ Map {
},
"Select" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"disabled": false,
"helperText": "",
"inline": false,
"invalid": false,
"invalidText": "",
"labelText": "Select",
},
"propTypes": Object {
"children": Object {
"type": "node",
Expand Down Expand Up @@ -6532,12 +6502,6 @@ Map {
"render": [Function],
},
"SelectItem" => Object {
"defaultProps": Object {
"disabled": false,
"hidden": false,
"text": "",
"value": "",
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand All @@ -6559,9 +6523,6 @@ Map {
},
},
"SelectItemGroup" => Object {
"defaultProps": Object {
"disabled": false,
},
"propTypes": Object {
"children": Object {
"type": "node",
Expand Down Expand Up @@ -6714,13 +6675,9 @@ Map {
},
},
"SideNavFooter" => Object {
"defaultProps": Object {
"assistiveText": "Toggle opening or closing the side navigation",
},
"displayName": "SideNavFooter",
"propTypes": Object {
"assistiveText": Object {
"isRequired": true,
"type": "string",
},
"className": Object {
Expand Down Expand Up @@ -6765,9 +6722,6 @@ Map {
},
},
"SideNavIcon" => Object {
"defaultProps": Object {
"small": false,
},
"propTypes": Object {
"children": Object {
"isRequired": true,
Expand All @@ -6777,7 +6731,6 @@ Map {
"type": "string",
},
"small": Object {
"isRequired": true,
"type": "bool",
},
},
Expand Down Expand Up @@ -6966,12 +6919,6 @@ Map {
},
},
"SkeletonText" => Object {
"defaultProps": Object {
"heading": false,
"lineCount": 3,
"paragraph": false,
"width": "100%",
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down Expand Up @@ -7190,11 +7137,6 @@ Map {
},
"Switch" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"onClick": [Function],
"onKeyDown": [Function],
"selected": false,
},
"propTypes": Object {
"children": Object {
"type": "node",
Expand Down Expand Up @@ -8066,20 +8008,6 @@ Map {
},
"TextArea" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"disabled": false,
"enableCounter": false,
"helperText": "",
"invalid": false,
"invalidText": "",
"maxCount": undefined,
"onChange": [Function],
"onClick": [Function],
"placeholder": "",
"rows": 4,
"warn": false,
"warnText": "",
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down Expand Up @@ -8180,15 +8108,6 @@ Map {
"$$typeof": Symbol(react.forward_ref),
"ControlledPasswordInput": Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"disabled": false,
"helperText": "",
"invalid": false,
"invalidText": "",
"onChange": [Function],
"onClick": [Function],
"size": undefined,
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down Expand Up @@ -9329,11 +9248,6 @@ Map {
},
"unstable_OverflowMenuV2" => Object {},
"unstable_PageSelector" => Object {
"defaultProps": Object {
"className": null,
"id": 1,
"labelText": "Current page number",
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down Expand Up @@ -9365,24 +9279,6 @@ Map {
},
},
"unstable_Pagination" => Object {
"defaultProps": Object {
"backwardText": "Previous page",
"children": undefined,
"className": null,
"disabled": false,
"forwardText": "Next page",
"id": 1,
"initialPage": 1,
"itemRangeText": [Function],
"itemText": [Function],
"itemsPerPageText": "Items per page:",
"pageRangeText": [Function],
"pageSize": 10,
"pageSizes": undefined,
"pageText": [Function],
"pagesUnknown": false,
"totalItems": undefined,
},
"propTypes": Object {
"backwardText": Object {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import SelectItem from '../../SelectItem';
import { usePrefix } from '../../../internal/usePrefix';

const getInstanceId = setupGetInstanceId();

function PageSelector({
className,
className = null,
currentPage,
id,
labelText,
id = 1,
labelText = 'Current page number',
totalPages,
...other
}) {
Expand Down Expand Up @@ -71,10 +70,4 @@ PageSelector.propTypes = {
totalPages: PropTypes.number.isRequired,
};

PageSelector.defaultProps = {
className: null,
id: 1,
labelText: 'Current page number',
};

export default PageSelector;
51 changes: 16 additions & 35 deletions packages/react/src/components/Pagination/experimental/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ import { IconButton } from '../../IconButton';
import { usePrefix } from '../../../internal/usePrefix';

function Pagination({
backwardText,
children,
className,
disabled,
forwardText,
id,
initialPage,
itemsPerPageText,
itemRangeText,
itemText,
backwardText = 'Previous page',
children = undefined,
className = null,
disabled = false,
forwardText = 'Next page',
id = 1,
initialPage = 1,
itemsPerPageText = 'Items per page:',
itemRangeText = (min, max, total) => `${min}${max} of ${total} items`,
itemText = (min, max) => `${min}${max} items`,
onChange,
pageRangeText,
pageSize,
pageSizes,
pageText,
pagesUnknown,
totalItems,
pageRangeText = (current, total) => `${current} of ${total} pages`,
pageSize = 10,
pageSizes = undefined,
pageText = (page) => `page ${page}`,
pagesUnknown = false,
totalItems = undefined,
...other
}) {
const [currentPage, setCurrentPage] = useState(initialPage);
Expand Down Expand Up @@ -270,23 +270,4 @@ Pagination.propTypes = {
totalItems: PropTypes.number,
};

Pagination.defaultProps = {
backwardText: 'Previous page',
className: null,
children: undefined,
disabled: false,
forwardText: 'Next page',
id: 1,
itemsPerPageText: 'Items per page:',
itemRangeText: (min, max, total) => `${min}${max} of ${total} items`,
itemText: (min, max) => `${min}${max} items`,
initialPage: 1,
pageRangeText: (current, total) => `${current} of ${total} pages`,
pageSize: 10,
pageSizes: undefined,
pageText: (page) => `page ${page}`,
pagesUnknown: false,
totalItems: undefined,
};

export default Pagination;
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function ProgressStep({
secondaryLabel,
disabled,
onClick,
translateWithId: t,
translateWithId: t = translateWithId,
...rest
}) {
const prefix = usePrefix();
Expand Down Expand Up @@ -292,8 +292,4 @@ ProgressStep.propTypes = {
translateWithId: PropTypes.func,
};

ProgressStep.defaultProps = {
translateWithId,
};

export { ProgressIndicator, ProgressStep };
10 changes: 3 additions & 7 deletions packages/react/src/components/RadioTile/RadioTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { keys, matches } from '../../internal/keyboard';
import { useFallbackId } from '../../internal/useId';
import { usePrefix } from '../../internal/usePrefix';
import deprecate from '../../prop-types/deprecate';
import { noopFn } from '../../internal/noopFn';

const RadioTile = React.forwardRef(function RadioTile(
{
Expand All @@ -25,8 +26,8 @@ const RadioTile = React.forwardRef(function RadioTile(
name,
value,
id,
onChange,
tabIndex,
onChange = noopFn,
tabIndex = 0,
...rest
},
ref
Expand Down Expand Up @@ -137,9 +138,4 @@ RadioTile.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
};

RadioTile.defaultProps = {
onChange: () => {},
tabIndex: 0,
};

export default RadioTile;
2 changes: 1 addition & 1 deletion packages/react/src/components/Search/Search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('Search', () => {
/>
);

expect(screen.getAllByRole('button')[0]).toHaveAttribute('tabIndex', '1');
expect(screen.getAllByRole('button')[0]).toHaveAttribute('tabIndex', '0');
expect(screen.getByRole('searchbox')).toHaveAttribute('tabIndex', '-1');
});

Expand Down
10 changes: 5 additions & 5 deletions packages/react/src/components/Search/Search.Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export interface SearchSkeletonProps
small?: boolean;
}

const SearchSkeleton = ({ small, className, ...rest }: SearchSkeletonProps) => {
const SearchSkeleton = ({
small = false,
className,
...rest
}: SearchSkeletonProps) => {
const prefix = usePrefix();
const searchClasses = cx(className, {
[`${prefix}--skeleton`]: true,
Expand Down Expand Up @@ -51,9 +55,5 @@ SearchSkeleton.propTypes = {
small: PropTypes.bool,
};

SearchSkeleton.defaultProps = {
small: false,
};

export default SearchSkeleton;
export { SearchSkeleton };
Loading

0 comments on commit a235977

Please sign in to comment.