mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
Merge remote-tracking branch 'origin/master' into antd-3.0
This commit is contained in:
commit
b10f7726c3
@ -14,7 +14,7 @@ describe('Breadcrumb', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// https://github.com/airbnb/enzyme/issues/875
|
// https://github.com/airbnb/enzyme/issues/875
|
||||||
xit('warns on non-Breadcrumb.Item children', () => {
|
it('warns on non-Breadcrumb.Item children', () => {
|
||||||
const MyCom = () => <div>foo</div>;
|
const MyCom = () => <div>foo</div>;
|
||||||
mount(
|
mount(
|
||||||
<Breadcrumb>
|
<Breadcrumb>
|
||||||
|
27
components/card/__tests__/index.test.js
Normal file
27
components/card/__tests__/index.test.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { mount } from 'enzyme';
|
||||||
|
import Card from '../index';
|
||||||
|
|
||||||
|
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
|
||||||
|
|
||||||
|
describe('Card', () => {
|
||||||
|
function fakeResizeWindowTo(wrapper, width) {
|
||||||
|
Object.defineProperties(wrapper.node.container, {
|
||||||
|
offsetWidth: {
|
||||||
|
get() { return width; },
|
||||||
|
configurable: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
window.resizeTo(width);
|
||||||
|
}
|
||||||
|
|
||||||
|
it('resize card will trigger different padding', async () => {
|
||||||
|
const wrapper = mount(<Card title="xxx">xxx</Card>);
|
||||||
|
fakeResizeWindowTo(wrapper, 1000);
|
||||||
|
await delay(0);
|
||||||
|
expect(wrapper.hasClass('ant-card-wider-padding')).toBe(true);
|
||||||
|
fakeResizeWindowTo(wrapper, 800);
|
||||||
|
await delay(0);
|
||||||
|
expect(wrapper.hasClass('ant-card-wider-padding')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
@ -66,7 +66,7 @@ If the form has been decorated by `Form.create` then it has `this.props.form` pr
|
|||||||
|
|
||||||
> Note: Before using `getFieldsValue` `getFieldValue` `setFieldsValue` and so on, please make sure that corresponding field had been registered with `getFieldDecorator`.
|
> Note: Before using `getFieldsValue` `getFieldValue` `setFieldsValue` and so on, please make sure that corresponding field had been registered with `getFieldDecorator`.
|
||||||
|
|
||||||
| Property | Description | Type |
|
| Method | Description | Type |
|
||||||
|-----------|------------------------------------------|------------|
|
|-----------|------------------------------------------|------------|
|
||||||
| getFieldsValue | Get the specified fields' values. If you don't specify a parameter, you will get all fields' values. | Function([fieldNames: string[]]) |
|
| getFieldsValue | Get the specified fields' values. If you don't specify a parameter, you will get all fields' values. | Function([fieldNames: string[]]) |
|
||||||
| getFieldValue | Get the value of a field. | Function(fieldName: string) |
|
| getFieldValue | Get the value of a field. | Function(fieldName: string) |
|
||||||
@ -83,6 +83,16 @@ If the form has been decorated by `Form.create` then it has `this.props.form` pr
|
|||||||
| resetFields | Reset the specified fields' value(to `initialValue`) and status. If you don't specify a parameter, all the fields will be reset. | Function([names: string[]]) |
|
| resetFields | Reset the specified fields' value(to `initialValue`) and status. If you don't specify a parameter, all the fields will be reset. | Function([names: string[]]) |
|
||||||
| getFieldDecorator | Two-way binding for form, please read below for details. | |
|
| getFieldDecorator | Two-way binding for form, please read below for details. | |
|
||||||
|
|
||||||
|
### this.props.form.validateFields/validateFieldsAndScroll([fieldNames: string[]], [options: object], callback: Function(errors, values))
|
||||||
|
|
||||||
|
| 参数 | 说明 | 类型 | 默认值 |
|
||||||
|
|-----|-----|------|-------|
|
||||||
|
| options.first | If `true`, every field will stop validation at first failed rule | boolean | false |
|
||||||
|
| options.firstFields | Those fields will stop validation at first failed rule | String[] | [] |
|
||||||
|
| options.force | Should validate validated field again when `validateTrigger` is been triggered again | boolean | false |
|
||||||
|
| options.scroll | Config scroll behavior of `validateFieldsAndScroll`, more: [dom-scroll-into-view's config](https://github.com/yiminghe/dom-scroll-into-view#function-parameter) | Object | {} |
|
||||||
|
|
||||||
|
|
||||||
### this.props.form.getFieldDecorator(id, options)
|
### this.props.form.getFieldDecorator(id, options)
|
||||||
|
|
||||||
After wrapped by `getFieldDecorator`, `value`(or other property defined by `valuePropName`) `onChange`(or other property defined by `trigger`) props will be added to form controls,the flow of form data will be handled by Form which will cause:
|
After wrapped by `getFieldDecorator`, `value`(or other property defined by `valuePropName`) `onChange`(or other property defined by `trigger`) props will be added to form controls,the flow of form data will be handled by Form which will cause:
|
||||||
|
@ -68,7 +68,7 @@ CustomizedForm = Form.create({})(CustomizedForm);
|
|||||||
|
|
||||||
> 注意:使用 `getFieldsValue` `getFieldValue` `setFieldsValue` 等时,应确保对应的 field 已经用 `getFieldDecorator` 注册过了。
|
> 注意:使用 `getFieldsValue` `getFieldValue` `setFieldsValue` 等时,应确保对应的 field 已经用 `getFieldDecorator` 注册过了。
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 |
|
| 方法 | 说明 | 类型 |
|
||||||
|-----------|------------------------------------------|------------|
|
|-----------|------------------------------------------|------------|
|
||||||
| getFieldsValue | 获取一组输入控件的值,如不传入参数,则获取全部组件的值 | Function([fieldNames: string[]]) |
|
| getFieldsValue | 获取一组输入控件的值,如不传入参数,则获取全部组件的值 | Function([fieldNames: string[]]) |
|
||||||
| getFieldValue | 获取一个输入控件的值 | Function(fieldName: string) |
|
| getFieldValue | 获取一个输入控件的值 | Function(fieldName: string) |
|
||||||
@ -84,6 +84,15 @@ CustomizedForm = Form.create({})(CustomizedForm);
|
|||||||
| resetFields | 重置一组输入控件的值(为 `initialValue`)与状态,如不传入参数,则重置所有组件 | Function([names: string[]]) |
|
| resetFields | 重置一组输入控件的值(为 `initialValue`)与状态,如不传入参数,则重置所有组件 | Function([names: string[]]) |
|
||||||
| getFieldDecorator | 用于和表单进行双向绑定,详见下方描述 | |
|
| getFieldDecorator | 用于和表单进行双向绑定,详见下方描述 | |
|
||||||
|
|
||||||
|
### this.props.form.validateFields/validateFieldsAndScroll([fieldNames: string[]], [options: object], callback: Function(errors, values))
|
||||||
|
|
||||||
|
| 参数 | 说明 | 类型 | 默认值 |
|
||||||
|
|-----|-----|------|-------|
|
||||||
|
| options.first | 若为 true,则每一表单域的都会在碰到第一个失败了的校验规则后停止校验 | boolean | false |
|
||||||
|
| options.firstFields | 指定表单域会在碰到第一个失败了的校验规则后停止校验 | String[] | [] |
|
||||||
|
| options.force | 对已经校验过的表单域,在 validateTrigger 再次被触发时是否再次校验 | boolean | false |
|
||||||
|
| options.scroll | 定义 validateFieldsAndScroll 的滚动行为,详细配置见 [dom-scroll-into-view config](https://github.com/yiminghe/dom-scroll-into-view#function-parameter) | Object | {} |
|
||||||
|
|
||||||
### this.props.form.getFieldDecorator(id, options)
|
### this.props.form.getFieldDecorator(id, options)
|
||||||
|
|
||||||
经过 `getFieldDecorator` 包装的控件,表单控件会自动添加 `value`(或 `valuePropName` 指定的其他属性) `onChange`(或 `trigger` 指定的其他属性),数据同步将被 Form 接管,这会导致以下结果:
|
经过 `getFieldDecorator` 包装的控件,表单控件会自动添加 `value`(或 `valuePropName` 指定的其他属性) `onChange`(或 `trigger` 指定的其他属性),数据同步将被 Form 接管,这会导致以下结果:
|
||||||
|
@ -84,7 +84,7 @@ Flex layout is based on a grid 24 to define each "box" in width, but not rigidly
|
|||||||
Ant Design layout component if it can not meet your needs, you can use the excellent layout of the components of the community:
|
Ant Design layout component if it can not meet your needs, you can use the excellent layout of the components of the community:
|
||||||
|
|
||||||
- [react-flexbox-grid](http://roylee0704.github.io/react-flexbox-grid/)
|
- [react-flexbox-grid](http://roylee0704.github.io/react-flexbox-grid/)
|
||||||
- [react-blocks](http://whoisandie.github.io/react-blocks/)
|
- [react-blocks](https://github.com/whoisandy/react-blocks/)
|
||||||
|
|
||||||
### Row
|
### Row
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ Flex 布局是基于 24 栅格来定义每一个『盒子』的宽度,但排
|
|||||||
Ant Design 的布局组件若不能满足你的需求,你也可以直接使用社区的优秀布局组件:
|
Ant Design 的布局组件若不能满足你的需求,你也可以直接使用社区的优秀布局组件:
|
||||||
|
|
||||||
- [react-flexbox-grid](http://roylee0704.github.io/react-flexbox-grid/)
|
- [react-flexbox-grid](http://roylee0704.github.io/react-flexbox-grid/)
|
||||||
- [react-blocks](http://whoisandie.github.io/react-blocks/)
|
- [react-blocks](https://github.com/whoisandy/react-blocks/)
|
||||||
|
|
||||||
### Row
|
### Row
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ type: Data Entry
|
|||||||
title: Select
|
title: Select
|
||||||
---
|
---
|
||||||
|
|
||||||
A Selector similar to Select2.
|
Select component to select value from options.
|
||||||
|
|
||||||
## When To Use
|
## When To Use
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ type: Data Entry
|
|||||||
title: Select
|
title: Select
|
||||||
---
|
---
|
||||||
|
|
||||||
类似 Select2 的选择器。
|
下拉选择器。
|
||||||
|
|
||||||
## 何时使用
|
## 何时使用
|
||||||
|
|
||||||
|
@ -469,10 +469,6 @@
|
|||||||
background-color: @item-hover-bg;
|
background-color: @item-hover-bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-active {
|
|
||||||
background-color: @item-active-bg;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-disabled {
|
&-disabled {
|
||||||
color: @disabled-color;
|
color: @disabled-color;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
@ -493,6 +489,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-active {
|
||||||
|
background-color: @item-active-bg;
|
||||||
|
}
|
||||||
|
|
||||||
&-divider {
|
&-divider {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
margin: 1px 0;
|
margin: 1px 0;
|
||||||
|
@ -17,20 +17,14 @@
|
|||||||
// alert info backgrounds.
|
// alert info backgrounds.
|
||||||
@primary-1: color(~`colorPalette("@{primary-color}", 1)`); // replace tint(@primary-color, 90%)
|
@primary-1: color(~`colorPalette("@{primary-color}", 1)`); // replace tint(@primary-color, 90%)
|
||||||
@primary-2: color(~`colorPalette("@{primary-color}", 2)`); // replace tint(@primary-color, 80%)
|
@primary-2: color(~`colorPalette("@{primary-color}", 2)`); // replace tint(@primary-color, 80%)
|
||||||
// unused
|
@primary-3: color(~`colorPalette("@{primary-color}", 3)`); // unused
|
||||||
@primary-3: color(~`colorPalette("@{primary-color}", 3)`);
|
@primary-4: color(~`colorPalette("@{primary-color}", 4)`); // unused
|
||||||
@primary-4: color(~`colorPalette("@{primary-color}", 4)`);
|
@primary-5: color(~`colorPalette("@{primary-color}", 5)`); // color used to control the text color in many active and hover states, replace tint(@primary-color, 20%)
|
||||||
// Color used to control the text color in many active and hover states.
|
@primary-6: @primary-color; // color used to control the text color of active buttons, don't use, use @primary-color
|
||||||
@primary-5: color(~`colorPalette("@{primary-color}", 5)`); // replace tint(@primary-color, 20%)
|
|
||||||
@primary-6: @primary-color; // don't use, use @primary-color
|
|
||||||
// Color used to control the text color of active buttons.
|
|
||||||
@primary-7: color(~`colorPalette("@{primary-color}", 7)`); // replace shade(@primary-color, 5%)
|
@primary-7: color(~`colorPalette("@{primary-color}", 7)`); // replace shade(@primary-color, 5%)
|
||||||
// unused
|
@primary-8: color(~`colorPalette("@{primary-color}", 8)`); // unused
|
||||||
@primary-8: color(~`colorPalette("@{primary-color}", 8)`);
|
@primary-9: color(~`colorPalette("@{primary-color}", 9)`); // unused
|
||||||
// unused
|
@primary-10: color(~`colorPalette("@{primary-color}", 10)`); // unused
|
||||||
@primary-9: color(~`colorPalette("@{primary-color}", 9)`);
|
|
||||||
// unused
|
|
||||||
@primary-10: color(~`colorPalette("@{primary-color}", 10)`);
|
|
||||||
|
|
||||||
// Base Scaffolding Variables
|
// Base Scaffolding Variables
|
||||||
// ---
|
// ---
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
"rc-input-number": "~3.6.0",
|
"rc-input-number": "~3.6.0",
|
||||||
"rc-menu": "~5.0.10",
|
"rc-menu": "~5.0.10",
|
||||||
"rc-notification": "~2.0.0",
|
"rc-notification": "~2.0.0",
|
||||||
"rc-pagination": "~1.10.6",
|
"rc-pagination": "~1.11.0",
|
||||||
"rc-progress": "~2.2.2",
|
"rc-progress": "~2.2.2",
|
||||||
"rc-rate": "~2.1.1",
|
"rc-rate": "~2.1.1",
|
||||||
"rc-select": "~6.8.6",
|
"rc-select": "~6.8.6",
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { jsdom } from 'jsdom';
|
||||||
|
|
||||||
// fixed jsdom miss
|
// fixed jsdom miss
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
const matchMediaPolyfill = function matchMediaPolyfill() {
|
const matchMediaPolyfill = function matchMediaPolyfill() {
|
||||||
@ -11,3 +13,17 @@ if (typeof window !== 'undefined') {
|
|||||||
};
|
};
|
||||||
window.matchMedia = window.matchMedia || matchMediaPolyfill;
|
window.matchMedia = window.matchMedia || matchMediaPolyfill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global.requestAnimationFrame = global.requestAnimationFrame || function (cb) {
|
||||||
|
return setTimeout(cb, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const documentHTML = '<!doctype html><html><body><div id="root"></div></body></html>';
|
||||||
|
global.document = jsdom(documentHTML);
|
||||||
|
global.window = document.parentWindow;
|
||||||
|
|
||||||
|
global.window.resizeTo = (width, height) => {
|
||||||
|
global.window.innerWidth = width || global.window.innerWidth;
|
||||||
|
global.window.innerHeight = height || global.window.innerHeight;
|
||||||
|
global.window.dispatchEvent(new Event('resize'));
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user