diff --git a/src/views/Item/Item.js b/src/views/Item/Item.js index a66d7ce841..e76e5e4862 100644 --- a/src/views/Item/Item.js +++ b/src/views/Item/Item.js @@ -14,7 +14,7 @@ import ItemMeta from './ItemMeta' /** * An item view presents large collections of site content for display. */ -function Item(props) { +const Item = React.forwardRef(function (props, ref) { const { children, className, content, description, extra, header, image, meta } = props const classes = cx('item', className) @@ -23,14 +23,14 @@ function Item(props) { if (!childrenUtils.isNil(children)) { return ( - + {children} ) } return ( - + {ItemImage.create(image, { autoGenerateKey: false })} ) -} +}) Item.Content = ItemContent Item.Description = ItemDescription @@ -52,6 +52,7 @@ Item.Header = ItemHeader Item.Image = ItemImage Item.Meta = ItemMeta +Item.displayName = 'Item' Item.propTypes = { /** An element type to render as (string or function). */ as: PropTypes.elementType, diff --git a/src/views/Item/ItemContent.js b/src/views/Item/ItemContent.js index ab3df2ec32..6699a1cbc1 100644 --- a/src/views/Item/ItemContent.js +++ b/src/views/Item/ItemContent.js @@ -18,7 +18,7 @@ import ItemMeta from './ItemMeta' /** * An item can contain content. */ -function ItemContent(props) { +const ItemContent = React.forwardRef(function (props, ref) { const { children, className, content, description, extra, header, meta, verticalAlign } = props const classes = cx(useVerticalAlignProp(verticalAlign), 'content', className) @@ -27,14 +27,14 @@ function ItemContent(props) { if (!childrenUtils.isNil(children)) { return ( - + {children} ) } return ( - + {ItemHeader.create(header, { autoGenerateKey: false })} {ItemMeta.create(meta, { autoGenerateKey: false })} {ItemDescription.create(description, { autoGenerateKey: false })} @@ -42,8 +42,9 @@ function ItemContent(props) { {content} ) -} +}) +ItemContent.displayName = 'ItemContent' ItemContent.propTypes = { /** An element type to render as (string or function). */ as: PropTypes.elementType, diff --git a/src/views/Item/ItemDescription.js b/src/views/Item/ItemDescription.js index 1dc86c537f..be5440a41d 100644 --- a/src/views/Item/ItemDescription.js +++ b/src/views/Item/ItemDescription.js @@ -13,19 +13,20 @@ import { /** * An item can contain a description with a single or multiple paragraphs. */ -function ItemDescription(props) { +const ItemDescription = React.forwardRef(function (props, ref) { const { children, className, content } = props const classes = cx('description', className) const rest = getUnhandledProps(ItemDescription, props) const ElementType = getElementType(ItemDescription, props) return ( - + {childrenUtils.isNil(children) ? content : children} ) -} +}) +ItemDescription.displayName = 'ItemDescription' ItemDescription.propTypes = { /** An element type to render as (string or function). */ as: PropTypes.elementType, diff --git a/src/views/Item/ItemExtra.js b/src/views/Item/ItemExtra.js index 5cab3b3642..ed9a2a0add 100644 --- a/src/views/Item/ItemExtra.js +++ b/src/views/Item/ItemExtra.js @@ -13,19 +13,20 @@ import { /** * An item can contain extra content meant to be formatted separately from the main content. */ -function ItemExtra(props) { +const ItemExtra = React.forwardRef(function (props, ref) { const { children, className, content } = props const classes = cx('extra', className) const rest = getUnhandledProps(ItemExtra, props) const ElementType = getElementType(ItemExtra, props) return ( - + {childrenUtils.isNil(children) ? content : children} ) -} +}) +ItemExtra.displayName = 'ItemExtra' ItemExtra.propTypes = { /** An element type to render as (string or function). */ as: PropTypes.elementType, diff --git a/src/views/Item/ItemGroup.js b/src/views/Item/ItemGroup.js index e41e5ea96c..7ceca3b9ea 100644 --- a/src/views/Item/ItemGroup.js +++ b/src/views/Item/ItemGroup.js @@ -16,7 +16,7 @@ import Item from './Item' /** * A group of items. */ -function ItemGroup(props) { +const ItemGroup = React.forwardRef(function (props, ref) { const { children, className, content, divided, items, link, relaxed, unstackable } = props const classes = cx( @@ -33,14 +33,14 @@ function ItemGroup(props) { if (!childrenUtils.isNil(children)) { return ( - + {children} ) } if (!childrenUtils.isNil(content)) { return ( - + {content} ) @@ -56,12 +56,13 @@ function ItemGroup(props) { }) return ( - + {itemsJSX} ) -} +}) +ItemGroup.displayName = 'ItemGroup' ItemGroup.propTypes = { /** An element type to render as (string or function). */ as: PropTypes.elementType, diff --git a/src/views/Item/ItemHeader.js b/src/views/Item/ItemHeader.js index e01f59cbf3..610e6d649a 100644 --- a/src/views/Item/ItemHeader.js +++ b/src/views/Item/ItemHeader.js @@ -13,19 +13,20 @@ import { /** * An item can contain a header. */ -function ItemHeader(props) { +const ItemHeader = React.forwardRef(function (props, ref) { const { children, className, content } = props const classes = cx('header', className) const rest = getUnhandledProps(ItemHeader, props) const ElementType = getElementType(ItemHeader, props) return ( - + {childrenUtils.isNil(children) ? content : children} ) -} +}) +ItemHeader.displayName = 'ItemHeader' ItemHeader.propTypes = { /** An element type to render as (string or function). */ as: PropTypes.elementType, diff --git a/src/views/Item/ItemImage.d.ts b/src/views/Item/ItemImage.d.ts index 1a2f4d06ce..f2ce1ffeec 100644 --- a/src/views/Item/ItemImage.d.ts +++ b/src/views/Item/ItemImage.d.ts @@ -1,9 +1,19 @@ import * as React from 'react' + import { ImageProps, StrictImageProps } from '../../elements/Image' +import { SemanticSIZES } from '../../generic' + +export interface ItemImageProps extends ImageProps { + [key: string]: any -export interface ItemImageProps extends ImageProps {} + /** An image may appear at different sizes. */ + size?: SemanticSIZES +} -export interface StrictItemImageProps extends StrictImageProps {} +export interface StrictItemImageProps extends StrictImageProps { + /** An image may appear at different sizes. */ + size?: SemanticSIZES +} declare const ItemImage: React.StatelessComponent diff --git a/src/views/Item/ItemImage.js b/src/views/Item/ItemImage.js index 5e06be9a18..55854ec66e 100644 --- a/src/views/Item/ItemImage.js +++ b/src/views/Item/ItemImage.js @@ -6,13 +6,14 @@ import Image from '../../elements/Image' /** * An item can contain an image. */ -function ItemImage(props) { +const ItemImage = React.forwardRef(function (props, ref) { const { size } = props const rest = getUnhandledProps(ItemImage, props) - return -} + return +}) +ItemImage.displayName = 'ItemImage' ItemImage.propTypes = { /** An image may appear at different sizes. */ size: Image.propTypes.size, diff --git a/src/views/Item/ItemMeta.js b/src/views/Item/ItemMeta.js index 1bacc4b2b8..307bf59a72 100644 --- a/src/views/Item/ItemMeta.js +++ b/src/views/Item/ItemMeta.js @@ -13,19 +13,20 @@ import { /** * An item can contain content metadata. */ -function ItemMeta(props) { +const ItemMeta = React.forwardRef(function (props, ref) { const { children, className, content } = props const classes = cx('meta', className) const rest = getUnhandledProps(ItemMeta, props) const ElementType = getElementType(ItemMeta, props) return ( - + {childrenUtils.isNil(children) ? content : children} ) -} +}) +ItemMeta.displayName = 'ItemMeta' ItemMeta.propTypes = { /** An element type to render as (string or function). */ as: PropTypes.elementType, diff --git a/test/specs/views/Item/Item-test.js b/test/specs/views/Item/Item-test.js index 00085818f3..275ae97eb0 100644 --- a/test/specs/views/Item/Item-test.js +++ b/test/specs/views/Item/Item-test.js @@ -13,6 +13,9 @@ import * as common from 'test/specs/commonTests' describe('Item', () => { common.isConformant(Item) + common.forwardsRef(Item) + common.forwardsRef(Item, { requiredProps: { children: } }) + common.forwardsRef(Item, { requiredProps: { content: faker.lorem.word() } }) common.hasSubcomponents(Item, [ ItemContent, ItemDescription, diff --git a/test/specs/views/Item/ItemContent-test.js b/test/specs/views/Item/ItemContent-test.js index 927d9f1231..12eb210f5f 100644 --- a/test/specs/views/Item/ItemContent-test.js +++ b/test/specs/views/Item/ItemContent-test.js @@ -1,3 +1,6 @@ +import faker from 'faker' +import React from 'react' + import ItemContent from 'src/views/Item/ItemContent' import ItemDescription from 'src/views/Item/ItemDescription' import ItemExtra from 'src/views/Item/ItemExtra' @@ -7,6 +10,9 @@ import * as common from 'test/specs/commonTests' describe('ItemContent', () => { common.isConformant(ItemContent) + common.forwardsRef(ItemContent) + common.forwardsRef(ItemContent, { requiredProps: { children: } }) + common.forwardsRef(ItemContent, { requiredProps: { content: faker.lorem.word() } }) common.rendersChildren(ItemContent) common.implementsShorthandProp(ItemContent, { diff --git a/test/specs/views/Item/ItemDescription-test.js b/test/specs/views/Item/ItemDescription-test.js index 18caa13656..f2b7637f07 100644 --- a/test/specs/views/Item/ItemDescription-test.js +++ b/test/specs/views/Item/ItemDescription-test.js @@ -3,6 +3,7 @@ import * as common from 'test/specs/commonTests' describe('ItemDescription', () => { common.isConformant(ItemDescription) + common.forwardsRef(ItemDescription) common.rendersChildren(ItemDescription) common.implementsCreateMethod(ItemDescription) diff --git a/test/specs/views/Item/ItemExtra-test.js b/test/specs/views/Item/ItemExtra-test.js index 74547f2295..959770e15b 100644 --- a/test/specs/views/Item/ItemExtra-test.js +++ b/test/specs/views/Item/ItemExtra-test.js @@ -3,6 +3,7 @@ import * as common from 'test/specs/commonTests' describe('ItemExtra', () => { common.isConformant(ItemExtra) + common.forwardsRef(ItemExtra) common.rendersChildren(ItemExtra) common.implementsCreateMethod(ItemExtra) diff --git a/test/specs/views/Item/ItemGroup-test.js b/test/specs/views/Item/ItemGroup-test.js index 97f993a8e3..a9bc5fba86 100644 --- a/test/specs/views/Item/ItemGroup-test.js +++ b/test/specs/views/Item/ItemGroup-test.js @@ -5,8 +5,11 @@ import ItemGroup from 'src/views/Item/ItemGroup' import * as common from 'test/specs/commonTests' describe('ItemGroup', () => { - common.hasUIClassName(ItemGroup) common.isConformant(ItemGroup) + common.forwardsRef(ItemGroup) + common.forwardsRef(ItemGroup, { requiredProps: { children: } }) + common.forwardsRef(ItemGroup, { requiredProps: { content: faker.lorem.word() } }) + common.hasUIClassName(ItemGroup) common.rendersChildren(ItemGroup) common.propKeyOnlyToClassName(ItemGroup, 'divided') diff --git a/test/specs/views/Item/ItemHeader-test.js b/test/specs/views/Item/ItemHeader-test.js index 15b8bbffdd..4e7081f00b 100644 --- a/test/specs/views/Item/ItemHeader-test.js +++ b/test/specs/views/Item/ItemHeader-test.js @@ -3,6 +3,7 @@ import * as common from 'test/specs/commonTests' describe('ItemHeader', () => { common.isConformant(ItemHeader) + common.forwardsRef(ItemHeader) common.rendersChildren(ItemHeader) common.implementsCreateMethod(ItemHeader) diff --git a/test/specs/views/Item/ItemImage-test.js b/test/specs/views/Item/ItemImage-test.js index ac8b4cac66..84ac354361 100644 --- a/test/specs/views/Item/ItemImage-test.js +++ b/test/specs/views/Item/ItemImage-test.js @@ -4,6 +4,8 @@ import ItemImage from 'src/views/Item/ItemImage' import * as common from 'test/specs/commonTests' describe('ItemImage', () => { + common.isConformant(ItemImage, { rendersChildren: false }) + common.forwardsRef(ItemImage, { tagName: 'img' }) common.implementsCreateMethod(ItemImage) it('renders Image component', () => { diff --git a/test/specs/views/Item/ItemMeta-test.js b/test/specs/views/Item/ItemMeta-test.js index 58f2236ac2..8ecbae3766 100644 --- a/test/specs/views/Item/ItemMeta-test.js +++ b/test/specs/views/Item/ItemMeta-test.js @@ -3,6 +3,7 @@ import * as common from 'test/specs/commonTests' describe('ItemMeta', () => { common.isConformant(ItemMeta) + common.forwardsRef(ItemMeta) common.rendersChildren(ItemMeta) common.implementsCreateMethod(ItemMeta)