Skip to content

Commit

Permalink
Merge remote-tracking branch 'fusion/feat/1.16.0' into fix-inner
Browse files Browse the repository at this point in the history
  • Loading branch information
bindoon committed Jul 9, 2019
2 parents 0024a63 + 3e3a289 commit f032128
Show file tree
Hide file tree
Showing 29 changed files with 937 additions and 247 deletions.
3 changes: 3 additions & 0 deletions docs/badge/demo/change.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class Demo extends React.Component {
<Badge count={this.state.count}>
<a href="#" className="head-example"><span className="next-sr-only">unread messages</span></a>
</Badge>
<Badge count={this.state.count} showZero>
<a href="#" className="head-example"><span className="next-sr-only">unread messages</span></a>
</Badge>
<ButtonGroup>
<Button aria-label="add" onClick={this.increase}>
<Icon type="add"/>
Expand Down
1 change: 1 addition & 0 deletions docs/badge/index.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You can add class as below, so that messages will not appear on pages, but can b
| ------------- | ----------------------------------------------------- | ------------- | ----- |
| children | content of Badge based on | ReactNode | - |
| count | number to display, display ${overflowCount}+ when count is greater than overflowCount, display none when count equal to 0 | Number/String | 0 |
| showZero | whether to show count when count is 0 | Boolean | false |
| content | customized node content | ReactNode | - |
| overflowCount | max number to display | Number/String | 99 |
| dot | display a red dot, not a number | Boolean | false |
15 changes: 8 additions & 7 deletions docs/badge/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@

### Badge

| 参数 | 说明 | 类型 | 默认值 |
| ------------- | ----------------------------------------------------- | ------------- | ----- |
| children | 徽章依托的内容 | ReactNode | - |
| count | 展示的数字,大于 overflowCount 时显示为 ${overflowCount}+,为 0 时隐藏 | Number/String | 0 |
| content | 自定义节点内容 | ReactNode | - |
| overflowCount | 展示的封顶的数字 | Number/String | 99 |
| dot | 不展示数字,只展示一个小红点 | Boolean | false |
| 参数 | 说明 | 类型 | 默认值 |
| ------------- | ------------------------------------------------------- | ------------- | ----- |
| children | 徽章依托的内容 | ReactNode | - |
| count | 展示的数字,大于 overflowCount 时显示为 ${overflowCount}+,为 0 时默认隐藏 | Number/String | 0 |
| showZero | 当count为0时,是否显示count | Boolean | false |
| content | 自定义节点内容 | ReactNode | - |
| overflowCount | 展示的封顶的数字 | Number/String | 99 |
| dot | 不展示数字,只展示一个小红点 | Boolean | false |
2 changes: 2 additions & 0 deletions docs/calendar/index.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ moment.locale('zh-cn');
| showOtherMonth | Show dates of other month in current date | Boolean | true |
| defaultVisibleMonth | Default visible month of panel<br><br>**signature**:<br>Function() => void | Function | - |
| onSelect | Callback when select a date <br><br>**signature**:<br>Function(value: Object) => void<br>**parameter**:<br>_value_: {Object} date object | Function | func.noop |
| onModeChange | Callback when change mode <br><br>**签名**:<br>Function(mode: string) => void<br>**参数**:<br>_mode_: {string} mode type: date month year | Function | func.noop |
| dateCellRender | Render function for date cell<br><br>**signature**:<br>Function(value: Object) => ReactNode<br>**parameter**:<br>_value_: {Object} date object<br>**return**:<br>{ReactNode} null<br> | Function | (value) => value.date() |
| monthCellRender | Render function for month cell<br><br>**signature**:<br>Function(calendarDate: Object) => ReactNode<br>**parameter**:<br>_calendarDate_: {Object} current date object<br>**return**:<br>{ReactNode} null<br> | Function | - |
| yearRange | Year Range,[START_YEAR, END_YEAR] \(only shape in ‘card’, 'fullscreen') | Array&lt;Number> | - |
| disabledDate | Function to disable dates <br><br>**signature**:<br>Function(calendarDate: Object) => Boolean<br>**parameter**:<br>_calendarDate_: {Object} current date object<br>_view_: {Enum} current view type: 'year', 'month', 'date' <br>**return**:<br>{Boolean} null<br> | Function | - |

27 changes: 15 additions & 12 deletions docs/calendar/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ moment.locale('zh-cn');

### Calendar

| 参数 | 说明 | 类型 | 默认值 |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------------- |
| defaultValue | 默认选中的日期(moment 对象) | custom | - |
| shape | 展现形态<br><br>**可选值**:<br>'card', 'fullscreen', 'panel' | Enum | 'fullscreen' |
| value | 选中的日期值 (moment 对象) | custom | - |
| showOtherMonth | 是否展示非本月的日期 | Boolean | true |
| defaultVisibleMonth | 默认展示的月份<br><br>**签名**:<br>Function() => void | Function | - |
| onSelect | 选择日期单元格时的回调<br><br>**签名**:<br>Function(value: Object) => void<br>**参数**:<br>_value_: {Object} 对应的日期值 (moment 对象) | Function | func.noop |
| onVisibleMonthChange | 展现的月份变化时的回调<br><br>**签名**:<br>Function(value: Object, reason: String) => void<br>**参数**:<br>_value_: {Object} 显示的月份 (moment 对象)<br>_reason_: {String} 触发月份改变原因 | Function | func.noop |
| dateCellRender | 自定义日期渲染函数<br><br>**签名**:<br>Function(value: Object) => ReactNode<br>**参数**:<br>_value_: {Object} 日期值(moment对象)<br>**返回值**:<br>{ReactNode} null<br> | Function | value => value.date() |
| monthCellRender | 自定义月份渲染函数<br><br>**签名**:<br>Function(calendarDate: Object) => ReactNode<br>**参数**:<br>_calendarDate_: {Object} 对应 Calendar 返回的自定义日期对象<br>**返回值**:<br>{ReactNode} null<br> | Function | - |
| disabledDate | 不可选择的日期<br><br>**签名**:<br>Function(calendarDate: Object, view: String) => Boolean<br>**参数**:<br>_calendarDate_: {Object} 对应 Calendar 返回的自定义日期对象<br>_view_: {String} 当前视图类型,year: 年, month: 月, date: 日<br>**返回值**:<br>{Boolean} null<br> | Function | - |
| 参数 | 说明 | 类型 | 默认值 |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | --------------------- |
| defaultValue | 默认选中的日期(moment 对象) | custom | - |
| shape | 展现形态<br><br>**可选值**:<br>'card', 'fullscreen', 'panel' | Enum | 'fullscreen' |
| value | 选中的日期值 (moment 对象) | custom | - |
| mode | 面板模式<br><br>**可选值**:<br>'date', 'month', 'year' | Enum | - |
| showOtherMonth | 是否展示非本月的日期 | Boolean | true |
| defaultVisibleMonth | 默认展示的月份<br><br>**签名**:<br>Function() => void | Function | - |
| onSelect | 选择日期单元格时的回调<br><br>**签名**:<br>Function(value: Object) => void<br>**参数**:<br>_value_: {Object} 对应的日期值 (moment 对象) | Function | func.noop |
| onModeChange | 面板模式变化时的回调<br><br>**签名**:<br>Function(mode: String) => void<br>**参数**:<br>_mode_: {String} 对应面板模式 date month year | Function | func.noop |
| onVisibleMonthChange | 展现的月份变化时的回调<br><br>**签名**:<br>Function(value: Object, reason: String) => void<br>**参数**:<br>_value_: {Object} 显示的月份 (moment 对象)<br>_reason_: {String} 触发月份改变原因 | Function | func.noop |
| dateCellRender | 自定义日期渲染函数<br><br>**签名**:<br>Function(value: Object) => ReactNode<br>**参数**:<br>_value_: {Object} 日期值(moment对象)<br>**返回值**:<br>{ReactNode} null<br> | Function | value => value.date() |
| monthCellRender | 自定义月份渲染函数<br><br>**签名**:<br>Function(calendarDate: Object) => ReactNode<br>**参数**:<br>_calendarDate_: {Object} 对应 Calendar 返回的自定义日期对象<br>**返回值**:<br>{ReactNode} null<br> | Function | - |
| yearRange | 年份范围,[START_YEAR, END_YEAR] \(只在shape 为 ‘card’, 'fullscreen' 下生效) | Array&lt;Number> | - |
| disabledDate | 不可选择的日期<br><br>**签名**:<br>Function(calendarDate: Object, view: String) => Boolean<br>**参数**:<br>_calendarDate_: {Object} 对应 Calendar 返回的自定义日期对象<br>_view_: {String} 当前视图类型,year: 年, month: 月, date: 日<br>**返回值**:<br>{Boolean} null<br> | Function | - |
74 changes: 0 additions & 74 deletions docs/field/demo/topath-defaults.md

This file was deleted.

16 changes: 14 additions & 2 deletions docs/field/demo/topath.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ import { Input, Button, Field } from '@alifd/next';

class App extends React.Component {
field = new Field(this, {
parseName: true
parseName: true,
values: {
objWithDefaults: {
a: 1,
b: 2
}
}
});

onGetValue() {
Expand All @@ -43,7 +49,7 @@ class App extends React.Component {
}

render() {
const { init, reset } = this.field;
const { init, reset, resetToDefault } = this.field;

return (<div className="demo">
<h3>Object transfer</h3>
Expand All @@ -57,6 +63,11 @@ class App extends React.Component {
arr.1: <Input {...init('arr.1', {initValue: '1'})} />
<br/><br/>

<h3>Object with Defaults</h3>
objWithDefaults.a: <Input {...init('objWithDefaults.a')} /> &nbsp;
objWithDefaults.b: <Input {...init('objWithDefaults.b')} />
<br/><br/>

result:
<pre>{JSON.stringify(this.field.getValues(), null, 2)}</pre>

Expand All @@ -65,6 +76,7 @@ class App extends React.Component {
<Button type="primary" onClick={this.onGetValue.bind(this)}>getValues</Button>
<Button onClick={this.onSetValue.bind(this)}>setValues</Button>
<Button onClick={() => reset()}>reset</Button>
<Button onClick={() => resetToDefault()}>resetToDefault</Button>
</div>);
}
}
Expand Down
20 changes: 17 additions & 3 deletions src/badge/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ class Badge extends Component {
*/
children: PropTypes.node,
/**
* 展示的数字,大于 overflowCount 时显示为 ${overflowCount}+,为 0 时隐藏
* 展示的数字,大于 overflowCount 时显示为 ${overflowCount}+,为 0 时默认隐藏
*/
count: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/**
* 当count为0时,是否显示count
*/
showZero: PropTypes.bool,
/**
* 自定义节点内容
*/
Expand All @@ -45,6 +49,7 @@ class Badge extends Component {
static defaultProps = {
prefix: 'next-',
count: 0,
showZero: false,
overflowCount: 99,
dot: false,
};
Expand All @@ -59,14 +64,15 @@ class Badge extends Component {
style,
rtl,
count: originCount,
showZero,
overflowCount: originOverflowCount,
} = this.props;
const count = parseInt(originCount, 10);
const overflowCount = parseInt(originOverflowCount, 10);
const others = obj.pickOthers(Badge.propTypes, this.props);

// 如果是数字,则添加默认的 title
if (count) {
if (count || (count === 0 && showZero)) {
others.title = others.title || `${count}`;
}

Expand All @@ -82,7 +88,15 @@ class Badge extends Component {
<span dir={rtl ? 'rtl' : undefined} className={classes} {...others}>
{children}
<Sup
{...{ prefix, content, count, overflowCount, dot, style }}
{...{
prefix,
content,
count,
showZero,
overflowCount,
dot,
style,
}}
/>
</span>
);
Expand Down
Loading

0 comments on commit f032128

Please sign in to comment.