Skip to content

Commit c8ef1fa

Browse files
committed
Update
1 parent 7bb04da commit c8ef1fa

35 files changed

+579
-560
lines changed

build/npm/next.js

-1
This file was deleted.

build/scripts/prepare.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if [ $? = 0 ]; then
1313
babel build/npm/index.js --out-file dist/npm/index.js
1414

1515
# keep es6 for next.js
16-
cp build/npm/next.js next.js
16+
cp build/npm/index.js next.js
1717
else
1818
echo 'Code cant be verify, plz check ~'
1919
fi

dist/npm/src/button/Button.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ var Button = function (_Component) {
4848
}), disabled: this.props.disabled, type: this.props.nativeType, onClick: this.onClick.bind(this) },
4949
this.props.loading && _react2.default.createElement('i', { className: 'el-icon-loading' }),
5050
this.props.icon && !this.props.loading && _react2.default.createElement('i', { className: 'el-icon-' + this.props.icon }),
51-
this.props.children
51+
_react2.default.createElement(
52+
'span',
53+
null,
54+
this.props.children
55+
)
5256
);
5357
}
5458
}]);

dist/npm/src/checkbox/CheckBox.js

+28-16
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,29 @@ var Checkbox = function (_Component) {
6262
value: function onChange(e) {
6363
var _this2 = this;
6464

65-
var label = this.state.label;
66-
var _props = this.props,
67-
trueLabel = _props.trueLabel,
68-
falseLabel = _props.falseLabel,
69-
value = _props.value;
70-
7165
if (e.target instanceof HTMLInputElement) {
66+
var _label = this.state.label;
67+
var _props = this.props,
68+
trueLabel = _props.trueLabel,
69+
falseLabel = _props.falseLabel;
70+
71+
7272
var _checked = e.target.checked;
73-
var newLabel = label;
73+
var group = this.context.ElCheckboxGroup;
74+
75+
if (group) {
76+
var length = group.state.options.length + (_checked ? 1 : -1);
77+
78+
if (group.props.min !== undefined && length < group.props.min) {
79+
return;
80+
}
81+
82+
if (group.props.max !== undefined && length > group.props.max) {
83+
return;
84+
}
85+
}
86+
87+
var newLabel = _label;
7488

7589
if (this.props.trueLabel || this.props.falseLabel) {
7690
newLabel = _checked ? trueLabel : falseLabel;
@@ -136,26 +150,24 @@ var _default = Checkbox;
136150
exports.default = _default;
137151

138152

139-
Checkbox.defaultProps = {
140-
checked: false,
141-
focus: false,
142-
trueLabel: '',
143-
falseLabel: ''
153+
Checkbox.contextTypes = {
154+
ElCheckboxGroup: _libs.PropTypes.any
144155
};
145156

146157
Checkbox.propTypes = {
147158
label: _libs.PropTypes.string,
159+
trueLabel: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]),
160+
falseLabel: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]),
148161
disabled: _libs.PropTypes.bool,
149162
checked: _libs.PropTypes.bool,
150163
indeterminate: _libs.PropTypes.bool,
151164
focus: _libs.PropTypes.bool,
152-
trueLabel: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]),
153-
falseLabel: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]),
154165
onChange: _libs.PropTypes.func
155166
};
156167

