Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(content): fixing the type of the content prop in all components #528

Merged
merged 18 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import * as _ from 'lodash'
import * as PropTypes from 'prop-types'
import * as React from 'react'

import { AutoControlledComponent, customPropTypes, childrenExist } from '../../lib'
import {
AutoControlledComponent,
customPropTypes,
childrenExist,
UIComponentProps,
ChildrenComponentProps,
commonPropTypes,
} from '../../lib'
import AccordionTitle from './AccordionTitle'
import AccordionContent from './AccordionContent'
import { defaultBehavior } from '../../lib/accessibility'
Expand All @@ -13,10 +20,8 @@ import {
ShorthandRenderFunction,
ShorthandValue,
} from '../../../types/utils'
import { UIComponentProps, ChildrenComponentProps } from '../../lib/commonPropInterfaces'
import { commonUIComponentPropTypes, childrenComponentPropTypes } from '../../lib/commonPropTypes'

export interface AccordionProps extends UIComponentProps<any, any>, ChildrenComponentProps {
export interface AccordionProps extends UIComponentProps, ChildrenComponentProps {
/** Index of the currently active panel. */
activeIndex?: number[] | number

Expand Down Expand Up @@ -76,8 +81,8 @@ class Accordion extends AutoControlledComponent<Extendable<AccordionProps>, any>
static className = 'ui-accordion'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...commonPropTypes.commonUIComponentPropTypes,
...commonPropTypes.childrenComponentPropTypes,
activeIndex: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
Expand Down
26 changes: 12 additions & 14 deletions src/components/Accordion/AccordionContent.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import * as PropTypes from 'prop-types'
import * as React from 'react'

import { childrenExist, createShorthandFactory, UIComponent } from '../../lib'
import { Extendable, ComponentEventHandler } from '../../../types/utils'
import {
childrenExist,
createShorthandFactory,
UIComponent,
UIComponentProps,
ChildrenComponentProps,
ContentComponentProps,
} from '../../lib/commonPropInterfaces'
import {
commonUIComponentPropTypes,
childrenComponentPropTypes,
contentComponentPropsTypes,
} from '../../lib/commonPropTypes'
ContentNodeComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable, ComponentEventHandler } from '../../../types/utils'

export interface AccordionContentProps
extends UIComponentProps<any, any>,
extends UIComponentProps,
ChildrenComponentProps,
ContentComponentProps {
ContentNodeComponentProps {
/** Whether or not the content is visible. */
active?: boolean

Expand All @@ -41,9 +39,9 @@ class AccordionContent extends UIComponent<Extendable<AccordionContentProps>, an
static className = 'ui-accordion__content'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...contentComponentPropsTypes,
...commonPropTypes.commonUIComponentPropTypes,
...commonPropTypes.childrenComponentPropTypes,
...commonPropTypes.contentNodeComponentPropsTypes,
active: PropTypes.bool,
onClick: PropTypes.func,
}
Expand Down
26 changes: 12 additions & 14 deletions src/components/Accordion/AccordionTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ import * as _ from 'lodash'
import * as PropTypes from 'prop-types'
import * as React from 'react'

import { childrenExist, createShorthandFactory, UIComponent } from '../../lib'
import { Extendable, ComponentEventHandler } from '../../../types/utils'
import {
childrenExist,
createShorthandFactory,
UIComponent,
UIComponentProps,
ContentComponentProps,
ContentNodeComponentProps,
ChildrenComponentProps,
} from '../../lib/commonPropInterfaces'
import {
commonUIComponentPropTypes,
childrenComponentPropTypes,
contentComponentPropsTypes,
} from '../../lib/commonPropTypes'
commonPropTypes,
} from '../../lib'
import { Extendable, ComponentEventHandler } from '../../../types/utils'

export interface AccordionTitleProps
extends UIComponentProps<any, any>,
ContentComponentProps,
extends UIComponentProps,
ContentNodeComponentProps,
ChildrenComponentProps {
/** Whether or not the title is in the open state. */
active?: boolean
Expand Down Expand Up @@ -45,9 +43,9 @@ class AccordionTitle extends UIComponent<Extendable<AccordionTitleProps>, any> {
static className = 'ui-accordion__title'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...contentComponentPropsTypes,
...commonPropTypes.commonUIComponentPropTypes,
...commonPropTypes.childrenComponentPropTypes,
...commonPropTypes.contentNodeComponentPropsTypes,
active: PropTypes.bool,
index: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onClick: PropTypes.func,
Expand Down
22 changes: 16 additions & 6 deletions src/components/Animation/Animation.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import * as PropTypes from 'prop-types'
import * as React from 'react'

import { UIComponent, customPropTypes, childrenExist } from '../../lib'
import {
UIComponent,
customPropTypes,
childrenExist,
StyledComponentProps,
commonPropTypes,
} from '../../lib'
import { AnimationProp } from '../../themes/types'
import createAnimationStyles from '../../lib/createAnimationStyles'
import { ChildrenComponentProps, StyledComponentProps } from '../../lib/commonPropInterfaces'
import { styledComponentPropTypes, childrenComponentPropTypes } from '../../lib/commonPropTypes'

export interface AnimationProps extends StyledComponentProps<any, any>, ChildrenComponentProps {
export interface AnimationProps extends StyledComponentProps {
/** An element type to render as (string or function). */
as?: any

/**
* Content for childrenApi
* @docSiteIgnore
*/
children?: React.ReactChild
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as description is duplicated now, I would rather suggest to still encapsulate it at the single place (ChildrenComponentProps), and just introduce optional generic parameter to this type:

ChildrenComponentProps<TChildren=React.ReactChildren> {
  /**
   *  Content for childrenApi
   *  @docSiteIgnore
   */
  children?: TChildren
}


/** Additional CSS class name(s) to apply. */
className?: string

Expand Down Expand Up @@ -80,8 +90,8 @@ class Animation extends UIComponent<AnimationProps, any> {
static displayName = 'Animation'

static propTypes = {
...styledComponentPropTypes,
...childrenComponentPropTypes,
...commonPropTypes.styledComponentPropTypes,
children: PropTypes.element,
name: PropTypes.string,
as: customPropTypes.as,
className: PropTypes.string,
Expand Down
17 changes: 11 additions & 6 deletions src/components/Attachment/Attachment.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import * as PropTypes from 'prop-types'
import * as React from 'react'
import * as _ from 'lodash'
import { UIComponent, customPropTypes, createShorthandFactory } from '../../lib'
import {
UIComponent,
customPropTypes,
createShorthandFactory,
UIComponentProps,
ChildrenComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable, ShorthandRenderFunction, ShorthandValue } from '../../../types/utils'
import Icon from '../Icon/Icon'
import Button from '../Button/Button'
import Text from '../Text/Text'
import Slot from '../Slot/Slot'
import { UIComponentProps, ChildrenComponentProps } from '../../lib/commonPropInterfaces'
import { commonUIComponentPropTypes, childrenComponentPropTypes } from '../../lib/commonPropTypes'

export interface AttachmentProps extends UIComponentProps<any, any>, ChildrenComponentProps {
export interface AttachmentProps extends UIComponentProps, ChildrenComponentProps {
/** Button shorthand for the action slot. */
action?: ShorthandValue

Expand Down Expand Up @@ -86,8 +91,8 @@ class Attachment extends UIComponent<Extendable<AttachmentProps>, any> {
static displayName = 'Attachment'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...commonPropTypes.commonUIComponentPropTypes,
...commonPropTypes.childrenComponentPropTypes,
action: customPropTypes.itemShorthand,
actionable: PropTypes.bool,
description: customPropTypes.itemShorthand,
Expand Down
14 changes: 9 additions & 5 deletions src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import * as PropTypes from 'prop-types'
import * as React from 'react'
import { Image, Label, Status } from '../../'

import { createShorthandFactory, customPropTypes, UIComponent } from '../../lib'
import {
createShorthandFactory,
customPropTypes,
UIComponent,
UIComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable, ShorthandRenderFunction, ShorthandValue } from '../../../types/utils'
import { UIComponentProps } from '../../lib/commonPropInterfaces'
import { commonUIComponentPropTypes } from '../../lib/commonPropTypes'

export interface AvatarProps extends UIComponentProps<any, any> {
export interface AvatarProps extends UIComponentProps {
/** Shorthand for the image. */
image?: ShorthandValue

Expand Down Expand Up @@ -65,7 +69,7 @@ class Avatar extends UIComponent<Extendable<AvatarProps>, any> {
static displayName = 'Avatar'

static propTypes = {
...commonUIComponentPropTypes,
...commonPropTypes.commonUIComponentPropTypes,
name: PropTypes.string,
image: customPropTypes.itemShorthand,
label: customPropTypes.itemShorthand,
Expand Down
31 changes: 15 additions & 16 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import * as PropTypes from 'prop-types'
import * as React from 'react'
import * as _ from 'lodash'

import { UIComponent, childrenExist, customPropTypes, createShorthandFactory } from '../../lib'
import {
UIComponent,
childrenExist,
customPropTypes,
createShorthandFactory,
UIComponentProps,
ContentShorthandComponentProps,
ChildrenComponentProps,
commonPropTypes,
} from '../../lib'
import Icon from '../Icon/Icon'
import Slot from '../Slot/Slot'
import { buttonBehavior } from '../../lib/accessibility'
Expand All @@ -15,20 +24,10 @@ import {
} from '../../../types/utils'
import ButtonGroup from './ButtonGroup'
import isFromKeyboard from '../../lib/isFromKeyboard'
import {
UIComponentProps,
ContentComponentProps,
ChildrenComponentProps,
} from '../../lib/commonPropInterfaces'
import {
commonUIComponentPropTypes,
childrenComponentPropTypes,
contentComponentPropsTypes,
} from '../../lib/commonPropTypes'

export interface ButtonProps
extends UIComponentProps<any, any>,
ContentComponentProps,
extends UIComponentProps,
ContentShorthandComponentProps,
ChildrenComponentProps {
/**
* Accessibility behavior if overridden by the user.
Expand Down Expand Up @@ -106,9 +105,9 @@ class Button extends UIComponent<Extendable<ButtonProps>, ButtonState> {
public static className = 'ui-button'

public static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...contentComponentPropsTypes,
...commonPropTypes.commonUIComponentPropTypes,
...commonPropTypes.childrenComponentPropTypes,
...commonPropTypes.contentShorthandComponentPropsTypes,
circular: PropTypes.bool,
disabled: PropTypes.bool,
fluid: PropTypes.bool,
Expand Down
30 changes: 14 additions & 16 deletions src/components/Button/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@ import * as PropTypes from 'prop-types'
import * as React from 'react'
import * as _ from 'lodash'

import { UIComponent, childrenExist, customPropTypes } from '../../lib'
import {
UIComponent,
childrenExist,
customPropTypes,
UIComponentProps,
ChildrenComponentProps,
ContentNodeComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable, ShorthandRenderFunction, ShorthandValue } from '../../../types/utils'
import Button from './Button'
import { buttonGroupBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/types'
import {
UIComponentProps,
ChildrenComponentProps,
ContentComponentProps,
} from '../../lib/commonPropInterfaces'
import {
commonUIComponentPropTypes,
childrenComponentPropTypes,
contentComponentPropsTypes,
} from '../../lib/commonPropTypes'

export interface ButtonGroupProps
extends UIComponentProps<any, any>,
extends UIComponentProps,
ChildrenComponentProps,
ContentComponentProps {
ContentNodeComponentProps {
/**
* Accessibility behavior if overridden by the user.
* @default buttonGroupBehavior
Expand Down Expand Up @@ -54,9 +52,9 @@ class ButtonGroup extends UIComponent<Extendable<ButtonGroupProps>, any> {
public static className = 'ui-buttons'

public static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...contentComponentPropsTypes,
...commonPropTypes.commonUIComponentPropTypes,
...commonPropTypes.childrenComponentPropTypes,
...commonPropTypes.contentNodeComponentPropsTypes,
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
buttons: customPropTypes.collectionShorthand,
circular: PropTypes.bool,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { chatBehavior } from '../../lib/accessibility'
import { UIComponentProps, ChildrenComponentProps } from '../../lib/commonPropInterfaces'
import { commonUIComponentPropTypes, childrenComponentPropTypes } from '../../lib/commonPropTypes'

export interface ChatProps extends UIComponentProps<any, any>, ChildrenComponentProps {
export interface ChatProps extends UIComponentProps, ChildrenComponentProps {
/**
* Accessibility behavior if overridden by the user.
* @default chatBehavior
Expand Down
Loading