From d48799ba09a3250562a1b72f1b8d0dc5988c12f1 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Thu, 1 Sep 2016 17:13:30 +0100 Subject: [PATCH] build new version --- lib/autocomplete/Autocomplete.js | 30 +++++++++--------- lib/button/Button.js | 4 +-- lib/button/IconButton.js | 4 +-- lib/button/theme.scss | 6 ++-- lib/checkbox/Checkbox.js | 4 +-- lib/date_picker/Calendar.js | 8 ++--- lib/date_picker/CalendarDay.js | 4 +-- lib/date_picker/CalendarMonth.js | 4 +-- lib/date_picker/DatePicker.js | 4 +-- lib/date_picker/DatePickerDialog.js | 4 +-- lib/dialog/theme.scss | 12 ++++++++ lib/dropdown/Dropdown.js | 4 +-- lib/form/Form.js | 4 +-- lib/hoc/ActivableRenderer.js | 4 +-- lib/hoc/Portal.js | 2 +- lib/input/Input.js | 4 +-- lib/list/List.js | 2 +- lib/list/ListItem.js | 4 +-- lib/list/ListItemContent.js | 2 +- lib/menu/IconMenu.js | 7 +++-- lib/menu/Menu.js | 4 +-- lib/menu/MenuItem.js | 4 +-- lib/overlay/Overlay.js | 2 +- lib/progress_bar/ProgressBar.js | 2 +- lib/radio/RadioButton.js | 4 +-- lib/radio/RadioGroup.js | 4 +-- lib/ripple/Ripple.js | 39 ++++++++++++------------ lib/slider/Slider.js | 4 +-- lib/snackbar/Snackbar.js | 2 +- lib/switch/Switch.js | 4 +-- lib/table/Table.js | 4 +-- lib/table/TableRow.js | 4 +-- lib/tabs/Tab.js | 4 +-- lib/tabs/TabContent.js | 2 +- lib/tabs/Tabs.js | 47 ++++++++++++++++++++++++----- lib/tabs/__tests__/index.spec.js | 41 ++++++++++++++++++++++++- lib/tabs/_config.scss | 7 +++++ lib/tabs/theme.scss | 24 +++++++++++++++ lib/time_picker/Clock.js | 4 +-- lib/time_picker/ClockFace.js | 4 +-- lib/time_picker/ClockHand.js | 4 +-- lib/time_picker/ClockHours.js | 4 +-- lib/time_picker/ClockMinutes.js | 4 +-- lib/time_picker/TimePicker.js | 4 +-- lib/time_picker/TimePickerDialog.js | 4 +-- lib/tooltip/Tooltip.js | 12 ++++---- lib/utils/utils.js | 9 ++++++ 47 files changed, 248 insertions(+), 120 deletions(-) diff --git a/lib/autocomplete/Autocomplete.js b/lib/autocomplete/Autocomplete.js index 70f2a8db..a03d125e 100644 --- a/lib/autocomplete/Autocomplete.js +++ b/lib/autocomplete/Autocomplete.js @@ -64,7 +64,7 @@ var factory = function factory(Chip, Input) { _inherits(Autocomplete, _Component); function Autocomplete() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -74,7 +74,7 @@ var factory = function factory(Chip, Input) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Autocomplete)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete)).call.apply(_ref, [this].concat(args))), _this), _this.state = { direction: _this.props.direction, focus: false, showAllSuggestions: _this.props.showSuggestionsWhenValueIsSet, @@ -109,7 +109,7 @@ var factory = function factory(Chip, Input) { } _this.setState({ active: target }); } - _this.select(target, event); + _this.select(event, target); } if (event.which === 27) _reactDom2.default.findDOMNode(_this).querySelector('input').blur(); @@ -123,10 +123,11 @@ var factory = function factory(Chip, Input) { } }, _this.handleSuggestionHover = function (event) { _this.setState({ active: event.target.id }); - }, _this.select = function (event) { + }, _this.select = function (event, target) { _events2.default.pauseEvent(event); var values = _this.values(_this.props.value); - _this.handleChange([event.target.id].concat(_toConsumableArray(values.keys())), event); + var newValue = target === void 0 ? event.target.id : target; + _this.handleChange([newValue].concat(_toConsumableArray(values.keys())), event); }, _temp), _possibleConstructorReturn(_this, _ret); } @@ -176,7 +177,8 @@ var factory = function factory(Chip, Input) { key: 'suggestions', value: function suggestions() { var suggest = new Map(); - var query = (this.state.query || (!this.props.multiple ? this.props.value : '')).toLowerCase().trim() || ''; + var rawQuery = this.state.query || this.props.multiple ? '' : this.props.value; + var query = (rawQuery || '').toLowerCase().trim(); var values = this.values(); var source = this.source(); @@ -333,11 +335,11 @@ var factory = function factory(Chip, Input) { var _this2 = this; if (this.props.multiple) { - var selectedItems = [].concat(_toConsumableArray(this.values())).map(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2); + var selectedItems = [].concat(_toConsumableArray(this.values())).map(function (_ref2) { + var _ref3 = _slicedToArray(_ref2, 2); - var key = _ref2[0]; - var value = _ref2[1]; + var key = _ref3[0]; + var value = _ref3[1]; return _react2.default.createElement( Chip, @@ -365,11 +367,11 @@ var factory = function factory(Chip, Input) { var theme = this.props.theme; - var suggestions = [].concat(_toConsumableArray(this.suggestions())).map(function (_ref3) { - var _ref4 = _slicedToArray(_ref3, 2); + var suggestions = [].concat(_toConsumableArray(this.suggestions())).map(function (_ref4) { + var _ref5 = _slicedToArray(_ref4, 2); - var key = _ref4[0]; - var value = _ref4[1]; + var key = _ref5[0]; + var value = _ref5[1]; var className = (0, _classnames5.default)(theme.suggestion, _defineProperty({}, theme.active, _this3.state.active === key)); return _react2.default.createElement( diff --git a/lib/button/Button.js b/lib/button/Button.js index 2b9e424f..b38aeb3b 100644 --- a/lib/button/Button.js +++ b/lib/button/Button.js @@ -46,7 +46,7 @@ var factory = function factory(ripple, FontIcon) { _inherits(Button, _Component); function Button() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -56,7 +56,7 @@ var factory = function factory(ripple, FontIcon) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Button)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleMouseUp = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Button.__proto__ || Object.getPrototypeOf(Button)).call.apply(_ref, [this].concat(args))), _this), _this.handleMouseUp = function (event) { _this.refs.button.blur(); if (_this.props.onMouseUp) _this.props.onMouseUp(event); }, _this.handleMouseLeave = function (event) { diff --git a/lib/button/IconButton.js b/lib/button/IconButton.js index 98f6331b..40f22fd9 100644 --- a/lib/button/IconButton.js +++ b/lib/button/IconButton.js @@ -46,7 +46,7 @@ var factory = function factory(ripple, FontIcon) { _inherits(IconButton, _Component); function IconButton() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -56,7 +56,7 @@ var factory = function factory(ripple, FontIcon) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(IconButton)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleMouseUp = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = IconButton.__proto__ || Object.getPrototypeOf(IconButton)).call.apply(_ref, [this].concat(args))), _this), _this.handleMouseUp = function (event) { _this.refs.button.blur(); if (_this.props.onMouseUp) _this.props.onMouseUp(event); }, _this.handleMouseLeave = function (event) { diff --git a/lib/button/theme.scss b/lib/button/theme.scss index f57d6027..cff21b37 100644 --- a/lib/button/theme.scss +++ b/lib/button/theme.scss @@ -31,14 +31,14 @@ > span:not([data-react-toolbox="tooltip"]) { display: inline-block; line-height: $button-height; - vertical-align: middle; + vertical-align: top; } > svg { display: inline-block; width: 1em; height: $button-height; font-size: 120%; - vertical-align: middle; + vertical-align: top; fill: currentColor; } > * { @@ -126,7 +126,7 @@ > .icon, svg { font-size: $button-toggle-font-size; line-height: $button-height; - vertical-align: middle; + vertical-align: top; } > .rippleWrapper { border-radius: 50%; diff --git a/lib/checkbox/Checkbox.js b/lib/checkbox/Checkbox.js index 164ffb67..a7d090d3 100644 --- a/lib/checkbox/Checkbox.js +++ b/lib/checkbox/Checkbox.js @@ -46,7 +46,7 @@ var factory = function factory(Check) { _inherits(Checkbox, _Component); function Checkbox() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -56,7 +56,7 @@ var factory = function factory(Check) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Checkbox)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleToggle = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Checkbox.__proto__ || Object.getPrototypeOf(Checkbox)).call.apply(_ref, [this].concat(args))), _this), _this.handleToggle = function (event) { if (event.pageX !== 0 && event.pageY !== 0) _this.blur(); if (!_this.props.disabled && _this.props.onChange) { _this.props.onChange(!_this.props.checked, event); diff --git a/lib/date_picker/Calendar.js b/lib/date_picker/Calendar.js index d4e5a663..31b1de12 100644 --- a/lib/date_picker/Calendar.js +++ b/lib/date_picker/Calendar.js @@ -43,7 +43,7 @@ var factory = function factory(IconButton) { _inherits(Calendar, _Component); function Calendar() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -53,17 +53,17 @@ var factory = function factory(IconButton) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Calendar)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Calendar.__proto__ || Object.getPrototypeOf(Calendar)).call.apply(_ref, [this].concat(args))), _this), _this.state = { viewDate: _this.props.selectedDate }, _this.handleDayClick = function (day) { _this.props.onChange(_time2.default.setDay(_this.state.viewDate, day), true); }, _this.handleYearClick = function (event) { - var year = parseInt(event.target.id); + var year = parseInt(event.currentTarget.id); var viewDate = _time2.default.setYear(_this.props.selectedDate, year); _this.setState({ viewDate: viewDate }); _this.props.onChange(viewDate, false); }, _this.changeViewMonth = function (event) { - var direction = event.target.id; + var direction = event.currentTarget.id; _this.setState({ direction: direction, viewDate: _time2.default.addMonths(_this.state.viewDate, DIRECTION_STEPS[direction]) diff --git a/lib/date_picker/CalendarDay.js b/lib/date_picker/CalendarDay.js index 023206fd..af1b4a94 100644 --- a/lib/date_picker/CalendarDay.js +++ b/lib/date_picker/CalendarDay.js @@ -32,7 +32,7 @@ var Day = function (_Component) { _inherits(Day, _Component); function Day() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -42,7 +42,7 @@ var Day = function (_Component) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Day)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleClick = function () { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Day.__proto__ || Object.getPrototypeOf(Day)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function () { if (!_this.props.disabled && _this.props.onClick) { _this.props.onClick(_this.props.day); } diff --git a/lib/date_picker/CalendarMonth.js b/lib/date_picker/CalendarMonth.js index 772c665e..ad3afbe2 100644 --- a/lib/date_picker/CalendarMonth.js +++ b/lib/date_picker/CalendarMonth.js @@ -36,7 +36,7 @@ var Month = function (_Component) { _inherits(Month, _Component); function Month() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -46,7 +46,7 @@ var Month = function (_Component) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Month)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleDayClick = function (day) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Month.__proto__ || Object.getPrototypeOf(Month)).call.apply(_ref, [this].concat(args))), _this), _this.handleDayClick = function (day) { if (_this.props.onDayClick) _this.props.onDayClick(day); }, _temp), _possibleConstructorReturn(_this, _ret); } diff --git a/lib/date_picker/DatePicker.js b/lib/date_picker/DatePicker.js index a8409ea5..afaf0b1a 100644 --- a/lib/date_picker/DatePicker.js +++ b/lib/date_picker/DatePicker.js @@ -66,7 +66,7 @@ var factory = function factory(Input, DatePickerDialog) { _inherits(DatePicker, _Component); function DatePicker() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -76,7 +76,7 @@ var factory = function factory(Input, DatePickerDialog) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(DatePicker)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = DatePicker.__proto__ || Object.getPrototypeOf(DatePicker)).call.apply(_ref, [this].concat(args))), _this), _this.state = { active: _this.props.active }, _this.handleDismiss = function () { _this.setState({ active: false }); diff --git a/lib/date_picker/DatePickerDialog.js b/lib/date_picker/DatePickerDialog.js index 0a3d9110..2c227b4c 100644 --- a/lib/date_picker/DatePickerDialog.js +++ b/lib/date_picker/DatePickerDialog.js @@ -31,7 +31,7 @@ var factory = function factory(Dialog, Calendar) { _inherits(CalendarDialog, _Component); function CalendarDialog() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -41,7 +41,7 @@ var factory = function factory(Dialog, Calendar) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(CalendarDialog)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = CalendarDialog.__proto__ || Object.getPrototypeOf(CalendarDialog)).call.apply(_ref, [this].concat(args))), _this), _this.state = { display: 'months', date: _this.props.value }, _this.handleNewDate = function (value, dayClick) { diff --git a/lib/dialog/theme.scss b/lib/dialog/theme.scss index 62e7388d..c7ac36f7 100644 --- a/lib/dialog/theme.scss +++ b/lib/dialog/theme.scss @@ -47,6 +47,18 @@ width: 96vw; } +.fullscreen { + width: 96vw; + + @media screen and (max-width: $layout-breakpoint-xs) { + max-width: 100vw; + max-height: 100vh; + min-height: 100vh; + width: 100vw; + border-radius: 0; + } +} + .title { @include typo-title(); flex-grow: 0; diff --git a/lib/dropdown/Dropdown.js b/lib/dropdown/Dropdown.js index a9fe5171..5009fcc6 100644 --- a/lib/dropdown/Dropdown.js +++ b/lib/dropdown/Dropdown.js @@ -50,7 +50,7 @@ var factory = function factory(Input) { _inherits(Dropdown, _Component); function Dropdown() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -60,7 +60,7 @@ var factory = function factory(Input) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Dropdown)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).call.apply(_ref, [this].concat(args))), _this), _this.state = { active: false, up: false }, _this.close = function () { diff --git a/lib/form/Form.js b/lib/form/Form.js index 7de399c9..fe56e77f 100644 --- a/lib/form/Form.js +++ b/lib/form/Form.js @@ -80,7 +80,7 @@ var factory = function factory(Autocomplete, Button, Checkbox, DatePicker, Dropd _inherits(Form, _Component); function Form() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -90,7 +90,7 @@ var factory = function factory(Autocomplete, Button, Checkbox, DatePicker, Dropd args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Form)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.onSubmit = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Form.__proto__ || Object.getPrototypeOf(Form)).call.apply(_ref, [this].concat(args))), _this), _this.onSubmit = function (event) { event.preventDefault(); if (_this.props.onSubmit) _this.props.onSubmit(event); }, _this.onChange = function (field, value, event) { diff --git a/lib/hoc/ActivableRenderer.js b/lib/hoc/ActivableRenderer.js index e64654f7..f15f41a3 100644 --- a/lib/hoc/ActivableRenderer.js +++ b/lib/hoc/ActivableRenderer.js @@ -31,7 +31,7 @@ var ActivableRendererFactory = function ActivableRendererFactory() { _inherits(ActivableRenderer, _Component); function ActivableRenderer() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -41,7 +41,7 @@ var ActivableRendererFactory = function ActivableRendererFactory() { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(ActivableRenderer)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ActivableRenderer.__proto__ || Object.getPrototypeOf(ActivableRenderer)).call.apply(_ref, [this].concat(args))), _this), _this.state = { active: _this.props.active, rendered: _this.props.active }, _temp), _possibleConstructorReturn(_this, _ret); diff --git a/lib/hoc/Portal.js b/lib/hoc/Portal.js index bf12d903..0d8cda45 100644 --- a/lib/hoc/Portal.js +++ b/lib/hoc/Portal.js @@ -28,7 +28,7 @@ var Portal = function (_Component) { function Portal() { _classCallCheck(this, Portal); - return _possibleConstructorReturn(this, Object.getPrototypeOf(Portal).apply(this, arguments)); + return _possibleConstructorReturn(this, (Portal.__proto__ || Object.getPrototypeOf(Portal)).apply(this, arguments)); } _createClass(Portal, [{ diff --git a/lib/input/Input.js b/lib/input/Input.js index d29f218b..e561fc21 100644 --- a/lib/input/Input.js +++ b/lib/input/Input.js @@ -44,7 +44,7 @@ var factory = function factory(FontIcon) { _inherits(Input, _React$Component); function Input() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -54,7 +54,7 @@ var factory = function factory(FontIcon) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Input)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleChange = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Input.__proto__ || Object.getPrototypeOf(Input)).call.apply(_ref, [this].concat(args))), _this), _this.handleChange = function (event) { var _this$props = _this.props; var onChange = _this$props.onChange; var multiline = _this$props.multiline; diff --git a/lib/list/List.js b/lib/list/List.js index cd315c95..eac163f8 100644 --- a/lib/list/List.js +++ b/lib/list/List.js @@ -38,7 +38,7 @@ var factory = function factory(ListItem) { function List() { _classCallCheck(this, List); - return _possibleConstructorReturn(this, Object.getPrototypeOf(List).apply(this, arguments)); + return _possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).apply(this, arguments)); } _createClass(List, [{ diff --git a/lib/list/ListItem.js b/lib/list/ListItem.js index 193dec03..3358acdd 100644 --- a/lib/list/ListItem.js +++ b/lib/list/ListItem.js @@ -44,7 +44,7 @@ var factory = function factory(ripple, ListItemLayout, ListItemContent) { _inherits(ListItem, _Component); function ListItem() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -54,7 +54,7 @@ var factory = function factory(ripple, ListItemLayout, ListItemContent) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(ListItem)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleClick = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ListItem.__proto__ || Object.getPrototypeOf(ListItem)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (event) { if (_this.props.onClick && !_this.props.disabled) { _this.props.onClick(event); } diff --git a/lib/list/ListItemContent.js b/lib/list/ListItemContent.js index f9924b4a..f288d9df 100644 --- a/lib/list/ListItemContent.js +++ b/lib/list/ListItemContent.js @@ -42,7 +42,7 @@ var factory = function factory(ListItemText) { function ListItemContent() { _classCallCheck(this, ListItemContent); - return _possibleConstructorReturn(this, Object.getPrototypeOf(ListItemContent).apply(this, arguments)); + return _possibleConstructorReturn(this, (ListItemContent.__proto__ || Object.getPrototypeOf(ListItemContent)).apply(this, arguments)); } _createClass(ListItemContent, [{ diff --git a/lib/menu/IconMenu.js b/lib/menu/IconMenu.js index 062b856f..70bff718 100644 --- a/lib/menu/IconMenu.js +++ b/lib/menu/IconMenu.js @@ -40,7 +40,7 @@ var factory = function factory(IconButton, Menu) { _inherits(IconMenu, _Component); function IconMenu() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -50,7 +50,7 @@ var factory = function factory(IconButton, Menu) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(IconMenu)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = IconMenu.__proto__ || Object.getPrototypeOf(IconMenu)).call.apply(_ref, [this].concat(args))), _this), _this.state = { active: false }, _this.handleButtonClick = function (event) { _this.setState({ active: !_this.state.active }); @@ -84,7 +84,8 @@ var factory = function factory(IconButton, Menu) { position: this.props.position, ripple: this.props.menuRipple, selectable: this.props.selectable, - selected: this.props.selected + selected: this.props.selected, + theme: this.props.theme }, this.props.children ) diff --git a/lib/menu/Menu.js b/lib/menu/Menu.js index bcc8ed06..51ab885d 100644 --- a/lib/menu/Menu.js +++ b/lib/menu/Menu.js @@ -53,7 +53,7 @@ var factory = function factory(MenuItem) { _inherits(Menu, _Component); function Menu() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -63,7 +63,7 @@ var factory = function factory(MenuItem) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Menu)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Menu.__proto__ || Object.getPrototypeOf(Menu)).call.apply(_ref, [this].concat(args))), _this), _this.state = { active: _this.props.active, rippled: false }, _this.handleDocumentClick = function (event) { diff --git a/lib/menu/MenuItem.js b/lib/menu/MenuItem.js index 7562dfa0..2670f432 100644 --- a/lib/menu/MenuItem.js +++ b/lib/menu/MenuItem.js @@ -46,7 +46,7 @@ var factory = function factory(ripple) { _inherits(MenuItem, _Component); function MenuItem() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -56,7 +56,7 @@ var factory = function factory(ripple) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(MenuItem)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleClick = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = MenuItem.__proto__ || Object.getPrototypeOf(MenuItem)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (event) { if (_this.props.onClick && !_this.props.disabled) { _this.props.onClick(event, _this); } diff --git a/lib/overlay/Overlay.js b/lib/overlay/Overlay.js index 0bf6de75..5fa1d7d6 100644 --- a/lib/overlay/Overlay.js +++ b/lib/overlay/Overlay.js @@ -39,7 +39,7 @@ var Overlay = function (_Component) { function Overlay() { _classCallCheck(this, Overlay); - return _possibleConstructorReturn(this, Object.getPrototypeOf(Overlay).apply(this, arguments)); + return _possibleConstructorReturn(this, (Overlay.__proto__ || Object.getPrototypeOf(Overlay)).apply(this, arguments)); } _createClass(Overlay, [{ diff --git a/lib/progress_bar/ProgressBar.js b/lib/progress_bar/ProgressBar.js index c1a36201..f8a16e85 100644 --- a/lib/progress_bar/ProgressBar.js +++ b/lib/progress_bar/ProgressBar.js @@ -39,7 +39,7 @@ var ProgressBar = function (_Component) { function ProgressBar() { _classCallCheck(this, ProgressBar); - return _possibleConstructorReturn(this, Object.getPrototypeOf(ProgressBar).apply(this, arguments)); + return _possibleConstructorReturn(this, (ProgressBar.__proto__ || Object.getPrototypeOf(ProgressBar)).apply(this, arguments)); } _createClass(ProgressBar, [{ diff --git a/lib/radio/RadioButton.js b/lib/radio/RadioButton.js index 7fe8abe0..71ee095a 100644 --- a/lib/radio/RadioButton.js +++ b/lib/radio/RadioButton.js @@ -44,7 +44,7 @@ var factory = function factory(Radio) { _inherits(RadioButton, _Component); function RadioButton() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -54,7 +54,7 @@ var factory = function factory(Radio) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(RadioButton)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleClick = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = RadioButton.__proto__ || Object.getPrototypeOf(RadioButton)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (event) { var _this$props = _this.props; var checked = _this$props.checked; var disabled = _this$props.disabled; diff --git a/lib/radio/RadioGroup.js b/lib/radio/RadioGroup.js index e85ce1dd..a69b9fe3 100644 --- a/lib/radio/RadioGroup.js +++ b/lib/radio/RadioGroup.js @@ -34,7 +34,7 @@ var factory = function factory(RadioButton) { _inherits(RadioGroup, _Component); function RadioGroup() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -44,7 +44,7 @@ var factory = function factory(RadioButton) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(RadioGroup)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleChange = function (value) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = RadioGroup.__proto__ || Object.getPrototypeOf(RadioGroup)).call.apply(_ref, [this].concat(args))), _this), _this.handleChange = function (value) { if (_this.props.onChange) _this.props.onChange(value); }, _temp), _possibleConstructorReturn(_this, _ret); } diff --git a/lib/ripple/Ripple.js b/lib/ripple/Ripple.js index 4400c42f..cf2c1949 100644 --- a/lib/ripple/Ripple.js +++ b/lib/ripple/Ripple.js @@ -22,9 +22,9 @@ var _classnames2 = require('classnames'); var _classnames3 = _interopRequireDefault(_classnames2); -var _reactAddonsUpdate = require('react-addons-update'); +var _immutabilityHelper = require('immutability-helper'); -var _reactAddonsUpdate2 = _interopRequireDefault(_reactAddonsUpdate); +var _immutabilityHelper2 = _interopRequireDefault(_immutabilityHelper); var _reactCssThemr = require('react-css-themr'); @@ -38,6 +38,10 @@ var _prefixer = require('../utils/prefixer'); var _prefixer2 = _interopRequireDefault(_prefixer); +var _utils = require('../utils/utils'); + +var _utils2 = _interopRequireDefault(_utils); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } @@ -76,7 +80,7 @@ var rippleFactory = function rippleFactory() { _inherits(RippledComponent, _Component); function RippledComponent() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -86,7 +90,7 @@ var rippleFactory = function rippleFactory() { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(RippledComponent)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = RippledComponent.__proto__ || Object.getPrototypeOf(RippledComponent)).call.apply(_ref, [this].concat(args))), _this), _this.state = { ripples: {} }, _this.handleMouseDown = function (event) { if (_this.props.onMouseDown) _this.props.onMouseDown(event); @@ -146,10 +150,7 @@ var rippleFactory = function rippleFactory() { if (e.propertyName === 'opacity') { if (self.props.onRippleEnded) self.props.onRippleEnded(e); _events2.default.removeEventListenerOnTransitionEnded(self.refs[rippleKey], onOpacityEnd); - self.setState({ ripples: (0, _reactAddonsUpdate2.default)(self.state.ripples, _defineProperty({}, rippleKey, { $apply: function $apply(ripplesState) { - delete ripplesState[rippleKey]; - return ripplesState; - } })) }); + self.setState({ ripples: _utils2.default.removeObjectKey(rippleKey, self.state.ripples) }); } }); } @@ -184,9 +185,9 @@ var rippleFactory = function rippleFactory() { var endRipple = _this3.addRippleDeactivateEventListener(isTouch, key); var initialState = { active: false, restarting: true, top: top, left: left, width: width, endRipple: endRipple }; var runningState = { active: true, restarting: false }; - _this3.setState((0, _reactAddonsUpdate2.default)(_this3.state, { ripples: _defineProperty({}, key, { $set: initialState }) }), function () { + _this3.setState((0, _immutabilityHelper2.default)(_this3.state, { ripples: _defineProperty({}, key, { $set: initialState }) }), function () { _this3.refs[key].offsetWidth; //eslint-disable-line no-unused-expressions - _this3.setState((0, _reactAddonsUpdate2.default)(_this3.state, { ripples: _defineProperty({}, key, { $merge: runningState }) })); + _this3.setState((0, _immutabilityHelper2.default)(_this3.state, { ripples: _defineProperty({}, key, { $merge: runningState }) })); }); })(); } @@ -249,7 +250,7 @@ var rippleFactory = function rippleFactory() { key: 'getNextKey', value: function getNextKey() { this.currentCount = this.currentCount ? this.currentCount + 1 : 1; - return this.currentCount.toString(); + return 'ripple' + this.currentCount; } /** @@ -262,7 +263,7 @@ var rippleFactory = function rippleFactory() { }, { key: 'getLastKey', value: function getLastKey() { - return this.currentCount.toString(); + return 'ripple' + this.currentCount; } /** @@ -300,19 +301,19 @@ var rippleFactory = function rippleFactory() { var self = this; return function endRipple() { document.removeEventListener(eventType, endRipple); - self.setState({ ripples: (0, _reactAddonsUpdate2.default)(self.state.ripples, _defineProperty({}, rippleKey, { $merge: { active: false } })) }); + self.setState({ ripples: (0, _immutabilityHelper2.default)(self.state.ripples, _defineProperty({}, rippleKey, { $merge: { active: false } })) }); }; } }, { key: 'renderRipple', - value: function renderRipple(key, className, _ref) { + value: function renderRipple(key, className, _ref2) { var _classnames; - var active = _ref.active; - var left = _ref.left; - var restarting = _ref.restarting; - var top = _ref.top; - var width = _ref.width; + var active = _ref2.active; + var left = _ref2.left; + var restarting = _ref2.restarting; + var top = _ref2.top; + var width = _ref2.width; var scale = restarting ? 0 : 1; var transform = 'translate3d(' + (-width / 2 + left) + 'px, ' + (-width / 2 + top) + 'px, 0) scale(' + scale + ')'; diff --git a/lib/slider/Slider.js b/lib/slider/Slider.js index c838283e..10ac5244 100644 --- a/lib/slider/Slider.js +++ b/lib/slider/Slider.js @@ -58,7 +58,7 @@ var factory = function factory(ProgressBar, Input) { _inherits(Slider, _Component); function Slider() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -68,7 +68,7 @@ var factory = function factory(ProgressBar, Input) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Slider)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Slider.__proto__ || Object.getPrototypeOf(Slider)).call.apply(_ref, [this].concat(args))), _this), _this.state = { inputFocused: false, inputValue: null, sliderLength: 0, diff --git a/lib/snackbar/Snackbar.js b/lib/snackbar/Snackbar.js index bbb90867..b4ae2f99 100644 --- a/lib/snackbar/Snackbar.js +++ b/lib/snackbar/Snackbar.js @@ -52,7 +52,7 @@ var factory = function factory(Overlay, Button) { function Snackbar() { _classCallCheck(this, Snackbar); - return _possibleConstructorReturn(this, Object.getPrototypeOf(Snackbar).apply(this, arguments)); + return _possibleConstructorReturn(this, (Snackbar.__proto__ || Object.getPrototypeOf(Snackbar)).apply(this, arguments)); } _createClass(Snackbar, [{ diff --git a/lib/switch/Switch.js b/lib/switch/Switch.js index 96ad9977..b723eccb 100644 --- a/lib/switch/Switch.js +++ b/lib/switch/Switch.js @@ -44,7 +44,7 @@ var factory = function factory(Thumb) { _inherits(Switch, _Component); function Switch() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -54,7 +54,7 @@ var factory = function factory(Thumb) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Switch)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleToggle = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Switch.__proto__ || Object.getPrototypeOf(Switch)).call.apply(_ref, [this].concat(args))), _this), _this.handleToggle = function (event) { if (event.pageX !== 0 && event.pageY !== 0) _this.blur(); if (!_this.props.disabled && _this.props.onChange) { _this.props.onChange(!_this.props.checked, event); diff --git a/lib/table/Table.js b/lib/table/Table.js index addc42c9..6ad6b563 100644 --- a/lib/table/Table.js +++ b/lib/table/Table.js @@ -44,7 +44,7 @@ var factory = function factory(TableHead, TableRow) { _inherits(Table, _Component); function Table() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -54,7 +54,7 @@ var factory = function factory(TableHead, TableRow) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Table)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleFullSelect = function () { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Table.__proto__ || Object.getPrototypeOf(Table)).call.apply(_ref, [this].concat(args))), _this), _this.handleFullSelect = function () { if (_this.props.onSelect) { var _this$props = _this.props; var source = _this$props.source; diff --git a/lib/table/TableRow.js b/lib/table/TableRow.js index ae0a25cc..b6405e13 100644 --- a/lib/table/TableRow.js +++ b/lib/table/TableRow.js @@ -33,7 +33,7 @@ var factory = function factory(Checkbox) { _inherits(TableRow, _Component); function TableRow() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -43,7 +43,7 @@ var factory = function factory(Checkbox) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(TableRow)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleInputChange = function (index, key, type, event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = TableRow.__proto__ || Object.getPrototypeOf(TableRow)).call.apply(_ref, [this].concat(args))), _this), _this.handleInputChange = function (index, key, type, event) { var value = type === 'checkbox' ? event.target.checked : event.target.value; var onChange = _this.props.model[key].onChange || _this.props.onChange; onChange(index, key, value); diff --git a/lib/tabs/Tab.js b/lib/tabs/Tab.js index 7035a5b5..60240cda 100644 --- a/lib/tabs/Tab.js +++ b/lib/tabs/Tab.js @@ -37,7 +37,7 @@ var Tab = function (_Component) { _inherits(Tab, _Component); function Tab() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -47,7 +47,7 @@ var Tab = function (_Component) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Tab)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleClick = function (event) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Tab.__proto__ || Object.getPrototypeOf(Tab)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (event) { if (!_this.props.disabled && _this.props.onClick) { _this.props.onClick(event); } diff --git a/lib/tabs/TabContent.js b/lib/tabs/TabContent.js index 96f3538b..65bd7a6a 100644 --- a/lib/tabs/TabContent.js +++ b/lib/tabs/TabContent.js @@ -35,7 +35,7 @@ var TabContent = function (_Component) { function TabContent() { _classCallCheck(this, TabContent); - return _possibleConstructorReturn(this, Object.getPrototypeOf(TabContent).apply(this, arguments)); + return _possibleConstructorReturn(this, (TabContent.__proto__ || Object.getPrototypeOf(TabContent)).apply(this, arguments)); } _createClass(TabContent, [{ diff --git a/lib/tabs/Tabs.js b/lib/tabs/Tabs.js index 1dc68473..34eda37d 100644 --- a/lib/tabs/Tabs.js +++ b/lib/tabs/Tabs.js @@ -11,9 +11,9 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); -var _classnames = require('classnames'); +var _classnames2 = require('classnames'); -var _classnames2 = _interopRequireDefault(_classnames); +var _classnames3 = _interopRequireDefault(_classnames2); var _reactCssThemr = require('react-css-themr'); @@ -29,6 +29,8 @@ var _TabContent2 = _interopRequireDefault(_TabContent); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } @@ -40,7 +42,7 @@ var factory = function factory(Tab, TabContent) { _inherits(Tabs, _Component); function Tabs() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -50,11 +52,22 @@ var factory = function factory(Tab, TabContent) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Tabs)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Tabs.__proto__ || Object.getPrototypeOf(Tabs)).call.apply(_ref, [this].concat(args))), _this), _this.state = { pointer: {} }, _this.handleHeaderClick = function (event) { var idx = parseInt(event.currentTarget.id); if (_this.props.onChange) _this.props.onChange(idx); + }, _this.handleResize = function () { + if (!_this.props.fixed) { + return; + } + + if (_this.resizeTimeout) { + clearTimeout(_this.resizeTimeout); + } + _this.resizeTimeout = setTimeout(_this.handleResizeEnd, 50); + }, _this.handleResizeEnd = function () { + _this.updatePointer(_this.props.index); }, _temp), _possibleConstructorReturn(_this, _ret); } @@ -62,6 +75,8 @@ var factory = function factory(Tab, TabContent) { key: 'componentDidMount', value: function componentDidMount() { !this.props.disableAnimatedBottomBorder && this.updatePointer(this.props.index); + window.addEventListener('resize', this.handleResize); + this.handleResize(); } }, { key: 'componentWillReceiveProps', @@ -71,6 +86,8 @@ var factory = function factory(Tab, TabContent) { }, { key: 'componentWillUnmount', value: function componentWillUnmount() { + window.removeEventListener('resize', this.handleResize); + clearTimeout(this.resizeTimeout); clearTimeout(this.pointerTimeout); } }, { @@ -121,8 +138,12 @@ var factory = function factory(Tab, TabContent) { return _react2.default.cloneElement(item, { id: idx, key: idx, + theme: _this4.props.theme, active: _this4.props.index === idx, - onClick: _this4.handleHeaderClick + onClick: function onClick(event) { + _this4.handleHeaderClick(event); + item.props.onClick && item.props.onClick(event); + } }); }); } @@ -138,6 +159,7 @@ var factory = function factory(Tab, TabContent) { if (contents && contents[activeIdx]) { return _react2.default.cloneElement(contents[activeIdx], { key: activeIdx, + theme: this.props.theme, active: true, tabIndex: activeIdx }); @@ -146,18 +168,23 @@ var factory = function factory(Tab, TabContent) { }, { key: 'render', value: function render() { + var _classnames; + var _props = this.props; var className = _props.className; var theme = _props.theme; + var fixed = _props.fixed; + var inverse = _props.inverse; var _parseChildren = this.parseChildren(); var headers = _parseChildren.headers; var contents = _parseChildren.contents; + var classes = (0, _classnames3.default)(theme.tabs, className, (_classnames = {}, _defineProperty(_classnames, theme.fixed, fixed), _defineProperty(_classnames, theme.inverse, inverse), _classnames)); return _react2.default.createElement( 'div', - { ref: 'tabs', 'data-react-toolbox': 'tabs', className: (0, _classnames2.default)(theme.tabs, className) }, + { ref: 'tabs', 'data-react-toolbox': 'tabs', className: classes }, _react2.default.createElement( 'nav', { className: theme.navigation, ref: 'navigation' }, @@ -176,16 +203,22 @@ var factory = function factory(Tab, TabContent) { children: _react.PropTypes.node, className: _react.PropTypes.string, disableAnimatedBottomBorder: _react.PropTypes.bool, + fixed: _react.PropTypes.bool, index: _react.PropTypes.number, + inverse: _react.PropTypes.bool, onChange: _react.PropTypes.func, theme: _react.PropTypes.shape({ + fixed: _react.PropTypes.string, + inverse: _react.PropTypes.string, navigation: _react.PropTypes.string, pointer: _react.PropTypes.string, tabs: _react.PropTypes.string }) }; Tabs.defaultProps = { - index: 0 + index: 0, + fixed: false, + inverse: false }; diff --git a/lib/tabs/__tests__/index.spec.js b/lib/tabs/__tests__/index.spec.js index 9f6ffa9c..4995f871 100644 --- a/lib/tabs/__tests__/index.spec.js +++ b/lib/tabs/__tests__/index.spec.js @@ -18,6 +18,10 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _reactDom = require('react-dom'); + +var _reactDom2 = _interopRequireDefault(_reactDom); + var _Tabs = require('../Tabs'); var _Tabs2 = _interopRequireDefault(_Tabs); @@ -30,6 +34,10 @@ var _TabContent = require('../TabContent'); var _TabContent2 = _interopRequireDefault(_TabContent); +var _theme = require('../theme.scss'); + +var _theme2 = _interopRequireDefault(_theme); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -38,6 +46,11 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +var getRenderedClassName = function getRenderedClassName(tree, TargetComponent) { + var rendered = _reactAddonsTestUtils2.default.findRenderedComponentWithType(tree, TargetComponent); + return _reactDom2.default.findDOMNode(rendered).getAttribute('class'); +}; + describe('Tabs', function () { var tabContents = void 0, composition = void 0; @@ -49,7 +62,7 @@ describe('Tabs', function () { function Composition() { _classCallCheck(this, Composition); - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Composition).call(this)); + var _this = _possibleConstructorReturn(this, (Composition.__proto__ || Object.getPrototypeOf(Composition)).call(this)); _this.state = { index: 0 }; return _this; @@ -97,4 +110,30 @@ describe('Tabs', function () { (0, _expect2.default)(tabContents.length).toEqual(1); (0, _expect2.default)(tabContents[0].props.tabIndex).toEqual(1); }); + + describe('#render', function () { + it('does not use fixed by default', function () { + var tree = _reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement(_Tabs2.default, { theme: _theme2.default })); + var className = getRenderedClassName(tree, _Tabs.Tabs); + (0, _expect2.default)(className).toNotContain(_theme2.default.fixed); + }); + + it('uses fixed when set', function () { + var tree = _reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement(_Tabs2.default, { theme: _theme2.default, fixed: true })); + var className = getRenderedClassName(tree, _Tabs.Tabs); + (0, _expect2.default)(className).toContain(_theme2.default.fixed); + }); + + it('does not use inverse by default', function () { + var tree = _reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement(_Tabs2.default, { theme: _theme2.default })); + var className = getRenderedClassName(tree, _Tabs.Tabs); + (0, _expect2.default)(className).toNotContain(_theme2.default.inverse); + }); + + it('uses inverse when set', function () { + var tree = _reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement(_Tabs2.default, { theme: _theme2.default, inverse: true })); + var className = getRenderedClassName(tree, _Tabs.Tabs); + (0, _expect2.default)(className).toContain(_theme2.default.inverse); + }); + }); }); \ No newline at end of file diff --git a/lib/tabs/_config.scss b/lib/tabs/_config.scss index f67e5587..4a03d641 100644 --- a/lib/tabs/_config.scss +++ b/lib/tabs/_config.scss @@ -9,3 +9,10 @@ $tab-pointer-height: .2 * $unit !default; $tab-text: $color-black !default; $tab-text-color: $tab-text !default; $tab-text-inactive-color: rgba($tab-text, .7) !default; + +// Inverse +$tab-inverse-bar-color: $color-primary !default; +$tab-inverse-pointer-color: $color-accent !default; +$tab-inverse-text: $color-primary-contrast !default; +$tab-inverse-text-color: $tab-inverse-text !default; +$tab-inverse-text-inactive-color: rgba($tab-inverse-text, .7) !default; diff --git a/lib/tabs/theme.scss b/lib/tabs/theme.scss index f2e77760..9d9fda29 100644 --- a/lib/tabs/theme.scss +++ b/lib/tabs/theme.scss @@ -61,3 +61,27 @@ display: block; } } + +.fixed { + .label { + flex: 1; + text-align: center; + } +} + +.inverse { + .navigation { + background-color: $tab-inverse-bar-color; + } + + .label { + color: $tab-inverse-text-inactive-color; + &.active { + color: $tab-inverse-text-color; + } + } + + .pointer { + background-color: $tab-inverse-pointer-color; + } +} diff --git a/lib/time_picker/Clock.js b/lib/time_picker/Clock.js index 2b74f0a1..aaa55acc 100644 --- a/lib/time_picker/Clock.js +++ b/lib/time_picker/Clock.js @@ -40,7 +40,7 @@ var Clock = function (_Component) { _inherits(Clock, _Component); function Clock() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -50,7 +50,7 @@ var Clock = function (_Component) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Clock)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Clock.__proto__ || Object.getPrototypeOf(Clock)).call.apply(_ref, [this].concat(args))), _this), _this.state = { center: { x: null, y: null }, radius: 0 }, _this.handleHourChange = function (hours) { diff --git a/lib/time_picker/ClockFace.js b/lib/time_picker/ClockFace.js index 54ca2640..b2604a0c 100644 --- a/lib/time_picker/ClockFace.js +++ b/lib/time_picker/ClockFace.js @@ -28,7 +28,7 @@ var Face = function (_Component) { _inherits(Face, _Component); function Face() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -38,7 +38,7 @@ var Face = function (_Component) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Face)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.renderNumber = function (number, idx) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Face.__proto__ || Object.getPrototypeOf(Face)).call.apply(_ref, [this].concat(args))), _this), _this.renderNumber = function (number, idx) { var _this$props = _this.props; var active = _this$props.active; var radius = _this$props.radius; diff --git a/lib/time_picker/ClockHand.js b/lib/time_picker/ClockHand.js index 053b19e0..d16bdaea 100644 --- a/lib/time_picker/ClockHand.js +++ b/lib/time_picker/ClockHand.js @@ -34,7 +34,7 @@ var Hand = function (_Component) { _inherits(Hand, _Component); function Hand() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -44,7 +44,7 @@ var Hand = function (_Component) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Hand)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Hand.__proto__ || Object.getPrototypeOf(Hand)).call.apply(_ref, [this].concat(args))), _this), _this.state = { knobWidth: 0 }, _this.handleMouseMove = function (event) { _this.move(_events2.default.getMousePosition(event)); diff --git a/lib/time_picker/ClockHours.js b/lib/time_picker/ClockHours.js index 85a711ab..3b4ee10f 100644 --- a/lib/time_picker/ClockHours.js +++ b/lib/time_picker/ClockHours.js @@ -41,7 +41,7 @@ var Hours = function (_Component) { _inherits(Hours, _Component); function Hours() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -51,7 +51,7 @@ var Hours = function (_Component) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Hours)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Hours.__proto__ || Object.getPrototypeOf(Hours)).call.apply(_ref, [this].concat(args))), _this), _this.state = { inner: _this.props.format === '24hr' && _this.props.selected > 0 && _this.props.selected <= 12 }, _this.handleHandMove = function (degrees, radius) { var currentInner = radius < _this.props.radius - _this.props.spacing * innerSpacing; diff --git a/lib/time_picker/ClockMinutes.js b/lib/time_picker/ClockMinutes.js index 780a90ba..0b21e74a 100644 --- a/lib/time_picker/ClockMinutes.js +++ b/lib/time_picker/ClockMinutes.js @@ -37,7 +37,7 @@ var Minutes = function (_Component) { _inherits(Minutes, _Component); function Minutes() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -47,7 +47,7 @@ var Minutes = function (_Component) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Minutes)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.handleHandMove = function (degrees) { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Minutes.__proto__ || Object.getPrototypeOf(Minutes)).call.apply(_ref, [this].concat(args))), _this), _this.handleHandMove = function (degrees) { _this.props.onChange(degrees / step); }, _this.handleMouseDown = function (event) { _this.refs.hand.mouseStart(event); diff --git a/lib/time_picker/TimePicker.js b/lib/time_picker/TimePicker.js index d4dc2e75..2e0a06ae 100644 --- a/lib/time_picker/TimePicker.js +++ b/lib/time_picker/TimePicker.js @@ -58,7 +58,7 @@ var factory = function factory(TimePickerDialog, Input) { _inherits(TimePicker, _Component); function TimePicker() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -68,7 +68,7 @@ var factory = function factory(TimePickerDialog, Input) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(TimePicker)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = TimePicker.__proto__ || Object.getPrototypeOf(TimePicker)).call.apply(_ref, [this].concat(args))), _this), _this.state = { active: _this.props.active }, _this.handleDismiss = function () { _this.setState({ active: false }); diff --git a/lib/time_picker/TimePickerDialog.js b/lib/time_picker/TimePickerDialog.js index 92e55b2d..9d4dcefb 100644 --- a/lib/time_picker/TimePickerDialog.js +++ b/lib/time_picker/TimePickerDialog.js @@ -35,7 +35,7 @@ var factory = function factory(Dialog) { _inherits(TimePickerDialog, _Component); function TimePickerDialog() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -45,7 +45,7 @@ var factory = function factory(Dialog) { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(TimePickerDialog)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = TimePickerDialog.__proto__ || Object.getPrototypeOf(TimePickerDialog)).call.apply(_ref, [this].concat(args))), _this), _this.state = { display: 'hours', displayTime: _this.props.value }, _this.handleClockChange = function (value) { diff --git a/lib/tooltip/Tooltip.js b/lib/tooltip/Tooltip.js index b77620ef..a57b41d7 100644 --- a/lib/tooltip/Tooltip.js +++ b/lib/tooltip/Tooltip.js @@ -78,7 +78,7 @@ var tooltipFactory = function tooltipFactory() { _inherits(TooltippedComponent, _Component); function TooltippedComponent() { - var _Object$getPrototypeO; + var _ref; var _temp, _this, _ret; @@ -88,7 +88,7 @@ var tooltipFactory = function tooltipFactory() { args[_key] = arguments[_key]; } - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(TooltippedComponent)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = TooltippedComponent.__proto__ || Object.getPrototypeOf(TooltippedComponent)).call.apply(_ref, [this].concat(args))), _this), _this.state = { active: false, position: _this.props.tooltipPosition, visible: false @@ -118,12 +118,12 @@ var tooltipFactory = function tooltipFactory() { } }, { key: 'activate', - value: function activate(_ref) { + value: function activate(_ref2) { var _this2 = this; - var top = _ref.top; - var left = _ref.left; - var position = _ref.position; + var top = _ref2.top; + var left = _ref2.left; + var position = _ref2.position; if (this.timeout) clearTimeout(this.timeout); this.setState({ visible: true, position: position }); diff --git a/lib/utils/utils.js b/lib/utils/utils.js index e31db244..e95ea63c 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -60,5 +60,14 @@ exports.default = { return value ? 'on' : ''; } return value; + }, + removeObjectKey: function removeObjectKey(key, object) { + var newObject = {}; + Object.keys(object).filter(function (k) { + return k !== key; + }).forEach(function (k) { + newObject[k] = object[k]; + }); + return newObject; } }; \ No newline at end of file