diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5d61ac07bf..ad234b83ff 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -490,7 +490,7 @@ Label.propTypes = { /** A label can reduce its complexity. */ basic: PropTypes.bool, - /** Primary content of the label, same as text. */ + /** Primary content. */ children: PropTypes.node, /** Classes to add to the label className. */ diff --git a/src/addons/Portal/Portal.js b/src/addons/Portal/Portal.js index 29003f1d8f..c7299d4c77 100644 --- a/src/addons/Portal/Portal.js +++ b/src/addons/Portal/Portal.js @@ -22,10 +22,10 @@ const _meta = { */ class Portal extends Component { static propTypes = { - /** Primary content */ + /** Primary content. */ children: PropTypes.node.isRequired, - /** Classes to be added to the portal node element. */ + /** Additional classes. */ className: PropTypes.string, /** Controls whether or not the portal should close on a click outside. */ diff --git a/src/collections/Breadcrumb/Breadcrumb.js b/src/collections/Breadcrumb/Breadcrumb.js index 9d75e3c3ce..723cbde19e 100644 --- a/src/collections/Breadcrumb/Breadcrumb.js +++ b/src/collections/Breadcrumb/Breadcrumb.js @@ -55,13 +55,13 @@ Breadcrumb.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the Breadcrumb */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['sections', 'icon', 'divider']), PropTypes.node, ]), - /** Classes that will be added to the Breadcrumb className. */ + /** Additional classes. */ className: PropTypes.string, /** For use with the sections prop. Primary content of the Breadcrumb.Divider. */ diff --git a/src/collections/Breadcrumb/BreadcrumbDivider.js b/src/collections/Breadcrumb/BreadcrumbDivider.js index cbdc0439c5..ded645970c 100644 --- a/src/collections/Breadcrumb/BreadcrumbDivider.js +++ b/src/collections/Breadcrumb/BreadcrumbDivider.js @@ -33,13 +33,13 @@ BreadcrumbDivider.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the Breadcrumb.Divider. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['icon']), PropTypes.node, ]), - /** Classes that will be added to the BreadcrumbDivider className. */ + /** Additional classes. */ className: PropTypes.string, /** Render as an `Icon` component with `divider` class instead of a `div`. */ diff --git a/src/collections/Breadcrumb/BreadcrumbSection.js b/src/collections/Breadcrumb/BreadcrumbSection.js index 98d0c2d9cb..b2edca6132 100644 --- a/src/collections/Breadcrumb/BreadcrumbSection.js +++ b/src/collections/Breadcrumb/BreadcrumbSection.js @@ -48,10 +48,10 @@ BreadcrumbSection.propTypes = { /** Style as the currently active section. */ active: PropTypes.bool, - /** Primary content of the Breadcrumb.Section. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(BreadcrumbSection), - /** Classes that will be added to the BreadcrumbSection className. */ + /** Additional classes. */ className: PropTypes.string, /** Render as an `a` tag instead of a `div`. */ diff --git a/src/collections/Form/Form.js b/src/collections/Form/Form.js index fe101eb684..5d4500a884 100644 --- a/src/collections/Form/Form.js +++ b/src/collections/Form/Form.js @@ -223,10 +223,10 @@ Form.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Form), - /** Additional classes */ + /** Additional classes. */ className: PropTypes.string, /** Automatically show a loading indicator */ diff --git a/src/collections/Form/FormField.js b/src/collections/Form/FormField.js index 6b2e2ae11d..0bd37238c9 100644 --- a/src/collections/Form/FormField.js +++ b/src/collections/Form/FormField.js @@ -131,10 +131,10 @@ FormField.propTypes = { PropTypes.oneOf(FormField._meta.props.control), ]), - /** Primary content */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(FormField), - /** Additional classes to add */ + /** Additional classes. */ className: PropTypes.string, /** Individual fields may be disabled */ diff --git a/src/collections/Form/FormGroup.js b/src/collections/Form/FormGroup.js index 9e061ed10f..ad6a084e15 100644 --- a/src/collections/Form/FormGroup.js +++ b/src/collections/Form/FormGroup.js @@ -43,10 +43,10 @@ FormGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content. Intended to be Form Fields. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(FormGroup), - /** Additional classes */ + /** Additional classes. */ className: PropTypes.string, /** Fields can show related choices */ diff --git a/src/collections/Grid/Grid.js b/src/collections/Grid/Grid.js index 224c73425f..d920bfc278 100644 --- a/src/collections/Grid/Grid.js +++ b/src/collections/Grid/Grid.js @@ -77,10 +77,10 @@ Grid.propTypes = { /** A grid can have its columns centered. */ centered: PropTypes.bool, - /** Primary content of the Grid. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Grid), - /** Classes that will be added to the Grid className. */ + /** Additional classes. */ className: PropTypes.string, /** Represents column count per row in Grid. */ diff --git a/src/collections/Grid/GridColumn.js b/src/collections/Grid/GridColumn.js index 645b32b989..7ebc2388f4 100644 --- a/src/collections/Grid/GridColumn.js +++ b/src/collections/Grid/GridColumn.js @@ -64,10 +64,10 @@ GridColumn.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the GridColumn. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(GridColumn), - /** Classes that will be added to the GridColumn className. */ + /** Additional classes. */ className: PropTypes.string, /** A column can specify a width for a computer. */ diff --git a/src/collections/Grid/GridRow.js b/src/collections/Grid/GridRow.js index 3ae80bbd86..9b2a1cfeac 100644 --- a/src/collections/Grid/GridRow.js +++ b/src/collections/Grid/GridRow.js @@ -68,10 +68,10 @@ GridRow.propTypes = { /** A row can have its columns centered. */ centered: PropTypes.bool, - /** Primary content of the GridRow. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(GridRow), - /** Classes that will be added to the GridRow className. */ + /** Additional classes. */ className: PropTypes.string, /** A grid row can be colored. */ diff --git a/src/collections/Menu/Menu.js b/src/collections/Menu/Menu.js index 11d8216906..fa45178a3b 100644 --- a/src/collections/Menu/Menu.js +++ b/src/collections/Menu/Menu.js @@ -54,10 +54,10 @@ class Menu extends Component { /** A menu item or menu can have no borders. */ borderless: PropTypes.bool, - /** Primary content of the Menu. Mutually exclusive with items. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Menu), - /** Classes that will be added to the Menu className. */ + /** Additional classes. */ className: PropTypes.string, /** Additional colors can be specified. */ diff --git a/src/collections/Menu/MenuHeader.js b/src/collections/Menu/MenuHeader.js index f14e7bfb37..33c1f74229 100644 --- a/src/collections/Menu/MenuHeader.js +++ b/src/collections/Menu/MenuHeader.js @@ -27,17 +27,14 @@ MenuHeader.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(MenuHeader), - /** Additional classes */ + /** Additional classes. */ className: PropTypes.string, - /** Shorthand for primary content */ - content: PropTypes.oneOfType([ - PropTypes.number, - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default MenuHeader diff --git a/src/collections/Menu/MenuItem.js b/src/collections/Menu/MenuItem.js index ad4766dcef..37c232275a 100644 --- a/src/collections/Menu/MenuItem.js +++ b/src/collections/Menu/MenuItem.js @@ -66,23 +66,17 @@ MenuItem.propTypes = { /** A menu item can be active. */ active: PropTypes.bool, - /** Primary content of the MenuItem. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(MenuItem), - /** Classes that will be added to the MenuItem className. */ + /** Additional classes. */ className: PropTypes.string, /** Additional colors can be specified. */ color: PropTypes.oneOf(MenuItem._meta.props.color), - /** Shorthand for primary content of the MenuItem. Mutually exclusive with the children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, /** A menu item or menu can remove element padding, vertically or horizontally. */ fitted: PropTypes.oneOfType([ diff --git a/src/collections/Menu/MenuMenu.js b/src/collections/Menu/MenuMenu.js index 8107c43b22..7b452ed21f 100644 --- a/src/collections/Menu/MenuMenu.js +++ b/src/collections/Menu/MenuMenu.js @@ -30,10 +30,10 @@ MenuMenu.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the MenuMenu. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(MenuMenu), - /** Classes that will be added to the MenuMenu className. */ + /** Additional classes. */ className: PropTypes.string, /** A sub menu can take right position. */ diff --git a/src/collections/Message/Message.js b/src/collections/Message/Message.js index cbb3fb2a90..376d01909a 100644 --- a/src/collections/Message/Message.js +++ b/src/collections/Message/Message.js @@ -109,7 +109,7 @@ Message.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the message. */ + /** Primary content. */ children: customPropTypes.every([ PropTypes.node, customPropTypes.disallow(['header', 'content']), diff --git a/src/collections/Message/MessageContent.js b/src/collections/Message/MessageContent.js index 577f7021ac..dd49c9ea6d 100644 --- a/src/collections/Message/MessageContent.js +++ b/src/collections/Message/MessageContent.js @@ -28,7 +28,7 @@ MessageContent.propTypes = { as: customPropTypes.as, /** Primary content. */ - children: PropTypes.node, + children: customPropTypes.children(MessageContent), /** Additional classes. */ className: PropTypes.node, diff --git a/src/collections/Message/MessageHeader.js b/src/collections/Message/MessageHeader.js index 34e4c22945..ad7c35f699 100644 --- a/src/collections/Message/MessageHeader.js +++ b/src/collections/Message/MessageHeader.js @@ -28,7 +28,7 @@ MessageHeader.propTypes = { as: customPropTypes.as, /** Primary content. */ - children: PropTypes.node, + children: customPropTypes.children(MessageHeader), /** Additional classes. */ className: PropTypes.node, diff --git a/src/collections/Message/MessageItem.js b/src/collections/Message/MessageItem.js index cc066a85cc..7a29568220 100644 --- a/src/collections/Message/MessageItem.js +++ b/src/collections/Message/MessageItem.js @@ -28,7 +28,7 @@ MessageItem.propTypes = { as: customPropTypes.as, /** Primary content. */ - children: PropTypes.node, + children: customPropTypes.children(MessageItem), /** Additional classes. */ className: PropTypes.node, diff --git a/src/collections/Message/MessageList.js b/src/collections/Message/MessageList.js index 98f6c163ea..905eeaa9e4 100644 --- a/src/collections/Message/MessageList.js +++ b/src/collections/Message/MessageList.js @@ -32,7 +32,7 @@ MessageList.propTypes = { as: customPropTypes.as, /** Primary content. */ - children: PropTypes.node, + children: customPropTypes.children(MessageList), /** Additional classes. */ className: PropTypes.node, diff --git a/src/collections/Table/Table.js b/src/collections/Table/Table.js index 0e51652f94..79b9f1cbc5 100644 --- a/src/collections/Table/Table.js +++ b/src/collections/Table/Table.js @@ -83,7 +83,7 @@ function Table(props) { return ( {headerRow && {TableRow.create(headerRow, { cellAs: 'th' })}} - {{_.map(tableData, (data, index) => TableRow.create(renderBodyRow(data, index)))}} + {_.map(tableData, (data, index) => TableRow.create(renderBodyRow(data, index)))} {footerRow && {TableRow.create(footerRow)}} ) @@ -126,13 +126,10 @@ Table.propTypes = { /** A table may be divided each row into separate cells. */ celled: PropTypes.bool, - /** Primary content of the Table. */ - children: customPropTypes.every([ - customPropTypes.disallow(['headerRow', 'renderBodyRow', 'footerRow', 'tableData']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(Table), - /** Classes that will be added to the Table className. */ + /** Additional classes. */ className: PropTypes.string, /** A table can be collapsing, taking up only as much space as its rows. */ @@ -159,16 +156,10 @@ Table.propTypes = { fixed: PropTypes.bool, /** Shorthand for a TableRow to be placed within Table.Footer. */ - footerRow: PropTypes.oneOfType([ - PropTypes.array, - PropTypes.element, - ]), + footerRow: customPropTypes.collectionShorthand, /** Shorthand for a TableRow to be placed within Table.Header. */ - headerRow: PropTypes.oneOfType([ - PropTypes.array, - PropTypes.element, - ]), + headerRow: customPropTypes.collectionShorthand, /** A table's colors can be inverted. */ inverted: PropTypes.bool, @@ -184,6 +175,7 @@ Table.propTypes = { * to be placed within Table.Body. */ renderBodyRow: customPropTypes.every([ + customPropTypes.disallow(['children']), customPropTypes.demand(['tableData']), PropTypes.func, ]), @@ -208,6 +200,7 @@ Table.propTypes = { /** Data to be passed to the renderBodyRow function. */ tableData: customPropTypes.every([ + customPropTypes.disallow(['children']), customPropTypes.demand(['renderBodyRow']), PropTypes.array, ]), diff --git a/src/collections/Table/TableBody.js b/src/collections/Table/TableBody.js index ef31323693..3a61a3b427 100644 --- a/src/collections/Table/TableBody.js +++ b/src/collections/Table/TableBody.js @@ -31,10 +31,10 @@ TableBody.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the TableBody. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(TableBody), - /** Classes that will be added to the TableBody className. */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/collections/Table/TableCell.js b/src/collections/Table/TableCell.js index 3b0948d54d..c1a62ad39b 100644 --- a/src/collections/Table/TableCell.js +++ b/src/collections/Table/TableCell.js @@ -85,23 +85,17 @@ TableCell.propTypes = { /** A cell can be active or selected by a user. */ active: PropTypes.bool, - /** Primary content of the TableCell. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content', 'icon']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(TableCell), - /** Classes that will be added to the TableCell className. */ + /** Additional classes. */ className: PropTypes.string, /** A cell can be collapsing so that it only uses as much space as required. */ collapsing: PropTypes.bool, - /** Shorthand for primary content of the TableCell. Mutually exclusive with the children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, /** A cell can be disabled. */ disabled: PropTypes.bool, @@ -110,14 +104,7 @@ TableCell.propTypes = { error: PropTypes.bool, /** Add an Icon by name, props object, or pass an */ - icon: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.oneOfType([ - PropTypes.number, - PropTypes.string, - PropTypes.element, - ]), - ]), + icon: customPropTypes.itemShorthand, /** A cell may let a user know whether a value is bad. */ negative: PropTypes.bool, diff --git a/src/collections/Table/TableHeader.js b/src/collections/Table/TableHeader.js index 4b8354967a..cfa0f28e02 100644 --- a/src/collections/Table/TableHeader.js +++ b/src/collections/Table/TableHeader.js @@ -35,10 +35,10 @@ TableHeader.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the TableHeader. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(TableHeader), - /** Classes that will be added to the TableHeader className. */ + /** Additional classes. */ className: PropTypes.string, /** A definition table can have a full width header or footer, filling in the gap left by the first column. */ diff --git a/src/collections/Table/TableRow.js b/src/collections/Table/TableRow.js index 38957d34c2..22bf4df239 100644 --- a/src/collections/Table/TableRow.js +++ b/src/collections/Table/TableRow.js @@ -82,23 +82,12 @@ TableRow.propTypes = { cellAs: customPropTypes.as, /** Shorthand array of props for TableCell. Mutually exclusive with children. */ - cells: customPropTypes.every([ - customPropTypes.disallow(['children']), - // Array of shorthands for TableCell - PropTypes.arrayOf(PropTypes.oneOfType([ - PropTypes.string, - PropTypes.element, - PropTypes.object, - ])), - ]), - - /** Primary content of the TableRow. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content', 'icon']), - PropTypes.node, - ]), - - /** Classes that will be added to the TableRow className. */ + cells: customPropTypes.arrayOfShorthand, + + /** Primary content. */ + children: customPropTypes.children(TableRow), + + /** Additional classes. */ className: PropTypes.string, /** A row can be disabled. */ diff --git a/src/elements/Button/Button.js b/src/elements/Button/Button.js index 265ac8a3db..2d3964349c 100644 --- a/src/elements/Button/Button.js +++ b/src/elements/Button/Button.js @@ -159,7 +159,7 @@ Button.propTypes = { /** A basic button is less pronounced */ basic: PropTypes.bool, - /** Primary content of the button */ + /** Primary content. */ children: customPropTypes.every([ PropTypes.node, customPropTypes.disallow(['label']), @@ -178,14 +178,11 @@ Button.propTypes = { /** A button can be circular */ circular: PropTypes.bool, - /** Classes to add to the button className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content. Mutually exclusive with children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, /** A button can have different colors */ color: PropTypes.oneOf(Button._meta.props.color), diff --git a/src/elements/Button/ButtonContent.js b/src/elements/Button/ButtonContent.js index bd2c077578..ab12fd0c6e 100644 --- a/src/elements/Button/ButtonContent.js +++ b/src/elements/Button/ButtonContent.js @@ -36,17 +36,17 @@ ButtonContent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Initially visible, hidden on hover */ - visible: PropTypes.bool, + /** Additional classes. */ + className: PropTypes.string, + + /** Primary content. */ + children: customPropTypes.children(ButtonContent), /** Initially hidden, visible on hover */ hidden: PropTypes.bool, - /** Additional classes */ - className: PropTypes.string, - - /** Primary content, intended to the Button children */ - children: PropTypes.any, + /** Initially visible, hidden on hover */ + visible: PropTypes.bool, } export default ButtonContent diff --git a/src/elements/Button/ButtonGroup.js b/src/elements/Button/ButtonGroup.js index ea5e129c1a..ff8bbb4847 100644 --- a/src/elements/Button/ButtonGroup.js +++ b/src/elements/Button/ButtonGroup.js @@ -60,11 +60,11 @@ ButtonGroup.propTypes = { /** Groups can be less pronounced */ basic: PropTypes.bool, - /** Additional classes */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content, intended to be Button elements */ - children: PropTypes.any, + /** Primary content. */ + children: customPropTypes.children(ButtonGroup), /** Groups can have a shared color */ color: PropTypes.oneOf(ButtonGroup._meta.props.color), diff --git a/src/elements/Button/ButtonOr.js b/src/elements/Button/ButtonOr.js index 2a44f16c07..e3611d8b0d 100644 --- a/src/elements/Button/ButtonOr.js +++ b/src/elements/Button/ButtonOr.js @@ -30,7 +30,7 @@ ButtonOr.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Additional classes */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/elements/Container/Container.js b/src/elements/Container/Container.js index 4d4e94f539..b632b5eb17 100644 --- a/src/elements/Container/Container.js +++ b/src/elements/Container/Container.js @@ -41,10 +41,10 @@ Container.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the Container */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Container), - /** Classes to add to the container className. */ + /** Additional classes. */ className: PropTypes.string, /** Reduce maximum width to more naturally accommodate text */ diff --git a/src/elements/Divider/Divider.js b/src/elements/Divider/Divider.js index 41d155bd24..230fd6ed56 100644 --- a/src/elements/Divider/Divider.js +++ b/src/elements/Divider/Divider.js @@ -45,10 +45,10 @@ Divider.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the Divider */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Divider), - /** Classes to add to the divider className. */ + /** Additional classes. */ className: PropTypes.string, /** Divider can segment content horizontally */ diff --git a/src/elements/Flag/Flag.js b/src/elements/Flag/Flag.js index 38e3482816..2256812542 100644 --- a/src/elements/Flag/Flag.js +++ b/src/elements/Flag/Flag.js @@ -73,7 +73,7 @@ Flag.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Classes that will be added to the Flag className. */ + /** Additional classes. */ className: PropTypes.string, /** Flag name, can use the two digit country code, the full name, or a common alias */ diff --git a/src/elements/Header/Header.js b/src/elements/Header/Header.js index 04861a5359..16b153dcdb 100644 --- a/src/elements/Header/Header.js +++ b/src/elements/Header/Header.js @@ -90,11 +90,11 @@ Header.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Additional classes */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Header), /** Primary content. Mutually exclusive with children. */ content: customPropTypes.every([ diff --git a/src/elements/Header/HeaderContent.js b/src/elements/Header/HeaderContent.js index 1cb2baeab3..8e0b1cb4b5 100644 --- a/src/elements/Header/HeaderContent.js +++ b/src/elements/Header/HeaderContent.js @@ -30,10 +30,10 @@ HeaderContent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(HeaderContent), - /** Classes that will be added to the HeaderContent className */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/elements/Header/HeaderSubheader.js b/src/elements/Header/HeaderSubheader.js index 9a135f183c..77ee2b85af 100644 --- a/src/elements/Header/HeaderSubheader.js +++ b/src/elements/Header/HeaderSubheader.js @@ -27,20 +27,14 @@ HeaderSubheader.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the HeaderSubheader. Mutually exclusive with content */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(HeaderSubheader), - /** Classes to add to the subheader className. */ + /** Additional classes. */ className: PropTypes.string, - /** Shorthand for primary content. Mutually exclusive with children */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default HeaderSubheader diff --git a/src/elements/Icon/Icon.js b/src/elements/Icon/Icon.js index e37f658dc6..d24c520f6a 100644 --- a/src/elements/Icon/Icon.js +++ b/src/elements/Icon/Icon.js @@ -69,7 +69,7 @@ Icon.propTypes = { /** Formatted to appear bordered */ bordered: PropTypes.bool, - /** Class names for custom styling. */ + /** Additional classes. */ className: PropTypes.string, /** Icon can formatted to appear circular */ diff --git a/src/elements/Icon/IconGroup.js b/src/elements/Icon/IconGroup.js index 10582e259f..67a27400d8 100644 --- a/src/elements/Icon/IconGroup.js +++ b/src/elements/Icon/IconGroup.js @@ -41,11 +41,11 @@ IconGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Class names for custom styling. */ + /** Additional classes. */ className: PropTypes.string, - /** Icon children for the Icon group */ - children: PropTypes.any, + /** Primary content. */ + children: customPropTypes.children(IconGroup), /** Size of the icon group. */ size: PropTypes.oneOf(IconGroup._meta.props.size), diff --git a/src/elements/Image/Image.js b/src/elements/Image/Image.js index aa20b79a19..c0ce4a3f01 100644 --- a/src/elements/Image/Image.js +++ b/src/elements/Image/Image.js @@ -115,7 +115,7 @@ Image.propTypes = { /** An image can appear centered in a content block */ centered: PropTypes.bool, - /** Class names for custom styling. */ + /** Additional classes. */ className: PropTypes.string, /** An image can show that it is disabled and cannot be selected */ diff --git a/src/elements/Image/ImageGroup.js b/src/elements/Image/ImageGroup.js index 35112209b3..2f31e79dd2 100644 --- a/src/elements/Image/ImageGroup.js +++ b/src/elements/Image/ImageGroup.js @@ -34,10 +34,10 @@ ImageGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Class names for custom styling. */ - children: PropTypes.any, + /** Primary content. */ + children: customPropTypes.children(ImageGroup), - /** Class names for custom styling. */ + /** Additional classes. */ className: PropTypes.string, /** A group of images can be formatted to have the same size. */ diff --git a/src/elements/Input/Input.js b/src/elements/Input/Input.js index 5ca8120ff4..ef5176cb4e 100644 --- a/src/elements/Input/Input.js +++ b/src/elements/Input/Input.js @@ -158,7 +158,7 @@ Input.propTypes = { /** An action can appear along side an Input on the left or right */ actionPosition: PropTypes.oneOf(Input._meta.props.actionPosition), - /** Primary content. Used when there are multiple Labels or multiple Actions. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['input', 'label']), customPropTypes.givenProps( diff --git a/src/elements/Label/Label.js b/src/elements/Label/Label.js index 654c54e46d..88d9514f08 100644 --- a/src/elements/Label/Label.js +++ b/src/elements/Label/Label.js @@ -115,7 +115,7 @@ Label.propTypes = { /** A label can reduce its complexity. */ basic: PropTypes.bool, - /** Primary content of the label, same as content. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['content', 'detail', 'icon']), PropTypes.node, @@ -124,20 +124,14 @@ Label.propTypes = { /** A label can be circular. */ circular: PropTypes.bool, - /** Classes to add to the label className. */ + /** Additional classes. */ className: PropTypes.string, /** Color of the label. */ color: PropTypes.oneOf(Label._meta.props.color), - /** Shorthand for primary content of the label. Mutually exclusive with children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.oneOfType([ - PropTypes.number, - PropTypes.string, - ]), - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, /** A label can position itself in the corner of an element. */ corner: PropTypes.oneOfType([ diff --git a/src/elements/Label/LabelDetail.js b/src/elements/Label/LabelDetail.js index fe2df6fc31..efdb4307df 100644 --- a/src/elements/Label/LabelDetail.js +++ b/src/elements/Label/LabelDetail.js @@ -27,20 +27,14 @@ LabelDetail.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the detail. Mutually exclusive with content. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(LabelDetail), - /** Classes to add to the label className. */ + /** Additional classes. */ className: PropTypes.string, - /** Shorthand for primary content of the detail. Mutually exclusive with children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default LabelDetail diff --git a/src/elements/Label/LabelGroup.js b/src/elements/Label/LabelGroup.js index 33ca47b33a..a563c4184e 100644 --- a/src/elements/Label/LabelGroup.js +++ b/src/elements/Label/LabelGroup.js @@ -49,16 +49,13 @@ LabelGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the label group. Mutually exclusive with content. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(LabelGroup), /** Labels can share shapes. */ circular: PropTypes.bool, - /** Classes to add to the label group className. */ + /** Additional classes. */ className: PropTypes.string, /** Label group can share colors together. */ diff --git a/src/elements/List/List.js b/src/elements/List/List.js index 5d39b825c4..19ae46d0e2 100644 --- a/src/elements/List/List.js +++ b/src/elements/List/List.js @@ -89,10 +89,10 @@ List.propTypes = { /** A list can divide its items into cells. */ celled: PropTypes.bool, - /** Primary content of the List. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(List), - /** Classes to add to the List className. */ + /** Additional classes. */ className: PropTypes.string, /** A list can show divisions between content. */ diff --git a/src/elements/List/ListContent.js b/src/elements/List/ListContent.js index 7bcd8221b4..0d827d1c21 100644 --- a/src/elements/List/ListContent.js +++ b/src/elements/List/ListContent.js @@ -45,10 +45,10 @@ ListContent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ListContent. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(ListContent), - /** Classes to add to the ListContent className. */ + /** Additional classes. */ className: PropTypes.string, /** An list content can be floated left or right. */ diff --git a/src/elements/List/ListDescription.js b/src/elements/List/ListDescription.js index 2a61258b8b..c579a7a02f 100644 --- a/src/elements/List/ListDescription.js +++ b/src/elements/List/ListDescription.js @@ -27,10 +27,10 @@ ListDescription.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ListDescription. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(ListDescription), - /** Classes to add to the ListDescription className. */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/elements/List/ListHeader.js b/src/elements/List/ListHeader.js index 2d783aa770..85bd73a081 100644 --- a/src/elements/List/ListHeader.js +++ b/src/elements/List/ListHeader.js @@ -27,10 +27,10 @@ ListHeader.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ListHeader. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(ListHeader), - /** Classes to add to the ListHeader className. */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/elements/List/ListIcon.js b/src/elements/List/ListIcon.js index 684d6bca45..4a7528cf6e 100644 --- a/src/elements/List/ListIcon.js +++ b/src/elements/List/ListIcon.js @@ -30,7 +30,7 @@ ListIcon._meta = { } ListIcon.propTypes = { - /** Classes to add to the ListIcon className. */ + /** Additional classes. */ className: PropTypes.string, /** An element inside a list can be vertically aligned. */ diff --git a/src/elements/List/ListItem.js b/src/elements/List/ListItem.js index 17c55d5a0d..9f372b2aa8 100644 --- a/src/elements/List/ListItem.js +++ b/src/elements/List/ListItem.js @@ -44,10 +44,10 @@ ListItem.propTypes = { /** A list item can active. */ active: PropTypes.bool, - /** Primary content of the ListItem. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(ListItem), - /** Classes to add to the ListItem className. */ + /** Additional classes. */ className: PropTypes.string, /** A list item can disabled. */ diff --git a/src/elements/List/ListList.js b/src/elements/List/ListList.js index 22646f37d0..7e7e05d6c7 100644 --- a/src/elements/List/ListList.js +++ b/src/elements/List/ListList.js @@ -32,10 +32,10 @@ ListList.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ListList. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(ListList), - /** Classes to add to the ListList className. */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/elements/Loader/Loader.js b/src/elements/Loader/Loader.js index f58ae3af91..a978ec8d98 100644 --- a/src/elements/Loader/Loader.js +++ b/src/elements/Loader/Loader.js @@ -47,10 +47,10 @@ Loader.propTypes = { /** A loader can be active or visible. */ active: PropTypes.bool, - /** Classes that will be added to the Loader className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the Loader. Mutually exclusive with the text. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['text']), PropTypes.node, diff --git a/src/elements/Rail/Rail.js b/src/elements/Rail/Rail.js index 1cc8872039..5078ba9457 100644 --- a/src/elements/Rail/Rail.js +++ b/src/elements/Rail/Rail.js @@ -51,7 +51,7 @@ Rail.propTypes = { /** A rail can appear attached to the main viewport. */ attached: PropTypes.bool, - /** Classes that will be added to the Rail className. */ + /** Additional classes. */ className: PropTypes.string, /** A rail can appear closer to the main viewport. */ @@ -60,8 +60,8 @@ Rail.propTypes = { PropTypes.oneOf(Rail._meta.props.close), ]), - /** Primary content of the Rail. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Rail), /** A rail can create a division between itself and a container. */ dividing: PropTypes.bool, diff --git a/src/elements/Segment/Segment.js b/src/elements/Segment/Segment.js index ddab3bcf2c..074b40400d 100644 --- a/src/elements/Segment/Segment.js +++ b/src/elements/Segment/Segment.js @@ -101,13 +101,13 @@ Segment.propTypes = { /** A basic segment has no special formatting */ basic: PropTypes.bool, - /** Segment tag body content. */ - children: PropTypes.any, + /** Primary content. */ + children: customPropTypes.children(Segment), /** A segment can be circular */ circular: PropTypes.bool, - /** Class names for custom styling. */ + /** Additional classes. */ className: PropTypes.string, /** A segment can clear floated content */ diff --git a/src/elements/Segment/SegmentGroup.js b/src/elements/Segment/SegmentGroup.js index fad50d9504..5677cbe0e5 100644 --- a/src/elements/Segment/SegmentGroup.js +++ b/src/elements/Segment/SegmentGroup.js @@ -46,11 +46,11 @@ SegmentGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Class names for custom styling. */ + /** Additional classes. */ className: PropTypes.string, - /** Nested segments for this Segment group */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(SegmentGroup), /** A segment may take up only as much space as is necessary */ compact: PropTypes.bool, diff --git a/src/elements/Step/Step.js b/src/elements/Step/Step.js index 7ccc89ce28..089dbe6b46 100644 --- a/src/elements/Step/Step.js +++ b/src/elements/Step/Step.js @@ -64,10 +64,10 @@ Step.propTypes = { /** A step can be highlighted as active. */ active: PropTypes.bool, - /** Classes that will be added to the Step className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the Step. Mutually exclusive with description and title props. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['description', 'title']), PropTypes.node, diff --git a/src/elements/Step/StepContent.js b/src/elements/Step/StepContent.js index 6c3b2f0997..9789cf7063 100644 --- a/src/elements/Step/StepContent.js +++ b/src/elements/Step/StepContent.js @@ -39,10 +39,10 @@ StepContent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Classes that will be added to the StepContent className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of StepContent. Mutually exclusive with description and title props. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['description', 'title']), PropTypes.node, diff --git a/src/elements/Step/StepDescription.js b/src/elements/Step/StepDescription.js index a7db8ffae8..c1bfaeb739 100644 --- a/src/elements/Step/StepDescription.js +++ b/src/elements/Step/StepDescription.js @@ -27,10 +27,10 @@ StepDescription.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Classes that will be added to the StepDescription className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the StepDescription. Mutually exclusive with description prop. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['description']), PropTypes.node, diff --git a/src/elements/Step/StepGroup.js b/src/elements/Step/StepGroup.js index 8fadd91fb8..ca5dd5bf53 100644 --- a/src/elements/Step/StepGroup.js +++ b/src/elements/Step/StepGroup.js @@ -50,10 +50,10 @@ StepGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Classes that will be added to the StepGroup className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the StepGroup. Mutually exclusive with items prop. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['items']), PropTypes.node, diff --git a/src/elements/Step/StepTitle.js b/src/elements/Step/StepTitle.js index 05143f4703..898ce9dcc9 100644 --- a/src/elements/Step/StepTitle.js +++ b/src/elements/Step/StepTitle.js @@ -27,10 +27,10 @@ StepTitle.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Classes that will be added to the StepTitle className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the StepTitle. Mutually exclusive with title prop. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['title']), PropTypes.node, diff --git a/src/lib/customPropTypes.js b/src/lib/customPropTypes.js index 70a388fee3..66969221d7 100644 --- a/src/lib/customPropTypes.js +++ b/src/lib/customPropTypes.js @@ -180,6 +180,71 @@ export const demand = (requiredProps) => { } } +/** + * Node shorthand ensures a prop is a node and that it's not valid with children. + */ +export const nodeShorthand = (...args) => every([ + disallow(['children']), + PropTypes.node, +])(...args) + +/** + * Item shorthand is a description of a component that can be a literal, + * a props object, or an element. + */ +export const itemShorthand = (...args) => every([ + disallow(['children']), + PropTypes.oneOfType([ + PropTypes.element, + PropTypes.number, + PropTypes.object, + PropTypes.string, + ]), +])(...args) + +/** + * ArrayOf shorthand ensures a prop is an array of itemShorthand + */ +export const arrayOfShorthand = (...args) => every([ + disallow(['children']), + PropTypes.arrayOf(itemShorthand), +])(...args) + +/** + * Collection shorthand is a description of a component that can be a literal, + * a props object, or an element. + */ +export const collectionShorthand = (...args) => every([ + disallow(['children']), + PropTypes.oneOfType([ + arrayOfShorthand, + PropTypes.element, + PropTypes.object, + ]), +])(...args) + +const shorthandPropTypes = [ + arrayOfShorthand, + collectionShorthand, + itemShorthand, + nodeShorthand, +] + +/** + * Ensure a prop conforms to children prop standards. + */ +export const children = (Component) => (...args) => { + const disallowedProps = _.flow( + _.pickBy(checker => _.some(shorthandPropTypes, (propType) => propType === checker)), + _.keys, + )(Component.propTypes) + + return every([ + disallow(disallowedProps), + PropTypes.node, + ])(...args) +} + /** * Show a deprecated warning for component props with a help message and optional validator. * @param {string} help A help message to display with the deprecation warning. diff --git a/src/modules/Accordion/Accordion.js b/src/modules/Accordion/Accordion.js index 06b553a8dd..a99bec594b 100644 --- a/src/modules/Accordion/Accordion.js +++ b/src/modules/Accordion/Accordion.js @@ -29,13 +29,13 @@ export default class Accordion extends Component { /** Index of the currently active panel. */ activeIndex: PropTypes.number, - /** Accordion.Title and Accordion.Content components. Mutually exclusive with the panels prop. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['panels']), PropTypes.node, ]), - /** Classes to add to the Accordion className. */ + /** Additional classes. */ className: PropTypes.string, /** Initial activeIndex value. */ diff --git a/src/modules/Accordion/AccordionContent.js b/src/modules/Accordion/AccordionContent.js index b602de68f4..82ea3626a8 100644 --- a/src/modules/Accordion/AccordionContent.js +++ b/src/modules/Accordion/AccordionContent.js @@ -31,10 +31,10 @@ AccordionContent.propTypes = { /** Whether or not the content is visible. */ active: PropTypes.bool, - /** Primary content of the Content. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(AccordionContent), - /** Classes to add to the content className. */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/modules/Accordion/AccordionTitle.js b/src/modules/Accordion/AccordionTitle.js index afcb1fafea..e6506dc865 100644 --- a/src/modules/Accordion/AccordionTitle.js +++ b/src/modules/Accordion/AccordionTitle.js @@ -40,10 +40,10 @@ AccordionTitle.propTypes = { /** Whether or not the title is in the open state. */ active: PropTypes.bool, - /** Primary content of the Title. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(AccordionTitle), - /** Classes to add to the title className. */ + /** Additional classes. */ className: PropTypes.string, /** Called with (event, index) on title click. */ diff --git a/src/modules/Dropdown/Dropdown.js b/src/modules/Dropdown/Dropdown.js index 5fb97f269a..8222c5ce5d 100644 --- a/src/modules/Dropdown/Dropdown.js +++ b/src/modules/Dropdown/Dropdown.js @@ -66,7 +66,7 @@ export default class Dropdown extends Component { /** Initial value of open. */ defaultOpen: PropTypes.bool, - /** A Dropdown can contain a single child. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['options', 'selection']), customPropTypes.demand(['text']), @@ -170,7 +170,7 @@ export default class Dropdown extends Component { /** Format the Dropdown to appear as a button. */ button: PropTypes.bool, - /** Additional classes added to the root element. */ + /** Additional classes. */ className: PropTypes.string, /** Format the dropdown to only take up as much width as needed. */ diff --git a/src/modules/Dropdown/DropdownDivider.js b/src/modules/Dropdown/DropdownDivider.js index 0e0c612274..dd0505355f 100644 --- a/src/modules/Dropdown/DropdownDivider.js +++ b/src/modules/Dropdown/DropdownDivider.js @@ -27,7 +27,7 @@ DropdownDivider.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Additional classes */ + /** Additional classes. */ className: PropTypes.node, } diff --git a/src/modules/Dropdown/DropdownHeader.js b/src/modules/Dropdown/DropdownHeader.js index 7be373a1ce..ed1db16479 100644 --- a/src/modules/Dropdown/DropdownHeader.js +++ b/src/modules/Dropdown/DropdownHeader.js @@ -37,13 +37,13 @@ DropdownHeader.propTypes = { /** An element type to render as (string or function) */ as: customPropTypes.as, - /** Primary content of the header, same as content. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['content', 'icon']), PropTypes.node, ]), - /** Additional classes */ + /** Additional classes. */ className: PropTypes.node, /** Primary content of the header, same as children. */ diff --git a/src/modules/Dropdown/DropdownItem.js b/src/modules/Dropdown/DropdownItem.js index 363966287d..de1c62b4b8 100644 --- a/src/modules/Dropdown/DropdownItem.js +++ b/src/modules/Dropdown/DropdownItem.js @@ -71,7 +71,7 @@ DropdownItem.propTypes = { PropTypes.node, ]), - /** Additional className. */ + /** Additional classes. */ className: PropTypes.string, /** Additional text with less emphasis. */ diff --git a/src/modules/Dropdown/DropdownMenu.js b/src/modules/Dropdown/DropdownMenu.js index a3bdd1538f..0ce52d12cc 100644 --- a/src/modules/Dropdown/DropdownMenu.js +++ b/src/modules/Dropdown/DropdownMenu.js @@ -27,10 +27,10 @@ DropdownMenu.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Should be components. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(DropdownMenu), - /** Classes to add to the className. */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/modules/Modal/Modal.js b/src/modules/Modal/Modal.js index d73c46b6f8..48d52c5e45 100644 --- a/src/modules/Modal/Modal.js +++ b/src/modules/Modal/Modal.js @@ -38,10 +38,10 @@ class Modal extends Component { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the modal. Consider using ModalHeader, ModalContent or ModalActions here */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Modal), - /** Classes to add to the modal className */ + /** Additional classes. */ className: PropTypes.string, /** A modal can reduce its complexity */ diff --git a/src/modules/Modal/ModalActions.js b/src/modules/Modal/ModalActions.js index 8a694c6415..37924eaa74 100644 --- a/src/modules/Modal/ModalActions.js +++ b/src/modules/Modal/ModalActions.js @@ -27,10 +27,10 @@ ModalActions.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the modal actions */ - children: PropTypes.any, + /** Primary content. */ + children: customPropTypes.children(ModalActions), - /** Classes to add to the modal actions className */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/modules/Modal/ModalContent.js b/src/modules/Modal/ModalContent.js index 26e8ce27e2..113c597ac5 100644 --- a/src/modules/Modal/ModalContent.js +++ b/src/modules/Modal/ModalContent.js @@ -32,10 +32,10 @@ ModalContent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the modal content */ - children: PropTypes.any, + /** Primary content. */ + children: customPropTypes.children(ModalContent), - /** Classes to add to the modal content className */ + /** Additional classes. */ className: PropTypes.string, /** A modal can contain image content */ diff --git a/src/modules/Modal/ModalDescription.js b/src/modules/Modal/ModalDescription.js index f45f76dc5a..96ef23a895 100644 --- a/src/modules/Modal/ModalDescription.js +++ b/src/modules/Modal/ModalDescription.js @@ -27,10 +27,10 @@ ModalDescription.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content */ - children: PropTypes.any, + /** Primary content. */ + children: customPropTypes.children(ModalDescription), - /** Classes to add to the className */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/modules/Modal/ModalHeader.js b/src/modules/Modal/ModalHeader.js index 5b101bdd3b..66a55011dc 100644 --- a/src/modules/Modal/ModalHeader.js +++ b/src/modules/Modal/ModalHeader.js @@ -27,10 +27,10 @@ ModalHeader.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the modal header */ - children: PropTypes.any, + /** Primary content. */ + children: customPropTypes.children(ModalHeader), - /** Classes to add to the modal header className */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/modules/Progress/Progress.js b/src/modules/Progress/Progress.js index ccd2e9239c..6cf7927e09 100644 --- a/src/modules/Progress/Progress.js +++ b/src/modules/Progress/Progress.js @@ -100,10 +100,10 @@ Progress.propTypes = { /** A progress bar can have different colors. */ color: PropTypes.oneOf(Progress._meta.props.color), - /** Displayed as a label immediately below the progress bar. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Progress), - /** Additional className. */ + /** Additional classes. */ className: PropTypes.string, /** A progress bar be disabled. */ diff --git a/src/modules/Rating/Rating.js b/src/modules/Rating/Rating.js index f30b20e84b..1306266892 100644 --- a/src/modules/Rating/Rating.js +++ b/src/modules/Rating/Rating.js @@ -26,7 +26,7 @@ class Rating extends Component { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Additional className. */ + /** Additional classes. */ className: PropTypes.string, /** diff --git a/src/modules/Search/Search.js b/src/modules/Search/Search.js index 7f487ac4f1..cedcb04783 100644 --- a/src/modules/Search/Search.js +++ b/src/modules/Search/Search.js @@ -133,7 +133,7 @@ export default class Search extends Component { /** A search can display results from remote content ordered by categories. */ category: PropTypes.bool, - /** Additional classes added to the root element. */ + /** Additional classes. */ className: PropTypes.string, /** A search can have its results take up the width of its container. */ diff --git a/src/modules/Search/SearchCategory.js b/src/modules/Search/SearchCategory.js index 5b3447dbd0..e563780344 100644 --- a/src/modules/Search/SearchCategory.js +++ b/src/modules/Search/SearchCategory.js @@ -44,10 +44,10 @@ SearchCategory.propTypes = { /** The item currently selected by keyboard shortcut. */ active: PropTypes.bool, - /** Should be components. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(SearchCategory), - /** Classes to add to the className. */ + /** Additional classes. */ className: PropTypes.string, /** Display name. */ diff --git a/src/modules/Search/SearchResult.js b/src/modules/Search/SearchResult.js index aa6b2c4193..0e016141b3 100644 --- a/src/modules/Search/SearchResult.js +++ b/src/modules/Search/SearchResult.js @@ -71,7 +71,7 @@ SearchResult.propTypes = { /** The item currently selected by keyboard shortcut. */ active: PropTypes.bool, - /** Additional className. */ + /** Additional classes. */ className: PropTypes.string, /** Additional text with less emphasis. */ diff --git a/src/modules/Search/SearchResults.js b/src/modules/Search/SearchResults.js index f507b7cc89..bfbd32cc25 100644 --- a/src/modules/Search/SearchResults.js +++ b/src/modules/Search/SearchResults.js @@ -27,10 +27,10 @@ SearchResults.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Should be components. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(SearchResults), - /** Classes to add to the className. */ + /** Additional classes. */ className: PropTypes.string, } diff --git a/src/views/Card/Card.js b/src/views/Card/Card.js index e6e9bec902..6f54b10905 100644 --- a/src/views/Card/Card.js +++ b/src/views/Card/Card.js @@ -84,13 +84,13 @@ Card.propTypes = { /** A Card can center itself inside its container. */ centered: PropTypes.bool, - /** Primary content of the Card. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['description', 'header', 'image', 'meta']), PropTypes.node, ]), - /** Classes that will be added to the Card className. */ + /** Additional classes. */ className: PropTypes.string, /** A Card can be formatted to display different colors. */ diff --git a/src/views/Card/CardContent.js b/src/views/Card/CardContent.js index 2092985b7b..3f303acaf4 100644 --- a/src/views/Card/CardContent.js +++ b/src/views/Card/CardContent.js @@ -49,13 +49,13 @@ CardContent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the CardContent. Mutually exclusive with all shorthand props. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['description', 'header', 'meta']), PropTypes.node, ]), - /** Classes that will be added to the CardContent className */ + /** Additional classes. */ className: PropTypes.string, /** Shorthand prop for CardDescription. Mutually exclusive with children. */ diff --git a/src/views/Card/CardDescription.js b/src/views/Card/CardDescription.js index 1842d99df0..9769d84b98 100644 --- a/src/views/Card/CardDescription.js +++ b/src/views/Card/CardDescription.js @@ -30,23 +30,14 @@ CardDescription.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the CardDescription. Mutually exclusive with content. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(CardDescription), - /** Classes that will be added to the CardDescription className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the CardDescription. Mutually exclusive with children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - ]), - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default CardDescription diff --git a/src/views/Card/CardGroup.js b/src/views/Card/CardGroup.js index c821bd3dbd..5eb5ee09ae 100644 --- a/src/views/Card/CardGroup.js +++ b/src/views/Card/CardGroup.js @@ -48,13 +48,13 @@ CardGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** A group of Card components. Mutually exclusive with items. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['items']), PropTypes.node, ]), - /** Classes that will be added to the CardGroup className */ + /** Additional classes. */ className: PropTypes.string, /** A group of cards can double its column width for mobile */ diff --git a/src/views/Card/CardHeader.js b/src/views/Card/CardHeader.js index 43601f28ed..7e7d8349ce 100644 --- a/src/views/Card/CardHeader.js +++ b/src/views/Card/CardHeader.js @@ -30,20 +30,14 @@ CardHeader.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the CardHeader. Mutually exclusive with content. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(CardHeader), - /** Classes that will be added to the CardHeader className */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the CardHeader. Mutually exclusive with children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.node, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default CardHeader diff --git a/src/views/Card/CardMeta.js b/src/views/Card/CardMeta.js index 262b5bc014..993629c4c5 100644 --- a/src/views/Card/CardMeta.js +++ b/src/views/Card/CardMeta.js @@ -30,23 +30,14 @@ CardMeta.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the CardMeta. Mutually exclusive with content. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(CardMeta), - /** Classes that will be added to the CardMeta className */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the CardMeta. Mutually exclusive with children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - ]), - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default CardMeta diff --git a/src/views/Feed/Feed.js b/src/views/Feed/Feed.js index 8bb3e3c460..0330bafac5 100644 --- a/src/views/Feed/Feed.js +++ b/src/views/Feed/Feed.js @@ -59,13 +59,13 @@ Feed.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the Feed. Mutually exclusive with events. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['events']), PropTypes.node, ]), - /** Classes that will be added to the Feed className. */ + /** Additional classes. */ className: PropTypes.string, /** Array of props for FeedEvent. Mutually exclusive with children. */ diff --git a/src/views/Feed/FeedContent.js b/src/views/Feed/FeedContent.js index 6e051db084..2849fd6d79 100644 --- a/src/views/Feed/FeedContent.js +++ b/src/views/Feed/FeedContent.js @@ -45,7 +45,7 @@ FeedContent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedContent. Mutually exclusive with all shorthand props. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow([ 'date', @@ -57,7 +57,7 @@ FeedContent.propTypes = { PropTypes.node, ]), - /** Classes that will be added to the FeedContent className. */ + /** Additional classes. */ className: PropTypes.string, /** Shorthand for children. */ diff --git a/src/views/Feed/FeedDate.js b/src/views/Feed/FeedDate.js index 7f80d3c4bf..fdb05ca882 100644 --- a/src/views/Feed/FeedDate.js +++ b/src/views/Feed/FeedDate.js @@ -29,23 +29,14 @@ FeedDate.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedDate. Mutually exclusive with the content. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(FeedDate), - /** Classes that will be added to the FeedDate className. */ + /** Additional classes. */ className: PropTypes.string, - /** Shorthand for children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - ]), - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default FeedDate diff --git a/src/views/Feed/FeedEvent.js b/src/views/Feed/FeedEvent.js index 844c2db149..aa375fcb9b 100644 --- a/src/views/Feed/FeedEvent.js +++ b/src/views/Feed/FeedEvent.js @@ -40,7 +40,7 @@ FeedEvent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedEvent. Mutually exclusive with all shorthand props. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow([ 'date', @@ -54,7 +54,7 @@ FeedEvent.propTypes = { PropTypes.node, ]), - /** Classes that will be added to the FeedEvent className. */ + /** Additional classes. */ className: PropTypes.string, /** Shorthand for FeedContent. Mutually exclusive with children. */ diff --git a/src/views/Feed/FeedExtra.js b/src/views/Feed/FeedExtra.js index 9c3a556328..345ad95c86 100644 --- a/src/views/Feed/FeedExtra.js +++ b/src/views/Feed/FeedExtra.js @@ -50,8 +50,8 @@ FeedExtra.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedExtra. Mutually exclusive with content. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(FeedExtra), /** Shorthand for children. Mutually exclusive with children. */ content: customPropTypes.every([ @@ -59,7 +59,7 @@ FeedExtra.propTypes = { PropTypes.string, ]), - /** Classes that will be added to the FeedExtra className. */ + /** Additional classes. */ className: PropTypes.string, /** An event can contain additional information like a set of images. Mutually exclusive with children. */ diff --git a/src/views/Feed/FeedLabel.js b/src/views/Feed/FeedLabel.js index c858bd7972..a761235400 100644 --- a/src/views/Feed/FeedLabel.js +++ b/src/views/Feed/FeedLabel.js @@ -39,13 +39,13 @@ FeedLabel.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedLabel. Mutually exclusive with all shorthand props. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['content', 'icon', 'image']), PropTypes.node, ]), - /** Classes that will be added to the FeedLabel className. */ + /** Additional classes. */ className: PropTypes.string, /** Shorthand for children. Mutually exclusive with children. */ diff --git a/src/views/Feed/FeedLike.js b/src/views/Feed/FeedLike.js index f843466594..89ff6cea1f 100644 --- a/src/views/Feed/FeedLike.js +++ b/src/views/Feed/FeedLike.js @@ -41,13 +41,13 @@ FeedLike.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedLike. Mutually exclusive with content. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['content', 'icon']), PropTypes.node, ]), - /** Classes that will be added to the FeedLike className. */ + /** Additional classes. */ className: PropTypes.string, /** Shorthand for children. Mutually exclusive with children. */ diff --git a/src/views/Feed/FeedMeta.js b/src/views/Feed/FeedMeta.js index 4ac79c5240..a16e3a0a39 100644 --- a/src/views/Feed/FeedMeta.js +++ b/src/views/Feed/FeedMeta.js @@ -38,13 +38,13 @@ FeedMeta.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedMeta. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['content', 'like']), PropTypes.node, ]), - /** Classes that will be added to the FeedMeta className. */ + /** Additional classes. */ className: PropTypes.string, /** Shorthand for children. Mutually exclusive with children. */ diff --git a/src/views/Feed/FeedSummary.js b/src/views/Feed/FeedSummary.js index 36dc0de047..c5aa1519e1 100644 --- a/src/views/Feed/FeedSummary.js +++ b/src/views/Feed/FeedSummary.js @@ -40,13 +40,13 @@ FeedSummary.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedSummary. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['content', 'date', 'user']), PropTypes.node, ]), - /** Classes that will be added to the FeedSummary className. */ + /** Additional classes. */ className: PropTypes.string, /** Shorthand for children. Mutually exclusive with children. */ diff --git a/src/views/Feed/FeedUser.js b/src/views/Feed/FeedUser.js index bc49ff432e..10a71dc2af 100644 --- a/src/views/Feed/FeedUser.js +++ b/src/views/Feed/FeedUser.js @@ -27,23 +27,14 @@ FeedUser.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the FeedUser. Mutually exclusive with content. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(FeedUser), - /** Classes that will be added to the FeedUser className. */ + /** Additional classes. */ className: PropTypes.string, - /** Shorthand for children. Mutually exclusive with children. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - ]), - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } FeedUser.defaultProps = { diff --git a/src/views/Item/Item.js b/src/views/Item/Item.js index 3f01a89f43..f105f6ad19 100644 --- a/src/views/Item/Item.js +++ b/src/views/Item/Item.js @@ -61,10 +61,10 @@ Item.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the Item. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(Item), - /** Classes that will be added to the Item className. */ + /** Additional classes. */ className: PropTypes.string, /** Shorthand for ItemContent component. */ diff --git a/src/views/Item/ItemContent.js b/src/views/Item/ItemContent.js index 8e0e4402f6..adcdfbbca8 100644 --- a/src/views/Item/ItemContent.js +++ b/src/views/Item/ItemContent.js @@ -52,44 +52,26 @@ ItemContent.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ItemContent. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(ItemContent), - /** Classes that will be added to the ItemContent className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the ItemContent. Mutually exclusive with the children prop. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, - /** Shorthand for of the ItemDescription. Mutually exclusive with the children prop. */ - description: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for ItemDescription component. */ + description: customPropTypes.itemShorthand, - /** Shorthand for ItemExtra component. Mutually exclusive with the children prop. */ - extra: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for ItemExtra component. */ + extra: customPropTypes.itemShorthand, - /** Shorthand for ItemHeader component. Mutually exclusive with the children prop. */ - header: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for ItemHeader component. */ + header: customPropTypes.itemShorthand, - /** Shorthand for ItemMeta component. Mutually exclusive with the children prop. */ - meta: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for ItemMeta component. */ + meta: customPropTypes.itemShorthand, /** Content can specify its vertical alignment */ verticalAlign: PropTypes.oneOf(ItemContent._meta.props.verticalAlign), diff --git a/src/views/Item/ItemDescription.js b/src/views/Item/ItemDescription.js index 4d8396c355..3ff2eed504 100644 --- a/src/views/Item/ItemDescription.js +++ b/src/views/Item/ItemDescription.js @@ -30,20 +30,14 @@ ItemDescription.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ItemDescription. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(ItemDescription), - /** Classes that will be added to the ItemDescription className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the ItemDescription. Mutually exclusive with the children prop. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default ItemDescription diff --git a/src/views/Item/ItemExtra.js b/src/views/Item/ItemExtra.js index cf0b8db543..583134cd25 100644 --- a/src/views/Item/ItemExtra.js +++ b/src/views/Item/ItemExtra.js @@ -30,20 +30,14 @@ ItemExtra.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ItemExtra. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(ItemExtra), - /** Classes that will be added to the ItemExtra className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the ItemExtra. Mutually exclusive with the children prop. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default ItemExtra diff --git a/src/views/Item/ItemGroup.js b/src/views/Item/ItemGroup.js index 5cc89e5f34..21e97eec3d 100644 --- a/src/views/Item/ItemGroup.js +++ b/src/views/Item/ItemGroup.js @@ -55,10 +55,10 @@ ItemGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ItemGroup. */ - children: PropTypes.node, + /** Primary content. */ + children: customPropTypes.children(ItemGroup), - /** Classes that will be added to the ItemGroup className. */ + /** Additional classes. */ className: PropTypes.string, /** Items can be divided to better distinguish between grouped content. */ diff --git a/src/views/Item/ItemHeader.js b/src/views/Item/ItemHeader.js index 675a5d084d..1ab410492c 100644 --- a/src/views/Item/ItemHeader.js +++ b/src/views/Item/ItemHeader.js @@ -30,20 +30,14 @@ ItemHeader.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ItemHeader. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(ItemHeader), - /** Classes that will be added to the ItemHeader className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the ItemHeader. Mutually exclusive with the children prop. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default ItemHeader diff --git a/src/views/Item/ItemMeta.js b/src/views/Item/ItemMeta.js index e6a8071077..bd8ef7c73a 100644 --- a/src/views/Item/ItemMeta.js +++ b/src/views/Item/ItemMeta.js @@ -30,20 +30,14 @@ ItemMeta.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the ItemMeta. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(ItemMeta), - /** Classes that will be added to the ItemMeta className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the ItemMeta. Mutually exclusive with the children prop. */ - content: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + content: customPropTypes.nodeShorthand, } export default ItemMeta diff --git a/src/views/Statistic/Statistic.js b/src/views/Statistic/Statistic.js index 3fdbfbbb95..7f6bc13783 100644 --- a/src/views/Statistic/Statistic.js +++ b/src/views/Statistic/Statistic.js @@ -56,13 +56,13 @@ Statistic.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the Statistic. */ + /** Primary content. */ children: customPropTypes.every([ customPropTypes.disallow(['label', 'value']), PropTypes.node, ]), - /** Classes that will be added to the Statistic className. */ + /** Additional classes. */ className: PropTypes.string, /** A statistic can be formatted to be different colors. */ diff --git a/src/views/Statistic/StatisticGroup.js b/src/views/Statistic/StatisticGroup.js index 03dd6c57ab..1f2b3f6797 100644 --- a/src/views/Statistic/StatisticGroup.js +++ b/src/views/Statistic/StatisticGroup.js @@ -49,27 +49,17 @@ StatisticGroup.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the StatisticGroup. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(StatisticGroup), - /** Classes that will be added to the StatisticGroup className. */ + /** Additional classes. */ className: PropTypes.string, /** A statistic can present its measurement horizontally. */ horizontal: PropTypes.bool, /** Array of props for Statistic. */ - items: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.arrayOf(PropTypes.shape({ - childKey: PropTypes.string, - // this object is spread on the Statistic - // allow it to validate props instead - })), - ]), + items: customPropTypes.arrayOfShorthand, /** A statistic group can have its items divided evenly. */ widths: PropTypes.oneOf(StatisticGroup._meta.props.widths), diff --git a/src/views/Statistic/StatisticLabel.js b/src/views/Statistic/StatisticLabel.js index 62e1edba39..d095dc1f8d 100644 --- a/src/views/Statistic/StatisticLabel.js +++ b/src/views/Statistic/StatisticLabel.js @@ -27,20 +27,14 @@ StatisticLabel.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the StatisticLabel. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(StatisticLabel), - /** Classes that will be added to the StatisticLabel className. */ + /** Additional classes. */ className: PropTypes.string, - /** Primary content of the StatisticLabel. Mutually exclusive with the children prop. */ - label: customPropTypes.every([ - customPropTypes.disallow(['children']), - PropTypes.string, - ]), + /** Shorthand for primary content. */ + label: customPropTypes.nodeShorthand, } export default StatisticLabel diff --git a/src/views/Statistic/StatisticValue.js b/src/views/Statistic/StatisticValue.js index 27c35a2afd..d73a0229c1 100644 --- a/src/views/Statistic/StatisticValue.js +++ b/src/views/Statistic/StatisticValue.js @@ -28,13 +28,10 @@ StatisticValue.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** Primary content of the StatisticValue. */ - children: customPropTypes.every([ - customPropTypes.disallow(['content']), - PropTypes.node, - ]), + /** Primary content. */ + children: customPropTypes.children(StatisticValue), - /** Classes that will be added to the StatisticValue className. */ + /** Additional classes. */ className: PropTypes.string, /** Format the value with smaller font size to fit nicely beside number values. */