From ef0eecda17e8c57af98938ec050ccc9b8bc7dc36 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Fri, 14 Sep 2018 12:16:46 +1200 Subject: [PATCH] First pass at proptypes --- client/src/components/Badge/Badge.js | 3 +- .../src/components/Breadcrumb/Breadcrumb.js | 3 +- .../CheckboxSetField/CheckboxSetField.js | 27 +++++++------- .../CompositeField/CompositeField.js | 13 +++---- client/src/components/DateField/DateField.js | 11 +++--- .../components/DatetimeField/DatetimeField.js | 9 ++--- .../src/components/FieldHolder/FieldHolder.js | 3 +- .../src/components/Focusedzone/Focusedzone.js | 3 +- client/src/components/Form/Form.js | 3 +- .../src/components/FormAction/FormAction.js | 31 ++++++++-------- client/src/components/FormAlert/FormAlert.js | 3 +- .../FormBuilderModal/FormBuilderModal.js | 35 ++++++++++--------- client/src/components/GridField/GridField.js | 13 +++---- .../components/GridField/GridFieldAction.js | 3 +- .../src/components/GridField/GridFieldCell.js | 5 +-- .../GridFieldActions/GridFieldActions.js | 5 +-- .../GridFieldDropdownAction.js | 9 ++--- .../src/components/HeaderField/HeaderField.js | 15 ++++---- .../src/components/HiddenField/HiddenField.js | 9 ++--- .../HtmlReadonlyField/HtmlReadonlyField.js | 9 ++--- .../components/IframeDialog/IframeDialog.js | 3 +- .../src/components/LabelField/LabelField.js | 3 +- client/src/components/ListGroup/ListGroup.js | 3 +- .../src/components/ListGroup/ListGroupItem.js | 5 +-- .../components/LiteralField/LiteralField.js | 9 ++--- client/src/components/Loading/Loading.js | 3 +- .../src/components/LookupField/LookupField.js | 17 ++++----- .../MobileMenuToggle/MobileMenuToggle.js | 3 +- .../NotFoundComponent/NotFoundComponent.js | 3 +- .../components/OptionsetField/OptionField.js | 27 +++++++------- .../OptionsetField/OptionsetField.js | 25 ++++++------- .../components/PopoverField/PopoverField.js | 3 +- client/src/components/Preview/Preview.js | 13 +++---- .../src/components/ResizeAware/ResizeAware.js | 3 +- client/src/components/Search/Search.js | 4 +-- client/src/components/Search/SearchBox.js | 3 +- client/src/components/Search/SearchForm.js | 3 +- client/src/components/Search/SearchToggle.js | 3 +- .../SingleSelectField/SingleSelectField.js | 31 ++++++++-------- client/src/components/Tabs/TabItem.js | 9 ++--- client/src/components/Tabs/Tabs.js | 7 ++-- client/src/components/Tag/CompactTagList.js | 3 +- client/src/components/Tag/SummaryTag.js | 3 +- client/src/components/Tag/Tag.js | 3 +- client/src/components/Tag/TagList.js | 3 +- client/src/components/Tag/TagPropType.js | 2 +- client/src/components/TextField/TextField.js | 23 ++++++------ 47 files changed, 237 insertions(+), 192 deletions(-) diff --git a/client/src/components/Badge/Badge.js b/client/src/components/Badge/Badge.js index c56e2c0c6..0bacb01df 100644 --- a/client/src/components/Badge/Badge.js +++ b/client/src/components/Badge/Badge.js @@ -1,5 +1,6 @@ -import React, { PureComponent, PropTypes } from 'react'; +import React, { PureComponent } from 'react'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class Badge extends PureComponent { render() { diff --git a/client/src/components/Breadcrumb/Breadcrumb.js b/client/src/components/Breadcrumb/Breadcrumb.js index e195c3bd0..3d4f3b72a 100644 --- a/client/src/components/Breadcrumb/Breadcrumb.js +++ b/client/src/components/Breadcrumb/Breadcrumb.js @@ -1,5 +1,6 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import { connect } from 'react-redux'; +import PropTypes from 'prop-types'; class Breadcrumb extends Component { getLastCrumb() { diff --git a/client/src/components/CheckboxSetField/CheckboxSetField.js b/client/src/components/CheckboxSetField/CheckboxSetField.js index f98d60dab..35fe91118 100644 --- a/client/src/components/CheckboxSetField/CheckboxSetField.js +++ b/client/src/components/CheckboxSetField/CheckboxSetField.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import OptionField from 'components/OptionsetField/OptionField'; import fieldHolder from 'components/FieldHolder/FieldHolder'; +import PropTypes from 'prop-types'; // a group of check boxes class CheckboxSetField extends Component { @@ -112,20 +113,20 @@ class CheckboxSetField extends Component { } CheckboxSetField.propTypes = { - className: React.PropTypes.string, - extraClass: React.PropTypes.string, - itemClass: React.PropTypes.string, - id: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - source: React.PropTypes.arrayOf(React.PropTypes.shape({ - value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - title: React.PropTypes.any, - disabled: React.PropTypes.bool, + className: PropTypes.string, + extraClass: PropTypes.string, + itemClass: PropTypes.string, + id: PropTypes.string, + name: PropTypes.string.isRequired, + source: PropTypes.arrayOf(PropTypes.shape({ + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + title: PropTypes.any, + disabled: PropTypes.bool, })), - onChange: React.PropTypes.func, - value: React.PropTypes.any, - readOnly: React.PropTypes.bool, - disabled: React.PropTypes.bool, + onChange: PropTypes.func, + value: PropTypes.any, + readOnly: PropTypes.bool, + disabled: PropTypes.bool, }; CheckboxSetField.defaultProps = { diff --git a/client/src/components/CompositeField/CompositeField.js b/client/src/components/CompositeField/CompositeField.js index f0cd7db6c..4e7139dea 100644 --- a/client/src/components/CompositeField/CompositeField.js +++ b/client/src/components/CompositeField/CompositeField.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import castStringToElement from 'lib/castStringToElement'; +import PropTypes from 'prop-types'; class CompositeField extends Component { /** @@ -36,14 +37,14 @@ class CompositeField extends Component { } CompositeField.propTypes = { - data: React.PropTypes.oneOfType([ - React.PropTypes.array, - React.PropTypes.shape({ - tag: React.PropTypes.string, - legend: React.PropTypes.string, + data: PropTypes.oneOfType([ + PropTypes.array, + PropTypes.shape({ + tag: PropTypes.string, + legend: PropTypes.string, }), ]), - extraClass: React.PropTypes.string, + extraClass: PropTypes.string, }; CompositeField.defaultProps = { diff --git a/client/src/components/DateField/DateField.js b/client/src/components/DateField/DateField.js index 78d00cbf9..6c5d7e06d 100644 --- a/client/src/components/DateField/DateField.js +++ b/client/src/components/DateField/DateField.js @@ -4,6 +4,7 @@ import { Component as TextField } from '../TextField/TextField'; import moment from 'moment'; import modernizr from 'modernizr'; import i18n from 'i18n'; +import PropTypes from 'prop-types'; const localFormat = 'L'; @@ -127,11 +128,11 @@ class DateField extends TextField { } DateField.propTypes = { - lang: React.PropTypes.string, - isoLang: React.PropTypes.string, - modernizr: React.PropTypes.object, - data: React.PropTypes.shape({ - html5: React.PropTypes.bool, + lang: PropTypes.string, + isoLang: PropTypes.string, + modernizr: PropTypes.object, + data: PropTypes.shape({ + html5: PropTypes.bool, }), }; diff --git a/client/src/components/DatetimeField/DatetimeField.js b/client/src/components/DatetimeField/DatetimeField.js index bbbb742ff..791aeb684 100644 --- a/client/src/components/DatetimeField/DatetimeField.js +++ b/client/src/components/DatetimeField/DatetimeField.js @@ -4,6 +4,7 @@ import { Component as DateField } from '../DateField/DateField'; import moment from 'moment'; import modernizr from 'modernizr'; import i18n from 'i18n'; +import PropTypes from 'prop-types'; const localFormat = 'L LT'; @@ -67,10 +68,10 @@ class DatetimeField extends DateField { } DatetimeField.propTypes = { - lang: React.PropTypes.string, - modernizr: React.PropTypes.object, - data: React.PropTypes.shape({ - html5: React.PropTypes.boolean, + lang: PropTypes.string, + modernizr: PropTypes.object, + data: PropTypes.shape({ + html5: PropTypes.boolean, }), }; diff --git a/client/src/components/FieldHolder/FieldHolder.js b/client/src/components/FieldHolder/FieldHolder.js index 28c1d88eb..ef6c5c814 100644 --- a/client/src/components/FieldHolder/FieldHolder.js +++ b/client/src/components/FieldHolder/FieldHolder.js @@ -1,7 +1,8 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import { FormGroup, InputGroup, InputGroupAddon, Label } from 'reactstrap'; import castStringToElement from 'lib/castStringToElement'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; function fieldHolder(Field) { class FieldHolder extends Component { diff --git a/client/src/components/Focusedzone/Focusedzone.js b/client/src/components/Focusedzone/Focusedzone.js index d7f964539..ea859d9c2 100644 --- a/client/src/components/Focusedzone/Focusedzone.js +++ b/client/src/components/Focusedzone/Focusedzone.js @@ -1,5 +1,6 @@ /* global document */ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; /** * Wrapper component that fires a handler (`onClickOut`) when a user clicks diff --git a/client/src/components/Form/Form.js b/client/src/components/Form/Form.js index ddaacb577..6c3e0ef11 100644 --- a/client/src/components/Form/Form.js +++ b/client/src/components/Form/Form.js @@ -1,5 +1,6 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; import FormAlert from 'components/FormAlert/FormAlert'; +import PropTypes from 'prop-types'; class Form extends Component { componentDidMount() { diff --git a/client/src/components/FormAction/FormAction.js b/client/src/components/FormAction/FormAction.js index 5468d996f..359e226c4 100644 --- a/client/src/components/FormAction/FormAction.js +++ b/client/src/components/FormAction/FormAction.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import castStringToElement from 'lib/castStringToElement'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class FormAction extends Component { constructor(props) { @@ -169,23 +170,23 @@ class FormAction extends Component { } FormAction.propTypes = { - id: React.PropTypes.string, - name: React.PropTypes.string, - onClick: React.PropTypes.func, - title: React.PropTypes.string, - type: React.PropTypes.string, - loading: React.PropTypes.bool, - icon: React.PropTypes.string, - disabled: React.PropTypes.bool, - readOnly: React.PropTypes.bool, - data: React.PropTypes.oneOfType([ - React.PropTypes.array, - React.PropTypes.shape({ - buttonStyle: React.PropTypes.string, + id: PropTypes.string, + name: PropTypes.string, + onClick: PropTypes.func, + title: PropTypes.string, + type: PropTypes.string, + loading: PropTypes.bool, + icon: PropTypes.string, + disabled: PropTypes.bool, + readOnly: PropTypes.bool, + data: PropTypes.oneOfType([ + PropTypes.array, + PropTypes.shape({ + buttonStyle: PropTypes.string, }), ]), - extraClass: React.PropTypes.string, - attributes: React.PropTypes.object, + extraClass: PropTypes.string, + attributes: PropTypes.object, }; FormAction.defaultProps = { diff --git a/client/src/components/FormAlert/FormAlert.js b/client/src/components/FormAlert/FormAlert.js index e29956d0a..97ffa9f5c 100644 --- a/client/src/components/FormAlert/FormAlert.js +++ b/client/src/components/FormAlert/FormAlert.js @@ -1,7 +1,8 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import { Alert } from 'reactstrap'; import castStringToElement from 'lib/castStringToElement'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; /** * A wrapper for Alert messages in reactstrap. diff --git a/client/src/components/FormBuilderModal/FormBuilderModal.js b/client/src/components/FormBuilderModal/FormBuilderModal.js index 4cbfe24c9..5ac2884e6 100644 --- a/client/src/components/FormBuilderModal/FormBuilderModal.js +++ b/client/src/components/FormBuilderModal/FormBuilderModal.js @@ -3,6 +3,7 @@ import i18n from 'i18n'; import { Modal, ModalHeader, ModalBody } from 'reactstrap'; import FormBuilderLoader from 'containers/FormBuilderLoader/FormBuilderLoader'; import castStringToElement from 'lib/castStringToElement'; +import PropTypes from 'prop-types'; const noop = () => null; @@ -186,24 +187,24 @@ class FormBuilderModal extends Component { } FormBuilderModal.propTypes = { - autoFocus: React.PropTypes.bool, - isOpen: React.PropTypes.bool, - title: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.bool]), - className: React.PropTypes.string, - bodyClassName: React.PropTypes.string, - modalClassName: React.PropTypes.string, - showCloseButton: React.PropTypes.bool, - size: React.PropTypes.string, - onClosed: React.PropTypes.func, - schemaUrl: React.PropTypes.string, - onSubmit: React.PropTypes.func, - onAction: React.PropTypes.func, - responseClassGood: React.PropTypes.string, - responseClassBad: React.PropTypes.string, - identifier: React.PropTypes.string, + autoFocus: PropTypes.bool, + isOpen: PropTypes.bool, + title: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), + className: PropTypes.string, + bodyClassName: PropTypes.string, + modalClassName: PropTypes.string, + showCloseButton: PropTypes.bool, + size: PropTypes.string, + onClosed: PropTypes.func, + schemaUrl: PropTypes.string, + onSubmit: PropTypes.func, + onAction: PropTypes.func, + responseClassGood: PropTypes.string, + responseClassBad: PropTypes.string, + identifier: PropTypes.string, // Ignored and assumed true if onLoadingError is unassigned - showErrorMessage: React.PropTypes.bool, - onLoadingError: React.PropTypes.func, + showErrorMessage: PropTypes.bool, + onLoadingError: PropTypes.func, }; FormBuilderModal.defaultProps = { diff --git a/client/src/components/GridField/GridField.js b/client/src/components/GridField/GridField.js index 42a411a6a..f73f8b2ad 100644 --- a/client/src/components/GridField/GridField.js +++ b/client/src/components/GridField/GridField.js @@ -12,6 +12,7 @@ import GridFieldAction from './GridFieldAction'; import FormConstants from 'components/Form/FormConstants'; import * as actions from 'state/records/RecordsActions'; import castStringToElement from 'lib/castStringToElement'; +import PropTypes from 'prop-types'; const NotYetLoaded = []; @@ -158,12 +159,12 @@ class GridField extends Component { } GridField.propTypes = { - data: React.PropTypes.shape({ - recordType: React.PropTypes.string.isRequired, - headerColumns: React.PropTypes.array, - collectionReadEndpoint: React.PropTypes.object, - onDrillDown: React.PropTypes.func, - onEditRecord: React.PropTypes.func, + data: PropTypes.shape({ + recordType: PropTypes.string.isRequired, + headerColumns: PropTypes.array, + collectionReadEndpoint: PropTypes.object, + onDrillDown: PropTypes.func, + onEditRecord: PropTypes.func, }), }; diff --git a/client/src/components/GridField/GridFieldAction.js b/client/src/components/GridField/GridFieldAction.js index 6dd85cb1a..e5c0ae1be 100644 --- a/client/src/components/GridField/GridFieldAction.js +++ b/client/src/components/GridField/GridFieldAction.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; class GridFieldAction extends Component { constructor(props) { @@ -21,7 +22,7 @@ class GridFieldAction extends Component { } GridFieldAction.PropTypes = { - Click: React.PropTypes.func.isRequired, + Click: PropTypes.func.isRequired, }; export default GridFieldAction; diff --git a/client/src/components/GridField/GridFieldCell.js b/client/src/components/GridField/GridFieldCell.js index fad76088b..cc6aa937c 100644 --- a/client/src/components/GridField/GridFieldCell.js +++ b/client/src/components/GridField/GridFieldCell.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class GridFieldCell extends Component { constructor(props) { @@ -34,8 +35,8 @@ class GridFieldCell extends Component { } GridFieldCell.PropTypes = { - className: React.PropTypes.string, - onDrillDown: React.PropTypes.func, + className: PropTypes.string, + onDrillDown: PropTypes.func, }; export default GridFieldCell; diff --git a/client/src/components/GridFieldActions/GridFieldActions.js b/client/src/components/GridFieldActions/GridFieldActions.js index 3e8dafddc..d954a2d0d 100644 --- a/client/src/components/GridFieldActions/GridFieldActions.js +++ b/client/src/components/GridFieldActions/GridFieldActions.js @@ -3,6 +3,7 @@ import { Button, DropdownItem } from 'reactstrap'; import GridFieldDropdownAction from './GridFieldDropdownAction'; import ActionMenu from '../ActionMenu/ActionMenu'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class GridFieldActions extends PureComponent { constructor(props) { @@ -92,9 +93,9 @@ class GridFieldActions extends PureComponent { } const actionShape = GridFieldDropdownAction.propTypes; -actionShape.group = React.PropTypes.string; +actionShape.group = PropTypes.string; -GridFieldActions.propTypes = React.PropTypes.arrayOf( +GridFieldActions.propTypes = PropTypes.arrayOf( React.PropTypes.shape(actionShape) ).isRequired; diff --git a/client/src/components/GridFieldActions/GridFieldDropdownAction.js b/client/src/components/GridFieldActions/GridFieldDropdownAction.js index e9b42befc..dccf9515c 100644 --- a/client/src/components/GridFieldActions/GridFieldDropdownAction.js +++ b/client/src/components/GridFieldActions/GridFieldDropdownAction.js @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import { DropdownItem } from 'reactstrap'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class GridFieldDropdownAction extends PureComponent { render() { @@ -38,10 +39,10 @@ class GridFieldDropdownAction extends PureComponent { } GridFieldDropdownAction.propTypes = { - data: React.PropTypes.object, - title: React.PropTypes.string.isRequired, - type: React.PropTypes.oneOf(['submit', 'link']), - url: React.PropTypes.string, + data: PropTypes.object, + title: PropTypes.string.isRequired, + type: PropTypes.oneOf(['submit', 'link']), + url: PropTypes.string, }; export default GridFieldDropdownAction; diff --git a/client/src/components/HeaderField/HeaderField.js b/client/src/components/HeaderField/HeaderField.js index 2349d505b..821219ab2 100644 --- a/client/src/components/HeaderField/HeaderField.js +++ b/client/src/components/HeaderField/HeaderField.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; class HeaderField extends Component { /** @@ -25,13 +26,13 @@ class HeaderField extends Component { } HeaderField.propTypes = { - extraClass: React.PropTypes.string, - id: React.PropTypes.string, - data: React.PropTypes.oneOfType([ - React.PropTypes.array, - React.PropTypes.shape({ - headingLevel: React.PropTypes.number, - title: React.PropTypes.string, + extraClass: PropTypes.string, + id: PropTypes.string, + data: PropTypes.oneOfType([ + PropTypes.array, + PropTypes.shape({ + headingLevel: PropTypes.number, + title: PropTypes.string, }), ]).isRequired, }; diff --git a/client/src/components/HiddenField/HiddenField.js b/client/src/components/HiddenField/HiddenField.js index 92fb734ff..9ed3f3858 100644 --- a/client/src/components/HiddenField/HiddenField.js +++ b/client/src/components/HiddenField/HiddenField.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import { Input } from 'reactstrap'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class HiddenField extends Component { /** @@ -26,10 +27,10 @@ class HiddenField extends Component { } HiddenField.propTypes = { - id: React.PropTypes.string, - extraClass: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - value: React.PropTypes.any, + id: PropTypes.string, + extraClass: PropTypes.string, + name: PropTypes.string.isRequired, + value: PropTypes.any, }; HiddenField.defaultProps = { diff --git a/client/src/components/HtmlReadonlyField/HtmlReadonlyField.js b/client/src/components/HtmlReadonlyField/HtmlReadonlyField.js index 50dd21298..99be46604 100644 --- a/client/src/components/HtmlReadonlyField/HtmlReadonlyField.js +++ b/client/src/components/HtmlReadonlyField/HtmlReadonlyField.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import fieldHolder from 'components/FieldHolder/FieldHolder'; import { Input } from 'reactstrap'; +import PropTypes from 'prop-types'; class HtmlReadonlyField extends Component { constructor(props) { @@ -46,10 +47,10 @@ class HtmlReadonlyField extends Component { } HtmlReadonlyField.propTypes = { - id: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - extraClass: React.PropTypes.string, - value: React.PropTypes.string, + id: PropTypes.string, + name: PropTypes.string.isRequired, + extraClass: PropTypes.string, + value: PropTypes.string, }; HtmlReadonlyField.defaultProps = { diff --git a/client/src/components/IframeDialog/IframeDialog.js b/client/src/components/IframeDialog/IframeDialog.js index e22148efc..b2493e8ba 100644 --- a/client/src/components/IframeDialog/IframeDialog.js +++ b/client/src/components/IframeDialog/IframeDialog.js @@ -1,6 +1,7 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; import { Modal, ModalHeader, ModalBody } from 'reactstrap'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class IframeDialog extends Component { constructor(props) { diff --git a/client/src/components/LabelField/LabelField.js b/client/src/components/LabelField/LabelField.js index da8fc352b..480412193 100644 --- a/client/src/components/LabelField/LabelField.js +++ b/client/src/components/LabelField/LabelField.js @@ -1,4 +1,5 @@ -import React, { PropTypes } from 'react'; +import React from 'react'; +import PropTypes from 'prop-types'; const LabelField = ({ id, className, title, extraClass, data }) => { const htmlFor = data && data.target; diff --git a/client/src/components/ListGroup/ListGroup.js b/client/src/components/ListGroup/ListGroup.js index 547e3fa26..a440bae16 100644 --- a/client/src/components/ListGroup/ListGroup.js +++ b/client/src/components/ListGroup/ListGroup.js @@ -1,5 +1,6 @@ import React from 'react'; import ListGroupItem from './ListGroupItem'; +import PropTypes from 'prop-types'; const ListGroup = (props) => (
@@ -8,7 +9,7 @@ const ListGroup = (props) => ( ); ListGroup.propTypes = { - items: React.PropTypes.array, + items: PropTypes.array, }; export default ListGroup; diff --git a/client/src/components/ListGroup/ListGroupItem.js b/client/src/components/ListGroup/ListGroupItem.js index 8fb3add04..43314f1cd 100644 --- a/client/src/components/ListGroup/ListGroupItem.js +++ b/client/src/components/ListGroup/ListGroupItem.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; class ListGroupItem extends Component { constructor(props) { @@ -23,8 +24,8 @@ class ListGroupItem extends Component { } ListGroupItem.propTypes = { - onClickArg: React.PropTypes.any, - onClick: React.PropTypes.func, + onClickArg: PropTypes.any, + onClick: PropTypes.func, }; export default ListGroupItem; diff --git a/client/src/components/LiteralField/LiteralField.js b/client/src/components/LiteralField/LiteralField.js index eae828920..456dd135b 100644 --- a/client/src/components/LiteralField/LiteralField.js +++ b/client/src/components/LiteralField/LiteralField.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; class LiteralField extends Component { /** @@ -37,10 +38,10 @@ class LiteralField extends Component { } LiteralField.propTypes = { - id: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - extraClass: React.PropTypes.string, - value: React.PropTypes.string, + id: PropTypes.string, + name: PropTypes.string.isRequired, + extraClass: PropTypes.string, + value: PropTypes.string, }; LiteralField.defaultProps = { diff --git a/client/src/components/Loading/Loading.js b/client/src/components/Loading/Loading.js index 4e4332c83..35deb2c6a 100644 --- a/client/src/components/Loading/Loading.js +++ b/client/src/components/Loading/Loading.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react'; +import PropTypes from 'prop-types'; /** * Renders a SilverStripe loading animation @@ -17,7 +18,7 @@ class Loading extends PureComponent { } Loading.propTypes = { - containerClass: React.PropTypes.string, + containerClass: PropTypes.string, }; Loading.defaultProps = { diff --git a/client/src/components/LookupField/LookupField.js b/client/src/components/LookupField/LookupField.js index 889b9cdca..192808b7b 100644 --- a/client/src/components/LookupField/LookupField.js +++ b/client/src/components/LookupField/LookupField.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import { Input } from 'reactstrap'; import fieldHolder from 'components/FieldHolder/FieldHolder'; import i18n from 'i18n'; +import PropTypes from 'prop-types'; class LookupField extends Component { constructor(props) { @@ -70,15 +71,15 @@ class LookupField extends Component { } LookupField.propTypes = { - extraClass: React.PropTypes.string, - id: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - source: React.PropTypes.arrayOf(React.PropTypes.shape({ - value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - title: React.PropTypes.any, - disabled: React.PropTypes.bool, + extraClass: PropTypes.string, + id: PropTypes.string, + name: PropTypes.string.isRequired, + source: PropTypes.arrayOf(PropTypes.shape({ + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + title: PropTypes.any, + disabled: PropTypes.bool, })), - value: React.PropTypes.any, + value: PropTypes.any, }; LookupField.defaultProps = { diff --git a/client/src/components/MobileMenuToggle/MobileMenuToggle.js b/client/src/components/MobileMenuToggle/MobileMenuToggle.js index 647019b9b..6fb96322a 100644 --- a/client/src/components/MobileMenuToggle/MobileMenuToggle.js +++ b/client/src/components/MobileMenuToggle/MobileMenuToggle.js @@ -1,5 +1,6 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class MobileMenuToggle extends Component { constructor() { diff --git a/client/src/components/NotFoundComponent/NotFoundComponent.js b/client/src/components/NotFoundComponent/NotFoundComponent.js index 616e83154..795815fd1 100644 --- a/client/src/components/NotFoundComponent/NotFoundComponent.js +++ b/client/src/components/NotFoundComponent/NotFoundComponent.js @@ -1,7 +1,8 @@ -import React, { PropTypes } from 'react'; +import React from 'react'; import i18n from 'i18n'; import classnames from 'classnames'; import FormAlert from 'components/FormAlert/FormAlert'; +import PropTypes from 'prop-types'; const NotFoundComponent = ({ itemName, name, value }) => (
diff --git a/client/src/components/OptionsetField/OptionField.js b/client/src/components/OptionsetField/OptionField.js index e9c2542ba..4b0aeaa44 100644 --- a/client/src/components/OptionsetField/OptionField.js +++ b/client/src/components/OptionsetField/OptionField.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import { FormGroup, Input, Label } from 'reactstrap'; import classnames from 'classnames'; import castStringToElement from 'lib/castStringToElement'; +import PropTypes from 'prop-types'; class OptionField extends Component { constructor(props) { @@ -83,20 +84,20 @@ class OptionField extends Component { } OptionField.propTypes = { - type: React.PropTypes.oneOf(['checkbox', 'radio']), - leftTitle: React.PropTypes.any, - title: React.PropTypes.any, - extraClass: React.PropTypes.string, - id: React.PropTypes.string, - name: React.PropTypes.string, - onChange: React.PropTypes.func, - value: React.PropTypes.oneOfType([ - React.PropTypes.string, - React.PropTypes.number, - React.PropTypes.bool, + type: PropTypes.oneOf(['checkbox', 'radio']), + leftTitle: PropTypes.any, + title: PropTypes.any, + extraClass: PropTypes.string, + id: PropTypes.string, + name: PropTypes.string, + onChange: PropTypes.func, + value: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + PropTypes.bool, ]), - readOnly: React.PropTypes.bool, - disabled: React.PropTypes.bool, + readOnly: PropTypes.bool, + disabled: PropTypes.bool, }; OptionField.defaultProps = { diff --git a/client/src/components/OptionsetField/OptionsetField.js b/client/src/components/OptionsetField/OptionsetField.js index 68d78345f..c6dbe9e24 100644 --- a/client/src/components/OptionsetField/OptionsetField.js +++ b/client/src/components/OptionsetField/OptionsetField.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import OptionField from 'components/OptionsetField/OptionField'; import fieldHolder from 'components/FieldHolder/FieldHolder'; +import PropTypes from 'prop-types'; class OptionsetField extends Component { constructor(props) { @@ -79,19 +80,19 @@ class OptionsetField extends Component { } OptionsetField.propTypes = { - extraClass: React.PropTypes.string, - itemClass: React.PropTypes.string, - id: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - source: React.PropTypes.arrayOf(React.PropTypes.shape({ - value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - title: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - disabled: React.PropTypes.bool, + extraClass: PropTypes.string, + itemClass: PropTypes.string, + id: PropTypes.string, + name: PropTypes.string.isRequired, + source: PropTypes.arrayOf(PropTypes.shape({ + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + disabled: PropTypes.bool, })), - onChange: React.PropTypes.func, - value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - readOnly: React.PropTypes.bool, - disabled: React.PropTypes.bool, + onChange: PropTypes.func, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + readOnly: PropTypes.bool, + disabled: PropTypes.bool, }; OptionsetField.defaultProps = { diff --git a/client/src/components/PopoverField/PopoverField.js b/client/src/components/PopoverField/PopoverField.js index d03c0b8eb..37b680049 100644 --- a/client/src/components/PopoverField/PopoverField.js +++ b/client/src/components/PopoverField/PopoverField.js @@ -1,6 +1,7 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import { Button, Popover, PopoverHeader, PopoverBody } from 'reactstrap'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class PopoverField extends Component { constructor(props) { diff --git a/client/src/components/Preview/Preview.js b/client/src/components/Preview/Preview.js index d297f3b86..f0670b74d 100644 --- a/client/src/components/Preview/Preview.js +++ b/client/src/components/Preview/Preview.js @@ -1,8 +1,9 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import i18n from 'i18n'; import ActionMenu from '../ActionMenu/ActionMenu'; import classnames from 'classnames'; import { inject } from 'lib/Injector'; +import PropTypes from 'prop-types'; /** * Renders the right-hand collapsable change preview panel @@ -120,11 +121,11 @@ class Preview extends Component { } Preview.propTypes = { - className: React.PropTypes.string, - itemLinks: React.PropTypes.object, - itemId: React.PropTypes.number, - onBack: React.PropTypes.func, - moreActions: React.PropTypes.arrayOf(React.PropTypes.element), + className: PropTypes.string, + itemLinks: PropTypes.object, + itemId: PropTypes.number, + onBack: PropTypes.func, + moreActions: PropTypes.arrayOf(PropTypes.element), ViewModeComponent: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), }; diff --git a/client/src/components/ResizeAware/ResizeAware.js b/client/src/components/ResizeAware/ResizeAware.js index 30135c53c..c9f2b2c48 100644 --- a/client/src/components/ResizeAware/ResizeAware.js +++ b/client/src/components/ResizeAware/ResizeAware.js @@ -1,6 +1,7 @@ import { createElement, Component, Children, - cloneElement, isValidElement, PropTypes } from 'react'; + cloneElement, isValidElement } from 'react'; import ResizeObserver from 'resize-observer-polyfill'; +import PropTypes from 'prop-types'; /** * Can be wrapped around a component to detect dimension changes. diff --git a/client/src/components/Search/Search.js b/client/src/components/Search/Search.js index cbf1e37e4..27f267b56 100644 --- a/client/src/components/Search/Search.js +++ b/client/src/components/Search/Search.js @@ -1,6 +1,6 @@ /* global document */ import i18n from 'i18n'; -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; import { connect } from 'react-redux'; import ReactDOM from 'react-dom'; import { bindActionCreators } from 'redux'; @@ -15,7 +15,7 @@ import SearchBox from './SearchBox'; import SearchForm from './SearchForm'; import SearchToggle from './SearchToggle'; import mapFormSchemaToTags from './utilities/mapFormSchemaToTags'; - +import PropTypes from 'prop-types'; const DISPLAY = { NONE: 'NONE', diff --git a/client/src/components/Search/SearchBox.js b/client/src/components/Search/SearchBox.js index e296add3c..2911a008e 100644 --- a/client/src/components/Search/SearchBox.js +++ b/client/src/components/Search/SearchBox.js @@ -1,12 +1,13 @@ /* global document window */ import i18n from 'i18n'; -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; import { Label, Button } from 'reactstrap'; import classNames from 'classnames'; import TagPropType from '../Tag/TagPropType'; import CompactTagList from 'components/Tag/CompactTagList'; import ResizeAware from 'components/ResizeAware/ResizeAware'; import ReactDOM from 'react-dom'; +import PropTypes from 'prop-types'; /** * Displays a search box and a few buttons related buttons. diff --git a/client/src/components/Search/SearchForm.js b/client/src/components/Search/SearchForm.js index f47ae3bb5..170cc7664 100644 --- a/client/src/components/Search/SearchForm.js +++ b/client/src/components/Search/SearchForm.js @@ -1,8 +1,9 @@ /* global document */ import i18n from 'i18n'; -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; import FormBuilderLoader from 'containers/FormBuilderLoader/FormBuilderLoader'; import { Collapse, Button } from 'reactstrap'; +import PropTypes from 'prop-types'; const searchLabel = i18n._t('Admin.SEARCH', 'Search'); const clearLabel = i18n._t('Admin.CLEAR', 'Clear'); diff --git a/client/src/components/Search/SearchToggle.js b/client/src/components/Search/SearchToggle.js index 927c523e2..af9b26475 100644 --- a/client/src/components/Search/SearchToggle.js +++ b/client/src/components/Search/SearchToggle.js @@ -1,7 +1,8 @@ import i18n from 'i18n'; -import React, { PropTypes } from 'react'; +import React from 'react'; import { Button } from 'reactstrap'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; const label = i18n._t('Admin.SHOW_SEARCH', 'Show search'); diff --git a/client/src/components/SingleSelectField/SingleSelectField.js b/client/src/components/SingleSelectField/SingleSelectField.js index 70834a8d4..d9bfe0c38 100644 --- a/client/src/components/SingleSelectField/SingleSelectField.js +++ b/client/src/components/SingleSelectField/SingleSelectField.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import fieldHolder from 'components/FieldHolder/FieldHolder'; import i18n from 'i18n'; import { Input } from 'reactstrap'; +import PropTypes from 'prop-types'; class SingleSelectField extends Component { constructor(props) { @@ -108,22 +109,22 @@ class SingleSelectField extends Component { } SingleSelectField.propTypes = { - id: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - onChange: React.PropTypes.func, - value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - readOnly: React.PropTypes.bool, - disabled: React.PropTypes.bool, - source: React.PropTypes.arrayOf(React.PropTypes.shape({ - value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - title: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - disabled: React.PropTypes.bool, + id: PropTypes.string, + name: PropTypes.string.isRequired, + onChange: PropTypes.func, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + readOnly: PropTypes.bool, + disabled: PropTypes.bool, + source: PropTypes.arrayOf(PropTypes.shape({ + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + disabled: PropTypes.bool, })), - data: React.PropTypes.oneOfType([ - React.PropTypes.array, - React.PropTypes.shape({ - hasEmptyDefault: React.PropTypes.bool, - emptyString: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), + data: PropTypes.oneOfType([ + PropTypes.array, + PropTypes.shape({ + hasEmptyDefault: PropTypes.bool, + emptyString: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), }), ]), }; diff --git a/client/src/components/Tabs/TabItem.js b/client/src/components/Tabs/TabItem.js index 11fc9ed22..1007ad8d1 100644 --- a/client/src/components/Tabs/TabItem.js +++ b/client/src/components/Tabs/TabItem.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import { Fade, TabPane } from 'reactstrap'; +import PropTypes from 'prop-types'; class TabItem extends Component { /** @@ -44,9 +45,9 @@ class TabItem extends Component { } TabItem.propTypes = { - name: React.PropTypes.string.isRequired, - extraClass: React.PropTypes.string, - tabClassName: React.PropTypes.string, + name: PropTypes.string.isRequired, + extraClass: PropTypes.string, + tabClassName: PropTypes.string, }; TabItem.defaultProps = { @@ -55,7 +56,7 @@ TabItem.defaultProps = { }; TabItem.contextTypes = { - activeTabId: React.PropTypes.string + activeTabId: PropTypes.string }; export default TabItem; diff --git a/client/src/components/Tabs/Tabs.js b/client/src/components/Tabs/Tabs.js index 1d7db026d..279e4121b 100644 --- a/client/src/components/Tabs/Tabs.js +++ b/client/src/components/Tabs/Tabs.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import { TabContent, Nav, NavItem, NavLink } from 'reactstrap'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; class Tabs extends Component { constructor(props) { @@ -134,9 +135,9 @@ class Tabs extends Component { } Tabs.propTypes = { - id: React.PropTypes.string.isRequired, - defaultActiveKey: React.PropTypes.string, - extraClass: React.PropTypes.string, + id: PropTypes.string.isRequired, + defaultActiveKey: PropTypes.string, + extraClass: PropTypes.string, }; Tabs.defaultProps = { diff --git a/client/src/components/Tag/CompactTagList.js b/client/src/components/Tag/CompactTagList.js index a9217a7a7..f479c153c 100644 --- a/client/src/components/Tag/CompactTagList.js +++ b/client/src/components/Tag/CompactTagList.js @@ -1,9 +1,10 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; import TagList from 'components/Tag/TagList'; import SummaryTag from './SummaryTag'; import ResizeAware from 'components/ResizeAware/ResizeAware'; import classnames from 'classnames'; import ReactDOM from 'react-dom'; +import PropTypes from 'prop-types'; /** * Extension of TagList that is aware of its size and switch to a summary view if greater than a diff --git a/client/src/components/Tag/SummaryTag.js b/client/src/components/Tag/SummaryTag.js index 0163f8452..50f1311dd 100644 --- a/client/src/components/Tag/SummaryTag.js +++ b/client/src/components/Tag/SummaryTag.js @@ -1,6 +1,7 @@ -import React, { PropTypes } from 'react'; +import React from 'react'; import Tag from 'components/Tag/Tag'; import i18n from 'i18n'; +import PropTypes from 'prop-types'; /** * Display a tag with a *filter* icons and a number to summarise a greater number of other tags. diff --git a/client/src/components/Tag/Tag.js b/client/src/components/Tag/Tag.js index 21d1ccb99..0fb68cebe 100644 --- a/client/src/components/Tag/Tag.js +++ b/client/src/components/Tag/Tag.js @@ -1,7 +1,8 @@ -import React, { PropTypes } from 'react'; +import React from 'react'; import { Button } from 'reactstrap'; import classnames from 'classnames'; import i18n from 'i18n'; +import PropTypes from 'prop-types'; /** * High jack some keys to fire off matching events. diff --git a/client/src/components/Tag/TagList.js b/client/src/components/Tag/TagList.js index 78284fd45..a667331e1 100644 --- a/client/src/components/Tag/TagList.js +++ b/client/src/components/Tag/TagList.js @@ -1,6 +1,7 @@ -import React, { PropTypes } from 'react'; +import React from 'react'; import Tag from 'components/Tag/Tag'; import TagPropType from './TagPropType'; +import PropTypes from 'prop-types'; /** * Whatever the focus should move forward. diff --git a/client/src/components/Tag/TagPropType.js b/client/src/components/Tag/TagPropType.js index 72e902393..1a4b95135 100644 --- a/client/src/components/Tag/TagPropType.js +++ b/client/src/components/Tag/TagPropType.js @@ -1,4 +1,4 @@ -import { PropTypes } from 'react'; +import PropTypes from 'prop-types'; const TagPropType = PropTypes.shape({ key: PropTypes.string.required, diff --git a/client/src/components/TextField/TextField.js b/client/src/components/TextField/TextField.js index 858f6d8ef..ef875c5d0 100644 --- a/client/src/components/TextField/TextField.js +++ b/client/src/components/TextField/TextField.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import fieldHolder from 'components/FieldHolder/FieldHolder'; import { Input } from 'reactstrap'; +import PropTypes from 'prop-types'; class TextField extends Component { constructor(props) { @@ -78,17 +79,17 @@ class TextField extends Component { } TextField.propTypes = { - extraClass: React.PropTypes.string, - id: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - onChange: React.PropTypes.func, - value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), - readOnly: React.PropTypes.bool, - disabled: React.PropTypes.bool, - placeholder: React.PropTypes.string, - type: React.PropTypes.string, - autoFocus: React.PropTypes.bool, - attributes: React.PropTypes.oneOfType([React.PropTypes.object, React.PropTypes.array]), + extraClass: PropTypes.string, + id: PropTypes.string, + name: PropTypes.string.isRequired, + onChange: PropTypes.func, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + readOnly: PropTypes.bool, + disabled: PropTypes.bool, + placeholder: PropTypes.string, + type: PropTypes.string, + autoFocus: PropTypes.bool, + attributes: PropTypes.oneOfType([PropTypes.object, PropTypes.array]), }; TextField.defaultProps = {