Comparing version 0.3.4 to 0.3.5
@@ -33,2 +33,9 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Alert | ||
* | ||
* @param {Object} props 属性 | ||
* @return {ReactElement} | ||
*/ | ||
/** | ||
* @file melon/dialog/Alert | ||
@@ -35,0 +42,0 @@ * @author cxtom(cxtom2008@gmail.com) |
@@ -38,5 +38,20 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/BoxGroup | ||
* | ||
* @extends {melon-core/InputComponent} | ||
* @class | ||
*/ | ||
var BoxGroup = function (_InputComponent) { | ||
babelHelpers.inherits(BoxGroup, _InputComponent); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
* @param {*} context 上下文 | ||
*/ | ||
function BoxGroup(props, context) { | ||
@@ -49,2 +64,8 @@ babelHelpers.classCallCheck(this, BoxGroup); | ||
/** | ||
* 状态 | ||
* | ||
* @protected | ||
* @type {Object} | ||
*/ | ||
_this.state = babelHelpers['extends']({}, _this.state, { | ||
@@ -60,2 +81,10 @@ value: Array.isArray(value) ? value : [value] | ||
/** | ||
* 值改变时处理 | ||
* | ||
* @protected | ||
* @param {Object} e 事件对象 | ||
*/ | ||
BoxGroup.prototype.onChange = function onChange(e) { | ||
@@ -168,2 +197,8 @@ | ||
/** | ||
* 生成 BoxGroup 的选项 | ||
* | ||
* @param {Array<{disabled: boolean, name: string, value: string}>} datasource 数据 | ||
* @return {Array<ReactElement>} | ||
*/ | ||
function createOptions(datasource) { | ||
@@ -170,0 +205,0 @@ |
@@ -34,2 +34,9 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/* eslint-disable fecs-prefer-class */ | ||
/** | ||
* melon/Breadcrumb | ||
* | ||
* @param {Object} props 属性 | ||
* @return {ReactElement} | ||
*/ | ||
function Breadcrumb(props) { | ||
@@ -36,0 +43,0 @@ var children = props.children; |
@@ -34,2 +34,11 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/* eslint-disable fecs-prefer-class */ | ||
/** | ||
* melon/Button | ||
* | ||
* @param {Object} props 属性 | ||
* @param {boolean} props.disabled 是否不可点击 | ||
* @param {boolean} props.hasRipple 是否有ripple动画 | ||
* @return {ReactElement} | ||
*/ | ||
function Button(props) { | ||
@@ -36,0 +45,0 @@ var hasRipple = props.hasRipple; |
11
Card.js
@@ -32,6 +32,13 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/* eslint-disable fecs-prefer-class */ | ||
/** | ||
* melon/Card | ||
* | ||
* @param {Object} props 属性 | ||
* @return {ReactElement} | ||
*/ | ||
function Card(props) { | ||
var children = props.children; | ||
return _react2['default'].createElement( | ||
@@ -44,2 +51,4 @@ 'div', | ||
/* eslint-enable fecs-prefer-class */ | ||
Card.displayName = 'Card'; | ||
}); |
@@ -29,4 +29,14 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
function throttle(func, wait, options) { | ||
/** | ||
* 限流 | ||
* | ||
* @param {Function} func 被限流的原函数 | ||
* @param {number} wait 限流时间阀 | ||
* @param {Object} options 选项 | ||
* @return {Function} | ||
*/ | ||
function throttle(func, wait) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var timeout = void 0; | ||
@@ -38,6 +48,2 @@ var context = void 0; | ||
if (!options) { | ||
options = {}; | ||
} | ||
var later = function later() { | ||
@@ -44,0 +50,0 @@ |
@@ -38,5 +38,19 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Dialog | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Dialog = function (_Component) { | ||
babelHelpers.inherits(Dialog, _Component); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
*/ | ||
function Dialog(props) { | ||
@@ -47,4 +61,16 @@ babelHelpers.classCallCheck(this, Dialog); | ||
/** | ||
* 保存原始的 html body 样式 | ||
* | ||
* @private | ||
* @type {Object} | ||
*/ | ||
_this.originalHTMLBodySize = {}; | ||
/** | ||
* 初始状态 | ||
* | ||
* @private | ||
* @type {Object} | ||
*/ | ||
_this.state = { | ||
@@ -61,2 +87,10 @@ open: props.open | ||
/** | ||
* Mount时的处理 | ||
* | ||
* @public | ||
* @override | ||
*/ | ||
Dialog.prototype.componentDidMount = function componentDidMount() { | ||
@@ -74,5 +108,5 @@ if (this.state.open) { | ||
Dialog.prototype.componentWillReceiveProps = function componentWillReceiveProps(_ref) { | ||
var open = _ref.open; | ||
Dialog.prototype.componentWillReceiveProps = function componentWillReceiveProps(nestProps) { | ||
var open = nestProps.open; | ||
@@ -171,4 +205,4 @@ if (open === this.state.open) { | ||
{ style: { y: (0, _reactMotion.spring)(open ? 0 : -80) } }, | ||
function (_ref2) { | ||
var y = _ref2.y; | ||
function (_ref) { | ||
var y = _ref.y; | ||
return _react2['default'].createElement( | ||
@@ -202,2 +236,15 @@ _DialogWindow2['default'], | ||
Dialog.displayName = 'Dialog'; | ||
/** | ||
* propTypes | ||
* | ||
* @property {Array<ReactElement>} selectedIndex 选中标签的序号 | ||
* @property {boolean} maskClickClose 是否点击遮罩时隐藏对话框 | ||
* @property {boolean} open 是否显示 | ||
* @property {Function} onHide 隐藏时执行 | ||
* @property {Function} onShow 显示时执行 | ||
* @property {ReactElement|string} title 标题 | ||
* @property {number|string} width 对话框宽度 | ||
*/ | ||
Dialog.propTypes = { | ||
@@ -204,0 +251,0 @@ actions: _react.PropTypes.node, |
@@ -33,2 +33,8 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* 创建一个对话框构造器 | ||
* | ||
* @param {Function} Dialog ReactComponent | ||
* @return {Function} 一个可以实时创建对话框的函数 | ||
*/ | ||
function createDialogCommand(Dialog) { | ||
@@ -35,0 +41,0 @@ |
@@ -41,2 +41,9 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Drawer | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Drawer = function (_Component) { | ||
@@ -123,2 +130,12 @@ babelHelpers.inherits(Drawer, _Component); | ||
/** | ||
* propTypes | ||
* | ||
* @property {number} position 弹出的位置 | ||
* @property {boolean} open 是否打开 | ||
* @property {number} size 宽度 | ||
* @property {boolean} mask 是否需要遮罩 | ||
* @property {boolean} maskClickClose 是否点击遮罩以后关闭 | ||
* @property {Function} onHide 关闭时调用 | ||
*/ | ||
Drawer.propTypes = { | ||
@@ -125,0 +142,0 @@ position: _react.PropTypes.oneOf(Object.keys(REVERT_POSITION)).isRequired, |
@@ -32,2 +32,10 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/* eslint-disable fecs-prefer-class */ | ||
/** | ||
* melon/Icon | ||
* | ||
* @param {Object} props 属性 | ||
* @param {string} props.icon icon名称 | ||
* @return {ReactElement} | ||
*/ | ||
function Icon(props) { | ||
@@ -40,3 +48,2 @@ var icon = props.icon; | ||
} | ||
/* eslint-enable fecs-prefer-class */ | ||
@@ -43,0 +50,0 @@ Icon.propTypes = { |
62
Link.js
/*! 2016 Baidu Inc. All Rights Reserved */ | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['exports', 'react', 'melon-core/classname/cxBuilder', "./babelHelpers"], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports, require('react'), require('melon-core/classname/cxBuilder'), require("./babelHelpers")); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports, global.react, global.cxBuilder, global.babelHelpers); | ||
global.Link = mod.exports; | ||
} | ||
if (typeof define === "function" && define.amd) { | ||
define(['exports', 'react', 'melon-core/classname/cxBuilder', "./babelHelpers"], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports, require('react'), require('melon-core/classname/cxBuilder'), require("./babelHelpers")); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports, global.react, global.cxBuilder, global.babelHelpers); | ||
global.Link = mod.exports; | ||
} | ||
})(this, function (exports, _react, _cxBuilder, babelHelpers) { | ||
'use strict'; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = Link; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = Link; | ||
var _react2 = babelHelpers.interopRequireDefault(_react); | ||
var _react2 = babelHelpers.interopRequireDefault(_react); | ||
/** | ||
* @file melon/Link | ||
* @author leon(ludafa@outlook.com) | ||
*/ | ||
/** | ||
* @file melon/Link | ||
* @author leon(ludafa@outlook.com) | ||
*/ | ||
var cx = (0, _cxBuilder.create)('Link'); | ||
var cx = (0, _cxBuilder.create)('Link'); | ||
/* eslint-disable fecs-prefer-class */ | ||
/* eslint-disable fecs-prefer-class */ | ||
function Link(props) { | ||
/** | ||
* melon/Link | ||
* | ||
* @param {Object} props 属性 | ||
* @return {ReactElement} | ||
*/ | ||
function Link(props) { | ||
return _react2['default'].createElement('a', babelHelpers['extends']({}, props, { className: cx(props).build() })); | ||
} | ||
return _react2['default'].createElement('a', babelHelpers['extends']({}, props, { className: cx(props).build() })); | ||
} | ||
/* eslint-enable fecs-prefer-class */ | ||
Link.displayName = 'Link'; | ||
/* eslint-enable fecs-prefer-class */ | ||
}); |
@@ -32,2 +32,9 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Pager | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Mask = function (_Component) { | ||
@@ -79,6 +86,6 @@ babelHelpers.inherits(Mask, _Component); | ||
Mask.prototype.render = function render() { | ||
var props = this.props; | ||
var show = props.show; | ||
return _react2['default'].createElement('div', babelHelpers['extends']({}, props, { className: cx(props).addStates({ show: show }).build() })); | ||
@@ -85,0 +92,0 @@ }; |
{ | ||
"name": "melon", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "ui components for react", | ||
@@ -12,16 +12,18 @@ "main": "./src", | ||
"devDependencies": { | ||
"babel-core": "^6.10.4", | ||
"babel-core": "^6.13.2", | ||
"babel-istanbul": "^0.11.0", | ||
"babel-plugin-external-helpers": "^6.8.0", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.8.0", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.12.0", | ||
"babel-plugin-transform-es3-member-expression-literals": "^6.8.0", | ||
"babel-plugin-transform-es3-property-literals": "^6.8.0", | ||
"babel-preset-es2015": "^6.9.0", | ||
"babel-preset-es2015": "^6.13.2", | ||
"babel-preset-es2015-loose": "^7.0.0", | ||
"babel-preset-react": "^6.5.0", | ||
"babel-preset-stage-1": "^6.5.0", | ||
"babel-preset-react": "^6.11.1", | ||
"babel-preset-stage-1": "^6.13.0", | ||
"babelify": "^7.3.0", | ||
"browserify": "^13.0.1", | ||
"browserify": "^13.1.0", | ||
"browserify-istanbul": "^2.0.0", | ||
"coveralls": "^2.11.9", | ||
"coveralls": "^2.11.12", | ||
"esdoc": "^0.4.8", | ||
"esdoc-es7-plugin": "0.0.3", | ||
"expect": "^1.12.2", | ||
@@ -31,13 +33,11 @@ "expect-jsx": "^2.0.1", | ||
"jasmine-expect-jsx": "^1.1.2", | ||
"karma": "^1.1.0", | ||
"karma-browserify": "^5.0.5", | ||
"karma-chrome-launcher": "^1.0.1", | ||
"karma-coverage": "^1.0.0", | ||
"karma": "^1.2.0", | ||
"karma-browserify": "^5.1.0", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma-jasmine": "^1.0.2", | ||
"karma-mocha": "^1.1.1", | ||
"karma-mocha-reporter": "^2.0.4", | ||
"karma-mocha-reporter": "^2.1.0", | ||
"karma-sauce-launcher": "^1.0.0", | ||
"lodash": "^3.10.1", | ||
"mocha": "^2.2.5", | ||
"nib": "^1.1.0", | ||
"nib": "^1.1.2", | ||
"react-addons-test-utils": "^0.14.3", | ||
@@ -53,3 +53,4 @@ "stylus": "^0.54.2", | ||
"build": "sh tool/build.sh", | ||
"release": "sh tool/release.sh" | ||
"release": "sh tool/release.sh", | ||
"doc": "esdoc -c esdoc.json" | ||
}, | ||
@@ -56,0 +57,0 @@ "repository": { |
35
Pager.js
@@ -32,5 +32,19 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Pager | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Pager = function (_Component) { | ||
babelHelpers.inherits(Pager, _Component); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
*/ | ||
function Pager(props) { | ||
@@ -43,2 +57,8 @@ babelHelpers.classCallCheck(this, Pager); | ||
/** | ||
* 状态 | ||
* | ||
* @protected | ||
* @type {Object} | ||
*/ | ||
_this.state = { page: page }; | ||
@@ -51,7 +71,16 @@ | ||
Pager.prototype.componentWillReceiveProps = function componentWillReceiveProps(_ref) { | ||
var page = _ref.page; | ||
var total = _ref.total; | ||
/** | ||
* 接受新属性时的处理 | ||
* | ||
* @public | ||
* @override | ||
* @param {*} nextProps 新属性 | ||
*/ | ||
Pager.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
var page = nextProps.page; | ||
var total = nextProps.total; | ||
if (page < 0) { | ||
@@ -58,0 +87,0 @@ page = 0; |
@@ -31,5 +31,19 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Progress | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Progress = function (_Component) { | ||
babelHelpers.inherits(Progress, _Component); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
*/ | ||
function Progress(props) { | ||
@@ -40,2 +54,7 @@ babelHelpers.classCallCheck(this, Progress); | ||
/** | ||
* timerIds | ||
* | ||
* @type {Object} | ||
*/ | ||
_this.timers = {}; | ||
@@ -45,2 +64,10 @@ return _this; | ||
/** | ||
* Mount时的处理 | ||
* | ||
* @public | ||
* @override | ||
*/ | ||
Progress.prototype.componentDidMount = function componentDidMount() { | ||
@@ -79,5 +106,8 @@ var _this2 = this; | ||
Progress.prototype.barUpdate = function barUpdate(step, barName, stepValues) { | ||
Progress.prototype.barUpdate = function barUpdate() { | ||
var step = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; | ||
var barName = arguments[1]; | ||
var stepValues = arguments[2]; | ||
step = step || 0; | ||
step %= 4; | ||
@@ -107,5 +137,6 @@ | ||
Progress.prototype.scalePath = function scalePath(path, step) { | ||
Progress.prototype.scalePath = function scalePath(path) { | ||
var step = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; | ||
step = step || 0; | ||
step %= 3; | ||
@@ -176,3 +207,3 @@ | ||
} else { | ||
children = [_react2['default'].createElement('div', { ref: 'bar1', className: cx().part('bar1').build(), key: 'bar1' }), _react2['default'].createElement('div', { ref: 'bar2', className: cx().part('bar2').build(), key: 'bar2' })]; | ||
children = [_react2['default'].createElement('div', { ref: 'bar1', className: cx.getPartClassName('bar1'), key: 'bar1' }), _react2['default'].createElement('div', { ref: 'bar2', className: cx.getPartClassName('bar2'), key: 'bar2' })]; | ||
} | ||
@@ -182,3 +213,3 @@ | ||
'div', | ||
{ className: cx().part('bar').build(), style: style }, | ||
{ className: cx.getPartClassName('bar'), style: style }, | ||
children | ||
@@ -207,6 +238,6 @@ ); | ||
'div', | ||
{ ref: 'wrapper', className: cx().part('wapper').build() }, | ||
{ ref: 'wrapper', className: cx.getPartClassName('wapper') }, | ||
_react2['default'].createElement( | ||
'svg', | ||
{ className: cx().part('svg').build() }, | ||
{ className: cx.getPartClassName('svg') }, | ||
_react2['default'].createElement('circle', { ref: 'path', | ||
@@ -216,3 +247,3 @@ cx: c, | ||
r: r, | ||
className: cx().part('path').build(), | ||
className: cx.getPartClassName('path'), | ||
style: pathStyle, | ||
@@ -227,3 +258,5 @@ fill: 'none', | ||
Progress.prototype.render = function render() { | ||
var props = this.props; | ||
var shape = props.shape; | ||
@@ -230,0 +263,0 @@ var mode = props.mode; |
@@ -6,3 +6,3 @@ # melon | ||
[![Build Status](https://saucelabs.com/browser-matrix/react-melon.svg)](https://saucelabs.com/beta/builds/9c34f307345147a98a75d3aecf85392a) | ||
[![SauceLabs Status](https://saucelabs.com/browser-matrix/melon-ui.svg)](https://saucelabs.com/u/melon-ui) | ||
@@ -9,0 +9,0 @@ A Set of React Components that Implement Google's Material Design |
@@ -45,5 +45,20 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Select | ||
* | ||
* @extends {melon-core/InputComponent} | ||
* @class | ||
*/ | ||
var Select = function (_InputComponent) { | ||
babelHelpers.inherits(Select, _InputComponent); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
* @param {*} context 上下文 | ||
*/ | ||
function Select(props, context) { | ||
@@ -54,2 +69,7 @@ babelHelpers.classCallCheck(this, Select); | ||
/** | ||
* 状态 | ||
* | ||
* @type {Object} | ||
*/ | ||
_this.state = babelHelpers['extends']({}, _this.state, { | ||
@@ -66,2 +86,10 @@ open: false | ||
/** | ||
* Mount时的处理 | ||
* | ||
* @public | ||
* @override | ||
*/ | ||
Select.prototype.componentDidMount = function componentDidMount() { | ||
@@ -77,2 +105,7 @@ | ||
/** | ||
* 浮层 | ||
* | ||
* @type {Object} | ||
*/ | ||
this.popup = _reactDom2['default'].render(_react2['default'].createElement( | ||
@@ -113,2 +146,8 @@ _SeparatePopup2['default'], | ||
container.parentElement.removeChild(container); | ||
/** | ||
* 浮层的容器 | ||
* | ||
* @type {HTMLElement} | ||
*/ | ||
this.container = container = null; | ||
@@ -120,7 +159,7 @@ } | ||
Select.prototype.showOptions = function showOptions() { | ||
Select.prototype.renderOptions = function renderOptions(open) { | ||
var _this2 = this; | ||
this.setState({ | ||
open: true | ||
open: open | ||
}, function () { | ||
@@ -131,3 +170,3 @@ _reactDom2['default'].render(_react2['default'].createElement( | ||
target: _reactDom2['default'].findDOMNode(_this2), | ||
open: true, | ||
open: open, | ||
onHide: _this2.onPopupHide }, | ||
@@ -139,19 +178,2 @@ _react.Children.map(_this2.props.children, _this2.renderItem, _this2) | ||
Select.prototype.hideOptions = function hideOptions() { | ||
var _this3 = this; | ||
this.setState({ | ||
open: false | ||
}, function () { | ||
_reactDom2['default'].render(_react2['default'].createElement( | ||
_SeparatePopup2['default'], | ||
{ | ||
target: _reactDom2['default'].findDOMNode(_this3), | ||
open: false, | ||
onHide: _this3.onPopupHide }, | ||
_react.Children.map(_this3.props.children, _this3.renderItem, _this3) | ||
), _this3.container); | ||
}); | ||
}; | ||
Select.prototype.onClick = function onClick() { | ||
@@ -167,14 +189,10 @@ var _props = this.props; | ||
if (this.isOpen()) { | ||
this.hideOptions(); | ||
} else { | ||
this.showOptions(); | ||
} | ||
this.renderOptions(!this.isOpen()); | ||
}; | ||
Select.prototype.onClickOption = function onClickOption(_ref) { | ||
var value = _ref.value; | ||
Select.prototype.onClickOption = function onClickOption(e) { | ||
var value = e.value; | ||
this.hideOptions(); | ||
this.renderOptions(false); | ||
@@ -188,4 +206,4 @@ _InputComponent.prototype.onChange.call(this, { | ||
Select.prototype.onPopupHide = function onPopupHide(e) { | ||
this.hideOptions(); | ||
Select.prototype.onPopupHide = function onPopupHide() { | ||
this.renderOptions(false); | ||
}; | ||
@@ -317,2 +335,8 @@ | ||
/** | ||
* 生成 Select 的选项 | ||
* | ||
* @param {Array<{disabled: boolean, name: string, value: string}>} dataSource 数据 | ||
* @return {Array<ReactElement>} | ||
*/ | ||
function createOptions(dataSource) { | ||
@@ -319,0 +343,0 @@ |
/*! 2016 Baidu Inc. All Rights Reserved */ | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['exports', 'react', './Table', './table/SelectorColumn', "./babelHelpers"], factory); | ||
define(['exports', 'react', './Table', './table/SelectorColumn', './table/SelectorRow', "./babelHelpers"], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports, require('react'), require('./Table'), require('./table/SelectorColumn'), require("./babelHelpers")); | ||
factory(exports, require('react'), require('./Table'), require('./table/SelectorColumn'), require('./table/SelectorRow'), require("./babelHelpers")); | ||
} else { | ||
@@ -11,6 +11,6 @@ var mod = { | ||
}; | ||
factory(mod.exports, global.react, global.Table, global.SelectorColumn, global.babelHelpers); | ||
factory(mod.exports, global.react, global.Table, global.SelectorColumn, global.SelectorRow, global.babelHelpers); | ||
global.SelectableTable = mod.exports; | ||
} | ||
})(this, function (exports, _react, _Table, _SelectorColumn, babelHelpers) { | ||
})(this, function (exports, _react, _Table2, _SelectorColumn, _SelectorRow, babelHelpers) { | ||
'use strict'; | ||
@@ -24,6 +24,8 @@ | ||
var _Table2 = babelHelpers.interopRequireDefault(_Table); | ||
var _Table3 = babelHelpers.interopRequireDefault(_Table2); | ||
var _SelectorColumn2 = babelHelpers.interopRequireDefault(_SelectorColumn); | ||
var _SelectorRow2 = babelHelpers.interopRequireDefault(_SelectorRow); | ||
/** | ||
@@ -57,9 +59,21 @@ * @file SelectableTable | ||
var SelectableTable = function (_Component) { | ||
babelHelpers.inherits(SelectableTable, _Component); | ||
/** | ||
* 可选择行的表格 | ||
* | ||
* @extends {Table} | ||
*/ | ||
var SelectableTable = function (_Table) { | ||
babelHelpers.inherits(SelectableTable, _Table); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @param {*} props 属性 | ||
*/ | ||
function SelectableTable(props) { | ||
babelHelpers.classCallCheck(this, SelectableTable); | ||
var _this = babelHelpers.possibleConstructorReturn(this, _Component.call(this, props)); | ||
var _this = babelHelpers.possibleConstructorReturn(this, _Table.call(this, props)); | ||
@@ -72,5 +86,5 @@ _this.getSelected = _this.getSelected.bind(_this); | ||
_this.state = { | ||
_this.state = babelHelpers['extends']({}, _this.state, { | ||
selected: _this.props.selected | ||
}; | ||
}); | ||
@@ -80,7 +94,21 @@ return _this; | ||
/** | ||
* 接受新属性时处理函数 | ||
* | ||
* @public | ||
* @param {*} props 新属性 | ||
*/ | ||
SelectableTable.prototype.componentWillReceiveProps = function componentWillReceiveProps(props) { | ||
if (!this.props.onSelect) { | ||
_Table.prototype.componentWillReceiveProps.call(this, props); | ||
var selected = props.selected; | ||
var onSelect = props.onSelect; | ||
if (onSelect && selected != null) { | ||
this.setState({ | ||
selected: props.selected | ||
selected: selected | ||
}); | ||
@@ -123,45 +151,52 @@ } | ||
SelectableTable.prototype.getSelected = function getSelected() { | ||
var state = this.state; | ||
var props = this.props; | ||
var onSelect = props.onSelect; | ||
var _ref = onSelect ? props : state; | ||
var selected = _ref.selected; | ||
return selected; | ||
var source = this.props.onSelect ? this.props : this.state; | ||
return source.selected; | ||
}; | ||
SelectableTable.prototype.isRowSelected = function isRowSelected(rowIndex) { | ||
var selected = this.getSelected(); | ||
return selected.indexOf(rowIndex) !== -1; | ||
var selectedRows = this.getSelected(); | ||
return selectedRows.indexOf(rowIndex) !== -1; | ||
}; | ||
SelectableTable.prototype.isAllRowsSelected = function isAllRowsSelected() { | ||
var selected = this.getSelected(); | ||
return selected.length === this.props.dataSource.length; | ||
var selectedRows = this.getSelected(); | ||
return selectedRows.length === this.props.dataSource.length; | ||
}; | ||
SelectableTable.prototype.render = function render() { | ||
var _props2 = this.props; | ||
var children = _props2.children; | ||
var multiple = _props2.multiple; | ||
var rest = babelHelpers.objectWithoutProperties(_props2, ['children', 'multiple']); | ||
SelectableTable.prototype.getColumns = function getColumns(props) { | ||
var selectorColumn = _react2['default'].createElement(_SelectorColumn2['default'], { | ||
isSelected: this.isRowSelected, | ||
isAllSelected: this.isAllRowsSelected, | ||
multiple: props.multiple, | ||
onSelect: this.onSelect, | ||
onSelectAll: this.onSelectAll }); | ||
return _react2['default'].createElement( | ||
_Table2['default'], | ||
rest, | ||
_react2['default'].createElement(_SelectorColumn2['default'], { | ||
isSelected: this.isRowSelected, | ||
isAllSelected: this.isAllRowsSelected, | ||
multiple: multiple, | ||
onSelect: this.onSelect, | ||
onSelectAll: this.onSelectAll }), | ||
children | ||
); | ||
var columns = _Table.prototype.getColumns.call(this, props); | ||
return [selectorColumn].concat(columns); | ||
}; | ||
SelectableTable.prototype.renderRow = function renderRow(part, columns, rowData, index, tableWidth) { | ||
var _props2 = this.props; | ||
var rowHeight = _props2.rowHeight; | ||
var headerRowHeight = _props2.headerRowHeight; | ||
var highlight = _props2.highlight; | ||
var rowHasChanged = _props2.rowHasChanged; | ||
return _react2['default'].createElement(_SelectorRow2['default'], { | ||
selected: part === 'body' ? this.isRowSelected(index) : this.isAllRowsSelected(), | ||
height: part === 'body' ? rowHeight : headerRowHeight, | ||
highlight: highlight, | ||
key: index, | ||
rowIndex: index, | ||
part: part, | ||
columns: columns, | ||
data: rowData, | ||
tableWidth: tableWidth, | ||
rowHasChanged: rowHasChanged }); | ||
}; | ||
return SelectableTable; | ||
}(_react.Component); | ||
}(_Table3['default']); | ||
@@ -173,3 +208,3 @@ exports['default'] = SelectableTable; | ||
SelectableTable.propTypes = babelHelpers['extends']({}, _Table2['default'].propTypes, { | ||
SelectableTable.propTypes = babelHelpers['extends']({}, _Table3['default'].propTypes, { | ||
multiple: _react.PropTypes.bool.isRequired, | ||
@@ -180,3 +215,3 @@ onSelect: _react.PropTypes.func, | ||
SelectableTable.defaultProps = babelHelpers['extends']({}, _Table2['default'].defaultProps, { | ||
SelectableTable.defaultProps = babelHelpers['extends']({}, _Table3['default'].defaultProps, { | ||
multiple: true, | ||
@@ -183,0 +218,0 @@ selected: [] |
@@ -42,5 +42,20 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Slider | ||
* | ||
* @extends {melon-core/InputComponent} | ||
* @class | ||
*/ | ||
var Slider = function (_InputComponent) { | ||
babelHelpers.inherits(Slider, _InputComponent); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
* @param {*} context 上下文 | ||
*/ | ||
function Slider(props, context) { | ||
@@ -63,2 +78,8 @@ babelHelpers.classCallCheck(this, Slider); | ||
/** | ||
* 状态 | ||
* | ||
* @protected | ||
* @type {Object} | ||
*/ | ||
_this.state = babelHelpers['extends']({}, _this.state, { | ||
@@ -70,3 +91,18 @@ active: false | ||
/** | ||
* 将要Unmount时的处理 | ||
* | ||
* @public | ||
* @override | ||
*/ | ||
Slider.prototype.componentWillUnmount = function componentWillUnmount() { | ||
/** | ||
* bar | ||
* | ||
* @protected | ||
* @type {HTMLElement} | ||
*/ | ||
this.slider = null; | ||
@@ -81,4 +117,6 @@ }; | ||
Slider.prototype.onMouseChange = function onMouseChange(_ref) { | ||
var clientX = _ref.clientX; | ||
Slider.prototype.onMouseChange = function onMouseChange(e) { | ||
var clientX = e.clientX; | ||
var _props = this.props; | ||
@@ -85,0 +123,0 @@ var maximum = _props.maximum; |
@@ -37,5 +37,19 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/SnackBar | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var SnackBar = function (_Component) { | ||
babelHelpers.inherits(SnackBar, _Component); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
*/ | ||
function SnackBar(props) { | ||
@@ -46,2 +60,7 @@ babelHelpers.classCallCheck(this, SnackBar); | ||
/** | ||
* timeoutId | ||
* | ||
* @type {?number} | ||
*/ | ||
_this.autoHideTimer = null; | ||
@@ -52,2 +71,7 @@ | ||
/** | ||
* 状态 | ||
* | ||
* @type {Object} | ||
*/ | ||
_this.state = { | ||
@@ -60,2 +84,10 @@ open: props.open | ||
/** | ||
* Mount时的处理 | ||
* | ||
* @public | ||
* @override | ||
*/ | ||
SnackBar.prototype.componentDidMount = function componentDidMount() { | ||
@@ -72,5 +104,5 @@ | ||
SnackBar.prototype.componentWillReceiveProps = function componentWillReceiveProps(_ref) { | ||
var open = _ref.open; | ||
SnackBar.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
var open = nextProps.open; | ||
@@ -77,0 +109,0 @@ if (open === this.state.open) { |
73
Table.js
@@ -36,5 +36,17 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* 表格 | ||
* | ||
* @extends React.Component | ||
*/ | ||
var Table = function (_Component) { | ||
babelHelpers.inherits(Table, _Component); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @param {*} props 属性 | ||
*/ | ||
function Table(props) { | ||
@@ -45,5 +57,3 @@ babelHelpers.classCallCheck(this, Table); | ||
_this.state = { | ||
columns: _this.getColumns(_this.props) | ||
}; | ||
_this.state = {}; | ||
@@ -54,2 +64,15 @@ _this.onWindowResize = _this.onWindowResize.bind(_this); | ||
/** | ||
* 即将挂载到 DOM 时处理函数 | ||
* | ||
* @public | ||
*/ | ||
Table.prototype.componentWillMount = function componentWillMount() { | ||
this.setState({ | ||
columns: this.getColumns(this.props) | ||
}); | ||
}; | ||
Table.prototype.componentDidMount = function componentDidMount() { | ||
@@ -80,3 +103,5 @@ this.onWindowResize(); | ||
children.push(child); | ||
children.push((0, _react.cloneElement)(child, { | ||
rowHasChanged: props.rowHasChanged | ||
})); | ||
} | ||
@@ -89,12 +114,6 @@ | ||
Table.prototype.renderHeader = function renderHeader(columns, width) { | ||
var props = this.props; | ||
return _react2['default'].createElement( | ||
'div', | ||
{ className: cx().part('header').build() }, | ||
_react2['default'].createElement(_Row2['default'], { | ||
part: 'header', | ||
height: props.headerRowHeight, | ||
columns: columns, | ||
tableWidth: width }) | ||
{ className: cx.getPartClassName('header') }, | ||
this.renderRow('header', columns, null, -1, width) | ||
); | ||
@@ -112,7 +131,7 @@ }; | ||
var body = dataSource && dataSource.length ? dataSource.map(function (rowData, index) { | ||
return _this2.renderRow(columns, rowData, index, width); | ||
return _this2.renderRow('body', columns, rowData, index, width); | ||
}) : _react2['default'].createElement( | ||
'div', | ||
{ | ||
className: cx().part('body-empty').build(), | ||
className: cx.getPartClassName('body-empty'), | ||
style: { width: width - 2 } }, | ||
@@ -124,3 +143,3 @@ noDataContent | ||
'div', | ||
{ className: cx().part('body').build() }, | ||
{ className: cx.getPartClassName('body') }, | ||
body | ||
@@ -130,16 +149,22 @@ ); | ||
Table.prototype.renderRow = function renderRow(columns, rowData, index, tableWidth) { | ||
Table.prototype.renderRow = function renderRow(part, columns, rowData, index, tableWidth) { | ||
var _props2 = this.props; | ||
var rowHeight = _props2.rowHeight; | ||
var headerRowHeight = _props2.headerRowHeight; | ||
var highlight = _props2.highlight; | ||
var rowHasChanged = _props2.rowHasChanged; | ||
var height = part === 'body' ? rowHeight : headerRowHeight; | ||
return _react2['default'].createElement(_Row2['default'], { | ||
height: rowHeight, | ||
height: height, | ||
highlight: highlight, | ||
key: index, | ||
rowIndex: index, | ||
part: 'body', | ||
part: part, | ||
columns: columns, | ||
data: rowData, | ||
tableWidth: tableWidth }); | ||
tableWidth: tableWidth, | ||
rowHasChanged: rowHasChanged }); | ||
}; | ||
@@ -152,5 +177,5 @@ | ||
Table.prototype.onWindowResize = function onWindowResize() { | ||
var main = this.main; | ||
if (this.main) { | ||
@@ -206,3 +231,4 @@ this.setState({ | ||
dataSource: _react.PropTypes.array.isRequired, | ||
noDataContent: _react.PropTypes.node | ||
noDataContent: _react.PropTypes.node, | ||
rowHasChanged: _react.PropTypes.func.isRequired | ||
}, Table.defaultProps = { | ||
@@ -212,3 +238,6 @@ highlight: true, | ||
headerRowHeight: 56, | ||
noDataContent: '没有数据' | ||
noDataContent: '没有数据', | ||
rowHasChanged: function rowHasChanged(r1, r2) { | ||
return r1 !== r2; | ||
} | ||
}; | ||
@@ -215,0 +244,0 @@ |
@@ -20,13 +20,21 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
}); | ||
exports.default = TableColumn; | ||
/** | ||
* @file TableColumn | ||
* @author leon(ludafa@outlook.com) | ||
*/ | ||
var TableColumn = function (_Component) { | ||
babelHelpers.inherits(TableColumn, _Component); | ||
function TableColumn(props) { | ||
return null; | ||
} | ||
function TableColumn() { | ||
babelHelpers.classCallCheck(this, TableColumn); | ||
return babelHelpers.possibleConstructorReturn(this, _Component.apply(this, arguments)); | ||
} | ||
TableColumn.prototype.render = function render() { | ||
return null; | ||
}; | ||
return TableColumn; | ||
}(_react.Component); | ||
exports['default'] = TableColumn; | ||
TableColumn.displayName = 'TableColumn'; | ||
@@ -66,3 +74,3 @@ | ||
* | ||
* @type {[type]} | ||
* @type {string} | ||
*/ | ||
@@ -69,0 +77,0 @@ title: _react.PropTypes.string, |
122
table/Row.js
@@ -32,58 +32,83 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
function renderCell(props, columnData, index) { | ||
var part = props.part; | ||
var data = props.data; | ||
var height = props.height; | ||
var rowIndex = props.rowIndex; | ||
var width = columnData.width; | ||
var align = columnData.align; | ||
var dataKey = columnData.dataKey; | ||
var cellRenderer = columnData.cellRenderer; | ||
/** | ||
* 表格行 | ||
* | ||
* @extends React.Component | ||
*/ | ||
var TableRow = function (_Component) { | ||
babelHelpers.inherits(TableRow, _Component); | ||
var cellData = part === 'header' || part === 'footer' ? columnData[part] : data[dataKey]; | ||
function TableRow() { | ||
babelHelpers.classCallCheck(this, TableRow); | ||
return babelHelpers.possibleConstructorReturn(this, _Component.apply(this, arguments)); | ||
} | ||
var cellProps = { | ||
part: part, | ||
height: height, | ||
width: width, | ||
align: align, | ||
rowIndex: rowIndex, | ||
columnData: columnData, | ||
cellData: cellData, | ||
key: dataKey || part, | ||
columnIndex: index, | ||
rowData: data, | ||
cellKey: dataKey | ||
TableRow.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { | ||
var _props = this.props; | ||
var tableWidth = _props.tableWidth; | ||
var rowHasChanged = _props.rowHasChanged; | ||
var data = _props.data; | ||
if (tableWidth !== nextProps.tableWidth) { | ||
return true; | ||
} | ||
if (rowHasChanged) { | ||
return rowHasChanged(data, nextProps.data); | ||
} | ||
return true; | ||
}; | ||
// 内容默认是 cellData | ||
var content = cellData; | ||
TableRow.prototype.renderCell = function renderCell(props, columnData, index) { | ||
var part = props.part; | ||
var data = props.data; | ||
var height = props.height; | ||
var rowIndex = props.rowIndex; | ||
var width = columnData.width; | ||
var align = columnData.align; | ||
var dataKey = columnData.dataKey; | ||
var cellRenderer = columnData.cellRenderer; | ||
// 如果有 cellRenderer | ||
if (typeof cellRenderer === 'function') { | ||
content = cellRenderer(cellProps); | ||
} | ||
// 或者是有局部的 renderer | ||
else { | ||
var partSpecificRenderer = columnData[part + 'Renderer']; | ||
var cellData = part === 'header' || part === 'footer' ? columnData[part] : data[dataKey]; | ||
if (typeof partSpecificRenderer === 'function') { | ||
content = partSpecificRenderer(cellProps); | ||
} | ||
var cellProps = { | ||
part: part, | ||
height: height, | ||
width: width, | ||
align: align, | ||
rowIndex: rowIndex, | ||
columnData: columnData, | ||
cellData: cellData, | ||
key: dataKey || part, | ||
columnIndex: index, | ||
rowData: data, | ||
cellKey: dataKey | ||
}; | ||
// 内容默认是 cellData | ||
var content = cellData; | ||
// 如果有 cellRenderer | ||
if (typeof cellRenderer === 'function') { | ||
content = cellRenderer(cellProps); | ||
} | ||
// 或者是有局部的 renderer | ||
else { | ||
return _react2['default'].createElement(_Cell2['default'], babelHelpers['extends']({}, cellProps, { content: content })); | ||
} | ||
var partSpecificRenderer = columnData[part + 'Renderer']; | ||
var TableRow = function (_Component) { | ||
babelHelpers.inherits(TableRow, _Component); | ||
if (typeof partSpecificRenderer === 'function') { | ||
content = partSpecificRenderer(cellProps); | ||
} | ||
} | ||
function TableRow() { | ||
babelHelpers.classCallCheck(this, TableRow); | ||
return babelHelpers.possibleConstructorReturn(this, _Component.apply(this, arguments)); | ||
} | ||
return _react2['default'].createElement(_Cell2['default'], babelHelpers['extends']({}, cellProps, { content: content })); | ||
}; | ||
TableRow.prototype.render = function render() { | ||
var _this2 = this; | ||
@@ -101,3 +126,3 @@ var props = this.props; | ||
columns.map(function (column, index) { | ||
return renderCell(props, column.props, index); | ||
return _this2.renderCell(props, column.props, index); | ||
}) | ||
@@ -137,4 +162,13 @@ ); | ||
*/ | ||
height: _react.PropTypes.number.isRequired | ||
height: _react.PropTypes.number.isRequired, | ||
/** | ||
* 行数据是否发生变化 | ||
* | ||
* 此函数会被用于优化性能。如果返回值为 false,那么当前行不会被更新 | ||
* | ||
* @type {Funciton} | ||
*/ | ||
rowHasChanged: _react.PropTypes.func.isRequired | ||
}; | ||
}); |
@@ -20,3 +20,2 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
}); | ||
exports.default = TableSelectorColumn; | ||
@@ -29,11 +28,20 @@ var _react2 = babelHelpers.interopRequireDefault(_react); | ||
/** | ||
* @file TableSelectorColumn | ||
* @author leon(ludafa@outlook.com) | ||
*/ | ||
var TableSelectorColumn = function (_Component) { | ||
babelHelpers.inherits(TableSelectorColumn, _Component); | ||
function TableSelectorColumn(props) { | ||
return null; | ||
} | ||
function TableSelectorColumn() { | ||
babelHelpers.classCallCheck(this, TableSelectorColumn); | ||
return babelHelpers.possibleConstructorReturn(this, _Component.apply(this, arguments)); | ||
} | ||
TableSelectorColumn.prototype.render = function render() { | ||
return null; | ||
}; | ||
return TableSelectorColumn; | ||
}(_react.Component); | ||
exports['default'] = TableSelectorColumn; | ||
TableSelectorColumn.displayName = 'TableSelectorColumn'; | ||
@@ -61,5 +69,5 @@ | ||
var rowIndex = props.rowIndex; | ||
var multiple = columnData.multiple; | ||
if (!multiple && part !== 'body') { | ||
@@ -66,0 +74,0 @@ return null; |
41
Tabs.js
@@ -34,5 +34,19 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Tabs | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Tabs = function (_Component) { | ||
babelHelpers.inherits(Tabs, _Component); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
*/ | ||
function Tabs(props) { | ||
@@ -45,3 +59,8 @@ babelHelpers.classCallCheck(this, Tabs); | ||
/** | ||
* 状态 | ||
* | ||
* @private | ||
* @type {Object} | ||
*/ | ||
_this.state = { | ||
@@ -54,2 +73,11 @@ selectedIndex: selectedIndex | ||
/** | ||
* 接受新属性时的处理 | ||
* | ||
* @public | ||
* @override | ||
* @param {*} nextProps 新属性 | ||
*/ | ||
Tabs.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
@@ -95,3 +123,3 @@ | ||
Tabs.prototype.getSelected = function getSelected(tab, index) { | ||
Tabs.prototype.isTabSelected = function isTabSelected(index) { | ||
return this.state.selectedIndex === index; | ||
@@ -113,3 +141,3 @@ }; | ||
var selected = this.getSelected(tab, i); | ||
var selected = this.isTabSelected(i); | ||
@@ -161,2 +189,9 @@ if (selected) { | ||
/** | ||
* propTypes | ||
* | ||
* @property {number} selectedIndex 选中标签的序号 | ||
* @property {Function} onChange 选中标签发生变化后处理函数 | ||
* @property {Function} onBeforeChange 选中标签发生变化前处理函数 | ||
*/ | ||
Tabs.propTypes = { | ||
@@ -163,0 +198,0 @@ selectedIndex: _react.PropTypes.number.isRequired, |
@@ -31,2 +31,9 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Tabs/TabPanel | ||
* | ||
* @param {Object} props 属性 | ||
* @param {boolean} props.active 是否选中 | ||
* @return {ReactElement} | ||
*/ | ||
function TabsPanel(props) { | ||
@@ -33,0 +40,0 @@ var active = props.active; |
@@ -32,2 +32,12 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/* eslint-disable fecs-prefer-class */ | ||
/** | ||
* melon/Tabs/TabPanel | ||
* | ||
* @param {Object} props 属性 | ||
* @param {string|ReactElement} props.label Tab上显示的内容 | ||
* @param {boolean} props.disabled 是否不可选 | ||
* @param {boolean} props.selected 是否选中 | ||
* @return {ReactElement} | ||
*/ | ||
function Tab(props) { | ||
@@ -34,0 +44,0 @@ var selected = props.selected; |
@@ -40,5 +40,20 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/TextBox | ||
* | ||
* @extends {melon-core/InputComponent} | ||
* @class | ||
*/ | ||
var TextBox = function (_InputComponent) { | ||
babelHelpers.inherits(TextBox, _InputComponent); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
* @param {*} context 上下文 | ||
*/ | ||
function TextBox(props, context) { | ||
@@ -51,2 +66,8 @@ babelHelpers.classCallCheck(this, TextBox); | ||
/** | ||
* 状态 | ||
* | ||
* @protected | ||
* @type {Object} | ||
*/ | ||
_this.state = babelHelpers['extends']({}, _this.state, { | ||
@@ -64,2 +85,11 @@ isFloating: !!value, | ||
/** | ||
* 接受新属性时的处理 | ||
* | ||
* @public | ||
* @override | ||
* @param {*} nextProps 新属性 | ||
*/ | ||
TextBox.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
@@ -190,4 +220,3 @@ | ||
var floatingLabel = props.floatingLabel; | ||
var className = props.className; | ||
var rest = babelHelpers.objectWithoutProperties(props, ['floatingLabel', 'className']); | ||
var rest = babelHelpers.objectWithoutProperties(props, ['floatingLabel']); | ||
var _state2 = this.state; | ||
@@ -239,3 +268,3 @@ var validity = _state2.validity; | ||
type: _react.PropTypes.oneOf(['text', 'password']), | ||
type: _react.PropTypes.oneOf(['text', 'password', 'number']), | ||
@@ -242,0 +271,0 @@ placeholder: _react.PropTypes.string, |
@@ -32,2 +32,10 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/* eslint-disable fecs-prefer-class */ | ||
/** | ||
* melon/Title | ||
* | ||
* @param {Object} props 属性 | ||
* @param {Object} props.level 级别 | ||
* @return {ReactElement} | ||
*/ | ||
function Title(props) { | ||
@@ -34,0 +42,0 @@ var level = props.level; |
@@ -37,5 +37,20 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Toggle | ||
* | ||
* @extends {melon-core/InputComponent} | ||
* @class | ||
*/ | ||
var Toggle = function (_InputComponent) { | ||
babelHelpers.inherits(Toggle, _InputComponent); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
* @param {*} context 上下文 | ||
*/ | ||
function Toggle(props, context) { | ||
@@ -51,2 +66,10 @@ babelHelpers.classCallCheck(this, Toggle); | ||
/** | ||
* 值改变处理 | ||
* | ||
* @protected | ||
* @param {Object} e 事件对象 | ||
*/ | ||
Toggle.prototype.onChange = function onChange(e) { | ||
@@ -53,0 +76,0 @@ var _props = this.props; |
@@ -31,6 +31,12 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/ToolBar | ||
* | ||
* @param {Object} props 属性 | ||
* @return {ReactElement} | ||
*/ | ||
function ToolBar(props) { | ||
var children = props.children; | ||
return _react2['default'].createElement( | ||
@@ -42,2 +48,4 @@ 'div', | ||
} | ||
ToolBar.displayName = 'ToolBar'; | ||
}); |
@@ -34,5 +34,19 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Tooltip | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Tooltip = function (_Component) { | ||
babelHelpers.inherits(Tooltip, _Component); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
*/ | ||
function Tooltip(props) { | ||
@@ -47,2 +61,8 @@ babelHelpers.classCallCheck(this, Tooltip); | ||
/** | ||
* 状态 | ||
* | ||
* @protected | ||
* @type {Object} | ||
*/ | ||
_this.state = { | ||
@@ -55,2 +75,10 @@ isShown: false | ||
/** | ||
* 将要Mount时的处理 | ||
* | ||
* @public | ||
* @override | ||
*/ | ||
Tooltip.prototype.componentDidMount = function componentDidMount() { | ||
@@ -63,2 +91,9 @@ var popup = this.popup = Tooltip.createPopup(); | ||
Tooltip.destroyPopup(this.popup); | ||
/** | ||
* 弹出层的dom | ||
* | ||
* @protected | ||
* @type {HTMLElement} | ||
*/ | ||
this.popup = null; | ||
@@ -65,0 +100,0 @@ }; |
28
Tree.js
@@ -30,3 +30,3 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
* @author cxtom<cxtom2008@gmail.com> | ||
* @author leon<ludafa@outlook.com> | ||
* leon<ludafa@outlook.com> | ||
*/ | ||
@@ -36,5 +36,19 @@ | ||
/** | ||
* melon/Tree | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Tree = function (_Component) { | ||
babelHelpers.inherits(Tree, _Component); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
*/ | ||
function Tree(props) { | ||
@@ -49,2 +63,10 @@ babelHelpers.classCallCheck(this, Tree); | ||
/** | ||
* 节点点击的处理 | ||
* | ||
* @protected | ||
* @param {Object} e 事件对象 | ||
*/ | ||
Tree.prototype.onTreeNodeClick = function onTreeNodeClick(e) { | ||
@@ -109,5 +131,5 @@ | ||
Tree.createTreeNodes = function (datasource, level) { | ||
Tree.createTreeNodes = function (datasource) { | ||
var level = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1]; | ||
level = level || 1; | ||
@@ -114,0 +136,0 @@ if (datasource == null) { |
@@ -42,5 +42,20 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Uploader | ||
* | ||
* @extends {melon-core/InputComponent} | ||
* @class | ||
*/ | ||
var Uploader = function (_InputComponent) { | ||
babelHelpers.inherits(Uploader, _InputComponent); | ||
/** | ||
* 构造函数 | ||
* | ||
* @public | ||
* @constructor | ||
* @param {*} props 属性 | ||
* @param {*} context 上下文 | ||
*/ | ||
function Uploader(props, context) { | ||
@@ -51,2 +66,8 @@ babelHelpers.classCallCheck(this, Uploader); | ||
/** | ||
* 状态 | ||
* | ||
* @protected | ||
* @type {Object} | ||
*/ | ||
_this.state = babelHelpers['extends']({}, _this.state, { | ||
@@ -60,2 +81,10 @@ isUploading: false, | ||
/** | ||
* 文件上传时的处理 | ||
* | ||
* @protected | ||
* @param {Object} e 事件对象 | ||
*/ | ||
Uploader.prototype.onFileChange = function onFileChange(e) { | ||
@@ -62,0 +91,0 @@ var _this2 = this; |
@@ -30,2 +30,9 @@ /*! 2016 Baidu Inc. All Rights Reserved */ | ||
/** | ||
* melon/Zippy | ||
* | ||
* @extends {React.Component} | ||
* @class | ||
*/ | ||
var Zippy = function (_React$Component) { | ||
@@ -48,4 +55,2 @@ babelHelpers.inherits(Zippy, _React$Component); | ||
/* eslint-disable fecs-min-vars-per-destructure */ | ||
var className = cx(props).addVariants(horizontal ? 'horizontal' : 'vertical').addStates({ close: !expand }).build(); | ||
@@ -52,0 +57,0 @@ |
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
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
958506
110
6626