157-
Checkbox.contextTypes = {
158-
isWrap: _libs.PropTypes.bool
168+
Checkbox.defaultProps = {
169+
checked: false,
170+
focus: false
159171
};
160172
;
161173

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
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; }; }();
8+
9+
var _react = require('react');
10+
11+
var _react2 = _interopRequireDefault(_react);
12+
13+
var _CheckBox2 = require('./CheckBox');
14+
15+
var _CheckBox3 = _interopRequireDefault(_CheckBox2);
16+
17+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18+
19+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20+
21+
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; }
22+
23+
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; }
24+
25+
var CheckboxButton = function (_CheckBox) {
26+
_inherits(CheckboxButton, _CheckBox);
27+
28+
function CheckboxButton() {
29+
_classCallCheck(this, CheckboxButton);
30+
31+
return _possibleConstructorReturn(this, (CheckboxButton.__proto__ || Object.getPrototypeOf(CheckboxButton)).apply(this, arguments));
32+
}
33+
34+
_createClass(CheckboxButton, [{
35+
key: 'render',
36+
value: function render() {
37+
var group = this.context.ElCheckboxGroup;
38+
39+
return _react2.default.createElement(
40+
'label',
41+
{ style: this.style(), className: this.className('el-checkbox-button', group.props.size ? 'el-checkbox-button--' + group.props.size : '', {
42+
'is-disabled': this.props.disabled,
43+
'is-checked': this.state.checked,
44+
'is-focus': this.state.focus
45+
}) },
46+
_react2.default.createElement('input', {
47+
className: 'el-checkbox-button__original',
48+
type: 'checkbox',
49+
checked: this.state.checked,
50+
disabled: this.props.disabled,
51+
onFocus: this.onFocus.bind(this),
52+
onBlur: this.onBlur.bind(this),
53+
onChange: this.onChange.bind(this)
54+
}),
55+
_react2.default.createElement(
56+
'span',
57+
{ className: 'el-checkbox-button__inner', style: this.state.checked ? {
58+
boxShadow: '-1px 0 0 0 ' + group.props.fill,
59+
backgroundColor: group.props.fill || '',
60+
borderColor: group.props.fill || '',
61+
color: group.props.textColor || ''
62+
} : {} },
63+
this.state.label || this.props.children
64+
)
65+
);
66+
}
67+
}]);
68+
69+
return CheckboxButton;
70+
}(_CheckBox3.default);
71+
72+
var _default = CheckboxButton;
73+
exports.default = _default;
74+
;
75+
76+
var _temp = function () {
77+
if (typeof __REACT_HOT_LOADER__ === 'undefined') {
78+
return;
79+
}
80+
81+
__REACT_HOT_LOADER__.register(CheckboxButton, 'CheckboxButton', 'src/checkbox/CheckBoxButton.jsx');
82+
83+
__REACT_HOT_LOADER__.register(_default, 'default', 'src/checkbox/CheckBoxButton.jsx');
84+
}();
85+
86+
;

dist/npm/src/checkbox/CheckBoxGroup.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,26 @@ var CheckboxGroup = function (_Component) {
2929
var _this = _possibleConstructorReturn(this, (CheckboxGroup.__proto__ || Object.getPrototypeOf(CheckboxGroup)).call(this, props));
3030

3131
_this.state = {
32-
options: _this.props.options || []
32+
options: _this.props.value || []
3333
};
3434
return _this;
3535
}
3636

