diff --git a/src/addons/Confirm/Confirm.js b/src/addons/Confirm/Confirm.js index 89c7679521..57a360e6f4 100644 --- a/src/addons/Confirm/Confirm.js +++ b/src/addons/Confirm/Confirm.js @@ -10,9 +10,15 @@ import Modal from '../../modules/Modal' * A Confirm modal gives the user a choice to confirm or cancel an action. * @see Modal */ -const Confirm = React.forwardRef(function (partialProps, ref) { - const props = _.defaults(partialProps, getDefaultProps()) - const { cancelButton, confirmButton, content, header, open, size } = props +const Confirm = React.forwardRef(function (props, ref) { + const { + cancelButton = 'Cancel', + confirmButton = 'OK', + content = 'Are you sure?', + header, + open, + size = 'small', + } = props const rest = getUnhandledProps(Confirm, props) const handleCancel = (e) => { @@ -97,13 +103,4 @@ Confirm.propTypes = { size: PropTypes.oneOf(['mini', 'tiny', 'small', 'large', 'fullscreen']), } -function getDefaultProps() { - return { - cancelButton: 'Cancel', - confirmButton: 'OK', - content: 'Are you sure?', - size: 'small', - } -} - export default Confirm diff --git a/src/addons/Pagination/Pagination.js b/src/addons/Pagination/Pagination.js index 2a0550f4bb..05a8b39c4a 100644 --- a/src/addons/Pagination/Pagination.js +++ b/src/addons/Pagination/Pagination.js @@ -14,14 +14,30 @@ import PaginationItem from './PaginationItem' /** * A component to render a pagination. */ -const Pagination = React.forwardRef(function (partialProps, ref) { - const props = _.defaults(partialProps, getDefaultProps()) +const Pagination = React.forwardRef(function (props, ref) { const { - 'aria-label': ariaLabel, - boundaryRange, + 'aria-label': ariaLabel = 'Pagination Navigation', + boundaryRange = 1, disabled, - ellipsisItem, - siblingRange, + ellipsisItem = '...', + firstItem = { + 'aria-label': 'First item', + content: '«', + }, + lastItem = { + 'aria-label': 'Last item', + content: '»', + }, + nextItem = { + 'aria-label': 'Next item', + content: '⟩', + }, + pageItem = {}, + prevItem = { + 'aria-label': 'Previous item', + content: '⟨', + }, + siblingRange = 1, totalPages, } = props const [activePage, setActivePage] = useAutoControlledValue({ @@ -64,10 +80,18 @@ const Pagination = React.forwardRef(function (partialProps, ref) { }) const rest = getUnhandledProps(Pagination, props) + const paginationItemTypes = { + firstItem, + lastItem, + nextItem, + pageItem, + prevItem, + } + return ( {_.map(items, ({ active, type, value }) => - PaginationItem.create(props[type], { + PaginationItem.create(paginationItemTypes[type], { defaultProps: { content: value, disabled, @@ -130,32 +154,6 @@ Pagination.propTypes = { totalPages: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, } -function getDefaultProps() { - return { - 'aria-label': 'Pagination Navigation', - boundaryRange: 1, - ellipsisItem: '...', - firstItem: { - 'aria-label': 'First item', - content: '«', - }, - lastItem: { - 'aria-label': 'Last item', - content: '»', - }, - nextItem: { - 'aria-label': 'Next item', - content: '⟩', - }, - pageItem: {}, - prevItem: { - 'aria-label': 'Previous item', - content: '⟨', - }, - siblingRange: 1, - } -} - Pagination.Item = PaginationItem export default Pagination diff --git a/src/addons/Radio/Radio.js b/src/addons/Radio/Radio.js index 4199880908..957e1baaba 100644 --- a/src/addons/Radio/Radio.js +++ b/src/addons/Radio/Radio.js @@ -1,4 +1,3 @@ -import _ from 'lodash' import React from 'react' import { getUnhandledProps } from '../../lib' @@ -10,9 +9,8 @@ import Checkbox from '../../modules/Checkbox' * @see Checkbox * @see Form */ -const Radio = React.forwardRef(function (partialProps, ref) { - const props = _.defaults(partialProps, getDefaultProps()) - const { slider, toggle, type } = props +const Radio = React.forwardRef(function (props, ref) { + const { slider, toggle, type = 'radio' } = props const rest = getUnhandledProps(Radio, props) // const ElementType = getElementType(Radio, props) @@ -35,10 +33,4 @@ Radio.propTypes = { type: Checkbox.propTypes.type, } -function getDefaultProps() { - return { - type: 'radio', - } -} - export default Radio