diff --git a/.eslintignore b/.eslintignore
index b04f9cd2..f574f775 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,10 @@
**/node_modules/
**/build/
+docs/
+spec/
lib
+karma.conf.js
+gulpfile.js
+tests.webpack*
+server.js
+webpack*
diff --git a/.eslintrc b/.eslintrc
index 136e551f..3c7ec891 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,227 +1,30 @@
{
+ "parser": "babel-eslint",
+ "extends": "airbnb",
"env": {
"browser": true,
"node": true,
- "mocha": true,
+ "jest": true,
"es6": true
},
-
- "ecmaFeatures": {
- "jsx": true,
- "templateStrings": true,
- "superInFunctions": false,
- "classes": true,
- "modules": true
- },
-
- "parser": "babel-eslint",
-
- "plugins": [
- "babel",
- "react"
- ],
-
"rules": {
- "block-scoped-var": [0],
- "brace-style": [2, "1tbs", {
- "allowSingleLine": true
- }],
- "camelcase": [0],
- "comma-dangle": [2, "never"],
- "comma-spacing": [2],
- "comma-style": [2, "last"],
- "complexity": [0, 11],
- "constructor-super": [2],
- "consistent-return": [0],
- "consistent-this": [0, "that"],
- "curly": [2, "multi-line"],
- "default-case": [2],
- "dot-notation": [2, {
- "allowKeywords": true
- }],
- "eol-last": [2],
- "eqeqeq": [2],
- "func-names": [0],
- "func-style": [0, "declaration"],
- "generator-star-spacing": [2, "after"],
- "guard-for-in": [0],
- "handle-callback-err": [0],
- "key-spacing": [2, {
- "beforeColon": false,
- "afterColon": true
- }],
- "quotes": [2, "single", "avoid-escape"],
- "max-depth": [0, 4],
- "max-len": [0, 80, 4],
- "max-nested-callbacks": [0, 2],
- "max-params": [0, 3],
- "max-statements": [0, 10],
- "new-parens": [2],
- "new-cap": [0],
- "newline-after-var": [0],
- "no-alert": [2],
- "no-array-constructor": [2],
- "no-bitwise": [0],
- "no-caller": [2],
- "no-catch-shadow": [2],
- "no-cond-assign": [2],
- "no-console": [0],
- "no-constant-condition": [1],
- "no-continue": [2],
- "no-control-regex": [2],
- "no-debugger": [2],
- "no-delete-var": [2],
- "no-div-regex": [0],
- "no-dupe-args": [2],
- "no-dupe-keys": [2],
- "no-duplicate-case": [2],
- "no-else-return": [0],
- "no-empty": [2],
- "no-empty-character-class": [2],
- "no-eq-null": [0],
- "no-eval": [2],
- "no-ex-assign": [2],
- "no-extend-native": [1],
- "no-extra-bind": [2],
- "no-extra-boolean-cast": [2],
- "no-extra-parens": [0],
- "no-extra-semi": [1],
- "no-fallthrough": [2],
- "no-floating-decimal": [2],
- "no-func-assign": [2],
- "no-implied-eval": [2],
- "no-inline-comments": [0],
- "no-inner-declarations": [2, "functions"],
- "no-invalid-regexp": [2],
- "no-irregular-whitespace": [2],
- "no-iterator": [2],
- "no-label-var": [2],
- "no-labels": [2],
- "no-lone-blocks": [2],
- "no-lonely-if": [2],
- "no-loop-func": [2],
- "no-mixed-requires": [0, false],
- "no-mixed-spaces-and-tabs": [2, false],
- "no-multi-spaces": [2],
- "no-multi-str": [2],
- "no-multiple-empty-lines": [2, {
- "max": 2
- }],
- "no-native-reassign": [1],
- "no-negated-in-lhs": [2],
- "no-nested-ternary": [0],
- "no-new": [2],
- "no-new-func": [2],
- "no-new-object": [2],
- "no-new-require": [0],
- "no-new-wrappers": [2],
- "no-obj-calls": [2],
- "no-octal": [2],
- "no-octal-escape": [2],
- "no-path-concat": [0],
- "no-param-reassign": [2],
- "no-plusplus": [0],
- "no-process-env": [0],
- "no-process-exit": [2],
- "no-proto": [2],
- "no-redeclare": [2],
- "no-regex-spaces": [2],
- "no-reserved-keys": [0],
- "no-restricted-modules": [0],
- "no-return-assign": [2],
- "no-script-url": [2],
- "no-self-compare": [0],
- "no-sequences": [2],
- "no-shadow": [2],
- "no-shadow-restricted-names": [2],
- "semi-spacing": [2],
- "no-spaced-func": [2],
- "no-sparse-arrays": [2],
- "no-sync": [0],
- "no-ternary": [0],
- "no-this-before-super": [2],
- "no-throw-literal": [2],
- "no-trailing-spaces": [2],
- "no-undef": [2],
- "no-undef-init": [2],
- "no-undefined": [0],
- "no-underscore-dangle": [0],
- "no-unreachable": [2],
- "no-unused-expressions": [2, {
- "allowShortCircuit": true
- }],
- "no-unused-vars": [1, {
- "vars": "all",
- "args": "after-used"
- }],
- "no-use-before-define": [2, "nofunc"],
- "no-var": [2],
- "no-void": [0],
- "no-warning-comments": [0, {
- "terms": ["todo", "fixme", "xxx"],
- "location": "start"
- }],
- "no-with": [2],
- "object-shorthand": [2],
- "one-var": [0],
- "operator-assignment": [0, "always"],
- "operator-linebreak": [2, "before"],
- "padded-blocks": [0],
- "prefer-const": [2],
- "prefer-spread": [2],
- "quote-props": [0],
- "radix": [0],
- "semi": [2],
- "sort-vars": [0],
- "keyword-spacing": [2, {"after": true}],
- "space-before-function-paren": [2, { "anonymous": "always", "named": "always" }],
- "space-before-blocks": [0, "always"],
- "space-in-brackets": [0, "never", {
- "singleValue": true,
- "arraysInArrays": false,
- "arraysInObjects": false,
- "objectsInArrays": true,
- "objectsInObjects": true,
- "propertyName": false
- }],
- "space-in-parens": [2, "never"],
- "space-infix-ops": [2],
- "space-unary-ops": [2, {
- "words": true,
- "nonwords": false
- }],
- "spaced-line-comment": [0, "always"],
- "strict": [1],
- "use-isnan": [2],
- "valid-jsdoc": [0],
- "valid-typeof": [2],
- "vars-on-top": [0],
- "wrap-iife": [2],
- "wrap-regex": [2],
- "yoda": [2, "never", {
- "exceptRange": true
- }],
- "react/display-name": 0,
- "react/jsx-boolean-value": 1,
- "react/jsx-closing-bracket-location": 0,
- "react/jsx-curly-spacing": 1,
- "react/jsx-max-props-per-line": 0,
- "react/jsx-indent-props": 0,
- "react/jsx-no-duplicate-props": 1,
- "react/jsx-no-undef": 1,
- "react/jsx-pascal-case": 1,
- "react/sort-prop-types": 1,
- "react/jsx-sort-props": 0,
- "react/jsx-uses-react": 1,
- "react/jsx-uses-vars": 1,
- "react/no-danger": 0,
- "react/no-did-mount-set-state": 0,
- "react/no-did-update-set-state": 1,
- "react/no-multi-comp": 0,
- "react/no-unknown-property": 1,
- "react/prop-types": [2, {"ignore": ["onMouseDown", "onTouchStart"]}],
- "react/react-in-jsx-scope": 1,
- "react/self-closing-comp": 1,
- "react/sort-comp": 1
+ "func-names": "off",
+ "global-require": "off",
+ "no-use-before-define": 0,
+ "no-underscore-dangle": 0,
+ "react/sort-prop-types": 2,
+ "react/jsx-no-bind": 2,
+ "react/require-default-props": 0,
+ "react/no-find-dom-node": 0,
+ "react/jsx-filename-extension": 0,
+ "import/prefer-default-export": 0,
+ "jsx-a11y/no-static-element-interactions": 0,
+ "import/no-extraneous-dependencies": [
+ "error", {
+ "devDependencies": true,
+ "optionalDependencies": false,
+ "peerDependencies": false
+ }
+ ]
}
}
diff --git a/components/app_bar/AppBar.js b/components/app_bar/AppBar.js
index f694f6cf..6e6aec44 100644
--- a/components/app_bar/AppBar.js
+++ b/components/app_bar/AppBar.js
@@ -1,8 +1,8 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { APP_BAR } from '../identifiers.js';
-import InjectIconButton from '../button/IconButton.js';
+import { APP_BAR } from '../identifiers';
+import InjectIconButton from '../button/IconButton';
const factory = (IconButton) => {
class AppBar extends React.Component {
@@ -13,13 +13,13 @@ const factory = (IconButton) => {
flat: PropTypes.bool,
leftIcon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
onLeftIconClick: PropTypes.func,
onRightIconClick: PropTypes.func,
rightIcon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
scrollHide: PropTypes.bool,
theme: PropTypes.shape({
@@ -30,27 +30,27 @@ const factory = (IconButton) => {
leftIcon: PropTypes.string,
rightIcon: PropTypes.string,
scrollHide: PropTypes.string,
- title: PropTypes.string
+ title: PropTypes.string,
}),
- title: PropTypes.node
+ title: PropTypes.node,
};
static defaultProps = {
className: '',
fixed: false,
flat: false,
- scrollHide: false
+ scrollHide: false,
};
- state = {hidden: false, height: 0};
+ state = { hidden: false, height: 0 };
- componentDidMount () {
+ componentDidMount() {
if (this.props.scrollHide) {
this.initializeScroll();
}
}
- componentWillReceiveProps (nextProps) {
+ componentWillReceiveProps(nextProps) {
if (!this.props.scrollHide && nextProps.scrollHide) {
this.initializeScroll();
}
@@ -60,7 +60,7 @@ const factory = (IconButton) => {
}
}
- componentWillUnmount () {
+ componentWillUnmount() {
if (this.props.scrollHide) {
this.endScroll();
}
@@ -70,7 +70,7 @@ const factory = (IconButton) => {
window.addEventListener('scroll', this.handleScroll);
const { height } = this.rootNode.getBoundingClientRect();
this.curScroll = window.scrollY;
- this.setState({height});
+ this.setState({ height });
};
endScroll = () => {
@@ -79,31 +79,42 @@ const factory = (IconButton) => {
handleScroll = () => {
const scrollDiff = this.curScroll - window.scrollY;
- const hidden = scrollDiff < 0 && window.scrollY !== undefined && window.scrollY > this.state.height;
- this.setState({hidden});
+ const hidden = scrollDiff < 0
+ && window.scrollY !== undefined
+ && window.scrollY > this.state.height;
+ this.setState({ hidden });
this.curScroll = window.scrollY;
};
- render () {
- const { children, leftIcon, onLeftIconClick, onRightIconClick, rightIcon, theme, title } = this.props;
+ render() {
+ const {
+ children,
+ leftIcon,
+ onLeftIconClick,
+ onRightIconClick,
+ rightIcon,
+ theme,
+ title,
+ } = this.props;
const className = classnames(theme.appBar, {
[theme.fixed]: this.props.fixed,
[theme.flat]: this.props.flat,
- [theme.scrollHide]: this.state.hidden
+ [theme.scrollHide]: this.state.hidden,
}, this.props.className);
return (
{this.rootNode = node;}}
+ data-react-toolbox="app-bar"
+ ref={(node) => { this.rootNode = node; }}
>
{leftIcon &&
+ icon={leftIcon}
+ />
}
{title &&
{title}
}
{children}
@@ -111,7 +122,8 @@ const factory = (IconButton) => {
inverse
className={classnames(theme.rightIcon)}
onClick={onRightIconClick}
- icon={rightIcon} />
+ icon={rightIcon}
+ />
}
diff --git a/components/app_bar/index.js b/components/app_bar/index.js
index 83d10d8e..ac09b55c 100644
--- a/components/app_bar/index.js
+++ b/components/app_bar/index.js
@@ -1,6 +1,6 @@
import { themr } from 'react-css-themr';
-import { APP_BAR } from '../identifiers.js';
-import { appBarFactory } from './AppBar.js';
+import { APP_BAR } from '../identifiers';
+import { appBarFactory } from './AppBar';
import { IconButton } from '../button';
import theme from './theme.css';
diff --git a/components/autocomplete/Autocomplete.js b/components/autocomplete/Autocomplete.js
index 32c6d647..636943d0 100644
--- a/components/autocomplete/Autocomplete.js
+++ b/components/autocomplete/Autocomplete.js
@@ -1,3 +1,4 @@
+/* eslint-disable */
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import classnames from 'classnames';
@@ -10,192 +11,191 @@ import events from '../utils/events.js';
const POSITION = {
AUTO: 'auto',
DOWN: 'down',
- UP: 'up'
+ UP: 'up',
};
const factory = (Chip, Input) => {
class Autocomplete extends Component {
- static propTypes = {
- allowCreate: PropTypes.bool,
- className: PropTypes.string,
- direction: PropTypes.oneOf(['auto', 'up', 'down']),
- disabled: PropTypes.bool,
- error: React.PropTypes.oneOfType([
- React.PropTypes.string,
- React.PropTypes.node
- ]),
- keepFocusOnChange: PropTypes.bool,
- label: React.PropTypes.oneOfType([
- React.PropTypes.string,
- React.PropTypes.node
- ]),
- multiple: PropTypes.bool,
- onBlur: PropTypes.func,
- onChange: PropTypes.func,
- onFocus: PropTypes.func,
- onQueryChange: PropTypes.func,
- query: PropTypes.string,
- selectedPosition: PropTypes.oneOf(['above', 'below', 'none']),
- showSelectedWhenNotInSource: PropTypes.bool,
- showSuggestionsWhenValueIsSet: PropTypes.bool,
- source: PropTypes.any,
- suggestionMatch: PropTypes.oneOf(['disabled', 'start', 'anywhere', 'word']),
- theme: PropTypes.shape({
- active: PropTypes.string,
- autocomplete: PropTypes.string,
- focus: PropTypes.string,
- input: PropTypes.string,
- suggestion: PropTypes.string,
- suggestions: PropTypes.string,
- up: PropTypes.string,
- value: PropTypes.string,
- values: PropTypes.string
- }),
- value: PropTypes.any
- };
+ static propTypes = {
+ allowCreate: PropTypes.bool,
+ className: PropTypes.string,
+ direction: PropTypes.oneOf(['auto', 'up', 'down']),
+ disabled: PropTypes.bool,
+ error: React.PropTypes.oneOfType([
+ React.PropTypes.string,
+ React.PropTypes.node,
+ ]),
+ keepFocusOnChange: PropTypes.bool,
+ label: React.PropTypes.oneOfType([
+ React.PropTypes.string,
+ React.PropTypes.node,
+ ]),
+ multiple: PropTypes.bool,
+ onBlur: PropTypes.func,
+ onChange: PropTypes.func,
+ onFocus: PropTypes.func,
+ onQueryChange: PropTypes.func,
+ query: PropTypes.string,
+ selectedPosition: PropTypes.oneOf(['above', 'below', 'none']),
+ showSelectedWhenNotInSource: PropTypes.bool,
+ showSuggestionsWhenValueIsSet: PropTypes.bool,
+ source: PropTypes.any,
+ suggestionMatch: PropTypes.oneOf(['disabled', 'start', 'anywhere', 'word']),
+ theme: PropTypes.shape({
+ active: PropTypes.string,
+ autocomplete: PropTypes.string,
+ focus: PropTypes.string,
+ input: PropTypes.string,
+ suggestion: PropTypes.string,
+ suggestions: PropTypes.string,
+ up: PropTypes.string,
+ value: PropTypes.string,
+ values: PropTypes.string,
+ }),
+ value: PropTypes.any,
+ };
- static defaultProps = {
- allowCreate: false,
- className: '',
- direction: 'auto',
- keepFocusOnChange: false,
- multiple: true,
- selectedPosition: 'above',
- showSelectedWhenNotInSource: false,
- showSuggestionsWhenValueIsSet: false,
- source: {},
- suggestionMatch: 'start'
- };
+ static defaultProps = {
+ allowCreate: false,
+ className: '',
+ direction: 'auto',
+ keepFocusOnChange: false,
+ multiple: true,
+ selectedPosition: 'above',
+ showSelectedWhenNotInSource: false,
+ showSuggestionsWhenValueIsSet: false,
+ source: {},
+ suggestionMatch: 'start',
+ };
- state = {
- direction: this.props.direction,
- focus: false,
- showAllSuggestions: this.props.showSuggestionsWhenValueIsSet,
- query: this.props.query ? this.props.query : this.query(this.props.value),
- isValueAnObject: false
- };
+ state = {
+ direction: this.props.direction,
+ focus: false,
+ showAllSuggestions: this.props.showSuggestionsWhenValueIsSet,
+ query: this.props.query ? this.props.query : this.query(this.props.value),
+ isValueAnObject: false,
+ };
- componentWillReceiveProps (nextProps) {
- if (!this.props.multiple) {
- const query = nextProps.query ? nextProps.query : this.query(nextProps.value);
- this.updateQuery(query, false);
- }
- }
+ componentWillReceiveProps(nextProps) {
+ if (!this.props.multiple) {
+ const query = nextProps.query ? nextProps.query : this.query(nextProps.value);
+ this.updateQuery(query, false);
+ }
+ }
- shouldComponentUpdate (nextProps, nextState) {
- if (!this.state.focus && nextState.focus && this.props.direction === POSITION.AUTO) {
- const direction = this.calculateDirection();
- if (this.state.direction !== direction) {
- this.setState({ direction });
- }
- }
- return true;
- }
+ shouldComponentUpdate(nextProps, nextState) {
+ if (!this.state.focus && nextState.focus && this.props.direction === POSITION.AUTO) {
+ const direction = this.calculateDirection();
+ if (this.state.direction !== direction) {
+ this.setState({ direction });
+ }
+ }
+ return true;
+ }
- handleChange = (values, event) => {
- const value = this.props.multiple ? values : values[0];
- const { showSuggestionsWhenValueIsSet: showAllSuggestions } = this.props;
- const query = this.query(value);
- if (this.props.onChange) this.props.onChange(value, event);
- if (this.props.keepFocusOnChange) {
- this.setState({ query, showAllSuggestions });
- } else {
- this.setState({ focus: false, query, showAllSuggestions }, () => {
- ReactDOM.findDOMNode(this).querySelector('input').blur();
- });
- }
- this.updateQuery(query, this.props.query);
- };
+ handleChange = (values, event) => {
+ const value = this.props.multiple ? values : values[0];
+ const { showSuggestionsWhenValueIsSet: showAllSuggestions } = this.props;
+ const query = this.query(value);
+ if (this.props.onChange) this.props.onChange(value, event);
+ if (this.props.keepFocusOnChange) {
+ this.setState({ query, showAllSuggestions });
+ } else {
+ this.setState({ focus: false, query, showAllSuggestions }, () => {
+ ReactDOM.findDOMNode(this).querySelector('input').blur();
+ });
+ }
+ this.updateQuery(query, this.props.query);
+ };
- handleMouseDown = (event) => {
- this.selectOrCreateActiveItem(event);
- }
+ handleMouseDown = (event) => {
+ this.selectOrCreateActiveItem(event);
+ }
- handleQueryBlur = (event) => {
- if (this.state.focus) this.setState({focus: false});
- if (this.props.onBlur) this.props.onBlur(event, this.state.active);
- };
+ handleQueryBlur = (event) => {
+ if (this.state.focus) this.setState({ focus: false });
+ if (this.props.onBlur) this.props.onBlur(event, this.state.active);
+ };
- updateQuery = (query, notify) => {
- if (notify && this.props.onQueryChange) this.props.onQueryChange(query);
- this.setState({ query });
- }
+ updateQuery = (query, notify) => {
+ if (notify && this.props.onQueryChange) this.props.onQueryChange(query);
+ this.setState({ query });
+ }
- handleQueryChange = (value) => {
- const query = this.clearQuery ? '' : value;
- this.clearQuery = false;
+ handleQueryChange = (value) => {
+ const query = this.clearQuery ? '' : value;
+ this.clearQuery = false;
- this.updateQuery(query, true);
- this.setState({showAllSuggestions: false, active: null});
- };
+ this.updateQuery(query, true);
+ this.setState({ showAllSuggestions: false, active: null });
+ };
- handleQueryFocus = (event) => {
- this.suggestionsNode.scrollTop = 0;
- this.setState({active: '', focus: true});
- if (this.props.onFocus) this.props.onFocus(event);
- };
+ handleQueryFocus = (event) => {
+ this.suggestionsNode.scrollTop = 0;
+ this.setState({ active: '', focus: true });
+ if (this.props.onFocus) this.props.onFocus(event);
+ };
- handleQueryKeyDown = (event) => {
+ handleQueryKeyDown = (event) => {
// Mark query for clearing in handleQueryChange when pressing backspace and showing all suggestions.
- this.clearQuery = (
+ this.clearQuery = (
event.which === 8
&& this.props.showSuggestionsWhenValueIsSet
&& this.state.showAllSuggestions
);
- if (event.which === 13) {
- this.selectOrCreateActiveItem(event);
- }
- };
+ if (event.which === 13) {
+ this.selectOrCreateActiveItem(event);
+ }
+ };
- handleQueryKeyUp = (event) => {
- if (event.which === 27) ReactDOM.findDOMNode(this).querySelector('input').blur();
+ handleQueryKeyUp = (event) => {
+ if (event.which === 27) ReactDOM.findDOMNode(this).querySelector('input').blur();
- if ([40, 38].indexOf(event.which) !== -1) {
- const suggestionsKeys = [...this.suggestions().keys()];
- let index = suggestionsKeys.indexOf(this.state.active) + (event.which === 40 ? +1 : -1);
- if (index < 0) index = suggestionsKeys.length - 1;
- if (index >= suggestionsKeys.length) index = 0;
- this.setState({active: suggestionsKeys[index]});
- }
- };
+ if ([40, 38].indexOf(event.which) !== -1) {
+ const suggestionsKeys = [...this.suggestions().keys()];
+ let index = suggestionsKeys.indexOf(this.state.active) + (event.which === 40 ? +1 : -1);
+ if (index < 0) index = suggestionsKeys.length - 1;
+ if (index >= suggestionsKeys.length) index = 0;
+ this.setState({ active: suggestionsKeys[index] });
+ }
+ };
- handleSuggestionHover = (event) => {
- this.setState({active: event.target.id});
- };
+ handleSuggestionHover = (event) => {
+ this.setState({ active: event.target.id });
+ };
- calculateDirection () {
- if (this.props.direction === 'auto') {
- const client = ReactDOM.findDOMNode(this.inputNode).getBoundingClientRect();
- const screen_height = window.innerHeight || document.documentElement.offsetHeight;
- const up = client.top > ((screen_height / 2) + client.height);
- return up ? 'up' : 'down';
- } else {
- return this.props.direction;
- }
- }
+ calculateDirection() {
+ if (this.props.direction === 'auto') {
+ const client = ReactDOM.findDOMNode(this.inputNode).getBoundingClientRect();
+ const screen_height = window.innerHeight || document.documentElement.offsetHeight;
+ const up = client.top > ((screen_height / 2) + client.height);
+ return up ? 'up' : 'down';
+ }
+ return this.props.direction;
+ }
- query (key) {
+ query(key) {
let query_value = '';
if (!this.props.multiple && key) {
const source_value = this.source().get(`${key}`);
- query_value = source_value ? source_value : key;
+ query_value = source_value || key;
}
return query_value;
- }
+ }
- selectOrCreateActiveItem (event) {
- let target = this.state.active;
- if (!target) {
- target = this.props.allowCreate
+ selectOrCreateActiveItem(event) {
+ let target = this.state.active;
+ if (!target) {
+ target = this.props.allowCreate
? this.state.query
: [...this.suggestions().keys()][0];
- this.setState({active: target});
- }
- this.select(event, target);
- }
+ this.setState({ active: target });
+ }
+ this.select(event, target);
+ }
- normalise (value) {
+ normalise(value) {
const sdiak = 'áâäąáâäąččććççĉĉďđďđééěëēėęéěëēėęĝĝğğġġģģĥĥħħíîíîĩĩīīĭĭįįi̇ıĵĵķķĸĺĺļļŀŀłłĺľĺľňńņŋŋņňńʼnóöôőøōōóöőôøřřŕŕŗŗššśśŝŝşşţţťťŧŧũũūūŭŭůůűűúüúüűųųŵŵýyŷŷýyžžźźżżß';
const bdiak = 'AAAAAAAACCCCCCCCDDDDEEEEEEEEEEEEEGGGGGGGGHHHHIIIIIIIIIIIIIIJJKKKLLLLLLLLLLLLNNNNNNNNNOOOOOOOOOOOORRRRRRSSSSSSSSTTTTTTUUUUUUUUUUUUUUUUUWWYYYYYYZZZZZZS';
@@ -209,209 +209,206 @@ const factory = (Chip, Input) => {
}
return normalised.toLowerCase().trim();
- }
+ }
- suggestions () {
- let suggest = new Map();
- const rawQuery = this.state.query || (this.props.multiple ? '' : this.props.value);
- const query = this.normalise((`${rawQuery}`));
- const values = this.values();
- const source = this.source();
+ suggestions() {
+ let suggest = new Map();
+ const rawQuery = this.state.query || (this.props.multiple ? '' : this.props.value);
+ const query = this.normalise((`${rawQuery}`));
+ const values = this.values();
+ const source = this.source();
// Suggest any non-set value which matches the query
- if (this.props.multiple) {
- for (const [key, value] of source) {
- if (!values.has(key) && this.matches(this.normalise(value), query)) {
- suggest.set(key, value);
- }
- }
+ if (this.props.multiple) {
+ for (const [key, value] of source) {
+ if (!values.has(key) && this.matches(this.normalise(value), query)) {
+ suggest.set(key, value);
+ }
+ }
// When multiple is false, suggest any value which matches the query if showAllSuggestions is false
- } else if (query && !this.state.showAllSuggestions) {
- for (const [key, value] of source) {
- if (this.matches(this.normalise(value), query)) {
- suggest.set(key, value);
- }
- }
+ } else if (query && !this.state.showAllSuggestions) {
+ for (const [key, value] of source) {
+ if (this.matches(this.normalise(value), query)) {
+ suggest.set(key, value);
+ }
+ }
// When multiple is false, suggest all values when showAllSuggestions is true
- } else {
- suggest = source;
- }
+ } else {
+ suggest = source;
+ }
- return suggest;
- }
+ return suggest;
+ }
- matches (value, query) {
- const { suggestionMatch } = this.props;
+ matches(value, query) {
+ const { suggestionMatch } = this.props;
- if (suggestionMatch === 'disabled') {
- return true;
- } else if (suggestionMatch === 'start') {
- return value.startsWith(query);
- } else if (suggestionMatch === 'anywhere') {
- return value.includes(query);
- } else if (suggestionMatch === 'word') {
- const re = new RegExp(`\\b${query}`, 'g');
- return re.test(value);
- }
+ if (suggestionMatch === 'disabled') {
+ return true;
+ } else if (suggestionMatch === 'start') {
+ return value.startsWith(query);
+ } else if (suggestionMatch === 'anywhere') {
+ return value.includes(query);
+ } else if (suggestionMatch === 'word') {
+ const re = new RegExp(`\\b${query}`, 'g');
+ return re.test(value);
+ }
- return false;
- }
+ return false;
+ }
- source () {
- const { source: src } = this.props;
- if (src.hasOwnProperty('length')) {
- return new Map(src.map((item) => Array.isArray(item) ? [...item] : [item, item]));
- } else {
- return new Map(Object.keys(src).map((key) => [`${key}`, src[key]]));
- }
- }
+ source() {
+ const { source: src } = this.props;
+ if (src.hasOwnProperty('length')) {
+ return new Map(src.map(item => Array.isArray(item) ? [...item] : [item, item]));
+ }
+ return new Map(Object.keys(src).map(key => [`${key}`, src[key]]));
+ }
- values () {
- let vals = this.props.multiple ? this.props.value : [this.props.value];
+ values() {
+ let vals = this.props.multiple ? this.props.value : [this.props.value];
- if (!vals) vals = [];
+ if (!vals) vals = [];
- if (this.props.showSelectedWhenNotInSource && this.isValueAnObject()) {
- return new Map(Object.entries(vals));
- }
+ if (this.props.showSelectedWhenNotInSource && this.isValueAnObject()) {
+ return new Map(Object.entries(vals));
+ }
- const valueMap = new Map();
+ const valueMap = new Map();
- const stringVals = vals.map(v => `${v}`);
- for (const [k, v] of this.source()) {
- if (stringVals.indexOf(k) !== -1) valueMap.set(k, v);
- }
+ const stringVals = vals.map(v => `${v}`);
+ for (const [k, v] of this.source()) {
+ if (stringVals.indexOf(k) !== -1) valueMap.set(k, v);
+ }
- return valueMap;
- }
+ return valueMap;
+ }
- select = (event, target) => {
- events.pauseEvent(event);
- const values = this.values(this.props.value);
- const source = this.source();
- const newValue = target === void 0 ? event.target.id : target;
+ select = (event, target) => {
+ events.pauseEvent(event);
+ const values = this.values(this.props.value);
+ const source = this.source();
+ const newValue = target === void 0 ? event.target.id : target;
- if (this.isValueAnObject()) {
- const newItem = Array.from(source).reduce((obj, [k, value]) => {
- if (k === newValue) {
- obj[k] = value;
- }
- return obj;
- }, {});
+ if (this.isValueAnObject()) {
+ const newItem = Array.from(source).reduce((obj, [k, value]) => {
+ if (k === newValue) {
+ obj[k] = value;
+ }
+ return obj;
+ }, {});
- return this.handleChange(Object.assign(this.mapToObject(values), newItem), event);
- }
+ return this.handleChange(Object.assign(this.mapToObject(values), newItem), event);
+ }
- this.handleChange([newValue, ...values.keys()], event);
- };
+ this.handleChange([newValue, ...values.keys()], event);
+ };
- unselect (key, event) {
- if (!this.props.disabled) {
- const values = this.values(this.props.value);
+ unselect(key, event) {
+ if (!this.props.disabled) {
+ const values = this.values(this.props.value);
- values.delete(key);
+ values.delete(key);
- if (this.isValueAnObject()) {
- return this.handleChange(this.mapToObject(values), event);
- }
+ if (this.isValueAnObject()) {
+ return this.handleChange(this.mapToObject(values), event);
+ }
- this.handleChange([...values.keys()], event);
- }
- }
+ this.handleChange([...values.keys()], event);
+ }
+ }
- isValueAnObject () {
+ isValueAnObject() {
return !Array.isArray(this.props.value) && typeof this.props.value === 'object';
- }
+ }
- mapToObject (map) {
+ mapToObject(map) {
return Array.from(map).reduce((obj, [k, value]) => {
obj[k] = value;
return obj;
}, {});
- }
+ }
- renderSelected () {
- if (this.props.multiple) {
- const selectedItems = [...this.values()].map(([key, value]) => {
- return (
-
- {value}
-
- );
- });
+ renderSelected() {
+ if (this.props.multiple) {
+ const selectedItems = [...this.values()].map(([key, value]) => (
+
+ {value}
+
+ ));
- return ;
- }
- }
+ return ;
+ }
+ }
- renderSuggestions () {
- const { theme } = this.props;
- const suggestions = [...this.suggestions()].map(([key, value]) => {
- const className = classnames(theme.suggestion, {[theme.active]: this.state.active === key});
- return (
-
- {value}
-
- );
- });
+ renderSuggestions() {
+ const { theme } = this.props;
+ const suggestions = [...this.suggestions()].map(([key, value]) => {
+ const className = classnames(theme.suggestion, { [theme.active]: this.state.active === key });
+ return (
+
+ {value}
+
+ );
+ });
- return (
- { this.suggestionsNode = node; }}
- >
- {suggestions}
-
- );
- }
+ return (
+ { this.suggestionsNode = node; }}
+ >
+ {suggestions}
+
+ );
+ }
- render () {
- const {
- allowCreate, error, label, source, suggestionMatch, query, //eslint-disable-line no-unused-vars
- selectedPosition, keepFocusOnChange, showSuggestionsWhenValueIsSet, showSelectedWhenNotInSource, onQueryChange, //eslint-disable-line no-unused-vars
+ render() {
+ const {
+ allowCreate, error, label, source, suggestionMatch, query, // eslint-disable-line no-unused-vars
+ selectedPosition, keepFocusOnChange, showSuggestionsWhenValueIsSet, showSelectedWhenNotInSource, onQueryChange, // eslint-disable-line no-unused-vars
theme, ...other
} = this.props;
- const className = classnames(theme.autocomplete, {
- [theme.focus]: this.state.focus
- }, this.props.className);
+ const className = classnames(theme.autocomplete, {
+ [theme.focus]: this.state.focus,
+ }, this.props.className);
- return (
-
- {this.props.selectedPosition === 'above' ? this.renderSelected() : null}
- { this.inputNode = node; }}
- autoComplete="off"
- className={theme.input}
- error={error}
- label={label}
- onBlur={this.handleQueryBlur}
- onChange={this.handleQueryChange}
- onFocus={this.handleQueryFocus}
- onKeyDown={this.handleQueryKeyDown}
- onKeyUp={this.handleQueryKeyUp}
- theme={theme}
- themeNamespace="input"
- value={this.state.query}
- />
- {this.renderSuggestions()}
- {this.props.selectedPosition === 'below' ? this.renderSelected() : null}
-
- );
- }
+ return (
+
+ {this.props.selectedPosition === 'above' ? this.renderSelected() : null}
+ { this.inputNode = node; }}
+ autoComplete="off"
+ className={theme.input}
+ error={error}
+ label={label}
+ onBlur={this.handleQueryBlur}
+ onChange={this.handleQueryChange}
+ onFocus={this.handleQueryFocus}
+ onKeyDown={this.handleQueryKeyDown}
+ onKeyUp={this.handleQueryKeyUp}
+ theme={theme}
+ themeNamespace="input"
+ value={this.state.query}
+ />
+ {this.renderSuggestions()}
+ {this.props.selectedPosition === 'below' ? this.renderSelected() : null}
+
+ );
+ }
}
return Autocomplete;
diff --git a/components/autocomplete/index.js b/components/autocomplete/index.js
index 1f0842ed..a0fa86cb 100644
--- a/components/autocomplete/index.js
+++ b/components/autocomplete/index.js
@@ -1,8 +1,8 @@
-import { AUTOCOMPLETE } from '../identifiers.js';
import { themr } from 'react-css-themr';
-import { autocompleteFactory } from './Autocomplete.js';
-import Chip from '../chip';
-import Input from '../input';
+import { AUTOCOMPLETE } from '../identifiers';
+import { autocompleteFactory } from './Autocomplete';
+import { Chip } from '../chip';
+import { Input } from '../input';
import theme from './theme.css';
const Autocomplete = autocompleteFactory(Chip, Input);
diff --git a/components/avatar/Avatar.js b/components/avatar/Avatar.js
index 7579b35a..e73ebe99 100644
--- a/components/avatar/Avatar.js
+++ b/components/avatar/Avatar.js
@@ -1,14 +1,14 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { AVATAR } from '../identifiers.js';
-import InjectFontIcon from '../font_icon/FontIcon.js';
+import { AVATAR } from '../identifiers';
+import InjectFontIcon from '../font_icon/FontIcon';
const factory = (FontIcon) => {
- const Avatar = ({alt, children, className, cover, icon, image, theme, title, ...other}) => (
-
+ const Avatar = ({ alt, children, className, cover, icon, image, theme, title, ...other }) => (
+
{children}
- {cover && typeof image === 'string' &&
}
+ {cover && typeof image === 'string' &&
}
{!cover && (typeof image === 'string' ?
: image)}
{typeof icon === 'string' ?
: icon}
{title ?
{title[0]} : null}
@@ -25,14 +25,14 @@ const factory = (FontIcon) => {
theme: PropTypes.shape({
avatar: PropTypes.string,
image: PropTypes.string,
- letter: PropTypes.string
+ letter: PropTypes.string,
}),
- title: PropTypes.string
+ title: PropTypes.string,
};
Avatar.defaultProps = {
alt: '',
- cover: false
+ cover: false,
};
return Avatar;
diff --git a/components/avatar/index.js b/components/avatar/index.js
index 6b2896bc..1bb9d9bc 100644
--- a/components/avatar/index.js
+++ b/components/avatar/index.js
@@ -1,7 +1,7 @@
-import { AVATAR } from '../identifiers.js';
import { themr } from 'react-css-themr';
-import { avatarFactory } from './Avatar.js';
-import FontIcon from '../font_icon/FontIcon.js';
+import { AVATAR } from '../identifiers';
+import { avatarFactory } from './Avatar';
+import { FontIcon } from '../font_icon/FontIcon';
import theme from './theme.css';
const Avatar = avatarFactory(FontIcon);
diff --git a/components/button/BrowseButton.js b/components/button/BrowseButton.js
index 50d17d73..199b27c6 100644
--- a/components/button/BrowseButton.js
+++ b/components/button/BrowseButton.js
@@ -1,9 +1,9 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { BUTTON } from '../identifiers.js';
-import InjectFontIcon from '../font_icon/FontIcon.js';
-import rippleFactory from '../ripple/Ripple.js';
+import { BUTTON } from '../identifiers';
+import InjectFontIcon from '../font_icon/FontIcon';
+import rippleFactory from '../ripple/Ripple';
const factory = (ripple, FontIcon) => {
class SimpleBrowseButton extends Component {
@@ -16,7 +16,7 @@ const factory = (ripple, FontIcon) => {
floating: PropTypes.bool,
icon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
inverse: PropTypes.bool,
label: PropTypes.string,
@@ -39,9 +39,9 @@ const factory = (ripple, FontIcon) => {
primary: PropTypes.string,
raised: PropTypes.string,
rippleWrapper: PropTypes.string,
- toggle: PropTypes.string
+ toggle: PropTypes.string,
}),
- type: PropTypes.string
+ type: PropTypes.string,
};
static defaultProps = {
@@ -52,16 +52,28 @@ const factory = (ripple, FontIcon) => {
mini: false,
neutral: true,
primary: false,
- raised: false
+ raised: false,
};
+ getLevel = () => {
+ if (this.props.primary) return 'primary';
+ if (this.props.accent) return 'accent';
+ return 'neutral';
+ }
+
+ getShape = () => {
+ if (this.props.raised) return 'raised';
+ if (this.props.floating) return 'floating';
+ return 'flat';
+ }
+
handleMouseUp = (event) => {
- this.refs.label.blur();
+ this.labelNode.blur();
if (this.props.onMouseUp) this.props.onMouseUp(event);
};
handleMouseLeave = (event) => {
- this.refs.label.blur();
+ this.labelNode.blur();
if (this.props.onMouseLeave) this.props.onMouseLeave(event);
};
@@ -69,34 +81,48 @@ const factory = (ripple, FontIcon) => {
if (this.props.onChange) this.props.onChange(event);
};
- render () {
- const { accent, children, className, flat, floating, icon,
- inverse, label, mini, neutral, primary, theme, raised, ...others} = this.props;
- const element = 'label';
- const level = primary ? 'primary' : accent ? 'accent' : 'neutral';
- const shape = flat ? 'flat' : raised ? 'raised' : floating ? 'floating' : 'flat';
+ render() {
+ const {
+ accent, // eslint-disable-line
+ children,
+ className,
+ flat, // eslint-disable-line
+ floating, // eslint-disable-line
+ icon,
+ inverse,
+ label,
+ mini,
+ neutral,
+ primary, // eslint-disable-line
+ raised, // eslint-disable-line
+ theme,
+ ...others
+ } = this.props;
+ const element = 'label';
+ const level = this.getLevel();
+ const shape = this.getShape();
- const classes = classnames(theme.button, [theme[shape]], {
- [theme[level]]: neutral,
- [theme.mini]: mini,
- [theme.inverse]: inverse
- }, className);
+ const classes = classnames(theme.button, [theme[shape]], {
+ [theme[level]]: neutral,
+ [theme.mini]: mini,
+ [theme.inverse]: inverse,
+ }, className);
- const props = {
- ...others,
- ref: 'label',
- className: classes,
- disabled: this.props.disabled,
- onMouseUp: this.handleMouseUp,
- onMouseLeave: this.handleMouseLeave,
- 'data-react-toolbox': 'label'
- };
+ const props = {
+ ...others,
+ ref: (node) => { this.labelNode = node; },
+ className: classes,
+ disabled: this.props.disabled,
+ onMouseUp: this.handleMouseUp,
+ onMouseLeave: this.handleMouseLeave,
+ 'data-react-toolbox': 'label',
+ };
- return React.createElement(element, props,
- icon ?
: null,
- {label},
- ,
- children
+ return React.createElement(element, props,
+ icon ? : null,
+ {label},
+ ,
+ children,
);
}
}
diff --git a/components/button/Button.js b/components/button/Button.js
index 3ffc90aa..5584e3ff 100644
--- a/components/button/Button.js
+++ b/components/button/Button.js
@@ -1,9 +1,9 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { BUTTON } from '../identifiers.js';
-import InjectFontIcon from '../font_icon/FontIcon.js';
-import rippleFactory from '../ripple/Ripple.js';
+import { BUTTON } from '../identifiers';
+import InjectFontIcon from '../font_icon/FontIcon';
+import rippleFactory from '../ripple/Ripple';
const factory = (ripple, FontIcon) => {
class Button extends Component {
@@ -17,7 +17,7 @@ const factory = (ripple, FontIcon) => {
href: PropTypes.string,
icon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
inverse: PropTypes.bool,
label: PropTypes.string,
@@ -39,9 +39,9 @@ const factory = (ripple, FontIcon) => {
primary: PropTypes.string,
raised: PropTypes.string,
rippleWrapper: PropTypes.string,
- toggle: PropTypes.string
+ toggle: PropTypes.string,
}),
- type: PropTypes.string
+ type: PropTypes.string,
};
static defaultProps = {
@@ -53,48 +53,76 @@ const factory = (ripple, FontIcon) => {
neutral: true,
primary: false,
raised: false,
- type: 'button'
+ type: 'button',
};
+ getLevel = () => {
+ if (this.props.primary) return 'primary';
+ if (this.props.accent) return 'accent';
+ return 'neutral';
+ }
+
+ getShape = () => {
+ if (this.props.raised) return 'raised';
+ if (this.props.floating) return 'floating';
+ return 'flat';
+ }
+
handleMouseUp = (event) => {
- this.refs.button.blur();
+ this.buttonNode.blur();
if (this.props.onMouseUp) this.props.onMouseUp(event);
};
handleMouseLeave = (event) => {
- this.refs.button.blur();
+ this.buttonNode.blur();
if (this.props.onMouseLeave) this.props.onMouseLeave(event);
};
- render () {
- const { accent, children, className, flat, floating, href, icon,
- inverse, label, mini, neutral, primary, theme, type, raised, ...others} = this.props;
+ render() {
+ const {
+ accent, // eslint-disable-line
+ children,
+ className,
+ flat, // eslint-disable-line
+ floating, // eslint-disable-line
+ href,
+ icon,
+ inverse,
+ label,
+ mini,
+ neutral,
+ primary, // eslint-disable-line
+ raised, // eslint-disable-line
+ theme,
+ type,
+ ...others
+ } = this.props;
const element = href ? 'a' : 'button';
- const level = primary ? 'primary' : accent ? 'accent' : 'neutral';
- const shape = flat ? 'flat' : raised ? 'raised' : floating ? 'floating' : 'flat';
+ const level = this.getLevel();
+ const shape = this.getShape();
const classes = classnames(theme.button, [theme[shape]], {
[theme[level]]: neutral,
[theme.mini]: mini,
- [theme.inverse]: inverse
+ [theme.inverse]: inverse,
}, className);
const props = {
...others,
href,
- ref: 'button',
+ ref: (node) => { this.buttonNode = node; },
className: classes,
disabled: this.props.disabled,
onMouseUp: this.handleMouseUp,
onMouseLeave: this.handleMouseLeave,
type: !href ? type : null,
- 'data-react-toolbox': 'button'
+ 'data-react-toolbox': 'button',
};
return React.createElement(element, props,
- icon ? : null,
+ icon ? : null,
label,
- children
+ children,
);
}
}
diff --git a/components/button/IconButton.js b/components/button/IconButton.js
index d0cec6eb..14992756 100644
--- a/components/button/IconButton.js
+++ b/components/button/IconButton.js
@@ -1,9 +1,9 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { BUTTON } from '../identifiers.js';
-import InjectFontIcon from '../font_icon/FontIcon.js';
-import rippleFactory from '../ripple/Ripple.js';
+import { BUTTON } from '../identifiers';
+import InjectFontIcon from '../font_icon/FontIcon';
+import rippleFactory from '../ripple/Ripple';
const factory = (ripple, FontIcon) => {
class IconButton extends Component {
@@ -15,15 +15,28 @@ const factory = (ripple, FontIcon) => {
href: PropTypes.string,
icon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
inverse: PropTypes.bool,
neutral: PropTypes.bool,
onMouseLeave: PropTypes.func,
onMouseUp: PropTypes.func,
primary: PropTypes.bool,
- theme: PropTypes.object,
- type: PropTypes.string
+ theme: PropTypes.shape({
+ accent: PropTypes.string,
+ button: PropTypes.string,
+ flat: PropTypes.string,
+ floating: PropTypes.string,
+ icon: PropTypes.string,
+ inverse: PropTypes.string,
+ mini: PropTypes.string,
+ neutral: PropTypes.string,
+ primary: PropTypes.string,
+ raised: PropTypes.string,
+ rippleWrapper: PropTypes.string,
+ toggle: PropTypes.string,
+ }),
+ type: PropTypes.string,
};
static defaultProps = {
@@ -31,44 +44,65 @@ const factory = (ripple, FontIcon) => {
className: '',
neutral: true,
primary: false,
- type: 'button'
+ type: 'button',
};
+ getLevel = () => {
+ if (this.props.primary) return 'primary';
+ if (this.props.accent) return 'accent';
+ return 'neutral';
+ }
+
handleMouseUp = (event) => {
- this.refs.button.blur();
+ this.buttonNode.blur();
if (this.props.onMouseUp) this.props.onMouseUp(event);
};
handleMouseLeave = (event) => {
- this.refs.button.blur();
+ this.buttonNode.blur();
if (this.props.onMouseLeave) this.props.onMouseLeave(event);
};
- render () {
- const {accent, children, className, href, icon, inverse, neutral,
- primary, theme, type, ...others} = this.props;
+ render() {
+ const {
+ accent, // eslint-disable-line
+ children,
+ className,
+ href,
+ icon,
+ inverse,
+ neutral,
+ primary, // eslint-disable-line
+ theme,
+ type,
+ ...others
+ } = this.props;
const element = href ? 'a' : 'button';
- const level = primary ? 'primary' : accent ? 'accent' : 'neutral';
+ const level = this.getLevel();
const classes = classnames([theme.toggle], {
[theme[level]]: neutral,
- [theme.inverse]: inverse
+ [theme.inverse]: inverse,
}, className);
const props = {
...others,
href,
- ref: 'button',
+ ref: (node) => { this.buttonNode = node; },
className: classes,
disabled: this.props.disabled,
onMouseUp: this.handleMouseUp,
onMouseLeave: this.handleMouseLeave,
type: !href ? type : null,
- 'data-react-toolbox': 'button'
+ 'data-react-toolbox': 'button',
};
+ const iconElement = typeof icon === 'string'
+ ?
+ : icon;
+
return React.createElement(element, props,
- icon ? typeof icon === 'string' ? : icon : null,
- children
+ icon && iconElement,
+ children,
);
}
}
@@ -76,7 +110,7 @@ const factory = (ripple, FontIcon) => {
return ripple(IconButton);
};
-const IconButton = factory(rippleFactory({centered: true}), InjectFontIcon);
+const IconButton = factory(rippleFactory({ centered: true }), InjectFontIcon);
export default themr(BUTTON)(IconButton);
export { factory as iconButtonFactory };
export { IconButton };
diff --git a/components/button/__test__/index.spec.js b/components/button/__test__/index.spec.js
index e217195d..1e83db91 100644
--- a/components/button/__test__/index.spec.js
+++ b/components/button/__test__/index.spec.js
@@ -1,3 +1,4 @@
+/* eslint-disable */
import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
@@ -10,23 +11,23 @@ const getRenderedClassName = (tree, Component) => {
return ReactDOM.findDOMNode(rendered).getAttribute('class');
};
-describe('Button', function () {
- describe('#render', function () {
- it('uses flat and neutral styles by default', function () {
+describe('Button', () => {
+ describe('#render', () => {
+ it('uses flat and neutral styles by default', () => {
const tree = TestUtils.renderIntoDocument();
const className = getRenderedClassName(tree, RawButton);
expect(className).toContain(theme.flat);
expect(className).toContain(theme.neutral);
});
- it('renders accent button with accent style', function () {
+ it('renders accent button with accent style', () => {
const tree = TestUtils.renderIntoDocument();
const className = getRenderedClassName(tree, RawButton);
expect(className).toContain(theme.flat);
expect(className).toContain(theme.accent);
});
- it('renders mini button with mini style', function () {
+ it('renders mini button with mini style', () => {
const tree = TestUtils.renderIntoDocument();
const className = getRenderedClassName(tree, RawButton);
expect(className).toContain(theme.floating);
@@ -34,7 +35,7 @@ describe('Button', function () {
expect(className).toContain(theme.mini);
});
- it('renders mini accented button with both styles', function () {
+ it('renders mini accented button with both styles', () => {
const tree = TestUtils.renderIntoDocument();
const className = getRenderedClassName(tree, RawButton);
expect(className).toContain(theme.flat);
diff --git a/components/button/index.js b/components/button/index.js
index 5baa93eb..003bc355 100644
--- a/components/button/index.js
+++ b/components/button/index.js
@@ -1,14 +1,14 @@
-import { BUTTON } from '../identifiers.js';
import { themr } from 'react-css-themr';
-import { buttonFactory } from './Button.js';
-import { browseButtonFactory } from './BrowseButton.js';
-import { iconButtonFactory } from './IconButton.js';
-import FontIcon from '../font_icon/FontIcon.js';
+import { BUTTON } from '../identifiers';
+import { buttonFactory } from './Button';
+import { browseButtonFactory } from './BrowseButton';
+import { iconButtonFactory } from './IconButton';
+import { FontIcon } from '../font_icon/FontIcon';
import themedRippleFactory from '../ripple';
import theme from './theme.css';
const Button = buttonFactory(themedRippleFactory({ centered: false }), FontIcon);
-const IconButton = iconButtonFactory(themedRippleFactory({centered: true}), FontIcon);
+const IconButton = iconButtonFactory(themedRippleFactory({ centered: true }), FontIcon);
const BrowseButton = browseButtonFactory(themedRippleFactory({ centered: false }), FontIcon);
const ThemedButton = themr(BUTTON, theme)(Button);
const ThemedIconButton = themr(BUTTON, theme)(IconButton);
diff --git a/components/card/Card.js b/components/card/Card.js
index 23858199..9c15137c 100644
--- a/components/card/Card.js
+++ b/components/card/Card.js
@@ -1,28 +1,28 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
import classnames from 'classnames';
-import { CARD } from '../identifiers.js';
+import { CARD } from '../identifiers';
-const Card = ({children, className, raised, theme, ...other}) => {
+const Card = ({ children, className, raised, theme, ...other }) => {
const classes = classnames(theme.card, {
- [theme.raised]: raised
+ [theme.raised]: raised,
}, className);
return (
-
+
{children}
);
};
Card.propTypes = {
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
raised: PropTypes.bool,
theme: PropTypes.shape({
card: PropTypes.string,
- raised: PropTypes.string
- })
+ raised: PropTypes.string,
+ }),
};
export default themr(CARD)(Card);
diff --git a/components/card/CardActions.js b/components/card/CardActions.js
index 951355dd..e11ae865 100644
--- a/components/card/CardActions.js
+++ b/components/card/CardActions.js
@@ -1,7 +1,7 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
import classnames from 'classnames';
-import { CARD } from '../identifiers.js';
+import { CARD } from '../identifiers';
const CardActions = ({ children, className, theme, ...other }) => (
@@ -10,11 +10,11 @@ const CardActions = ({ children, className, theme, ...other }) => (
);
CardActions.propTypes = {
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
theme: PropTypes.shape({
- cardActions: PropTypes.string
- })
+ cardActions: PropTypes.string,
+ }),
};
export default themr(CARD)(CardActions);
diff --git a/components/card/CardMedia.js b/components/card/CardMedia.js
index 7d2ecd86..cf32853e 100644
--- a/components/card/CardMedia.js
+++ b/components/card/CardMedia.js
@@ -1,20 +1,29 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
import classnames from 'classnames';
-import { CARD } from '../identifiers.js';
+import { CARD } from '../identifiers';
-const CardMedia = ({ aspectRatio, children, className, color, contentOverlay, image, theme, ...other }) => {
+const CardMedia = ({
+ aspectRatio,
+ children,
+ className,
+ color,
+ contentOverlay,
+ image,
+ theme,
+ ...other
+}) => {
const classes = classnames(theme.cardMedia, {
- [theme[aspectRatio]]: aspectRatio
+ [theme[aspectRatio]]: aspectRatio,
}, className);
const innerClasses = classnames(theme.content, {
- [theme.contentOverlay]: contentOverlay
+ [theme.contentOverlay]: contentOverlay,
});
const bgStyle = {
- backgroundColor: color ? color : undefined,
- backgroundImage: typeof image === 'string' ? `url('${image}')` : undefined
+ backgroundColor: color || undefined,
+ backgroundImage: typeof image === 'string' ? `url('${image}')` : undefined,
};
return (
@@ -27,22 +36,22 @@ const CardMedia = ({ aspectRatio, children, className, color, contentOverlay, im
};
CardMedia.propTypes = {
- aspectRatio: PropTypes.oneOf([ 'wide', 'square' ]),
- children: PropTypes.any,
+ aspectRatio: PropTypes.oneOf(['wide', 'square']),
+ children: PropTypes.node,
className: PropTypes.string,
color: PropTypes.string,
contentOverlay: PropTypes.bool,
image: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
theme: PropTypes.shape({
cardMedia: PropTypes.string,
content: PropTypes.string,
contentOverlay: PropTypes.string,
square: PropTypes.string,
- wide: PropTypes.string
- })
+ wide: PropTypes.string,
+ }),
};
export default themr(CARD)(CardMedia);
diff --git a/components/card/CardText.js b/components/card/CardText.js
index 8a5df131..a9caf059 100644
--- a/components/card/CardText.js
+++ b/components/card/CardText.js
@@ -1,7 +1,7 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
import classnames from 'classnames';
-import { CARD } from '../identifiers.js';
+import { CARD } from '../identifiers';
const CardText = ({ children, className, theme, ...other }) => (
@@ -10,11 +10,11 @@ const CardText = ({ children, className, theme, ...other }) => (
);
CardText.propTypes = {
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
theme: PropTypes.shape({
- cardText: PropTypes.string
- })
+ cardText: PropTypes.string,
+ }),
};
export default themr(CARD)(CardText);
diff --git a/components/card/CardTitle.js b/components/card/CardTitle.js
index 87cd358e..92dce98d 100644
--- a/components/card/CardTitle.js
+++ b/components/card/CardTitle.js
@@ -1,14 +1,14 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { CARD } from '../identifiers.js';
-import InjectAvatar from '../avatar/Avatar.js';
+import { CARD } from '../identifiers';
+import InjectAvatar from '../avatar/Avatar';
const factory = (Avatar) => {
- const CardTitle = ({avatar, children, className, subtitle, theme, title, ...other}) => {
+ const CardTitle = ({ avatar, children, className, subtitle, theme, title, ...other }) => {
const classes = classnames(theme.cardTitle, {
[theme.small]: avatar,
- [theme.large]: !avatar
+ [theme.large]: !avatar,
}, className);
return (
@@ -29,28 +29,28 @@ const factory = (Avatar) => {
CardTitle.propTypes = {
avatar: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.element,
- PropTypes.array
+ PropTypes.array,
]),
className: PropTypes.string,
subtitle: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
theme: PropTypes.shape({
large: PropTypes.string,
title: PropTypes.string,
small: PropTypes.string,
- subtitle: PropTypes.string
+ subtitle: PropTypes.string,
}),
title: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
- ])
+ PropTypes.element,
+ ]),
};
return CardTitle;
diff --git a/components/card/index.js b/components/card/index.js
index a4e6f14a..3e826510 100644
--- a/components/card/index.js
+++ b/components/card/index.js
@@ -1,11 +1,11 @@
import { themr } from 'react-css-themr';
-import { CARD } from '../identifiers.js';
-import { Card } from './Card.js';
-import { CardActions } from './CardActions.js';
-import { CardMedia } from './CardMedia.js';
-import { CardText } from './CardText.js';
-import { cardTitleFactory } from './CardTitle.js';
-import Avatar from '../avatar';
+import { CARD } from '../identifiers';
+import { Card } from './Card';
+import { CardActions } from './CardActions';
+import { CardMedia } from './CardMedia';
+import { CardText } from './CardText';
+import { cardTitleFactory } from './CardTitle';
+import { Avatar } from '../avatar';
import theme from './theme.css';
const CardTitle = cardTitleFactory(Avatar);
diff --git a/components/checkbox/Check.js b/components/checkbox/Check.js
index c2980d53..71528634 100644
--- a/components/checkbox/Check.js
+++ b/components/checkbox/Check.js
@@ -1,10 +1,11 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
+import styleShape from 'react-style-proptype';
const factory = (ripple) => {
- const Check = ({checked, children, onMouseDown, theme, style}) => (
+ const Check = ({ checked, children, onMouseDown, theme, style }) => (
{
Check.propTypes = {
checked: PropTypes.bool,
- children: PropTypes.any,
+ children: PropTypes.node,
onMouseDown: PropTypes.func,
- style: PropTypes.object,
+ style: styleShape,
theme: PropTypes.shape({
check: PropTypes.string,
- checked: PropTypes.string
- })
+ checked: PropTypes.string,
+ }),
};
return ripple(Check);
diff --git a/components/checkbox/Checkbox.js b/components/checkbox/Checkbox.js
index e963deb2..87eb5a12 100644
--- a/components/checkbox/Checkbox.js
+++ b/components/checkbox/Checkbox.js
@@ -1,9 +1,10 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
+import styleShape from 'react-style-proptype';
import { themr } from 'react-css-themr';
-import { CHECKBOX } from '../identifiers.js';
-import rippleFactory from '../ripple/Ripple.js';
-import checkFactory from './Check.js';
+import { CHECKBOX } from '../identifiers';
+import rippleFactory from '../ripple/Ripple';
+import checkFactory from './Check';
const factory = (Check) => {
class Checkbox extends Component {
@@ -14,25 +15,25 @@ const factory = (Check) => {
disabled: PropTypes.bool,
label: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.node
+ PropTypes.node,
]),
name: PropTypes.string,
onChange: PropTypes.func,
onMouseEnter: PropTypes.func,
onMouseLeave: PropTypes.func,
- style: PropTypes.object,
+ style: styleShape,
theme: PropTypes.shape({
disabled: PropTypes.string,
field: PropTypes.string,
input: PropTypes.string,
- ripple: PropTypes.string
- })
+ ripple: PropTypes.string,
+ }),
};
static defaultProps = {
checked: false,
className: '',
- disabled: false
+ disabled: false,
};
handleToggle = (event) => {
@@ -42,24 +43,29 @@ const factory = (Check) => {
}
};
- blur () {
- this.inputNode && this.inputNode.blur();
+ blur() {
+ if (this.inputNode) {
+ this.inputNode.blur();
+ }
}
- focus () {
- this.inputNode && this.inputNode.focus();
+ focus() {
+ if (this.inputNode) {
+ this.inputNode.focus();
+ }
}
- render () {
+ render() {
const { checked, children, disabled, label, name, style, onChange, // eslint-disable-line
onMouseEnter, onMouseLeave, theme, ...others } = this.props;
const className = classnames(theme.field, {
- [theme.disabled]: this.props.disabled
+ [theme.disabled]: this.props.disabled,
}, this.props.className);
return (
);
@@ -92,7 +98,7 @@ const factory = (Check) => {
return Checkbox;
};
-const Check = checkFactory(rippleFactory({ centered: true, spread: 2.6}));
+const Check = checkFactory(rippleFactory({ centered: true, spread: 2.6 }));
const Checkbox = factory(Check);
export default themr(CHECKBOX)(Checkbox);
export { factory as checkboxFactory };
diff --git a/components/checkbox/index.js b/components/checkbox/index.js
index 8475ead2..5fad61cd 100644
--- a/components/checkbox/index.js
+++ b/components/checkbox/index.js
@@ -1,11 +1,11 @@
import { themr } from 'react-css-themr';
-import { CHECKBOX } from '../identifiers.js';
+import { CHECKBOX } from '../identifiers';
import themedRippleFactory from '../ripple';
-import { checkboxFactory } from './Checkbox.js';
-import checkFactory from './Check.js';
+import { checkboxFactory } from './Checkbox';
+import checkFactory from './Check';
import theme from './theme.css';
-const ThemedCheck = checkFactory(themedRippleFactory({ centered: true, spread: 2.6}));
+const ThemedCheck = checkFactory(themedRippleFactory({ centered: true, spread: 2.6 }));
const ThemedCheckbox = themr(CHECKBOX, theme)(checkboxFactory(ThemedCheck));
export default ThemedCheckbox;
diff --git a/components/chip/Chip.js b/components/chip/Chip.js
index 09d0a101..a791be37 100644
--- a/components/chip/Chip.js
+++ b/components/chip/Chip.js
@@ -1,11 +1,11 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { CHIP } from '../identifiers.js';
-import InjectAvatar from '../avatar/Avatar.js';
+import { CHIP } from '../identifiers';
+import InjectAvatar from '../avatar/Avatar';
const factory = (Avatar) => {
- const Chip = ({children, className, deletable, onDeleteClick, theme, ...other}) => {
+ const Chip = ({ children, className, deletable, onDeleteClick, theme, ...other }) => {
let hasAvatar = false;
if (React.Children.count(children)) {
const flatChildren = React.Children.toArray(children);
@@ -14,12 +14,12 @@ const factory = (Avatar) => {
}
const classes = classnames(theme.chip, {
- [theme.deletable]: !!deletable,
- [theme.avatar]: !!hasAvatar
+ [theme.deletable]: !!deletable,
+ [theme.avatar]: !!hasAvatar,
}, className);
return (
-
+
{typeof children === 'string' ?
{children} : children}
{
deletable ? (
@@ -45,13 +45,13 @@ const factory = (Avatar) => {
deletable: PropTypes.string,
delete: PropTypes.string,
deleteIcon: PropTypes.string,
- deleteX: PropTypes.string
- })
+ deleteX: PropTypes.string,
+ }),
};
Chip.defaultProps = {
className: '',
- deletable: false
+ deletable: false,
};
return Chip;
diff --git a/components/chip/__test__/index.spec.js b/components/chip/__test__/index.spec.js
index 87caae62..d509fabd 100644
--- a/components/chip/__test__/index.spec.js
+++ b/components/chip/__test__/index.spec.js
@@ -1,3 +1,4 @@
+/* eslint-disable */
import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
@@ -7,30 +8,30 @@ import { CHIP } from '../../identifiers.js';
import { chipFactory } from '../Chip';
import { tooltipFactory } from '../../tooltip';
-const Avatar = ({title}) =>
{title}; // eslint-disable-line react/prop-types
+const Avatar = ({ title }) =>
{title}; // eslint-disable-line react/prop-types
const Chip = themr(CHIP)(chipFactory(Avatar));
-describe('Chip', function () {
- describe('with avatar', function () {
- it('adds the avatar class to the element', function () {
+describe('Chip', () => {
+ describe('with avatar', () => {
+ it('adds the avatar class to the element', () => {
const tree = ReactTestUtils.renderIntoDocument(
-
-
+
+
Test
-
+ ,
);
const chip = ReactTestUtils.findRenderedComponentWithType(tree, Chip);
const chipNode = ReactDOM.findDOMNode(chip);
expect(chipNode.className).toMatch(/\bavatar-class\b/);
});
- it('works with non-flat children', function () {
+ it('works with non-flat children', () => {
const TooltippedChip = tooltipFactory()(Chip);
const tree = ReactTestUtils.renderIntoDocument(
-
-
+
+
Test
-
+ ,
);
const chip = ReactTestUtils.findRenderedComponentWithType(tree, Chip);
const chipNode = ReactDOM.findDOMNode(chip);
@@ -38,12 +39,12 @@ describe('Chip', function () {
});
});
- describe('without avatar', function () {
- it('does not add avatar class to the element', function () {
+ describe('without avatar', () => {
+ it('does not add avatar class to the element', () => {
const tree = ReactTestUtils.renderIntoDocument(
-
+
Test
-
+ ,
);
const chip = ReactTestUtils.findRenderedComponentWithType(tree, Chip);
const chipNode = ReactDOM.findDOMNode(chip);
diff --git a/components/chip/index.js b/components/chip/index.js
index b6802a9f..6777f33c 100644
--- a/components/chip/index.js
+++ b/components/chip/index.js
@@ -1,7 +1,7 @@
-import { CHIP } from '../identifiers.js';
import { themr } from 'react-css-themr';
-import { chipFactory } from './Chip.js';
-import Avatar from '../avatar';
+import { CHIP } from '../identifiers';
+import { chipFactory } from './Chip';
+import { Avatar } from '../avatar';
import theme from './theme.css';
const Chip = chipFactory(Avatar);
diff --git a/components/date_picker/Calendar.js b/components/date_picker/Calendar.js
index cb4ff1be..4a0cfc5a 100644
--- a/components/date_picker/Calendar.js
+++ b/components/date_picker/Calendar.js
@@ -1,64 +1,62 @@
import React, { Component, PropTypes } from 'react';
import CssTransitionGroup from 'react-addons-css-transition-group';
import { range, getAnimationModule } from '../utils/utils';
-import time from '../utils/time.js';
-import CalendarMonth from './CalendarMonth.js';
+import time from '../utils/time';
+import CalendarMonth from './CalendarMonth';
const DIRECTION_STEPS = { left: -1, right: 1 };
const factory = (IconButton) => {
class Calendar extends Component {
static propTypes = {
- disabledDates: React.PropTypes.array,
+ disabledDates: React.PropTypes.arrayOf(PropTypes.instanceOf(Date)),
display: PropTypes.oneOf(['months', 'years']),
- enabledDates: React.PropTypes.array,
+ enabledDates: React.PropTypes.arrayOf(PropTypes.instanceOf(Date)),
handleSelect: PropTypes.func,
locale: React.PropTypes.oneOfType([
React.PropTypes.string,
- React.PropTypes.object
+ React.PropTypes.object,
]),
- maxDate: PropTypes.object,
- minDate: PropTypes.object,
+ maxDate: PropTypes.instanceOf(Date),
+ minDate: PropTypes.instanceOf(Date),
onChange: PropTypes.func,
- selectedDate: PropTypes.object,
+ selectedDate: PropTypes.instanceOf(Date),
sundayFirstDayOfWeek: React.PropTypes.bool,
theme: PropTypes.shape({
active: PropTypes.string,
calendar: PropTypes.string,
next: PropTypes.string,
prev: PropTypes.string,
- years: PropTypes.string
+ years: PropTypes.string,
}),
- viewDate: PropTypes.object
};
static defaultProps = {
display: 'months',
- selectedDate: new Date()
+ selectedDate: new Date(),
};
state = {
- viewDate: this.props.selectedDate
+ viewDate: this.props.selectedDate,
};
- componentWillMount () {
+ componentWillMount() {
document.body.addEventListener('keydown', this.handleKeys);
}
- componentDidUpdate () {
- if (this.refs.activeYear) {
+ componentDidUpdate() {
+ if (this.activeYearNode) {
this.scrollToActive();
}
}
- componentWillUnmount () {
+ componentWillUnmount() {
document.body.removeEventListener('keydown', this.handleKeys);
}
- scrollToActive () {
- this.refs.years.scrollTop = this.refs.activeYear.offsetTop
- - this.refs.years.offsetHeight / 2
- + this.refs.activeYear.offsetHeight / 2;
+ scrollToActive() {
+ const offset = (this.yearsNode.offsetHeight / 2) + (this.activeYearNode.offsetHeight / 2);
+ this.yearsNode.scrollTop = this.activeYearNode.offsetTop - offset;
}
handleDayClick = (day) => {
@@ -66,16 +64,18 @@ const factory = (IconButton) => {
};
handleYearClick = (event) => {
- const year = parseInt(event.currentTarget.id);
+ const year = parseInt(event.currentTarget.id, 10);
const viewDate = time.setYear(this.props.selectedDate, year);
- this.setState({viewDate});
+ this.setState({ viewDate });
this.props.onChange(viewDate, false);
};
handleKeys = (e) => {
const { selectedDate } = this.props;
- if (e.which === 37 || e.which === 38 || e.which === 39 || e.which === 40 || e.which === 13) e.preventDefault();
+ if (e.which === 37 || e.which === 38 || e.which === 39 || e.which === 40 || e.which === 13) {
+ e.preventDefault();
+ }
switch (e.which) {
case 13: this.props.handleSelect(); break; // enter
@@ -96,35 +96,44 @@ const factory = (IconButton) => {
const direction = event.currentTarget.id;
this.setState({
direction,
- viewDate: time.addMonths(this.state.viewDate, DIRECTION_STEPS[direction])
+ viewDate: time.addMonths(this.state.viewDate, DIRECTION_STEPS[direction]),
});
};
- renderYears () {
+ renderYears() {
return (
-
+ { this.yearsNode = node; }}
+ >
{range(1900, 2100).map(year => (
+ ref={(node) => {
+ if (year === this.state.viewDate.getFullYear()) {
+ this.activeYearNode = node;
+ }
+ }}
+ >
+ {year}
+
))}
);
}
- renderMonths () {
+ renderMonths() {
const { theme } = this.props;
const animation = this.state.direction === 'left' ? 'slideLeft' : 'slideRight';
const animationModule = getAnimationModule(animation, theme);
return (
-
-
-
+
+
+
{
);
}
- render () {
+ render() {
return (
{this.props.display === 'months' ? this.renderMonths() : this.renderYears()}
diff --git a/components/date_picker/CalendarDay.js b/components/date_picker/CalendarDay.js
index 12829f91..027c010f 100644
--- a/components/date_picker/CalendarDay.js
+++ b/components/date_picker/CalendarDay.js
@@ -1,33 +1,34 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
-import time from '../utils/time.js';
+import time from '../utils/time';
class Day extends Component {
static propTypes = {
day: PropTypes.number,
disabled: PropTypes.bool,
onClick: PropTypes.func,
- selectedDate: PropTypes.object,
+ selectedDate: PropTypes.instanceOf(Date),
sundayFirstDayOfWeek: PropTypes.bool,
theme: PropTypes.shape({
active: PropTypes.string,
day: PropTypes.string,
- disabled: PropTypes.string
+ disabled: PropTypes.string,
}),
- viewDate: PropTypes.object
+ viewDate: PropTypes.instanceOf(Date),
};
- dayStyle () {
+ dayStyle() {
if (this.props.day === 1) {
const e = (this.props.sundayFirstDayOfWeek) ? 0 : 1;
const firstDay = time.getFirstWeekDay(this.props.viewDate) - e;
return {
- marginLeft: `${ (firstDay >= 0 ? firstDay : 6) * 100 / 7 }%`
+ marginLeft: `${(firstDay >= 0 ? firstDay : 6) * (100 / 7)}%`,
};
}
+ return undefined;
}
- isSelected () {
+ isSelected() {
const sameYear = this.props.viewDate.getFullYear() === this.props.selectedDate.getFullYear();
const sameMonth = this.props.viewDate.getMonth() === this.props.selectedDate.getMonth();
const sameDay = this.props.day === this.props.selectedDate.getDate();
@@ -40,14 +41,14 @@ class Day extends Component {
}
};
- render () {
+ render() {
const className = classnames(this.props.theme.day, {
[this.props.theme.active]: this.isSelected(),
- [this.props.theme.disabled]: this.props.disabled
+ [this.props.theme.disabled]: this.props.disabled,
});
return (
-
+
{this.props.day}
diff --git a/components/date_picker/CalendarMonth.js b/components/date_picker/CalendarMonth.js
index 8c38cfa8..08fb20aa 100644
--- a/components/date_picker/CalendarMonth.js
+++ b/components/date_picker/CalendarMonth.js
@@ -1,41 +1,41 @@
import React, { Component, PropTypes } from 'react';
import { range } from '../utils/utils';
-import time from '../utils/time.js';
-import CalendarDay from './CalendarDay.js';
+import time from '../utils/time';
+import CalendarDay from './CalendarDay';
class Month extends Component {
static propTypes = {
- disabledDates: React.PropTypes.array,
- enabledDates: React.PropTypes.array,
+ disabledDates: React.PropTypes.arrayOf(PropTypes.instanceOf(Date)),
+ enabledDates: React.PropTypes.arrayOf(PropTypes.instanceOf(Date)),
locale: React.PropTypes.oneOfType([
React.PropTypes.string,
- React.PropTypes.object
+ React.PropTypes.object,
]),
- maxDate: PropTypes.object,
- minDate: PropTypes.object,
+ maxDate: PropTypes.instanceOf(Date),
+ minDate: PropTypes.instanceOf(Date),
onDayClick: PropTypes.func,
- selectedDate: PropTypes.object,
+ selectedDate: PropTypes.instanceOf(Date),
sundayFirstDayOfWeek: React.PropTypes.bool,
theme: PropTypes.shape({
days: PropTypes.string,
month: PropTypes.string,
title: PropTypes.string,
- week: PropTypes.string
+ week: PropTypes.string,
}),
- viewDate: PropTypes.object
+ viewDate: PropTypes.instanceOf(Date),
};
static defaultProps = {
disabledDates: [],
- enabledDates: []
+ enabledDates: [],
};
handleDayClick = (day) => {
if (this.props.onDayClick) this.props.onDayClick(day);
};
- isDayDisabled (date) {
- const {minDate, maxDate, enabledDates, disabledDates} = this.props;
+ isDayDisabled(date) {
+ const { minDate, maxDate, enabledDates, disabledDates } = this.props;
const compareDate = compDate => date.getTime() === compDate.getTime();
const dateInDisabled = disabledDates.filter(compareDate).length > 0;
const dateInEnabled = enabledDates.filter(compareDate).length > 0;
@@ -44,14 +44,14 @@ class Month extends Component {
|| dateInDisabled;
}
- renderWeeks () {
+ renderWeeks() {
const days = range(0, 7).map(d => time.getDayOfWeekLetter(d, this.props.locale));
const source = (this.props.sundayFirstDayOfWeek) ? days : [...days.slice(1), days[0]];
- return source.map((d, i) => (
{d}));
+ return source.map((day, i) => (
{day})); // eslint-disable-line
}
- renderDays () {
- return range(1, time.getDaysInMonth(this.props.viewDate) + 1).map(i => {
+ renderDays() {
+ return range(1, time.getDaysInMonth(this.props.viewDate) + 1).map((i) => {
const date = new Date(this.props.viewDate.getFullYear(), this.props.viewDate.getMonth(), i);
return (
+
- {time.getFullMonth(this.props.viewDate, this.props.locale)} {this.props.viewDate.getFullYear()}
+ {fullMonth} {fullYear}
{this.renderWeeks()}
{this.renderDays()}
diff --git a/components/date_picker/DatePicker.js b/components/date_picker/DatePicker.js
index 149afbec..ed574788 100644
--- a/components/date_picker/DatePicker.js
+++ b/components/date_picker/DatePicker.js
@@ -1,15 +1,15 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { DATE_PICKER } from '../identifiers.js';
-import events from '../utils/events.js';
-import time from '../utils/time.js';
+import { DATE_PICKER } from '../identifiers';
+import events from '../utils/events';
+import time from '../utils/time';
-import InjectIconButton from '../button/IconButton.js';
-import InjectInput from '../input/Input.js';
-import InjectDialog from '../dialog/Dialog.js';
-import calendarFactory from './Calendar.js';
-import datePickerDialogFactory from './DatePickerDialog.js';
+import InjectIconButton from '../button/IconButton';
+import InjectInput from '../input/Input';
+import InjectDialog from '../dialog/Dialog';
+import calendarFactory from './Calendar';
+import datePickerDialogFactory from './DatePickerDialog';
const factory = (Input, DatePickerDialog) => {
class DatePicker extends Component {
@@ -18,22 +18,22 @@ const factory = (Input, DatePickerDialog) => {
autoOk: PropTypes.bool,
cancelLabel: PropTypes.string,
className: PropTypes.string,
- disabledDates: React.PropTypes.array,
- enabledDates: React.PropTypes.array,
+ disabledDates: React.PropTypes.arrayOf(PropTypes.instanceOf(Date)),
+ enabledDates: React.PropTypes.arrayOf(PropTypes.instanceOf(Date)),
error: PropTypes.string,
icon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
inputClassName: PropTypes.string,
inputFormat: PropTypes.func,
label: PropTypes.string,
locale: React.PropTypes.oneOfType([
React.PropTypes.string,
- React.PropTypes.object
+ React.PropTypes.object,
]),
- maxDate: PropTypes.object,
- minDate: PropTypes.object,
+ maxDate: PropTypes.instanceOf(Date),
+ minDate: PropTypes.instanceOf(Date),
name: PropTypes.string,
okLabel: PropTypes.string,
onChange: PropTypes.func,
@@ -46,32 +46,32 @@ const factory = (Input, DatePickerDialog) => {
sundayFirstDayOfWeek: React.PropTypes.bool,
theme: PropTypes.shape({
container: PropTypes.string,
- input: PropTypes.string
+ input: PropTypes.string,
}),
value: PropTypes.oneOfType([
PropTypes.instanceOf(Date),
- PropTypes.string
- ])
+ PropTypes.string,
+ ]),
};
static defaultProps = {
active: false,
locale: 'en',
- sundayFirstDayOfWeek: false
+ sundayFirstDayOfWeek: false,
};
state = {
- active: this.props.active
+ active: this.props.active,
};
- componentWillReceiveProps (nextProps) {
+ componentWillReceiveProps(nextProps) {
if (nextProps.active !== this.props.active && this.state.active !== nextProps.active) {
this.setState({ active: nextProps.active });
}
}
handleDismiss = () => {
- this.setState({active: false});
+ this.setState({ active: false });
if (this.props.onDismiss) {
this.props.onDismiss();
}
@@ -79,34 +79,34 @@ const factory = (Input, DatePickerDialog) => {
handleInputFocus = (event) => {
events.pauseEvent(event);
- this.setState({active: true});
+ this.setState({ active: true });
};
handleInputBlur = (event) => {
events.pauseEvent(event);
- this.setState({active: false});
+ this.setState({ active: false });
};
handleInputClick = (event) => {
events.pauseEvent(event);
- this.setState({active: true});
+ this.setState({ active: true });
if (this.props.onClick) this.props.onClick(event);
};
handleInputKeyPress = (event) => {
if (event.charCode === 13) {
events.pauseEvent(event);
- this.setState({active: true});
+ this.setState({ active: true });
}
if (this.props.onKeyPress) this.props.onKeyPress(event);
};
handleSelect = (value, event) => {
if (this.props.onChange) this.props.onChange(value, event);
- this.setState({active: false});
+ this.setState({ active: false });
};
- render () {
+ render() {
const { active, onDismiss,// eslint-disable-line
autoOk, cancelLabel, enabledDates, disabledDates, inputClassName, inputFormat,
locale, maxDate, minDate, okLabel, onEscKeyDown, onOverlayClick, readonly,
@@ -116,10 +116,10 @@ const factory = (Input, DatePickerDialog) => {
const formattedDate = date === undefined ? '' : finalInputFormat(value, locale);
return (
-
+
{
onKeyPress={this.handleInputKeyPress}
onClick={this.handleInputClick}
readOnly
- type='text'
+ type="text"
value={formattedDate}
/>
{
class CalendarDialog extends Component {
@@ -9,14 +9,14 @@ const factory = (Dialog, Calendar) => {
autoOk: PropTypes.bool,
cancelLabel: PropTypes.string,
className: PropTypes.string,
- disabledDates: PropTypes.array,
- enabledDates: PropTypes.array,
+ disabledDates: React.PropTypes.arrayOf(PropTypes.instanceOf(Date)),
+ enabledDates: React.PropTypes.arrayOf(PropTypes.instanceOf(Date)),
locale: React.PropTypes.oneOfType([
React.PropTypes.string,
- React.PropTypes.object
+ React.PropTypes.object,
]),
- maxDate: PropTypes.object,
- minDate: PropTypes.object,
+ maxDate: PropTypes.instanceOf(Date),
+ minDate: PropTypes.instanceOf(Date),
name: PropTypes.string,
okLabel: PropTypes.string,
onDismiss: PropTypes.func,
@@ -32,9 +32,9 @@ const factory = (Dialog, Calendar) => {
header: PropTypes.string,
monthsDisplay: PropTypes.string,
year: PropTypes.string,
- yearsDisplay: PropTypes.string
+ yearsDisplay: PropTypes.string,
}),
- value: PropTypes.object
+ value: PropTypes.instanceOf(Date),
};
static defaultProps = {
@@ -42,24 +42,24 @@ const factory = (Dialog, Calendar) => {
cancelLabel: 'Cancel',
className: '',
okLabel: 'Ok',
- value: new Date()
+ value: new Date(),
};
state = {
display: 'months',
- date: this.props.value
+ date: this.props.value,
};
- componentWillMount () {
+ componentWillMount() {
this.updateStateDate(this.props.value);
}
- componentWillReceiveProps (nextProps) {
+ componentWillReceiveProps(nextProps) {
this.updateStateDate(nextProps.value);
}
handleNewDate = (value, dayClick) => {
- const state = {display: 'months', date: value};
+ const state = { display: 'months', date: value };
if (time.dateOutOfRange(value, this.props.minDate, this.props.maxDate)) {
if (this.props.maxDate && this.props.minDate) {
state.date = time.closestDate(value, this.props.maxDate, this.props.minDate);
@@ -87,12 +87,18 @@ const factory = (Dialog, Calendar) => {
}
};
- actions = [
- { label: this.props.cancelLabel, className: this.props.theme.button, onClick: this.props.onDismiss },
- { label: this.props.okLabel, className: this.props.theme.button, name: this.props.name, onClick: this.handleSelect }
- ];
+ actions = [{
+ label: this.props.cancelLabel,
+ className: this.props.theme.button,
+ onClick: this.props.onDismiss,
+ }, {
+ label: this.props.okLabel,
+ className: this.props.theme.button,
+ name: this.props.name,
+ onClick: this.handleSelect,
+ }];
- render () {
+ render() {
const { theme } = this.props;
const display = `${this.state.display}Display`;
const className = classnames(theme.dialog, this.props.className);
@@ -111,10 +117,10 @@ const factory = (Dialog, Calendar) => {
type="custom"
>
-
+
{this.state.date.getFullYear()}
-
+
{shortDayOfWeek}, {shortMonth} {date}
diff --git a/components/date_picker/__test__/index.spec.js b/components/date_picker/__test__/index.spec.js
index a6e55a22..84eff2c2 100644
--- a/components/date_picker/__test__/index.spec.js
+++ b/components/date_picker/__test__/index.spec.js
@@ -1,82 +1,83 @@
+/* eslint-disable */
import expect from 'expect';
import theme from '../theme.css';
import { DatePickerDialog } from '../DatePicker';
import utils from '../../utils/testing';
-describe('DatePickerDialog', function () {
- describe('#on mount', function () {
- it('passes value through to calendar if no maxDate/minDate specified', function () {
+describe('DatePickerDialog', () => {
+ describe('#on mount', () => {
+ it('passes value through to calendar if no maxDate/minDate specified', () => {
const value = new Date(2016, 1, 1);
- const wrapper = utils.shallowRenderComponent(DatePickerDialog, {theme, value});
+ const wrapper = utils.shallowRenderComponent(DatePickerDialog, { theme, value });
expect(getDatePassedToCalendar(wrapper)).toBe(value);
});
- describe('when minDate but not maxDate specified', function () {
+ describe('when minDate but not maxDate specified', () => {
const minDate = new Date(2016, 1, 2);
- it('passes through a value after minDate', function () {
+ it('passes through a value after minDate', () => {
const value = new Date(2016, 1, 3);
- const wrapper = utils.shallowRenderComponent(DatePickerDialog, {theme, value, minDate});
+ const wrapper = utils.shallowRenderComponent(DatePickerDialog, { theme, value, minDate });
expect(getDatePassedToCalendar(wrapper)).toBe(value);
});
- it('sanitises a value before minDate to minDate', function () {
+ it('sanitises a value before minDate to minDate', () => {
const wrapper = utils.shallowRenderComponent(DatePickerDialog, {
- theme, value: new Date(2016, 1, 1), minDate
+ theme, value: new Date(2016, 1, 1), minDate,
});
expect(getDatePassedToCalendar(wrapper)).toBe(minDate);
});
});
- describe('when maxDate but not minDate specified', function () {
+ describe('when maxDate but not minDate specified', () => {
const maxDate = new Date(2016, 1, 2);
- it('passes through a value before maxDate', function () {
+ it('passes through a value before maxDate', () => {
const value = new Date(2016, 1, 1);
- const wrapper = utils.shallowRenderComponent(DatePickerDialog, {theme, value, maxDate});
+ const wrapper = utils.shallowRenderComponent(DatePickerDialog, { theme, value, maxDate });
expect(getDatePassedToCalendar(wrapper)).toBe(value);
});
- it('sanitises a value after maxDate to maxDate', function () {
+ it('sanitises a value after maxDate to maxDate', () => {
const wrapper = utils.shallowRenderComponent(DatePickerDialog, {
- theme, value: new Date(2016, 1, 3), maxDate
+ theme, value: new Date(2016, 1, 3), maxDate,
});
expect(getDatePassedToCalendar(wrapper)).toBe(maxDate);
});
});
- describe('if both minDate and maxDate are set', function () {
+ describe('if both minDate and maxDate are set', () => {
const minDate = new Date(2016, 1, 2);
const maxDate = new Date(2016, 1, 4);
- it('sanitises value to minDate if value is before minDate', function () {
+ it('sanitises value to minDate if value is before minDate', () => {
const wrapper = utils.shallowRenderComponent(DatePickerDialog, {
theme,
value: new Date(2016, 1, 1),
minDate,
- maxDate
+ maxDate,
});
expect(getDatePassedToCalendar(wrapper)).toBe(minDate);
});
- it('sanitises value to maxDate if value is after maxDate', function () {
+ it('sanitises value to maxDate if value is after maxDate', () => {
const wrapper = utils.shallowRenderComponent(DatePickerDialog, {
theme,
value: new Date(2016, 1, 5),
minDate,
- maxDate
+ maxDate,
});
expect(getDatePassedToCalendar(wrapper)).toBe(maxDate);
});
- it('doesn\'t sanitise when value is between maxDate/minDate', function () {
+ it('doesn\'t sanitise when value is between maxDate/minDate', () => {
const value = new Date(2016, 1, 3);
- const wrapper = utils.shallowRenderComponent(DatePickerDialog, {theme, value, minDate, maxDate});
+ const wrapper = utils.shallowRenderComponent(DatePickerDialog, { theme, value, minDate, maxDate });
expect(getDatePassedToCalendar(wrapper)).toBe(value);
});
});
- function getDatePassedToCalendar (wrapper) {
+ function getDatePassedToCalendar(wrapper) {
return wrapper.props.children[1].props.children.props.selectedDate;
}
});
diff --git a/components/date_picker/index.js b/components/date_picker/index.js
index 9bd7ee8e..2a7f36b6 100644
--- a/components/date_picker/index.js
+++ b/components/date_picker/index.js
@@ -1,12 +1,12 @@
import { themr } from 'react-css-themr';
-import { DATE_PICKER, DIALOG } from '../identifiers.js';
-import { datePickerFactory } from './DatePicker.js';
-import datePickerDialogFactory from './DatePickerDialog.js';
-import calendarFactory from './Calendar.js';
+import { DATE_PICKER, DIALOG } from '../identifiers';
+import { datePickerFactory } from './DatePicker';
+import datePickerDialogFactory from './DatePickerDialog';
+import calendarFactory from './Calendar';
import { IconButton } from '../button';
-import Input from '../input';
-import Dialog from '../dialog';
+import { Input } from '../input';
+import { Dialog } from '../dialog';
import theme from './theme.css';
const Calendar = calendarFactory(IconButton);
diff --git a/components/dialog/Dialog.js b/components/dialog/Dialog.js
index 9e5eb279..383e657a 100644
--- a/components/dialog/Dialog.js
+++ b/components/dialog/Dialog.js
@@ -1,21 +1,22 @@
+/* eslint-disable jsx-a11y/aria-role */
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
import classnames from 'classnames';
-import { DIALOG } from '../identifiers.js';
-import Portal from '../hoc/Portal.js';
-import ActivableRenderer from '../hoc/ActivableRenderer.js';
-import InjectButton from '../button/Button.js';
-import InjectOverlay from '../overlay/Overlay.js';
+import { DIALOG } from '../identifiers';
+import Portal from '../hoc/Portal';
+import ActivableRenderer from '../hoc/ActivableRenderer';
+import InjectButton from '../button/Button';
+import InjectOverlay from '../overlay/Overlay';
const factory = (Overlay, Button) => {
const Dialog = (props) => {
const actions = props.actions.map((action, idx) => {
- const className = classnames(props.theme.button, {[action.className]: action.className});
- return ;
+ const className = classnames(props.theme.button, { [action.className]: action.className });
+ return ; // eslint-disable-line
});
const className = classnames([props.theme.dialog, props.theme[props.type]], {
- [props.theme.active]: props.active
+ [props.theme.active]: props.active,
}, props.className);
return (
@@ -31,15 +32,15 @@ const factory = (Overlay, Button) => {
theme={props.theme}
themeNamespace="overlay"
/>
-
-
+
+
{props.title ? {props.title}
: null}
{props.children}
{actions.length
- ?
+ ?
: null
}
@@ -48,7 +49,11 @@ const factory = (Overlay, Button) => {
};
Dialog.propTypes = {
- actions: PropTypes.array,
+ actions: PropTypes.arrayOf(PropTypes.shape({
+ className: PropTypes.string,
+ label: PropTypes.string,
+ children: PropTypes.node,
+ })),
active: PropTypes.bool,
children: PropTypes.node,
className: PropTypes.string,
@@ -65,16 +70,16 @@ const factory = (Overlay, Button) => {
navigation: PropTypes.string,
overlay: PropTypes.string,
title: PropTypes.string,
- wrapper: PropTypes.string
+ wrapper: PropTypes.string,
}),
title: PropTypes.string,
- type: PropTypes.string
+ type: PropTypes.string,
};
Dialog.defaultProps = {
actions: [],
active: false,
- type: 'normal'
+ type: 'normal',
};
return ActivableRenderer()(Dialog);
diff --git a/components/dialog/index.js b/components/dialog/index.js
index 2720543e..13214456 100644
--- a/components/dialog/index.js
+++ b/components/dialog/index.js
@@ -1,8 +1,8 @@
import { themr } from 'react-css-themr';
-import { DIALOG } from '../identifiers.js';
-import { dialogFactory } from './Dialog.js';
-import Overlay from '../overlay';
-import Button from '../button';
+import { DIALOG } from '../identifiers';
+import { dialogFactory } from './Dialog';
+import { Overlay } from '../overlay';
+import { Button } from '../button';
import theme from './theme.css';
const Dialog = dialogFactory(Overlay, Button);
diff --git a/components/drawer/Drawer.js b/components/drawer/Drawer.js
index 940448d4..75dc8a7d 100644
--- a/components/drawer/Drawer.js
+++ b/components/drawer/Drawer.js
@@ -1,10 +1,10 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
import classnames from 'classnames';
-import Portal from '../hoc/Portal.js';
-import { DRAWER } from '../identifiers.js';
-import ActivableRenderer from '../hoc/ActivableRenderer.js';
-import InjectOverlay from '../overlay/Overlay.js';
+import Portal from '../hoc/Portal';
+import { DRAWER } from '../identifiers';
+import ActivableRenderer from '../hoc/ActivableRenderer';
+import InjectOverlay from '../overlay/Overlay';
const factory = (Overlay) => {
const Drawer = ({
@@ -16,35 +16,32 @@ const factory = (Overlay) => {
onEscKeyDown,
theme,
type,
- withOverlay
+ withOverlay,
}) => {
const _className = classnames([theme.drawer, theme[type]], {
- [theme.active]: active
+ [theme.active]: active,
}, className);
const content = (
-
+
);
- return React.createElement(insideTree ? 'div' : Portal, {
- className: theme.wrapper,
- children: [
- withOverlay && (
-
- ),
- content
- ]
- });
+ return React.createElement(
+ insideTree ? 'div' : Portal,
+ { className: theme.wrapper },
+ withOverlay && (
+
+ ),
+ content,
+ );
};
Drawer.propTypes = {
@@ -52,18 +49,18 @@ const factory = (Overlay) => {
children: PropTypes.node,
className: PropTypes.string,
insideTree: PropTypes.bool,
- onOverlayClick: PropTypes.func,
onEscKeyDown: PropTypes.func,
+ onOverlayClick: PropTypes.func,
theme: PropTypes.shape({
active: PropTypes.string,
drawer: PropTypes.string,
left: PropTypes.string,
- right: PropTypes.string
+ right: PropTypes.string,
}),
type: PropTypes.oneOf([
- 'left', 'right'
+ 'left', 'right',
]),
- withOverlay: PropTypes.bool
+ withOverlay: PropTypes.bool,
};
Drawer.defaultProps = {
@@ -71,7 +68,7 @@ const factory = (Overlay) => {
className: '',
insideTree: false,
type: 'left',
- withOverlay: true
+ withOverlay: true,
};
return ActivableRenderer()(Drawer);
diff --git a/components/drawer/index.js b/components/drawer/index.js
index cd5542c7..7c890931 100644
--- a/components/drawer/index.js
+++ b/components/drawer/index.js
@@ -1,7 +1,7 @@
import { themr } from 'react-css-themr';
-import { DRAWER } from '../identifiers.js';
+import { DRAWER } from '../identifiers';
import { Overlay } from '../overlay';
-import { drawerFactory } from './Drawer.js';
+import { drawerFactory } from './Drawer';
import theme from './theme.css';
const Drawer = drawerFactory(Overlay);
diff --git a/components/dropdown/Dropdown.js b/components/dropdown/Dropdown.js
index 096af703..2dd2d6c5 100644
--- a/components/dropdown/Dropdown.js
+++ b/components/dropdown/Dropdown.js
@@ -1,10 +1,11 @@
+/* eslint-disable */
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { DROPDOWN } from '../identifiers.js';
-import InjectInput from '../input/Input.js';
-import events from '../utils/events.js';
+import { DROPDOWN } from '../identifiers';
+import InjectInput from '../input/Input';
+import events from '../utils/events';
const factory = (Input) => {
class Dropdown extends Component {
@@ -21,7 +22,10 @@ const factory = (Input) => {
onClick: PropTypes.func,
onFocus: PropTypes.func,
required: PropTypes.bool,
- source: PropTypes.array.isRequired,
+ source: PropTypes.arrayOf(PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.object,
+ ])).isRequired,
template: PropTypes.func,
theme: PropTypes.shape({
active: PropTypes.string,
@@ -36,12 +40,12 @@ const factory = (Input) => {
templateValue: PropTypes.string,
up: PropTypes.string,
value: PropTypes.string,
- values: PropTypes.string
+ values: PropTypes.string,
}),
value: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.number
- ])
+ PropTypes.number,
+ ]),
};
static defaultProps = {
@@ -49,27 +53,27 @@ const factory = (Input) => {
className: '',
allowBlank: true,
disabled: false,
- required: false
+ required: false,
};
state = {
active: false,
- up: false
+ up: false,
};
- componentWillUpdate (nextProps, nextState) {
+ componentWillUpdate(nextProps, nextState) {
if (!this.state.active && nextState.active) {
events.addEventsToDocument(this.getDocumentEvents());
}
}
- componentDidUpdate (prevProps, prevState) {
+ componentDidUpdate(prevProps, prevState) {
if (prevState.active && !this.state.active) {
events.removeEventsFromDocument(this.getDocumentEvents());
}
}
- componentWillUnmount () {
+ componentWillUnmount() {
if (this.state.active) {
events.removeEventsFromDocument(this.getDocumentEvents());
}
@@ -77,26 +81,24 @@ const factory = (Input) => {
getDocumentEvents = () => ({
click: this.handleDocumentClick,
- touchend: this.handleDocumentClick
+ touchend: this.handleDocumentClick,
});
- open = (event) => {
- const client = event.target.getBoundingClientRect();
- const screenHeight = window.innerHeight || document.documentElement.offsetHeight;
- const up = this.props.auto ? client.top > ((screenHeight / 2) + client.height) : false;
- if (this.inputNode) this.inputNode.blur();
- this.setState({active: true, up});
+ getSelectedItem = () => {
+ for (const item of this.props.source) {
+ if (item.value === this.props.value) return item;
+ }
+ return !this.props.allowBlank
+ ? this.props.source[0]
+ : undefined;
};
- close = () => {
- if (this.state.active) {
- this.setState({active: false});
- }
- }
-
- handleDocumentClick = (event) => {
- if (this.state.active && !events.targetIsDescendant(event, ReactDOM.findDOMNode(this))) {
- this.setState({active: false});
+ handleSelect = (item, event) => {
+ if (this.props.onBlur) this.props.onBlur(event);
+ if (!this.props.disabled && this.props.onChange) {
+ if (this.props.name) event.target.name = this.props.name;
+ this.props.onChange(item, event);
+ this.close();
}
};
@@ -106,32 +108,44 @@ const factory = (Input) => {
if (this.props.onClick) this.props.onClick(event);
};
- handleSelect = (item, event) => {
+ handleDocumentClick = (event) => {
+ if (this.state.active && !events.targetIsDescendant(event, ReactDOM.findDOMNode(this))) {
+ this.setState({ active: false });
+ }
+ };
+
+ close = () => {
+ if (this.state.active) {
+ this.setState({ active: false });
+ }
+ }
+
+ open = (event) => {
+ const client = event.target.getBoundingClientRect();
+ const screenHeight = window.innerHeight || document.documentElement.offsetHeight;
+ const up = this.props.auto ? client.top > ((screenHeight / 2) + client.height) : false;
+ if (this.inputNode) this.inputNode.blur();
+ this.setState({ active: true, up });
+ };
+
+ handleFocus = (event) => {
+ event.stopPropagation();
+ if (!this.props.disabled) this.open(event);
+ if (this.props.onFocus) this.props.onFocus(event);
+ };
+
+ handleBlur = (event) => {
+ event.stopPropagation();
+ if (this.state.active) this.close();
if (this.props.onBlur) this.props.onBlur(event);
- if (!this.props.disabled && this.props.onChange) {
- if (this.props.name) {
- event.target.name = this.props.name;
- }
- this.props.onChange(item, event);
- this.close();
- }
- };
+ }
- getSelectedItem = () => {
- for (const item of this.props.source) {
- if (item.value === this.props.value) return item;
- }
- if (!this.props.allowBlank) {
- return this.props.source[0];
- }
- };
-
- renderTemplateValue (selected) {
+ renderTemplateValue(selected) {
const { theme } = this.props;
const className = classnames(theme.field, {
[theme.errored]: this.props.error,
[theme.disabled]: this.props.disabled,
- [theme.required]: this.props.required
+ [theme.required]: this.props.required,
});
return (
@@ -140,11 +154,12 @@ const factory = (Input) => {
{this.props.template(selected)}
{this.props.label
- ?
);
@@ -154,30 +169,22 @@ const factory = (Input) => {
const { theme } = this.props;
const className = classnames({
[theme.selected]: item.value === this.props.value,
- [theme.disabled]: item.disabled
+ [theme.disabled]: item.disabled,
});
return (
-
-
+
-
{this.props.template ? this.props.template(item) : item.label}
);
};
- handleFocus = event => {
- event.stopPropagation();
- if (!this.props.disabled) this.open(event);
- if (this.props.onFocus) this.props.onFocus(event);
- };
-
- handleBlur = event => {
- event.stopPropagation();
- if (this.state.active) this.close();
- if (this.props.onBlur) this.props.onBlur(event);
- }
-
- render () {
+ render() {
const {
- allowBlank, auto, required, onChange, onFocus, onBlur, //eslint-disable-line no-unused-vars
+ allowBlank, auto, required, onChange, onFocus, onBlur, // eslint-disable-line no-unused-vars
source, template, theme, ...others
} = this.props;
const selected = this.getSelectedItem();
@@ -185,13 +192,13 @@ const factory = (Input) => {
[theme.up]: this.state.up,
[theme.active]: this.state.active,
[theme.disabled]: this.props.disabled,
- [theme.required]: this.props.required
+ [theme.required]: this.props.required,
}, this.props.className);
return (
@@ -202,14 +209,14 @@ const factory = (Input) => {
onClick={this.handleClick}
required={this.props.required}
readOnly
- ref={node => { this.inputNode = node && node.getWrappedInstance(); }}
+ ref={(node) => { this.inputNode = node && node.getWrappedInstance(); }}
type={template && selected ? 'hidden' : null}
theme={theme}
themeNamespace="input"
value={selected && selected.label ? selected.label : ''}
/>
- {template && selected ? this.renderTemplateValue(selected) : null}
-
+ {template && selected ? this.renderTemplateValue(selected) : null}
+
{source.map(this.renderValue)}
diff --git a/components/dropdown/__test__/index.spec.js b/components/dropdown/__test__/index.spec.js
index f47e8cd8..a5c1558a 100644
--- a/components/dropdown/__test__/index.spec.js
+++ b/components/dropdown/__test__/index.spec.js
@@ -1,29 +1,30 @@
+/* eslint-disable */
import expect from 'expect';
import React from 'react';
import {
renderIntoDocument,
scryRenderedDOMComponentsWithClass,
- Simulate
+ Simulate,
} from 'react-addons-test-utils';
import sinon from 'sinon';
import theme from '../theme.css';
import Dropdown from '../Dropdown';
-describe('Dropdown', function () {
- describe('#renderValue', function () {
+describe('Dropdown', () => {
+ describe('#renderValue', () => {
const source = [
{ value: 'EN-gb', label: 'England' },
{ value: 'ES-es', label: 'Spain', disabled: true },
{ value: 'TH-th', label: 'Thailand', disabled: true },
- { value: 'EN-en', label: 'USA'}
+ { value: 'EN-en', label: 'USA' },
];
- it('renders dropdown item with disabled style', function () {
+ it('renders dropdown item with disabled style', () => {
const tree = renderIntoDocument(
);
const disabled = scryRenderedDOMComponentsWithClass(tree, theme.disabled);
expect(disabled.length).toEqual(2);
});
- it('does not call onChange callback when disabled dorpdown item is clicked', function () {
+ it('does not call onChange callback when disabled dorpdown item is clicked', () => {
const spy = sinon.spy();
const tree = renderIntoDocument(
( // eslint-disable-line
{value}
@@ -15,18 +15,18 @@ const FontIcon = ({ alt, children, className, theme, value, ...other}) => ( // e
FontIcon.propTypes = {
alt: PropTypes.string,
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
- theme: PropTypes.object,
+ theme: PropTypes.object, // eslint-disable-line
value: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
- ])
+ PropTypes.element,
+ ]),
};
FontIcon.defaultProps = {
alt: '',
- className: ''
+ className: '',
};
export default FontIcon;
diff --git a/components/font_icon/index.js b/components/font_icon/index.js
index 726aec89..15ace6be 100644
--- a/components/font_icon/index.js
+++ b/components/font_icon/index.js
@@ -1,4 +1,4 @@
-import FontIcon from './FontIcon.js';
+import { FontIcon } from './FontIcon';
export default FontIcon;
export { FontIcon };
diff --git a/components/form/Form.js b/components/form/Form.js
deleted file mode 100644
index 3f313399..00000000
--- a/components/form/Form.js
+++ /dev/null
@@ -1,86 +0,0 @@
-import React, { Component, PropTypes } from 'react';
-import InjectAutocomplete from '../autocomplete/Autocomplete.js';
-import InjectButton from '../button/Button.js';
-import InjectCheckbox from '../checkbox/Checkbox.js';
-import InjectDatePicker from '../date_picker/DatePicker.js';
-import InjectDropdown from '../dropdown/Dropdown.js';
-import InjectInput from '../input/Input.js';
-import InjectRadioGroup from '../radio/RadioGroup.js';
-import InjectSlider from '../slider/Slider.js';
-import InjectSwitch from '../switch/Switch.js';
-import InjectTimePicker from '../time_picker/TimePicker.js';
-
-const factory = (
- Autocomplete, Button, Checkbox, DatePicker, Dropdown,
- Input, RadioGroup, Slider, Switch, TimePicker
- ) => {
-
- const COMPONENTS = {
- 'autocomplete': Autocomplete,
- 'button': Button,
- 'checkbox': Checkbox,
- 'datepicker': DatePicker,
- 'dropdown': Dropdown,
- 'input': Input,
- 'radioGroup': RadioGroup,
- 'slider': Slider,
- 'switch': Switch,
- 'timepicker': TimePicker
- };
-
- class Form extends Component {
- static propTypes = {
- attributes: PropTypes.array,
- children: PropTypes.node,
- className: PropTypes.string,
- model: PropTypes.object,
- onChange: PropTypes.func,
- onError: PropTypes.func,
- onSubmit: PropTypes.func,
- onValid: PropTypes.func,
- storage: PropTypes.string
- };
-
- static defaultProps = {
- attributes: [],
- className: ''
- };
-
- onSubmit = (event) => {
- event.preventDefault();
- if (this.props.onSubmit) this.props.onSubmit(event);
- };
-
- onChange = (field, value, event) => {
- if (this.props.onChange) this.props.onChange(field, value, event);
- };
-
- renderFields () {
- return Object.keys(this.props.model).map((field, index) => {
- const properties = this.props.model[field];
- const Field = COMPONENTS[properties.kind.toLowerCase()];
- return ;
- });
- }
-
- render () {
- return (
-
- );
- }
- }
-
- return Form;
-};
-
-const Form = factory(
- InjectAutocomplete, InjectButton, InjectCheckbox, InjectDatePicker, InjectDropdown,
- InjectInput, InjectRadioGroup, InjectSlider, InjectSwitch, InjectTimePicker
-);
-
-export default Form;
-export { factory as formFactory };
-export { Form };
diff --git a/components/form/index.js b/components/form/index.js
deleted file mode 100644
index 7ae8c7f4..00000000
--- a/components/form/index.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import { formFactory } from './Form.js';
-import Autocomplete from '../autocomplete';
-import Button from '../button';
-import Checkbox from '../checkbox';
-import DatePicker from '../date_picker';
-import Dropdown from '../dropdown';
-import Input from '../input';
-import RadioGroup from '../radio';
-import Slider from '../slider';
-import Switch from '../switch';
-import TimePicker from '../time_picker';
-
-const ThemedForm = formFactory(
- Autocomplete, Button, Checkbox, DatePicker, Dropdown,
- Input, RadioGroup, Slider, Switch, TimePicker
-);
-
-export default ThemedForm;
-export { ThemedForm as Form };
diff --git a/components/form/readme.md b/components/form/readme.md
deleted file mode 100644
index a26b1238..00000000
--- a/components/form/readme.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Form
-
-```
-var Form = require('react-toolbox/components/form');
-var fields : [
- {ref: "name", label: "Your Name", required: true, storage: true},
- {ref: "description", multiline: true, label: "Description", value: "Doer"},
- {ref: "birthdate", type: "date", label: "Birthdate"}
-]
-
-
-```
-
-## Properties
-
-| Name | Type | Default | Description|
-|:- |:-: | :- |:-|
-| **attributes** | array | | Array of fields you want hold, fields can be instances of , , , or |
-| **className** | String | | Set the class-styles of the Component.|
-| **onChange** | Function | | Dispatch callback when values of the component changes.|
-| **onError** | Function | | Dispatch callback when a required field is null or has incorrect type.|
-| **onSubmit** | Function | | Dispatch callback when user clicks on submit |
-| **onValid** | Function | | Dispatch callback when all required fields are full-filled.|
-| **Storage** | String | | Sets a localStorage key for save all current field values.|
diff --git a/components/hoc/ActivableRenderer.js b/components/hoc/ActivableRenderer.js
index d7ac8ad1..bc2908b7 100644
--- a/components/hoc/ActivableRenderer.js
+++ b/components/hoc/ActivableRenderer.js
@@ -1,40 +1,40 @@
import React, { Component, PropTypes } from 'react';
-const ActivableRendererFactory = (options = {delay: 500}) =>
+const ActivableRendererFactory = (options = { delay: 500 }) =>
ActivableComponent => class ActivableRenderer extends Component {
static propTypes = {
active: PropTypes.bool.isRequired,
- children: PropTypes.any,
- delay: PropTypes.number
+ children: PropTypes.node,
+ delay: PropTypes.number,
};
static defaultProps = {
- delay: options.delay
+ delay: options.delay,
}
state = {
active: this.props.active,
- rendered: this.props.active
+ rendered: this.props.active,
};
- componentWillReceiveProps (nextProps) {
+ componentWillReceiveProps(nextProps) {
if (nextProps.active && !this.props.active) this.renderAndActivate();
if (!nextProps.active && this.props.active) this.deactivateAndUnrender();
}
- componentWillUnmount () {
+ componentWillUnmount() {
clearTimeout(this.activateTimeout);
clearTimeout(this.unrenderTimeout);
}
- renderAndActivate () {
+ renderAndActivate() {
if (this.unrenderTimeout) clearTimeout(this.unrenderTimeout);
this.setState({ rendered: true, active: false }, () => {
this.activateTimeout = setTimeout(() => this.setState({ active: true }), 20);
});
}
- deactivateAndUnrender () {
+ deactivateAndUnrender() {
this.setState({ rendered: true, active: false }, () => {
this.unrenderTimeout = setTimeout(() => {
this.setState({ rendered: false });
@@ -43,7 +43,7 @@ const ActivableRendererFactory = (options = {delay: 500}) =>
});
}
- render () {
+ render() {
const { delay, ...others } = this.props; // eslint-disable-line no-unused-vars
const { active, rendered } = this.state;
return rendered
diff --git a/components/hoc/Portal.js b/components/hoc/Portal.js
index 0e28a2d2..2e09b10d 100644
--- a/components/hoc/Portal.js
+++ b/components/hoc/Portal.js
@@ -3,22 +3,20 @@ import ReactDOM from 'react-dom';
class Portal extends Component {
static propTypes = {
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
- container: PropTypes.any,
- lockBody: PropTypes.bool
+ container: PropTypes.node,
}
static defaultProps = {
className: '',
- lockBody: true
}
- componentDidMount () {
+ componentDidMount() {
this._renderOverlay();
}
- componentWillReceiveProps (nextProps) {
+ componentWillReceiveProps(nextProps) {
if (this._overlayTarget && nextProps.container !== this.props.container) {
this._portalContainerNode.removeChild(this._overlayTarget);
this._portalContainerNode = getContainer(nextProps.container);
@@ -26,42 +24,45 @@ class Portal extends Component {
}
}
- componentDidUpdate () {
+ componentDidUpdate() {
this._renderOverlay();
}
- componentWillUnmount () {
+ componentWillUnmount() {
this._unrenderOverlay();
this._unmountOverlayTarget();
}
- _mountOverlayTarget () {
- if (!this._overlayTarget) {
- this._overlayTarget = document.createElement('div');
- this._portalContainerNode = getContainer(this.props.container);
- this._portalContainerNode.appendChild(this._overlayTarget);
- }
+ getMountNode() {
+ return this._overlayTarget;
}
- _unmountOverlayTarget () {
- if (this._overlayTarget) {
- this._portalContainerNode.removeChild(this._overlayTarget);
- this._overlayTarget = null;
+ getOverlayDOMNode() {
+ if (!this.isMounted()) { // eslint-disable-line
+ throw new Error('getOverlayDOMNode(): A component must be mounted to have a DOM node.');
}
- this._portalContainerNode = null;
+
+ if (this._overlayInstance) {
+ if (this._overlayInstance.getWrappedDOMNode) {
+ return this._overlayInstance.getWrappedDOMNode();
+ }
+ return ReactDOM.findDOMNode(this._overlayInstance);
+ }
+
+ return null;
}
- _getOverlay () {
+ _getOverlay() {
if (!this.props.children) return null;
return {this.props.children}
;
}
- _renderOverlay () {
+ _renderOverlay() {
const overlay = this._getOverlay();
if (overlay !== null) {
this._mountOverlayTarget();
this._overlayInstance = ReactDOM.unstable_renderSubtreeIntoContainer(
- this, overlay, this._overlayTarget
+ this, overlay, this._overlayTarget,
);
} else {
this._unrenderOverlay();
@@ -69,40 +70,36 @@ class Portal extends Component {
}
}
- _unrenderOverlay () {
+ _unrenderOverlay() {
if (this._overlayTarget) {
ReactDOM.unmountComponentAtNode(this._overlayTarget);
this._overlayInstance = null;
}
}
- getMountNode () {
- return this._overlayTarget;
+ _mountOverlayTarget() {
+ if (!this._overlayTarget) {
+ this._overlayTarget = document.createElement('div');
+ this._portalContainerNode = getContainer(this.props.container);
+ this._portalContainerNode.appendChild(this._overlayTarget);
+ }
}
- getOverlayDOMNode () {
- if (!this.isMounted()) {
- throw new Error('getOverlayDOMNode(): A component must be mounted to have a DOM node.');
+ _unmountOverlayTarget() {
+ if (this._overlayTarget) {
+ this._portalContainerNode.removeChild(this._overlayTarget);
+ this._overlayTarget = null;
}
-
- if (this._overlayInstance) {
- if (this._overlayInstance.getWrappedDOMNode) {
- return this._overlayInstance.getWrappedDOMNode();
- } else {
- return ReactDOM.findDOMNode(this._overlayInstance);
- }
- }
-
- return null;
+ this._portalContainerNode = null;
}
- render () {
+ render() {
return null;
}
}
-function getContainer (container) {
+function getContainer(container) {
const _container = typeof container === 'function' ? container() : container;
return ReactDOM.findDOMNode(_container) || document.body;
}
diff --git a/components/index.js b/components/index.js
index 1c16cd77..c4305c2a 100644
--- a/components/index.js
+++ b/components/index.js
@@ -1,31 +1,31 @@
import './utils/polyfills'; // Import polyfills for IE11
+
export { overrideComponentTypeChecker } from './utils/is-component-of-type';
-export AppBar from './app_bar';
-export Autocomplete from './autocomplete';
-export Avatar from './avatar';
+export { default as AppBar } from './app_bar';
+export { default as Autocomplete } from './autocomplete';
+export { default as Avatar } from './avatar';
export * from './button';
export * from './card';
-export Chip from './chip';
-export Checkbox from './checkbox';
-export DatePicker from './date_picker';
-export Dialog from './dialog';
-export Drawer from './drawer';
-export Dropdown from './dropdown';
-export FontIcon from './font_icon';
-export Form from './form';
-export Input from './input';
+export { default as Chip } from './chip';
+export { default as Checkbox } from './checkbox';
+export { default as DatePicker } from './date_picker';
+export { default as Dialog } from './dialog';
+export { default as Drawer } from './drawer';
+export { default as Dropdown } from './dropdown';
+export { default as FontIcon } from './font_icon';
+export { default as Input } from './input';
export * from './layout';
-export Link from './link';
+export { default as Link } from './link';
export * from './list';
export * from './menu';
-export Navigation from './navigation';
-export ProgressBar from './progress_bar';
+export { default as Navigation } from './navigation';
+export { default as ProgressBar } from './progress_bar';
export * from './radio';
export Ripple from './ripple';
-export Slider from './slider';
-export Snackbar from './snackbar';
-export Switch from './switch';
-export Table from './table';
+export { default as Slider } from './slider';
+export { default as Snackbar } from './snackbar';
+export { default as Switch } from './switch';
+export { default as Table } from './table';
export * from './tabs';
export Tooltip from './tooltip';
-export TimePicker from './time_picker';
+export { default as TimePicker } from './time_picker';
diff --git a/components/input/Input.js b/components/input/Input.js
index 71d23b69..9da60a5e 100644
--- a/components/input/Input.js
+++ b/components/input/Input.js
@@ -1,57 +1,60 @@
-import React from 'react';
+import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { INPUT } from '../identifiers.js';
-import InjectedFontIcon from '../font_icon/FontIcon.js';
+import { INPUT } from '../identifiers';
+import InjectedFontIcon from '../font_icon/FontIcon';
const factory = (FontIcon) => {
class Input extends React.Component {
static propTypes = {
- children: React.PropTypes.any,
- className: React.PropTypes.string,
- disabled: React.PropTypes.bool,
- error: React.PropTypes.oneOfType([
- React.PropTypes.string,
- React.PropTypes.node
+ children: PropTypes.node,
+ className: PropTypes.string,
+ disabled: PropTypes.bool,
+ error: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.node,
]),
- floating: React.PropTypes.bool,
- hint: React.PropTypes.oneOfType([
- React.PropTypes.string,
- React.PropTypes.node
+ floating: PropTypes.bool,
+ hint: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.node,
]),
- icon: React.PropTypes.oneOfType([
- React.PropTypes.string,
- React.PropTypes.element
+ icon: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.element,
]),
- label: React.PropTypes.oneOfType([
- React.PropTypes.string,
- React.PropTypes.node
+ label: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.node,
]),
- maxLength: React.PropTypes.number,
- multiline: React.PropTypes.bool,
- name: React.PropTypes.string,
- onBlur: React.PropTypes.func,
- onChange: React.PropTypes.func,
- onFocus: React.PropTypes.func,
- onKeyPress: React.PropTypes.func,
- required: React.PropTypes.bool,
- rows: React.PropTypes.number,
- theme: React.PropTypes.shape({
- bar: React.PropTypes.string,
- counter: React.PropTypes.string,
- disabled: React.PropTypes.string,
- error: React.PropTypes.string,
- errored: React.PropTypes.string,
- hidden: React.PropTypes.string,
- hint: React.PropTypes.string,
- icon: React.PropTypes.string,
- input: React.PropTypes.string,
- inputElement: React.PropTypes.string,
- required: React.PropTypes.string,
- withIcon: React.PropTypes.string
+ maxLength: PropTypes.number,
+ multiline: PropTypes.bool,
+ name: PropTypes.string,
+ onBlur: PropTypes.func,
+ onChange: PropTypes.func,
+ onFocus: PropTypes.func,
+ onKeyPress: PropTypes.func,
+ required: PropTypes.bool,
+ rows: PropTypes.number,
+ theme: PropTypes.shape({
+ bar: PropTypes.string,
+ counter: PropTypes.string,
+ disabled: PropTypes.string,
+ error: PropTypes.string,
+ errored: PropTypes.string,
+ hidden: PropTypes.string,
+ hint: PropTypes.string,
+ icon: PropTypes.string,
+ input: PropTypes.string,
+ inputElement: PropTypes.string,
+ required: PropTypes.string,
+ withIcon: PropTypes.string,
}),
- type: React.PropTypes.string,
- value: React.PropTypes.any
+ type: PropTypes.string,
+ value: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.string,
+ ]),
};
static defaultProps = {
@@ -61,17 +64,17 @@ const factory = (FontIcon) => {
floating: true,
multiline: false,
required: false,
- type: 'text'
+ type: 'text',
};
- componentDidMount () {
+ componentDidMount() {
if (this.props.multiline) {
window.addEventListener('resize', this.handleAutoresize);
this.handleAutoresize();
}
}
- componentWillReceiveProps (nextProps) {
+ componentWillReceiveProps(nextProps) {
if (!this.props.multiline && nextProps.multiline) {
window.addEventListener('resize', this.handleAutoresize);
} else if (this.props.multiline && !nextProps.multiline) {
@@ -79,12 +82,12 @@ const factory = (FontIcon) => {
}
}
- componentDidUpdate () {
+ componentDidUpdate() {
// resize the textarea, if nessesary
if (this.props.multiline) this.handleAutoresize();
}
- componentWillUnmount () {
+ componentWillUnmount() {
if (this.props.multiline) window.removeEventListener('resize', this.handleAutoresize);
}
@@ -103,7 +106,7 @@ const factory = (FontIcon) => {
};
handleAutoresize = () => {
- const element = this.refs.input;
+ const element = this.inputNode;
const rows = this.props.rows;
if (typeof rows === 'number' && !isNaN(rows)) {
@@ -135,51 +138,52 @@ const factory = (FontIcon) => {
if (!isReplacing && value.length === maxLength) {
event.preventDefault();
event.stopPropagation();
- return;
+ return undefined;
}
}
if (onKeyPress) onKeyPress(event);
+ return undefined;
};
- blur () {
- this.refs.input.blur();
+ blur() {
+ this.inputNode.blur();
}
- focus () {
- this.refs.input.focus();
+ focus() {
+ this.inputNode.focus();
}
- render () {
+ render() {
const { children, disabled, error, floating, hint, icon,
name, label: labelText, maxLength, multiline, required,
- theme, type, value, onKeyPress, rows = 1, ...others} = this.props;
+ theme, type, value, onKeyPress, rows = 1, ...others } = this.props;
const length = maxLength && value ? value.length : 0;
- const labelClassName = classnames(theme.label, {[theme.fixed]: !floating});
+ const labelClassName = classnames(theme.label, { [theme.fixed]: !floating });
const className = classnames(theme.input, {
[theme.disabled]: disabled,
[theme.errored]: error,
[theme.hidden]: type === 'hidden',
- [theme.withIcon]: icon
+ [theme.withIcon]: icon,
}, this.props.className);
const valuePresent = value !== null
&& value !== undefined
&& value !== ''
- && !(typeof value === Number && isNaN(value));
+ && !(typeof value === Number && isNaN(value)); // eslint-disable-line
const inputElementProps = {
...others,
- className: classnames(theme.inputElement, {[theme.filled]: valuePresent}),
+ className: classnames(theme.inputElement, { [theme.filled]: valuePresent }),
onChange: this.handleChange,
- ref: 'input',
+ ref: (node) => { this.inputNode = node; },
role: 'input',
name,
disabled,
required,
type,
- value
+ value,
};
if (!multiline) {
inputElementProps.maxLength = maxLength;
@@ -190,15 +194,15 @@ const factory = (FontIcon) => {
}
return (
-
+
{React.createElement(multiline ? 'textarea' : 'input', inputElementProps)}
{icon ?
: null}
{labelText
- ?
- {labelText}
- {required ? * : null}
-
+ ?
+ {labelText}
+ {required ? * : null}
+
: null}
{hint ?
{hint} : null}
{error ?
{error} : null}
diff --git a/components/input/index.js b/components/input/index.js
index a079ffcd..062dbebb 100644
--- a/components/input/index.js
+++ b/components/input/index.js
@@ -1,7 +1,7 @@
-import { INPUT } from '../identifiers.js';
import { themr } from 'react-css-themr';
-import { inputFactory } from './Input.js';
-import FontIcon from '../font_icon/FontIcon.js';
+import { INPUT } from '../identifiers';
+import { inputFactory } from './Input';
+import { FontIcon } from '../font_icon/FontIcon';
import theme from './theme.css';
const Input = inputFactory(FontIcon);
diff --git a/components/layout/Layout.js b/components/layout/Layout.js
index b3bc733d..70432d0e 100644
--- a/components/layout/Layout.js
+++ b/components/layout/Layout.js
@@ -2,8 +2,8 @@ import React, { cloneElement, Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
import { getViewport } from '../utils/utils';
-import filterReactChildren from '../utils/filter-react-children.js';
-import isComponentOfType from '../utils/is-component-of-type.js';
+import filterReactChildren from '../utils/filter-react-children';
+import isComponentOfType from '../utils/is-component-of-type';
import InjectAppBar from '../app_bar/AppBar';
import InjectNavDrawer from './NavDrawer';
import InjectSidebar from './Sidebar';
@@ -21,23 +21,31 @@ const factory = (AppBar, NavDrawer, Sidebar) => {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
- theme: PropTypes.object
+ theme: PropTypes.shape({
+ appbarFixed: PropTypes.string,
+ layout: PropTypes.string,
+ layoutInner: PropTypes.string,
+ navDrawerClipped: PropTypes.string,
+ navDrawerPinned: PropTypes.string,
+ sidebarClipped: PropTypes.string,
+ sidebarPinned: PropTypes.string,
+ }),
};
static defaultProps = {
- className: ''
+ className: '',
};
state = {
- width: isBrowser() && getViewport().width
+ width: isBrowser() && getViewport().width,
};
- componentDidMount () {
+ componentDidMount() {
if (!this.state.width) this.handleResize();
window.addEventListener('resize', this.handleResize);
}
- componentWillUnmount () {
+ componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
}
@@ -45,7 +53,7 @@ const factory = (AppBar, NavDrawer, Sidebar) => {
this.setState({ width: getViewport().width });
}
- isPinned = sideNav => {
+ isPinned = (sideNav) => {
if (sideNav) {
const { permanentAt, pinned } = sideNav.props;
const { width } = this.state;
@@ -54,7 +62,7 @@ const factory = (AppBar, NavDrawer, Sidebar) => {
return undefined;
}
- render () {
+ render() {
const { children, className, theme, ...rest } = this.props;
const appBar = filterReactChildren(children, isAppBar)[0];
const navDrawer = filterReactChildren(children, isNavDrawer)[0];
@@ -69,17 +77,17 @@ const factory = (AppBar, NavDrawer, Sidebar) => {
const clonedAppBar = appBar && cloneElement(appBar, {
theme,
- themeNamespace: 'appbar'
+ themeNamespace: 'appbar',
});
const clonedLeftSideNav = navDrawer && cloneElement(navDrawer, {
clipped: navDrawerClipped,
- pinned: navDrawerPinned
+ pinned: navDrawerPinned,
});
const clonedRightSideNav = sidebar && cloneElement(sidebar, {
clipped: sidebarClipped,
- pinned: sidebarPinned
+ pinned: sidebarPinned,
});
const _className = classnames(theme.layout,
@@ -88,8 +96,8 @@ const factory = (AppBar, NavDrawer, Sidebar) => {
[theme.navDrawerClipped]: navDrawerClipped,
[theme.sidebarPinned]: sidebarPinned,
[theme.sidebarClipped]: sidebarClipped,
- [theme.appbarFixed]: appBarFixed
- }, className);
+ [theme.appbarFixed]: appBarFixed,
+ }, className);
return (
diff --git a/components/layout/NavDrawer.js b/components/layout/NavDrawer.js
index 58aa1a9e..e4a36b21 100644
--- a/components/layout/NavDrawer.js
+++ b/components/layout/NavDrawer.js
@@ -4,7 +4,7 @@ import { themr } from 'react-css-themr';
import InjectDrawer from '../drawer/Drawer';
import { LAYOUT } from '../identifiers';
-const factory = Drawer => {
+const factory = (Drawer) => {
const NavDrawer = ({
active,
className,
@@ -16,7 +16,7 @@ const factory = Drawer => {
}) => {
const _className = classnames({
[theme.pinned]: pinned,
- [theme.clipped]: clipped
+ [theme.clipped]: clipped,
}, className);
return (
@@ -40,12 +40,15 @@ const factory = Drawer => {
permanentAt: PropTypes.oneOf(['sm', 'smTablet', 'md', 'lg', 'lgTablet', 'xl', 'xxl', 'xxxl']),
pinned: PropTypes.bool,
right: PropTypes.bool,
- theme: PropTypes.object
+ theme: PropTypes.shape({
+ clipped: PropTypes.string,
+ pinned: PropTypes.string,
+ }),
};
NavDrawer.defaultProps = {
className: '',
- pinned: false
+ pinned: false,
};
return NavDrawer;
diff --git a/components/layout/Panel.js b/components/layout/Panel.js
index 41785e8a..a7cbfd47 100644
--- a/components/layout/Panel.js
+++ b/components/layout/Panel.js
@@ -1,31 +1,29 @@
import React, { PropTypes } from 'react';
-import classnames from 'classnames';
+import cn from 'classnames';
import { themr } from 'react-css-themr';
-import { LAYOUT } from '../identifiers.js';
+import { LAYOUT } from '../identifiers';
-const Panel = ({ bodyScroll, children, className, theme, ...other }) => (
-
-);
+const Panel = ({ bodyScroll, children, className, theme, ...other }) => {
+ const _className = cn(theme.panel, { [theme.bodyScroll]: bodyScroll }, className);
+ return (
+
+ {children}
+
+ );
+};
Panel.propTypes = {
bodyScroll: PropTypes.bool,
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
theme: PropTypes.shape({
- panel: PropTypes.string
- })
+ panel: PropTypes.string,
+ }),
};
Panel.defaultProps = {
bodyScroll: true,
- className: ''
+ className: '',
};
export default themr(LAYOUT)(Panel);
diff --git a/components/layout/Sidebar.js b/components/layout/Sidebar.js
index 869c1620..006d8231 100644
--- a/components/layout/Sidebar.js
+++ b/components/layout/Sidebar.js
@@ -4,7 +4,7 @@ import { themr } from 'react-css-themr';
import InjectDrawer from '../drawer/Drawer';
import { LAYOUT } from '../identifiers';
-const factory = Drawer => {
+const factory = (Drawer) => {
const Sidebar = ({
active,
className,
@@ -16,7 +16,7 @@ const factory = Drawer => {
}) => {
const _className = classnames({
[theme.pinned]: pinned,
- [theme.clipped]: clipped
+ [theme.clipped]: clipped,
}, className);
return (
@@ -40,14 +40,17 @@ const factory = Drawer => {
clipped: PropTypes.bool,
permanentAt: PropTypes.oneOf(['sm', 'smTablet', 'md', 'lg', 'lgTablet', 'xl', 'xxl', 'xxxl']),
pinned: PropTypes.bool,
- theme: PropTypes.object,
- width: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 25, 33, 50, 66, 75, 100])
+ theme: PropTypes.shape({
+ clipped: PropTypes.string,
+ pinned: PropTypes.string,
+ }),
+ width: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 25, 33, 50, 66, 75, 100]),
};
Sidebar.defaultProps = {
className: '',
pinned: false,
- right: false
+ right: false,
};
return Sidebar;
diff --git a/components/layout/index.js b/components/layout/index.js
index 37258c11..18b9ad55 100644
--- a/components/layout/index.js
+++ b/components/layout/index.js
@@ -3,9 +3,9 @@ import { LAYOUT } from '../identifiers';
import { layoutFactory } from './Layout';
import { sidebarFactory } from './Sidebar';
import { navDrawerFactory } from './NavDrawer';
-import Panel from './Panel';
-import AppBar from '../app_bar';
-import Drawer from '../drawer';
+import { Panel } from './Panel';
+import { AppBar } from '../app_bar';
+import { Drawer } from '../drawer';
import theme from './theme.css';
const injectTheme = component => themr(LAYOUT, theme)(component);
diff --git a/components/link/Link.js b/components/link/Link.js
index f37bfc6e..382f2a8d 100644
--- a/components/link/Link.js
+++ b/components/link/Link.js
@@ -1,19 +1,19 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { LINK } from '../identifiers.js';
-import FontIcon from '../font_icon/FontIcon.js';
+import { LINK } from '../identifiers';
+import { FontIcon } from '../font_icon/FontIcon';
-const Link = ({active, children, className, count, icon, label, theme, ...others}) => {
+const Link = ({ active, children, className, count, icon, label, theme, ...others }) => {
const _className = classnames(theme.link, {
- [theme.active]: active
+ [theme.active]: active,
}, className);
return (
-
+
{icon ? : null}
{label ? {label} : null}
- {count && parseInt(count) !== 0 ? {count} : null}
+ {count && parseInt(count, 10) !== 0 ? {count} : null}
{children}
);
@@ -26,19 +26,19 @@ Link.propTypes = {
count: PropTypes.number,
icon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
label: PropTypes.string,
theme: PropTypes.shape({
active: PropTypes.string,
icon: PropTypes.string,
- link: PropTypes.string
- })
+ link: PropTypes.string,
+ }),
};
Link.defaultProps = {
active: false,
- className: ''
+ className: '',
};
export default themr(LINK)(Link);
diff --git a/components/link/index.js b/components/link/index.js
index b4f15266..73c91ba1 100644
--- a/components/link/index.js
+++ b/components/link/index.js
@@ -1,6 +1,6 @@
import { themr } from 'react-css-themr';
-import { LINK } from '../identifiers.js';
-import { Link } from './Link.js';
+import { LINK } from '../identifiers';
+import { Link } from './Link';
import theme from './theme.css';
const ThemedLink = themr(LINK, theme)(Link);
diff --git a/components/list/List.js b/components/list/List.js
index 9067d0c2..f90c7324 100644
--- a/components/list/List.js
+++ b/components/list/List.js
@@ -1,8 +1,8 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
-import InjectListItem from './ListItem.js';
+import { LIST } from '../identifiers';
+import InjectListItem from './ListItem';
const mergeProp = (propName, child, parent) => (
child[propName] !== undefined
@@ -15,20 +15,18 @@ const factory = (ListItem) => {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
- ripple: PropTypes.bool,
- selectable: PropTypes.bool,
theme: PropTypes.shape({
- list: PropTypes.string
- })
+ list: PropTypes.string,
+ }),
};
static defaultProps = {
className: '',
ripple: false,
- selectable: false
+ selectable: false,
};
- renderItems () {
+ renderItems() {
return React.Children.map(this.props.children, (item) => {
if (item === null || item === undefined) {
return item;
@@ -36,15 +34,14 @@ const factory = (ListItem) => {
const selectable = mergeProp('selectable', item.props, this.props);
const ripple = mergeProp('ripple', item.props, this.props);
return React.cloneElement(item, { selectable, ripple });
- } else {
- return React.cloneElement(item);
}
+ return React.cloneElement(item);
});
}
- render () {
+ render() {
return (
-
+
);
diff --git a/components/list/ListCheckbox.js b/components/list/ListCheckbox.js
index c50379dd..b2a7203d 100644
--- a/components/list/ListCheckbox.js
+++ b/components/list/ListCheckbox.js
@@ -1,14 +1,25 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
-import InjectCheckbox from '../checkbox/Checkbox.js';
-import InjectListItemContent from './ListItemContent.js';
+import { LIST } from '../identifiers';
+import InjectCheckbox from '../checkbox/Checkbox';
+import InjectListItemContent from './ListItemContent';
const factory = (Checkbox, ListItemContent) => {
- const ListCheckbox = ({ caption, checked, className, disabled, legend, name, onBlur, onChange, onFocus, theme }) => {
+ const ListCheckbox = ({
+ caption,
+ checked,
+ className,
+ disabled,
+ legend,
+ name,
+ onBlur,
+ onChange,
+ onFocus,
+ theme,
+ }) => {
const _className = classnames(theme.item, theme.checkboxItem, {
- [theme.disabled]: disabled
+ [theme.disabled]: disabled,
}, className);
return (
@@ -41,13 +52,13 @@ const factory = (Checkbox, ListItemContent) => {
checkbox: PropTypes.string,
checkboxItem: PropTypes.string,
disabled: PropTypes.string,
- item: PropTypes.string
- })
+ item: PropTypes.string,
+ }),
};
ListCheckbox.defaultProps = {
checked: false,
- disabled: false
+ disabled: false,
};
return ListCheckbox;
diff --git a/components/list/ListDivider.js b/components/list/ListDivider.js
index f1cc252f..851575ad 100644
--- a/components/list/ListDivider.js
+++ b/components/list/ListDivider.js
@@ -1,8 +1,8 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
+import { LIST } from '../identifiers';
-const ListDivider = ({inset, theme}) => (
+const ListDivider = ({ inset, theme }) => (
);
@@ -10,12 +10,12 @@ ListDivider.propTypes = {
inset: PropTypes.bool,
theme: PropTypes.shape({
divider: PropTypes.string,
- inset: PropTypes.string
- })
+ inset: PropTypes.string,
+ }),
};
ListDivider.defaultProps = {
- inset: false
+ inset: false,
};
export default themr(LIST)(ListDivider);
diff --git a/components/list/ListItem.js b/components/list/ListItem.js
index e9a06825..f097b5d5 100644
--- a/components/list/ListItem.js
+++ b/components/list/ListItem.js
@@ -1,28 +1,31 @@
import React, { Component, PropTypes } from 'react';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
-import InjectListItemContent from './ListItemContent.js';
-import InjectListItemLayout from './ListItemLayout.js';
-import rippleFactory from '../ripple/Ripple.js';
+import { LIST } from '../identifiers';
+import InjectListItemContent from './ListItemContent';
+import InjectListItemLayout from './ListItemLayout';
+import rippleFactory from '../ripple/Ripple';
const factory = (ripple, ListItemLayout, ListItemContent) => {
class ListItem extends Component {
static propTypes = {
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
disabled: PropTypes.bool,
+ hasRipple: PropTypes.bool,
onClick: PropTypes.func,
+ onMouseDown: PropTypes.func,
+ onTouchStart: PropTypes.func,
ripple: PropTypes.bool,
theme: PropTypes.shape({
- listItem: PropTypes.string
+ listItem: PropTypes.string,
}),
- to: PropTypes.string
+ to: PropTypes.string,
};
static defaultProps = {
className: '',
disabled: false,
- ripple: false
+ ripple: false,
};
handleClick = (event) => {
@@ -31,16 +34,16 @@ const factory = (ripple, ListItemLayout, ListItemContent) => {
}
};
- groupChildren () {
+ groupChildren() {
const children = {
leftActions: [],
rightActions: [],
- ignored: []
+ ignored: [],
};
React.Children.forEach(this.props.children, (child, i) => {
if (!React.isValidElement(child)) {
- return;
+ return undefined;
}
const { listItemIgnore, ...rest } = child.props;
@@ -48,23 +51,34 @@ const factory = (ripple, ListItemLayout, ListItemContent) => {
if (listItemIgnore) {
children.ignored.push(strippedChild);
- return;
+ return undefined;
}
if (child.type === ListItemContent) {
children.itemContent = strippedChild;
- return;
+ return undefined;
}
const bucket = children.itemContent ? 'rightActions' : 'leftActions';
- children[bucket].push({...strippedChild, key: i});
+ children[bucket].push({ ...strippedChild, key: i });
+ return undefined;
});
return children;
}
- render () {
- const {className, onMouseDown, onTouchStart, to, onClick, ripple: hasRipple, theme, ...other} = this.props; //eslint-disable-line no-unused-vars
+ render() {
+ const {
+ className,
+ hasRipple, // eslint-disable-line no-unused-vars
+ onClick, // eslint-disable-line no-unused-vars
+ onMouseDown, // eslint-disable-line no-unused-vars
+ onTouchStart, // eslint-disable-line no-unused-vars
+ ripple:
+ theme,
+ to,
+ ...other
+ } = this.props;
const children = this.groupChildren();
- const content = ;
+ const content = ;
return (
-
{to ? {content} : content}
diff --git a/components/list/ListItemAction.js b/components/list/ListItemAction.js
index f424cac5..838d2adc 100644
--- a/components/list/ListItemAction.js
+++ b/components/list/ListItemAction.js
@@ -1,9 +1,9 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
+import { LIST } from '../identifiers';
-const ListItemAction = ({action, theme}) => {
- const {onClick, onMouseDown} = action.props;
+const ListItemAction = ({ action, theme }) => {
+ const { onClick, onMouseDown } = action.props;
const stopRipple = onClick && !onMouseDown;
const stop = e => e.stopPropagation();
return (
@@ -14,10 +14,10 @@ const ListItemAction = ({action, theme}) => {
};
ListItemAction.propTypes = {
- action: PropTypes.object,
+ action: PropTypes.node,
theme: PropTypes.shape({
- itemAction: PropTypes.string
- })
+ itemAction: PropTypes.string,
+ }),
};
export default themr(LIST)(ListItemAction);
diff --git a/components/list/ListItemActions.js b/components/list/ListItemActions.js
index 94ed511d..71f9e639 100644
--- a/components/list/ListItemActions.js
+++ b/components/list/ListItemActions.js
@@ -1,28 +1,30 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
-import InjectListItemAction from './ListItemAction.js';
+import { LIST } from '../identifiers';
+import InjectListItemAction from './ListItemAction';
const factory = (ListItemAction) => {
- const ListItemActions = ({type, children, theme}) => {
+ const ListItemActions = ({ type, children, theme }) => {
const validChildren = React.Children.toArray(children).filter(c => (
React.isValidElement(c)
));
return (
- {validChildren.map((action, i) => )}
+ {validChildren.map((action, i) => (
+ // eslint-disable-line
+ ))}
);
};
ListItemActions.propTypes = {
- children: PropTypes.any,
+ children: PropTypes.node,
theme: PropTypes.shape({
left: PropTypes.string,
- right: PropTypes.string
+ right: PropTypes.string,
}),
- type: PropTypes.oneOf(['left', 'right'])
+ type: PropTypes.oneOf(['left', 'right']),
};
return ListItemActions;
diff --git a/components/list/ListItemContent.js b/components/list/ListItemContent.js
index c02438ed..8a6dff29 100644
--- a/components/list/ListItemContent.js
+++ b/components/list/ListItemContent.js
@@ -1,8 +1,8 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
-import InjectListItemText from './ListItemText.js';
+import { LIST } from '../identifiers';
+import InjectListItemText from './ListItemText';
const types = ['auto', 'normal', 'large'];
@@ -11,34 +11,34 @@ const factory = (ListItemText) => {
static propTypes = {
caption: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.node
+ PropTypes.node,
]),
- children: PropTypes.any,
+ children: PropTypes.node,
legend: PropTypes.string,
theme: PropTypes.shape({
auto: PropTypes.string,
itemContentRoot: PropTypes.string,
large: PropTypes.string,
- normal: PropTypes.string
+ normal: PropTypes.string,
}),
- type: PropTypes.oneOf(types)
+ type: PropTypes.oneOf(types),
};
- getType () {
- const {type, children, caption, legend} = this.props;
+ getType() {
+ const { type, children, caption, legend } = this.props;
let count = React.Children.count(children);
- [caption, legend].forEach(s => { count += s ? 1 : 0; });
+ [caption, legend].forEach((s) => { count += s ? 1 : 0; });
const typeIndex = Math.min(count, types.length);
return type || types[typeIndex];
}
- render () {
- const {children, caption, legend, theme} = this.props;
+ render() {
+ const { children, caption, legend, theme } = this.props;
const contentType = this.getType();
const className = classnames(theme.itemContentRoot, {
- [theme[contentType]]: theme[contentType]
+ [theme[contentType]]: theme[contentType],
});
return (
diff --git a/components/list/ListItemLayout.js b/components/list/ListItemLayout.js
index 18c114e1..d7be0565 100644
--- a/components/list/ListItemLayout.js
+++ b/components/list/ListItemLayout.js
@@ -1,36 +1,38 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
-import FontIcon from '../font_icon/FontIcon.js';
-import InjectAvatar from '../avatar/Avatar.js';
-import InjectListItemContent from './ListItemContent.js';
-import InjectListItemActions from './ListItemActions.js';
+import { LIST } from '../identifiers';
+import { FontIcon } from '../font_icon/FontIcon';
+import InjectAvatar from '../avatar/Avatar';
+import InjectListItemContent from './ListItemContent';
+import InjectListItemActions from './ListItemActions';
const factory = (Avatar, ListItemContent, ListItemActions) => {
const ListItemLayout = (props) => {
const className = classnames(props.theme.item, {
[props.theme.disabled]: props.disabled,
- [props.theme.selectable]: props.selectable
+ [props.theme.selectable]: props.selectable,
}, props.className);
const leftActions = [
- props.leftIcon && ,
- props.avatar && ,
- ...props.leftActions
+ props.leftIcon && ,
+ props.avatar && ,
+ ...props.leftActions,
];
const rightActions = [
- props.rightIcon && ,
- ...props.rightActions
+ props.rightIcon && ,
+ ...props.rightActions,
];
- const content = props.itemContent || ;
- const emptyActions = (item) => !item[0] && !item[1] && !item[2];
+ const emptyActions = item => !item[0] && !item[1] && !item[2];
+ const content = props.itemContent || (
+
+ );
return (
- {!emptyActions(leftActions) > 0 && {leftActions}}
+ {!emptyActions(leftActions) > 0 && {leftActions}}
{content}
- {!emptyActions(rightActions) > 0 && {rightActions}}
+ {!emptyActions(rightActions) > 0 && {rightActions}}
);
};
@@ -38,36 +40,34 @@ const factory = (Avatar, ListItemContent, ListItemActions) => {
ListItemLayout.propTypes = {
avatar: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
caption: PropTypes.string,
- children: PropTypes.any,
className: PropTypes.string,
disabled: PropTypes.bool,
itemContent: PropTypes.element,
- leftActions: PropTypes.array,
+ leftActions: PropTypes.arrayOf(PropTypes.node),
leftIcon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
legend: PropTypes.string,
- rightActions: PropTypes.array,
+ rightActions: PropTypes.arrayOf(PropTypes.node),
rightIcon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
selectable: PropTypes.bool,
theme: PropTypes.shape({
disabled: PropTypes.string,
item: PropTypes.string,
- selectable: PropTypes.string
+ selectable: PropTypes.string,
}),
- to: PropTypes.string
};
ListItemLayout.defaultProps = {
disabled: false,
- selectable: false
+ selectable: false,
};
return ListItemLayout;
diff --git a/components/list/ListItemText.js b/components/list/ListItemText.js
index 6d930c78..21160508 100644
--- a/components/list/ListItemText.js
+++ b/components/list/ListItemText.js
@@ -1,10 +1,10 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
+import { LIST } from '../identifiers';
-const ListItemText = ({className, primary, children, theme, ...other}) => {
- const _className = classnames(theme.itemText, {[theme.primary]: primary}, className);
+const ListItemText = ({ className, primary, children, theme, ...other }) => {
+ const _className = classnames(theme.itemText, { [theme.primary]: primary }, className);
return (
{children}
@@ -13,17 +13,17 @@ const ListItemText = ({className, primary, children, theme, ...other}) => {
};
ListItemText.propTypes = {
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
primary: PropTypes.bool,
theme: PropTypes.shape({
itemText: PropTypes.string,
- primary: PropTypes.string
- })
+ primary: PropTypes.string,
+ }),
};
ListItemText.defaultProps = {
- primary: false
+ primary: false,
};
export default themr(LIST)(ListItemText);
diff --git a/components/list/ListSubHeader.js b/components/list/ListSubHeader.js
index e4da5798..db4a1fd5 100644
--- a/components/list/ListSubHeader.js
+++ b/components/list/ListSubHeader.js
@@ -1,7 +1,7 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
+import { LIST } from '../identifiers';
const ListSubHeader = ({ caption, className, theme }) => (
{caption}
@@ -10,11 +10,11 @@ const ListSubHeader = ({ caption, className, theme }) => (
ListSubHeader.propTypes = {
caption: PropTypes.string,
className: PropTypes.string,
- theme: PropTypes.object
+ theme: PropTypes.object, // eslint-disable-line
};
ListSubHeader.defaultProps = {
- className: ''
+ className: '',
};
export default themr(LIST)(ListSubHeader);
diff --git a/components/list/index.js b/components/list/index.js
index df158130..f13c94ec 100644
--- a/components/list/index.js
+++ b/components/list/index.js
@@ -1,21 +1,21 @@
import { themr } from 'react-css-themr';
-import { LIST } from '../identifiers.js';
+import { LIST } from '../identifiers';
import { Avatar } from '../avatar';
import { Checkbox } from '../checkbox';
-import { ListItemText } from './ListItemText.js';
-import { ListItemAction } from './ListItemAction.js';
-import { ListSubHeader } from './ListSubHeader.js';
-import { ListDivider } from './ListDivider.js';
-import { listFactory } from './List.js';
-import { listItemFactory } from './ListItem.js';
-import { listCheckboxFactory } from './ListCheckbox.js';
-import { listItemActionsFactory } from './ListItemActions.js';
-import { listItemContentFactory } from './ListItemContent.js';
-import { listItemLayoutFactory } from './ListItemLayout.js';
+import { ListItemText } from './ListItemText';
+import { ListItemAction } from './ListItemAction';
+import { ListSubHeader } from './ListSubHeader';
+import { ListDivider } from './ListDivider';
+import { listFactory } from './List';
+import { listItemFactory } from './ListItem';
+import { listCheckboxFactory } from './ListCheckbox';
+import { listItemActionsFactory } from './ListItemActions';
+import { listItemContentFactory } from './ListItemContent';
+import { listItemLayoutFactory } from './ListItemLayout';
import themedRippleFactory from '../ripple';
import theme from './theme.css';
-const applyTheme = (Component) => themr(LIST, theme)(Component);
+const applyTheme = Component => themr(LIST, theme)(Component);
const ripple = themedRippleFactory({ centered: false, listItemIgnore: true });
const ThemedListItemAction = applyTheme(ListItemAction);
const ThemedListSubHeader = applyTheme(ListSubHeader);
@@ -23,9 +23,13 @@ const ThemedListItemText = applyTheme(ListItemText);
const ThemedListDivider = applyTheme(ListDivider);
const ThemedListItemContent = applyTheme(listItemContentFactory(ThemedListItemText));
const ThemedListItemActions = applyTheme(listItemActionsFactory(ThemedListItemAction));
-const ThemedListItemLayout = applyTheme(listItemLayoutFactory(Avatar, ThemedListItemContent, ThemedListItemActions));
+const ThemedListItemLayout = applyTheme(
+ listItemLayoutFactory(Avatar, ThemedListItemContent, ThemedListItemActions),
+);
const ThemedListCheckbox = applyTheme(listCheckboxFactory(Checkbox, ThemedListItemContent));
-const ThemedListItem = applyTheme(listItemFactory(ripple, ThemedListItemLayout, ThemedListItemContent));
+const ThemedListItem = applyTheme(
+ listItemFactory(ripple, ThemedListItemLayout, ThemedListItemContent),
+);
const ThemedList = applyTheme(listFactory(ThemedListItem));
export { ThemedListItemActions as ListItemActions };
diff --git a/components/menu/IconMenu.js b/components/menu/IconMenu.js
index 54697e98..9962b5c1 100644
--- a/components/menu/IconMenu.js
+++ b/components/menu/IconMenu.js
@@ -1,9 +1,9 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { MENU } from '../identifiers.js';
-import InjectIconButton from '../button/IconButton.js';
-import InjectMenu from './Menu.js';
+import { MENU } from '../identifiers';
+import InjectIconButton from '../button/IconButton';
+import InjectMenu from './Menu';
const factory = (IconButton, Menu) => {
class IconMenu extends Component {
@@ -12,7 +12,7 @@ const factory = (IconButton, Menu) => {
className: PropTypes.string,
icon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
iconRipple: PropTypes.bool,
menuRipple: PropTypes.bool,
@@ -22,11 +22,11 @@ const factory = (IconButton, Menu) => {
onShow: PropTypes.func,
position: PropTypes.string,
selectable: PropTypes.bool,
- selected: PropTypes.any,
+ selected: PropTypes.node,
theme: PropTypes.shape({
icon: PropTypes.string,
- iconMenu: PropTypes.string
- })
+ iconMenu: PropTypes.string,
+ }),
};
static defaultProps = {
@@ -35,11 +35,11 @@ const factory = (IconButton, Menu) => {
iconRipple: true,
menuRipple: true,
position: 'auto',
- selectable: false
+ selectable: false,
};
state = {
- active: false
+ active: false,
}
handleButtonClick = (event) => {
@@ -52,7 +52,7 @@ const factory = (IconButton, Menu) => {
if (this.props.onHide) this.props.onHide();
}
- render () {
+ render() {
const {
children, className, icon, iconRipple, inverse, menuRipple, onHide, // eslint-disable-line
onSelect, onShow, position, selectable, selected, theme, ...other
diff --git a/components/menu/Menu.js b/components/menu/Menu.js
index 2be53511..efd46156 100644
--- a/components/menu/Menu.js
+++ b/components/menu/Menu.js
@@ -2,10 +2,10 @@ import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { MENU } from '../identifiers.js';
+import { MENU } from '../identifiers';
import { events } from '../utils';
import { getViewport } from '../utils/utils';
-import InjectMenuItem from './MenuItem.js';
+import InjectMenuItem from './MenuItem';
const POSITION = {
AUTO: 'auto',
@@ -13,7 +13,7 @@ const POSITION = {
TOP_LEFT: 'topLeft',
TOP_RIGHT: 'topRight',
BOTTOM_LEFT: 'bottomLeft',
- BOTTOM_RIGHT: 'bottomRight'
+ BOTTOM_RIGHT: 'bottomRight',
};
const factory = (MenuItem) => {
@@ -29,7 +29,7 @@ const factory = (MenuItem) => {
position: PropTypes.oneOf(Object.keys(POSITION).map(key => POSITION[key])),
ripple: PropTypes.bool,
selectable: PropTypes.bool,
- selected: PropTypes.any,
+ selected: PropTypes.node,
theme: PropTypes.shape({
active: PropTypes.string,
bottomLeft: PropTypes.string,
@@ -40,8 +40,8 @@ const factory = (MenuItem) => {
rippled: PropTypes.string,
static: PropTypes.string,
topLeft: PropTypes.string,
- topRight: PropTypes.string
- })
+ topRight: PropTypes.string,
+ }),
};
static defaultProps = {
@@ -49,17 +49,17 @@ const factory = (MenuItem) => {
outline: true,
position: POSITION.STATIC,
ripple: true,
- selectable: true
+ selectable: true,
};
state = {
active: this.props.active,
- rippled: false
+ rippled: false,
};
- componentDidMount () {
+ componentDidMount() {
this.positionTimeoutHandle = setTimeout(() => {
- const { width, height } = this.refs.menu.getBoundingClientRect();
+ const { width, height } = this.menuNode.getBoundingClientRect();
const position = this.props.position === POSITION.AUTO
? this.calculatePosition()
: this.props.position;
@@ -67,7 +67,7 @@ const factory = (MenuItem) => {
});
}
- componentWillReceiveProps (nextProps) {
+ componentWillReceiveProps(nextProps) {
if (this.props.position !== nextProps.position) {
const position = nextProps.position === POSITION.AUTO
? this.calculatePosition()
@@ -104,64 +104,39 @@ const factory = (MenuItem) => {
}
}
- componentWillUpdate (nextProps, nextState) {
+ componentWillUpdate(nextProps, nextState) {
if (!this.state.active && nextState.active) {
events.addEventsToDocument({
click: this.handleDocumentClick,
- touchstart: this.handleDocumentClick
+ touchstart: this.handleDocumentClick,
});
}
}
- componentDidUpdate (prevProps, prevState) {
+ componentDidUpdate(prevProps, prevState) {
if (prevState.active && !this.state.active) {
if (this.props.onHide) this.props.onHide();
events.removeEventsFromDocument({
click: this.handleDocumentClick,
- touchstart: this.handleDocumentClick
+ touchstart: this.handleDocumentClick,
});
} else if (!prevState.active && this.state.active && this.props.onShow) {
this.props.onShow();
}
}
- componentWillUnmount () {
+ componentWillUnmount() {
if (this.state.active) {
events.removeEventsFromDocument({
click: this.handleDocumentClick,
- touchstart: this.handleDocumentClick
+ touchstart: this.handleDocumentClick,
});
}
clearTimeout(this.positionTimeoutHandle);
clearTimeout(this.activateTimeoutHandle);
}
- handleDocumentClick = (event) => {
- if (this.state.active && !events.targetIsDescendant(event, ReactDOM.findDOMNode(this))) {
- this.setState({active: false, rippled: false});
- }
- };
-
- handleSelect = (item, event) => {
- const { value, onClick } = item.props;
- if (onClick) event.persist();
- this.setState({ active: false, rippled: this.props.ripple }, () => {
- if (onClick) onClick(event);
- if (this.props.onSelect) this.props.onSelect(value);
- });
- };
-
- calculatePosition () {
- const parentNode = ReactDOM.findDOMNode(this).parentNode;
- if (!parentNode) return;
- const {top, left, height, width} = parentNode.getBoundingClientRect();
- const {height: wh, width: ww} = getViewport();
- const toTop = top < ((wh / 2) - height / 2);
- const toLeft = left < ((ww / 2) - width / 2);
- return `${toTop ? 'top' : 'bottom'}${toLeft ? 'Left' : 'Right'}`;
- }
-
- getMenuStyle () {
+ getMenuStyle() {
const { width, height, position } = this.state;
if (position !== POSITION.STATIC) {
if (this.state.active) {
@@ -176,50 +151,82 @@ const factory = (MenuItem) => {
return { clip: 'rect(0 0 0 0)' };
}
}
+
+ return undefined;
}
- getRootStyle () {
- if (this.state.position !== POSITION.STATIC) {
- return { width: this.state.width, height: this.state.height };
+ getRootStyle() {
+ return this.state.position !== POSITION.STATIC
+ ? { width: this.state.width, height: this.state.height }
+ : undefined;
+ }
+
+ calculatePosition() {
+ const parentNode = ReactDOM.findDOMNode(this).parentNode;
+ if (!parentNode) return undefined;
+ const { top, left, height, width } = parentNode.getBoundingClientRect();
+ const { height: wh, width: ww } = getViewport();
+ const toTop = top < ((wh / 2) - (height / 2));
+ const toLeft = left < ((ww / 2) - (width / 2));
+ return `${toTop ? 'top' : 'bottom'}${toLeft ? 'Left' : 'Right'}`;
+ }
+
+ handleDocumentClick = (event) => {
+ if (this.state.active && !events.targetIsDescendant(event, ReactDOM.findDOMNode(this))) {
+ this.setState({ active: false, rippled: false });
}
+ };
+
+ handleSelect = (item, event) => {
+ const { value, onClick } = item.props;
+ if (onClick) event.persist();
+ this.setState({ active: false, rippled: this.props.ripple }, () => {
+ if (onClick) onClick(event);
+ if (this.props.onSelect) this.props.onSelect(value);
+ });
+ };
+
+ show() {
+ const { width, height } = this.menuNode.getBoundingClientRect();
+ this.setState({ active: true, width, height });
}
- renderItems () {
+ hide() {
+ this.setState({ active: false });
+ }
+
+ renderItems() {
return React.Children.map(this.props.children, (item) => {
if (!item) return item;
if (item.type === MenuItem) {
return React.cloneElement(item, {
ripple: item.props.ripple || this.props.ripple,
- selected: typeof item.props.value !== 'undefined' && this.props.selectable && item.props.value === this.props.selected,
- onClick: this.handleSelect.bind(this, item)
+ selected: typeof item.props.value !== 'undefined'
+ && this.props.selectable
+ && item.props.value === this.props.selected,
+ onClick: this.handleSelect.bind(this, item),
});
- } else {
- return React.cloneElement(item);
}
+ return React.cloneElement(item);
});
}
- show () {
- const { width, height } = this.refs.menu.getBoundingClientRect();
- this.setState({active: true, width, height});
- }
-
- hide () {
- this.setState({active: false});
- }
-
- render () {
+ render() {
const { theme } = this.props;
const outlineStyle = { width: this.state.width, height: this.state.height };
const className = classnames([theme.menu, theme[this.state.position]], {
[theme.active]: this.state.active,
- [theme.rippled]: this.state.rippled
+ [theme.rippled]: this.state.rippled,
}, this.props.className);
return (
-
+
{this.props.outline ?
: null}
-
+ { this.menuNode = node; }}
+ className={theme.menuInner}
+ style={this.getMenuStyle()}
+ >
{this.renderItems()}
diff --git a/components/menu/MenuDivider.js b/components/menu/MenuDivider.js
index b99cf87c..89543bca 100644
--- a/components/menu/MenuDivider.js
+++ b/components/menu/MenuDivider.js
@@ -1,15 +1,15 @@
import React, { PropTypes } from 'react';
import { themr } from 'react-css-themr';
-import { MENU } from '../identifiers.js';
+import { MENU } from '../identifiers';
const MenuDivider = ({ theme }) => (
-
+
);
MenuDivider.propTypes = {
theme: PropTypes.shape({
- menuDivider: PropTypes.string
- })
+ menuDivider: PropTypes.string,
+ }),
};
export default themr(MENU)(MenuDivider);
diff --git a/components/menu/MenuItem.js b/components/menu/MenuItem.js
index 4ce2dc18..d573704b 100644
--- a/components/menu/MenuItem.js
+++ b/components/menu/MenuItem.js
@@ -1,20 +1,20 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { MENU } from '../identifiers.js';
-import FontIcon from '../font_icon/FontIcon.js';
-import rippleFactory from '../ripple/Ripple.js';
+import { MENU } from '../identifiers';
+import { FontIcon } from '../font_icon/FontIcon';
+import rippleFactory from '../ripple/Ripple';
const factory = (ripple) => {
class MenuItem extends Component {
static propTypes = {
caption: PropTypes.string,
- children: PropTypes.any,
+ children: PropTypes.node,
className: PropTypes.string,
disabled: PropTypes.bool,
icon: PropTypes.oneOfType([
PropTypes.string,
- PropTypes.element
+ PropTypes.element,
]),
onClick: PropTypes.func,
selected: PropTypes.bool,
@@ -25,14 +25,14 @@ const factory = (ripple) => {
icon: PropTypes.string,
menuItem: PropTypes.string,
selected: PropTypes.string,
- shortcut: PropTypes.string
- })
+ shortcut: PropTypes.string,
+ }),
};
static defaultProps = {
className: '',
disabled: false,
- selected: false
+ selected: false,
};
handleClick = (event) => {
@@ -41,16 +41,25 @@ const factory = (ripple) => {
}
};
- render () {
- const {icon, caption, children, shortcut, selected, disabled, theme, ...others} = this.props;
+ render() {
+ const {
+ caption,
+ children,
+ disabled,
+ icon,
+ selected,
+ shortcut,
+ theme,
+ ...others
+ } = this.props;
const className = classnames(theme.menuItem, {
[theme.selected]: selected,
- [theme.disabled]: disabled
+ [theme.disabled]: disabled,
}, this.props.className);
return (
-
-
- {icon ? : null}
+
-
+ {icon ? : null}
{caption}
{shortcut ? {shortcut} : null}
{children}
diff --git a/components/menu/__test__/index.spec.js b/components/menu/__test__/index.spec.js
index fefb186f..89faf0d8 100644
--- a/components/menu/__test__/index.spec.js
+++ b/components/menu/__test__/index.spec.js
@@ -1,13 +1,14 @@
+/* eslint-disable */
import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-addons-test-utils';
import Menu from '../Menu';
-import MenuItem, {MenuItem as RawMenuItem} from '../MenuItem';
+import MenuItem, { MenuItem as RawMenuItem } from '../MenuItem';
-describe('MenuItem', function () {
- describe('#onClick', function () {
- it('passes to listener the event', function () {
+describe('MenuItem', () => {
+ describe('#onClick', () => {
+ it('passes to listener the event', () => {
let listenerCalled = false;
const handleClick = function (event) {
listenerCalled = true;
@@ -17,7 +18,7 @@ describe('MenuItem', function () {
const tree = ReactTestUtils.renderIntoDocument(
);
const menuItem = ReactTestUtils.findRenderedComponentWithType(tree, RawMenuItem);
diff --git a/components/menu/index.js b/components/menu/index.js
index f5d71dba..a62675ab 100644
--- a/components/menu/index.js
+++ b/components/menu/index.js
@@ -1,14 +1,14 @@
import { themr } from 'react-css-themr';
-import { MENU } from '../identifiers.js';
+import { MENU } from '../identifiers';
import { IconButton } from '../button';
-import { MenuDivider } from './MenuDivider.js';
-import { menuItemFactory } from './MenuItem.js';
-import { menuFactory } from './Menu.js';
-import { iconMenuFactory } from './IconMenu.js';
+import { MenuDivider } from './MenuDivider';
+import { menuItemFactory } from './MenuItem';
+import { menuFactory } from './Menu';
+import { iconMenuFactory } from './IconMenu';
import themedRippleFactory from '../ripple';
import theme from './theme.css';
-const applyTheme = (Component) => themr(MENU, theme)(Component);
+const applyTheme = Component => themr(MENU, theme)(Component);
const ThemedMenuDivider = applyTheme(MenuDivider);
const ThemedMenuItem = applyTheme(menuItemFactory(themedRippleFactory({})));
const ThemedMenu = applyTheme(menuFactory(ThemedMenuItem));
diff --git a/components/navigation/Navigation.js b/components/navigation/Navigation.js
index 79d384ae..29a014fb 100644
--- a/components/navigation/Navigation.js
+++ b/components/navigation/Navigation.js
@@ -1,23 +1,23 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
-import { NAVIGATION } from '../identifiers.js';
-import InjectButton from '../button/Button.js';
-import InjectLink from '../link/Link.js';
+import { NAVIGATION } from '../identifiers';
+import InjectButton from '../button/Button';
+import InjectLink from '../link/Link';
const factory = (Button, Link) => {
const Navigation = ({ actions, children, className, routes, theme, type }) => {
const _className = classnames(theme[type], className);
- const buttons = actions.map((action, index) => {
- return ;
- });
+ const buttons = actions.map((action, index) => (
+ // eslint-disable-line
+ ));
- const links = routes.map((route, index) => {
- return ;
- });
+ const links = routes.map((route, index) => (
+ // eslint-disable-line
+ ));
return (
-