diff --git a/.eslintrc.js b/.eslintrc.js
index 3c85116424..5e2173a4e2 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -28,7 +28,9 @@ const eslintrc = {
'react/sort-comp': 0,
'react/prop-types': 0,
'react/jsx-first-prop-new-line': 0,
+ "react/jsx-filename-extension": [1, { extensions: ['.js', '.jsx', '.md'] }],
'import/no-unresolved': 0,
+ 'import/no-extraneous-dependencies': 0,
'no-param-reassign': 0,
'no-return-assign': 0,
'max-len': 0,
@@ -50,6 +52,8 @@ if (process.env.RUN_ENV === 'DEMO') {
'prefer-rest-params': 0,
'react/no-multi-comp': 0,
'react/prefer-es6-class': 0,
+ 'jsx-a11y/href-no-hash': 0,
+ 'import/newline-after-import': 0,
});
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2e613b1d5e..588858250e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,11 +9,22 @@ timeline: true
---
+## 1.10.0
+
+`2016-08-20`
+
+- Affix 和 BackTop 新增 `target` 属性,支持指定滚动容器。[#2718](https://github.com/ant-design/ant-design/issues/2718)
+- 文档页面加上编辑按钮,方便社区贡献。[#2325](https://github.com/ant-design/ant-design/issues/2325)
+- 升级 rc-cascader 依赖,修复一个 `loadData` 属性和表单结合使用的问题。[#2767](https://github.com/ant-design/ant-design/issues/2767)
+- 修复 `editable-card` 类型的 Tabs 没有关闭图标的问题。[#2747](https://github.com/ant-design/ant-design/issues/2747)
+- Menu 修正默认 `z-index`。[#2762](https://github.com/ant-design/ant-design/issues/2762)
+- 修正 Select 组件在 IE 下的一些样式问题。[#2741](https://github.com/ant-design/ant-design/issues/2741)
+
## 1.9.1
`2016-08-16`
-- 修复 Tabs 的 `type="editable-card"` 模式,activeKey 错误的问题。[#2725](https://github.com/ant-design/ant-design/issues/2725)
+- 修复 `editable-card` 类型的 Tabs 设置 `activeKey` 无效的问题。[#2725](https://github.com/ant-design/ant-design/issues/2725)
- 修复一个 Table 的样式兼容性问题。[#2723](https://github.com/ant-design/ant-design/issues/2723)
- 更新 axure 部件库。[#2714](https://github.com/ant-design/ant-design/issues/2714)
diff --git a/components/affix/demo/target.md b/components/affix/demo/target.md
new file mode 100644
index 0000000000..e2a21d1f56
--- /dev/null
+++ b/components/affix/demo/target.md
@@ -0,0 +1,29 @@
+---
+order: 4
+title: 参考对象
+---
+
+用 `target` 设置 `Affix` 需要监听其滚动事件的元素,默认为 `window`。
+
+````jsx
+import { Affix, Button } from 'antd';
+
+const Demo = () => {
+ return (
+
+
+
+
+
+
+
document.getElementById('affix-target')} offsetTop={20}>
+
+
+
+
+
+ );
+};
+
+ReactDOM.render(, mountNode);
+````
diff --git a/components/affix/index.tsx b/components/affix/index.tsx
index 1bd409d4f9..d4b70ec732 100644
--- a/components/affix/index.tsx
+++ b/components/affix/index.tsx
@@ -6,32 +6,42 @@ import warning from 'warning';
import assign from 'object-assign';
import shallowequal from 'shallowequal';
-function getScroll(w, top?: boolean) {
- let ret = w[`page${top ? 'Y' : 'X'}Offset`];
- const method = `scroll${top ? 'Top' : 'Left'}`;
- if (typeof ret !== 'number') {
- const d = w.document;
- // ie6,7,8 standard mode
- ret = d.documentElement[method];
- if (typeof ret !== 'number') {
- // quirks mode
- ret = d.body[method];
- }
+function getScroll(target, top) {
+ const prop = top ? 'pageYOffset' : 'pageXOffset';
+ const method = top ? 'scrollTop' : 'scrollLeft';
+ const isWindow = target === window;
+
+ let ret = isWindow ? target[prop] : target[method];
+ // ie6,7,8 standard mode
+ if (isWindow && typeof ret !== 'number') {
+ ret = window.document.documentElement[method];
}
+
return ret;
}
-function getOffset(element) {
- const rect = element.getBoundingClientRect();
- const body = document.body;
- const clientTop = element.clientTop || body.clientTop || 0;
- const clientLeft = element.clientLeft || body.clientLeft || 0;
- const scrollTop = getScroll(window, true);
- const scrollLeft = getScroll(window);
+function getTargetRect(target): any {
+ return target !== window ?
+ target.getBoundingClientRect() :
+ { top: 0, left: 0, bottom: 0 };
+}
+
+function getOffset(element, target) {
+ const elemRect = element.getBoundingClientRect();
+ const targetRect = getTargetRect(target);
+
+ const scrollTop = getScroll(target, true);
+ const scrollLeft = getScroll(target, false);
+
+ const docElem = window.document.body;
+ const clientTop = docElem.clientTop || 0;
+ const clientLeft = docElem.clientLeft || 0;
return {
- top: rect.top + scrollTop - clientTop,
- left: rect.left + scrollLeft - clientLeft,
+ top: elemRect.top - targetRect.top +
+ scrollTop - clientTop,
+ left: elemRect.left - targetRect.left +
+ scrollLeft - clientLeft,
};
}
@@ -45,15 +55,20 @@ export interface AffixProps {
offsetBottom?: number;
style?: React.CSSProperties;
onChange?: (affixed?: boolean) => any;
+ target?: () => Window | HTMLElement;
}
export default class Affix extends React.Component {
static propTypes = {
offsetTop: React.PropTypes.number,
offsetBottom: React.PropTypes.number,
+ target: React.PropTypes.func,
};
static defaultProps = {
+ target() {
+ return window;
+ },
onChange() {},
};
@@ -73,8 +88,10 @@ export default class Affix extends React.Component {
}
setAffixStyle(e, affixStyle) {
+ const { onChange, target } = this.props;
const originalAffixStyle = this.state.affixStyle;
- if (e.type === 'scroll' && originalAffixStyle && affixStyle) {
+ const isWindow = target() === window;
+ if (e.type === 'scroll' && originalAffixStyle && affixStyle && isWindow) {
return;
}
if (shallowequal(affixStyle, originalAffixStyle)) {
@@ -84,7 +101,7 @@ export default class Affix extends React.Component {
const affixed = !!this.state.affixStyle;
if ((affixStyle && !originalAffixStyle) ||
(!affixStyle && originalAffixStyle)) {
- this.props.onChange(affixed);
+ onChange(affixed);
}
});
}
@@ -100,24 +117,25 @@ export default class Affix extends React.Component {
this.setState({ placeholderStyle });
}
- handleScroll = (e) => {
- let { offsetTop, offsetBottom, offset } = this.props;
+ updatePosition = (e) => {
+ let { offsetTop, offsetBottom, offset, target } = this.props;
+ const targetNode = target();
// Backwards support
offsetTop = offsetTop || offset;
- const scrollTop = getScroll(window, true);
+ const scrollTop = getScroll(targetNode, true);
const affixNode = ReactDOM.findDOMNode(this) as HTMLElement;
- const fixedNode = ReactDOM.findDOMNode(this.refs.fixedNode) as HTMLElement;
- const elemOffset = getOffset(affixNode);
+ const elemOffset = getOffset(affixNode, targetNode);
const elemSize = {
- width: fixedNode.offsetWidth,
- height: fixedNode.offsetHeight,
+ width: this.refs.fixedNode.offsetWidth,
+ height: this.refs.fixedNode.offsetHeight,
};
const offsetMode = {
top: null as boolean,
bottom: null as boolean,
};
+ // Default to `offsetTop=0`.
if (typeof offsetTop !== 'number' && typeof offsetBottom !== 'number') {
offsetMode.top = true;
offsetTop = 0;
@@ -126,25 +144,31 @@ export default class Affix extends React.Component {
offsetMode.bottom = typeof offsetBottom === 'number';
}
+ const targetRect = getTargetRect(targetNode);
+ const targetInnerHeight =
+ (targetNode as Window).innerHeight || (targetNode as HTMLElement).clientHeight;
if (scrollTop > elemOffset.top - offsetTop && offsetMode.top) {
// Fixed Top
this.setAffixStyle(e, {
position: 'fixed',
- top: offsetTop,
- left: elemOffset.left,
+ top: targetRect.top + offsetTop,
+ left: targetRect.left + elemOffset.left,
width: affixNode.offsetWidth,
});
this.setPlaceholderStyle(e, {
width: affixNode.offsetWidth,
height: affixNode.offsetHeight,
});
- } else if (scrollTop < elemOffset.top + elemSize.height + offsetBottom - window.innerHeight &&
- offsetMode.bottom) {
+ } else if (
+ scrollTop < elemOffset.top + elemSize.height + offsetBottom - targetInnerHeight &&
+ offsetMode.bottom
+ ) {
// Fixed Bottom
+ const targetBottomOffet = targetNode === window ? 0 : (window.innerHeight - targetRect.bottom);
this.setAffixStyle(e, {
position: 'fixed',
- bottom: offsetBottom,
- left: elemOffset.left,
+ bottom: targetBottomOffet + offsetBottom,
+ left: targetRect.left + elemOffset.left,
width: affixNode.offsetWidth,
});
this.setPlaceholderStyle(e, {
@@ -159,17 +183,37 @@ export default class Affix extends React.Component {
componentDidMount() {
warning(!('offset' in this.props), '`offset` prop of Affix is deprecated, use `offsetTop` instead.');
- this.scrollEvent = addEventListener(window, 'scroll', this.handleScroll);
- this.resizeEvent = addEventListener(window, 'resize', this.handleScroll);
+
+ const target = this.props.target;
+ this.setTargetEventListeners(target);
+ }
+
+ componentWillReceiveProps(nextProps) {
+ if (this.props.target !== nextProps.target) {
+ this.clearScrollEventListeners();
+ this.setTargetEventListeners(nextProps.target);
+
+ // Mock Event object.
+ this.updatePosition({});
+ }
}
componentWillUnmount() {
- if (this.scrollEvent) {
- this.scrollEvent.remove();
- }
- if (this.resizeEvent) {
- this.resizeEvent.remove();
- }
+ this.clearScrollEventListeners();
+ }
+
+ setTargetEventListeners(getTarget) {
+ const target = getTarget();
+ this.scrollEvent = addEventListener(target, 'scroll', this.updatePosition);
+ this.resizeEvent = addEventListener(target, 'resize', this.updatePosition);
+ }
+
+ clearScrollEventListeners() {
+ ['scrollEvent', 'resizeEvent'].forEach((name) => {
+ if (this[name]) {
+ this[name].remove();
+ }
+ });
}
render() {
@@ -180,6 +224,7 @@ export default class Affix extends React.Component {
const props = assign({}, this.props);
delete props.offsetTop;
delete props.offsetBottom;
+ delete props.target;
return (
diff --git a/components/affix/index.zh-CN.md b/components/affix/index.zh-CN.md
index 1ac87fcf2e..bb4a4f54ab 100644
--- a/components/affix/index.zh-CN.md
+++ b/components/affix/index.zh-CN.md
@@ -20,4 +20,5 @@ english: Affix
|-------------|----------------|--------------------|--------------|
| offsetTop | 距离窗口顶部达到指定偏移量后触发 | Number | |
| offsetBottom | 距离窗口底部达到指定偏移量后触发 | Number | |
+| target | 设置 `Affix` 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | Function | () => window |
| onChange | 固定状态改变时触发的回调函数 | Function(affixed) | 无 |
diff --git a/components/auto-complete/demo/basic.md b/components/auto-complete/demo/basic.md
index eded8408bb..8f4b6651e5 100644
--- a/components/auto-complete/demo/basic.md
+++ b/components/auto-complete/demo/basic.md
@@ -1,6 +1,6 @@
---
order: 0
-title:
+title:
zh-CN: 基本使用
en-US: Basic Usage
---
diff --git a/components/auto-complete/demo/options.md b/components/auto-complete/demo/options.md
index 34d8d5ff5f..57b9fe2435 100644
--- a/components/auto-complete/demo/options.md
+++ b/components/auto-complete/demo/options.md
@@ -1,6 +1,6 @@
---
order: 2
-title:
+title:
zh-CN: 自定义选项
en-US: Customized
---
@@ -16,6 +16,7 @@ Items in dataSource could be an `AutoComplete.Option`.
````jsx
import { AutoComplete } from 'antd';
+
const Option = AutoComplete.Option;
const Complete = React.createClass({
diff --git a/components/auto-complete/index.tsx b/components/auto-complete/index.tsx
index 063ce0092f..8e92ccd1be 100644
--- a/components/auto-complete/index.tsx
+++ b/components/auto-complete/index.tsx
@@ -3,7 +3,7 @@ import Select, { Option, OptGroup } from '../select';
import classNames from 'classnames';
export interface AutoCompleteProps {
- size?: string;
+ size?: 'large' | 'small' | 'default';
className?: string;
notFoundContent?: Element;
dataSource: Array
;
diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx
index 111de53212..f8a5873056 100644
--- a/components/back-top/index.tsx
+++ b/components/back-top/index.tsx
@@ -5,24 +5,28 @@ import addEventListener from 'rc-util/lib/Dom/addEventListener';
import classNames from 'classnames';
import omit from 'object.omit';
-function getScroll(w, top) {
- let ret = w[`page${top ? 'Y' : 'X'}Offset`];
- const method = `scroll${top ? 'Top' : 'Left'}`;
- if (typeof ret !== 'number') {
- const d = w.document;
- // ie6,7,8 standard mode
- ret = d.documentElement[method];
- if (typeof ret !== 'number') {
- // quirks mode
- ret = d.body[method];
- }
+function getScroll(target, top) {
+ if (typeof window === 'undefined') {
+ return 0;
}
+
+ const prop = top ? 'pageYOffset' : 'pageXOffset';
+ const method = top ? 'scrollTop' : 'scrollLeft';
+ const isWindow = target === window;
+
+ let ret = isWindow ? target[prop] : target[method];
+ // ie6,7,8 standard mode
+ if (isWindow && typeof ret !== 'number') {
+ ret = window.document.documentElement[method];
+ }
+
return ret;
}
interface BackTopProps {
visibilityHeight?: number;
onClick?: (event) => void;
+ target?: () => HTMLElement | Window;
prefixCls?: string;
className?: string;
}
@@ -31,6 +35,9 @@ export default class BackTop extends React.Component {
static defaultProps = {
onClick() {},
visibilityHeight: 400,
+ target() {
+ return window;
+ },
prefixCls: 'ant-back-top',
};
@@ -38,9 +45,9 @@ export default class BackTop extends React.Component {
constructor(props) {
super(props);
- const scrollTop = getScroll(window, true);
+ const scrollTop = getScroll(props.target(), true);
this.state = {
- visible: scrollTop > this.props.visibilityHeight,
+ visible: scrollTop > props.visibilityHeight,
};
}
@@ -53,19 +60,25 @@ export default class BackTop extends React.Component {
}
setScrollTop(value) {
- document.body.scrollTop = value;
- document.documentElement.scrollTop = value;
+ const targetNode = this.props.target();
+ if (targetNode === window) {
+ document.body.scrollTop = value;
+ document.documentElement.scrollTop = value;
+ } else {
+ (targetNode as HTMLElement).scrollTop = value;
+ }
}
handleScroll = () => {
- const scrollTop = getScroll(window, true);
+ const { visibilityHeight, target } = this.props;
+ const scrollTop = getScroll(target(), true);
this.setState({
- visible: scrollTop > this.props.visibilityHeight,
+ visible: scrollTop > visibilityHeight,
});
}
componentDidMount() {
- this.scrollEvent = addEventListener(window, 'scroll', this.handleScroll);
+ this.scrollEvent = addEventListener(this.props.target(), 'scroll', this.handleScroll);
}
componentWillUnmount() {
diff --git a/components/badge/demo/99plus.md b/components/badge/demo/99plus.md
index e3e12700bf..b284cdcdbc 100644
--- a/components/badge/demo/99plus.md
+++ b/components/badge/demo/99plus.md
@@ -18,10 +18,10 @@ import { Badge } from 'antd';
ReactDOM.render(, mountNode);
````
diff --git a/components/badge/demo/basic.md b/components/badge/demo/basic.md
index 93c123fe87..ea20e74954 100644
--- a/components/badge/demo/basic.md
+++ b/components/badge/demo/basic.md
@@ -18,7 +18,7 @@ import { Badge } from 'antd';
ReactDOM.render(
-
+
, mountNode);
````
diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md
index 2919fcfba6..e7110f6932 100644
--- a/components/badge/demo/change.md
+++ b/components/badge/demo/change.md
@@ -44,10 +44,10 @@ const Test = React.createClass({
return (
-
+
-
+
diff --git a/components/badge/demo/link.md b/components/badge/demo/link.md
index 9b2da4b871..45aa19a15f 100644
--- a/components/badge/demo/link.md
+++ b/components/badge/demo/link.md
@@ -19,7 +19,7 @@ import { Badge } from 'antd';
ReactDOM.render(
-
+
, mountNode);
diff --git a/components/badge/demo/overflow.md b/components/badge/demo/overflow.md
index 245f64c2a4..c0a786dd4b 100644
--- a/components/badge/demo/overflow.md
+++ b/components/badge/demo/overflow.md
@@ -18,10 +18,10 @@ import { Badge } from 'antd';
ReactDOM.render(, mountNode);
````
diff --git a/components/badge/demo/status.md b/components/badge/demo/status.md
new file mode 100644
index 0000000000..de0ca28b84
--- /dev/null
+++ b/components/badge/demo/status.md
@@ -0,0 +1,36 @@
+---
+order: 7
+title:
+ zh-CN: 状态点
+ en-US: Status
+---
+
+## zh-CN
+
+用于表示状态的小圆点。
+
+## en-US
+
+Standalone badge with status.
+
+````jsx
+import { Badge } from 'antd';
+
+ReactDOM.render(
+
+
Status:
+
+
+
+
+
+
+
+
+
+
+
+
,
+ mountNode
+);
+````
diff --git a/components/badge/index.en-US.md b/components/badge/index.en-US.md
index 9b40049c6a..1f13f4ead7 100644
--- a/components/badge/index.en-US.md
+++ b/components/badge/index.en-US.md
@@ -14,7 +14,7 @@ Badge normally appears in proximity to notification or head picture with eye-cat
```jsx
-
+
```
@@ -28,3 +28,5 @@ Badge normally appears in proximity to notification or head picture with eye-cat
| count | Number to show in badge | Number | |
| overflowCount | Max count to show | Number | 99 |
| dot | whether to show red dot without number | Boolean | false |
+| status | Set Badge as a status dot | Enum{ 'success', 'processing, 'default', 'error', 'warning' } | '' |
+| text | If `status` is set, `text` is to set the text of status dot | String | '' |
diff --git a/components/badge/index.tsx b/components/badge/index.tsx
index e326905133..3864a63294 100644
--- a/components/badge/index.tsx
+++ b/components/badge/index.tsx
@@ -13,6 +13,8 @@ interface BadgeProps {
style?: React.CSSProperties;
prefixCls?: string;
className?: string;
+ status?: 'success' | 'processing' | 'default' | 'error' | 'warning';
+ text?: string;
}
export default class Badge extends React.Component {
@@ -21,6 +23,7 @@ export default class Badge extends React.Component {
count: null,
dot: false,
overflowCount: 99,
+ // status: 'default',
};
static propTypes = {
@@ -33,18 +36,25 @@ export default class Badge extends React.Component {
};
render() {
- let { count, prefixCls, overflowCount, className, style, children, dot } = this.props;
+ let { count, prefixCls, overflowCount, className, style, children, dot, status, text } = this.props;
+ const isDot = dot || status;
count = count > overflowCount ? `${overflowCount}+` : count;
// dot mode don't need count
- if (dot) {
+ if (isDot) {
count = '';
}
// null undefined "" "0" 0
- const hidden = (!count || count === '0') && !dot;
- const scrollNumberCls = prefixCls + (dot ? '-dot' : '-count');
+ const hidden = (!count || count === '0') && !isDot;
+ const scrollNumberCls = classNames({
+ [`${prefixCls}-dot`]: isDot,
+ [`${prefixCls}-count`]: !isDot,
+ [`${prefixCls}-status`]: status,
+ [`${prefixCls}-status-${status}`]: status,
+ [`${prefixCls}-status-with-text`]: text,
+ });
const badgeCls = classNames({
[className]: !!className,
[prefixCls]: true,
@@ -70,6 +80,10 @@ export default class Badge extends React.Component {
/>
}
+ {
+ hidden || !text ? null :
+ {text}
+ }
);
}
diff --git a/components/badge/index.zh-CN.md b/components/badge/index.zh-CN.md
index 4a93a7e40e..9a3284d631 100644
--- a/components/badge/index.zh-CN.md
+++ b/components/badge/index.zh-CN.md
@@ -15,7 +15,7 @@ english: Badge
```jsx
-
+
```
@@ -28,4 +28,6 @@ english: Badge
|----------------|----------------------------------|------------|---------|--------|
| count | 展示的数字,大于 overflowCount 时显示为 `${overflowCount}+`,为 0 时隐藏 | Number | | |
| overflowCount | 展示封顶的数字值 | Number | | 99 |
-| dot | 不展示数字,只有一个小红点 | boolean | | false |
+| dot | 不展示数字,只有一个小红点 | Boolean | | false |
+| status | 设置 Badge 为状态点 | Enum | 'success'、'processing'、'default'、'error'、'warning' | '' |
+| text | 在设置了 `status` 的前提下有效,设置状态点的文本 | String | | '' |
diff --git a/components/badge/style/index.less b/components/badge/style/index.less
index 84f4f114f4..af5bcb6d1a 100644
--- a/components/badge/style/index.less
+++ b/components/badge/style/index.less
@@ -47,6 +47,38 @@
box-shadow: 0 0 0 1px #fff;
}
+ &-status {
+ width: 6px;
+ height: 6px;
+
+ &-success {
+ background-color: @success-color;
+ }
+ &-processing {
+ background-color: @primary-color;
+ animation: antStatusProcessing 1.2s infinite ease-in-out;
+ }
+ &-default {
+ background-color: @normal-color;
+ }
+ &-error {
+ background-color: @error-color;
+ }
+ &-warning {
+ background-color: @warning-color;
+ }
+
+ &-with-text {
+ top: 5px;
+ }
+
+ &-text {
+ color: @text-color;
+ font-size: @font-size-base;
+ margin-left: 8px; // 8 - (6 / 2) === 5
+ }
+ }
+
&-zoom-appear,
&-zoom-enter {
animation: antZoomBadgeIn .3s @ease-out-back;
@@ -66,6 +98,16 @@
}
}
+@keyframes antStatusProcessing {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+ 50% {
+ opacity: 0;
+ }
+}
+
a & {
&-count:hover {
background: tint(@error-color, 20%);
diff --git a/components/button/button.tsx b/components/button/button.tsx
index 10a7a189a9..b95679b4ec 100644
--- a/components/button/button.tsx
+++ b/components/button/button.tsx
@@ -35,6 +35,7 @@ interface ButtonProps {
shape?: ButtonShape;
size?: ButtonSize;
onClick?: React.FormEventHandler;
+ onMouseUp?: React.FormEventHandler;
loading?: boolean;
disabled?: boolean;
style?: React.CSSProperties;
diff --git a/components/calendar/Header.tsx b/components/calendar/Header.tsx
index f2f3a4d9d4..9715e1dadd 100644
--- a/components/calendar/Header.tsx
+++ b/components/calendar/Header.tsx
@@ -7,7 +7,19 @@ const Option = Select.Option;
function noop() {}
-export default class Header extends React.Component {
+export interface HeaderProps {
+ prefixCls?: string;
+ locale?: any;
+ fullscreen?: boolean;
+ yearSelectOffset?: number;
+ yearSelectTotal?: number;
+ type?: string;
+ onValueChange?: (value) => void;
+ onTypeChange?: (type: string) => void;
+ value: any;
+}
+
+export default class Header extends React.Component {
static defaultProps = {
prefixCls: `${PREFIX_CLS}-header`,
yearSelectOffset: 10,
diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx
index 677977aaab..bb185e838e 100644
--- a/components/calendar/index.tsx
+++ b/components/calendar/index.tsx
@@ -16,7 +16,27 @@ function zerofixed(v) {
return `${v}`;
}
-export default class Calendar extends React.Component {
+interface CalendarContext {
+ antLocale?: {
+ Calendar?: any
+ };
+}
+
+export interface CalendarProps {
+ prefixCls?: string;
+ className?: string;
+ value?: Date;
+ defaultValue?: Date;
+ mode?: 'month' | 'year';
+ fullscreen?: boolean;
+ dateCellRender?: (date) => React.ReactNode;
+ monthCellRender?: (month) => React.ReactNode;
+ locale?: any;
+ style?: React.CSSProperties;
+ onPanelChange?: (date: Date, mode: string) => void;
+}
+
+export default class Calendar extends React.Component {
static defaultProps = {
monthCellRender: noop,
dateCellRender: noop,
@@ -43,6 +63,8 @@ export default class Calendar extends React.Component {
antLocale: PropTypes.object,
};
+ context: CalendarContext;
+
constructor(props) {
super(props);
this.state = {
diff --git a/components/calendar/locale/en_US.tsx b/components/calendar/locale/en_US.tsx
index 1fde2c098a..6847cc35d8 100644
--- a/components/calendar/locale/en_US.tsx
+++ b/components/calendar/locale/en_US.tsx
@@ -1 +1,2 @@
-module.exports = require('../../date-picker/locale/en_US');
+import en_US from '../../date-picker/locale/en_US';
+export default en_US;
diff --git a/components/calendar/locale/ru_RU.tsx b/components/calendar/locale/ru_RU.tsx
index aea2dd9a41..c1feaedaea 100644
--- a/components/calendar/locale/ru_RU.tsx
+++ b/components/calendar/locale/ru_RU.tsx
@@ -1 +1,2 @@
-module.exports = require('../../date-picker/locale/ru_RU');
+import ru_RU from '../../date-picker/locale/ru_RU';
+export default ru_RU;
diff --git a/components/calendar/locale/zh_CN.tsx b/components/calendar/locale/zh_CN.tsx
index 1880b1a980..9c83ec8453 100644
--- a/components/calendar/locale/zh_CN.tsx
+++ b/components/calendar/locale/zh_CN.tsx
@@ -1 +1,2 @@
-module.exports = require('../../date-picker/locale/zh_CN');
+import zh_CN from '../../date-picker/locale/zh_CN';
+export default zh_CN;
diff --git a/components/carousel/index.tsx b/components/carousel/index.tsx
index 721af47654..af7feeba4a 100644
--- a/components/carousel/index.tsx
+++ b/components/carousel/index.tsx
@@ -2,8 +2,9 @@
// https://github.com/WickyNilliams/enquire.js/issues/82
import assign from 'object-assign';
if (typeof window !== 'undefined') {
- const matchMediaPolyfill = function matchMediaPolyfill() {
+ const matchMediaPolyfill = function matchMediaPolyfill(mediaQuery: string): MediaQueryList {
return {
+ media: mediaQuery,
matches: false,
addListener() {
},
@@ -23,7 +24,7 @@ export interface CarouselProps {
/** 动画效果函数,可取 scrollx, fade */
effect?: CarouselEffect;
/** 是否显示面板指示点 */
- dots?: SlickCarouselboolean;
+ dots?: boolean;
/** 垂直显示 */
vertical?: boolean;
/** 是否自动切换 */
diff --git a/components/checkbox/Group.tsx b/components/checkbox/Group.tsx
index 24cc6fb05b..7d923ba552 100644
--- a/components/checkbox/Group.tsx
+++ b/components/checkbox/Group.tsx
@@ -59,12 +59,13 @@ export default class CheckboxGroup extends React.Component {
+ // https://github.com/Microsoft/TypeScript/issues/7960
+ return (options as Array).map(option => {
if (typeof option === 'string') {
return {
label: option,
value: option,
- };
+ } as CheckboxOptionType;
}
return option;
});
diff --git a/components/checkbox/demo/disable.md b/components/checkbox/demo/disabled.md
similarity index 100%
rename from components/checkbox/demo/disable.md
rename to components/checkbox/demo/disabled.md
diff --git a/components/date-picker/Calendar.tsx b/components/date-picker/Calendar.tsx
index ce7939bad1..bb60c4cf48 100644
--- a/components/date-picker/Calendar.tsx
+++ b/components/date-picker/Calendar.tsx
@@ -2,7 +2,7 @@ import * as React from 'react';
import CalendarLocale from 'rc-calendar/lib/locale/zh_CN';
import RcCalendar from 'rc-calendar';
-export default class Calendar extends React.Component {
+export default class Calendar extends React.Component {
static defaultProps = {
locale: CalendarLocale,
prefixCls: 'ant-calendar',
diff --git a/components/date-picker/RangePicker.tsx b/components/date-picker/RangePicker.tsx
index 5755828661..0ef673c41f 100644
--- a/components/date-picker/RangePicker.tsx
+++ b/components/date-picker/RangePicker.tsx
@@ -5,7 +5,7 @@ import RcDatePicker from 'rc-calendar/lib/Picker';
import classNames from 'classnames';
import Icon from '../icon';
-export default class RangePicker extends React.Component {
+export default class RangePicker extends React.Component {
static defaultProps = {
defaultValue: [],
};
@@ -74,7 +74,7 @@ export default class RangePicker extends React.Component {
let pickerChangeHandler = {
onChange: this.handleChange,
};
- let calendarHandler = {
+ let calendarHandler: Object = {
onOk: this.handleChange,
};
if (props.timePicker) {
diff --git a/components/date-picker/createPicker.tsx b/components/date-picker/createPicker.tsx
index 0aea0d27fa..d34fd5d59a 100644
--- a/components/date-picker/createPicker.tsx
+++ b/components/date-picker/createPicker.tsx
@@ -6,6 +6,11 @@ import classNames from 'classnames';
import assign from 'object-assign';
import Icon from '../icon';
+export interface PickerProps {
+ parseDateFromValue?: Function;
+ value?: string | Date;
+}
+
export default function createPicker(TheCalendar) {
// use class typescript error
const CalenderWrapper = React.createClass({
@@ -16,7 +21,7 @@ export default function createPicker(TheCalendar) {
};
},
- componentWillReceiveProps(nextProps) {
+ componentWillReceiveProps(nextProps: PickerProps) {
if ('value' in nextProps) {
this.setState({
value: nextProps.parseDateFromValue(nextProps.value),
@@ -60,10 +65,10 @@ export default function createPicker(TheCalendar) {
});
// 需要选择时间时,点击 ok 时才触发 onChange
- let pickerChangeHandler = {
+ let pickerChangeHandler: Object = {
onChange: this.handleChange,
};
- let calendarHandler = {
+ let calendarHandler: Object = {
onOk: this.handleChange,
// fix https://github.com/ant-design/ant-design/issues/1902
onSelect: (value, cause) => {
@@ -95,7 +100,7 @@ export default function createPicker(TheCalendar) {
);
// default width for showTime
- const pickerStyle = {};
+ const pickerStyle = { width: undefined };
if (props.showTime) {
pickerStyle.width = 180;
}
diff --git a/components/date-picker/demo/locale.md b/components/date-picker/demo/locale.md
index 8e1ebcc655..eabd7a8511 100644
--- a/components/date-picker/demo/locale.md
+++ b/components/date-picker/demo/locale.md
@@ -7,11 +7,11 @@ title:
## zh-CN
-通过 `locale` 配置时区、语言等, 默认支持 `en_US`,`zh_CN`。
+通过 `locale` 配置时区、语言等, 默认支持 `en_US`,`zh_CN`。不同版本带有不同的时区配置,如果所在时区与默认配置不同,需要自行设置。上面的 demo 就是在东八区使用 en_US 版本的例子。
## en-US
-Use locale to set the properties like time zone, language and etc. en_US, zh_CN are supported by default.
+Use locale to set the properties like time zone, language and etc. `en_US`, `zh_CN` are supported by default. There are different time zone configuration in different versions, you must set it by yourself if your time zone does not match the default setting. The example above is to show how to use the `en_US` version at GMT+8 time zone.
````jsx
@@ -19,7 +19,7 @@ import { DatePicker } from 'antd';
import enUS from 'antd/lib/date-picker/locale/en_US';
const customLocale = {
- timezoneOffset: 0 * 60,
+ timezoneOffset: 8 * 60,
firstDayOfWeek: 0,
minimalDaysInFirstWeek: 1,
};
diff --git a/components/date-picker/index.tsx b/components/date-picker/index.tsx
index 9c33a6efb4..108cc7824e 100644
--- a/components/date-picker/index.tsx
+++ b/components/date-picker/index.tsx
@@ -1,15 +1,49 @@
+import * as React from 'react';
+import assign from 'object-assign';
import RcCalendar from 'rc-calendar';
import MonthCalendar from 'rc-calendar/lib/MonthCalendar';
import createPicker from './createPicker';
import wrapPicker from './wrapPicker';
import RangePicker from './RangePicker';
import Calendar from './Calendar';
+import { TimePickerProps } from '../time-picker';
-const DatePicker = wrapPicker(createPicker(RcCalendar));
-const MonthPicker = wrapPicker(createPicker(MonthCalendar), 'yyyy-MM');
+interface PickerProps {
+ format?: string;
+ disabled?: boolean;
+ style?: React.CSSProperties;
+ popupStyle?: React.CSSProperties;
+ locale?: any;
+ size?: 'large' | 'small' | 'default';
+ getCalendarContainer?: (trigger) => React.ReactNode;
+}
-DatePicker.Calendar = Calendar;
-DatePicker.RangePicker = wrapPicker(RangePicker);
-DatePicker.MonthPicker = MonthPicker;
+interface SinglePickerProps {
+ value?: string | Date;
+ defaultValue?: string | Date;
+ onChange?: (date: Date, dateString: string) => void;
+}
+
+export interface DatePickerProps extends PickerProps, SinglePickerProps {
+ showTime?: TimePickerProps;
+}
+const DatePicker = wrapPicker(createPicker(RcCalendar)) as React.ClassicComponentClass;
+
+export interface MonthPickerProps extends PickerProps, SinglePickerProps {
+}
+const MonthPicker = wrapPicker(createPicker(MonthCalendar), 'yyyy-MM') as React.ClassicComponentClass;
+
+export interface RangePickerProps extends PickerProps {
+ value?: [string | Date, string | Date];
+ defaultValue?: [string | Date, string | Date];
+ onChange?: (dates: [Date, Date], dateStrings: [String, String]) => void;
+ showTime?: TimePickerProps;
+}
+
+assign(DatePicker, {
+ RangePicker: wrapPicker(RangePicker) as React.ClassicComponentClass,
+ Calendar,
+ MonthPicker,
+});
export default DatePicker;
diff --git a/components/date-picker/wrapPicker.tsx b/components/date-picker/wrapPicker.tsx
index 5eece135f8..bfb93b465c 100644
--- a/components/date-picker/wrapPicker.tsx
+++ b/components/date-picker/wrapPicker.tsx
@@ -7,7 +7,7 @@ import classNames from 'classnames';
import defaultLocale from './locale/zh_CN';
import assign from 'object-assign';
-export default function wrapPicker(Picker, defaultFormat) {
+export default function wrapPicker(Picker, defaultFormat?) {
const PickerWrapper = React.createClass({
getDefaultProps() {
return {
@@ -46,7 +46,7 @@ export default function wrapPicker(Picker, defaultFormat) {
getFormatter() {
const format = this.props.format;
- const formatter = new DateTimeFormat(format, this.getLocale().lang.format);
+ const formatter = new DateTimeFormat(format as string, this.getLocale().lang.format);
return formatter;
},
diff --git a/components/dropdown/demo/basic.md b/components/dropdown/demo/basic.md
index 2c7e45a9d0..2f6b962545 100644
--- a/components/dropdown/demo/basic.md
+++ b/components/dropdown/demo/basic.md
@@ -19,13 +19,13 @@ import { Menu, Dropdown, Icon } from 'antd';
const menu = (
);
diff --git a/components/dropdown/demo/item.md b/components/dropdown/demo/item.md
index 4668428509..8ab8c165a6 100644
--- a/components/dropdown/demo/item.md
+++ b/components/dropdown/demo/item.md
@@ -19,10 +19,10 @@ import { Menu, Dropdown, Icon } from 'antd';
const menu = (
diff --git a/components/upload/demo/fileList.md b/components/upload/demo/fileList.md
index 3df1ce3224..6ed31b8d18 100644
--- a/components/upload/demo/fileList.md
+++ b/components/upload/demo/fileList.md
@@ -1,8 +1,12 @@
---
order: 2
-title: 完全控制的上传列表
+title:
+ zh-CN: 完全控制的上传列表
+ en-US: Complete control over file list
---
+## zh-CN
+
使用 `fileList` 对列表进行完全控制,可以实现各种自定义功能,以下演示三种情况:
1) 上传列表数量的限制。
@@ -11,6 +15,14 @@ title: 完全控制的上传列表
3) 按照服务器返回信息筛选成功上传的文件。
+## en-US
+
+You can gain full control over filelist by configuring `fileList`. You can accomplish all kinds of customed functions. The following shows three circumstances:
+
+1. limit the number of uploaded files
+2. read from response and show file link
+3. filter successfully uploaded files according to response from server
+
````jsx
import { Upload, Button, Icon } from 'antd';
@@ -28,20 +40,20 @@ const MyUpload = React.createClass({
handleChange(info) {
let fileList = info.fileList;
- // 1. 上传列表数量的限制
- // 只显示最近上传的一个,旧的会被新的顶掉
+ // 1. Limit the number of uploaded files
+ // Only to show two recent uploaded files, and old ones will be replaced by the new
fileList = fileList.slice(-2);
- // 2. 读取远程路径并显示链接
+ // 2. read from response and show file link
fileList = fileList.map((file) => {
if (file.response) {
- // 组件会将 file.url 作为链接进行展示
+ // Component will show file.url as link
file.url = file.response.url;
}
return file;
});
- // 3. 按照服务器返回信息筛选成功上传的文件
+ // 3. filter successfully uploaded files according to response from server
fileList = fileList.filter((file) => {
if (file.response) {
return file.response.status === 'success';
@@ -60,7 +72,7 @@ const MyUpload = React.createClass({
return (
);
diff --git a/components/upload/demo/multiple.md b/components/upload/demo/multiple.md
index be410c9616..b34c6dbd2f 100644
--- a/components/upload/demo/multiple.md
+++ b/components/upload/demo/multiple.md
@@ -1,11 +1,19 @@
---
order: 5
hidden: true
-title: 多文件选择
+title:
+ zh-CN: 多文件选择
+ en-US: Multifile Selection
---
+## zh-CN
+
按住 ctrl 可选择多个文件,`ie10+` 支持。
+## en-US
+
+You can select multiple files with CTRL holding down. `IE10+` supported.
+
````jsx
import { Upload, message, Button, Icon } from 'antd';
@@ -17,9 +25,9 @@ const props = {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
- message.success(`${info.file.name} 上传成功。`);
+ message.success(`${info.file.name} upload sucessfully。`);
} else if (info.file.status === 'error') {
- message.error(`${info.file.name} 上传失败。`);
+ message.error(`${info.file.name} upload unsuccessfully。`);
}
},
};
@@ -27,7 +35,7 @@ const props = {
ReactDOM.render(
, mountNode);
diff --git a/components/upload/demo/picture-card.md b/components/upload/demo/picture-card.md
index 03f280bd2c..6e810e88e4 100644
--- a/components/upload/demo/picture-card.md
+++ b/components/upload/demo/picture-card.md
@@ -1,10 +1,18 @@
---
order: 8
-title: 图片卡片样式
+title:
+ zh-CN: 图片卡片样式
+ en-US: Pictures with card tyle
---
+## zh-CN
+
上传文件为图片,可展示本地缩略图。
+## en-US
+
+If uploade file is picture, a thumbnail can be shown.
+
````jsx
import { Upload, Icon, Modal } from 'antd';
@@ -42,11 +50,11 @@ const ImageUploadList = React.createClass({
{introChildren}
+
+
+
+
+ );
+}
diff --git a/site/theme/template/Content/MainContent.jsx b/site/theme/template/Content/MainContent.jsx
index 287b127b6d..232dbe9c69 100644
--- a/site/theme/template/Content/MainContent.jsx
+++ b/site/theme/template/Content/MainContent.jsx
@@ -5,6 +5,7 @@ import Article from './Article';
import ComponentDoc from './ComponentDoc';
import * as utils from '../utils';
import config from '../../';
+
const SubMenu = Menu.SubMenu;
export default class MainContent extends React.Component {
@@ -62,7 +63,7 @@ export default class MainContent extends React.Component {
{text}
:
-
+
{text}
;
@@ -182,12 +183,12 @@ export default class MainContent extends React.Component {
>
{
- !!prev ?
+ prev ?
React.cloneElement(prev.props.children, { className: 'prev-page' }) :
null
}
{
- !!next ?
+ next ?
React.cloneElement(next.props.children, { className: 'next-page' }) :
null
}
diff --git a/site/theme/template/Content/index.jsx b/site/theme/template/Content/index.jsx
index 406e02e5af..868df86905 100644
--- a/site/theme/template/Content/index.jsx
+++ b/site/theme/template/Content/index.jsx
@@ -1,6 +1,6 @@
import React from 'react';
-import MainContent from './MainContent';
import Promise from 'bluebird';
+import MainContent from './MainContent';
// locale copy from layout
const locale = (
diff --git a/site/theme/template/Layout/Footer.jsx b/site/theme/template/Layout/Footer.jsx
index 2baf34aa55..89c85f0fb4 100644
--- a/site/theme/template/Layout/Footer.jsx
+++ b/site/theme/template/Layout/Footer.jsx
@@ -2,6 +2,7 @@ import React from 'react';
import { Select, Modal } from 'antd';
import { version as antdVersion } from 'antd/package.json';
import { docVersions } from '../../';
+
const Option = Select.Option;
function isLocalStorageNameSupported() {
@@ -41,8 +42,8 @@ export default class Footer extends React.Component {
@@ -70,10 +71,13 @@ export default class Footer extends React.Component {
仓库
+
@@ -85,19 +89,24 @@ export default class Footer extends React.Component {
- 联系我们
+ 社区
+
diff --git a/site/theme/template/Layout/Header.jsx b/site/theme/template/Layout/Header.jsx
index ddfe7b1001..edbc1d9dde 100644
--- a/site/theme/template/Layout/Header.jsx
+++ b/site/theme/template/Layout/Header.jsx
@@ -5,6 +5,7 @@ import enquire from 'enquire.js';
import debounce from 'lodash.debounce';
import classNames from 'classnames';
import { Select, Menu, Row, Col, Icon, Button } from 'antd';
+
const Option = Select.Option;
export default class Header extends React.Component {
@@ -116,6 +117,7 @@ export default class Header extends React.Component {
'home-nav-white': !this.state.isFirstFrame,
});
+ const searchPlaceholder = this.context.intl.locale === 'zh-CN' ? '搜索组件...' : 'Search...';
return (