Merge branch '1.x-stable'

This commit is contained in:
afc163 2016-07-11 14:57:38 +08:00
commit 6dad2b2987
9 changed files with 50 additions and 17 deletions

View File

@ -59,11 +59,15 @@ export default class Affix extends React.Component<AffixProps, any> {
super(props); super(props);
this.state = { this.state = {
affixStyle: null, affixStyle: null,
placeholderStyle: null,
}; };
} }
setAffixStyle(affixStyle) { setAffixStyle(e, affixStyle) {
const originalAffixStyle = this.state.affixStyle; const originalAffixStyle = this.state.affixStyle;
if (e.type === 'scroll' && originalAffixStyle && affixStyle) {
return;
}
if (shallowequal(affixStyle, originalAffixStyle)) { if (shallowequal(affixStyle, originalAffixStyle)) {
return; return;
} }
@ -76,7 +80,18 @@ export default class Affix extends React.Component<AffixProps, any> {
}); });
} }
handleScroll = () => { setPlaceholderStyle(e, placeholderStyle) {
const originalPlaceholderStyle = this.state.placeholderStyle;
if (e.type === 'resize') {
return;
}
if (shallowequal(placeholderStyle, originalPlaceholderStyle)) {
return;
}
this.setState({ placeholderStyle });
}
handleScroll = (e) => {
let { offsetTop, offsetBottom, offset } = this.props; let { offsetTop, offsetBottom, offset } = this.props;
// Backwards support // Backwards support
@ -99,23 +114,32 @@ export default class Affix extends React.Component<AffixProps, any> {
if (scrollTop > elemOffset.top - offsetTop && offsetMode.top) { if (scrollTop > elemOffset.top - offsetTop && offsetMode.top) {
// Fixed Top // Fixed Top
this.setAffixStyle({ this.setAffixStyle(e, {
position: 'fixed', position: 'fixed',
top: offsetTop, top: offsetTop,
left: elemOffset.left, left: elemOffset.left,
width: ReactDOM.findDOMNode(this).offsetWidth, width: ReactDOM.findDOMNode(this).offsetWidth,
}); });
this.setPlaceholderStyle(e, {
width: ReactDOM.findDOMNode(this).offsetWidth,
height: ReactDOM.findDOMNode(this).offsetHeight,
});
} else if (scrollTop < elemOffset.top + elemSize.height + offsetBottom - window.innerHeight && } else if (scrollTop < elemOffset.top + elemSize.height + offsetBottom - window.innerHeight &&
offsetMode.bottom) { offsetMode.bottom) {
// Fixed Bottom // Fixed Bottom
this.setAffixStyle({ this.setAffixStyle(e, {
position: 'fixed', position: 'fixed',
bottom: offsetBottom, bottom: offsetBottom,
left: elemOffset.left, left: elemOffset.left,
width: ReactDOM.findDOMNode(this).offsetWidth, width: ReactDOM.findDOMNode(this).offsetWidth,
}); });
this.setPlaceholderStyle(e, {
width: ReactDOM.findDOMNode(this).offsetWidth,
height: ReactDOM.findDOMNode(this).offsetHeight,
});
} else { } else {
this.setAffixStyle(null); this.setAffixStyle(e, null);
this.setPlaceholderStyle(e, null);
} }
} }
@ -144,7 +168,7 @@ export default class Affix extends React.Component<AffixProps, any> {
delete props.offsetBottom; delete props.offsetBottom;
return ( return (
<div {...props}> <div {...props} style={this.state.placeholderStyle}>
<div className={className} ref="fixedNode" style={this.state.affixStyle}> <div className={className} ref="fixedNode" style={this.state.affixStyle}>
{this.props.children} {this.props.children}
</div> </div>

View File

@ -18,6 +18,8 @@
cursor: pointer; cursor: pointer;
vertical-align: middle; vertical-align: middle;
font-size: @font-size-base; font-size: @font-size-base;
background-color: #fff;
border-radius: @border-radius-base;
&-disabled { &-disabled {
cursor: not-allowed; cursor: not-allowed;

View File

@ -162,8 +162,8 @@ export default class FormItem extends React.Component {
} }
return props.label ? ( return props.label ? (
<Col {...labelCol}> <Col {...labelCol} key="label" className={`${props.prefixCls}-item-label`}>
<label htmlFor={props.id || this.getId()} className={className} key="label"> <label htmlFor={props.id || this.getId()} className={className}>
{label} {label}
</label> </label>
</Col> </Col>

View File

@ -80,7 +80,7 @@ input[type="checkbox"] {
margin-bottom: @form-item-margin-bottom - @font-size-base * @line-height-base - 3; margin-bottom: @form-item-margin-bottom - @font-size-base * @line-height-base - 3;
} }
> div:first-child { &-label {
text-align: right; text-align: right;
vertical-align: middle; vertical-align: middle;
padding: 7px 0; padding: 7px 0;

View File

@ -157,7 +157,7 @@ export default class Input extends Component {
}); });
if ('value' in props) { if ('value' in props) {
props.value = fixControlledValue(props.value); otherProps.value = fixControlledValue(props.value);
// Input elements must be either controlled or uncontrolled, // Input elements must be either controlled or uncontrolled,
// specify either the value prop, or the defaultValue prop, but not both. // specify either the value prop, or the defaultValue prop, but not both.
delete otherProps.defaultValue; delete otherProps.defaultValue;

View File

@ -214,6 +214,12 @@
table { table {
border: 0; border: 0;
} }
.@{table-prefix-cls}-fixed-left {
border-right: 1px solid @border-color-split;
}
.@{table-prefix-cls}-fixed-right {
border-left: 1px solid @border-color-split;
}
} }
th { th {
@ -341,7 +347,7 @@
width: 17px; width: 17px;
height: 17px; height: 17px;
text-align: center; text-align: center;
line-height: 15px; line-height: 14px;
border: 1px solid @border-color-split; border: 1px solid @border-color-split;
user-select: none; user-select: none;
background: #fff; background: #fff;
@ -422,8 +428,8 @@
} }
} }
&-fixed-left &-fixed, &-fixed-header &-fixed-left &-body-outer &-fixed,
&-fixed-right &-fixed { &-fixed-header &-fixed-right &-body-outer &-fixed {
border-radius: 0; border-radius: 0;
} }

View File

@ -76,7 +76,7 @@
"devDependencies": { "devDependencies": {
"antd-tools": "^0.9.0", "antd-tools": "^0.9.0",
"babel-eslint": "^6.0.2", "babel-eslint": "^6.0.2",
"babel-jest": "^12.0.2", "babel-jest": "^13.2.2",
"babel-plugin-antd": "^0.4.0", "babel-plugin-antd": "^0.4.0",
"bisheng": "^0.7.1", "bisheng": "^0.7.1",
"bisheng-plugin-antd": "0.1.0", "bisheng-plugin-antd": "0.1.0",
@ -86,7 +86,7 @@
"dora-plugin-upload": "^0.3.1", "dora-plugin-upload": "^0.3.1",
"enquire.js": "^2.1.1", "enquire.js": "^2.1.1",
"es6-shim": "^0.35.0", "es6-shim": "^0.35.0",
"eslint": "^2.2.0", "eslint": "^3.0.1",
"eslint-config-airbnb": "^9.0.1", "eslint-config-airbnb": "^9.0.1",
"eslint-plugin-babel": "^3.0.0", "eslint-plugin-babel": "^3.0.0",
"eslint-plugin-import": "^1.6.1", "eslint-plugin-import": "^1.6.1",
@ -97,7 +97,7 @@
"history": "^2.0.1", "history": "^2.0.1",
"intl": "^1.2.2", "intl": "^1.2.2",
"intl-locales-supported": "^1.0.0", "intl-locales-supported": "^1.0.0",
"jest-cli": "^12.0.2", "jest-cli": "^13.2.3",
"jsonml-to-react-component": "~0.2.0", "jsonml-to-react-component": "~0.2.0",
"jsonml.js": "^0.1.0", "jsonml.js": "^0.1.0",
"jsonp": "^0.2.0", "jsonp": "^0.2.0",

View File

@ -6,6 +6,7 @@ import path from 'path';
describe('antd dist files', function() { describe('antd dist files', function() {
const distFilesExisted = fs.existsSync(path.join(process.cwd(), 'dist', 'antd.js')); const distFilesExisted = fs.existsSync(path.join(process.cwd(), 'dist', 'antd.js'));
if (!distFilesExisted) { if (!distFilesExisted) {
it('empty test case placeholder', () => {});
return; return;
} else { } else {
jest.unmock('../dist/antd'); jest.unmock('../dist/antd');

View File

@ -21,7 +21,7 @@ describe('Popover', function() {
); );
const popup = popover.getPopupDomNode(); const popup = popover.getPopupDomNode();
expect(popup).not.toBe(undefined); expect(popup).not.toBe(null);
expect(popup.className).toContain('ant-popover-placement-top'); expect(popup.className).toContain('ant-popover-placement-top');
expect(popup.innerHTML).toMatch(/<div class="ant-popover-title".*?>code<\/div>/); expect(popup.innerHTML).toMatch(/<div class="ant-popover-title".*?>code<\/div>/);
expect(popup.innerHTML).toMatch(/<div class="ant-popover-inner-content".*?>console\.log\('hello world'\)<\/div>/); expect(popup.innerHTML).toMatch(/<div class="ant-popover-inner-content".*?>console\.log\('hello world'\)<\/div>/);