rmc-cascader
Advanced tools
Comparing version 0.2.10 to 0.3.0
@@ -85,4 +85,11 @@ 'use strict'; | ||
if (this.state.visible) { | ||
if (!this.onDocumentClickListener) { | ||
this.onDocumentClickListener = (0, _utils.addEventListener)(document, 'click', this.onDocumentClick); | ||
} | ||
_reactDom2['default'].render(this.getModal(), this.popupContainer); | ||
} else { | ||
if (this.onDocumentClickListener) { | ||
this.onDocumentClickListener.remove(); | ||
this.onDocumentClickListener = null; | ||
} | ||
this.pickerValue = null; | ||
@@ -125,10 +132,17 @@ _reactDom2['default'].unmountComponentAtNode(this.popupContainer); | ||
}, | ||
onDocumentClick: function onDocumentClick(e) { | ||
if (e.target !== this.modalContent && !(0, _utils.contains)(this.modalContent, e.target)) { | ||
this.setVisibleState(false); | ||
} | ||
}, | ||
setVisibleState: function setVisibleState(visible) { | ||
this.setState({ | ||
visible: visible | ||
}); | ||
if (!visible) { | ||
if (this.state.visible !== visible) { | ||
this.setState({ | ||
pickerValue: null | ||
visible: visible | ||
}); | ||
if (!visible) { | ||
this.setState({ | ||
pickerValue: null | ||
}); | ||
} | ||
} | ||
@@ -166,18 +180,22 @@ }, | ||
'div', | ||
{ className: prefixCls + '-popup-header' }, | ||
{ ref: this.saveModalContent }, | ||
_react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-popup-item', onClick: this.onDismiss }, | ||
dismissText | ||
{ className: prefixCls + '-popup-header' }, | ||
_react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-popup-item', onClick: this.onDismiss }, | ||
dismissText | ||
), | ||
_react2['default'].createElement('div', { className: prefixCls + '-popup-item' }), | ||
_react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-popup-item', onClick: this.onChange }, | ||
okText | ||
) | ||
), | ||
_react2['default'].createElement('div', { className: prefixCls + '-popup-item' }), | ||
_react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-popup-item', onClick: this.onChange }, | ||
okText | ||
) | ||
), | ||
_react2['default'].createElement(_MCascader2['default'], _extends({ data: data, value: this.state.pickerValue || value, | ||
cols: cols, | ||
onChange: this.onPickerChange }, extraProps)) | ||
_react2['default'].createElement(_MCascader2['default'], _extends({ data: data, value: this.state.pickerValue || value, | ||
cols: cols, | ||
onChange: this.onPickerChange }, extraProps)) | ||
) | ||
); | ||
@@ -191,2 +209,5 @@ }, | ||
}, | ||
saveModalContent: function saveModalContent(content) { | ||
this.modalContent = content; | ||
}, | ||
render: function render() { | ||
@@ -193,0 +214,0 @@ var props = this.props; |
@@ -1,8 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.getDefaultValue = getDefaultValue; | ||
exports.addEventListener = addEventListener; | ||
exports.contains = contains; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _reactDom = require('react-dom'); | ||
var _reactDom2 = _interopRequireDefault(_reactDom); | ||
function getDefaultValue(d, val, cols) { | ||
@@ -25,3 +33,28 @@ var data = d; | ||
function addEventListener(target, eventType, cb) { | ||
/* eslint camelcase: 2 */ | ||
var callback = _reactDom2['default'].unstable_batchedUpdates ? function run(e) { | ||
_reactDom2['default'].unstable_batchedUpdates(cb, e); | ||
} : cb; | ||
target.addEventListener(eventType, callback, false); | ||
return { | ||
remove: function remove() { | ||
target.removeEventListener(eventType, callback, false); | ||
} | ||
}; | ||
} | ||
function contains(root, n) { | ||
var node = n; | ||
while (node) { | ||
if (node === root) { | ||
return true; | ||
} | ||
node = node.parentNode; | ||
} | ||
return false; | ||
} | ||
var COLS = 3; | ||
exports.COLS = COLS; |
{ | ||
"name": "rmc-cascader", | ||
"version": "0.2.10", | ||
"version": "0.3.0", | ||
"description": "m-cascader ui component for react", | ||
@@ -12,3 +12,2 @@ "keywords": [ | ||
"homepage": "https://github.com/react-component/m-cascader", | ||
"author": "hualei5280@gmail.com", | ||
"repository": { | ||
@@ -63,2 +62,2 @@ "type": "git", | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18486
416
2