Skip to content

Commit

Permalink
Task/remove proptypes (#1077)
Browse files Browse the repository at this point in the history
* Remove proptypes dependency

* Use a git hash for now for react-frame-component until they release 4.0.1 or greater that includes the SSR fix
  • Loading branch information
darthtrevino authored Jun 13, 2018
1 parent f2b0a3a commit 0bc9d08
Show file tree
Hide file tree
Showing 45 changed files with 15 additions and 329 deletions.
1 change: 0 additions & 1 deletion packages/dnd-core/src/HandlerRegistryImpl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Store } from 'redux'
import invariant from 'invariant'
import isArray from 'lodash/isArray'
import {
addSource,
addTarget,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { DragDropContext } from 'react-dnd'
import HTML5Backend, { HTML5BackendContext } from 'react-dnd-html5-backend'
import BoardSquare from './BoardSquare'
Expand All @@ -12,10 +11,6 @@ export interface BoardProps {

@DragDropContext<BoardProps, {}, Board>(HTML5Backend)
export default class Board extends React.Component<BoardProps> {
public static propTypes = {
knightPosition: PropTypes.arrayOf(PropTypes.number.isRequired).isRequired,
}

public render() {
const squares = []
for (let i = 0; i < 64; i += 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
DropTarget,
DropTargetMonitor,
Expand Down Expand Up @@ -45,15 +44,6 @@ const collect: DropTargetCollector<CollectedProps> = (

@DropTarget(ItemTypes.KNIGHT, squareTarget, collect)
export default class BoardSquare extends React.Component<BoardSquareProps> {
public static propTypes = {
x: PropTypes.number.isRequired,
y: PropTypes.number.isRequired,
isOver: PropTypes.bool.isRequired,
canDrop: PropTypes.bool.isRequired,
connectDropTarget: PropTypes.func.isRequired,
children: PropTypes.node,
}

public render() {
const { x, y, connectDropTarget, isOver, canDrop, children } = this.props
const black = (x + y) % 2 === 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
DragSource,
ConnectDragSource,
Expand Down Expand Up @@ -33,12 +32,6 @@ export interface KnightProps {

@DragSource(ItemTypes.KNIGHT, knightSource, collect)
export default class Knight extends React.Component<KnightProps> {
public static propTypes = {
connectDragSource: PropTypes.func.isRequired,
connectDragPreview: PropTypes.func.isRequired,
isDragging: PropTypes.bool.isRequired,
}

public componentDidMount() {
const img = new Image()
img.src =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import React from 'react'
import PropTypes from 'prop-types'

export interface SquareProps {
black: boolean
children: JSX.Element
}

export default class Square extends React.Component<SquareProps> {
public static propTypes = {
black: PropTypes.bool,
children: PropTypes.node,
}

public render() {
const { black } = this.props
const backgroundColor = black ? 'black' : 'white'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
DragSource,
ConnectDragSource,
DragSourceConnector,
DragSourceMonitor,
} from 'react-dnd'
import ItemTypes from '../Single Target/ItemTypes'
import { DragDropManager } from 'dnd-core'

const style: React.CSSProperties = {
border: '1px dashed gray',
Expand Down Expand Up @@ -64,12 +62,6 @@ export interface BoxProps {
}),
)
export default class Box extends React.Component<BoxProps> {
public static propTypes = {
connectDragSource: PropTypes.func.isRequired,
isDragging: PropTypes.bool.isRequired,
name: PropTypes.string.isRequired,
}

public render() {
const { isDragging, connectDragSource } = this.props
const { name } = this.props
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { DropTarget, ConnectDropTarget } from 'react-dnd'
import ItemTypes from '../Single Target/ItemTypes'

Expand Down Expand Up @@ -38,13 +37,6 @@ export interface DustbinProps {
canDrop: monitor.canDrop(),
}))
export default class Dustbin extends React.Component<DustbinProps> {
public static propTypes = {
connectDropTarget: PropTypes.func.isRequired,
isOver: PropTypes.bool.isRequired,
canDrop: PropTypes.bool.isRequired,
allowedDropEffect: PropTypes.string.isRequired,
}

public render() {
const { canDrop, isOver, allowedDropEffect, connectDropTarget } = this.props
const isActive = canDrop && isOver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
DragSource,
ConnectDragSource,
Expand Down Expand Up @@ -41,14 +40,6 @@ export interface BoxProps {
}),
)
export default class Box extends React.Component<BoxProps> {
public static propTypes = {
connectDragSource: PropTypes.func.isRequired,
isDragging: PropTypes.bool.isRequired,
name: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
isDropped: PropTypes.bool.isRequired,
}

public render() {
const { name, isDropped, isDragging, connectDragSource } = this.props
const opacity = isDragging ? 0.4 : 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { DropTarget, ConnectDropTarget, DropTargetMonitor } from 'react-dnd'

const style: React.CSSProperties = {
Expand Down Expand Up @@ -40,15 +39,6 @@ export interface DustbinProps {
}),
)
export default class Dustbin extends React.Component<DustbinProps> {
public static propTypes = {
connectDropTarget: PropTypes.func.isRequired,
isOver: PropTypes.bool.isRequired,
canDrop: PropTypes.bool.isRequired,
accepts: PropTypes.arrayOf(PropTypes.string).isRequired,
lastDroppedItem: PropTypes.object,
onDrop: PropTypes.func.isRequired,
}

public render() {
const {
accepts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
import React from 'react'
import PropTypes from 'prop-types'
import { DragDropContextProvider } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'
import Dustbin from '../Single Target/Dustbin'
import Box from '../Single Target/Box'

// TODO: Update this example when react-frame-component uses the official context API
const Frame = require('react-frame-component').default
const {
default: Frame,
FrameContextConsumer,
} = require('react-frame-component')

class FrameBindingContext extends React.Component {
public static contextTypes = {
window: PropTypes.object,
}
public static propTypes = {
children: PropTypes.node,
}

get dragDropContext() {
return {
window: this.context.window,
}
}

public render() {
return (
<DragDropContextProvider
backend={HTML5Backend}
context={this.dragDropContext}
>
{this.props.children}
</DragDropContextProvider>
<FrameContextConsumer>
{({ window }: any) => (
<DragDropContextProvider backend={HTML5Backend} context={window}>
{this.props.children}
</DragDropContextProvider>
)}
</FrameContextConsumer>
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
ConnectDragSource,
DragSource,
Expand Down Expand Up @@ -50,12 +49,6 @@ const boxSource = {
}),
)
export default class Box extends React.Component<BoxProps> {
public static propTypes = {
connectDragSource: PropTypes.func.isRequired,
isDragging: PropTypes.bool.isRequired,
name: PropTypes.string.isRequired,
}

public render() {
const { isDragging, connectDragSource } = this.props
const { name } = this.props
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
DropTarget,
DropTargetConnector,
Expand Down Expand Up @@ -43,12 +42,6 @@ export interface DustbinProps {
}),
)
export default class Dustbin extends React.Component<DustbinProps> {
public static propTypes = {
connectDropTarget: PropTypes.func.isRequired,
isOver: PropTypes.bool.isRequired,
canDrop: PropTypes.bool.isRequired,
}

public render() {
const { canDrop, isOver, connectDropTarget } = this.props
const isActive = canDrop && isOver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
DragSource,
DragSourceConnector,
Expand Down Expand Up @@ -47,13 +46,6 @@ export interface BoxProps {
}),
)
export default class Box extends React.Component<BoxProps> {
public static propTypes = {
connectDragSource: PropTypes.func.isRequired,
isDragging: PropTypes.bool.isRequired,
name: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
isDropped: PropTypes.bool.isRequired,
}
public render() {
const { name, isDropped, isDragging, connectDragSource } = this.props
const opacity = isDragging ? 0.4 : 1
Expand Down
10 changes: 0 additions & 10 deletions packages/documentation/examples/01 Dustbin/Stress Test/Dustbin.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
ConnectDropTarget,
DropTarget,
Expand Down Expand Up @@ -45,15 +44,6 @@ export interface DustbinProps {
}),
)
export default class Dustbin extends React.Component<DustbinProps> {
public static propTypes = {
connectDropTarget: PropTypes.func.isRequired,
isOver: PropTypes.bool.isRequired,
canDrop: PropTypes.bool.isRequired,
accepts: PropTypes.arrayOf(PropTypes.string).isRequired,
lastDroppedItem: PropTypes.object,
onDrop: PropTypes.func.isRequired,
}

public render() {
const {
accepts,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'

const styles: React.CSSProperties = {
border: '1px dashed gray',
Expand All @@ -13,11 +12,6 @@ export interface BoxProps {
}

export default class Box extends React.PureComponent<BoxProps> {
public static propTypes = {
title: PropTypes.string.isRequired,
yellow: PropTypes.bool,
}

public render() {
const { title, yellow } = this.props
const backgroundColor = yellow ? 'yellow' : 'white'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import Box from './Box'

const styles = {
Expand All @@ -20,10 +19,6 @@ export default class BoxDragPreview extends React.PureComponent<
BoxDragPreviewProps,
BoxDragPreviewState
> {
public static propTypes = {
title: PropTypes.string.isRequired,
}

private interval: any

constructor(props: BoxDragPreviewProps) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
DropTarget,
ConnectDropTarget,
Expand Down Expand Up @@ -56,11 +55,6 @@ export default class Container extends React.PureComponent<
ContainerProps,
ContainerState
> {
public static propTypes = {
connectDropTarget: PropTypes.func.isRequired,
snapToGrid: PropTypes.bool.isRequired,
}

constructor(props: ContainerProps) {
super(props)
this.state = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { DragLayer, XYCoord } from 'react-dnd'
import ItemTypes from './ItemTypes'
import BoxDragPreview from './BoxDragPreview'
Expand Down Expand Up @@ -59,21 +58,6 @@ export interface CustomDragLayerProps {
export default class CustomDragLayer extends React.Component<
CustomDragLayerProps
> {
public static propTypes = {
item: PropTypes.object,
itemType: PropTypes.string,
initialOffset: PropTypes.shape({
x: PropTypes.number.isRequired,
y: PropTypes.number.isRequired,
}),
currentOffset: PropTypes.shape({
x: PropTypes.number.isRequired,
y: PropTypes.number.isRequired,
}),
isDragging: PropTypes.bool.isRequired,
snapToGrid: PropTypes.bool.isRequired,
}

public renderItem(type: any, item: any) {
switch (type) {
case ItemTypes.BOX:
Expand Down
Loading

0 comments on commit 0bc9d08

Please sign in to comment.