3737
_createClass(CheckboxGroup, [{
3838
key: 'componentWillReceiveProps',
3939
value: function componentWillReceiveProps(nextProps) {
40-
if (nextProps.options !== this.props.options) {
40+
if (nextProps.value !== this.props.value) {
4141
this.setState({
42-
options: nextProps.options
42+
options: nextProps.value
4343
});
4444
}
4545
}
4646
}, {
4747
key: 'getChildContext',
4848
value: function getChildContext() {
49-
return { isWrap: true };
49+
return {
50+
ElCheckboxGroup: this
51+
};
5052
}
5153
}, {
5254
key: 'onChange',
@@ -74,6 +76,7 @@ var CheckboxGroup = function (_Component) {
7476

7577
var options = this.state.options;
7678

79+
7780
var children = _react.Children.map(this.props.children, function (child, index) {
7881
return _react2.default.cloneElement(child, Object.assign({}, child.props, {
7982
key: index,
@@ -97,13 +100,18 @@ var _default = CheckboxGroup;
97100
exports.default = _default;
98101

99102

100-
CheckboxGroup.propTypes = {
101-
options: _libs.PropTypes.array,
102-
onChange: _libs.PropTypes.func
103+
CheckboxGroup.childContextTypes = {
104+
ElCheckboxGroup: _libs.PropTypes.any
103105
};
104106

105-
CheckboxGroup.childContextTypes = {
106-
isWrap: _libs.PropTypes.bool
107+
CheckboxGroup.propTypes = {
108+
min: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]),
109+
max: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]),
110+
size: _libs.PropTypes.string,
111+
fill: _libs.PropTypes.string,
112+
textColor: _libs.PropTypes.string,
113+
value: _libs.PropTypes.any,
114+
onChange: _libs.PropTypes.func
107115
};
108116
;
109117

dist/npm/src/checkbox/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ var _CheckBoxGroup = require('./CheckBoxGroup');
1212

1313
var _CheckBoxGroup2 = _interopRequireDefault(_CheckBoxGroup);
1414

15+
var _CheckBoxButton = require('./CheckBoxButton');
16+
17+
var _CheckBoxButton2 = _interopRequireDefault(_CheckBoxButton);
18+
1519
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1620

1721
_CheckBox2.default.Group = _CheckBoxGroup2.default;
22+
_CheckBox2.default.Button = _CheckBoxButton2.default;
1823

1924
var _default = _CheckBox2.default;
2025
exports.default = _default;

dist/npm/src/radio/Radio.js

-2
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ Radio.propTypes = {
129129
value: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]).isRequired,
130130
onChange: _libs.PropTypes.func,
131131
disabled: _libs.PropTypes.bool,
132-
/* eslint-disable */
133132
checked: _libs.PropTypes.bool
134-
/* eslint-enable */
135133
};
136134
;
137135

dist/npm/src/switch/Switch.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var Switch = function (_Component) {
7777
}, {
7878
key: 'setBackgroundColor',
7979
value: function setBackgroundColor() {
80-
var newColor = this.state.value ? this.props.onColor : this.props.offColor;
80+
var newColor = this.state.value === this.props.onValue ? this.props.onColor : this.props.offColor;
8181

8282
this.refs.core.style.borderColor = newColor;
8383
this.refs.core.style.backgroundColor = newColor;
@@ -88,7 +88,7 @@ var Switch = function (_Component) {
8888
var _this3 = this;
8989

9090
this.setState({
91-
value: e.target.checked
91+
value: e.target.checked ? this.props.onValue : this.props.offValue
9292
}, function () {
9393
_this3.updateSwitch();
9494

@@ -105,8 +105,7 @@ var Switch = function (_Component) {
105105
coreWidth = _state.coreWidth,
106106
buttonStyle = _state.buttonStyle;
107107

108-
109-
buttonStyle.transform = value ? 'translate(' + (coreWidth - 20) + 'px, 2px)' : 'translate(2px, 2px)';
108+
buttonStyle.transform = value === this.props.onValue ? 'translate(' + (coreWidth - 20) + 'px, 2px)' : 'translate(2px, 2px)';
110109

111110
this.setState({ buttonStyle: buttonStyle });
112111
}
@@ -118,6 +117,7 @@ var Switch = function (_Component) {
118117
disabled = _props.disabled,
119118
onText = _props.onText,
120119
offText = _props.offText,
120+
onValue = _props.onValue,
121121
onIconClass = _props.onIconClass,
122122
offIconClass = _props.offIconClass;
123123
var _state2 = this.state,
@@ -142,7 +142,7 @@ var Switch = function (_Component) {
142142
_react2.default.createElement('input', {
143143
className: 'el-switch__input',
144144
type: 'checkbox',
145-
checked: value,
145+
checked: value === onValue,
146146
name: name,
147147
disabled: disabled,
148148
onChange: this.handleChange.bind(this)
@@ -157,7 +157,7 @@ var Switch = function (_Component) {
157157
{ name: 'label-fade' },
158158
_react2.default.createElement(
159159
_libs.View,
160-
{ show: value },
160+
{ show: value === onValue },
161161
_react2.default.createElement(
162162
'div',
163163
{
@@ -178,7 +178,7 @@ var Switch = function (_Component) {
178178
{ name: 'label-fade' },
179179
_react2.default.createElement(
180180
_libs.View,
181-
{ show: !value },
181+
{ show: value !== onValue },
182182
_react2.default.createElement(
183183
'div',
184184
{
@@ -206,7 +206,7 @@ exports.default = _default;
206206

207207

208208
Switch.propTypes = {
209-
value: _libs.PropTypes.bool,
209+
value: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string, _libs.PropTypes.bool]),
210210
disabled: _libs.PropTypes.bool,
211211
width: _libs.PropTypes.number,
212212
onIconClass: _libs.PropTypes.string,
@@ -215,6 +215,8 @@ Switch.propTypes = {
215215
offText: _libs.PropTypes.string,
216216
onColor: _libs.PropTypes.string,
217217
offColor: _libs.PropTypes.string,
218+
onValue: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string, _libs.PropTypes.bool]),
219+
offValue: _libs.PropTypes.oneOfType([_libs.PropTypes.number, _libs.PropTypes.string, _libs.PropTypes.bool]),
218220
name: _libs.PropTypes.string,
219221
onChange: _libs.PropTypes.func
220222
};
@@ -227,6 +229,8 @@ Switch.defaultProps = {
227229
offIconClass: '',
228230
onText: 'ON',
229231
offText: 'OFF',
232+
onValue: true,
233+
offValue: false,
230234
onColor: '',
231235
offColor: '',
232236
name: ''

0 commit comments

Comments
 (0)