@collab-ui/react
Advanced tools
Comparing version 8.4.1 to 8.4.2
@@ -0,1 +1,8 @@ | ||
## [8.4.2](https://github.com/collab-ui/collab-ui-react/compare/v8.4.1...v8.4.2) (2018-08-07) | ||
### Bug Fixes | ||
* **Select:** add value prop, fix onSelect function ([e9e32a6](https://github.com/collab-ui/collab-ui-react/commit/e9e32a6)) | ||
## [8.4.1](https://github.com/collab-ui/collab-ui-react/compare/v8.4.0...v8.4.1) (2018-08-03) | ||
@@ -2,0 +9,0 @@ |
@@ -47,4 +47,4 @@ import "core-js/modules/web.dom.iterable"; | ||
return { | ||
setSelected: function setSelected(e, idx, value) { | ||
return _this.setSelected(e, idx, value); | ||
setSelected: function setSelected(e, idx, value, label) { | ||
return _this.setSelected(e, idx, value, label); | ||
}, | ||
@@ -65,3 +65,3 @@ handleListKeyDown: function handleListKeyDown(e, idx) { | ||
_this.setSelected = function (e, index, value) { | ||
_this.setSelected = function (e, index, value, label) { | ||
var _this$props = _this.props, | ||
@@ -76,3 +76,3 @@ children = _this$props.children, | ||
if (onSelect) { | ||
return onSelect(e, value, index); | ||
return onSelect(e, value, index, label); | ||
} // Don't do anything if index is the same or outside of the bounds | ||
@@ -79,0 +79,0 @@ |
@@ -80,2 +80,3 @@ import "core-js/modules/es6.object.keys"; | ||
itemIndex = _this$props.itemIndex, | ||
label = _this$props.label, | ||
onClick = _this$props.onClick, | ||
@@ -91,3 +92,3 @@ value = _this$props.value; | ||
e.persist(); | ||
setSelected && setSelected(e, itemIndex, value); | ||
setSelected && setSelected(e, itemIndex, value, label); | ||
onClick && onClick(e); | ||
@@ -94,0 +95,0 @@ }; |
@@ -5,4 +5,2 @@ import "core-js/modules/es6.object.assign"; | ||
import "core-js/modules/es6.object.keys"; | ||
import "core-js/modules/es7.array.includes"; | ||
import "core-js/modules/es6.string.includes"; | ||
@@ -23,4 +21,4 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import PropTypes from 'prop-types'; | ||
import { List, Icon, Button, EventOverlay } from "./.."; | ||
import { uniqueId } from 'lodash'; | ||
import { Button, EventOverlay, Icon, List } from "./.."; | ||
import { isEqual, filter, find, uniqueId } from 'lodash'; | ||
@@ -55,3 +53,3 @@ var Select = | ||
_this.handleSelect = function (e, value, index) { | ||
_this.handleSelect = function (e, value, index, label) { | ||
e.preventDefault(); | ||
@@ -62,3 +60,6 @@ var _this$state = _this.state, | ||
var isMulti = _this.props.isMulti; | ||
var isActive = selected.includes(value); | ||
var isActive = find(selected, { | ||
value: value, | ||
label: label | ||
}); | ||
!isMulti && _this.setState({ | ||
@@ -71,4 +72,7 @@ isOpen: false | ||
return _this.setState({ | ||
selected: selected.filter(function (v) { | ||
return v !== value; | ||
selected: filter(selected, function (item) { | ||
return !isEqual(item, { | ||
value: value, | ||
label: label | ||
}); | ||
}), | ||
@@ -81,3 +85,6 @@ selectedIndex: selectedIndex.filter(function (i) { | ||
return _this.setState({ | ||
selected: [value], | ||
selected: [{ | ||
value: value, | ||
label: label | ||
}], | ||
selectedIndex: [index] | ||
@@ -87,3 +94,6 @@ }); | ||
return _this.setState({ | ||
selected: selected.concat([value]), | ||
selected: selected.concat([{ | ||
value: value, | ||
label: label | ||
}]), | ||
selectedIndex: selectedIndex.concat([index]) | ||
@@ -147,3 +157,3 @@ }); | ||
var currentValue = function currentValue() { | ||
if (!isMulti) return selected[0]; | ||
if (!isMulti && selected.length) return selected[0].label; | ||
@@ -166,3 +176,2 @@ if (selected.length === 1) { | ||
id: id, | ||
children: label, | ||
onClick: this.handleToggle, | ||
@@ -176,3 +185,3 @@ ref: function ref(_ref) { | ||
active: isOpen | ||
}, props)); | ||
}, props), label); | ||
var dropdownElement = React.createElement(EventOverlay, { | ||
@@ -179,0 +188,0 @@ allowClickAway: true, |
@@ -72,2 +72,3 @@ import "core-js/modules/es6.object.assign"; | ||
id: id, | ||
label: label, | ||
title: title || label | ||
@@ -88,3 +89,4 @@ }, props), separateChildren); | ||
label: '', | ||
title: '' | ||
title: '', | ||
value: '' | ||
}; | ||
@@ -111,4 +113,7 @@ SelectOption.propTypes = { | ||
/** ListItem Title */ | ||
title: PropTypes.string | ||
title: PropTypes.string, | ||
/** Value */ | ||
value: PropTypes.string | ||
}; | ||
export default SelectOption; |
@@ -62,4 +62,4 @@ "use strict"; | ||
return { | ||
setSelected: function setSelected(e, idx, value) { | ||
return _this.setSelected(e, idx, value); | ||
setSelected: function setSelected(e, idx, value, label) { | ||
return _this.setSelected(e, idx, value, label); | ||
}, | ||
@@ -80,3 +80,3 @@ handleListKeyDown: function handleListKeyDown(e, idx) { | ||
_this.setSelected = function (e, index, value) { | ||
_this.setSelected = function (e, index, value, label) { | ||
var _this$props = _this.props, | ||
@@ -91,3 +91,3 @@ children = _this$props.children, | ||
if (onSelect) { | ||
return onSelect(e, value, index); | ||
return onSelect(e, value, index, label); | ||
} // Don't do anything if index is the same or outside of the bounds | ||
@@ -94,0 +94,0 @@ |
@@ -99,2 +99,3 @@ "use strict"; | ||
itemIndex = _this$props.itemIndex, | ||
label = _this$props.label, | ||
onClick = _this$props.onClick, | ||
@@ -110,3 +111,3 @@ value = _this$props.value; | ||
e.persist(); | ||
setSelected && setSelected(e, itemIndex, value); | ||
setSelected && setSelected(e, itemIndex, value, label); | ||
onClick && onClick(e); | ||
@@ -113,0 +114,0 @@ }; |
"use strict"; | ||
require("core-js/modules/es6.array.find"); | ||
exports.__esModule = true; | ||
@@ -14,6 +16,2 @@ exports.default = void 0; | ||
require("core-js/modules/es7.array.includes"); | ||
require("core-js/modules/es6.string.includes"); | ||
var _react = _interopRequireDefault(require("react")); | ||
@@ -65,3 +63,3 @@ | ||
_this.handleSelect = function (e, value, index) { | ||
_this.handleSelect = function (e, value, index, label) { | ||
e.preventDefault(); | ||
@@ -72,3 +70,6 @@ var _this$state = _this.state, | ||
var isMulti = _this.props.isMulti; | ||
var isActive = selected.includes(value); | ||
var isActive = (0, _lodash.find)(selected, { | ||
value: value, | ||
label: label | ||
}); | ||
!isMulti && _this.setState({ | ||
@@ -81,4 +82,7 @@ isOpen: false | ||
return _this.setState({ | ||
selected: selected.filter(function (v) { | ||
return v !== value; | ||
selected: (0, _lodash.filter)(selected, function (item) { | ||
return !(0, _lodash.isEqual)(item, { | ||
value: value, | ||
label: label | ||
}); | ||
}), | ||
@@ -91,3 +95,6 @@ selectedIndex: selectedIndex.filter(function (i) { | ||
return _this.setState({ | ||
selected: [value], | ||
selected: [{ | ||
value: value, | ||
label: label | ||
}], | ||
selectedIndex: [index] | ||
@@ -97,3 +104,6 @@ }); | ||
return _this.setState({ | ||
selected: selected.concat([value]), | ||
selected: selected.concat([{ | ||
value: value, | ||
label: label | ||
}]), | ||
selectedIndex: selectedIndex.concat([index]) | ||
@@ -157,3 +167,3 @@ }); | ||
var currentValue = function currentValue() { | ||
if (!isMulti) return selected[0]; | ||
if (!isMulti && selected.length) return selected[0].label; | ||
@@ -177,3 +187,2 @@ if (selected.length === 1) { | ||
id: id, | ||
children: label, | ||
onClick: this.handleToggle, | ||
@@ -187,3 +196,3 @@ ref: function ref(_ref) { | ||
active: isOpen | ||
}, props)); | ||
}, props), label); | ||
@@ -190,0 +199,0 @@ var dropdownElement = _react.default.createElement(_.EventOverlay, { |
@@ -85,2 +85,3 @@ "use strict"; | ||
id: id, | ||
label: label, | ||
title: title || label | ||
@@ -101,3 +102,4 @@ }, props), separateChildren); | ||
label: '', | ||
title: '' | ||
title: '', | ||
value: '' | ||
}; | ||
@@ -124,5 +126,8 @@ SelectOption.propTypes = { | ||
/** ListItem Title */ | ||
title: _propTypes.default.string | ||
title: _propTypes.default.string, | ||
/** Value */ | ||
value: _propTypes.default.string | ||
}; | ||
var _default = SelectOption; | ||
exports.default = _default; |
{ | ||
"name": "@collab-ui/react", | ||
"version": "8.4.1", | ||
"version": "8.4.2", | ||
"description": "Cisco Collab UI framework for ReactJs applications", | ||
@@ -5,0 +5,0 @@ "author": "Cisco Systems, Inc.", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
10500810
40920