mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-15 22:09:21 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6a617f2e9 | ||
|
|
1a790a5a9f | ||
|
|
2a411130bc | ||
|
|
bf22853f41 |
14
.github/lock.yml
vendored
14
.github/lock.yml
vendored
@@ -1,14 +0,0 @@
|
||||
# Configuration for lock-threads - https://github.com/dessant/lock-threads
|
||||
|
||||
# Number of days of inactivity before a closed issue or pull request is locked
|
||||
daysUntilLock: 365
|
||||
# Comment to post before locking. Set to `false` to disable
|
||||
lockComment: >
|
||||
This thread has been automatically locked because it has not had recent
|
||||
activity. Please open a new issue for related bugs and link to relevant
|
||||
comments in this thread.
|
||||
# Issues or pull requests with these labels will not be locked
|
||||
# exemptLabels:
|
||||
# - no-locking
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: issues
|
||||
@@ -15,77 +15,6 @@ timeline: true
|
||||
|
||||
---
|
||||
|
||||
## 3.5.2
|
||||
|
||||
`2018-05-13`
|
||||
|
||||
- 🐞 Fixed `Cascader` displayRender z-index issue. [#10433](https://github.com/ant-design/ant-design/issues/10433)
|
||||
- 🐞 Fixed `Button` Types of property 'ref' are incompatible. [#10405](https://github.com/ant-design/ant-design/issues/10405)
|
||||
- 🐞 Fixed `Table` filter doesn't work on checkbox click. [#10452](https://github.com/ant-design/ant-design/issues/10452)
|
||||
- 🐞 Fixed the height of `Form` item when checks position is dithered. [#10445](https://github.com/ant-design/ant-design/issues/10445)
|
||||
- 🌟 Allow to use any CSS units for `Layout` width. [#10479](https://github.com/ant-design/ant-design/pull/10479)
|
||||
|
||||
## 3.5.1
|
||||
|
||||
`2018-05-09`
|
||||
|
||||
- 🐞 Fixed broken style of Input.Group under Form. [#10371](https://github.com/ant-design/ant-design/issues/10371)
|
||||
- 🐞 Fixed overlay style of Select. [#10383](https://github.com/ant-design/ant-design/issues/10383)
|
||||
- 🐞 Remove focused style of Collapse.
|
||||
- 🐞 Remove unnecessary `z-index` of Input.Group and Checkbox. [#9840](https://github.com/ant-design/ant-design/issues/9840) [#10385](https://github.com/ant-design/ant-design/issues/10385)
|
||||
- 🐞 Fixed that monospaced font family can't be bold.
|
||||
- Table
|
||||
- 💄 Rewrited the editable table demo. [#10119](https://github.com/ant-design/ant-design/pull/10119)
|
||||
- 🐞 Fixed that table column overlay each other. [#9822](https://github.com/ant-design/ant-design/issues/9822)
|
||||
- TypeScript
|
||||
- 🐞 Fixed Breadcrumb.Item type. [#10372](https://github.com/ant-design/ant-design/pull/10372) [@karol-majewski](https://github.com/karol-majewski)
|
||||
- 🐞 Fixed Table `rowSelection` type。[#10374](https://github.com/ant-design/ant-design/issues/10374)
|
||||
|
||||
## 3.5.0
|
||||
|
||||
`2018-05-04`
|
||||
|
||||
- 🌟 Add `title` prop to `Badge` that shows when hovering it. [74d81c2](https://github.com/ant-design/ant-design/commit/74d81c2d078a3c84b3e44cbfbdd99b8f479ea71d) [@ludwigbacklund](https://github.com/ludwigbacklund)
|
||||
- 🌟 Add `successPercent` as `Progress[format]` argument. [#10096](https://github.com/ant-design/ant-design/issues/10096)
|
||||
- 🌟 Update `rc-notification` to 3.1.0 so that `Notification` support set `maxCount`. [#10161](https://github.com/ant-design/ant-design/pull/10161) [@jzhangs](https://github.com/jzhangs)
|
||||
- 🌟 Update `rc-cascader` to 1.13.0 so that `Cascader` support set `filedNames`. [react-component/cascader#23](https://github.com/react-component/cascader/pull/23) [@405go](https://github.com/405go)
|
||||
- 🌟 Add ability to update `Notification` props by key. [react-component/notification#40](https://github.com/react-component/notification/pull/40) [@yevhen-hryhorevskyi](https://github.com/yevhen-hryhorevskyi)
|
||||
- 🌟 `List` support pagination by default. [#10135](https://github.com/ant-design/ant-design/pull/10135)
|
||||
- Table
|
||||
- 🌟 Column `sorter` function is passed `sortOrder` as param. [#10306](https://github.com/ant-design/ant-design/pull/10306) [@kumarashwin](https://github.com/kumarashwin)
|
||||
- 🐞 Fix merged header cell border. [#10359](https://github.com/ant-design/ant-design/issues/10359)
|
||||
- 🐞 Fix lost of user selection on data updates. [#10332](https://github.com/ant-design/ant-design/pull/10332) [@chrvadala](https://github.com/chrvadala)
|
||||
- `Menu` upgrade `rc-menu` to `7.x` [#10305](https://github.com/ant-design/ant-design/pull/10305)
|
||||
- 🌟 Better aria-* attributes support. [react-component/menu#137](https://github.com/react-component/menu/pull/137)
|
||||
- 🌟 Improve Menu performance by avoiding unnecessary updates. [react-component/menu#133](https://github.com/react-component/menu/pull/133)
|
||||
- 🌟 Support passing props through to MenuItem list item. [react-component/menu#135](https://github.com/react-component/menu/pull/135)
|
||||
- 🐞 Minor key shortcut bug fixes. [react-component/menu#132](https://github.com/react-component/menu/pull/132)
|
||||
- Collapse
|
||||
- 🌟 Support custom `Collapse` styles with less. [#9943](https://github.com/ant-design/ant-design/pull/9943) [@davidhatten](https://github.com/davidhatten)
|
||||
- 🌟 Update `rc-collapse` to 1.9.0 to add `Collapse` keyboard support. [react-component/collapse#84](https://github.com/react-component/collapse/pull/84/) [@kossel](https://github.com/kossel)
|
||||
- Select
|
||||
- 🐞 Fix type for `placeholder`. [#10282](https://github.com/ant-design/ant-design/pull/10282) [@thomasthiebaud](https://github.com/thomasthiebaud)
|
||||
- 🐞 Fix extra space taken up when arrow disabled. [#10296](https://github.com/ant-design/ant-design/pull/10296)
|
||||
- 🐞 Fix property `value` typescript type. [#10336](https://github.com/ant-design/ant-design/pull/10336) [@paranoidjk](https://github.com/paranoidjk)
|
||||
- Input
|
||||
- 🐞 Fix `Input.Search` not disable enter button when disabled prop is true. [#10040](https://github.com/ant-design/ant-design/issues/10040)
|
||||
- 🐞 Fix `Input.Group` align issue in Form. [#10281](https://github.com/ant-design/ant-design/issues/10281)
|
||||
- Form
|
||||
- 🐞 Fix typing for `Form.onValuesChange`. [#10231](https://github.com/ant-design/ant-design/pull/10231) [@whtsky](https://github.com/whtsky)
|
||||
- 🐞 Fix typescript interface `ComponentDecorator`. [#10324](https://github.com/ant-design/ant-design/pull/10324) [@paranoidjk](https://github.com/paranoidjk)
|
||||
- 🐞 Fix dashed `Divider`. [#10216](https://github.com/ant-design/ant-design/issues/10216)
|
||||
- 🐞 Fix `Spin` container interaction. [#10227](https://github.com/ant-design/ant-design/issues/10227)
|
||||
- 🐞 Fix `Notification` icon hover color. [#10272](https://github.com/ant-design/ant-design/issues/10272)
|
||||
- 🐞 Fix `Upload` property `lastModifiedDate` name. [#10315](https://github.com/ant-design/ant-design/pull/10315) [@danielg2002](https://github.com/danielg2002)
|
||||
- 🐞 Fix `Button` props type, use `React.HTMLProps`. [#10229](https://github.com/ant-design/ant-design/pull/10229) [@whtsky](https://github.com/whtsky)
|
||||
- 🐞 Fix less var naming convention. [#10275](https://github.com/ant-design/ant-design/issues/10275)
|
||||
|
||||
## 3.4.5
|
||||
|
||||
`2018-05-03`
|
||||
|
||||
- 🐞 Fix file object is empty and file name not showing in Upload. [#10319](https://github.com/ant-design/ant-design/issues/10319)
|
||||
|
||||
## 3.4.4
|
||||
|
||||
`2018-04-28`
|
||||
|
||||
@@ -15,77 +15,6 @@ timeline: true
|
||||
|
||||
---
|
||||
|
||||
## 3.5.2
|
||||
|
||||
`2018-05-13`
|
||||
|
||||
- 🐞 修复 `Cascader` 的 displayRender 问题。[#10433](https://github.com/ant-design/ant-design/issues/10433)
|
||||
- 🐞 修复 `Button` ref 不兼容问题。[#10405](https://github.com/ant-design/ant-design/issues/10405)
|
||||
- 🐞 修复 `Table` 过滤器在复选框上不起作用。[#10452](https://github.com/ant-design/ant-design/issues/10452)
|
||||
- 🐞 修复 `Form` 表单项校验位置高度时出现抖动问题。[#10445](https://github.com/ant-design/ant-design/issues/10445)
|
||||
- 🌟 设置 `Layout` 宽度时,允许使用任何的 CSS 单位。 [#10479](https://github.com/ant-design/ant-design/pull/10479)
|
||||
|
||||
## 3.5.1
|
||||
|
||||
`2018-05-09`
|
||||
|
||||
- 🐞 修复 Input.Group 在 Form 下样式错位的问题。[#10371](https://github.com/ant-design/ant-design/issues/10371)
|
||||
- 🐞 修复 Select 箭头和内容重叠的问题。[#10383](https://github.com/ant-design/ant-design/issues/10383)
|
||||
- 🐞 移除 Collapse 点击时的 focus 样式。
|
||||
- 🐞 移除 Input.Group 和 Checkbox 不必要的 `z-index`。[#9840](https://github.com/ant-design/ant-design/issues/9840) [#10385](https://github.com/ant-design/ant-design/issues/10385)
|
||||
- 🐞 修复一个数字等宽字体没有加粗的问题。
|
||||
- Table
|
||||
- 💄 重写了可编辑表格的演示。[#10119](https://github.com/ant-design/ant-design/pull/10119)
|
||||
- 🐞 修复一个表格列内容互相重叠的问题。[#9822](https://github.com/ant-design/ant-design/issues/9822)
|
||||
- TypeScript
|
||||
- 🐞 调整 Breadcrumb.Item 的类型。[#10372](https://github.com/ant-design/ant-design/pull/10372) [@karol-majewski](https://github.com/karol-majewski)
|
||||
- 🐞 修复 Table 的 `rowSelection` 的类型。[#10374](https://github.com/ant-design/ant-design/issues/10374)
|
||||
|
||||
## 3.5.0
|
||||
|
||||
`2018-05-04`
|
||||
|
||||
- 🌟 组件 `Badge` 新增 `title` 属性支持鼠标 hover 的时候显示。[74d81c2](https://github.com/ant-design/ant-design/commit/74d81c2d078a3c84b3e44cbfbdd99b8f479ea71d) [@ludwigbacklund](https://github.com/ludwigbacklund)
|
||||
- 🌟 添加 `successPercent` 为 `Progress[format]` 的参数。[#10096](https://github.com/ant-design/ant-design/issues/10096)
|
||||
- 🌟 更新 `rc-notification` 到 3.1.0 来支持组件 `Notification` 的 `maxCount` 属性。[#10161](https://github.com/ant-design/ant-design/pull/10161) [@jzhangs](https://github.com/jzhangs)
|
||||
- 🌟 更新 `rc-cascader` 到 1.13.0 来支持组件 `Cascader` 的 `filedNames` 属性。[react-component/cascader#23](https://github.com/react-component/cascader/pull/23) [@405go](https://github.com/405go)
|
||||
- 🌟 组件 `Notification` 支持通过 key 更新通知属性。 [react-component/notification#40](https://github.com/react-component/notification/pull/40) [@yevhen-hryhorevskyi](https://github.com/yevhen-hryhorevskyi)
|
||||
- 🌟 组件 `List` 支持内置的翻页功能。[#10135](https://github.com/ant-design/ant-design/pull/10135)
|
||||
- Table
|
||||
- 🌟 新增 `sortOrder` 参数传递给列配置中的 `sorter` 方法。[#10306](https://github.com/ant-design/ant-design/pull/10306) [@kumarashwin](https://github.com/kumarashwin)
|
||||
- 🐞 修复头部单元格的边框样式问题。[#10359](https://github.com/ant-design/ant-design/issues/10359)
|
||||
- 🐞 修复当数据变化时用户选择项丢失的问题。[#10332](https://github.com/ant-design/ant-design/pull/10332) [@chrvadala](https://github.com/chrvadala)
|
||||
- `Menu` 升级 `rc-menu` 到 `7.x` [#10305](https://github.com/ant-design/ant-design/pull/10305)
|
||||
- 🌟 更好的 aria-* 属性支持。[react-component/menu#137](https://github.com/react-component/menu/pull/137)
|
||||
- 🌟 一些内部优化提升组件性能。[react-component/menu#133](https://github.com/react-component/menu/pull/133)
|
||||
- 🌟 支持将属性传递到菜单项中。[react-component/menu#135](https://github.com/react-component/menu/pull/135)
|
||||
- 🐞 修复一些快捷键的问题。[react-component/menu#132](https://github.com/react-component/menu/pull/132)
|
||||
- Collapse
|
||||
- 🌟 更新 `rc-collapse` 到 1.9.0 优化键盘支持。[react-component/collapse#84](https://github.com/react-component/collapse/pull/84/) [@kossel](https://github.com/kossel)
|
||||
- 🌟 支持通过 less 定义组件 `Collapse` 的样式。[#9943](https://github.com/ant-design/ant-design/pull/9943) [@davidhatten](https://github.com/davidhatten)
|
||||
- Select
|
||||
- 🐞 修复 `placeholder` 的 ts 类型问题。[#10282](https://github.com/ant-design/ant-design/pull/10282) [@thomasthiebaud](https://github.com/thomasthiebaud)
|
||||
- 🐞 修复不显示箭头时多余的空白。[#10296](https://github.com/ant-design/ant-design/pull/10296)
|
||||
- 🐞 修复属性 `value` 的 typescript 类型错误。[#10336](https://github.com/ant-design/ant-design/pull/10336) [@paranoidjk](https://github.com/paranoidjk)
|
||||
- Input
|
||||
- 🐞 修复 `Input.Search` 当 disabled 为 true 时按钮没有被禁用的问题。[#10040](https://github.com/ant-design/ant-design/issues/10040)
|
||||
- 🐞 修复 `Input.Group` 在表单中对齐的问题。[#10281](https://github.com/ant-design/ant-design/issues/10281)
|
||||
- Form
|
||||
- 🐞 修复 `Form.onValuesChange` 的 ts 类型错误。[#10231](https://github.com/ant-design/ant-design/pull/10231) [@whtsky](https://github.com/whtsky)
|
||||
- 🐞 修复 `ComponentDecorator` typescript 定义的错误。[#10324](https://github.com/ant-design/ant-design/pull/10324) [@paranoidjk](https://github.com/paranoidjk)
|
||||
- 🐞 修复 `Divider` 为 dashed 时的样式问题。[#10216](https://github.com/ant-design/ant-design/issues/10216)
|
||||
- 🐞 修复 `Spin` 覆盖层的展示问题。[#10227](https://github.com/ant-design/ant-design/issues/10227)
|
||||
- 🐞 修复 `Notification` 鼠标 hover 是图标的颜色问题。[#10272](https://github.com/ant-design/ant-design/issues/10272)
|
||||
- 🐞 修复 `Upload` 组件属性 `lastModifiedDate` 的拼写错误。[#10315](https://github.com/ant-design/ant-design/pull/10315) [@danielg2002](https://github.com/danielg2002)
|
||||
- 🐞 修复 `Button` 的属性类型,使用 `React.HTMLProps`。[#10229](https://github.com/ant-design/ant-design/pull/10229) [@whtsky](https://github.com/whtsky)
|
||||
- 🐞 修复 less 命名约定不一致的问题。 [#10275](https://github.com/ant-design/ant-design/issues/10275)
|
||||
|
||||
## 3.4.5
|
||||
|
||||
`2018-05-03`
|
||||
|
||||
- 🐞 修复 Upload 上传文件名不展示(file 对象属性为空)的问题。[#10319](https://github.com/ant-design/ant-design/issues/10319)
|
||||
|
||||
## 3.4.4
|
||||
|
||||
`2018-04-28`
|
||||
|
||||
@@ -19,7 +19,7 @@ exports[`renders ./components/auto-complete/demo/basic.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
input here
|
||||
</div>
|
||||
@@ -47,7 +47,7 @@ exports[`renders ./components/auto-complete/demo/basic.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -78,7 +78,7 @@ exports[`renders ./components/auto-complete/demo/certain-category.md correctly 1
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
input here
|
||||
</div>
|
||||
@@ -117,7 +117,7 @@ exports[`renders ./components/auto-complete/demo/certain-category.md correctly 1
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -166,7 +166,7 @@ exports[`renders ./components/auto-complete/demo/custom.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -193,7 +193,7 @@ exports[`renders ./components/auto-complete/demo/non-case-sensitive.md correctly
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
try to type \`b\`
|
||||
</div>
|
||||
@@ -221,7 +221,7 @@ exports[`renders ./components/auto-complete/demo/non-case-sensitive.md correctly
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -248,7 +248,7 @@ exports[`renders ./components/auto-complete/demo/options.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
input here
|
||||
</div>
|
||||
@@ -276,7 +276,7 @@ exports[`renders ./components/auto-complete/demo/options.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -307,7 +307,7 @@ exports[`renders ./components/auto-complete/demo/uncertain-category.md correctly
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
input here
|
||||
</div>
|
||||
@@ -351,7 +351,7 @@ exports[`renders ./components/auto-complete/demo/uncertain-category.md correctly
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
|
||||
@@ -1617,177 +1617,3 @@ exports[`renders ./components/badge/demo/status.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`renders ./components/badge/demo/title.md correctly 1`] = `
|
||||
<div>
|
||||
<span
|
||||
class="ant-badge"
|
||||
>
|
||||
<a
|
||||
class="head-example"
|
||||
href="#"
|
||||
/>
|
||||
<sup
|
||||
class="ant-scroll-number ant-badge-count"
|
||||
data-show="true"
|
||||
title="Custom hover text"
|
||||
>
|
||||
<span
|
||||
class="ant-scroll-number-only"
|
||||
style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)"
|
||||
>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
9
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class="current"
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
9
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class=""
|
||||
>
|
||||
9
|
||||
</p>
|
||||
</span>
|
||||
</sup>
|
||||
</span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -7,14 +7,8 @@ describe('Badge', () => {
|
||||
const badge = mount(<Badge count={10} dot />);
|
||||
expect(badge.find('.ant-card-multiple-words').length).toBe(0);
|
||||
});
|
||||
|
||||
test('badge dot not showing count == 0', () => {
|
||||
const badge = mount(<Badge count={0} dot />);
|
||||
expect(badge.find('.ant-badge-dot').length).toBe(0);
|
||||
});
|
||||
|
||||
it('should have an overriden title attribute', () => {
|
||||
const badge = mount(<Badge count={10} title="Custom title" />);
|
||||
expect(badge.find('.ant-scroll-number').getDOMNode().attributes.getNamedItem('title').value).toEqual('Custom title');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
order: 7
|
||||
title:
|
||||
zh-CN: 自定义标题
|
||||
en-US: Title
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
设置鼠标放在状态点上时显示的文字
|
||||
|
||||
## en-US
|
||||
|
||||
The badge will display `title` when hovered over, instead of `count`.
|
||||
|
||||
````jsx
|
||||
import { Badge } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<Badge count={5} title="Custom hover text">
|
||||
<a href="#" className="head-example" />
|
||||
</Badge>
|
||||
</div>
|
||||
, mountNode);
|
||||
````
|
||||
|
||||
<style>
|
||||
.ant-badge:not(.ant-badge-status) {
|
||||
margin-right: 20px;
|
||||
}
|
||||
.head-example {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
border-radius: 4px;
|
||||
background: #eee;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
@@ -31,4 +31,3 @@ Badge normally appears in proximity to notifications or user avatars with eye-ca
|
||||
| showZero | Whether to show badge when `count` is zero | boolean | `false` |
|
||||
| status | Set Badge as a status dot | `success` \| `processing` \| `default` \| `error` \| `warning` | `''` |
|
||||
| text | If `status` is set, `text` sets the display text of the status `dot` | string | `''` |
|
||||
| title | Text to show when hovering over the badge | string | `count` |
|
||||
|
||||
@@ -21,7 +21,6 @@ export interface BadgeProps {
|
||||
status?: 'success' | 'processing' | 'default' | 'error' | 'warning';
|
||||
text?: string;
|
||||
offset?: [number | string, number | string];
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export default class Badge extends React.Component<BadgeProps, any> {
|
||||
@@ -58,7 +57,6 @@ export default class Badge extends React.Component<BadgeProps, any> {
|
||||
status,
|
||||
text,
|
||||
offset,
|
||||
title,
|
||||
...restProps,
|
||||
} = this.props;
|
||||
let displayCount = (count as number) > (overflowCount as number) ? `${overflowCount}+` : count;
|
||||
@@ -105,7 +103,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
|
||||
data-show={!hidden}
|
||||
className={scrollNumberCls}
|
||||
count={displayCount}
|
||||
title={title || count}
|
||||
title={count}
|
||||
style={styleWithOffset}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -32,4 +32,3 @@ title: Badge
|
||||
| showZero | 当数值为 0 时,是否展示 Badge | boolean | false |
|
||||
| status | 设置 Badge 为状态点 | Enum{ 'success', 'processing, 'default', 'error', 'warning' } | '' |
|
||||
| text | 在设置了 `status` 的前提下有效,设置状态点的文本 | string | '' |
|
||||
| title | 设置鼠标放在状态点上时显示的文字 | string | `count` |
|
||||
|
||||
@@ -41,7 +41,7 @@ function defaultItemRender(route: Route, params: any, routes: Route[], paths: st
|
||||
}
|
||||
|
||||
export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
|
||||
static Item: typeof BreadcrumbItem;
|
||||
static Item: any;
|
||||
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-breadcrumb',
|
||||
|
||||
@@ -66,48 +66,6 @@ exports[`Button renders Chinese characters correctly 3`] = `
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`Button renders Chinese characters correctly 4`] = `
|
||||
<button
|
||||
class="ant-btn"
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
class="anticon anticon-search"
|
||||
/>
|
||||
<span>
|
||||
按钮
|
||||
</span>
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`Button renders Chinese characters correctly 5`] = `
|
||||
<button
|
||||
class="ant-btn ant-btn-loading"
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
class="anticon anticon-spin anticon-loading"
|
||||
/>
|
||||
<span>
|
||||
按钮
|
||||
</span>
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`Button renders Chinese characters correctly 6`] = `
|
||||
<button
|
||||
class="ant-btn ant-btn-loading"
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
class="anticon anticon-spin anticon-loading"
|
||||
/>
|
||||
<span>
|
||||
按 钮
|
||||
</span>
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`Button renders correctly 1`] = `
|
||||
<button
|
||||
class="ant-btn"
|
||||
|
||||
@@ -26,21 +26,6 @@ describe('Button', () => {
|
||||
<Button><Icon type="search" />按钮</Button>
|
||||
);
|
||||
expect(wrapper2).toMatchSnapshot();
|
||||
// should not insert space when there is icon
|
||||
const wrapper3 = render(
|
||||
<Button icon="search">按钮</Button>
|
||||
);
|
||||
expect(wrapper3).toMatchSnapshot();
|
||||
// should not insert space when there is icon while loading
|
||||
const wrapper4 = render(
|
||||
<Button icon="search" loading>按钮</Button>
|
||||
);
|
||||
expect(wrapper4).toMatchSnapshot();
|
||||
// should insert space while loading
|
||||
const wrapper5 = render(
|
||||
<Button loading>按钮</Button>
|
||||
);
|
||||
expect(wrapper5).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders Chinese characters correctly in HOC', () => {
|
||||
|
||||
@@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import omit from 'omit.js';
|
||||
import Icon from '../icon';
|
||||
import { Omit } from '../_util/type';
|
||||
import Group from './button-group';
|
||||
|
||||
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
|
||||
@@ -39,26 +38,29 @@ export type ButtonType = 'default' | 'primary' | 'ghost' | 'dashed' | 'danger';
|
||||
export type ButtonShape = 'circle' | 'circle-outline';
|
||||
export type ButtonSize = 'small' | 'default' | 'large';
|
||||
|
||||
export interface BaseButtonProps<T> extends Omit<React.HTMLProps<T>, 'ref' | 'size'> {
|
||||
export interface ButtonProps {
|
||||
type?: ButtonType;
|
||||
htmlType?: string;
|
||||
icon?: string;
|
||||
shape?: ButtonShape;
|
||||
size?: ButtonSize;
|
||||
onClick?: React.FormEventHandler<any>;
|
||||
onMouseUp?: React.FormEventHandler<any>;
|
||||
onMouseDown?: React.FormEventHandler<any>;
|
||||
onKeyPress?: React.KeyboardEventHandler<any>;
|
||||
onKeyDown?: React.KeyboardEventHandler<any>;
|
||||
tabIndex?: number;
|
||||
loading?: boolean | { delay?: number };
|
||||
disabled?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
ghost?: boolean;
|
||||
target?: string;
|
||||
href?: string;
|
||||
download?: string;
|
||||
}
|
||||
|
||||
export interface AnchorButtonProps extends BaseButtonProps<HTMLAnchorElement> {
|
||||
href: string;
|
||||
}
|
||||
|
||||
export interface NativeButtonProps extends BaseButtonProps<HTMLButtonElement> {}
|
||||
|
||||
export type ButtonProps = AnchorButtonProps | NativeButtonProps;
|
||||
|
||||
export default class Button extends React.Component<ButtonProps, any> {
|
||||
static Group: typeof Group;
|
||||
static __ANT_BUTTON = true;
|
||||
@@ -141,7 +143,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
}
|
||||
}
|
||||
|
||||
handleClick = (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {
|
||||
handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
// Add click effect
|
||||
this.setState({ clicked: true });
|
||||
clearTimeout(this.timeout);
|
||||
@@ -149,13 +151,14 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
|
||||
const onClick = this.props.onClick;
|
||||
if (onClick) {
|
||||
(onClick as (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void)(e);
|
||||
onClick(e);
|
||||
}
|
||||
}
|
||||
|
||||
isNeedInserted() {
|
||||
const { icon, children } = this.props;
|
||||
return React.Children.count(children) === 1 && !icon;
|
||||
const { loading, icon, children } = this.props;
|
||||
const iconType = loading ? 'loading' : icon;
|
||||
return React.Children.count(children) === 1 && (!iconType || iconType === 'loading');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -178,7 +181,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
break;
|
||||
}
|
||||
|
||||
const ComponentProp = (others as AnchorButtonProps).href ? 'a' : 'button';
|
||||
const ComponentProp = others.href ? 'a' : 'button';
|
||||
|
||||
const classes = classNames(prefixCls, className, {
|
||||
[`${prefixCls}-${type}`]: type,
|
||||
@@ -199,7 +202,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
return (
|
||||
<ComponentProp
|
||||
{...omit(others, ['loading'])}
|
||||
type={(others as AnchorButtonProps).href ? undefined : (htmlType || 'button')}
|
||||
type={others.href ? undefined : (htmlType || 'button')}
|
||||
className={classes}
|
||||
onClick={this.handleClick}
|
||||
>
|
||||
|
||||
@@ -21,7 +21,6 @@ To get a customized button, just set `type`/`shape`/`size`/`loading`/`disabled`.
|
||||
| htmlType | set the original html `type` of `button`, see: [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` |
|
||||
| icon | set the icon of button, see: Icon component | string | - |
|
||||
| loading | set the loading status of button | boolean \| { delay: number } | false |
|
||||
| disabled | disabled state of button | boolean | `false` |
|
||||
| shape | can be set to `circle` or omitted | string | - |
|
||||
| size | can be set to `small` `large` or omitted | string | `default` |
|
||||
| target | same as target attribute of a, works when href is specified | string | - |
|
||||
|
||||
@@ -24,7 +24,6 @@ subtitle: 按钮
|
||||
| htmlType | 设置 `button` 原生的 `type` 值,可选值请参考 [HTML 标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` |
|
||||
| icon | 设置按钮的图标类型 | string | - |
|
||||
| loading | 设置按钮载入状态 | boolean \| { delay: number } | `false` |
|
||||
| disabled | 按钮失效状态 | boolean | `false` |
|
||||
| shape | 设置按钮形状,可选值为 `circle` 或者不设 | string | - |
|
||||
| size | 设置按钮大小,可选值为 `small` `large` 或者不设 | string | `default` |
|
||||
| target | 相当于 a 链接的 target 属性,href 存在时生效 | string | - |
|
||||
|
||||
@@ -33,7 +33,7 @@ exports[`renders ./components/calendar/demo/basic.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -65,7 +65,7 @@ exports[`renders ./components/calendar/demo/basic.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -1042,7 +1042,7 @@ exports[`renders ./components/calendar/demo/card.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -1074,7 +1074,7 @@ exports[`renders ./components/calendar/demo/card.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -2049,7 +2049,7 @@ exports[`renders ./components/calendar/demo/notice-calendar.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -2081,7 +2081,7 @@ exports[`renders ./components/calendar/demo/notice-calendar.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -3466,7 +3466,7 @@ exports[`renders ./components/calendar/demo/select.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -3498,7 +3498,7 @@ exports[`renders ./components/calendar/demo/select.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Card should still have padding when card which set padding to 0 is loading 1`] = `
|
||||
<div
|
||||
class="ant-card ant-card-loading ant-card-bordered"
|
||||
>
|
||||
<div
|
||||
class="ant-card-body"
|
||||
style="padding: 0px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-content"
|
||||
style="padding: 24px;"
|
||||
>
|
||||
<div
|
||||
class="ant-row"
|
||||
style="margin-left: -4px; margin-right: -4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-col-22"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-row"
|
||||
style="margin-left: -4px; margin-right: -4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-col-8"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-col-15"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-row"
|
||||
style="margin-left: -4px; margin-right: -4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-col-6"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-col-18"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-row"
|
||||
style="margin-left: -4px; margin-right: -4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-col-13"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-col-9"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-row"
|
||||
style="margin-left: -4px; margin-right: -4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-col-4"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-col-3"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-col-16"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-row"
|
||||
style="margin-left: -4px; margin-right: -4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-col-8"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-col-6"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-col-8"
|
||||
style="padding-left: 4px; padding-right: 4px;"
|
||||
>
|
||||
<div
|
||||
class="ant-card-loading-block"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -34,9 +34,4 @@ describe('Card', () => {
|
||||
wrapper.update();
|
||||
expect(wrapper.find('.ant-card-wider-padding').length).toBe(0);
|
||||
});
|
||||
|
||||
it('should still have padding when card which set padding to 0 is loading', () => {
|
||||
const wrapper = mount(<Card loading bodyStyle={{ padding: 0 }}>xxx</Card>);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ export default class Card extends React.Component<CardProps, CardState> {
|
||||
}
|
||||
render() {
|
||||
const {
|
||||
prefixCls = 'ant-card', className, extra, bodyStyle = {}, noHovering, hoverable, title, loading,
|
||||
prefixCls = 'ant-card', className, extra, bodyStyle, noHovering, hoverable, title, loading,
|
||||
bordered = true, type, cover, actions, tabList, children, activeTabKey, defaultActiveTabKey, ...others,
|
||||
} = this.props;
|
||||
|
||||
@@ -148,14 +148,8 @@ export default class Card extends React.Component<CardProps, CardState> {
|
||||
[`${prefixCls}-type-${type}`]: !!type,
|
||||
});
|
||||
|
||||
const loadingBlockStyle = (bodyStyle.padding === 0 || bodyStyle.padding === '0px')
|
||||
? { padding: 24 } : undefined;
|
||||
|
||||
const loadingBlock = (
|
||||
<div
|
||||
className={`${prefixCls}-loading-content`}
|
||||
style={loadingBlockStyle}
|
||||
>
|
||||
<div className={`${prefixCls}-loading-content`}>
|
||||
<Row gutter={8}>
|
||||
<Col span={22}>
|
||||
<div className={`${prefixCls}-loading-block`} />
|
||||
|
||||
@@ -143,28 +143,6 @@ exports[`renders ./components/cascader/demo/disabled-option.md correctly 1`] = `
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`renders ./components/cascader/demo/fileds-name.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker"
|
||||
tabindex="0"
|
||||
>
|
||||
<span
|
||||
class="ant-cascader-picker-label"
|
||||
/>
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
placeholder="Please select"
|
||||
readonly=""
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow"
|
||||
/>
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`renders ./components/cascader/demo/hover.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker"
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
---
|
||||
order: 10
|
||||
title:
|
||||
zh-CN: 自定义字段名
|
||||
en-US: Custom Filed Names
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
自定义字段名。
|
||||
|
||||
## en-US
|
||||
|
||||
Custom filed names.
|
||||
|
||||
````jsx
|
||||
import { Cascader } from 'antd';
|
||||
|
||||
const options = [{
|
||||
code: 'zhejiang',
|
||||
name: 'Zhejiang',
|
||||
items: [{
|
||||
code: 'hangzhou',
|
||||
name: 'Hangzhou',
|
||||
items: [{
|
||||
code: 'xihu',
|
||||
name: 'West Lake',
|
||||
}],
|
||||
}],
|
||||
}, {
|
||||
code: 'jiangsu',
|
||||
name: 'Jiangsu',
|
||||
items: [{
|
||||
code: 'nanjing',
|
||||
name: 'Nanjing',
|
||||
items: [{
|
||||
code: 'zhonghuamen',
|
||||
name: 'Zhong Hua Men',
|
||||
}],
|
||||
}],
|
||||
}];
|
||||
|
||||
function onChange(value) {
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<Cascader filedNames={{ label: 'name', value: 'code', children: 'items' }} options={options} onChange={onChange} placeholder="Please select" />
|
||||
, mountNode);
|
||||
````
|
||||
@@ -42,7 +42,6 @@ Cascade selection box.
|
||||
| value | selected value | string\[] | - |
|
||||
| onChange | callback when finishing cascader select | `(value, selectedOptions) => void` | - |
|
||||
| onPopupVisibleChange | callback when popup shown or hidden | `(value) => void` | - |
|
||||
| filedNames | custom field name for label and value and children | object | `{ label: 'label', value: 'value', children: 'children' }` |
|
||||
|
||||
Fields in `showSearch`:
|
||||
|
||||
|
||||
@@ -8,37 +8,19 @@ import Input from '../input';
|
||||
import Icon from '../icon';
|
||||
|
||||
export interface CascaderOptionType {
|
||||
value?: string;
|
||||
label?: React.ReactNode;
|
||||
value: string;
|
||||
label: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
children?: Array<CascaderOptionType>;
|
||||
__IS_FILTERED_OPTION?: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface FiledNamesType {
|
||||
value?: string;
|
||||
label?: string;
|
||||
children?: string;
|
||||
}
|
||||
|
||||
export interface FilledFiledNamesType {
|
||||
value: string;
|
||||
label: string;
|
||||
children: string;
|
||||
}
|
||||
|
||||
export type CascaderExpandTrigger = 'click' | 'hover';
|
||||
|
||||
export interface ShowSearchType {
|
||||
filter?: (inputValue: string, path: CascaderOptionType[], names: FilledFiledNamesType) => boolean;
|
||||
render?: (
|
||||
inputValue: string,
|
||||
path: CascaderOptionType[],
|
||||
prefixCls: string | undefined,
|
||||
names: FilledFiledNamesType,
|
||||
) => React.ReactNode;
|
||||
sort?: (a: CascaderOptionType[], b: CascaderOptionType[], inputValue: string, names: FilledFiledNamesType) => number;
|
||||
filter?: (inputValue: string, path: CascaderOptionType[]) => boolean;
|
||||
render?: (inputValue: string, path: CascaderOptionType[], prefixCls: string | undefined) => React.ReactNode;
|
||||
sort?: (a: CascaderOptionType[], b: CascaderOptionType[], inputValue: string) => number;
|
||||
matchInputWidth?: boolean;
|
||||
}
|
||||
|
||||
@@ -82,7 +64,6 @@ export interface CascaderProps {
|
||||
inputPrefixCls?: string;
|
||||
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
|
||||
popupVisible?: boolean;
|
||||
filedNames?: FiledNamesType;
|
||||
}
|
||||
|
||||
export interface CascaderState {
|
||||
@@ -101,41 +82,26 @@ function highlightKeyword(str: string, keyword: string, prefixCls: string | unde
|
||||
]);
|
||||
}
|
||||
|
||||
function defaultFilterOption(inputValue: string, path: CascaderOptionType[], names: FilledFiledNamesType) {
|
||||
return path.some(option => (option[names.label] as string).indexOf(inputValue) > -1);
|
||||
function defaultFilterOption(inputValue: string, path: CascaderOptionType[]) {
|
||||
return path.some(option => (option.label as string).indexOf(inputValue) > -1);
|
||||
}
|
||||
|
||||
function defaultRenderFilteredOption(
|
||||
inputValue: string,
|
||||
path: CascaderOptionType[],
|
||||
prefixCls: string | undefined,
|
||||
names: FilledFiledNamesType,
|
||||
) {
|
||||
return path.map((option, index) => {
|
||||
const label = option[names.label];
|
||||
function defaultRenderFilteredOption(inputValue: string, path: CascaderOptionType[], prefixCls: string | undefined) {
|
||||
return path.map(({ label }, index) => {
|
||||
const node = (label as string).indexOf(inputValue) > -1 ?
|
||||
highlightKeyword(label as string, inputValue, prefixCls) : label;
|
||||
return index === 0 ? node : [' / ', node];
|
||||
});
|
||||
}
|
||||
|
||||
function defaultSortFilteredOption(a: any[], b: any[], inputValue: string, names: FilledFiledNamesType) {
|
||||
function defaultSortFilteredOption(a: any[], b: any[], inputValue: string) {
|
||||
function callback(elem: CascaderOptionType) {
|
||||
return (elem[names.label] as string).indexOf(inputValue) > -1;
|
||||
return (elem.label as string).indexOf(inputValue) > -1;
|
||||
}
|
||||
|
||||
return a.findIndex(callback) - b.findIndex(callback);
|
||||
}
|
||||
|
||||
function getFilledFieldNames(filedNames: FiledNamesType = {}) {
|
||||
const names: FilledFiledNamesType = {
|
||||
children: filedNames.children || 'children',
|
||||
label: filedNames.label || 'label',
|
||||
value: filedNames.value || 'value',
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
const defaultDisplayRender = (label: string[]) => label.join(' / ');
|
||||
|
||||
export default class Cascader extends React.Component<CascaderProps, CascaderState> {
|
||||
@@ -162,7 +128,7 @@ export default class Cascader extends React.Component<CascaderProps, CascaderSta
|
||||
inputValue: '',
|
||||
inputFocused: false,
|
||||
popupVisible: props.popupVisible,
|
||||
flattenOptions: props.showSearch && this.flattenTree(props.options, props.changeOnSelect, props.filedNames),
|
||||
flattenOptions: props.showSearch && this.flattenTree(props.options, props.changeOnSelect),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -174,9 +140,7 @@ export default class Cascader extends React.Component<CascaderProps, CascaderSta
|
||||
this.setState({ popupVisible: nextProps.popupVisible });
|
||||
}
|
||||
if (nextProps.showSearch && this.props.options !== nextProps.options) {
|
||||
this.setState({
|
||||
flattenOptions: this.flattenTree(nextProps.options, nextProps.changeOnSelect, nextProps.filedNames),
|
||||
});
|
||||
this.setState({ flattenOptions: this.flattenTree(nextProps.options, nextProps.changeOnSelect) });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,14 +207,13 @@ export default class Cascader extends React.Component<CascaderProps, CascaderSta
|
||||
}
|
||||
|
||||
getLabel() {
|
||||
const { options, displayRender = defaultDisplayRender as Function, filedNames } = this.props;
|
||||
const names = getFilledFieldNames(filedNames);
|
||||
const { options, displayRender = defaultDisplayRender as Function } = this.props;
|
||||
const value = this.state.value;
|
||||
const unwrappedValue = Array.isArray(value[0]) ? value[0] : value;
|
||||
const selectedOptions: CascaderOptionType[] = arrayTreeFilter(options,
|
||||
(o: CascaderOptionType, level: number) => o[names.value] === unwrappedValue[level],
|
||||
(o: CascaderOptionType, level: number) => o.value === unwrappedValue[level],
|
||||
);
|
||||
const label = selectedOptions.map(o => o[names.label]);
|
||||
const label = selectedOptions.map(o => o.label);
|
||||
return displayRender(label, selectedOptions);
|
||||
}
|
||||
|
||||
@@ -265,58 +228,43 @@ export default class Cascader extends React.Component<CascaderProps, CascaderSta
|
||||
}
|
||||
}
|
||||
|
||||
flattenTree(
|
||||
options: CascaderOptionType[],
|
||||
changeOnSelect: boolean | undefined,
|
||||
filedNames: FiledNamesType | undefined,
|
||||
ancestor: CascaderOptionType[] = [],
|
||||
) {
|
||||
const names: FiledNamesType = getFilledFieldNames(filedNames);
|
||||
flattenTree(options: CascaderOptionType[], changeOnSelect: boolean | undefined, ancestor: CascaderOptionType[] = []) {
|
||||
let flattenOptions: any = [];
|
||||
let childrenName: any = names.children;
|
||||
options.forEach((option) => {
|
||||
const path = ancestor.concat(option);
|
||||
if (changeOnSelect || !option[childrenName] || !option[childrenName].length) {
|
||||
if (changeOnSelect || !option.children || !option.children.length) {
|
||||
flattenOptions.push(path);
|
||||
}
|
||||
if (option[childrenName]) {
|
||||
flattenOptions = flattenOptions.concat(
|
||||
this.flattenTree(
|
||||
option[childrenName],
|
||||
changeOnSelect,
|
||||
filedNames,
|
||||
path,
|
||||
),
|
||||
);
|
||||
if (option.children) {
|
||||
flattenOptions = flattenOptions.concat(this.flattenTree(option.children, changeOnSelect, path));
|
||||
}
|
||||
});
|
||||
return flattenOptions;
|
||||
}
|
||||
|
||||
generateFilteredOptions(prefixCls: string | undefined) {
|
||||
const { showSearch, notFoundContent, filedNames } = this.props;
|
||||
const names: FilledFiledNamesType = getFilledFieldNames(filedNames);
|
||||
const { showSearch, notFoundContent } = this.props;
|
||||
const {
|
||||
filter = defaultFilterOption,
|
||||
render = defaultRenderFilteredOption,
|
||||
sort = defaultSortFilteredOption,
|
||||
} = showSearch as ShowSearchType;
|
||||
const { flattenOptions, inputValue } = this.state;
|
||||
const filtered = flattenOptions.filter((path) => filter(this.state.inputValue, path, names))
|
||||
.sort((a, b) => sort(a, b, inputValue, names));
|
||||
const filtered = flattenOptions.filter((path) => filter(this.state.inputValue, path))
|
||||
.sort((a, b) => sort(a, b, inputValue));
|
||||
|
||||
if (filtered.length > 0) {
|
||||
return filtered.map((path: any) => {
|
||||
return {
|
||||
__IS_FILTERED_OPTION: true,
|
||||
path,
|
||||
[names.label]: render(inputValue, path, prefixCls, names),
|
||||
[names.value]: path.map((o: CascaderOptionType) => o[names.value]),
|
||||
label: render(inputValue, path, prefixCls),
|
||||
value: path.map((o: CascaderOptionType) => o.value),
|
||||
disabled: path.some((o: CascaderOptionType) => o.disabled),
|
||||
} as CascaderOptionType;
|
||||
});
|
||||
}
|
||||
return [{ [names.label]: notFoundContent, [names.value]: 'ANT_CASCADER_NOT_FOUND', disabled: true }];
|
||||
return [{ label: notFoundContent, value: 'ANT_CASCADER_NOT_FOUND', disabled: true }];
|
||||
}
|
||||
|
||||
focus() {
|
||||
@@ -380,7 +328,6 @@ export default class Cascader extends React.Component<CascaderProps, CascaderSta
|
||||
'renderFilteredOption',
|
||||
'sortFilteredOption',
|
||||
'notFoundContent',
|
||||
'filedNames',
|
||||
]);
|
||||
|
||||
let options = props.options;
|
||||
|
||||
@@ -43,7 +43,6 @@ subtitle: 级联选择
|
||||
| value | 指定选中项 | string\[] | - |
|
||||
| onChange | 选择完成后的回调 | `(value, selectedOptions) => void` | - |
|
||||
| onPopupVisibleChange | 显示/隐藏浮层的回调 | `(value) => void` | - |
|
||||
| filedNames | 自定义 options 中 label name children 的字段 | object | `{ label: 'label', value: 'value', children: 'children' }` |
|
||||
|
||||
`showSearch` 为对象时,其中的字段:
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
display: block;
|
||||
position: static;
|
||||
}
|
||||
|
||||
&-picker {
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface CheckboxChangeEvent {
|
||||
target: CheckboxChangeEventTarget;
|
||||
stopPropagation: () => void;
|
||||
preventDefault: () => void;
|
||||
nativeEvent: Event;
|
||||
nativeEvent: MouseEvent;
|
||||
}
|
||||
|
||||
export default class Checkbox extends React.Component<CheckboxProps, {}> {
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
&-input {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
top: 0;
|
||||
|
||||
@@ -3,16 +3,15 @@
|
||||
exports[`renders ./components/collapse/demo/accordion.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-collapse"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -22,12 +21,12 @@ exports[`renders ./components/collapse/demo/accordion.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -37,12 +36,12 @@ exports[`renders ./components/collapse/demo/accordion.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -59,12 +58,12 @@ exports[`renders ./components/collapse/demo/basic.md correctly 1`] = `
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-item ant-collapse-item-active"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -73,6 +72,7 @@ exports[`renders ./components/collapse/demo/basic.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-content ant-collapse-content-active"
|
||||
role="tabpanel"
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-content-box"
|
||||
@@ -89,12 +89,12 @@ exports[`renders ./components/collapse/demo/basic.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -104,12 +104,12 @@ exports[`renders ./components/collapse/demo/basic.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item ant-collapse-item-disabled"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -126,12 +126,12 @@ exports[`renders ./components/collapse/demo/borderless.md correctly 1`] = `
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-item ant-collapse-item-active"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -140,6 +140,7 @@ exports[`renders ./components/collapse/demo/borderless.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-content ant-collapse-content-active"
|
||||
role="tabpanel"
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-content-box"
|
||||
@@ -154,12 +155,12 @@ exports[`renders ./components/collapse/demo/borderless.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -169,12 +170,12 @@ exports[`renders ./components/collapse/demo/borderless.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -191,13 +192,13 @@ exports[`renders ./components/collapse/demo/custom.md correctly 1`] = `
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-item ant-collapse-item-active"
|
||||
role="tablist"
|
||||
style="background:#f7f7f7;border-radius:4px;margin-bottom:24px;border:0;overflow:hidden"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -206,6 +207,7 @@ exports[`renders ./components/collapse/demo/custom.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-content ant-collapse-content-active"
|
||||
role="tabpanel"
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-content-box"
|
||||
@@ -222,13 +224,13 @@ exports[`renders ./components/collapse/demo/custom.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
style="background:#f7f7f7;border-radius:4px;margin-bottom:24px;border:0;overflow:hidden"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -238,13 +240,13 @@ exports[`renders ./components/collapse/demo/custom.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
style="background:#f7f7f7;border-radius:4px;margin-bottom:24px;border:0;overflow:hidden"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -261,12 +263,12 @@ exports[`renders ./components/collapse/demo/mix.md correctly 1`] = `
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -276,12 +278,12 @@ exports[`renders ./components/collapse/demo/mix.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -291,12 +293,12 @@ exports[`renders ./components/collapse/demo/mix.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -313,12 +315,12 @@ exports[`renders ./components/collapse/demo/noarrow.md correctly 1`] = `
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-item ant-collapse-item-active"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
<i
|
||||
class="arrow"
|
||||
@@ -327,6 +329,7 @@ exports[`renders ./components/collapse/demo/noarrow.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-content ant-collapse-content-active"
|
||||
role="tabpanel"
|
||||
>
|
||||
<div
|
||||
class="ant-collapse-content-box"
|
||||
@@ -343,12 +346,12 @@ exports[`renders ./components/collapse/demo/noarrow.md correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse-item ant-collapse-no-arrow"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
class="ant-collapse-header"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
role="tab"
|
||||
>
|
||||
This is panel header with no arrow icon
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
@collapse-prefix-cls: ~"@{ant-prefix}-collapse";
|
||||
|
||||
@collapse-header-bg: @background-color-light;
|
||||
@collapse-active-bg: @background-color-base;
|
||||
|
||||
.collapse-close() {
|
||||
transform: rotate(0);
|
||||
}
|
||||
@@ -29,7 +32,7 @@
|
||||
|
||||
> .@{collapse-prefix-cls}-header {
|
||||
line-height: 22px;
|
||||
padding: @collapse-header-padding;
|
||||
padding: 12px 0 12px 40px;
|
||||
color: @heading-color;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
@@ -50,10 +53,6 @@
|
||||
content: "\E61F";
|
||||
}
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.@{collapse-prefix-cls}-no-arrow {
|
||||
@@ -70,11 +69,13 @@
|
||||
&-content {
|
||||
overflow: hidden;
|
||||
color: @text-color;
|
||||
background-color: @collapse-content-bg;
|
||||
padding: 0 @padding-md;
|
||||
background-color: @component-background;
|
||||
border-top: @border-width-base @border-style-base @border-color-base;
|
||||
|
||||
& > &-box {
|
||||
padding: @collapse-content-padding;
|
||||
padding-top: @padding-md;
|
||||
padding-bottom: @padding-md;
|
||||
}
|
||||
|
||||
&-inactive {
|
||||
|
||||
@@ -51,8 +51,6 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker, WeekPicke
|
||||
| size | determine the size of the input box, the height of `large` and `small`, are 40px and 24px respectively, while default size is 32px | string | - |
|
||||
| style | to customize the style of the input box | object | {} |
|
||||
| onOpenChange | a callback function, can be executed whether the popup calendar is popped up or closed | function(status) | - |
|
||||
| mode | picker panel mode | `time|date|month|year` | 'date' |
|
||||
| onPanelChange | callback when picker panel mode is changed | function(value, mode) | - |
|
||||
|
||||
### Common Methods
|
||||
|
||||
|
||||
@@ -74,8 +74,6 @@ subtitle: 日期选择框
|
||||
| value | 日期 | [moment](http://momentjs.com/) | 无 |
|
||||
| onChange | 时间发生变化的回调 | function(date: moment, dateString: string) | 无 |
|
||||
| onOk | 点击确定按钮的回调 | function() | - |
|
||||
| mode | 日期面板的状态 | `time|date|month|year` | 'date' |
|
||||
| onPanelChange | 日期面板变化时的回调 | function(value, mode) | - |
|
||||
|
||||
### MonthPicker
|
||||
|
||||
|
||||
@@ -120,9 +120,7 @@
|
||||
background: none;
|
||||
border-top: 1px dashed @border-color-split;
|
||||
}
|
||||
&-horizontal&-with-text&-dashed,
|
||||
&-horizontal&-with-text-left&-dashed,
|
||||
&-horizontal&-with-text-right&-dashed {
|
||||
&-horizontal&-with-text&-dashed {
|
||||
border-top: 0;
|
||||
&:before,
|
||||
&:after {
|
||||
|
||||
@@ -35,11 +35,11 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
class="ant-btn ant-dropdown-trigger ant-btn-default ant-btn-icon-only"
|
||||
class="ant-btn ant-dropdown-trigger ant-btn-default"
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
class="anticon anticon-ellipsis"
|
||||
class="anticon anticon-down"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
@@ -57,12 +57,12 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
class="ant-btn ant-dropdown-trigger ant-btn-default ant-btn-icon-only"
|
||||
class="ant-btn ant-dropdown-trigger ant-btn-default"
|
||||
disabled=""
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
class="anticon anticon-ellipsis"
|
||||
class="anticon anticon-down"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import Button from '../button';
|
||||
import { ButtonGroupProps } from '../button/button-group';
|
||||
import Icon from '../icon';
|
||||
import Dropdown, { DropDownProps } from './dropdown';
|
||||
import classNames from 'classnames';
|
||||
const ButtonGroup = Button.Group;
|
||||
@@ -8,7 +9,7 @@ const ButtonGroup = Button.Group;
|
||||
export interface DropdownButtonProps extends ButtonGroupProps, DropDownProps {
|
||||
type?: 'primary' | 'ghost' | 'dashed';
|
||||
disabled?: boolean;
|
||||
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
||||
onClick?: React.MouseEventHandler<any>;
|
||||
children?: any;
|
||||
}
|
||||
|
||||
@@ -53,7 +54,9 @@ export default class DropdownButton extends React.Component<DropdownButtonProps,
|
||||
{children}
|
||||
</Button>
|
||||
<Dropdown {...dropdownProps}>
|
||||
<Button type={type} icon="ellipsis" />
|
||||
<Button type={type}>
|
||||
<Icon type="down" />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
</ButtonGroup>
|
||||
);
|
||||
|
||||
@@ -59,12 +59,10 @@ export default class Dropdown extends React.Component<DropDownProps, any> {
|
||||
disabled,
|
||||
});
|
||||
// menu cannot be selectable in dropdown defaultly
|
||||
// menu should be focusable in dropdown defaultly
|
||||
const { selectable = false, focusable = true } = overlay.props;
|
||||
const selectable = overlay.props.selectable || false;
|
||||
const fixedModeOverlay = React.cloneElement(overlay, {
|
||||
mode: 'vertical',
|
||||
selectable,
|
||||
focusable,
|
||||
});
|
||||
return (
|
||||
<RcDropdown
|
||||
|
||||
@@ -208,9 +208,6 @@
|
||||
.@{iconfont-css-prefix}-down {
|
||||
.iconfont-size-under-12px(10px);
|
||||
}
|
||||
.@{iconfont-css-prefix}-ellipsis {
|
||||
text-shadow: 0 0 currentColor;
|
||||
}
|
||||
}
|
||||
|
||||
.@{dropdown-prefix-cls}-button {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Omit } from '../_util/type';
|
||||
|
||||
export interface FormCreateOption<T> {
|
||||
onFieldsChange?: (props: T, fields: Array<any>) => void;
|
||||
onValuesChange?: (props: T, changedValues: any, allValues: any) => void;
|
||||
onValuesChange?: (props: T, values: any) => void;
|
||||
mapPropsToFields?: (props: T) => void;
|
||||
withRef?: boolean;
|
||||
}
|
||||
@@ -115,14 +115,10 @@ export interface FormComponentProps {
|
||||
form: WrappedFormUtils;
|
||||
}
|
||||
|
||||
export interface RcBaseFormProps {
|
||||
wrappedComponentRef?: any;
|
||||
}
|
||||
|
||||
export interface ComponentDecorator {
|
||||
<P extends FormComponentProps>(
|
||||
component: React.ComponentClass<P> | React.SFC<P>,
|
||||
): React.ComponentClass<RcBaseFormProps & Omit<P, keyof FormComponentProps>>;
|
||||
): React.ComponentClass<Omit<P, keyof FormComponentProps>>;
|
||||
}
|
||||
|
||||
export default class Form extends React.Component<FormProps, any> {
|
||||
|
||||
@@ -55,7 +55,7 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
|
||||
context: FormItemContext;
|
||||
|
||||
helpShow = false;
|
||||
state = { helpShow: false };
|
||||
|
||||
componentDidMount() {
|
||||
warning(
|
||||
@@ -124,10 +124,7 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
}
|
||||
|
||||
onHelpAnimEnd = (_key: string, helpShow: boolean) => {
|
||||
this.helpShow = helpShow;
|
||||
if (!helpShow) {
|
||||
this.setState({});
|
||||
}
|
||||
this.setState({ helpShow });
|
||||
}
|
||||
|
||||
renderHelp() {
|
||||
@@ -138,9 +135,6 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
{help}
|
||||
</div>
|
||||
) : null;
|
||||
if (children) {
|
||||
this.helpShow = !!children;
|
||||
}
|
||||
return (
|
||||
<Animate
|
||||
transitionName="show-help"
|
||||
@@ -312,10 +306,11 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
const style = props.style;
|
||||
const itemClassName = {
|
||||
[`${prefixCls}-item`]: true,
|
||||
[`${prefixCls}-item-with-help`]: this.helpShow,
|
||||
[`${prefixCls}-item-with-help`]: !!this.getHelpMsg() || this.state.helpShow,
|
||||
[`${prefixCls}-item-no-colon`]: !props.colon,
|
||||
[`${props.className}`]: !!props.className,
|
||||
};
|
||||
|
||||
return (
|
||||
<Row className={classNames(itemClassName)} style={style}>
|
||||
{children}
|
||||
|
||||
@@ -543,7 +543,7 @@ exports[`renders ./components/form/demo/coordinated.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Select a option and change input text above
|
||||
</div>
|
||||
@@ -551,7 +551,7 @@ exports[`renders ./components/form/demo/coordinated.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -649,7 +649,7 @@ exports[`renders ./components/form/demo/customized-form-controls.md correctly 1`
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -1637,7 +1637,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -1698,7 +1698,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
website
|
||||
</div>
|
||||
@@ -1726,7 +1726,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -2263,7 +2263,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Please select a country
|
||||
</div>
|
||||
@@ -2271,7 +2271,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -2321,7 +2321,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Please select favourite colors
|
||||
</div>
|
||||
@@ -3340,7 +3340,7 @@ exports[`renders ./components/form/demo/validate-static.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
|
||||
@@ -56,7 +56,7 @@ The following `options` are available:
|
||||
| mapPropsToFields | Convert props to field value(e.g. reading the values from Redux store). And you must mark returned fields with [`Form.createFormField`](#Form.createFormField) | (props) => Object{ fieldName: FormField { value } } |
|
||||
| validateMessages | Default validate message. And its format is similar with [newMessages](https://github.com/yiminghe/async-validator/blob/master/src/messages.js)'s returned value | Object { [nested.path]: String } |
|
||||
| onFieldsChange | Specify a function that will be called when the value a `Form.Item` gets changed. Usage example: saving the field's value to Redux store. | Function(props, fields) |
|
||||
| onValuesChange | A handler while value of any field is changed | (props, changedValues, allValues) => void |
|
||||
| onValuesChange | A handler while value of any field is changed | (props, values) => void |
|
||||
|
||||
If the form has been decorated by `Form.create` then it has `this.props.form` property. `this.props.form` provides some APIs as follows:
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ CustomizedForm = Form.create({})(CustomizedForm);
|
||||
| mapPropsToFields | 把父组件的属性映射到表单项上(如:把 Redux store 中的值读出),需要对返回值中的表单域数据用 [`Form.createFormField`](#Form.createFormField) 标记 | (props) => Object{ fieldName: FormField { value } } |
|
||||
| validateMessages | 默认校验信息,可用于把默认错误信息改为中文等,格式与 [newMessages](https://github.com/yiminghe/async-validator/blob/master/src/messages.js) 返回值一致 | Object { [nested.path]: String } |
|
||||
| onFieldsChange | 当 `Form.Item` 子节点的值发生改变时触发,可以把对应的值转存到 Redux store | Function(props, fields) |
|
||||
| onValuesChange | 任一表单域的值发生改变时的回调 | (props, changedValues, allValues) => void |
|
||||
| onValuesChange | 任一表单域的值发生改变时的回调 | (props, values) => void |
|
||||
|
||||
经过 `Form.create` 包装的组件将会自带 `this.props.form` 属性,`this.props.form` 提供的 API 如下:
|
||||
|
||||
|
||||
@@ -132,9 +132,8 @@ input[type="checkbox"] {
|
||||
.@{form-prefix-cls}-extra {
|
||||
color: @text-color-secondary;
|
||||
line-height: @line-height-base;
|
||||
transition: color .3s @ease-out; // sync input color transition
|
||||
transition: color .15s @ease-out;
|
||||
margin-top: @form-help-margin-top;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.@{form-prefix-cls}-extra {
|
||||
@@ -252,9 +251,7 @@ form {
|
||||
}
|
||||
|
||||
// fix input with addon position. https://github.com/ant-design/ant-design/issues/8243
|
||||
:not(.@{ant-prefix}-input-group-wrapper) > .@{ant-prefix}-input-group,
|
||||
.@{ant-prefix}-input-group-wrapper {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
@@ -577,7 +574,7 @@ form {
|
||||
}
|
||||
}
|
||||
|
||||
.show-help-motion(show-help, antShowHelp, 0.3s);
|
||||
.show-help-motion(show-help, antShowHelp, 0.15s);
|
||||
|
||||
@keyframes antShowHelpIn {
|
||||
0% {
|
||||
|
||||
@@ -40,7 +40,7 @@ export default class Search extends React.Component<SearchProps, any> {
|
||||
}
|
||||
|
||||
getButtonOrIcon() {
|
||||
const { enterButton, prefixCls, size, disabled } = this.props;
|
||||
const { enterButton, prefixCls, size } = this.props;
|
||||
if (!enterButton) {
|
||||
return <Icon className={`${prefixCls}-icon`} type="search" key="searchIcon" />;
|
||||
}
|
||||
@@ -59,7 +59,6 @@ export default class Search extends React.Component<SearchProps, any> {
|
||||
className={`${prefixCls}-button`}
|
||||
type="primary"
|
||||
size={size}
|
||||
disabled={disabled}
|
||||
onClick={this.onSearch}
|
||||
key="enterButton"
|
||||
>
|
||||
|
||||
@@ -20,11 +20,4 @@ describe('Input.Search', () => {
|
||||
);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should disable enter button when disabled prop is true', () => {
|
||||
const wrapper = mount(
|
||||
<Search placeholder="input search text" enterButton disabled />
|
||||
);
|
||||
expect(wrapper.find('.ant-btn-primary[disabled]')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ exports[`renders ./components/input/demo/addon.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -110,7 +110,7 @@ exports[`renders ./components/input/demo/addon.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -242,7 +242,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -285,7 +285,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -399,7 +399,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -431,7 +431,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -468,7 +468,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -524,7 +524,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -548,7 +548,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Email
|
||||
</div>
|
||||
@@ -576,7 +576,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -614,7 +614,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
|
||||
@@ -311,12 +311,12 @@
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
|
||||
&:hover .@{inputClass}:not(.@{inputClass}-disabled) {
|
||||
.hover();
|
||||
.@{inputClass} {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.@{inputClass} {
|
||||
position: static;
|
||||
&:hover .@{inputClass}:not(.@{inputClass}-disabled) {
|
||||
.hover();
|
||||
}
|
||||
|
||||
.@{inputClass}-prefix,
|
||||
@@ -324,6 +324,7 @@
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 2;
|
||||
line-height: 0;
|
||||
color: @input-color;
|
||||
:not(.anticon) {
|
||||
|
||||
@@ -180,11 +180,9 @@ export default class Sider extends React.Component<SiderProps, SiderState> {
|
||||
} = this.props;
|
||||
const divProps = omit(others, ['collapsed',
|
||||
'defaultCollapsed', 'onCollapse', 'breakpoint']);
|
||||
const rawWidth = this.state.collapsed ? collapsedWidth : width;
|
||||
// use "px" as fallback unit for width
|
||||
const siderWidth = typeof rawWidth === 'number' ? `${rawWidth}px` : String(rawWidth || 0);
|
||||
const siderWidth = this.state.collapsed ? collapsedWidth : width;
|
||||
// special trigger when collapsedWidth == 0
|
||||
const zeroWidthTrigger = parseFloat(String(collapsedWidth || 0)) === 0 ? (
|
||||
const zeroWidthTrigger = collapsedWidth === 0 || collapsedWidth === '0' || collapsedWidth === '0px' ? (
|
||||
<span onClick={this.toggle} className={`${prefixCls}-zero-width-trigger`}>
|
||||
<Icon type="bars" />
|
||||
</span>
|
||||
@@ -203,18 +201,21 @@ export default class Sider extends React.Component<SiderProps, SiderState> {
|
||||
</div>
|
||||
) : null
|
||||
);
|
||||
// For collapsedWidth="40px"
|
||||
// https://github.com/ant-design/ant-design/issues/10140
|
||||
const siderWidthNumber = (siderWidth || 0).toString().replace(/px$/, '');
|
||||
const divStyle = {
|
||||
...style,
|
||||
flex: `0 0 ${siderWidth}`,
|
||||
maxWidth: siderWidth, // Fix width transition bug in IE11
|
||||
minWidth: siderWidth, // https://github.com/ant-design/ant-design/issues/6349
|
||||
width: siderWidth,
|
||||
flex: `0 0 ${siderWidthNumber}px`,
|
||||
maxWidth: `${siderWidthNumber}px`, // Fix width transition bug in IE11
|
||||
minWidth: `${siderWidthNumber}px`, // https://github.com/ant-design/ant-design/issues/6349
|
||||
width: `${siderWidthNumber}px`,
|
||||
};
|
||||
const siderCls = classNames(className, prefixCls, {
|
||||
[`${prefixCls}-collapsed`]: !!this.state.collapsed,
|
||||
[`${prefixCls}-has-trigger`]: collapsible && trigger !== null && !zeroWidthTrigger,
|
||||
[`${prefixCls}-below`]: !!this.state.below,
|
||||
[`${prefixCls}-zero-width`]: parseFloat(siderWidth) === 0,
|
||||
[`${prefixCls}-zero-width`]: siderWidth === 0 || siderWidth === '0' || siderWidth === '0px',
|
||||
});
|
||||
return (
|
||||
<div className={siderCls} {...divProps} style={divStyle}>
|
||||
|
||||
@@ -138,10 +138,13 @@ exports[`renders ./components/layout/demo/custom-trigger.md correctly 1`] = `
|
||||
class="logo"
|
||||
/>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -154,6 +157,7 @@ exports[`renders ./components/layout/demo/custom-trigger.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -166,6 +170,7 @@ exports[`renders ./components/layout/demo/custom-trigger.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -213,23 +218,28 @@ exports[`renders ./components/layout/demo/fixed.md correctly 1`] = `
|
||||
class="logo"
|
||||
/>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-horizontal"
|
||||
role="menu"
|
||||
style="line-height:64px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
nav 1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
nav 2
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -312,10 +322,13 @@ exports[`renders ./components/layout/demo/fixed-sider.md correctly 1`] = `
|
||||
class="logo"
|
||||
/>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -330,6 +343,7 @@ exports[`renders ./components/layout/demo/fixed-sider.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -344,6 +358,7 @@ exports[`renders ./components/layout/demo/fixed-sider.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -358,6 +373,7 @@ exports[`renders ./components/layout/demo/fixed-sider.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -372,6 +388,7 @@ exports[`renders ./components/layout/demo/fixed-sider.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -386,6 +403,7 @@ exports[`renders ./components/layout/demo/fixed-sider.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -400,6 +418,7 @@ exports[`renders ./components/layout/demo/fixed-sider.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -414,6 +433,7 @@ exports[`renders ./components/layout/demo/fixed-sider.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -567,10 +587,13 @@ exports[`renders ./components/layout/demo/responsive.md correctly 1`] = `
|
||||
class="logo"
|
||||
/>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -585,6 +608,7 @@ exports[`renders ./components/layout/demo/responsive.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -599,6 +623,7 @@ exports[`renders ./components/layout/demo/responsive.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -613,6 +638,7 @@ exports[`renders ./components/layout/demo/responsive.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -672,10 +698,13 @@ exports[`renders ./components/layout/demo/side.md correctly 1`] = `
|
||||
class="logo"
|
||||
/>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -688,6 +717,7 @@ exports[`renders ./components/layout/demo/side.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -701,11 +731,11 @@ exports[`renders ./components/layout/demo/side.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub1$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -721,15 +751,14 @@ exports[`renders ./components/layout/demo/side.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -745,9 +774,9 @@ exports[`renders ./components/layout/demo/side.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -837,23 +866,28 @@ exports[`renders ./components/layout/demo/top.md correctly 1`] = `
|
||||
class="logo"
|
||||
/>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-horizontal"
|
||||
role="menu"
|
||||
style="line-height:64px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
nav 1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
nav 2
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -932,23 +966,28 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
class="logo"
|
||||
/>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-horizontal"
|
||||
role="menu"
|
||||
style="line-height:64px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
nav 1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
nav 2
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -1013,13 +1052,14 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
class="ant-layout-sider-children"
|
||||
>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-light ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
style="height:100%"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline ant-menu-submenu-open ant-menu-submenu-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
@@ -1039,11 +1079,13 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-sub ant-menu-inline"
|
||||
id="sub1$Menu"
|
||||
role="menu"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -1051,6 +1093,7 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
option1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -1058,6 +1101,7 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
option2
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -1065,6 +1109,7 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
option3
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -1075,11 +1120,11 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -1093,15 +1138,14 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub3$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -1115,7 +1159,6 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1148,23 +1191,28 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
class="logo"
|
||||
/>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-horizontal"
|
||||
role="menu"
|
||||
style="line-height:64px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
nav 1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
nav 2
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -1183,13 +1231,14 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
class="ant-layout-sider-children"
|
||||
>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-light ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
style="height:100%;border-right:0"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline ant-menu-submenu-open ant-menu-submenu-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
@@ -1209,11 +1258,13 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-sub ant-menu-inline"
|
||||
id="sub1$Menu"
|
||||
role="menu"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -1221,6 +1272,7 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
option1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -1228,6 +1280,7 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
option2
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -1235,6 +1288,7 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
option3
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -1245,11 +1299,11 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -1263,15 +1317,14 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub3$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -1285,7 +1338,6 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -34,25 +34,4 @@ describe('Layout', () => {
|
||||
);
|
||||
expect(wrapper.find('.ant-layout-sider').hasClass('ant-layout-sider-has-trigger')).toBe(true);
|
||||
});
|
||||
|
||||
it('should have 50% width of sidebar', async () => {
|
||||
const wrapper = mount(
|
||||
<Layout>
|
||||
<div><Sider width="50%">Sider</Sider></div>
|
||||
<Content>Content</Content>
|
||||
</Layout>
|
||||
);
|
||||
expect(wrapper.find('.ant-layout-sider').at(0).prop('style').width).toBe('50%');
|
||||
expect(wrapper.find('.ant-layout-sider').at(0).prop('style').flex).toBe('0 0 50%');
|
||||
});
|
||||
|
||||
it('detect ant-layout-sider-zero-width class in sider when its width is 0%', async () => {
|
||||
const wrapper = mount(
|
||||
<Layout>
|
||||
<div><Sider width="0%">Sider</Sider></div>
|
||||
<Content>Content</Content>
|
||||
</Layout>
|
||||
);
|
||||
expect(wrapper.find('.ant-layout-sider').hasClass('ant-layout-sider-zero-width')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1168,6 +1168,198 @@ exports[`renders ./components/list/demo/vertical.md correctly 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-extra-wrap"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-main"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-meta"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-meta-avatar"
|
||||
>
|
||||
<span
|
||||
class="ant-avatar ant-avatar-circle ant-avatar-image"
|
||||
>
|
||||
<img
|
||||
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item-meta-content"
|
||||
>
|
||||
<h4
|
||||
class="ant-list-item-meta-title"
|
||||
>
|
||||
<a
|
||||
href="http://ant.design"
|
||||
>
|
||||
ant design part 3
|
||||
</a>
|
||||
</h4>
|
||||
<div
|
||||
class="ant-list-item-meta-description"
|
||||
>
|
||||
Ant Design, a design language for background applications, is refined by Ant UED Team.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item-content"
|
||||
>
|
||||
We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
|
||||
</div>
|
||||
<ul
|
||||
class="ant-list-item-action"
|
||||
>
|
||||
<li>
|
||||
<span>
|
||||
<i
|
||||
class="anticon anticon-star-o"
|
||||
style="margin-right:8px"
|
||||
/>
|
||||
156
|
||||
</span>
|
||||
<em
|
||||
class="ant-list-item-action-split"
|
||||
/>
|
||||
</li>
|
||||
<li>
|
||||
<span>
|
||||
<i
|
||||
class="anticon anticon-like-o"
|
||||
style="margin-right:8px"
|
||||
/>
|
||||
156
|
||||
</span>
|
||||
<em
|
||||
class="ant-list-item-action-split"
|
||||
/>
|
||||
</li>
|
||||
<li>
|
||||
<span>
|
||||
<i
|
||||
class="anticon anticon-message"
|
||||
style="margin-right:8px"
|
||||
/>
|
||||
2
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item-extra"
|
||||
>
|
||||
<img
|
||||
alt="logo"
|
||||
src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png"
|
||||
width="272"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-extra-wrap"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-main"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-meta"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-meta-avatar"
|
||||
>
|
||||
<span
|
||||
class="ant-avatar ant-avatar-circle ant-avatar-image"
|
||||
>
|
||||
<img
|
||||
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item-meta-content"
|
||||
>
|
||||
<h4
|
||||
class="ant-list-item-meta-title"
|
||||
>
|
||||
<a
|
||||
href="http://ant.design"
|
||||
>
|
||||
ant design part 4
|
||||
</a>
|
||||
</h4>
|
||||
<div
|
||||
class="ant-list-item-meta-description"
|
||||
>
|
||||
Ant Design, a design language for background applications, is refined by Ant UED Team.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item-content"
|
||||
>
|
||||
We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
|
||||
</div>
|
||||
<ul
|
||||
class="ant-list-item-action"
|
||||
>
|
||||
<li>
|
||||
<span>
|
||||
<i
|
||||
class="anticon anticon-star-o"
|
||||
style="margin-right:8px"
|
||||
/>
|
||||
156
|
||||
</span>
|
||||
<em
|
||||
class="ant-list-item-action-split"
|
||||
/>
|
||||
</li>
|
||||
<li>
|
||||
<span>
|
||||
<i
|
||||
class="anticon anticon-like-o"
|
||||
style="margin-right:8px"
|
||||
/>
|
||||
156
|
||||
</span>
|
||||
<em
|
||||
class="ant-list-item-action-split"
|
||||
/>
|
||||
</li>
|
||||
<li>
|
||||
<span>
|
||||
<i
|
||||
class="anticon anticon-message"
|
||||
style="margin-right:8px"
|
||||
/>
|
||||
2
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item-extra"
|
||||
>
|
||||
<img
|
||||
alt="logo"
|
||||
src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png"
|
||||
width="272"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@@ -1206,72 +1398,8 @@ exports[`renders ./components/list/demo/vertical.md correctly 1`] = `
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-2"
|
||||
tabindex="0"
|
||||
title="2"
|
||||
>
|
||||
<a>
|
||||
2
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-3"
|
||||
tabindex="0"
|
||||
title="3"
|
||||
>
|
||||
<a>
|
||||
3
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-4"
|
||||
tabindex="0"
|
||||
title="4"
|
||||
>
|
||||
<a>
|
||||
4
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-5"
|
||||
tabindex="0"
|
||||
title="5"
|
||||
>
|
||||
<a>
|
||||
5
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-6"
|
||||
tabindex="0"
|
||||
title="6"
|
||||
>
|
||||
<a>
|
||||
6
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-7"
|
||||
tabindex="0"
|
||||
title="7"
|
||||
>
|
||||
<a>
|
||||
7
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-8"
|
||||
tabindex="0"
|
||||
title="8"
|
||||
>
|
||||
<a>
|
||||
8
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
aria-disabled="false"
|
||||
class=" ant-pagination-next"
|
||||
tabindex="0"
|
||||
aria-disabled="true"
|
||||
class="ant-pagination-disabled ant-pagination-next"
|
||||
title="Next Page"
|
||||
>
|
||||
<a
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`List.pagination renders pagination correctly 1`] = `
|
||||
<div
|
||||
class="ant-list ant-list-vertical ant-list-split ant-list-something-after-last-item"
|
||||
>
|
||||
<div
|
||||
class="ant-spin-nested-loading"
|
||||
>
|
||||
<div
|
||||
class="ant-spin-container"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-content ant-list-item-content-single"
|
||||
>
|
||||
Jack
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-item"
|
||||
>
|
||||
<div
|
||||
class="ant-list-item-content ant-list-item-content-single"
|
||||
>
|
||||
Lucy
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-list-pagination"
|
||||
>
|
||||
<ul
|
||||
class="ant-pagination my-page"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<li
|
||||
aria-disabled="true"
|
||||
class="ant-pagination-disabled ant-pagination-prev"
|
||||
title="Previous Page"
|
||||
>
|
||||
<a
|
||||
class="ant-pagination-item-link"
|
||||
/>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
|
||||
tabindex="0"
|
||||
title="1"
|
||||
>
|
||||
<a>
|
||||
1
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="ant-pagination-item ant-pagination-item-2"
|
||||
tabindex="0"
|
||||
title="2"
|
||||
>
|
||||
<a>
|
||||
2
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
aria-disabled="false"
|
||||
class=" ant-pagination-next"
|
||||
tabindex="0"
|
||||
title="Next Page"
|
||||
>
|
||||
<a
|
||||
class="ant-pagination-item-link"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -1,129 +0,0 @@
|
||||
import React from 'react';
|
||||
import { render, mount } from 'enzyme';
|
||||
import List from '..';
|
||||
|
||||
describe('List.pagination', () => {
|
||||
const data = [
|
||||
{ key: 0, name: 'Jack' },
|
||||
{ key: 1, name: 'Lucy' },
|
||||
{ key: 2, name: 'Tom' },
|
||||
{ key: 3, name: 'Jerry' },
|
||||
];
|
||||
|
||||
const pagination = { className: 'my-page', pageSize: 2 };
|
||||
|
||||
function createList(props) {
|
||||
return (
|
||||
<List
|
||||
itemLayout="vertical"
|
||||
pagination={pagination}
|
||||
dataSource={data}
|
||||
renderItem={item => (
|
||||
<List.Item key={item.key} >
|
||||
{item.name}
|
||||
</List.Item>
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderedNames(wrapper) {
|
||||
return wrapper.find('.ant-list-item-content').map(row => row.text());
|
||||
}
|
||||
|
||||
it('renders pagination correctly', () => {
|
||||
const wrapper = render(createList());
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should not show pager if pagination.hideOnSinglePage is true and only 1 page', () => {
|
||||
const wrapper = mount(
|
||||
createList({ pagination: { pageSize: 3, hideOnSinglePage: true } })
|
||||
);
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(1);
|
||||
wrapper.setProps({ pagination: { pageSize: 3, hideOnSinglePage: false } });
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(1);
|
||||
wrapper.setProps({ pagination: { pageSize: 4, hideOnSinglePage: true } });
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(0);
|
||||
wrapper.setProps({ pagination: { pageSize: 4, hideOnSinglePage: false } });
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(1);
|
||||
wrapper.setProps({ pagination: { pageSize: 5, hideOnSinglePage: true } });
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(0);
|
||||
wrapper.setProps({ pagination: { pageSize: 5, hideOnSinglePage: false } });
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('paginate data', () => {
|
||||
const wrapper = mount(createList());
|
||||
|
||||
expect(renderedNames(wrapper)).toEqual(['Jack', 'Lucy']);
|
||||
wrapper
|
||||
.find('Pager')
|
||||
.last()
|
||||
.simulate('click');
|
||||
expect(renderedNames(wrapper)).toEqual(['Tom', 'Jerry']);
|
||||
});
|
||||
|
||||
it('repaginates when pageSize change', () => {
|
||||
const wrapper = mount(createList());
|
||||
|
||||
wrapper.setProps({ pagination: { pageSize: 1 } });
|
||||
expect(renderedNames(wrapper)).toEqual(['Jack']);
|
||||
});
|
||||
|
||||
it('fires change event', () => {
|
||||
const handlePaginationChange = jest.fn();
|
||||
const noop = () => {};
|
||||
const wrapper = mount(
|
||||
createList({
|
||||
pagination: {
|
||||
...pagination,
|
||||
onChange: handlePaginationChange,
|
||||
onShowSizeChange: noop,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
wrapper
|
||||
.find('Pager')
|
||||
.last()
|
||||
.simulate('click');
|
||||
|
||||
expect(handlePaginationChange).toBeCalledWith(2, 2);
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/4532
|
||||
// https://codepen.io/afc163/pen/pWVRJV?editors=001
|
||||
it('should display pagination as prop pagination change between true and false', () => {
|
||||
const wrapper = mount(createList());
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(1);
|
||||
expect(wrapper.find('.ant-pagination-item')).toHaveLength(2);
|
||||
wrapper.setProps({ pagination: false });
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(0);
|
||||
wrapper.setProps({ pagination });
|
||||
wrapper.update();
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(1);
|
||||
expect(wrapper.find('.ant-pagination-item')).toHaveLength(2);
|
||||
wrapper.find('.ant-pagination-item-2').simulate('click');
|
||||
expect(renderedNames(wrapper)).toEqual(['Tom', 'Jerry']);
|
||||
wrapper.setProps({ pagination: false });
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(0);
|
||||
wrapper.setProps({ pagination: true });
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(1);
|
||||
expect(wrapper.find('.ant-pagination-item')).toHaveLength(1); // pageSize will be 10
|
||||
expect(renderedNames(wrapper)).toEqual(['Jack', 'Lucy', 'Tom', 'Jerry']);
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/5259
|
||||
it('change to correct page when data source changes', () => {
|
||||
const wrapper = mount(createList({ pagination: { pageSize: 1 } }));
|
||||
wrapper.find('.ant-pagination-item-3').simulate('click');
|
||||
wrapper.setProps({ dataSource: [data[0]] });
|
||||
expect(
|
||||
wrapper
|
||||
.find('.ant-pagination-item-1')
|
||||
.hasClass('ant-pagination-item-active')
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -17,7 +17,7 @@ Setting `itemLayout` property with `vertical` to create a vertical list.
|
||||
import { List, Avatar, Icon } from 'antd';
|
||||
|
||||
const listData = [];
|
||||
for (let i = 0; i < 23; i++) {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
listData.push({
|
||||
href: 'http://ant.design',
|
||||
title: `ant design part ${i}`,
|
||||
@@ -27,6 +27,13 @@ for (let i = 0; i < 23; i++) {
|
||||
});
|
||||
}
|
||||
|
||||
const pagination = {
|
||||
pageSize: 10,
|
||||
current: 1,
|
||||
total: listData.length,
|
||||
onChange: (() => {}),
|
||||
};
|
||||
|
||||
const IconText = ({ type, text }) => (
|
||||
<span>
|
||||
<Icon type={type} style={{ marginRight: 8 }} />
|
||||
@@ -38,12 +45,7 @@ ReactDOM.render(
|
||||
<List
|
||||
itemLayout="vertical"
|
||||
size="large"
|
||||
pagination={{
|
||||
onChange: (page) => {
|
||||
console.log(page);
|
||||
},
|
||||
pageSize: 3,
|
||||
}}
|
||||
pagination={pagination}
|
||||
dataSource={listData}
|
||||
footer={<div><b>ant design</b> footer part</div>}
|
||||
renderItem={item => (
|
||||
|
||||
@@ -15,15 +15,7 @@ export { ListItemProps, ListItemMetaProps } from './Item';
|
||||
|
||||
export type ColumnCount = 1 | 2 | 3 | 4 | 6 | 8 | 12 | 24;
|
||||
|
||||
export type ColumnType =
|
||||
| 'gutter'
|
||||
| 'column'
|
||||
| 'xs'
|
||||
| 'sm'
|
||||
| 'md'
|
||||
| 'lg'
|
||||
| 'xl'
|
||||
| 'xxl';
|
||||
export type ColumnType = 'gutter' | 'column' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
||||
|
||||
export interface ListGridType {
|
||||
gutter?: number;
|
||||
@@ -80,26 +72,7 @@ export default class List extends React.Component<ListProps> {
|
||||
pagination: false,
|
||||
};
|
||||
|
||||
state = {
|
||||
paginationCurrent: 1,
|
||||
};
|
||||
|
||||
defaultPaginationProps = {
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
onChange: (page: number, pageSize: number) => {
|
||||
const { pagination } = this.props;
|
||||
this.setState({
|
||||
paginationCurrent: page,
|
||||
});
|
||||
if (pagination && pagination.onChange) {
|
||||
pagination.onChange(page, pageSize);
|
||||
}
|
||||
},
|
||||
total: 0,
|
||||
};
|
||||
|
||||
private keys: { [key: string]: string } = {};
|
||||
private keys: {[key: string]: string} = {};
|
||||
|
||||
getChildContext() {
|
||||
return {
|
||||
@@ -135,15 +108,10 @@ export default class List extends React.Component<ListProps> {
|
||||
|
||||
renderEmpty = (contextLocale: ListLocale) => {
|
||||
const locale = { ...contextLocale, ...this.props.locale };
|
||||
return (
|
||||
<div className={`${this.props.prefixCls}-empty-text`}>
|
||||
{locale.emptyText}
|
||||
</div>
|
||||
);
|
||||
return <div className={`${this.props.prefixCls}-empty-text`}>{locale.emptyText}</div>;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { paginationCurrent } = this.state;
|
||||
const {
|
||||
bordered,
|
||||
split,
|
||||
@@ -171,7 +139,7 @@ export default class List extends React.Component<ListProps> {
|
||||
spinning: loadingProp,
|
||||
};
|
||||
}
|
||||
const isLoading = loadingProp && loadingProp.spinning;
|
||||
const isLoading = (loadingProp && loadingProp.spinning);
|
||||
|
||||
// large => lg
|
||||
// small => sm
|
||||
@@ -196,57 +164,24 @@ export default class List extends React.Component<ListProps> {
|
||||
[`${prefixCls}-something-after-last-item`]: this.isSomethingAfterLastItem(),
|
||||
});
|
||||
|
||||
const paginationProps = {
|
||||
...this.defaultPaginationProps,
|
||||
total: dataSource.length,
|
||||
current: paginationCurrent,
|
||||
...pagination,
|
||||
};
|
||||
const largestPage = Math.ceil(
|
||||
paginationProps.total / paginationProps.pageSize,
|
||||
);
|
||||
if (paginationProps.current > largestPage) {
|
||||
paginationProps.current = largestPage;
|
||||
}
|
||||
const paginationContent = pagination ? (
|
||||
<div className={`${prefixCls}-pagination`}>
|
||||
<Pagination
|
||||
{...paginationProps}
|
||||
onChange={this.defaultPaginationProps.onChange}
|
||||
/>
|
||||
<Pagination {...pagination} />
|
||||
</div>
|
||||
) : null;
|
||||
|
||||
let splitDataSource = [...dataSource];
|
||||
if (pagination) {
|
||||
if (
|
||||
dataSource.length >
|
||||
(paginationProps.current - 1) * paginationProps.pageSize
|
||||
) {
|
||||
splitDataSource = [...dataSource].splice(
|
||||
(paginationProps.current - 1) * paginationProps.pageSize,
|
||||
paginationProps.pageSize,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let childrenContent;
|
||||
childrenContent = isLoading && <div style={{ minHeight: 53 }} />;
|
||||
if (splitDataSource.length > 0) {
|
||||
const items = splitDataSource.map((item: any, index: number) =>
|
||||
this.renderItem(item, index),
|
||||
);
|
||||
const childrenList = React.Children.map(items, (child: any, index) =>
|
||||
React.cloneElement(child, {
|
||||
if (dataSource.length > 0) {
|
||||
const items = dataSource.map((item: any, index: number) => this.renderItem(item, index));
|
||||
const childrenList = React.Children.map(items, (child: any, index) => React.cloneElement(child, {
|
||||
key: this.keys[index],
|
||||
}),
|
||||
);
|
||||
|
||||
childrenContent = grid ? (
|
||||
<Row gutter={grid.gutter}>{childrenList}</Row>
|
||||
) : (
|
||||
childrenList
|
||||
);
|
||||
) : childrenList;
|
||||
} else if (!children && !isLoading) {
|
||||
childrenContent = (
|
||||
<LocaleReceiver
|
||||
|
||||
@@ -156,7 +156,7 @@ exports[`renders ./components/locale-provider/demo/all.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -207,7 +207,7 @@ exports[`renders ./components/locale-provider/demo/all.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -500,7 +500,7 @@ exports[`renders ./components/locale-provider/demo/all.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -532,7 +532,7 @@ exports[`renders ./components/locale-provider/demo/all.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -1643,7 +1643,7 @@ exports[`renders ./components/locale-provider/demo/basic.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,15 +18,17 @@ class MenuItem extends React.Component<any, any> {
|
||||
render() {
|
||||
const { inlineCollapsed } = this.context;
|
||||
const props = this.props;
|
||||
return (
|
||||
<Tooltip
|
||||
title={inlineCollapsed && props.level === 1 ? props.children : ''}
|
||||
const item = <Item {...props} ref={this.saveMenuItem} />;
|
||||
if (inlineCollapsed && props.level === 1) {
|
||||
return <Tooltip
|
||||
title={props.children}
|
||||
placement="right"
|
||||
overlayClassName={`${props.rootPrefixCls}-inline-collapsed-tooltip`}
|
||||
>
|
||||
<Item {...props} ref={this.saveMenuItem} />
|
||||
</Tooltip>
|
||||
);
|
||||
{item}
|
||||
</Tooltip>;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
exports[`renders ./components/menu/demo/horizontal.md correctly 1`] = `
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-light ant-menu-root ant-menu-horizontal"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -16,6 +19,7 @@ exports[`renders ./components/menu/demo/horizontal.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
aria-disabled="true"
|
||||
aria-selected="false"
|
||||
class="ant-menu-item ant-menu-item-disabled"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -26,11 +30,11 @@ exports[`renders ./components/menu/demo/horizontal.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-horizontal"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="item_2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
>
|
||||
<span>
|
||||
@@ -45,6 +49,7 @@ exports[`renders ./components/menu/demo/horizontal.md correctly 1`] = `
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -61,13 +66,14 @@ exports[`renders ./components/menu/demo/horizontal.md correctly 1`] = `
|
||||
|
||||
exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-light ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
style="width:256px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline ant-menu-submenu-open ant-menu-submenu-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
@@ -89,6 +95,7 @@ exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-sub ant-menu-inline"
|
||||
id="sub1$Menu"
|
||||
role="menu"
|
||||
@@ -106,6 +113,7 @@ exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
class="ant-menu-item-group-list"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -113,6 +121,7 @@ exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
Option 1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -134,6 +143,7 @@ exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
class="ant-menu-item-group-list"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -141,6 +151,7 @@ exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
Option 3
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -153,11 +164,11 @@ exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -173,15 +184,14 @@ exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub4$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -197,7 +207,6 @@ exports[`renders ./components/menu/demo/inline.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
</ul>
|
||||
`;
|
||||
@@ -216,10 +225,13 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
/>
|
||||
</button>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -232,6 +244,7 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -244,6 +257,7 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -257,7 +271,6 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline ant-menu-submenu-open"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
@@ -279,11 +292,13 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-sub ant-menu-inline"
|
||||
id="sub1$Menu"
|
||||
role="menu"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -291,6 +306,7 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
Option 5
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -298,6 +314,7 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
Option 6
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -305,6 +322,7 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
Option 7
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -315,11 +333,11 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -335,7 +353,6 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -343,13 +360,14 @@ exports[`renders ./components/menu/demo/inline-collapsed.md correctly 1`] = `
|
||||
|
||||
exports[`renders ./components/menu/demo/sider-current.md correctly 1`] = `
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-light ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
style="width:256px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline ant-menu-submenu-open"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
@@ -371,11 +389,13 @@ exports[`renders ./components/menu/demo/sider-current.md correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-sub ant-menu-inline"
|
||||
id="sub1$Menu"
|
||||
role="menu"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -383,6 +403,7 @@ exports[`renders ./components/menu/demo/sider-current.md correctly 1`] = `
|
||||
Option 1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -390,6 +411,7 @@ exports[`renders ./components/menu/demo/sider-current.md correctly 1`] = `
|
||||
Option 2
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -397,6 +419,7 @@ exports[`renders ./components/menu/demo/sider-current.md correctly 1`] = `
|
||||
Option 3
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -407,11 +430,11 @@ exports[`renders ./components/menu/demo/sider-current.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -427,15 +450,14 @@ exports[`renders ./components/menu/demo/sider-current.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub4$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -451,7 +473,6 @@ exports[`renders ./components/menu/demo/sider-current.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
</ul>
|
||||
`;
|
||||
@@ -483,11 +504,14 @@ exports[`renders ./components/menu/demo/switch-mode.md correctly 1`] = `
|
||||
<br />
|
||||
<br />
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-light ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
style="width:256px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -498,6 +522,7 @@ exports[`renders ./components/menu/demo/switch-mode.md correctly 1`] = `
|
||||
Navigation One
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:24px"
|
||||
@@ -509,7 +534,6 @@ exports[`renders ./components/menu/demo/switch-mode.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline ant-menu-submenu-open"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
@@ -531,11 +555,13 @@ exports[`renders ./components/menu/demo/switch-mode.md correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-sub ant-menu-inline"
|
||||
id="sub1$Menu"
|
||||
role="menu"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -543,6 +569,7 @@ exports[`renders ./components/menu/demo/switch-mode.md correctly 1`] = `
|
||||
Option 3
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -551,11 +578,11 @@ exports[`renders ./components/menu/demo/switch-mode.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub1-2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:48px"
|
||||
title="Submenu"
|
||||
@@ -565,17 +592,16 @@ exports[`renders ./components/menu/demo/switch-mode.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -591,7 +617,6 @@ exports[`renders ./components/menu/demo/switch-mode.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -613,13 +638,14 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
<br />
|
||||
<br />
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-dark ant-menu-root ant-menu-inline"
|
||||
role="menu"
|
||||
style="width:256px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline ant-menu-submenu-open ant-menu-submenu-selected"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="true"
|
||||
@@ -641,11 +667,13 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-sub ant-menu-inline"
|
||||
id="sub1$Menu"
|
||||
role="menu"
|
||||
>
|
||||
<li
|
||||
aria-selected="true"
|
||||
class="ant-menu-item ant-menu-item-selected"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -653,6 +681,7 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
Option 1
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -660,6 +689,7 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
Option 2
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -667,6 +697,7 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
Option 3
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-menu-item"
|
||||
role="menuitem"
|
||||
style="padding-left:48px"
|
||||
@@ -677,11 +708,11 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -697,15 +728,14 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-inline"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub4$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
style="padding-left:24px"
|
||||
>
|
||||
@@ -721,7 +751,6 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
class="ant-menu-submenu-arrow"
|
||||
/>
|
||||
</div>
|
||||
<div />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -729,17 +758,19 @@ exports[`renders ./components/menu/demo/theme.md correctly 1`] = `
|
||||
|
||||
exports[`renders ./components/menu/demo/vertical.md correctly 1`] = `
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-menu ant-menu-light ant-menu-root ant-menu-vertical"
|
||||
role="menu"
|
||||
style="width:256px"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-vertical"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub1$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
>
|
||||
<span>
|
||||
@@ -757,11 +788,11 @@ exports[`renders ./components/menu/demo/vertical.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-vertical"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub2$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
>
|
||||
<span>
|
||||
@@ -779,11 +810,11 @@ exports[`renders ./components/menu/demo/vertical.md correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-menu-submenu ant-menu-submenu-vertical"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="sub4$Menu"
|
||||
class="ant-menu-submenu-title"
|
||||
>
|
||||
<span>
|
||||
|
||||
@@ -133,14 +133,14 @@ describe('Menu', () => {
|
||||
<Menu.Item key="2">menu2</Menu.Item>
|
||||
</Menu>
|
||||
);
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true);
|
||||
wrapper.setProps({ mode: 'vertical' });
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true);
|
||||
wrapper.setProps({ mode: 'inline' });
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true);
|
||||
});
|
||||
|
||||
it('should always follow openKeys when inlineCollapsed is switched', () => {
|
||||
it('should always follow openKeys when mode is switched', () => {
|
||||
const wrapper = mount(
|
||||
<Menu defaultOpenKeys={['1']} mode="inline">
|
||||
<Menu.Item key="menu1">
|
||||
@@ -157,23 +157,24 @@ describe('Menu', () => {
|
||||
</SubMenu>
|
||||
</Menu>
|
||||
);
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-inline')).toBe(true);
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-inline')).toBe(true);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
|
||||
wrapper.setProps({ inlineCollapsed: true });
|
||||
// 动画结束后套样式;
|
||||
jest.runAllTimers();
|
||||
wrapper.update();
|
||||
|
||||
expect(wrapper.find('ul.ant-menu-root').at(0).hasClass('ant-menu-vertical')).toBe(true);
|
||||
expect(wrapper.find('ul.ant-menu-sub').length).toBe(0);
|
||||
expect(wrapper.find('.ant-menu').at(0).hasClass('ant-menu-vertical')).toBe(true);
|
||||
expect(wrapper.find('.ant-menu-sub').length).toBe(0);
|
||||
|
||||
wrapper.setProps({ inlineCollapsed: false });
|
||||
jest.runAllTimers();
|
||||
wrapper.update();
|
||||
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-inline')).toBe(true);
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-inline')).toBe(true);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
});
|
||||
|
||||
it('inlineCollapsed should works well when specify a not existed default openKeys', () => {
|
||||
@@ -202,8 +203,8 @@ describe('Menu', () => {
|
||||
wrapper.update();
|
||||
expect(wrapper.find('.ant-menu-submenu').at(0).hasClass('ant-menu-submenu-vertical')).toBe(true);
|
||||
expect(wrapper.find('.ant-menu-submenu').at(0).hasClass('ant-menu-submenu-open')).toBe(true);
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-vertical')).toBe(true);
|
||||
expect(wrapper.find('ul.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-vertical')).toBe(true);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).toBe(false);
|
||||
});
|
||||
|
||||
describe('open submenu when click submenu title', () => {
|
||||
|
||||
@@ -67,7 +67,6 @@ export default class Menu extends React.Component<MenuProps, MenuState> {
|
||||
prefixCls: 'ant-menu',
|
||||
className: '',
|
||||
theme: 'light' as MenuTheme, // or dark
|
||||
focusable: false,
|
||||
};
|
||||
static childContextTypes = {
|
||||
inlineCollapsed: PropTypes.bool,
|
||||
|
||||
@@ -33,20 +33,6 @@ describe('message', () => {
|
||||
expect(document.querySelectorAll('.custom-container').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should be able to config maxCount', () => {
|
||||
message.config({
|
||||
maxCount: 5,
|
||||
});
|
||||
for (let i = 0; i < 10; i += 1) {
|
||||
message.info('test');
|
||||
}
|
||||
message.info('last');
|
||||
expect(document.querySelectorAll('.ant-message-notice').length).toBe(5);
|
||||
expect(document.querySelectorAll('.ant-message-notice')[4].textContent).toBe('last');
|
||||
jest.runAllTimers();
|
||||
expect(document.querySelectorAll('.ant-message-notice').length).toBe(0);
|
||||
});
|
||||
|
||||
it('should be able to hide manually', () => {
|
||||
const hide1 = message.info('whatever', 0);
|
||||
const hide2 = message.info('whatever', 0);
|
||||
|
||||
@@ -40,7 +40,6 @@ Methods for global configuration and destruction are also provided:
|
||||
message.config({
|
||||
top: 100,
|
||||
duration: 2,
|
||||
maxCount: 3,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -48,5 +47,4 @@ message.config({
|
||||
| -------- | ----------- | ---- | ------- |
|
||||
| duration | time before auto-dismiss, in seconds | number | 1.5 |
|
||||
| getContainer | Return the mount node for Message | () => HTMLElement | () => document.body |
|
||||
| top | distance from top | number | 24 |
|
||||
| maxCount | max message show, drop oldest if exceed limit | number | - |
|
||||
| top | distance from top | number | 24px |
|
||||
|
||||
@@ -9,7 +9,6 @@ let key = 1;
|
||||
let prefixCls = 'ant-message';
|
||||
let transitionName = 'move-up';
|
||||
let getContainer: () => HTMLElement;
|
||||
let maxCount: number;
|
||||
|
||||
function getMessageInstance(callback: (i: any) => void) {
|
||||
if (messageInstance) {
|
||||
@@ -21,7 +20,6 @@ function getMessageInstance(callback: (i: any) => void) {
|
||||
transitionName,
|
||||
style: { top: defaultTop }, // 覆盖原来的样式
|
||||
getContainer,
|
||||
maxCount,
|
||||
}, (instance: any) => {
|
||||
if (messageInstance) {
|
||||
callback(messageInstance);
|
||||
@@ -40,7 +38,7 @@ function notice(
|
||||
type: NoticeType,
|
||||
onClose?: () => void,
|
||||
) {
|
||||
const iconType = ({
|
||||
let iconType = ({
|
||||
info: 'info-circle',
|
||||
success: 'check-circle',
|
||||
error: 'cross-circle',
|
||||
@@ -85,7 +83,6 @@ export interface ConfigOptions {
|
||||
prefixCls?: string;
|
||||
getContainer?: () => HTMLElement;
|
||||
transitionName?: string;
|
||||
maxCount?: number;
|
||||
}
|
||||
|
||||
export default {
|
||||
@@ -126,10 +123,6 @@ export default {
|
||||
transitionName = options.transitionName;
|
||||
messageInstance = null; // delete messageInstance for new transitionName
|
||||
}
|
||||
if (options.maxCount !== undefined) {
|
||||
maxCount = options.maxCount;
|
||||
messageInstance = null;
|
||||
}
|
||||
},
|
||||
destroy() {
|
||||
if (messageInstance) {
|
||||
|
||||
@@ -41,7 +41,6 @@ title: Message
|
||||
message.config({
|
||||
top: 100,
|
||||
duration: 2,
|
||||
maxCount: 3,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -49,5 +48,4 @@ message.config({
|
||||
| --- | --- | --- | --- |
|
||||
| duration | 默认自动关闭延时,单位秒 | number | 3 |
|
||||
| getContainer | 配置渲染节点的输出位置 | () => HTMLElement | () => document.body |
|
||||
| top | 消息距离顶部的位置 | number | 24 |
|
||||
| maxCount | 最大显示数, 超过限制时,最早的消息会被自动关闭 | number | - |
|
||||
| top | 消息距离顶部的位置 | number | 24px |
|
||||
|
||||
@@ -73,7 +73,7 @@ exports[`renders ./components/notification/demo/placement.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -90,17 +90,6 @@ exports[`renders ./components/notification/demo/placement.md correctly 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`renders ./components/notification/demo/update.md correctly 1`] = `
|
||||
<button
|
||||
class="ant-btn ant-btn-primary"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
Open the notification box
|
||||
</span>
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`renders ./components/notification/demo/with-btn.md correctly 1`] = `
|
||||
<button
|
||||
class="ant-btn ant-btn-primary"
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
order: 7
|
||||
title:
|
||||
zh-CN: 更新消息内容
|
||||
en-US: Update Message Content
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
可以通过唯一的 key 来更新内容。
|
||||
|
||||
## en-US
|
||||
|
||||
Update content with unique key.
|
||||
|
||||
````jsx
|
||||
import { Button, notification } from 'antd';
|
||||
|
||||
const key = 'updatable';
|
||||
|
||||
const openNotification = () => {
|
||||
notification.open({
|
||||
key,
|
||||
message: 'Notification Title',
|
||||
description: 'description.',
|
||||
});
|
||||
setTimeout(() => {
|
||||
notification.open({
|
||||
key,
|
||||
message: 'New Title',
|
||||
description: 'New description.',
|
||||
});
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
ReactDOM.render(
|
||||
<Button type="primary" onClick={openNotification}>Open the notification box</Button>
|
||||
, mountNode);
|
||||
````
|
||||
@@ -118,7 +118,7 @@
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: shade(@text-color-secondary, 40%);
|
||||
color: #404040;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ exports[`renders ./components/pagination/demo/changer.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -634,7 +634,7 @@ exports[`renders ./components/pagination/demo/mini.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
|
||||
@@ -11,7 +11,7 @@ title:
|
||||
|
||||
## en-US
|
||||
|
||||
Set `okText` and `cancelText` props to customize the button's labels.
|
||||
Set `okText` and `cancelText` props to customise the button's labels.
|
||||
|
||||
````jsx
|
||||
import { Popconfirm } from 'antd';
|
||||
|
||||
@@ -1,35 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Progress render format 1`] = `
|
||||
<div
|
||||
class="ant-progress ant-progress-line ant-progress-status-normal ant-progress-show-info ant-progress-default"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
class="ant-progress-outer"
|
||||
>
|
||||
<div
|
||||
class="ant-progress-inner"
|
||||
>
|
||||
<div
|
||||
class="ant-progress-bg"
|
||||
style="width: 50%; height: 8px;"
|
||||
/>
|
||||
<div
|
||||
class="ant-progress-success-bg"
|
||||
style="width: 10%; height: 8px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
class="ant-progress-text"
|
||||
>
|
||||
50 10
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Progress render negetive progress 1`] = `
|
||||
<div
|
||||
class="ant-progress ant-progress-line ant-progress-status-normal ant-progress-show-info ant-progress-default"
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mount } from 'enzyme';
|
||||
import Progress from '..';
|
||||
|
||||
describe('Progress', () => {
|
||||
it('successPercent should decide the progress status when it exists', () => {
|
||||
it('successPercent should decide the progress status when it exists', async () => {
|
||||
const wrapper = mount(<Progress percent={100} successPercent={50} />);
|
||||
expect(wrapper.find('.ant-progress-status-success')).toHaveLength(0);
|
||||
|
||||
@@ -11,34 +11,23 @@ describe('Progress', () => {
|
||||
expect(wrapper.find('.ant-progress-status-success')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('render out-of-range progress', () => {
|
||||
it('render out-of-range progress', async () => {
|
||||
const wrapper = mount(<Progress percent={120} />);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('render out-of-range progress with info', () => {
|
||||
it('render out-of-range progress with info', async () => {
|
||||
const wrapper = mount(<Progress percent={120} showInfo />);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('render negetive progress', () => {
|
||||
it('render negetive progress', async () => {
|
||||
const wrapper = mount(<Progress percent={-20} />);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('render negetive successPercent', () => {
|
||||
it('render negetive successPercent', async () => {
|
||||
const wrapper = mount(<Progress percent={50} successPercent={-20} />);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('render format', () => {
|
||||
const wrapper = mount(
|
||||
<Progress
|
||||
percent={50}
|
||||
successPercent={10}
|
||||
format={(percent, successPercent) => `${percent} ${successPercent}`}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ If it will take a long time to complete an operation, you can use `Progress` to
|
||||
|
||||
| Property | Description | Type | Default |
|
||||
| -------- | ----------- | ---- | ------- |
|
||||
| format | template function of the content | function(percent, successPercent) | `percent => percent + '%'` |
|
||||
| format | template function of the content | function(percent) | `percent => percent + '%'` |
|
||||
| gapDegree `(type=circle)` | the gap degree of half circle, 0 ~ 360 | number | 0 |
|
||||
| gapPosition `(type=circle)` | the gap position, options: `top` `bottom` `left` `right` | string | `top` |
|
||||
| percent | to set the completion percentage | number | 0 |
|
||||
|
||||
@@ -18,7 +18,7 @@ title: Progress
|
||||
|
||||
| 属性 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| format | 内容的模板函数 | function(percent, successPercent) | `percent => percent + '%'` |
|
||||
| format | 内容的模板函数 | function(percent) | `percent => percent + '%'` |
|
||||
| gapDegree `(type=circle)` | 圆形进度条缺口角度,可取值 0 ~ 360 | number | 0 |
|
||||
| gapPosition `(type=circle)` | 圆形进度条缺口位置 | Enum{ 'top', 'bottom', 'left', 'right' } | `top` |
|
||||
| percent | 百分比 | number | 0 |
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface ProgressProps {
|
||||
type?: ProgressType;
|
||||
percent?: number;
|
||||
successPercent?: number;
|
||||
format?: (percent?: number, successPercent?: number) => string;
|
||||
format?: (percent: number) => string;
|
||||
status?: 'success' | 'active' | 'exception';
|
||||
showInfo?: boolean;
|
||||
strokeWidth?: number;
|
||||
@@ -81,12 +81,12 @@ export default class Progress extends React.Component<ProgressProps, {}> {
|
||||
if (showInfo) {
|
||||
let text;
|
||||
const iconType = (type === 'circle' || type === 'dashboard') ? '' : '-circle';
|
||||
if (format || (progressStatus !== 'exception' && progressStatus !== 'success')) {
|
||||
text = textFormatter(validProgress(percent), validProgress(successPercent));
|
||||
} else if (progressStatus === 'exception') {
|
||||
text = <Icon type={`cross${iconType}`} />;
|
||||
if (progressStatus === 'exception') {
|
||||
text = format ? textFormatter(validProgress(percent)) : <Icon type={`cross${iconType}`} />;
|
||||
} else if (progressStatus === 'success') {
|
||||
text = <Icon type={`check${iconType}`} />;
|
||||
text = format ? textFormatter(validProgress(percent)) : <Icon type={`check${iconType}`} />;
|
||||
} else {
|
||||
text = textFormatter(validProgress(percent));
|
||||
}
|
||||
progressInfo = <span className={`${prefixCls}-text`}>{text}</span>;
|
||||
}
|
||||
|
||||
@@ -37,5 +37,5 @@ export interface RadioChangeEvent {
|
||||
target: RadioChangeEventTarget;
|
||||
stopPropagation: () => void;
|
||||
preventDefault: () => void;
|
||||
nativeEvent: Event;
|
||||
nativeEvent: MouseEvent;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
height: @radio-dot-size;
|
||||
left: (@radio-size - @radio-dot-size) / 2 - 1px;
|
||||
top: (@radio-size - @radio-dot-size) / 2 - 1px;
|
||||
border-radius: @radio-dot-size;
|
||||
border-radius: @border-radius-base;
|
||||
display: table;
|
||||
border-top: 0;
|
||||
border-left: 0;
|
||||
|
||||
@@ -70,14 +70,14 @@ exports[`renders ./components/select/demo/basic.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-select ant-select-disabled"
|
||||
class="ant-select ant-select-disabled ant-select-allow-clear"
|
||||
style="width:120px"
|
||||
>
|
||||
<div
|
||||
@@ -100,10 +100,15 @@ exports[`renders ./components/select/demo/basic.md correctly 1`] = `
|
||||
Lucy
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
class="ant-select-selection__clear"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="unselectable"
|
||||
/>
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -131,7 +136,7 @@ exports[`renders ./components/select/demo/combobox.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Enter the account name
|
||||
</div>
|
||||
@@ -159,7 +164,7 @@ exports[`renders ./components/select/demo/combobox.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -196,7 +201,7 @@ exports[`renders ./components/select/demo/coordinate.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -229,7 +234,7 @@ exports[`renders ./components/select/demo/coordinate.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -266,7 +271,7 @@ exports[`renders ./components/select/demo/label-in-value.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -293,7 +298,7 @@ exports[`renders ./components/select/demo/multiple.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:none;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Please select
|
||||
</div>
|
||||
@@ -302,7 +307,7 @@ exports[`renders ./components/select/demo/multiple.md correctly 1`] = `
|
||||
class="ant-select-selection__choice"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
title="a10"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<div
|
||||
class="ant-select-selection__choice__content"
|
||||
@@ -317,7 +322,7 @@ exports[`renders ./components/select/demo/multiple.md correctly 1`] = `
|
||||
class="ant-select-selection__choice"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
title="c12"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<div
|
||||
class="ant-select-selection__choice__content"
|
||||
@@ -380,7 +385,7 @@ exports[`renders ./components/select/demo/optgroup.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -408,7 +413,7 @@ exports[`renders ./components/select/demo/search.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Select a person
|
||||
</div>
|
||||
@@ -435,7 +440,7 @@ exports[`renders ./components/select/demo/search.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -445,7 +450,7 @@ exports[`renders ./components/select/demo/search.md correctly 1`] = `
|
||||
|
||||
exports[`renders ./components/select/demo/search-box.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select ant-select-combobox ant-select-enabled ant-select-no-arrow"
|
||||
class="ant-select ant-select-combobox ant-select-enabled"
|
||||
style="width:200px"
|
||||
>
|
||||
<div
|
||||
@@ -462,7 +467,7 @@ exports[`renders ./components/select/demo/search-box.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
input search text
|
||||
</div>
|
||||
@@ -510,7 +515,7 @@ exports[`renders ./components/select/demo/select-users.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Select users
|
||||
</div>
|
||||
@@ -632,7 +637,7 @@ exports[`renders ./components/select/demo/size.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -678,7 +683,7 @@ exports[`renders ./components/select/demo/size.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
@@ -703,7 +708,7 @@ exports[`renders ./components/select/demo/size.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:none;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Please select
|
||||
</div>
|
||||
@@ -712,7 +717,7 @@ exports[`renders ./components/select/demo/size.md correctly 1`] = `
|
||||
class="ant-select-selection__choice"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
title="a10"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<div
|
||||
class="ant-select-selection__choice__content"
|
||||
@@ -727,7 +732,7 @@ exports[`renders ./components/select/demo/size.md correctly 1`] = `
|
||||
class="ant-select-selection__choice"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
title="c12"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<div
|
||||
class="ant-select-selection__choice__content"
|
||||
@@ -779,7 +784,7 @@ exports[`renders ./components/select/demo/size.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:none;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Please select
|
||||
</div>
|
||||
@@ -788,7 +793,7 @@ exports[`renders ./components/select/demo/size.md correctly 1`] = `
|
||||
class="ant-select-selection__choice"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
title="a10"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<div
|
||||
class="ant-select-selection__choice__content"
|
||||
@@ -803,7 +808,7 @@ exports[`renders ./components/select/demo/size.md correctly 1`] = `
|
||||
class="ant-select-selection__choice"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
title="c12"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<div
|
||||
class="ant-select-selection__choice__content"
|
||||
@@ -858,7 +863,7 @@ exports[`renders ./components/select/demo/tags.md correctly 1`] = `
|
||||
<div
|
||||
class="ant-select-selection__placeholder"
|
||||
style="display:block;user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
Tags Mode
|
||||
</div>
|
||||
|
||||
@@ -29,7 +29,7 @@ ReactDOM.render(
|
||||
<Option value="disabled" disabled>Disabled</Option>
|
||||
<Option value="Yiminghe">yiminghe</Option>
|
||||
</Select>
|
||||
<Select defaultValue="lucy" style={{ width: 120 }} disabled>
|
||||
<Select defaultValue="lucy" style={{ width: 120 }} allowClear disabled>
|
||||
<Option value="lucy">Lucy</Option>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@ export interface AbstractSelectProps {
|
||||
disabled?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
placeholder?: string | React.ReactNode;
|
||||
placeholder?: string;
|
||||
defaultActiveFirstOption?: boolean;
|
||||
dropdownClassName?: string;
|
||||
dropdownStyle?: React.CSSProperties;
|
||||
@@ -31,7 +31,7 @@ export interface LabeledValue {
|
||||
label: React.ReactNode;
|
||||
}
|
||||
|
||||
export type SelectValue = string | string[] | number | number[] | LabeledValue | LabeledValue[];
|
||||
export type SelectValue = string | any[] | LabeledValue | LabeledValue[];
|
||||
|
||||
export interface SelectProps extends AbstractSelectProps {
|
||||
value?: SelectValue;
|
||||
@@ -58,7 +58,7 @@ export interface SelectProps extends AbstractSelectProps {
|
||||
|
||||
export interface OptionProps {
|
||||
disabled?: boolean;
|
||||
value?: string | number;
|
||||
value?: any;
|
||||
title?: string;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
@@ -116,10 +116,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-no-arrow &-selection-selected-value {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
&-disabled {
|
||||
color: @disabled-color;
|
||||
}
|
||||
@@ -375,10 +371,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-allow-clear &-selection--single &-selection-selected-value {
|
||||
padding-right: 16px;
|
||||
}
|
||||
|
||||
&-allow-clear &-selection--multiple &-selection__rendered {
|
||||
margin-right: 20px; // In case that clear button will overlap content
|
||||
}
|
||||
|
||||
@@ -77,8 +77,6 @@
|
||||
}
|
||||
|
||||
&-blur {
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
overflow: hidden;
|
||||
opacity: 0.7;
|
||||
-webkit-filter: blur(0.5px);
|
||||
|
||||
@@ -14,13 +14,6 @@
|
||||
unicode-range: U+30-39;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Monospaced Number";
|
||||
font-weight: bold;
|
||||
src: local("Tahoma-Bold");
|
||||
unicode-range: U+30-39;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Chinese Quote";
|
||||
src: local("PingFang SC"), local("SimSun");
|
||||
|
||||
@@ -322,8 +322,6 @@
|
||||
@menu-dark-arrow-color: #fff;
|
||||
@menu-dark-submenu-bg: #000c17;
|
||||
@menu-dark-highlight-color: #fff;
|
||||
@menu-dark-item-active-bg: @primary-color;
|
||||
// same as @menu-dark-item-active-bg, for naming downgrade compatible, should be deleted in next majoy version
|
||||
@menu-dark-item-selected-bg: @primary-color;
|
||||
|
||||
// Spin
|
||||
@@ -463,10 +461,3 @@
|
||||
@slider-dot-border-color-active: tint(@primary-color, 50%);
|
||||
@slider-disabled-color: @disabled-color;
|
||||
@slider-disabled-background-color: @component-background;
|
||||
|
||||
// Collapse
|
||||
// ---
|
||||
@collapse-header-padding: 12px 0 12px 40px;
|
||||
@collapse-header-bg: @background-color-light;
|
||||
@collapse-content-padding: @padding-md;
|
||||
@collapse-content-bg: @component-background;
|
||||
|
||||
@@ -28,10 +28,7 @@ import {
|
||||
CompareFn,
|
||||
TableStateFilters,
|
||||
SelectionItemSelectFn,
|
||||
SelectionInfo,
|
||||
TablePaginationConfig,
|
||||
TableSelectWay,
|
||||
TableRowSelection,
|
||||
} from './interface';
|
||||
import { RadioChangeEvent } from '../radio';
|
||||
import { CheckboxChangeEvent } from '../checkbox';
|
||||
@@ -46,10 +43,6 @@ function stopPropagation(e: React.SyntheticEvent<any>) {
|
||||
}
|
||||
}
|
||||
|
||||
function getRowSelection<T>(props: TableProps<T>): TableRowSelection<T> {
|
||||
return props.rowSelection || {};
|
||||
}
|
||||
|
||||
const defaultPagination = {
|
||||
onChange: noop,
|
||||
onShowSizeChange: noop,
|
||||
@@ -87,6 +80,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
dataSource: [],
|
||||
prefixCls: 'ant-table',
|
||||
useFixedHeader: false,
|
||||
rowSelection: null,
|
||||
className: '',
|
||||
size: 'large',
|
||||
loading: false,
|
||||
@@ -127,13 +121,13 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
this.CheckboxPropsCache = {};
|
||||
|
||||
this.store = createStore({
|
||||
selectedRowKeys: getRowSelection(props).selectedRowKeys || [],
|
||||
selectedRowKeys: (props.rowSelection || {}).selectedRowKeys || [],
|
||||
selectionDirty: false,
|
||||
});
|
||||
}
|
||||
|
||||
getCheckboxPropsByItem = (item: T, index: number) => {
|
||||
const rowSelection = getRowSelection(this.props);
|
||||
const { rowSelection = {} } = this.props;
|
||||
if (!rowSelection.getCheckboxProps) {
|
||||
return {};
|
||||
}
|
||||
@@ -146,7 +140,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
}
|
||||
|
||||
getDefaultSelection() {
|
||||
const rowSelection = getRowSelection(this.props);
|
||||
const { rowSelection = {} } = this.props;
|
||||
if (!rowSelection.getCheckboxProps) {
|
||||
return [];
|
||||
}
|
||||
@@ -230,9 +224,8 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
};
|
||||
}
|
||||
|
||||
setSelectedRowKeys(selectedRowKeys: string[], selectionInfo: SelectionInfo<T>) {
|
||||
const { selectWay, record, checked, changeRowKeys, nativeEvent } = selectionInfo;
|
||||
const rowSelection = getRowSelection(this.props);
|
||||
setSelectedRowKeys(selectedRowKeys: string[], { selectWay, record, checked, changeRowKeys, nativeEvent }: any) {
|
||||
const { rowSelection = {} as any } = this.props;
|
||||
if (rowSelection && !('selectedRowKeys' in rowSelection)) {
|
||||
this.store.setState({ selectedRowKeys });
|
||||
}
|
||||
@@ -247,12 +240,12 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
rowSelection.onChange(selectedRowKeys, selectedRows);
|
||||
}
|
||||
if (selectWay === 'onSelect' && rowSelection.onSelect) {
|
||||
rowSelection.onSelect(record!, checked!, selectedRows, nativeEvent!);
|
||||
rowSelection.onSelect(record, checked, selectedRows, nativeEvent);
|
||||
} else if (selectWay === 'onSelectAll' && rowSelection.onSelectAll) {
|
||||
const changeRows = data.filter(
|
||||
(row, i) => changeRowKeys!.indexOf(this.getRecordKey(row, i)) >= 0,
|
||||
(row, i) => changeRowKeys.indexOf(this.getRecordKey(row, i)) >= 0,
|
||||
);
|
||||
rowSelection.onSelectAll(checked!, selectedRows, changeRows);
|
||||
rowSelection.onSelectAll(checked, selectedRows, changeRows);
|
||||
} else if (selectWay === 'onSelectInvert' && rowSelection.onSelectInvert) {
|
||||
rowSelection.onSelectInvert(selectedRowKeys);
|
||||
}
|
||||
@@ -340,7 +333,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
}
|
||||
|
||||
return (a: T, b: T) => {
|
||||
const result = (sortColumn!.sorter as CompareFn<T>)(a, b, sortOrder);
|
||||
const result = (sortColumn!.sorter as CompareFn<T>)(a, b);
|
||||
if (result !== 0) {
|
||||
return (sortOrder === 'descend') ? -result : result;
|
||||
}
|
||||
@@ -348,7 +341,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
};
|
||||
}
|
||||
|
||||
toggleSortOrder(order: 'ascend'|'descend', column: ColumnProps<T>) {
|
||||
toggleSortOrder(order: string, column: ColumnProps<T>) {
|
||||
let { sortColumn, sortOrder } = this.state;
|
||||
// 只同时允许一列进行排序,否则会导致排序顺序的逻辑问题
|
||||
let isSortColumn = this.isSortColumn(column);
|
||||
@@ -357,7 +350,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
sortColumn = column;
|
||||
} else { // 当前列已排序
|
||||
if (sortOrder === order) { // 切换为未排序状态
|
||||
sortOrder = undefined;
|
||||
sortOrder = '';
|
||||
sortColumn = null;
|
||||
} else { // 切换为排序状态
|
||||
sortOrder = order;
|
||||
@@ -499,7 +492,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
.map((item, i) => this.getRecordKey(item, i));
|
||||
|
||||
let changeRowKeys: string[] = [];
|
||||
let selectWay: TableSelectWay = 'onSelectAll';
|
||||
let selectWay = '';
|
||||
let checked;
|
||||
// handle default selection
|
||||
switch (selectionKey) {
|
||||
@@ -551,7 +544,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
return onSelectFunc(changeableRowKeys);
|
||||
}
|
||||
this.setSelectedRowKeys(selectedRowKeys, {
|
||||
selectWay,
|
||||
selectWay: selectWay,
|
||||
checked,
|
||||
changeRowKeys,
|
||||
});
|
||||
|
||||
@@ -106,22 +106,6 @@ describe('Table.filter', () => {
|
||||
expect(dropdown.props().visible).toBe(false);
|
||||
});
|
||||
|
||||
it('if the filter is visible it should ignore the selectedKeys changes', () => {
|
||||
const wrapper = mount(createTable({
|
||||
columns: [{
|
||||
...column,
|
||||
filterDropdownVisible: true,
|
||||
}],
|
||||
}));
|
||||
|
||||
const filterMenu = wrapper.find('FilterMenu').instance();
|
||||
expect(filterMenu.state.selectedKeys).toEqual([]);
|
||||
wrapper.find('FilterMenu').find('input[type="checkbox"]').first().simulate('click');
|
||||
expect(filterMenu.state.selectedKeys).toEqual(['boy']);
|
||||
wrapper.setProps({ dataSource: [...data, { key: 999, name: 'Chris' }] });
|
||||
expect(filterMenu.state.selectedKeys).toEqual(['boy']);
|
||||
});
|
||||
|
||||
it('fires change event when visible change', () => {
|
||||
const handleChange = jest.fn();
|
||||
const wrapper = mount(createTable({
|
||||
|
||||
@@ -74,20 +74,6 @@ describe('Table.sorter', () => {
|
||||
expect(renderedNames(wrapper)).toEqual(['Jack', 'Jerry', 'Lucy', 'Tom']);
|
||||
});
|
||||
|
||||
it('provides sortOrder in the sorterFn', () => {
|
||||
let actualSortOrder;
|
||||
mount(createTable({ },
|
||||
{
|
||||
sortOrder: 'ascend',
|
||||
sorter: (a, b, sortOrder) => {
|
||||
actualSortOrder = sortOrder;
|
||||
return sorterFn(a, b);
|
||||
},
|
||||
},
|
||||
));
|
||||
expect(actualSortOrder).toEqual('ascend');
|
||||
});
|
||||
|
||||
it('fires change event', () => {
|
||||
const handleChange = jest.fn();
|
||||
const wrapper = mount(createTable({ onChange: handleChange }));
|
||||
|
||||
@@ -132,11 +132,13 @@ exports[`Table.filter renders menu correctly 1`] = `
|
||||
class="ant-table-filter-dropdown"
|
||||
>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-dropdown-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -160,6 +162,7 @@ exports[`Table.filter renders menu correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-dropdown-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -184,11 +187,11 @@ exports[`Table.filter renders menu correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-dropdown-menu-submenu ant-dropdown-menu-submenu-vertical"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="title$Menu"
|
||||
class="ant-dropdown-menu-submenu-title"
|
||||
title="Title"
|
||||
>
|
||||
@@ -227,11 +230,13 @@ exports[`Table.filter renders radio filter correctly 1`] = `
|
||||
class="ant-table-filter-dropdown"
|
||||
>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-dropdown-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -255,6 +260,7 @@ exports[`Table.filter renders radio filter correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-dropdown-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -279,11 +285,11 @@ exports[`Table.filter renders radio filter correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
class="ant-dropdown-menu-submenu ant-dropdown-menu-submenu-vertical"
|
||||
role="menuitem"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-owns="title$Menu"
|
||||
class="ant-dropdown-menu-submenu-title"
|
||||
title="Title"
|
||||
>
|
||||
|
||||
@@ -410,10 +410,13 @@ exports[`Table.rowSelection render with default selection correctly 1`] = `
|
||||
class="ant-dropdown ant-dropdown-placement-bottomLeft ant-dropdown-hidden"
|
||||
>
|
||||
<ul
|
||||
aria-activedescendant=""
|
||||
class="ant-dropdown-menu ant-table-selection-menu ant-dropdown-menu-light ant-dropdown-menu-root ant-dropdown-menu-vertical"
|
||||
role="menu"
|
||||
tabindex="0"
|
||||
>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-dropdown-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
@@ -422,6 +425,7 @@ exports[`Table.rowSelection render with default selection correctly 1`] = `
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
aria-selected="false"
|
||||
class="ant-dropdown-menu-item"
|
||||
role="menuitem"
|
||||
>
|
||||
|
||||
@@ -2954,17 +2954,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 0
|
||||
<div>
|
||||
Edrward 0
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 0
|
||||
<div>
|
||||
London Park no. 0
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -2988,17 +2994,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 1
|
||||
<div>
|
||||
Edrward 1
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 1
|
||||
<div>
|
||||
London Park no. 1
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -3022,17 +3034,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 2
|
||||
<div>
|
||||
Edrward 2
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 2
|
||||
<div>
|
||||
London Park no. 2
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -3056,17 +3074,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 3
|
||||
<div>
|
||||
Edrward 3
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 3
|
||||
<div>
|
||||
London Park no. 3
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -3090,17 +3114,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 4
|
||||
<div>
|
||||
Edrward 4
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 4
|
||||
<div>
|
||||
London Park no. 4
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -3124,17 +3154,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 5
|
||||
<div>
|
||||
Edrward 5
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 5
|
||||
<div>
|
||||
London Park no. 5
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -3158,17 +3194,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 6
|
||||
<div>
|
||||
Edrward 6
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 6
|
||||
<div>
|
||||
London Park no. 6
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -3192,17 +3234,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 7
|
||||
<div>
|
||||
Edrward 7
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 7
|
||||
<div>
|
||||
London Park no. 7
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -3226,17 +3274,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 8
|
||||
<div>
|
||||
Edrward 8
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 8
|
||||
<div>
|
||||
London Park no. 8
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
@@ -3260,17 +3314,23 @@ exports[`renders ./components/table/demo/edit-row.md correctly 1`] = `
|
||||
class="ant-table-row-indent indent-level-0"
|
||||
style="padding-left:0px"
|
||||
/>
|
||||
Edrward 9
|
||||
<div>
|
||||
Edrward 9
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
32
|
||||
<div>
|
||||
32
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
>
|
||||
London Park no. 9
|
||||
<div>
|
||||
London Park no. 9
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class=""
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import demoTest from '../../../tests/shared/demoTest';
|
||||
|
||||
demoTest('table', {
|
||||
skip: process.env.REACT === '15' ? ['edit-row'] : [],
|
||||
});
|
||||
demoTest('table');
|
||||
|
||||
@@ -13,8 +13,8 @@ title:
|
||||
|
||||
Table with editable rows.
|
||||
|
||||
```jsx
|
||||
import { Table, Input, InputNumber, Popconfirm, Form } from 'antd';
|
||||
````jsx
|
||||
import { Table, Input, Popconfirm } from 'antd';
|
||||
|
||||
const data = [];
|
||||
for (let i = 0; i < 100; i++) {
|
||||
@@ -25,190 +25,111 @@ for (let i = 0; i < 100; i++) {
|
||||
address: `London Park no. ${i}`,
|
||||
});
|
||||
}
|
||||
const FormItem = Form.Item;
|
||||
const EditableContext = React.createContext();
|
||||
|
||||
const EditableRow = ({ form, index, ...props }) => (
|
||||
<EditableContext.Provider value={form}>
|
||||
<tr {...props} />
|
||||
</EditableContext.Provider>
|
||||
);
|
||||
|
||||
const EditableFormRow = Form.create()(EditableRow);
|
||||
|
||||
class EditableCell extends React.Component {
|
||||
getInput = () => {
|
||||
if (this.props.inputType === 'number') {
|
||||
return <InputNumber size="small" />;
|
||||
const EditableCell = ({ editable, value, onChange }) => (
|
||||
<div>
|
||||
{editable
|
||||
? <Input style={{ margin: '-5px 0' }} value={value} onChange={e => onChange(e.target.value)} />
|
||||
: value
|
||||
}
|
||||
return <Input size="small" />;
|
||||
};
|
||||
render() {
|
||||
const {
|
||||
editing,
|
||||
dataIndex,
|
||||
title,
|
||||
inputType,
|
||||
record,
|
||||
index,
|
||||
...restProps
|
||||
} = this.props;
|
||||
return (
|
||||
<EditableContext.Consumer>
|
||||
{(form) => {
|
||||
const { getFieldDecorator } = form;
|
||||
return (
|
||||
<td {...restProps}>
|
||||
{editing ? (
|
||||
<FormItem>
|
||||
{getFieldDecorator(dataIndex, {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: `Please Input ${title}!`,
|
||||
},
|
||||
],
|
||||
initialValue: record[dataIndex],
|
||||
})(this.getInput())}
|
||||
</FormItem>
|
||||
) : (
|
||||
restProps.children
|
||||
)}
|
||||
</td>
|
||||
);
|
||||
}}
|
||||
</EditableContext.Consumer>
|
||||
);
|
||||
}
|
||||
}
|
||||
</div>
|
||||
);
|
||||
|
||||
class EditableTable extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { data, editingKey: '' };
|
||||
this.columns = [
|
||||
{
|
||||
title: 'name',
|
||||
dataIndex: 'name',
|
||||
width: '25%',
|
||||
editable: true,
|
||||
},
|
||||
{
|
||||
title: 'age',
|
||||
dataIndex: 'age',
|
||||
width: '15%',
|
||||
editable: true,
|
||||
},
|
||||
{
|
||||
title: 'address',
|
||||
dataIndex: 'address',
|
||||
width: '40%',
|
||||
editable: true,
|
||||
},
|
||||
{
|
||||
title: 'operation',
|
||||
dataIndex: 'operation',
|
||||
render: (text, record) => {
|
||||
const editable = this.isEditing(record);
|
||||
return (
|
||||
<div className="editable-row-operations">
|
||||
{editable ? (
|
||||
this.columns = [{
|
||||
title: 'name',
|
||||
dataIndex: 'name',
|
||||
width: '25%',
|
||||
render: (text, record) => this.renderColumns(text, record, 'name'),
|
||||
}, {
|
||||
title: 'age',
|
||||
dataIndex: 'age',
|
||||
width: '15%',
|
||||
render: (text, record) => this.renderColumns(text, record, 'age'),
|
||||
}, {
|
||||
title: 'address',
|
||||
dataIndex: 'address',
|
||||
width: '40%',
|
||||
render: (text, record) => this.renderColumns(text, record, 'address'),
|
||||
}, {
|
||||
title: 'operation',
|
||||
dataIndex: 'operation',
|
||||
render: (text, record) => {
|
||||
const { editable } = record;
|
||||
return (
|
||||
<div className="editable-row-operations">
|
||||
{
|
||||
editable ?
|
||||
<span>
|
||||
<EditableContext.Consumer>
|
||||
{form => (
|
||||
<a
|
||||
href="javascript:;"
|
||||
onClick={() => this.save(form, record.key)}
|
||||
>
|
||||
Save
|
||||
</a>
|
||||
)}
|
||||
</EditableContext.Consumer>
|
||||
<Popconfirm
|
||||
title="Sure to cancel?"
|
||||
onConfirm={() => this.cancel(record.key)}
|
||||
>
|
||||
<a onClick={() => this.save(record.key)}>Save</a>
|
||||
<Popconfirm title="Sure to cancel?" onConfirm={() => this.cancel(record.key)}>
|
||||
<a>Cancel</a>
|
||||
</Popconfirm>
|
||||
</span>
|
||||
) : (
|
||||
<a onClick={() => this.edit(record.key)}>Edit</a>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
: <a onClick={() => this.edit(record.key)}>Edit</a>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
];
|
||||
}];
|
||||
this.state = { data };
|
||||
this.cacheData = data.map(item => ({ ...item }));
|
||||
}
|
||||
isEditing = (record) => {
|
||||
return record.key === this.state.editingKey;
|
||||
};
|
||||
edit(key) {
|
||||
this.setState({ editingKey: key });
|
||||
}
|
||||
save(from, key) {
|
||||
from.validateFields((error, row) => {
|
||||
if (error) {
|
||||
return;
|
||||
}
|
||||
const newData = [...this.state.data];
|
||||
const index = newData.findIndex(item => key === item.key);
|
||||
if (index > -1) {
|
||||
const item = newData[index];
|
||||
newData.splice(index, 1, {
|
||||
...item,
|
||||
...row,
|
||||
});
|
||||
this.setState({ data: newData, editingKey: '' });
|
||||
} else {
|
||||
newData.push(data);
|
||||
this.setState({ data: newData, editingKey: '' });
|
||||
}
|
||||
});
|
||||
}
|
||||
cancel = () => {
|
||||
this.setState({ editingKey: '' });
|
||||
};
|
||||
render() {
|
||||
const components = {
|
||||
body: {
|
||||
row: EditableFormRow,
|
||||
cell: EditableCell,
|
||||
},
|
||||
};
|
||||
|
||||
const columns = this.columns.map((col) => {
|
||||
if (!col.editable) {
|
||||
return col;
|
||||
}
|
||||
return {
|
||||
...col,
|
||||
onCell: record => ({
|
||||
record,
|
||||
inputType: col.dataIndex === 'age' ? 'number' : 'text',
|
||||
dataIndex: col.dataIndex,
|
||||
title: col.title,
|
||||
editing: this.isEditing(record),
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
renderColumns(text, record, column) {
|
||||
return (
|
||||
<Table
|
||||
components={components}
|
||||
bordered
|
||||
dataSource={this.state.data}
|
||||
columns={columns}
|
||||
<EditableCell
|
||||
editable={record.editable}
|
||||
value={text}
|
||||
onChange={value => this.handleChange(value, record.key, column)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
handleChange(value, key, column) {
|
||||
const newData = [...this.state.data];
|
||||
const target = newData.filter(item => key === item.key)[0];
|
||||
if (target) {
|
||||
target[column] = value;
|
||||
this.setState({ data: newData });
|
||||
}
|
||||
}
|
||||
edit(key) {
|
||||
const newData = [...this.state.data];
|
||||
const target = newData.filter(item => key === item.key)[0];
|
||||
if (target) {
|
||||
target.editable = true;
|
||||
this.setState({ data: newData });
|
||||
}
|
||||
}
|
||||
save(key) {
|
||||
const newData = [...this.state.data];
|
||||
const target = newData.filter(item => key === item.key)[0];
|
||||
if (target) {
|
||||
delete target.editable;
|
||||
this.setState({ data: newData });
|
||||
this.cacheData = newData.map(item => ({ ...item }));
|
||||
}
|
||||
}
|
||||
cancel(key) {
|
||||
const newData = [...this.state.data];
|
||||
const target = newData.filter(item => key === item.key)[0];
|
||||
if (target) {
|
||||
Object.assign(target, this.cacheData.filter(item => key === item.key)[0]);
|
||||
delete target.editable;
|
||||
this.setState({ data: newData });
|
||||
}
|
||||
}
|
||||
render() {
|
||||
return <Table bordered dataSource={this.state.data} columns={this.columns} />;
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.render(<EditableTable />, mountNode);
|
||||
```
|
||||
````
|
||||
|
||||
```css
|
||||
````css
|
||||
.editable-row-operations a {
|
||||
margin-right: 8px;
|
||||
}
|
||||
```
|
||||
````
|
||||
|
||||
@@ -17,12 +17,10 @@ title:
|
||||
|
||||
Use `filters` to generate filter menu in columns, `onFilter` to determine filtered result, and `filterMultiple` to indicate whether it's multiple or single selection.
|
||||
|
||||
Use `sorter` to make a column sortable. `sorter` can be a function of the type `function(a, b) { ... }` for sorting data locally.
|
||||
Use `sorter` to make a column sortable. `sorter` can be a function `function(a, b) { ... }` for sorting data locally.
|
||||
|
||||
Uses `defaultSortOrder` to make a column sorted by default.
|
||||
|
||||
If a `sortOrder` or `defaultSortOrder` is specified with the value `ascend` or `descend`, you can access this value from within the function passed to the `sorter` as explained above. Such a function can take the form: `function(a, b, sortOrder) { ... }`.
|
||||
|
||||
````jsx
|
||||
import { Table } from 'antd';
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ title:
|
||||
|
||||
Using JSX style API (introduced in 2.5.0)
|
||||
|
||||
> Since this is just a syntax sugar for the prop `columns`, you can't compose `Column` and `ColumnGroup` with other Components.
|
||||
> Since this is just a syntax sugar for the prop `columns`, so that you can't compose `Column` and `ColumnGroup` with other Components.
|
||||
|
||||
````jsx
|
||||
import { Table, Icon, Divider } from 'antd';
|
||||
|
||||
@@ -3,7 +3,6 @@ import * as ReactDOM from 'react-dom';
|
||||
import Menu, { SubMenu, Item as MenuItem } from 'rc-menu';
|
||||
import closest from 'dom-closest';
|
||||
import classNames from 'classnames';
|
||||
import shallowequal from 'shallowequal';
|
||||
import Dropdown from '../dropdown';
|
||||
import Icon from '../icon';
|
||||
import Checkbox from '../checkbox';
|
||||
@@ -44,15 +43,7 @@ export default class FilterMenu<T> extends React.Component<FilterMenuProps<T>, F
|
||||
selectedKeys: string[];
|
||||
visible: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* if the state is visible the component should ignore updates on selectedKeys prop to avoid
|
||||
* that the user selection is lost
|
||||
* this happens frequently when a table is connected on some sort of realtime data
|
||||
* Fixes https://github.com/ant-design/ant-design/issues/10289 and
|
||||
* https://github.com/ant-design/ant-design/issues/10209
|
||||
*/
|
||||
if ('selectedKeys' in nextProps && !shallowequal(this.props.selectedKeys, nextProps.selectedKeys)) {
|
||||
if ('selectedKeys' in nextProps) {
|
||||
newState.selectedKeys = nextProps.selectedKeys;
|
||||
}
|
||||
if ('filterDropdownVisible' in column) {
|
||||
@@ -115,11 +106,12 @@ export default class FilterMenu<T> extends React.Component<FilterMenuProps<T>, F
|
||||
|
||||
renderMenuItem(item: ColumnFilterItem) {
|
||||
const { column } = this.props;
|
||||
const { selectedKeys } = this.state;
|
||||
const multiple = ('filterMultiple' in column) ? column.filterMultiple : true;
|
||||
const input = multiple
|
||||
? <Checkbox checked={selectedKeys.indexOf(item.value.toString()) >= 0} />
|
||||
: <Radio checked={selectedKeys.indexOf(item.value.toString()) >= 0} />;
|
||||
const input = multiple ? (
|
||||
<Checkbox checked={this.state.selectedKeys.indexOf(item.value.toString()) >= 0} />
|
||||
) : (
|
||||
<Radio checked={this.state.selectedKeys.indexOf(item.value.toString()) >= 0} />
|
||||
);
|
||||
|
||||
return (
|
||||
<MenuItem key={item.value}>
|
||||
@@ -153,7 +145,7 @@ export default class FilterMenu<T> extends React.Component<FilterMenuProps<T>, F
|
||||
}
|
||||
|
||||
handleMenuItemClick = (info: { keyPath: string, key: string }) => {
|
||||
if (!info.keyPath || info.keyPath.length <= 1) {
|
||||
if (info.keyPath.length <= 1) {
|
||||
return;
|
||||
}
|
||||
const keyPathOfSelectedItem = this.state.keyPathOfSelectedItem;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Store } from './createStore';
|
||||
import { RadioChangeEvent } from '../radio';
|
||||
import { CheckboxChangeEvent } from '../checkbox';
|
||||
|
||||
export type CompareFn<T> = ((a: T, b: T, sortOrder?: 'ascend' | 'descend') => number);
|
||||
export type CompareFn<T> = ((a: T, b: T) => number);
|
||||
export type ColumnFilterItem = { text: string; value: string, children?: ColumnFilterItem[] };
|
||||
|
||||
export interface ColumnProps<T> {
|
||||
@@ -28,7 +28,7 @@ export interface ColumnProps<T> {
|
||||
fixed?: boolean | ('left' | 'right');
|
||||
filterIcon?: React.ReactNode;
|
||||
filteredValue?: any[];
|
||||
sortOrder?: 'ascend' | 'descend';
|
||||
sortOrder?: boolean | ('ascend' | 'descend');
|
||||
children?: ColumnProps<T>[];
|
||||
onCellClick?: (record: T, event: any) => void;
|
||||
onCell?: (record: T) => any;
|
||||
@@ -59,14 +59,12 @@ export interface TableLocale {
|
||||
}
|
||||
|
||||
export type RowSelectionType = 'checkbox' | 'radio';
|
||||
export type SelectionSelectFn<T> = (record: T, selected: boolean, selectedRows: Object[], nativeEvent: Event) => any;
|
||||
export type SelectionSelectFn<T> = (record: T, selected: boolean, selectedRows: Object[]) => any;
|
||||
|
||||
export interface TablePaginationConfig extends PaginationProps {
|
||||
position?: 'top' | 'bottom' | 'both';
|
||||
}
|
||||
|
||||
export type TableSelectWay = 'onSelect' | 'onSelectAll' | 'onSelectInvert';
|
||||
|
||||
export interface TableRowSelection<T> {
|
||||
type?: RowSelectionType;
|
||||
selectedRowKeys?: string[] | number[];
|
||||
@@ -129,7 +127,7 @@ export interface TableState<T> {
|
||||
pagination: TablePaginationConfig;
|
||||
filters: TableStateFilters;
|
||||
sortColumn: ColumnProps<T> | null;
|
||||
sortOrder: 'ascend' | 'descend' | undefined;
|
||||
sortOrder: string;
|
||||
}
|
||||
|
||||
export type SelectionItemSelectFn = (key: string[]) => any;
|
||||
@@ -173,14 +171,6 @@ export interface SelectionBoxState {
|
||||
checked?: boolean;
|
||||
}
|
||||
|
||||
export interface SelectionInfo<T> {
|
||||
selectWay: TableSelectWay;
|
||||
record?: T;
|
||||
checked?: boolean;
|
||||
changeRowKeys?: React.Key[];
|
||||
nativeEvent?: Event;
|
||||
}
|
||||
|
||||
export interface FilterMenuProps<T> {
|
||||
locale: TableLocale;
|
||||
selectedKeys: string[];
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
&[colspan] {
|
||||
text-align: center;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.@{iconfont-css-prefix}-filter,
|
||||
@@ -78,12 +79,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-thead > tr:not(:last-child) > th {
|
||||
&[colspan] {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&-tbody > tr > td {
|
||||
border-bottom: @border-width-base @border-style-base @border-color-split;
|
||||
transition: all .3s;
|
||||
@@ -277,15 +272,14 @@
|
||||
height: 4px;
|
||||
transition: all .3s;
|
||||
position: relative;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&-down {
|
||||
margin-top: 1.5px;
|
||||
}
|
||||
|
||||
.@{iconfont-css-prefix}-caret-up {
|
||||
margin-top: 0.5px;
|
||||
.@{iconfont-css-prefix}-caret-down {
|
||||
top: -1.5px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +320,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.@{table-prefix-cls}-thead > tr:not(:last-child) > th {
|
||||
.@{table-prefix-cls}-thead > tr > th {
|
||||
border-bottom: @border-width-base @border-style-base @border-color-split;
|
||||
}
|
||||
|
||||
@@ -362,10 +356,6 @@
|
||||
border-radius: @border-radius-base;
|
||||
box-shadow: @box-shadow-base;
|
||||
|
||||
.@{ant-prefix}-checkbox-input {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.@{ant-prefix}-dropdown-menu {
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
@@ -509,7 +499,6 @@
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
table {
|
||||
width: auto;
|
||||
min-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,7 +837,7 @@ exports[`renders ./components/tabs/demo/position.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-select-arrow"
|
||||
style="user-select:none;-webkit-user-select:none"
|
||||
unselectable="on"
|
||||
unselectable="unselectable"
|
||||
>
|
||||
<b />
|
||||
</span>
|
||||
|
||||
@@ -10,30 +10,28 @@ export interface TimelineProps {
|
||||
pending?: React.ReactNode;
|
||||
pendingDot?: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
reverse?: boolean;
|
||||
}
|
||||
|
||||
export default class Timeline extends React.Component<TimelineProps, any> {
|
||||
static Item = TimelineItem as React.ClassicComponentClass<TimeLineItemProps>;
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-timeline',
|
||||
reverse: false,
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
prefixCls,
|
||||
pending = null, pendingDot,
|
||||
children, className, reverse,
|
||||
...restProps,
|
||||
} = this.props;
|
||||
const { prefixCls, children, pending, pendingDot, className, ...restProps } = this.props;
|
||||
const pendingNode = typeof pending === 'boolean' ? null : pending;
|
||||
const classString = classNames(prefixCls, {
|
||||
[`${prefixCls}-pending`]: !!pending,
|
||||
[`${prefixCls}-reverse`]: !!reverse,
|
||||
}, className);
|
||||
|
||||
const pendingItem = !!pending ? (
|
||||
// Remove falsy items
|
||||
const truthyItems = React.Children.toArray(children).filter(item => !!item);
|
||||
const items = React.Children.map(truthyItems, (ele: React.ReactElement<any>, idx) =>
|
||||
React.cloneElement(ele, {
|
||||
last: idx === (React.Children.count(truthyItems) - 1),
|
||||
}),
|
||||
);
|
||||
const pendingItem = (!!pending) ? (
|
||||
<TimelineItem
|
||||
pending={!!pending}
|
||||
dot={pendingDot || <Icon type="loading" />}
|
||||
@@ -41,29 +39,10 @@ export default class Timeline extends React.Component<TimelineProps, any> {
|
||||
{pendingNode}
|
||||
</TimelineItem>
|
||||
) : null;
|
||||
|
||||
const timeLineItems = !!reverse
|
||||
? [pendingItem, ...React.Children.toArray(children).reverse()]
|
||||
: [...React.Children.toArray(children), pendingItem];
|
||||
|
||||
// Remove falsy items
|
||||
const truthyItems = timeLineItems.filter(item => !!item);
|
||||
const itemsCount = React.Children.count(truthyItems);
|
||||
const lastCls = `${prefixCls}-item-last`;
|
||||
const items = React.Children.map(truthyItems, (ele: React.ReactElement<any>, idx) =>
|
||||
React.cloneElement(ele, {
|
||||
className: classNames([
|
||||
ele.props.className,
|
||||
(!reverse && !!pending)
|
||||
? (idx === itemsCount - 2) ? lastCls : ''
|
||||
: (idx === itemsCount - 1) ? lastCls : '',
|
||||
]),
|
||||
}),
|
||||
);
|
||||
|
||||
return (
|
||||
<ul {...restProps} className={classString}>
|
||||
{items}
|
||||
{pendingItem}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ export interface TimeLineItemProps {
|
||||
color?: string;
|
||||
dot?: React.ReactNode;
|
||||
pending?: boolean;
|
||||
last?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
@@ -14,14 +15,16 @@ export default class TimelineItem extends React.Component<TimeLineItemProps, any
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-timeline',
|
||||
color: 'blue',
|
||||
last: false,
|
||||
pending: false,
|
||||
};
|
||||
|
||||
render() {
|
||||
const { prefixCls, className, color = '', children, pending, dot, ...restProps } = this.props;
|
||||
const { prefixCls, className, color = '', last, children, pending, dot, ...restProps } = this.props;
|
||||
|
||||
const itemClassName = classNames({
|
||||
[`${prefixCls}-item`]: true,
|
||||
[`${prefixCls}-item-last`]: last,
|
||||
[`${prefixCls}-item-pending`]: pending,
|
||||
}, className);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user