Skip to content

Commit

Permalink
Merge pull request ElemeFE#285 from e1emeb0t/dev
Browse files Browse the repository at this point in the history
Document localization & update component
  • Loading branch information
Martin0809 committed Mar 21, 2017
2 parents 8c88206 + 9a6e0bc commit f48ec57
Show file tree
Hide file tree
Showing 85 changed files with 5,351 additions and 418 deletions.
2 changes: 1 addition & 1 deletion dist/npm/libs/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var Markdown = function (_React$Component) {
value: function render() {
var _this2 = this;

var document = this.document(navigator.language);
var document = this.document(localStorage.getItem('ELEMENT_LANGUAGE') || navigator.language);

if (typeof document === 'string') {
this.components.clear();
Expand Down
11 changes: 5 additions & 6 deletions dist/npm/src/card/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ var Card = function (_Component) {
return Card;
}(_libs.Component);

Card.defaultProps = {
bodyStyle: {
padding: '20px'
}
};
var _default = Card;
exports.default = _default;

Expand All @@ -66,12 +71,6 @@ Card.propTypes = {
header: _react.PropTypes.node,
bodyStyle: _react.PropTypes.object
};

Card.defaultProps = {
bodyStyle: {
padding: '20px'
}
};
;

var _temp = function () {
Expand Down
32 changes: 17 additions & 15 deletions dist/npm/src/checkbox/CheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,27 @@ var Checkbox = function (_Component) {
falseLabel = _props.falseLabel,
value = _props.value;

var checked = e.target.checked;
var newLabel = label;
if (e.target instanceof HTMLInputElement) {
var _checked = e.target.checked;
var newLabel = label;

if (this.props.trueLabel || this.props.falseLabel) {
newLabel = checked ? trueLabel : falseLabel;
}
if (this.props.trueLabel || this.props.falseLabel) {
newLabel = _checked ? trueLabel : falseLabel;
}

if (this.props.onChange) {
if (this.context.isWrap) {
this.props.onChange(e, label, value);
} else {
this.props.onChange(e, label, value);
if (this.props.onChange) {
if (this.context.isWrap) {
this.props.onChange(e, label, value);
} else {
this.props.onChange(e, label, value);
}
}
}

this.setState({
checked: checked,
label: newLabel
});
this.setState({
checked: _checked,
label: newLabel
});
}
}
}, {
key: 'getLabel',
Expand Down
26 changes: 14 additions & 12 deletions dist/npm/src/checkbox/CheckBoxGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,22 @@ var CheckboxGroup = function (_Component) {
var options = this.state.options;

var newOptions = void 0;
if (e.target.checked) {
newOptions = options.concat(value || label);
} else {
newOptions = options.filter(function (v) {
return v !== value && v !== label;
});
}
if (e.target instanceof HTMLInputElement) {
if (e.target.checked) {
newOptions = options.concat(value || label);
} else {
newOptions = options.filter(function (v) {
return v !== value && v !== label;
});
}

this.setState({
options: newOptions
});
this.setState({
options: newOptions
});

if (this.props.onChange) {
this.props.onChange(newOptions);
if (this.props.onChange) {
this.props.onChange(newOptions);
}
}
}
}, {
Expand Down
36 changes: 19 additions & 17 deletions dist/npm/src/dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ var Dialog = function (_Component) {
var _this = _possibleConstructorReturn(this, (Dialog.__proto__ || Object.getPrototypeOf(Dialog)).call(this, props));

_this.state = {
bodyOverflow: null
bodyOverflow: ''
};
return _this;
}

_createClass(Dialog, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {

if (this.willOpen(this.props, nextProps)) {
if (this.props.lockScroll) {
if (this.props.lockScroll && document.body && document.body.style) {
if (!this.state.bodyOverflow) {
this.setState({
bodyOverflow: document.body.style.overflow
Expand All @@ -49,7 +50,7 @@ var Dialog = function (_Component) {
}

if (this.willClose(this.props, nextProps) && this.props.lockScroll) {
if (this.props.modal && this.state.bodyOverflow !== 'hidden') {
if (this.props.modal && this.state.bodyOverflow !== 'hidden' && document.body && document.body.style) {
document.body.style.overflow = this.state.bodyOverflow;
}
}
Expand All @@ -64,7 +65,7 @@ var Dialog = function (_Component) {
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
document.body.style.removeProperty('overflow');
if (document.body && document.body.style) document.body.style.removeProperty('overflow');
}
}, {
key: 'onKeyDown',
Expand All @@ -76,8 +77,10 @@ var Dialog = function (_Component) {
}, {
key: 'handleWrapperClick',
value: function handleWrapperClick(e) {
if (this.props.closeOnClickModal && e.target === e.currentTarget) {
this.close(e);
if (e.target instanceof HTMLDivElement) {
if (this.props.closeOnClickModal && e.target === e.currentTarget) {
this.close(e);
}
}
}
}, {
Expand Down Expand Up @@ -164,6 +167,16 @@ var Dialog = function (_Component) {
return Dialog;
}(_libs.Component);

Dialog.defaultProps = {
visible: false,
title: '',
size: 'small',
top: '15%',
modal: true,
lockScroll: true,
closeOnClickModal: true,
closeOnPressEscape: true
};
var _default = Dialog;
exports.default = _default;

Expand All @@ -190,17 +203,6 @@ Dialog.propTypes = {
// 点击遮罩层或右上角叉或取消按钮的回调
onCancel: _react.PropTypes.func.isRequired
};

Dialog.defaultProps = {
visible: false,
title: '',
size: 'small',
top: '15%',
modal: true,
lockScroll: true,
closeOnClickModal: true,
closeOnPressEscape: true
};
;

var _temp = function () {
Expand Down
10 changes: 7 additions & 3 deletions dist/npm/src/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ var Dropdown = function (_Component) {
}, {
key: 'handleMenuItemClick',
value: function handleMenuItemClick(command, instance) {
this.setState({
visible: false
});
if (this.props.hideOnClick) {
this.setState({
visible: false
});
}

if (this.props.onCommand) {
this.props.onCommand(command, instance);
Expand Down Expand Up @@ -177,11 +179,13 @@ Dropdown.propTypes = {
trigger: _libs.PropTypes.oneOf(['hover', 'click']),
menuAlign: _libs.PropTypes.oneOf(['start', 'end']),
splitButton: _libs.PropTypes.bool,
hideOnClick: _libs.PropTypes.bool,
onClick: _libs.PropTypes.func,
onCommand: _libs.PropTypes.func
};

Dropdown.defaultProps = {
hideOnClick: true,
trigger: 'hover',
menuAlign: 'end'
};
Expand Down
20 changes: 16 additions & 4 deletions dist/npm/src/form/FormItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var FormItem = function (_Component) {

_this.state = {
error: '',
valid: false,
validating: false,
isRequired: false
};
Expand Down Expand Up @@ -71,9 +72,10 @@ var FormItem = function (_Component) {
});

var parent = _reactDom2.default.findDOMNode(this.parent());

parent.addEventListener('blur', this.onFieldBlur.bind(this));
parent.addEventListener('change', this.onFieldChange.bind(this));
if (parent) {
parent.addEventListener('blur', this.onFieldBlur.bind(this));
parent.addEventListener('change', this.onFieldChange.bind(this));
}
}
}
}
Expand Down Expand Up @@ -190,20 +192,30 @@ var FormItem = function (_Component) {
key: 'labelStyle',
value: function labelStyle() {
var ret = {};

if (this.parent().props.labelPosition === 'top') return ret;

var labelWidth = this.props.labelWidth || this.parent().props.labelWidth;

if (labelWidth) {
ret.width = Number(labelWidth);
}

return ret;
}
}, {
key: 'contentStyle',
value: function contentStyle() {
var ret = {};

if (this.parent().props.labelPosition === 'top' || this.parent().props.inline) return ret;

var labelWidth = this.props.labelWidth || this.parent().props.labelWidth;

if (labelWidth) {
ret.marginLeft = Number(labelWidth);
}

return ret;
}
}, {
Expand Down Expand Up @@ -271,7 +283,7 @@ FormItem.contextTypes = {

FormItem.propTypes = {
label: _libs.PropTypes.string,
labelWidth: _libs.PropTypes.string,
labelWidth: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]),
prop: _libs.PropTypes.string,
required: _libs.PropTypes.bool,
rules: _libs.PropTypes.oneOfType([_libs.PropTypes.object, _libs.PropTypes.array])
Expand Down
13 changes: 6 additions & 7 deletions dist/npm/src/input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ var Input = function (_Component) {
return Input;
}(_libs.Component);

Input.defaultProps = {
type: 'text',
autosize: false,
rows: 2,
autoComplete: 'off'
};
var _default = Input;
exports.default = _default;

Expand Down Expand Up @@ -249,13 +255,6 @@ Input.propTypes = {
form: _libs.PropTypes.string,
validating: _libs.PropTypes.bool
};

Input.defaultProps = {
type: 'text',
autosize: false,
rows: 2,
autoComplete: 'off'
};
;

var _temp = function () {
Expand Down
2 changes: 1 addition & 1 deletion dist/npm/src/input/calcTextareaHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function calcTextareaHeight(targetNode) {

if (!hiddenTextarea) {
hiddenTextarea = document.createElement('textarea');
document.body.appendChild(hiddenTextarea);
document.body && document.body.appendChild(hiddenTextarea);
}

var _calculateNodeStyling = calculateNodeStyling(targetNode),
Expand Down
39 changes: 36 additions & 3 deletions dist/npm/src/layout/Col.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require('react');
Expand Down Expand Up @@ -44,9 +46,32 @@ var Col = function (_Component) {
}, {
key: 'render',
value: function render() {
var _this2 = this;

var classList = [];

['span', 'offset', 'pull', 'push'].forEach(function (prop) {
if (_this2.props[prop]) {
classList.push(prop !== 'span' ? 'el-col-' + prop + '-' + _this2.props[prop] : 'el-col-' + _this2.props[prop]);
}
});

['xs', 'sm', 'md', 'lg'].forEach(function (size) {
if (_typeof(_this2.props[size]) === 'object') {
var props = _this2.props[size];
Object.keys(props).forEach(function (prop) {
classList.push(prop !== 'span' ? 'el-col-' + size + '-' + prop + '-' + props[prop] : 'el-col-' + size + '-' + props[prop]);
});
} else {
classList.push('el-col-' + size + '-' + Number(_this2.props[size]));
}
});

return _react2.default.createElement(
'div',
{ className: this.className('el-col', 'el-col-' + this.props.span, this.props.offset && 'el-col-offset-' + this.props.offset, this.props.pull && 'el-col-pull-' + this.props.pull, this.props.push && 'el-col-push-' + this.props.push), style: this.style(this.getStyle()) },
{
className: this.className('el-col', classList),
style: this.style(this.getStyle()) },
this.props.children
);
}
Expand All @@ -64,10 +89,18 @@ Col.contextTypes = {
};

Col.propTypes = {
span: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string]).isRequired,
span: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string]),
offset: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string]),
pull: _libs.PropTypes.number,
push: _libs.PropTypes.number
push: _libs.PropTypes.number,
xs: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string, _libs.PropTypes.object]),
sm: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string, _libs.PropTypes.object]),
md: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string, _libs.PropTypes.object]),
lg: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string, _libs.PropTypes.object])
};

Col.defaultProps = {
span: 24
};
;

Expand Down
Loading

0 comments on commit f48ec57

Please sign in to comment.