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 11 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
18 changes: 12 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,9 @@ class Accordion extends AutoControlledComponent<Extendable<AccordionProps>, any>
static className = 'ui-accordion'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...commonPropTypes.createCommon({
content: false,
}),
activeIndex: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
Expand Down
20 changes: 8 additions & 12 deletions src/components/Accordion/AccordionContent.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
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'
commonPropTypes,
} from '../../lib'
import { Extendable, ComponentEventHandler } from '../../../types/utils'

export interface AccordionContentProps
extends UIComponentProps<any, any>,
extends UIComponentProps,
ChildrenComponentProps,
ContentComponentProps {
/** Whether or not the content is visible. */
Expand All @@ -41,9 +39,7 @@ class AccordionContent extends UIComponent<Extendable<AccordionContentProps>, an
static className = 'ui-accordion__content'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...contentComponentPropsTypes,
...commonPropTypes.createCommon(),
active: PropTypes.bool,
onClick: PropTypes.func,
}
Expand Down
20 changes: 8 additions & 12 deletions src/components/Accordion/AccordionTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@ 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,
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>,
extends UIComponentProps,
ContentComponentProps,
ChildrenComponentProps {
/** Whether or not the title is in the open state. */
Expand Down Expand Up @@ -45,9 +43,7 @@ class AccordionTitle extends UIComponent<Extendable<AccordionTitleProps>, any> {
static className = 'ui-accordion__title'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...contentComponentPropsTypes,
...commonPropTypes.createCommon(),
Copy link
Member

Choose a reason for hiding this comment

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

❤️

active: PropTypes.bool,
index: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onClick: PropTypes.func,
Expand Down
23 changes: 15 additions & 8 deletions src/components/Animation/Animation.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import * as PropTypes from 'prop-types'
import * as React from 'react'

import { UIComponent, customPropTypes, childrenExist } from '../../lib'
import {
UIComponent,
childrenExist,
StyledComponentProps,
commonPropTypes,
ChildrenComponentProps,
} 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,
ChildrenComponentProps<React.ReactChild> {
/** An element type to render as (string or function). */
as?: any

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

static propTypes = {
...styledComponentPropTypes,
...childrenComponentPropTypes,
...commonPropTypes.createCommon({
animated: false,
content: false,
children: 'element',
}),
name: PropTypes.string,
as: customPropTypes.as,
className: PropTypes.string,
delay: PropTypes.string,
direction: PropTypes.string,
duration: PropTypes.string,
Expand Down
18 changes: 12 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,9 @@ class Attachment extends UIComponent<Extendable<AttachmentProps>, any> {
static displayName = 'Attachment'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...commonPropTypes.createCommon({
content: false,
}),
action: customPropTypes.itemShorthand,
actionable: PropTypes.bool,
description: customPropTypes.itemShorthand,
Expand Down
17 changes: 12 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,10 @@ class Avatar extends UIComponent<Extendable<AvatarProps>, any> {
static displayName = 'Avatar'

static propTypes = {
...commonUIComponentPropTypes,
...commonPropTypes.createCommon({
children: false,
content: false,
}),
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,
ContentComponentProps,
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,
ContentComponentProps<ShorthandValue>,
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.createCommon({
content: 'shorthand',
}),
circular: PropTypes.bool,
disabled: PropTypes.bool,
fluid: PropTypes.bool,
Expand Down
26 changes: 11 additions & 15 deletions src/components/Button/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ import * as PropTypes from 'prop-types'
import * as React from 'react'
import * as _ from 'lodash'

import { UIComponent, childrenExist, customPropTypes } 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 {
UIComponent,
childrenExist,
customPropTypes,
UIComponentProps,
ChildrenComponentProps,
ContentComponentProps,
} from '../../lib/commonPropInterfaces'
import {
commonUIComponentPropTypes,
childrenComponentPropTypes,
contentComponentPropsTypes,
} from '../../lib/commonPropTypes'
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'

export interface ButtonGroupProps
extends UIComponentProps<any, any>,
extends UIComponentProps,
ChildrenComponentProps,
ContentComponentProps {
/**
Expand Down Expand Up @@ -54,9 +52,7 @@ class ButtonGroup extends UIComponent<Extendable<ButtonGroupProps>, any> {
public static className = 'ui-buttons'

public static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...contentComponentPropsTypes,
...commonPropTypes.createCommon(),
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
buttons: customPropTypes.collectionShorthand,
circular: PropTypes.bool,
Expand Down
10 changes: 5 additions & 5 deletions src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import * as _ from 'lodash'
import * as PropTypes from 'prop-types'
import * as React from 'react'

import { childrenExist, customPropTypes, UIComponent } from '../../lib'
import { childrenExist, customPropTypes, UIComponent, commonPropTypes } from '../../lib'
import ChatItem from './ChatItem'
import ChatMessage from './ChatMessage'
import { Extendable, ShorthandValue, ShorthandRenderFunction } from '../../../types/utils'
import { Accessibility, AccessibilityActionHandlers } from '../../lib/accessibility/types'
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 Expand Up @@ -41,8 +40,9 @@ class Chat extends UIComponent<Extendable<ChatProps>, any> {
static displayName = 'Chat'

static propTypes = {
...commonUIComponentPropTypes,
...childrenComponentPropTypes,
...commonPropTypes.createCommon({
content: false,
}),
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
items: PropTypes.arrayOf(customPropTypes.itemShorthand),
renderItem: PropTypes.func,
Expand Down
Loading