From 7b3d03c411f1822c8836ea72723bfe873b9cc38b Mon Sep 17 00:00:00 2001 From: Kiku Date: Fri, 14 Jun 2019 17:05:51 +0300 Subject: [PATCH] fix (#3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add fault-tolerant processing for rowSelection.getCheckboxProps * Upload prop onRemove: allow Promise as return type * onDragEnter的函数定义缺少一个expandedKeys:string[]? 官方的示例里有expandedKeys, 可是typescript定义里没有,所以扩展一下 * Fix docs (#16637) * Format (#16639) * `==` to `===` close #16640 * fix close animation * Update drawer.less * fix space missing in button (#16551) * feat: Add Mentions component (#16532) * init * first demo * support empty * add loading support * add form sample * update form sample * omit value & defaultValue * add 2 rest demo * placement support * update docs * fix test * update docs * add test case * fix lint * follow textarea style * update docs style * :lipstick: unified Cascader selected style with Select * docs: Add the changelog of 3.18.2 (#16666) * Bump 3.18.2 * fix form typescript doc * prettier md files * Fix stylelint errors * Add renovate.json * Update renovate.json * Refined translation of St.Exupery quote including link to quote site * fix horizontal divider style * :up: support ESC to close drawer * :white_check_mark: update snapshots * :lipstick: improve code style of Drawer * update drawer version * update config-provider test * fix shouldComponentUpdate * Upload prop onRemove: fix action https://github.com/react-component/upload/tree/d0cf0eecee3b31888791f8c57acddb575bd259d4#api * Update dependency logrocket to v1 * :lipstick: chore some documents style * :memo: update customize theme * :up: rc-drawer 1.9.3 * :clapper: Add example for Select ``optionLabelProp` prop, #16709 * :white_check_mark: update snapshots * :lipstick: fix emoji lint problem https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md * New component Descriptions (#14645) * add new component: DescriptionList * add warning message * docs: fix doc typo * feat: implement the size attribute * docs: fix doc typo * refactor: use new name Descriptions * test: snapshots updated * feat: support react15 * style: fix code style warring * style: better var name * style: better code style * style: merge css class * feat: add responsive config * fix: fix error title * style: use @border-radius-base * update snapshot * feat: set default column * test: add test script * style: fix property defaultProps is useless error * style: more robust code * style: fix codereview warning * style: fix review warning * use responsiveObserveserve * fix review warning * bug: add childrenArray copy,prevent changes to incoming parameters * fix dom error * fix typo * fix test * don't use this * snapshot updated * prettier md * remove descriptions md text * new rendering method * doc :add dot * style: add right border * Update index.en-US.md add missing prop `showTitle` in documentation of Pagination * adjust Carousel children change goto Logic (#16756) * :memo: Add Programmatic Usage of antd colors * update preview demo * :bug: Fix Cascader displayRender not interactive close #16738 and #10433 this bug had been fixed in bc4143f before, but it was broken by #12407 here we change another method to fix #12395 * Create FUNDING.yml * :memo: Add opencollective link * upload disabled remove * feat: Steps support clickable (#16773) * support clickable * update snapshot * update desc * Locale (feat #16752): Added Latvian localization (#16780) * update getPopupContainer (#16778) since select/index.d.ts requires getPopupContainer={triggerNode => HTMLElement} but parentNode actually is not HTMLElement. * Remove ancient prop types (#16705) * Remove ancient Modal.propTypes.align and Progress.propTypes.size * Remove linkRender and nameRender from Breadcrumb * :bug: Fix Input parser type close #15226 * feat: New calendar apis, headerRender method (#16535) * added new calendar api, renderHeader now we can customize calendar header * fixed typo for tests * error handling for renderHeader * covering all cases with tests * fixed tests and change console error to warning * fixed feedbacks and code optimization * cleanup callback function arguments * removed unused changes * fixed tests * added extra classes * fixed some comments * tying to fix test for remote * tying to fix test for remote in my local machin it works fine * tying to fix test for remote in my local machin it works fine * tying to fix test for remote in my local machin it works fine * updated test snapshots * fixed comment * fixed linting * fixed some texts * added header for CN and added argument types * removed extra row * Allow users to define where tooltips should appear on slider marks (#16641) * feat: add disable style to upload component * Fix the problem that the Slider's Tooltip is in the incorrect position when use modal (#16717) * Fix incorrect position of tooltip when use slider * Remove useless comment * Reduce code * Update * getTooltipPopupContainer default to body * Public Slider's ref * Add docs * Update docs * :lipstick: Correct Statistic font color (#16801) close #15514 * docs: 3.19.0 changelog (#16796) * add changelog * add #16535 * update * add missing changelog * add #16801 changelog * adjust description * more desc * more info * change logo * fix: mentions ts definition update (#16814) * fix mentions ts definition * adjust logic of Mentions * fix: Tooltip not hidden when menu is in control mode (#16812) * fix: Select ts define (#16817) * fix: Descriptions warning should work as expect (#16819) * fix warning * add MockDate * Fix typescript compile error (#16816) * :bug: Fix typo name icons, add warning and update docs (#16818) close #13007 close #16810 deps: ant-design/ant-design-icons#63 * docs: 3.19.1 change-log (#16820) * update changelog * add missing one * :white_check_mark: Add test case for TransButton * fix: Tabs card vertical support scroll (#16825) * Update util.test.js * fix(Transfer): set state on an unmounted component (#16822) * chore: Add warning if use `inlineCollapsed` under Sider (#16826) * typescript: adding forceSubmenuRender as MenuProps * :lipstick: Optimize examples code style * Update index.en-US.md * :zap: export TypographyProps close #15190 * add onChange prop type definition to Steps * add onChange prop type definition to Steps (#16845) * add semicolon * fix: add webkitRelativePath (#16850) * fix: fix type of RcFile * fix: fix type of action in UploadProps * Update xhr2 requirement from ^0.1.4 to ^0.2.0 Updates the requirements on [xhr2](https://github.com/pwnall/node-xhr2) to permit the latest version. - [Release notes](https://github.com/pwnall/node-xhr2/releases) - [Commits](https://github.com/pwnall/node-xhr2/compare/v0.1.4...0.2.0) * Remove okButtonDisabled/cancelButtonDisabled never used prop defs - Also remove them from the CHANGELOG because they were never actually implemented, the prop was renamed to okButtonProps/cancelButtonProps within PR #10955 but these prop defs were left behind and ended up incorrectly included in the CHANGELOG. * 修复Breadcrumb.tsx 中处理route.children 路径不对 {itemRender(child, params, routes, [...paths, this.getPath(child.path, params)])} itemRender(...args) 中路径应该到拼接当前child.path * fix Breadcrumb.tsx getPath() 参数赋默认值 * fix: use @error-color & @warning-color instead of @text-color-danger & @text-color-warning #16856 * fix Breadcrumb.tsx 对于子路径是否为空进行判断 * add antd pro 4.0 badge (#16894) * Update ansi-styles requirement from ^3.2.1 to ^4.0.0 Updates the requirements on [ansi-styles](https://github.com/chalk/ansi-styles) to permit the latest version. - [Release notes](https://github.com/chalk/ansi-styles/releases) - [Commits](https://github.com/chalk/ansi-styles/compare/v3.2.1...v4.0.0) * doc: changelog 3.19.2 * doc: changelog * tweak: order changelog * doc: changelog * doc: changelog * doc: changelog * doc: changelog * doc: format * doc: changelog * :memo: changelog * :memo: changelog * release: 3.19.2 * :bug: fixes #16871 Cascader - Space during search * :wrench: Add packtracker * Remove useless type * fix: Transfer render Empty when customize without data (#16925) * fix: Hide Spinner of InputNumber when type is number (#16926) * fix: Hide Spinner of InputNumber when type is number * Firefox not obedient * fix: Breadcrumb validateDOMNesting warning (#16929) * :bug: Fix Breadcrumb validateDOMNesting warning ``` Warning: validateDOMNesting(...): cannot appear as a descendant of . in a (created by Context.Consumer) in span (created by Context.Consumer) in a (created by Context.Consumer) in Trigger (created by Dropdown) in Dropdown (created by Context.Consumer) in Dropdown (created by Context.Consumer) in span (created by Context.Consumer) in BreadcrumbItem (created by Context.Consumer) in div (created by Context.Consumer) in Breadcrumb (created by TestBreadcrumb) in TestBreadcrumb ``` * :white_check_mark: update snapshots * Update Breadcrumb.tsx * :bug: Fix abnormal scrollbar in Chrome when rowSelection and title work together close #16912 * :bug: Fix Table header extra scrollbar control close #4637 close #14211 https://github.com/react-component/table/pull/333 * :white_check_mark: update snapshots * :lipstick: Fix scrollbar border bottom * :white_check_mark: update snapshots * :memo: fix size toc overflow style * :lipstick: use marginRight remind developer * fix: test ci * rebase * fix: Table miss border-raidus in Firefox (#16957) * Revert "Merge pull request #16174 from ant-design/fix-table-chrome" This reverts commit 686c1fc34628b95354b3ed7158e27afeba8db84f, reversing changes made to 924afc2706219d348e3356c568be2f8578d2247f. * firefox only * add comment * :white_check_mark: update snapshots * :up: upgrade all deps to latest version * :up: fix for typescript@3.5 * :wrench: ignore other files for packtracker * Suppress autoprefixer warning * add new less var * less variable should be extended * :white_check_mark: Fix ci * :memo: Add FAQ for DatePicker/RangePicker mode prop usage * fix packtracker exclude_assets * :bug: Fix Divider `orientation="center"` style close #16987 * Add missing spanish translations * Export TextProps and update english in error * :white_check_mark: Fix test snapshots * Fix typo * Update colors.zh-CN.md * docs: 3.19.3 change-log (#16998) * chore: update package.json * fix: Table with sort should reset to first page (#17020) * sort reset pagination * add test case * :bug: Fix margin issue of PageHeader extra close #17025 * :arrow_up: Update majo requirement from ^0.7.1 to ^0.8.0 Updates the requirements on [majo](https://github.com/egoist/majo) to permit the latest version. - [Release notes](https://github.com/egoist/majo/releases) - [Commits](https://github.com/egoist/majo/compare/v0.7.1...v0.8.0) Signed-off-by: dependabot-preview[bot] * :bug: Fix margin issue of PageHeader extra continually * update calendar (#17038) * :lipstick: Keep submenu selected style * Update index.less * Update default.less * Update certain-category.md * Update uncertain-category.md * :white_check_mark: update snapshots * :memo: Fix image in feedback spec documentation * :white_check_mark: update snapshots * use calc to fix tree line (#17055) * fix: add link button to basic demo of button docs * :lipstick: adjust bordered table header scrollbar style * :lipstick: optimize bordered table header scrollbar style continue after #17065 * Fix grammar on message documentation * fix: remove margin for collapse arrow (#17009) * remove margin for collapse arrow * change translateY to -21px in collapse * remove line-height to center arrow * Fixing date formats for Arabic-Egypt locale * Update index.zh-CN.md add getPopupContainer props * :bug: Fix Input not align with other components in Chrome close #17082 --- .github/FUNDING.yml | 8 + .github/PULL_REQUEST_TEMPLATE.md | 8 +- .github/PULL_REQUEST_TEMPLATE/pr_cn.md | 8 +- CHANGELOG.en-US.md | 90 +- CHANGELOG.zh-CN.md | 89 +- .../__snapshots__/index.test.js.snap | 2 + components/_util/__tests__/util.test.js | 56 + components/_util/responsiveObserve.ts | 101 ++ components/_util/wave.tsx | 2 +- .../__tests__/__snapshots__/demo.test.js.snap | 1 + .../auto-complete/demo/certain-category.md | 21 +- components/auto-complete/demo/options.md | 2 +- .../auto-complete/demo/uncertain-category.md | 18 +- components/auto-complete/index.zh-CN.md | 1 + components/breadcrumb/Breadcrumb.tsx | 36 +- components/breadcrumb/BreadcrumbItem.tsx | 4 +- .../__snapshots__/Breadcrumb.test.js.snap | 63 +- .../__tests__/__snapshots__/demo.test.js.snap | 129 +- components/breadcrumb/demo/overlay.md | 22 +- components/breadcrumb/index.zh-CN.md | 2 +- .../__snapshots__/index.test.js.snap | 11 + components/button/__tests__/index.test.js | 11 + components/button/button.tsx | 27 +- components/button/demo/basic.md | 4 +- components/calendar/Header.tsx | 66 +- .../__tests__/__snapshots__/demo.test.js.snap | 1069 +++++++++++++++++ components/calendar/__tests__/index.test.js | 106 ++ components/calendar/demo/customize-header.md | 107 ++ components/calendar/index.en-US.md | 31 +- components/calendar/index.tsx | 7 +- components/calendar/index.zh-CN.md | 27 +- components/calendar/locale/lv_LV.tsx | 2 + components/carousel/__tests__/index.test.js | 28 +- components/carousel/index.tsx | 2 +- components/cascader/index.tsx | 3 +- components/cascader/style/index.less | 12 +- components/checkbox/demo/group.md | 8 +- components/checkbox/style/mixin.less | 2 +- components/collapse/style/index.less | 2 - components/comment/demo/editor.md | 2 +- components/comment/style/index.less | 10 +- .../__snapshots__/components.test.js.snap | 6 + components/config-provider/index.tsx | 4 +- components/config-provider/renderEmpty.tsx | 1 + .../date-picker/demo/presetted-ranges.md | 2 +- components/date-picker/index.en-US.md | 4 + components/date-picker/index.zh-CN.md | 4 + components/date-picker/locale/ar_EG.tsx | 4 + components/date-picker/locale/lv_LV.tsx | 19 + .../__tests__/__snapshots__/demo.test.js.snap | 611 ++++++++++ .../__snapshots__/index.test.js.snap | 101 ++ .../descriptions/__tests__/demo.test.js | 3 + .../descriptions/__tests__/index.test.js | 112 ++ components/descriptions/demo/basic.md | 31 + components/descriptions/demo/border.md | 50 + components/descriptions/demo/responsive.md | 52 + components/descriptions/demo/size.md | 68 ++ components/descriptions/index.en-US.md | 30 + components/descriptions/index.tsx | 256 ++++ components/descriptions/index.zh-CN.md | 31 + components/descriptions/style/index.less | 118 ++ components/descriptions/style/index.tsx | 2 + .../__tests__/__snapshots__/demo.test.js.snap | 2 +- components/divider/index.tsx | 4 +- components/divider/style/index.less | 5 +- .../__snapshots__/Drawer.test.js.snap | 6 + .../__snapshots__/DrawerEvent.test.js.snap | 1 + components/drawer/index.tsx | 17 +- components/drawer/style/drawer.less | 2 + components/dropdown/style/index.less | 2 +- components/form/context.ts | 4 +- components/form/demo/style-check-debug.md | 5 +- components/form/index.en-US.md | 11 +- components/form/index.zh-CN.md | 11 +- components/form/style/index.less | 1 + components/grid/__tests__/index.test.js | 43 +- components/grid/row.tsx | 74 +- components/icon/__tests__/index.test.js | 18 + components/icon/utils.ts | 19 +- components/index.tsx | 4 + components/input-number/index.tsx | 2 +- components/input-number/style/index.less | 8 +- .../__tests__/__snapshots__/demo.test.js.snap | 5 +- components/input/demo/addon.md | 2 +- components/input/demo/group.md | 2 +- components/input/style/mixin.less | 4 +- .../__tests__/__snapshots__/demo.test.js.snap | 32 +- components/layout/__tests__/index.test.js | 23 +- .../layout/demo/custom-trigger-debug.md | 2 +- components/layout/demo/side.md | 2 +- components/layout/layout.tsx | 4 +- .../__snapshots__/index.test.js.snap | 77 +- components/locale-provider/demo/all.md | 4 +- components/locale-provider/es_ES.tsx | 16 + components/locale-provider/lv_LV.tsx | 42 + components/mention/index.en-US.md | 14 +- components/mention/index.tsx | 7 + components/mention/index.zh-CN.md | 14 +- .../__tests__/__snapshots__/demo.test.js.snap | 154 +++ components/mentions/__tests__/demo.test.js | 3 + components/mentions/__tests__/index.test.js | 87 ++ components/mentions/demo/async.md | 87 ++ components/mentions/demo/basic.md | 42 + components/mentions/demo/form.md | 81 ++ components/mentions/demo/placement.md | 29 + components/mentions/demo/prefix.md | 56 + components/mentions/demo/readonly.md | 45 + components/mentions/index.en-US.md | 54 + components/mentions/index.tsx | 165 +++ components/mentions/index.zh-CN.md | 64 + components/mentions/style/index.less | 156 +++ components/mentions/style/index.tsx | 5 + components/menu/MenuItem.tsx | 8 +- components/menu/demo/horizontal.md | 11 +- components/menu/demo/inline-collapsed.md | 2 +- components/menu/demo/inline.md | 11 +- components/menu/demo/sider-current.md | 2 +- components/menu/demo/theme.md | 2 +- components/menu/demo/vertical.md | 11 +- components/menu/index.tsx | 11 +- components/menu/style/index.less | 4 + components/message/demo/other.md | 6 +- components/modal/Modal.tsx | 3 - .../__snapshots__/Modal.test.js.snap | 2 + components/page-header/demo/actions.md | 2 +- components/page-header/index.tsx | 2 +- components/page-header/style/index.less | 8 +- components/pagination/index.en-US.md | 1 + components/pagination/style/index.less | 12 +- components/progress/progress.tsx | 1 - components/radio/demo/radiobutton.md | 41 +- components/radio/demo/radiogroup-more.md | 14 +- components/radio/demo/radiogroup-options.md | 12 +- components/radio/demo/radiogroup-with-name.md | 12 +- components/radio/demo/radiogroup.md | 6 +- components/radio/demo/size.md | 39 +- .../__tests__/__snapshots__/demo.test.js.snap | 85 ++ .../select/demo/automatic-tokenization.md | 2 +- components/select/demo/basic.md | 2 +- components/select/demo/coordinate.md | 2 +- .../select/demo/custom-dropdown-menu.md | 2 +- components/select/demo/label-in-value.md | 2 +- components/select/demo/multiple.md | 6 +- components/select/demo/option-label-prop.md | 61 + components/select/demo/search-box.md | 2 +- components/select/demo/search.md | 2 +- components/select/demo/select-users.md | 2 +- components/select/demo/size.md | 2 +- components/select/demo/suffix.md | 2 +- components/select/demo/tags.md | 2 +- components/select/index.en-US.md | 8 +- components/select/index.tsx | 5 +- components/select/index.zh-CN.md | 10 +- components/slider/index.en-US.md | 36 +- components/slider/index.tsx | 13 +- components/slider/index.zh-CN.md | 38 +- components/statistic/style/index.less | 2 + .../__tests__/__snapshots__/demo.test.js.snap | 208 ++++ components/steps/demo/clickable.md | 55 + .../steps/demo/customized-progress-dot.md | 2 +- components/steps/demo/error.md | 2 +- components/steps/demo/icon.md | 2 +- components/steps/demo/progress-dot.md | 2 +- components/steps/demo/simple.md | 2 +- components/steps/demo/small-size.md | 2 +- components/steps/demo/step-next.md | 2 +- components/steps/demo/vertical-small.md | 2 +- components/steps/demo/vertical.md | 2 +- components/steps/index.en-US.md | 21 +- components/steps/index.tsx | 1 + components/steps/index.zh-CN.md | 21 +- components/steps/style/index.less | 34 + components/style/color/colorPalette.less | 2 +- components/style/themes/default.less | 15 +- components/table/Table.tsx | 13 +- .../table/__tests__/Table.sorter.test.js | 19 + .../__tests__/__snapshots__/demo.test.js.snap | 8 +- components/table/demo/grouping-columns.md | 1 + components/table/index.en-US.md | 2 +- components/table/style/index.less | 284 +++-- .../__tests__/__snapshots__/demo.test.js.snap | 271 ++++- components/tabs/demo/basic.md | 2 +- components/tabs/demo/card-top.md | 2 +- components/tabs/demo/card.md | 2 +- components/tabs/demo/custom-add-trigger.md | 2 +- components/tabs/demo/custom-tab-bar-node.md | 2 +- components/tabs/demo/custom-tab-bar.md | 2 +- components/tabs/demo/disabled.md | 2 +- components/tabs/demo/editable-card.md | 2 +- components/tabs/demo/extra.md | 2 +- components/tabs/demo/icon.md | 2 +- components/tabs/demo/nest.md | 6 +- components/tabs/demo/position.md | 4 +- components/tabs/demo/slide.md | 40 +- components/tabs/style/card-style.less | 2 +- .../__snapshots__/index.test.js.snap | 970 ++++++++++++++- .../time-picker/__tests__/index.test.js | 2 +- components/time-picker/locale/lv_LV.tsx | 5 + components/time-picker/style/index.less | 11 + components/transfer/list.tsx | 33 +- components/transfer/renderListBody.tsx | 2 +- components/tree/Tree.tsx | 7 +- components/tree/demo/directory.md | 3 +- components/tree/style/index.less | 3 +- components/typography/Text.tsx | 4 +- components/typography/index.tsx | 2 +- components/typography/style/index.less | 4 +- components/upload/Upload.tsx | 4 +- components/upload/demo/picture-card.md | 17 +- components/upload/interface.tsx | 7 +- components/upload/style/index.less | 4 + docs/react/customize-theme.en-US.md | 2 +- docs/react/customize-theme.zh-CN.md | 2 +- docs/react/faq.en-US.md | 19 +- docs/react/faq.zh-CN.md | 19 +- docs/spec/colors.en-US.md | 31 + docs/spec/colors.zh-CN.md | 35 +- docs/spec/feedback.en-US.md | 2 +- docs/spec/feedback.zh-CN.md | 2 +- docs/spec/values.en-US.md | 2 +- package.json | 184 +-- renovate.json | 6 + site/bisheng.config.js | 2 + site/theme/en-US.js | 2 +- site/theme/static/toc.less | 3 +- site/theme/template/Content/ComponentDoc.jsx | 10 +- site/theme/template/IconDisplay/fields.ts | 3 + site/theme/template/IconDisplay/index.tsx | 2 +- site/theme/template/Layout/Header.jsx | 12 +- site/theme/zh-CN.js | 2 +- tests/__snapshots__/index.test.js.snap | 2 + webpack.config.js | 10 + 232 files changed, 7231 insertions(+), 979 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 components/_util/responsiveObserve.ts create mode 100644 components/calendar/demo/customize-header.md create mode 100644 components/calendar/locale/lv_LV.tsx create mode 100644 components/date-picker/locale/lv_LV.tsx create mode 100644 components/descriptions/__tests__/__snapshots__/demo.test.js.snap create mode 100644 components/descriptions/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/descriptions/__tests__/demo.test.js create mode 100644 components/descriptions/__tests__/index.test.js create mode 100644 components/descriptions/demo/basic.md create mode 100644 components/descriptions/demo/border.md create mode 100644 components/descriptions/demo/responsive.md create mode 100644 components/descriptions/demo/size.md create mode 100644 components/descriptions/index.en-US.md create mode 100644 components/descriptions/index.tsx create mode 100644 components/descriptions/index.zh-CN.md create mode 100644 components/descriptions/style/index.less create mode 100644 components/descriptions/style/index.tsx create mode 100644 components/locale-provider/lv_LV.tsx create mode 100644 components/mentions/__tests__/__snapshots__/demo.test.js.snap create mode 100644 components/mentions/__tests__/demo.test.js create mode 100644 components/mentions/__tests__/index.test.js create mode 100644 components/mentions/demo/async.md create mode 100644 components/mentions/demo/basic.md create mode 100644 components/mentions/demo/form.md create mode 100644 components/mentions/demo/placement.md create mode 100644 components/mentions/demo/prefix.md create mode 100644 components/mentions/demo/readonly.md create mode 100644 components/mentions/index.en-US.md create mode 100644 components/mentions/index.tsx create mode 100644 components/mentions/index.zh-CN.md create mode 100644 components/mentions/style/index.less create mode 100644 components/mentions/style/index.tsx create mode 100644 components/select/demo/option-label-prop.md create mode 100644 components/steps/demo/clickable.md create mode 100644 components/time-picker/locale/lv_LV.tsx create mode 100644 renovate.json diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000000..ccf1611407ac --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,8 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: ant-design +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +custom: # Replace with a single custom sponsorship URL diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1f2584044244..2e0551a1e66e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -43,10 +43,10 @@ Please makes sure that these form are filled before submitting your pull request Describe changes from userside, and list all potential break changes or other risks. ---> -| Language | Changelog | -|---|--- -| 🇺🇸 English | | -| 🇨🇳 Chinese | | +| Language | Changelog | +| ---------- | --------- | +| 🇺🇸 English | | +| 🇨🇳 Chinese | | ### ☑️ Self Check before Merge diff --git a/.github/PULL_REQUEST_TEMPLATE/pr_cn.md b/.github/PULL_REQUEST_TEMPLATE/pr_cn.md index 20df3bc34381..697e91882fe9 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pr_cn.md +++ b/.github/PULL_REQUEST_TEMPLATE/pr_cn.md @@ -43,10 +43,10 @@ > 从用户角度描述具体变化,以及可能的 breaking change 和其他风险? --> -| 语言 | 更新描述 | -|---|--- -| 🇺🇸 英文 | | -| 🇨🇳 中文 | | +| 语言 | 更新描述 | +| ------- | -------- | +| 🇺🇸 英文 | | +| 🇨🇳 中文 | | - 中文(可选): diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index f2cab1e935a9..6b32aa4938c3 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -15,6 +15,95 @@ timeline: true --- +## 3.19.3 + +`2019-06-06` + +- 📝 Add FAQ for DatePicker/RangePicker with `mode` cannot be selected. [#16984](https://github.com/ant-design/ant-design/pull/16984) +- 🐞 Fix Breadcrumb validateDOMNesting warning. [#16929](https://github.com/ant-design/ant-design/pull/16929) +- 🐞 Fix Breadcrumb path error when `children` is selected. [#16885](https://github.com/ant-design/ant-design/pull/16885) [@haianweifeng](https://github.com/haianweifeng) +- 🐞 Fix InputNumber with `number` type display native spinner. [#16926](https://github.com/ant-design/ant-design/pull/16926) +- 🐞 Fix Transfer render Empty when customize without data. [#16925](https://github.com/ant-design/ant-design/pull/16925) +- 🐞 **Fix Table header extra vertical scrollbar problem.** [#16950](https://github.com/ant-design/ant-design/pull/16950) +- 🐞 Fix Table miss `border-radius` in Firefox. [#16957](https://github.com/ant-design/ant-design/pull/16957) +- 🐞 Fix Table error when `rowSelection.getCheckboxProps()` has no return value. [#15224](https://github.com/ant-design/ant-design/pull/15224) +- 🐞 Fix Table abnormal scrollbar in Chrome when using `title` and `rowSelection`. + [#16934](https://github.com/ant-design/ant-design/pull/16934) +- 🐞 Fix Divider `orientation="center"` style. [#16988](https://github.com/ant-design/ant-design/pull/16988) +- 🐞 Fix Cascader error when type space. [#16918](https://github.com/ant-design/ant-design/pull/16918) [@Durisvk](https://github.com/Durisvk) +- 🐞 Fix missing spanish translations. [#17002](https://github.com/ant-design/ant-design/pull/17002) [@morellan](https://github.com/morellan) +- TypeScript + - 🐞 Fix Upload `RcFile` definition. [#16851](https://github.com/ant-design/ant-design/pull/16851) + - ⚡️ Export `TextProps` type in Typography. [#17003](https://github.com/ant-design/ant-design/pull/17003) [@Jarvis1010](https://github.com/Jarvis1010) + +## 3.19.2 + +`2019-06-01` + +- 🐞 Fix Tabs vertical card mode not scrollable. [#16825](https://github.com/ant-design/ant-design/pull/16825) +- 🐞 Fix Transfer warn `setStart` on an unmounted component. [#16822](https://github.com/ant-design/ant-design/pull/16822) [@shiningjason](https://github.com/shiningjason) +- 💄 Using less variables `@error-color`, `@warning-color` instead of `@text-color-danger`, `@text-color-warning`. [#16890](https://github.com/ant-design/ant-design/pull/16890) [@MrHeer](https://github.com/MrHeer) +- 💄 Add warning if Menu use `inlineCollapsed` under Sider. [#16826](https://github.com/ant-design/ant-design/pull/16826) +- TypeScript + - ⚡️ Add `forceSubmenuRender` into MenuProps. [#16827](https://github.com/ant-design/ant-design/pull/16827) + - ⚡️ Export `TypographyProps` type. [#16835](https://github.com/ant-design/ant-design/pull/16835) + - ⚡️ Add `onChange` prop type definition to Steps. [#16845](https://github.com/ant-design/ant-design/pull/16845) [@JonathanLee-LX](https://github.com/JonathanLee-LX) + - ⚡️ Add `webkitRelativePath` prop type definition to Upload. [#16850](https://github.com/ant-design/ant-design/pull/16850) [@DiamondYuan](https://github.com/DiamondYuan) + +## 3.19.1 + +`2019-05-27` + +- 🐞 Fix Tooltip not hidden when Menu collapsed in control mode. [#16812](https://github.com/ant-design/ant-design/pull/16812) +- 🐞 Fix Description warning with column count not correct. [#16819](https://github.com/ant-design/ant-design/pull/16819) +- 🐞 Correct typo icon names `canlendar` / `interation` to `calendar` / `interaction`. [#16818](https://github.com/ant-design/ant-design/pull/16818) +- TypeScript + - ⚡️ Fix Mentions definition. [#16814](https://github.com/ant-design/ant-design/pull/16814) + - ⚡️ Update Select `onSelect` & `onDeselect` prop definition. [#16817](https://github.com/ant-design/ant-design/pull/16817) + +## 3.19.0 + +`2019-05-26` + +- New Components: + - 🔥🔥🔥 [Mentions](https://ant.design/components/mentions-cn/) Provides Mentions component and origin Mention marked as deprecated. + - 🔥🔥🔥 [Descriptions](https://ant.design/components/descriptions-cn/) Display multiple read-only fields in groups. +- 🇱🇻 Add Latvian localization support. [#16780](https://github.com/ant-design/ant-design/pull/16780) [@kirbo](https://github.com/kirbo) +- 🌟 Drawer support close by press `ESC`. [#16694](https://github.com/ant-design/ant-design/pull/16694) +- 🌟 Steps support click to switch. [#16773](https://github.com/ant-design/ant-design/pull/16773) +- 🌟 Calendar support `headerRender` to customize header。[#16535](https://github.com/ant-design/ant-design/pull/16535) [@abgaryanharutyun](https://github.com/abgaryanharutyun) +- 🌟 Slider support `tooltipPlacement` to set tooltip position. [#16641](https://github.com/ant-design/ant-design/pull/16641) [@cmaster11](https://github.com/cmaster11) +- 🌟 Slider support `getTooltipPopupContainer` to customize tooltip container. [#16717](https://github.com/ant-design/ant-design/pull/16717) +- 🐞 Fix PageHeader horizontal divider style. [#16684](https://github.com/ant-design/ant-design/pull/16684) +- 🐞 Fix Carousel `initialSlide` not work when `children` count change. [#16756](https://github.com/ant-design/ant-design/pull/16756) +- 🐞 Fix Cascader `displayRender` not interactive. [#16782](https://github.com/ant-design/ant-design/pull/16782) +- 🐞 Fix Upload list still can be removed when `disabled`. [#16786](https://github.com/ant-design/ant-design/pull/16786) +- 💄 Update Upload `disabled` cursor style. [#16799](https://github.com/ant-design/ant-design/pull/16799) [@attacking](https://github.com/attacking) +- 💄 Correct Statistic font color. [#16801](https://github.com/ant-design/ant-design/pull/16801) +- TypeScript + - ⚡️ Update Upload `action` prop definition. [#16716](https://github.com/ant-design/ant-design/pull/16716) [@christophehurpeau](https://github.com/christophehurpeau) + - ⚡️ Update Upload `onRemove` prop definition. [#16570](https://github.com/ant-design/ant-design/pull/16570) [@christophehurpeau](https://github.com/christophehurpeau) + - ⚡️ Update Select `getPopupContainer` prop definition. [#16778](https://github.com/ant-design/ant-design/pull/16778) [@chj-damon](https://github.com/chj-damon) + - ⚡️ Update InputNumber `parse` prop definition. [#16797](https://github.com/ant-design/ant-design/pull/16797) + - ⚡️ Remove useless props definition. [#16705](https://github.com/ant-design/ant-design/pull/16705) [@sirlantis](https://github.com/sirlantis) + +## 3.18.2 + +`2019-05-20` + +- 🐞 Fix space missing for Button with mixed content. [#15342](https://github.com/ant-design/ant-design/issues/15342) +- 🐞 Fix active status missing for Carousel when `children` is changed. [#16583](https://github.com/ant-design/ant-design/issues/16583) +- 🐞 Fix panel not close when DatePicker is `blur` by upgrading `rc-calendar` requirement to version `9.13.3`. [#16588](https://github.com/ant-design/ant-design/issues/16588) +- 🐞 Fix style disorder for Form.Item with `help` prop and `margin-bottom` is negative. [#16584](https://github.com/ant-design/ant-design/pull/16584) [@sbusch](https://github.com/sbusch) +- 🐞 Fix Spin not align when set `font-size` style. [#15206](https://github.com/ant-design/ant-design/issues/15206) +- 🐞 Fix `selectedRows` missing when there is `childrenColumnName` in Table. [#16614](https://github.com/ant-design/ant-design/issues/16614) +- TypeScript + - ⚡️ Improve the definition of `children` prop for Breadcrumb. [#16550](https://github.com/ant-design/ant-design/pull/16550) [@Gin-X](https://github.com/Gin-X) + - ⚡️ Improve the definition of `onFieldsChange` params for Form. [#16577](https://github.com/ant-design/ant-design/pull/16577) [@SylvanasGone](https://github.com/SylvanasGone) + - ⚡️ Improve the definition of `dataSource` and `renderItem` for List. [#16587](https://github.com/ant-design/ant-design/issues/16587) + - ⚡️ Improve the definition of `onDragEnter` params for Tree. [#16638](https://github.com/ant-design/ant-design/pull/16638) [@eruca](https://github.com/eruca) + - ⚡️ Improve the definition of `event` for Tree。[#16624](https://github.com/ant-design/ant-design/pull/16624) [@ztplz](https://github.com/ztplz) + ## 3.18.1 `2019-05-13` @@ -1169,7 +1258,6 @@ Component Fixes / Enhancements: - 🐞 Cascader adds `fieldNames` and discards the misspelled `filedNames`. [#10896](https://github.com/ant-design/ant-design/issues/10896) - 🐞 Fix Timeline dot not working with Tooltip. [0e3b67e](https://github.com/ant-design/ant-design/commit/0e3b67e9999d867cc304f3be61a8a042a2ab92ee) - 🐞 Fix border radius when avatar has custom size. [e1e6523](https://github.com/ant-design/ant-design/commit/e1e6523452286ba56f20b73abad762a58ea7d7bc) -- 🌟 Add `okButtonDisabled` and `cancelButtonDisabled` props to disable ok button and cancel button. [#10955](https://github.com/ant-design/ant-design/pull/10955) ## 3.6.6 diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 9b29408b81f2..e31721aeb7bb 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -15,6 +15,94 @@ timeline: true --- +## 3.19.3 + +`2019-06-06` + +- 📝 增加 DatePicker/RangePicker 指定 `mode` 后无法选择的文档说明。[#16984](https://github.com/ant-design/ant-design/pull/16984) +- 🐞 修复 Breadcrumb 的 `validateDOMNesting` 警告信息。[#16929](https://github.com/ant-design/ant-design/pull/16929) +- 🐞 修复 Breadcrumb 选中子路由时浏览器路径问题。[#16885](https://github.com/ant-design/ant-design/pull/16885) [@haianweifeng](https://github.com/haianweifeng) +- 🐞 修复 InputNumber 设置 `number` 类型时会展示原生按钮的问题。[#16926](https://github.com/ant-design/ant-design/pull/16926) +- 🐞 修复 Transfer 在自定义列表为空时展示 Empty 样式。[#16925](https://github.com/ant-design/ant-design/pull/16925) +- 🐞 **修复 Table 头部多余的垂直滚动条样式。**[#16950](https://github.com/ant-design/ant-design/pull/16950) +- 🐞 修复 Table 的 `rowSelection.getCheckboxProps()` 在没有返回值时报错的问题。[#15224](https://github.com/ant-design/ant-design/pull/15224) +- 🐞 修复 Firefox 的 Table 丢失 `border-radius` 样式问题。[#16957](https://github.com/ant-design/ant-design/pull/16957) +- 🐞 修复 Table 当 `title` 和 `rowSelection` 同时指定时在 Chrome 下滚动条异常的问题。[#16934](https://github.com/ant-design/ant-design/pull/16934) +- 🐞 修复 Divider `orientation="center"` 时样式错位的问题。[#16988](https://github.com/ant-design/ant-design/pull/16988) +- 🐞 修复 Cascader 搜索时不支持空格输入的问题。[#16918](https://github.com/ant-design/ant-design/pull/16918) [@Durisvk](https://github.com/Durisvk) +- 🐞 修复部分组件的西班牙语言翻译。[#17002](https://github.com/ant-design/ant-design/pull/17002) [@morellan](https://github.com/morellan) +- TypeScript + - 🐞 修复 Upload 的 `RcFile` 类型定义。[#16851](https://github.com/ant-design/ant-design/pull/16851) + - ⚡️ 导出 Typography 中 `TextProps` 的类型定义。[#17003](https://github.com/ant-design/ant-design/pull/17003) [@Jarvis1010](https://github.com/Jarvis1010) + +## 3.19.2 + +`2019-06-01` + +- 🐞 修复 Tabs 在垂直卡片模式下标签不能滚动的问题。[#16825](https://github.com/ant-design/ant-design/pull/16825) +- 🐞 修复 Transfer 组件在 unmount 时 `setState` 警告。[#16822](https://github.com/ant-design/ant-design/pull/16822) [@shiningjason](https://github.com/shiningjason) +- 💄 使用 Less 变量 `@error-color`、`@warning-color` 代替 `@text-color-danger`、`@text-color-warning`。[#16890](https://github.com/ant-design/ant-design/pull/16890) [@MrHeer](https://github.com/MrHeer) +- 💄 增加在 Sider 内 Menu 使用 `inlineCollapsed` 时的提示信息。[#16826](https://github.com/ant-design/ant-design/pull/16826) +- TypeScript + - ⚡️ 增加 Menu 中 `forceSubMenuRender` 类型定义。[#16827](https://github.com/ant-design/ant-design/pull/16827) + - ⚡️ 导出 Typography 类型定义。[#16835](https://github.com/ant-design/ant-design/pull/16835) + - ⚡️ 增加 Steps 中的 `onChange` 类型定义。[#16845](https://github.com/ant-design/ant-design/pull/16845) [@JonathanLee-LX](https://github.com/JonathanLee-LX) + - ⚡️ 增加 Upload 中 `webkitRelativePath` 类型定义。[#16850](https://github.com/ant-design/ant-design/pull/16850) [@DiamondYuan](https://github.com/DiamondYuan) + +## 3.19.1 + +`2019-05-27` + +- 🐞 修复 Menu 在受控模式下收起 Tooltip 不消失的问题。[#16812](https://github.com/ant-design/ant-design/pull/16812) +- 🐞 修复 Descriptions 排列警告信息逻辑错误的问题。[#16819](https://github.com/ant-design/ant-design/pull/16819) +- 🐞 修复图标 `canlendar` 和 `interation` 为正确的拼写 `calendar` 和 `interaction`。[#16818](https://github.com/ant-design/ant-design/pull/16818) +- TypeScript + - ⚡️ 修复 Mentions 定义。[#16814](https://github.com/ant-design/ant-design/pull/16814) + - ⚡️ 完善 Select 中 `onSelect` 和 `onDeselect` 属性的定义。[#16817](https://github.com/ant-design/ant-design/pull/16817) + +## 3.19.0 + +`2019-05-26` + +- 本月新增组件: + - 🔥🔥🔥 [Mentions](https://ant.design/components/mentions-cn/) 新增提及组件并废弃原有 Mention 组件。 + - 🔥🔥🔥 [Descriptions](https://ant.design/components/descriptions-cn/) 成组展示多个只读字段。 +- 🇱🇻 新增拉脱维亚语支持。[#16780](https://github.com/ant-design/ant-design/pull/16780) [@kirbo](https://github.com/kirbo) +- 🌟 Drawer 支持 `ESC` 关闭。[#16694](https://github.com/ant-design/ant-design/pull/16694) +- 🌟 Steps 支持点击切换功能。[#16773](https://github.com/ant-design/ant-design/pull/16773) +- 🌟 Calendar 支持 `headerRender` 以自定义头部。[#16535](https://github.com/ant-design/ant-design/pull/16535) [@abgaryanharutyun](https://github.com/abgaryanharutyun) +- 🌟 Slider 支持 `tooltipPlacement` 以定义提示所在位置。[#16641](https://github.com/ant-design/ant-design/pull/16641) [@cmaster11](https://github.com/cmaster11) +- 🌟 Slider 支持 `getTooltipPopupContainer` 以允许自定义提示所在容器。[#16717](https://github.com/ant-design/ant-design/pull/16717) +- 🐞 修复 PageHeader 中水平分割线样式问题。[#16684](https://github.com/ant-design/ant-design/pull/16684) +- 🐞 修复 Carousel `initialSlide` 在 `children` 数量变化时无效的问题。[#16756](https://github.com/ant-design/ant-design/pull/16756) +- 🐞 修复 Cascader 自定义渲染时元素无法交互的问题。[#16782](https://github.com/ant-design/ant-design/pull/16782) +- 🐞 修复 Upload 列表在 `disabled` 时仍然可以移除的问题。[#16786](https://github.com/ant-design/ant-design/pull/16786) +- 💄 增加 Upload `disabled` 状态下鼠标样式。[#16799](https://github.com/ant-design/ant-design/pull/16799) [@attacking](https://github.com/attacking) +- 💄 修正 Statistic 的字体颜色。[#16801](https://github.com/ant-design/ant-design/pull/16801) +- TypeScript + - ⚡️ 完善 Upload 中 `action` 属性的定义。[#16716](https://github.com/ant-design/ant-design/pull/16716) [@christophehurpeau](https://github.com/christophehurpeau) + - ⚡️ 完善 Upload 中 `onRemove` 属性的定义。[#16570](https://github.com/ant-design/ant-design/pull/16570) [@christophehurpeau](https://github.com/christophehurpeau) + - ⚡️ 完善 Select 中 `getPopupContainer` 属性的定义。[#16778](https://github.com/ant-design/ant-design/pull/16778) [@chj-damon](https://github.com/chj-damon) + - ⚡️ 完善 InputNumber 中 `parser` 属性的定义。[#16797](https://github.com/ant-design/ant-design/pull/16797) + - ⚡️ 移除已经失效的属性定义。[#16705](https://github.com/ant-design/ant-design/pull/16705) [@sirlantis](https://github.com/sirlantis) + +## 3.18.2 + +`2019-05-20` + +- 🐞 修复 Button 组件中插入文本时空格丢失的问题。[#15342](https://github.com/ant-design/ant-design/issues/15342) +- 🐞 修复 Carousel 组件的 `children` 数量变化时,面板指示点的选中状态不正常的问题。[#16583](https://github.com/ant-design/ant-design/issues/16583) +- 🐞 升级 `rc-calendar` 依赖到 `9.13.3` 版本,以修复 DatePicker 组件在失去焦点时面板不会关闭的问题。[#16588](https://github.com/ant-design/ant-design/issues/16588) +- 🐞 修复 Form.Item 组件带有 `help` 信息,并且 `margin-bottom` 为负数时,导致之后的元素样式错乱的问题。[#16584](https://github.com/ant-design/ant-design/pull/16584) [@sbusch](https://github.com/sbusch) +- 🐞 修复 Spin 组件在设置 `font-size` 样式时没有水平居中的问题。[#15206](https://github.com/ant-design/ant-design/issues/15206) +- 🐞 修复 Table 组件指定 `childrenColumnName` 时,`selectedRows` 参数为空的问题。[#16614](https://github.com/ant-design/ant-design/issues/16614) +- TypeScript + - ⚡️ 完善 Breadcrumb 中 `children` 属性的定义。[#16550](https://github.com/ant-design/ant-design/pull/16550) [@Gin-X](https://github.com/Gin-X) + - ⚡️ 完善 Form 中 `onFieldsChange` 函数的参数定义。[#16577](https://github.com/ant-design/ant-design/pull/16577) [@SylvanasGone](https://github.com/SylvanasGone) + - ⚡️ 完善 List 中 `dataSource` 和 `renderItem` 属性的定义。[#16587](https://github.com/ant-design/ant-design/issues/16587) + - ⚡️ 完善 Tree 中 `onDragEnter` 函数的参数定义。[#16638](https://github.com/ant-design/ant-design/pull/16638) [@eruca](https://github.com/eruca) + - ⚡️ 完善 Tree 中 event 属性的定义。[#16624](https://github.com/ant-design/ant-design/pull/16624) [@ztplz](https://github.com/ztplz) + ## 3.18.1 `2019-05-13` @@ -1168,7 +1256,6 @@ timeline: true - Tree 组件升级 `rc-tree` 到 `1.12.0` - 🌟 新增 `loadedKeys` 属性,用于设置已经加载的节点,需要配合 `loadData` 使用。[#10666](https://github.com/ant-design/ant-design/issues/10666) - 🌟 新增 `onLoad` 属性,作为节点加载完毕时的回调函数。[c488aca](https://github.com/ant-design/ant-design/commit/c488aca05e11d942d77c1b6bff45d12bbb1a2bd6) -- 🌟 增加 `okButtonDisabled` and `cancelButtonDisabled` 属性用于禁用确定和取消按钮。[#10955](https://github.com/ant-design/ant-design/pull/10955) - 🌟 Cascader 新增 fieldNames 并废弃拼写错误的 filedNames。[#10896](https://github.com/ant-design/ant-design/issues/10896) - 🐞 修复时间轴不能与`Tooltip`一起使用的问题。[0e3b67e](https://github.com/ant-design/ant-design/commit/0e3b67e9999d867cc304f3be61a8a042a2ab92ee) - 🐞 修复当 Avatar 自定义大小时,圆角不改变的问题。[e1e6523](https://github.com/ant-design/ant-design/commit/e1e6523452286ba56f20b73abad762a58ea7d7bc) diff --git a/components/__tests__/__snapshots__/index.test.js.snap b/components/__tests__/__snapshots__/index.test.js.snap index 6056d0fc2848..079920cab0d6 100644 --- a/components/__tests__/__snapshots__/index.test.js.snap +++ b/components/__tests__/__snapshots__/index.test.js.snap @@ -21,6 +21,7 @@ Array [ "Comment", "ConfigProvider", "DatePicker", + "Descriptions", "Divider", "Dropdown", "Drawer", @@ -34,6 +35,7 @@ Array [ "LocaleProvider", "message", "Menu", + "Mentions", "Modal", "Statistic", "notification", diff --git a/components/_util/__tests__/util.test.js b/components/_util/__tests__/util.test.js index c56e320c4eaf..42a2cb32508c 100644 --- a/components/_util/__tests__/util.test.js +++ b/components/_util/__tests__/util.test.js @@ -1,11 +1,14 @@ import raf from 'raf'; import React from 'react'; import { mount } from 'enzyme'; +import KeyCode from 'rc-util/lib/KeyCode'; import delayRaf from '../raf'; import throttleByAnimationFrame from '../throttleByAnimationFrame'; import getDataOrAriaProps from '../getDataOrAriaProps'; import triggerEvent from '../triggerEvent'; import Wave from '../wave'; +import TransButton from '../transButton'; +import openAnimation from '../openAnimation'; describe('Test utils function', () => { beforeAll(() => { @@ -163,5 +166,58 @@ describe('Test utils function', () => { ).instance(); expect(wrapper.bindAnimationEvent()).toBe(undefined); }); + + it('should not throw when click it', () => { + expect(() => { + const wrapper = mount(
); + wrapper.simulate('click'); + }).not.toThrow(); + }); + + it('should not throw when no children', () => { + if (process.env.REACT === '15') { + return; + } + expect(() => mount()).not.toThrow(); + }); + }); + + describe('TransButton', () => { + it('can be focus/blur', () => { + const wrapper = mount( + TransButton, + ); + expect(typeof wrapper.instance().focus).toBe('function'); + expect(typeof wrapper.instance().blur).toBe('function'); + }); + + it('should trigger onClick when press enter', () => { + const onClick = jest.fn(); + const preventDefault = jest.fn(); + const wrapper = mount( + TransButton, + ); + wrapper.simulate('keyUp', { keyCode: KeyCode.ENTER }); + expect(onClick).toHaveBeenCalled(); + wrapper.simulate('keyDown', { keyCode: KeyCode.ENTER, preventDefault }); + expect(preventDefault).toHaveBeenCalled(); + }); + }); + + describe('openAnimation', () => { + it('should support openAnimation', () => { + const done = jest.fn(); + const domNode = document.createElement('div'); + expect(typeof openAnimation.enter).toBe('function'); + expect(typeof openAnimation.leave).toBe('function'); + expect(typeof openAnimation.appear).toBe('function'); + const appear = openAnimation.appear(domNode, done); + const enter = openAnimation.enter(domNode, done); + const leave = openAnimation.leave(domNode, done); + expect(typeof appear.stop).toBe('function'); + expect(typeof enter.stop).toBe('function'); + expect(typeof leave.stop).toBe('function'); + expect(done).toHaveBeenCalled(); + }); }); }); diff --git a/components/_util/responsiveObserve.ts b/components/_util/responsiveObserve.ts new file mode 100644 index 000000000000..6ee73cddd205 --- /dev/null +++ b/components/_util/responsiveObserve.ts @@ -0,0 +1,101 @@ +// matchMedia polyfill for +// https://github.com/WickyNilliams/enquire.js/issues/82 +let enquire: any; + +if (typeof window !== 'undefined') { + const matchMediaPolyfill = (mediaQuery: string) => { + return { + media: mediaQuery, + matches: false, + addListener() {}, + removeListener() {}, + }; + }; + window.matchMedia = window.matchMedia || matchMediaPolyfill; + enquire = require('enquire.js'); +} + +export type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs'; +export type BreakpointMap = Partial>; + +export const responsiveArray: Breakpoint[] = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs']; + +export const responsiveMap: BreakpointMap = { + xs: '(max-width: 575px)', + sm: '(min-width: 576px)', + md: '(min-width: 768px)', + lg: '(min-width: 992px)', + xl: '(min-width: 1200px)', + xxl: '(min-width: 1600px)', +}; + +type SubscribeFunc = (screens: BreakpointMap) => void; + +let subscribers: Array<{ + token: string; + func: SubscribeFunc; +}> = []; +let subUid = -1; +let screens = {}; + +const responsiveObserve = { + dispatch(pointMap: BreakpointMap) { + screens = pointMap; + if (subscribers.length < 1) { + return false; + } + + subscribers.forEach(item => { + item.func(screens); + }); + + return true; + }, + subscribe(func: SubscribeFunc) { + if (subscribers.length === 0) { + this.register(); + } + const token = (++subUid).toString(); + subscribers.push({ + token: token, + func: func, + }); + func(screens); + return token; + }, + unsubscribe(token: string) { + subscribers = subscribers.filter(item => item.token !== token); + if (subscribers.length === 0) { + this.unregister(); + } + }, + unregister() { + Object.keys(responsiveMap).map((screen: Breakpoint) => + enquire.unregister(responsiveMap[screen]), + ); + }, + register() { + Object.keys(responsiveMap).map((screen: Breakpoint) => + enquire.register(responsiveMap[screen], { + match: () => { + const pointMap = { + ...screens, + [screen]: true, + }; + this.dispatch(pointMap); + }, + unmatch: () => { + const pointMap = { + ...screens, + [screen]: false, + }; + this.dispatch(pointMap); + }, + // Keep a empty destory to avoid triggering unmatch when unregister + destroy() {}, + }), + ); + }, +}; + +export default responsiveObserve; diff --git a/components/_util/wave.tsx b/components/_util/wave.tsx index abaf86e42382..2185455ba6f2 100644 --- a/components/_util/wave.tsx +++ b/components/_util/wave.tsx @@ -158,7 +158,7 @@ export default class Wave extends React.Component<{ insertExtraNode?: boolean }> componentDidMount() { const node = findDOMNode(this) as HTMLElement; - if (node.nodeType !== 1) { + if (!node || node.nodeType !== 1) { return; } this.instance = this.bindAnimationEvent(node); diff --git a/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap b/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap index f30f2613f62a..1069a8781915 100644 --- a/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap +++ b/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap @@ -443,6 +443,7 @@ exports[`renders ./components/auto-complete/demo/uncertain-category.md correctly > } @@ -116,10 +120,6 @@ ReactDOM.render(, mountNode); padding-right: 62px; } -.global-search.ant-select-auto-complete .ant-input-affix-wrapper .ant-input-suffix { - right: 0; -} - .global-search.ant-select-auto-complete .ant-input-affix-wrapper .ant-input-suffix button { border-top-left-radius: 0; border-bottom-left-radius: 0; diff --git a/components/auto-complete/index.zh-CN.md b/components/auto-complete/index.zh-CN.md index 70e4a9f8cb61..6d2edb45b004 100644 --- a/components/auto-complete/index.zh-CN.md +++ b/components/auto-complete/index.zh-CN.md @@ -31,6 +31,7 @@ const dataSource = ['12345', '23456', '34567']; | defaultValue | 指定默认选中的条目 | string\|string\[]\| 无 | | disabled | 是否禁用 | boolean | false | | filterOption | 是否根据输入项进行筛选。当其为一个函数时,会接收 `inputValue` `option` 两个参数,当 `option` 符合筛选条件时,应返回 `true`,反之则返回 `false`。 | boolean or function(inputValue, option) | true | +| getPopupContainer | 菜单渲染父节点。默认渲染到 body 上,如果你遇到菜单滚动定位问题,试试修改为滚动的区域,并相对其定位。[示例](https://codesandbox.io/s/4j168r7jw0) | Function(triggerNode) | () => document.body | | optionLabelProp | 回填到选择框的 Option 的属性值,默认是 Option 的子元素。比如在子元素需要高亮效果时,此值可以设为 `value`。 | string | `children` | | placeholder | 输入框提示 | string | - | | value | 指定当前选中的条目 | string\|string\[]\|{ key: string, label: string\|ReactNode }\|Array<{ key: string, label: string\|ReactNode }> | 无 | diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index 3b114a90d9ef..24d3066e263f 100755 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -59,8 +59,6 @@ export default class Breadcrumb extends React.Component { separator: PropTypes.node, routes: PropTypes.array, params: PropTypes.object, - linkRender: PropTypes.func, - nameRender: PropTypes.func, }; componentDidMount() { @@ -72,6 +70,24 @@ export default class Breadcrumb extends React.Component { 'see: https://u.ant.design/item-render.', ); } + + getPath = (path: string, params: any) => { + path = (path || '').replace(/^\//, ''); + Object.keys(params).forEach(key => { + path = path.replace(`:${key}`, params[key]); + }); + return path; + } + + addChildPath = (paths: string[], childPath: string = '', params: any) => { + const originalPaths = [...paths]; + const path = this.getPath(childPath, params); + if (path) { + originalPaths.push(path); + } + return originalPaths; + } + genForRoutes = ({ routes = [], params = {}, @@ -80,11 +96,7 @@ export default class Breadcrumb extends React.Component { }: BreadcrumbProps) => { const paths: string[] = []; return routes.map(route => { - route.path = route.path || ''; - let path = route.path.replace(/^\//, ''); - Object.keys(params).forEach(key => { - path = path.replace(`:${key}`, params[key]); - }); + const path = this.getPath(route.path, params); if (path) { paths.push(path); @@ -95,10 +107,12 @@ export default class Breadcrumb extends React.Component { overlay = ( {route.children.map(child => ( - - {itemRender(child, params, routes, paths)} - - ))} + + { + itemRender(child, params, routes, this.addChildPath(paths, child.path, params)) + } + + ))} ); } diff --git a/components/breadcrumb/BreadcrumbItem.tsx b/components/breadcrumb/BreadcrumbItem.tsx index 851f92199e6c..37936f4f812c 100644 --- a/components/breadcrumb/BreadcrumbItem.tsx +++ b/components/breadcrumb/BreadcrumbItem.tsx @@ -71,10 +71,10 @@ export default class BreadcrumbItem extends React.Component - + {breadcrumbItem} - + ); } diff --git a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap index 1f82c455884f..c5cb3931ccbd 100644 --- a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap +++ b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap @@ -71,42 +71,43 @@ exports[`Breadcrumb should render a menu 1`] = ` - - - - first - - - - + + + + - - - - - / + / + -
- - - Ant Design - - - / - +
+ + + Ant Design - - - - Component - - - - / - + + / - - - - + + + - General + Component - - - / - + + + - Button + + General + - - / - + + -
+ + / + + + + + Button + + + / + +
`; diff --git a/components/breadcrumb/demo/overlay.md b/components/breadcrumb/demo/overlay.md index 0789262d9baa..11f839c0e58a 100644 --- a/components/breadcrumb/demo/overlay.md +++ b/components/breadcrumb/demo/overlay.md @@ -37,18 +37,16 @@ const menu = ( ); ReactDOM.render( -
- - Ant Design - - Component - - - General - - Button - -
, + + Ant Design + + Component + + + General + + Button + , mountNode, ); ``` diff --git a/components/breadcrumb/index.zh-CN.md b/components/breadcrumb/index.zh-CN.md index edfe7805f61a..5726fc8200b4 100644 --- a/components/breadcrumb/index.zh-CN.md +++ b/components/breadcrumb/index.zh-CN.md @@ -31,7 +31,7 @@ title: Breadcrumb | href | 链接的目的地 | string | - | | separator | 自定义的分隔符 | string\|ReactNode | '/' | | overlay | 下来菜单的内容 | [Menu](/components/menu) \| () => Menu | - | -| onClick | 单击事件 | (e:MouseEventHandler)=>void | - | +| onClick | 单击事件 | (e:MouseEvent)=>void | - | ### routes diff --git a/components/button/__tests__/__snapshots__/index.test.js.snap b/components/button/__tests__/__snapshots__/index.test.js.snap index 463fbb629c8d..9206286b7da0 100644 --- a/components/button/__tests__/__snapshots__/index.test.js.snap +++ b/components/button/__tests__/__snapshots__/index.test.js.snap @@ -211,6 +211,17 @@ exports[`Button should has click wave effect 1`] = ` `; +exports[`Button should merge text if children using variable 1`] = ` + +`; + exports[`Button should not render as link button when href is undefined 1`] = ` , + ); + + expect(wrapper.render()).toMatchSnapshot(); + }); }); diff --git a/components/button/button.tsx b/components/button/button.tsx index b6a94e606861..abbf9ebf0b41 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -15,6 +15,29 @@ function isString(str: any) { return typeof str === 'string'; } +function spaceChildren(children: React.ReactNode, needInserted: boolean) { + let isPrevChildPure: boolean = false; + const childList: React.ReactNode[] = []; + React.Children.forEach(children, child => { + const type = typeof child; + const isCurrentChildPure = type === 'string' || type === 'number'; + if (isPrevChildPure && isCurrentChildPure) { + const lastIndex = childList.length - 1; + const lastChild = childList[lastIndex]; + childList[lastIndex] = `${lastChild}${child}`; + } else { + childList.push(child); + } + + isPrevChildPure = isCurrentChildPure; + }); + + // Pass to React.Children.map to auto fill key + return React.Children.map(childList, child => + insertSpace(child as React.ReactChild, needInserted), + ); +} + // Insert one space between two chinese characters automatically. function insertSpace(child: React.ReactChild, needInserted: boolean) { // Check the child if is undefined or null. @@ -243,9 +266,7 @@ class Button extends React.Component { const iconNode = iconType ? : null; const kids = children || children === 0 - ? React.Children.map(children, child => - insertSpace(child as React.ReactChild, this.isNeedInserted() && autoInsertSpace), - ) + ? spaceChildren(children, this.isNeedInserted() && autoInsertSpace) : null; const linkButtonRestProps = omit(rest as AnchorButtonProps, ['htmlType']); diff --git a/components/button/demo/basic.md b/components/button/demo/basic.md index d1a062165017..98fbfa3666c9 100644 --- a/components/button/demo/basic.md +++ b/components/button/demo/basic.md @@ -7,11 +7,11 @@ title: ## zh-CN -按钮有四种类型:主按钮、次按钮、虚线按钮、危险按钮。主按钮在同一个操作区域最多出现一次。 +按钮有五种类型:主按钮、次按钮、虚线按钮、危险按钮和链接按钮。主按钮在同一个操作区域最多出现一次。 ## en-US -There are `primary` button, `default` button, `dashed` button and `danger` button in antd. +There are `primary` button, `default` button, `dashed` button, `danger` button and `link` button in antd. ```jsx import { Button } from 'antd'; diff --git a/components/calendar/Header.tsx b/components/calendar/Header.tsx index c0413118233b..e305d0ad3d41 100644 --- a/components/calendar/Header.tsx +++ b/components/calendar/Header.tsx @@ -3,7 +3,14 @@ import * as moment from 'moment'; import Select from '../select'; import { Group, Button, RadioChangeEvent } from '../radio'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; -const Option = Select.Option; +const { Option } = Select; + +export interface RenderHeader { + value: moment.Moment; + onChange?: (value: moment.Moment) => void; + type: string; + onTypeChange: (type: string) => void; +} export interface HeaderProps { prefixCls?: string; @@ -14,8 +21,9 @@ export interface HeaderProps { type?: string; onValueChange?: (value: moment.Moment) => void; onTypeChange?: (type: string) => void; - value: any; + value: moment.Moment; validRange?: [moment.Moment, moment.Moment]; + headerRender: (header: RenderHeader) => React.ReactNode; } export default class Header extends React.Component { @@ -79,6 +87,7 @@ export default class Header extends React.Component { start = rangeStart.get('month'); } } + for (let index = start; index < end; index++) { options.push(); } @@ -128,10 +137,14 @@ export default class Header extends React.Component { } }; - onTypeChange = (e: RadioChangeEvent) => { + onInternalTypeChange = (e: RadioChangeEvent) => { + this.onTypeChange(e.target.value); + }; + + onTypeChange = (type: string) => { const onTypeChange = this.props.onTypeChange; if (onTypeChange) { - onTypeChange(e.target.value); + onTypeChange(type); } }; @@ -139,26 +152,53 @@ export default class Header extends React.Component { this.calenderHeaderNode = node; }; - renderHeader = ({ getPrefixCls }: ConfigConsumerProps) => { - const { prefixCls: customizePrefixCls, type, value, locale, fullscreen } = this.props; + getMonthYearSelections = (getPrefixCls: ConfigConsumerProps['getPrefixCls']) => { + const { prefixCls: customizePrefixCls, type, value } = this.props; + const prefixCls = getPrefixCls('fullcalendar', customizePrefixCls); - const yearSelect = this.getYearSelectElement(prefixCls, value.year()); - const monthSelect = + const yearReactNode = this.getYearSelectElement(prefixCls, value.year()); + const monthReactNode = type === 'month' ? this.getMonthSelectElement(prefixCls, value.month(), this.getMonthsLocale(value)) : null; + return { + yearReactNode, + monthReactNode, + }; + }; + + getTypeSwitch = () => { + const { locale, type, fullscreen } = this.props; const size = fullscreen ? 'default' : 'small'; - const typeSwitch = ( - + return ( + ); + }; - return ( + headerRenderCustom = (): React.ReactNode => { + const { headerRender, type, onValueChange, value } = this.props; + + return headerRender({ + value, + type: type || 'month', + onChange: onValueChange, + onTypeChange: this.onTypeChange, + }); + }; + + renderHeader = ({ getPrefixCls }: ConfigConsumerProps) => { + const { prefixCls, headerRender } = this.props; + const typeSwitch = this.getTypeSwitch(); + const { yearReactNode, monthReactNode } = this.getMonthYearSelections(getPrefixCls); + return headerRender ? ( + this.headerRenderCustom() + ) : (
- {yearSelect} - {monthSelect} + {yearReactNode} + {monthReactNode} {typeSwitch}
); diff --git a/components/calendar/__tests__/__snapshots__/demo.test.js.snap b/components/calendar/__tests__/__snapshots__/demo.test.js.snap index 0f444fe610f3..ad34a8e43fa0 100644 --- a/components/calendar/__tests__/__snapshots__/demo.test.js.snap +++ b/components/calendar/__tests__/__snapshots__/demo.test.js.snap @@ -2092,6 +2092,1075 @@ exports[`renders ./components/calendar/demo/card.md correctly 1`] = `
`; +exports[`renders ./components/calendar/demo/customize-header.md correctly 1`] = ` +
+
+
+
+ Custom header +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Su + + + + Mo + + + + Tu + + + + We + + + + Th + + + + Fr + + + + Sa + +
+
+
+ 30 +
+
+
+
+
+
+ 31 +
+
+
+
+
+
+ 01 +
+
+
+
+
+
+ 02 +
+
+
+
+
+
+ 03 +
+
+
+
+
+
+ 04 +
+
+
+
+
+
+ 05 +
+
+
+
+
+
+ 06 +
+
+
+
+
+
+ 07 +
+
+
+
+
+
+ 08 +
+
+
+
+
+
+ 09 +
+
+
+
+
+
+ 10 +
+
+
+
+
+
+ 11 +
+
+
+
+
+
+ 12 +
+
+
+
+
+
+ 13 +
+
+
+
+
+
+ 14 +
+
+
+
+
+
+ 15 +
+
+
+
+
+
+ 16 +
+
+
+
+
+
+ 17 +
+
+
+
+
+
+ 18 +
+
+
+
+
+
+ 19 +
+
+
+
+
+
+ 20 +
+
+
+
+
+
+ 21 +
+
+
+
+
+
+ 22 +
+
+
+
+
+
+ 23 +
+
+
+
+
+
+ 24 +
+
+
+
+
+
+ 25 +
+
+
+
+
+
+ 26 +
+
+
+
+
+
+ 27 +
+
+
+
+
+
+ 28 +
+
+
+
+
+
+ 29 +
+
+
+
+
+
+ 30 +
+
+
+
+
+
+ 01 +
+
+
+
+
+
+ 02 +
+
+
+
+
+
+ 03 +
+
+
+
+
+
+ 04 +
+
+
+
+
+
+ 05 +
+
+
+
+
+
+ 06 +
+
+
+
+
+
+ 07 +
+
+
+
+
+
+ 08 +
+
+
+
+
+
+ 09 +
+
+
+
+
+
+ 10 +
+
+
+
+
+
+
+
+`; + exports[`renders ./components/calendar/demo/notice-calendar.md correctly 1`] = `
{ it('Calendar should be selectable', () => { @@ -256,4 +259,107 @@ describe('Calendar', () => { .simulate('change'); expect(onTypeChange).toHaveBeenCalledWith('year'); }); + + it('headerRender should work correctly', () => { + const onMonthChange = jest.fn(); + const onYearChange = jest.fn(); + const onTypeChange = jest.fn(); + const headerRender = jest.fn(({ value }) => { + const year = value.year(); + const options = []; + for (let i = year - 100; i < year + 100; i += 1) { + options.push( + + {i} + , + ); + } + + return ( + + ); + }); + const wrapperWithYear = mount(); + + wrapperWithYear.find('.ant-select').simulate('click'); + wrapperWithYear.update(); + + wrapperWithYear + .find('.year-item') + .last() + .simulate('click'); + + expect(onYearChange).toHaveBeenCalled(); + const headerRenderWithMonth = jest.fn(({ value }) => { + const start = 0; + const end = 12; + const monthOptions = []; + const current = value.clone(); + const localeData = value.localeData(); + const months = []; + for (let i = 0; i < 12; i += 1) { + current.month(i); + months.push(localeData.monthsShort(current)); + } + + for (let index = start; index < end; index += 1) { + monthOptions.push( + + {months[index]} + , + ); + } + const month = value.month(); + return ( + + ); + }); + const wrapperWithMonth = mount( + , + ); + + wrapperWithMonth.find('.ant-select').simulate('click'); + wrapperWithMonth.update(); + + wrapperWithMonth + .find('.month-item') + .last() + .simulate('click'); + expect(onMonthChange).toHaveBeenCalled(); + + const headerRenderWithTypeChange = jest.fn(({ type }) => { + return ( + + + + + ); + }); + + const wrapperWithTypeChange = mount( + , + ); + + wrapperWithTypeChange + .find('.ant-radio-button-input') + .last() + .simulate('change'); + expect(onTypeChange).toHaveBeenCalled(); + }); }); diff --git a/components/calendar/demo/customize-header.md b/components/calendar/demo/customize-header.md new file mode 100644 index 000000000000..a64f13f51792 --- /dev/null +++ b/components/calendar/demo/customize-header.md @@ -0,0 +1,107 @@ +--- +order: 4 +title: + zh-CN: 自定义头部 + en-US: Customize Header +--- + +## zh-CN + +自定义日历头部内容。 + +## en-US + +Customize Calendar header content. + +```jsx +import { Calendar, Select, Radio, Col, Row } from 'antd'; + +const { Group, Button } = Radio; + +function onPanelChange(value, mode) { + console.log(value, mode); +} + +ReactDOM.render( +
+ { + const start = 0; + const end = 12; + const monthOptions = []; + + const current = value.clone(); + const localeData = value.localeData(); + const months = []; + for (let i = 0; i < 12; i++) { + current.month(i); + months.push(localeData.monthsShort(current)); + } + + for (let index = start; index < end; index++) { + monthOptions.push( + + {months[index]} + , + ); + } + const month = value.month(); + + const year = value.year(); + const options = []; + for (let i = year - 10; i < year + 10; i += 1) { + options.push( + + {i} + , + ); + } + return ( +
+
Custom header
+ + + onTypeChange(e.target.value)} value={type}> + + + + + + + + + + + +
+ ); + }} + onPanelChange={onPanelChange} + /> +
, + mountNode, +); +``` diff --git a/components/calendar/index.en-US.md b/components/calendar/index.en-US.md index 0ed680da5628..1cd91c9cb838 100644 --- a/components/calendar/index.en-US.md +++ b/components/calendar/index.en-US.md @@ -29,19 +29,20 @@ When data is in the form of dates, such as schedules, timetables, prices calenda /> ``` -| Property | Description | Type | Default | -| --- | --- | --- | --- | -| dateCellRender | Customize the display of the date cell, the returned content will be appended to the cell | function(date: moment): ReactNode | - | -| dateFullCellRender | Customize the display of the date cell, the returned content will override the cell | function(date: moment): ReactNode | - | -| defaultValue | The date selected by default | [moment](http://momentjs.com/) | default date | -| disabledDate | Function that specifies the dates that cannot be selected | (currentDate: moment) => boolean | - | -| fullscreen | Whether to display in full-screen | boolean | `true` | -| locale | The calendar's locale | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | -| mode | The display mode of the calendar | `month` \| `year` | `month` | -| monthCellRender | Customize the display of the month cell, the returned content will be appended to the cell | function(date: moment): ReactNode | - | -| monthFullCellRender | Customize the display of the month cell, the returned content will override the cell | function(date: moment): ReactNode | - | -| validRange | to set valid range | \[[moment](http://momentjs.com/), [moment](http://momentjs.com/)] | - | +| Property | Description | Type | Default | Version | +| --- | --- | --- | --- | --- | +| dateCellRender | Customize the display of the date cell, the returned content will be appended to the cell | function(date: moment): ReactNode | - | | +| dateFullCellRender | Customize the display of the date cell, the returned content will override the cell | function(date: moment): ReactNode | - | | +| defaultValue | The date selected by default | [moment](http://momentjs.com/) | default date | | +| disabledDate | Function that specifies the dates that cannot be selected | (currentDate: moment) => boolean | - | | +| fullscreen | Whether to display in full-screen | boolean | `true` | | +| locale | The calendar's locale | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | | +| mode | The display mode of the calendar | `month` \| `year` | `month` | | +| monthCellRender | Customize the display of the month cell, the returned content will be appended to the cell | function(date: moment): ReactNode | - | | +| monthFullCellRender | Customize the display of the month cell, the returned content will override the cell | function(date: moment): ReactNode | - | | +| validRange | to set valid range | \[[moment](http://momentjs.com/), [moment](http://momentjs.com/)] | - | | | value | The current selected date | [moment](http://momentjs.com/) | current date | -| onPanelChange | Callback for when panel changes | function(date: moment, mode: string) | - | -| onSelect | Callback for when a date is selected | function(date: moment) | - | -| onChange | Callback for when date changes | function(date: moment) | - | +| onPanelChange | Callback for when panel changes | function(date: moment, mode: string) | - | | +| onSelect | Callback for when a date is selected | function(date: moment) | - | | +| onChange | Callback for when date changes | function(date: moment) | - | | +| headerRender | render custom header in panel | function(object:{value: moment, type: string, onChange: f(), onTypeChange: f()}) | - | 3.19.0 | diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx index 65ae98fb60b6..25ca8e6ff937 100644 --- a/components/calendar/index.tsx +++ b/components/calendar/index.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; import * as moment from 'moment'; import FullCalendar from 'rc-calendar/lib/FullCalendar'; -import Header from './Header'; +import Header, { RenderHeader } from './Header'; import enUS from './locale/en_US'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; @@ -23,7 +23,6 @@ function zerofixed(v: number) { } export type CalendarMode = 'month' | 'year'; - export interface CalendarProps { prefixCls?: string; className?: string; @@ -42,6 +41,7 @@ export interface CalendarProps { onChange?: (date?: moment.Moment) => void; disabledDate?: (current: moment.Moment) => boolean; validRange?: [moment.Moment, moment.Moment]; + headerRender: (header: RenderHeader) => React.ReactNode; } export interface CalendarState { @@ -56,6 +56,7 @@ class Calendar extends React.Component { onSelect: noop, onPanelChange: noop, onChange: noop, + headerRender: null, }; static propTypes = { @@ -205,6 +206,7 @@ class Calendar extends React.Component { style, className, fullscreen, + headerRender, dateFullCellRender, monthFullCellRender, } = props; @@ -237,6 +239,7 @@ class Calendar extends React.Component {
``` -| 参数 | 说明 | 类型 | 默认值 | -| --- | --- | --- | --- | -| dateCellRender | 自定义渲染日期单元格,返回内容会被追加到单元格 | function(date: moment): ReactNode | 无 | -| dateFullCellRender | 自定义渲染日期单元格,返回内容覆盖单元格 | function(date: moment): ReactNode | 无 | +| 参数 | 说明 | 类型 | 默认值 | 版本 | +| --- | --- | --- | --- | --- | +| dateCellRender | 自定义渲染日期单元格,返回内容会被追加到单元格 | function(date: moment): ReactNode | 无 | | +| dateFullCellRender | 自定义渲染日期单元格,返回内容覆盖单元格 | function(date: moment): ReactNode | 无 | | | defaultValue | 默认展示的日期 | [moment](http://momentjs.com/) | 默认日期 | -| disabledDate | 不可选择的日期 | (currentDate: moment) => boolean | 无 | -| fullscreen | 是否全屏显示 | boolean | true | -| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | +| disabledDate | 不可选择的日期 | (currentDate: moment) => boolean | 无 | | +| fullscreen | 是否全屏显示 | boolean | true | | +| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | | | mode | 初始模式,`month/year` | string | month | -| monthCellRender | 自定义渲染月单元格,返回内容会被追加到单元格 | function(date: moment): ReactNode | 无 | -| monthFullCellRender | 自定义渲染月单元格,返回内容覆盖单元格 | function(date: moment): ReactNode | 无 | -| validRange | 设置可以显示的日期 | \[[moment](http://momentjs.com/), [moment](http://momentjs.com/)] | 无 | +| monthCellRender | 自定义渲染月单元格,返回内容会被追加到单元格 | function(date: moment): ReactNode | 无 | | +| monthFullCellRender | 自定义渲染月单元格,返回内容覆盖单元格 | function(date: moment): ReactNode | 无 | | +| validRange | 设置可以显示的日期 | \[[moment](http://momentjs.com/), [moment](http://momentjs.com/)] | 无 | | | value | 展示日期 | [moment](http://momentjs.com/) | 当前日期 | -| onPanelChange | 日期面板变化回调 | function(date: moment, mode: string) | 无 | -| onSelect | 点击选择日期回调 | function(date: moment) | 无 | -| onChange | 日期变化回调 | function(date: moment) | 无 | +| onPanelChange | 日期面板变化回调 | function(date: moment, mode: string) | 无 | | +| onSelect | 点击选择日期回调 | function(date: moment) | 无 | | +| onChange | 日期变化回调 | function(date: moment) | 无 | | +| headerRender | 自定义头部内容 | function(object:{value: moment, type: string, onChange: f(), onTypeChange: f()}) | 无 | 3.19.0 | diff --git a/components/calendar/locale/lv_LV.tsx b/components/calendar/locale/lv_LV.tsx new file mode 100644 index 000000000000..e947c8c42e35 --- /dev/null +++ b/components/calendar/locale/lv_LV.tsx @@ -0,0 +1,2 @@ +import lv_LV from '../../date-picker/locale/lv_LV'; +export default lv_LV; diff --git a/components/carousel/__tests__/index.test.js b/components/carousel/__tests__/index.test.js index c27f0edacb51..5ad52c864920 100644 --- a/components/carousel/__tests__/index.test.js +++ b/components/carousel/__tests__/index.test.js @@ -106,12 +106,28 @@ describe('Carousel', () => { warnSpy.mockRestore(); }); - it('should active when children change', () => { - const wrapper = mount(); - wrapper.setProps({ - children:
, + describe('should active when children change', () => { + it('should active', () => { + const wrapper = mount(); + wrapper.setProps({ + children:
, + }); + wrapper.update(); + expect(wrapper.find('.slick-active').length).toBeTruthy(); + }); + + it('should keep initialSlide', () => { + const wrapper = mount(); + wrapper.setProps({ + children: [
,
,
], + }); + wrapper.update(); + expect( + wrapper + .find('.slick-dots li') + .at(1) + .hasClass('slick-active'), + ).toBeTruthy(); }); - wrapper.update(); - expect(wrapper.find('.slick-active').length).toBeTruthy(); }); }); diff --git a/components/carousel/index.tsx b/components/carousel/index.tsx index da9319616b8a..e9f0b3a3ffb5 100644 --- a/components/carousel/index.tsx +++ b/components/carousel/index.tsx @@ -73,7 +73,7 @@ export default class Carousel extends React.Component { componentDidUpdate(prevProps: CarouselProps) { if (React.Children.count(this.props.children) !== React.Children.count(prevProps.children)) { - this.goTo(0, false); + this.goTo(this.props.initialSlide || 0, false); } } diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index 676e7e95f353..17fc1dbbe589 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -292,7 +292,8 @@ class Cascader extends React.Component { }; handleKeyDown = (e: React.KeyboardEvent) => { - if (e.keyCode === KeyCode.BACKSPACE) { + // SPACE => https://github.com/ant-design/ant-design/issues/16871 + if (e.keyCode === KeyCode.BACKSPACE || e.keyCode === KeyCode.SPACE) { e.stopPropagation(); } }; diff --git a/components/cascader/style/index.less b/components/cascader/style/index.less index b2f37336021b..eeb0a53d2388 100644 --- a/components/cascader/style/index.less +++ b/components/cascader/style/index.less @@ -8,7 +8,8 @@ .reset-component; &-input.@{ant-prefix}-input { - position: relative; + // Keep it static for https://github.com/ant-design/ant-design/issues/16738 + position: static; width: 100%; // Add important to fix https://github.com/ant-design/ant-design/issues/5078 // because input.less will compile after cascader.less @@ -109,6 +110,11 @@ } } + // https://github.com/ant-design/ant-design/pull/12407#issuecomment-424657810 + &-picker-label:hover + &-input { + .hover; + } + &-picker-small &-picker-clear, &-picker-small &-picker-arrow { right: @control-padding-horizontal-sm; @@ -195,8 +201,8 @@ &-active:not(&-disabled) { &, &:hover { - font-weight: 600; - background: @background-color-base; + font-weight: @select-item-selected-font-weight; + background-color: @background-color-light; } } &-expand { diff --git a/components/checkbox/demo/group.md b/components/checkbox/demo/group.md index e80c5a9ef789..bb92c8f9f187 100644 --- a/components/checkbox/demo/group.md +++ b/components/checkbox/demo/group.md @@ -16,8 +16,6 @@ Generate a group of checkboxes from an array. ```jsx import { Checkbox } from 'antd'; -const CheckboxGroup = Checkbox.Group; - function onChange(checkedValues) { console.log('checked = ', checkedValues); } @@ -36,13 +34,13 @@ const optionsWithDisabled = [ ReactDOM.render(
- +

- +

- ( a, & > span { height: 18px; padding-right: 8px; - font-size: 12px; + font-size: @comment-font-size-sm; line-height: 18px; } &-name { color: @comment-author-name-color; - font-size: 14px; + font-size: @comment-font-size-base; transition: color 0.3s; > * { color: @comment-author-name-color; @@ -76,7 +76,7 @@ > span { padding-right: 10px; color: @comment-action-color; - font-size: 12px; + font-size: @comment-font-size-sm; cursor: pointer; transition: color 0.3s; user-select: none; diff --git a/components/config-provider/__tests__/__snapshots__/components.test.js.snap b/components/config-provider/__tests__/__snapshots__/components.test.js.snap index bd5bb1ed48c9..abe53c950453 100644 --- a/components/config-provider/__tests__/__snapshots__/components.test.js.snap +++ b/components/config-provider/__tests__/__snapshots__/components.test.js.snap @@ -6771,6 +6771,7 @@ exports[`ConfigProvider components Drawer configProvider 1`] = ` >
= createReactContext({ +const ConfigContext = createReactContext({ // We provide a default function for Context without provider getPrefixCls: (suffixCls: string, customizePrefixCls?: string) => { if (customizePrefixCls) return customizePrefixCls; diff --git a/components/config-provider/renderEmpty.tsx b/components/config-provider/renderEmpty.tsx index 8b9d803dde84..52b0e5cca96e 100644 --- a/components/config-provider/renderEmpty.tsx +++ b/components/config-provider/renderEmpty.tsx @@ -16,6 +16,7 @@ const renderEmpty = (componentName?: string): React.ReactNode => ( case 'TreeSelect': case 'Cascader': case 'Transfer': + case 'Mentions': return ; default: return ; diff --git a/components/date-picker/demo/presetted-ranges.md b/components/date-picker/demo/presetted-ranges.md index 30b27d8cfa4b..d7cb1c49d861 100644 --- a/components/date-picker/demo/presetted-ranges.md +++ b/components/date-picker/demo/presetted-ranges.md @@ -17,7 +17,7 @@ We can set presetted ranges to RangePicker to improve user experience. import { DatePicker } from 'antd'; import moment from 'moment'; -const RangePicker = DatePicker.RangePicker; +const { RangePicker } = DatePicker; function onChange(dates, dateStrings) { console.log('From: ', dates[0], ', to: ', dates[1]); diff --git a/components/date-picker/index.en-US.md b/components/date-picker/index.en-US.md index ab987204469c..a4b9922b50fc 100644 --- a/components/date-picker/index.en-US.md +++ b/components/date-picker/index.en-US.md @@ -135,3 +135,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker, WeekPicke margin: 0 8px 12px 0; } + +## FAQ + +- [When set mode to DatePicker/RangePicker, cannot select year or month anymore?](/docs/react/faq#When-set-mode-to-DatePicker/RangePicker,-cannot-select-year-or-month-anymore?) diff --git a/components/date-picker/index.zh-CN.md b/components/date-picker/index.zh-CN.md index 21fc1d72d114..41f836190303 100644 --- a/components/date-picker/index.zh-CN.md +++ b/components/date-picker/index.zh-CN.md @@ -138,3 +138,7 @@ moment.locale('zh-cn'); margin: 0 8px 12px 0; } + +## FAQ + +- [当我指定了 DatePicker/RangePicker 的 `mode` 属性后,点击后无法选择年份/月份?](/docs/react/faq-cn#当我指定了-DatePicker/RangePicker-的-mode-属性后,点击后无法选择年份/月份?) diff --git a/components/date-picker/locale/ar_EG.tsx b/components/date-picker/locale/ar_EG.tsx index fcdaa12adc61..ad840b669bb8 100644 --- a/components/date-picker/locale/ar_EG.tsx +++ b/components/date-picker/locale/ar_EG.tsx @@ -11,6 +11,10 @@ const locale = { timePickerLocale: { ...TimePickerLocale, }, + dateFormat: 'DD-MM-YYYY', + monthFormat: 'MM-YYYY', + dateTimeFormat: 'DD-MM-YYYY HH:mm:ss', + weekFormat: 'wo-YYYY', }; // All settings at: diff --git a/components/date-picker/locale/lv_LV.tsx b/components/date-picker/locale/lv_LV.tsx new file mode 100644 index 000000000000..254b1280bb85 --- /dev/null +++ b/components/date-picker/locale/lv_LV.tsx @@ -0,0 +1,19 @@ +import CalendarLocale from 'rc-calendar/lib/locale/lv_LV'; +import TimePickerLocale from '../../time-picker/locale/lv_LV'; + +// Merge into a locale object +const locale = { + lang: { + placeholder: 'Izvēlieties datumu', + rangePlaceholder: ['Sākuma datums', 'Beigu datums'], + ...CalendarLocale, + }, + timePickerLocale: { + ...TimePickerLocale, + }, +}; + +// All settings at: +// https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json + +export default locale; diff --git a/components/descriptions/__tests__/__snapshots__/demo.test.js.snap b/components/descriptions/__tests__/__snapshots__/demo.test.js.snap new file mode 100644 index 000000000000..0eeb89fdfa95 --- /dev/null +++ b/components/descriptions/__tests__/__snapshots__/demo.test.js.snap @@ -0,0 +1,611 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders ./components/descriptions/demo/basic.md correctly 1`] = ` +
+
+ User Info +
+
+ + + + + + + + + + + + +
+ + UserName + + + Zhou Maomao + + + + Telephone + + + 1810000000 + + + + Live + + + Hangzhou, Zhejiang + +
+ + Remark + + + empty + + + + Address + + + No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China + +
+
+
+`; + +exports[`renders ./components/descriptions/demo/border.md correctly 1`] = ` +
+
+ User Info +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Product + + Cloud Database + + Billing Mode + + Prepaid + + Automatic Renewal + + YES +
+ Order time + + 2018-04-24 18:00:00 + + Usage Time + + 2019-04-24 18:00:00 +
+ Status + + + + + Running + + +
+ Negotiated Amount + + $80.00 + + Discount + + $20.00 + + Official Receipts + + $60.00 +
+ Config Info + + Data disk type: MongoDB +
+ Database version: 3.4 +
+ Package: dds.mongo.mid +
+ Storage space: 10 GB +
+ Replication_factor:3 +
+ Region: East China 1 +
+
+
+
+`; + +exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = ` +
+
+
+ Responsive Descriptions +
+
+ + + + + + + + + + + + + + + + +
+ + Product + + + Cloud Database + + + + Billing + + + Prepaid + + + + time + + + 18:00:00 + +
+ + Amount + + + $80.00 + + + + Discount + + + $20.00 + + + + Official + + + $60.00 + +
+ + Config Info + + + Data disk type: MongoDB +
+ Database version: 3.4 +
+ Package: dds.mongo.mid +
+ Storage space: 10 GB +
+ Replication_factor:3 +
+ Region: East China 1 +
+
+
+
+
+`; + +exports[`renders ./components/descriptions/demo/size.md correctly 1`] = ` +
+
+ + + +
+
+
+
+
+ Custom Size +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ Product + + Cloud Database + + Billing + + Prepaid + + time + + 18:00:00 +
+ Amount + + $80.00 + + Discount + + $20.00 + + Official + + $60.00 +
+ Config Info + + Data disk type: MongoDB +
+ Database version: 3.4 +
+ Package: dds.mongo.mid +
+ Storage space: 10 GB +
+ Replication_factor:3 +
+ Region: East China 1 +
+
+
+
+
+`; diff --git a/components/descriptions/__tests__/__snapshots__/index.test.js.snap b/components/descriptions/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 000000000000..1d3ad5bcfc55 --- /dev/null +++ b/components/descriptions/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,101 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Descriptions column is number 1`] = ` + +
+
+ + + + + + + + + + + +
+ + Product + + + Cloud Database + + + + Billing + + + Prepaid + + + + time + + + 18:00:00 + +
+ + Amount + + + $80.00 + +
+
+
+
+`; diff --git a/components/descriptions/__tests__/demo.test.js b/components/descriptions/__tests__/demo.test.js new file mode 100644 index 000000000000..966d453bea2a --- /dev/null +++ b/components/descriptions/__tests__/demo.test.js @@ -0,0 +1,3 @@ +import demoTest from '../../../tests/shared/demoTest'; + +demoTest('descriptions'); diff --git a/components/descriptions/__tests__/index.test.js b/components/descriptions/__tests__/index.test.js new file mode 100644 index 000000000000..d99e4530d1a6 --- /dev/null +++ b/components/descriptions/__tests__/index.test.js @@ -0,0 +1,112 @@ +import React from 'react'; +import MockDate from 'mockdate'; +import { mount } from 'enzyme'; +import Descriptions from '..'; + +jest.mock('enquire.js', () => { + let that; + let unmatchFun; + return { + unregister: jest.fn(), + register: (media, options) => { + if (media === '(max-width: 575px)') { + that = this; + options.match.call(that); + unmatchFun = options.unmatch; + } + }, + callunmatch() { + unmatchFun.call(that); + }, + }; +}); + +describe('Descriptions', () => { + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + + afterEach(() => { + MockDate.reset(); + errorSpy.mockReset(); + }); + + afterAll(() => { + errorSpy.mockRestore(); + }); + + it('when max-width: 575px,column=1', () => { + // eslint-disable-next-line global-require + const enquire = require('enquire.js'); + const wrapper = mount( + + Cloud Database + Prepaid + 18:00:00 + $80.00 + , + ); + expect(wrapper.find('tr')).toHaveLength(4); + + enquire.callunmatch(); + wrapper.unmount(); + }); + + it('when max-width: 575px,column=2', () => { + // eslint-disable-next-line global-require + const enquire = require('enquire.js'); + const wrapper = mount( + + Cloud Database + Prepaid + 18:00:00 + $80.00 + , + ); + expect(wrapper.find('tr')).toHaveLength(2); + + enquire.callunmatch(); + wrapper.unmount(); + }); + + it('column is number', () => { + // eslint-disable-next-line global-require + const wrapper = mount( + + Cloud Database + Prepaid + 18:00:00 + $80.00 + , + ); + expect(wrapper).toMatchSnapshot(); + wrapper.unmount(); + }); + + it('when typeof column is object', () => { + const wrapper = mount( + + Cloud Database + Prepaid + 18:00:00 + $80.00 + , + ); + expect(wrapper.instance().getColumn()).toBe(8); + wrapper.unmount(); + }); + + it('warning if ecceed the row span', () => { + mount( + + + Cloud Database + + + Prepaid + + , + ); + expect(errorSpy).toHaveBeenCalledWith( + 'Warning: [antd: Descriptions] Sum of column `span` in a line exceeds `column` of Descriptions.', + ); + }); +}); diff --git a/components/descriptions/demo/basic.md b/components/descriptions/demo/basic.md new file mode 100644 index 000000000000..f4d2232c3d8e --- /dev/null +++ b/components/descriptions/demo/basic.md @@ -0,0 +1,31 @@ +--- +order: 0 +title: + zh-CN: 基本 + en-US: Basic +--- + +## zh-CN + +简单的展示。 + +## en-US + +Simplest Usage. + +```jsx +import { Descriptions } from 'antd'; + +ReactDOM.render( + + Zhou Maomao + 1810000000 + Hangzhou, Zhejiang + empty + + No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China + + , + mountNode, +); +``` diff --git a/components/descriptions/demo/border.md b/components/descriptions/demo/border.md new file mode 100644 index 000000000000..ec59e74cb23e --- /dev/null +++ b/components/descriptions/demo/border.md @@ -0,0 +1,50 @@ +--- +order: 1 +title: + zh-CN: 带边框的 + en-US: border +--- + +## zh-CN + +带边框和背景颜色列表。 + +## en-US + +Descriptions with border and background color. + +```jsx +import { Descriptions, Badge } from 'antd'; + +ReactDOM.render( + + Cloud Database + Prepaid + YES + 2018-04-24 18:00:00 + + 2019-04-24 18:00:00 + + + + + $80.00 + $20.00 + $60.00 + + Data disk type: MongoDB +
+ Database version: 3.4 +
+ Package: dds.mongo.mid +
+ Storage space: 10 GB +
+ Replication_factor:3 +
+ Region: East China 1
+
+
, + mountNode, +); +``` diff --git a/components/descriptions/demo/responsive.md b/components/descriptions/demo/responsive.md new file mode 100644 index 000000000000..04dc0e1b8dec --- /dev/null +++ b/components/descriptions/demo/responsive.md @@ -0,0 +1,52 @@ +--- +order: 3 +title: + zh-CN: 响应式 + en-US: responsive +--- + +## zh-CN + +通过响应式的配置可以实现在小屏幕设备上的完美呈现。 + +## en-US + +Responsive configuration enables perfect presentation on small screen devices. + +```jsx +import { Descriptions } from 'antd'; + +const Demo = () => { + return ( +
+ + Cloud Database + Prepaid + 18:00:00 + $80.00 + $20.00 + $60.00 + + Data disk type: MongoDB +
+ Database version: 3.4 +
+ Package: dds.mongo.mid +
+ Storage space: 10 GB +
+ Replication_factor:3 +
+ Region: East China 1 +
+
+
+ ); +}; + +ReactDOM.render(, mountNode); +``` diff --git a/components/descriptions/demo/size.md b/components/descriptions/demo/size.md new file mode 100644 index 000000000000..c321302fc202 --- /dev/null +++ b/components/descriptions/demo/size.md @@ -0,0 +1,68 @@ +--- +order: 2 +title: + zh-CN: 自定义尺寸 + en-US: Custom size +--- + +## zh-CN + +自定义尺寸,适应在各种容器中展示。 + +## en-US + +Custom sizes to fit in a variety of containers. + +```jsx +import { Descriptions, Radio } from 'antd'; + +class Demo extends React.Component { + state = { + size: 'default', + }; + + onChange = e => { + console.log('size checked', e.target.value); + this.setState({ + size: e.target.value, + }); + }; + + render() { + return ( +
+ + default + middle + small + +
+
+ + Cloud Database + Prepaid + 18:00:00 + $80.00 + $20.00 + $60.00 + + Data disk type: MongoDB +
+ Database version: 3.4 +
+ Package: dds.mongo.mid +
+ Storage space: 10 GB +
+ Replication_factor:3 +
+ Region: East China 1
+
+
+
+ ); + } +} + +ReactDOM.render(, mountNode); +``` diff --git a/components/descriptions/index.en-US.md b/components/descriptions/index.en-US.md new file mode 100644 index 000000000000..cd500afd8d5d --- /dev/null +++ b/components/descriptions/index.en-US.md @@ -0,0 +1,30 @@ +--- +category: Components +type: Data Display +title: Description List +cols: 1 +--- + +Display multiple read-only fields in groups. + +## When To Use + +Commonly displayed on the details page. + +## API + +### Descriptions + +| Property | Description | Type | Default | +| --- | --- | --- | --- | +| title | The title of the description list, placed at the top | ReactNode | - | +| bordered | whether to display the border | boolean | false | +| column | the number of `DescriptionItems` in a row,could be a number or a object like `{ xs: 8, sm: 16, md: 24}`,(Only set `bordered={true}` to take effect) | number | 3 | +| size | set the size of the list. Can be set to `middle`,`small`, or not filled | `default | middle | small` | false | + +### DescriptionItem + +| Property | Description | Type | Default | +| -------- | ------------------------------ | --------- | ------- | +| label | description of the content | ReactNode | - | +| span | The number of columns included | number | 1 | diff --git a/components/descriptions/index.tsx b/components/descriptions/index.tsx new file mode 100644 index 000000000000..6851b396fbf8 --- /dev/null +++ b/components/descriptions/index.tsx @@ -0,0 +1,256 @@ +import * as React from 'react'; +import classNames from 'classnames'; +import warning from '../_util/warning'; +import ResponsiveObserve, { + Breakpoint, + BreakpointMap, + responsiveArray, +} from '../_util/responsiveObserve'; +import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; + +export interface DescriptionsItemProps { + prefixCls?: string; + label: React.ReactNode; + children: JSX.Element; + span?: number; +} + +const DescriptionsItem: React.SFC = ({ children }) => children; + +export interface DescriptionsProps { + prefixCls?: string; + className?: string; + style?: React.CSSProperties; + bordered?: boolean; + size?: 'middle' | 'small' | 'default'; + children?: React.ReactNode; + title?: string; + column?: number | Partial>; +} + +/** + * Convert children into `column` groups. + * @param cloneChildren: DescriptionsItem + * @param column: number + */ +const generateChildrenRows = ( + cloneChildren: React.ReactNode, + column: number, +): React.ReactElement[][] => { + const childrenArray: React.ReactElement[][] = []; + let columnArray: React.ReactElement[] = []; + let totalRowSpan = 0; + React.Children.forEach(cloneChildren, (node: React.ReactElement) => { + columnArray.push(node); + if (node.props.span) { + totalRowSpan += node.props.span; + } else { + totalRowSpan += 1; + } + if (totalRowSpan >= column) { + warning( + totalRowSpan <= column, + 'Descriptions', + 'Sum of column `span` in a line exceeds `column` of Descriptions.', + ); + + childrenArray.push(columnArray); + columnArray = []; + totalRowSpan = 0; + } + }); + if (columnArray.length > 0) { + childrenArray.push(columnArray); + columnArray = []; + } + return childrenArray; +}; + +/** + * This code is for handling react15 does not support returning an array, + * It can convert a children into two td + * @param child DescriptionsItem + * @returns + * <> + * {DescriptionsItem.label} + * {DescriptionsItem.children} + * + */ +const renderCol = (child: React.ReactElement, bordered: boolean) => { + const { prefixCls, label, children, span = 1 } = child.props; + if (bordered) { + return [ + + {label} + , + + {children} + , + ]; + } + return ( + + + {label} + + + {children} + + + ); +}; + +const renderRow = ( + children: React.ReactElement[], + index: number, + { prefixCls, column, isLast }: { prefixCls: string; column: number; isLast: boolean }, + bordered: boolean, +) => { + // copy children,prevent changes to incoming parameters + const childrenArray = [...children]; + let lastChildren = childrenArray.pop() as React.ReactElement; + const span = column - childrenArray.length; + if (isLast) { + lastChildren = React.cloneElement(lastChildren as React.ReactElement, { + span, + }); + } + const cloneChildren = React.Children.map( + childrenArray, + (childrenItem: React.ReactElement) => { + return renderCol(childrenItem, bordered); + }, + ); + return ( + + {cloneChildren} + {renderCol(lastChildren, bordered)} + + ); +}; + +const defaultColumnMap = { + xxl: 3, + xl: 3, + lg: 3, + md: 3, + sm: 2, + xs: 1, +}; + +class Descriptions extends React.Component< + DescriptionsProps, + { + screens: BreakpointMap; + } +> { + static defaultProps: DescriptionsProps = { + size: 'default', + column: defaultColumnMap, + }; + static Item: typeof DescriptionsItem; + state: { + screens: BreakpointMap; + } = { + screens: {}, + }; + token: string; + componentDidMount() { + const { column } = this.props; + this.token = ResponsiveObserve.subscribe(screens => { + if (typeof column !== 'object') { + return; + } + this.setState({ + screens, + }); + }); + } + + componentWillUnmount() { + ResponsiveObserve.unsubscribe(this.token); + } + + getColumn(): number { + const { column } = this.props; + if (typeof column === 'object') { + for (let i = 0; i < responsiveArray.length; i++) { + const breakpoint: Breakpoint = responsiveArray[i]; + if (this.state.screens[breakpoint] && column[breakpoint] !== undefined) { + return column[breakpoint] || defaultColumnMap[breakpoint]; + } + } + } + //If the configuration is not an object, it is a number, return number + if (typeof column === 'number') { + return column as number; + } + // If it is an object, but no response is found, this happens only in the test. + // Maybe there are some strange environments + return 3; + } + + render() { + return ( + + {({ getPrefixCls }: ConfigConsumerProps) => { + const { + className, + prefixCls: customizePrefixCls, + title, + size, + children, + bordered = false, + } = this.props; + const prefixCls = getPrefixCls('descriptions', customizePrefixCls); + + const column = this.getColumn(); + const cloneChildren = React.Children.map( + children, + (child: React.ReactElement) => { + return React.cloneElement(child, { + prefixCls, + }); + }, + ); + + const childrenArray: Array< + React.ReactElement[] + > = generateChildrenRows(cloneChildren, column); + return ( +
+ {title &&
{title}
} +
+ + + {childrenArray.map((child, index) => + renderRow( + child, + index, + { + prefixCls, + column, + isLast: index + 1 === childrenArray.length, + }, + bordered, + ), + )} + +
+
+
+ ); + }} +
+ ); + } +} + +Descriptions.Item = DescriptionsItem; + +export default Descriptions; diff --git a/components/descriptions/index.zh-CN.md b/components/descriptions/index.zh-CN.md new file mode 100644 index 000000000000..ba8c034907ab --- /dev/null +++ b/components/descriptions/index.zh-CN.md @@ -0,0 +1,31 @@ +--- +category: Components +subtitle: 描述列表 +type: 数据展示 +title: Descriptions +cols: 1 +--- + +成组展示多个只读字段。 + +## 何时使用 + +常见于详情页的信息展示。 + +## API + +### Descriptions + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| title | 描述列表的标题,显示在最顶部 | ReactNode | - | +| bordered | 是否展示边框 | boolean | false | +| column | 一行的 `DescriptionItems` 数量,可以写成像素值或支持响应式的对象写法 `{ xs: 8, sm: 16, md: 24}` | number | 3 | +| size | 设置列表的大小。可以设置为 `middle` 、`small`, 或不填(只有设置 `bordered={true}` 生效) | `default | middle | small` | false | + +### DescriptionItem + +| 参数 | 说明 | 类型 | 默认值 | +| ----- | ------------ | --------- | ------ | +| label | 内容的描述 | ReactNode | - | +| span | 包含列的数量 | number | 1 | diff --git a/components/descriptions/style/index.less b/components/descriptions/style/index.less new file mode 100644 index 000000000000..fcc29e539b70 --- /dev/null +++ b/components/descriptions/style/index.less @@ -0,0 +1,118 @@ +@import '../../style/themes/default'; +@import '../../style/mixins/index'; + +@descriptions-prefix-cls: ~'@{ant-prefix}-descriptions'; + +@descriptions-default-padding: 16px 24px; +@descriptions-middle-padding: 12px 24px; +@descriptions-small-padding: 8px 16px; + +.@{descriptions-prefix-cls} { + &-title { + margin-bottom: 20px; + color: @heading-color; + font-weight: bold; + font-size: @font-size-lg; + line-height: @line-height-base; + } + + &-view { + width: 100%; + overflow: hidden; + border-radius: @border-radius-base; + table { + width: 100%; + } + } + + &-row { + > td { + padding-bottom: 16px; + } + &:last-child { + border-bottom: none; + } + } + + &-item-label { + color: @heading-color; + font-size: @font-size-base; + line-height: @line-height-base; + white-space: nowrap; + &::after { + position: relative; + top: -0.5px; + margin: 0 8px 0 2px; + content: ':'; + } + } + + &-item-content { + display: table-cell; + color: @text-color; + font-size: @font-size-base; + line-height: @line-height-base; + } + + &-item { + padding-bottom: 0; + > span { + display: inline-block; + } + .@{descriptions-prefix-cls}-item-label { + float: left; + padding: 0 !important; + } + .@{descriptions-prefix-cls}-item-content { + float: left; + padding: 0 !important; + } + } + + // padding setting + .@{descriptions-prefix-cls}-item-label, + .@{descriptions-prefix-cls}-item-content { + padding: @descriptions-default-padding; + } + + &.bordered.middle { + .@{descriptions-prefix-cls}-item-label, + .@{descriptions-prefix-cls}-item-content { + padding: @descriptions-middle-padding; + } + } + &.bordered.small { + .@{descriptions-prefix-cls}-item-label, + .@{descriptions-prefix-cls}-item-content { + padding: @descriptions-small-padding; + } + } + &.bordered { + .@{descriptions-prefix-cls}-view { + border: 1px solid @border-color-split; + } + .@{descriptions-prefix-cls}-item-label, + .@{descriptions-prefix-cls}-item-content { + border-right: 1px solid @border-color-split; + } + + .@{descriptions-prefix-cls}-item-label:last-child, + .@{descriptions-prefix-cls}-item-content:last-child { + border-right: none; + } + + .@{descriptions-prefix-cls}-row { + border-bottom: 1px solid @border-color-split; + &:last-child { + border-bottom: none; + } + } + + .@{descriptions-prefix-cls}-item-label { + background-color: #fafafa; + &::after { + display: none; + } + } + } +} diff --git a/components/descriptions/style/index.tsx b/components/descriptions/style/index.tsx new file mode 100644 index 000000000000..3a3ab0de59ac --- /dev/null +++ b/components/descriptions/style/index.tsx @@ -0,0 +1,2 @@ +import '../../style/index.less'; +import './index.less'; diff --git a/components/divider/__tests__/__snapshots__/demo.test.js.snap b/components/divider/__tests__/__snapshots__/demo.test.js.snap index 9e7906d16fcc..22c9b0768086 100644 --- a/components/divider/__tests__/__snapshots__/demo.test.js.snap +++ b/components/divider/__tests__/__snapshots__/demo.test.js.snap @@ -12,7 +12,7 @@ exports[`renders ./components/divider/demo/horizontal.md correctly 1`] = ` Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.

= props => ( const { prefixCls: customizePrefixCls, type = 'horizontal', - orientation = '', + orientation = 'center', className, children, dashed, diff --git a/components/divider/style/index.less b/components/divider/style/index.less index bb3110481c87..78fab57b2dba 100644 --- a/components/divider/style/index.less +++ b/components/divider/style/index.less @@ -18,6 +18,7 @@ margin: 0 8px; vertical-align: middle; } + &-horizontal { display: block; clear: both; @@ -27,7 +28,7 @@ margin: 24px 0; } - &-horizontal&-with-text, + &-horizontal&-with-text-center, &-horizontal&-with-text-left, &-horizontal&-with-text-right { display: table; @@ -89,7 +90,7 @@ background: none; border-top: 1px dashed @border-color-split; } - &-horizontal&-with-text&-dashed, + &-horizontal&-with-text-center&-dashed, &-horizontal&-with-text-left&-dashed, &-horizontal&-with-text-right&-dashed { border-top: 0; diff --git a/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap b/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap index f59066fda65c..65212ee27231 100644 --- a/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap +++ b/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap @@ -6,6 +6,7 @@ exports[`Drawer className is test_drawer 1`] = ` >
= createReactContext(null); +const DrawerContext = createReactContext(null); type EventType = React.MouseEvent | React.MouseEvent; @@ -88,8 +88,9 @@ class Drawer extends React.Component { - if (this.props.visible !== undefined) { - if (this.props.onClose) { - this.props.onClose(e); - } - return; + const { visible, onClose } = this.props; + if (visible !== undefined && onClose) { + onClose(e); } }; diff --git a/components/drawer/style/drawer.less b/components/drawer/style/drawer.less index b3d0259f34ce..228c5851654f 100644 --- a/components/drawer/style/drawer.less +++ b/components/drawer/style/drawer.less @@ -187,6 +187,8 @@ &-mask { position: fixed; + top: 0; + left: 0; width: 100%; height: 0; background-color: @modal-mask-bg; diff --git a/components/dropdown/style/index.less b/components/dropdown/style/index.less index ffba8cd93904..99b198566a4c 100644 --- a/components/dropdown/style/index.less +++ b/components/dropdown/style/index.less @@ -102,7 +102,7 @@ &-selected, &-selected > a { - color: @primary-color; + color: @dropdown-selected-color; background-color: @item-active-bg; } diff --git a/components/form/context.ts b/components/form/context.ts index 9caf0828fcf5..1a9508000b6d 100644 --- a/components/form/context.ts +++ b/components/form/context.ts @@ -1,4 +1,4 @@ -import createReactContext, { Context } from '@ant-design/create-react-context'; +import createReactContext from '@ant-design/create-react-context'; import { ColProps } from '../grid/col'; import { FormLabelAlign } from './FormItem'; @@ -10,7 +10,7 @@ export interface FormContextProps { wrapperCol?: ColProps; } -export const FormContext: Context = createReactContext({ +export const FormContext = createReactContext({ labelAlign: 'right', vertical: false, }); diff --git a/components/form/demo/style-check-debug.md b/components/form/demo/style-check-debug.md index 38347775475d..827ad673af77 100644 --- a/components/form/demo/style-check-debug.md +++ b/components/form/demo/style-check-debug.md @@ -17,7 +17,6 @@ Please check this before commit. ```jsx import { Button, Modal, Form, Row, Col, Input, Select, InputNumber, Radio, DatePicker } from 'antd'; -const RadioGroup = Radio.Group; const ColSpan = { lg: 12, md: 24 }; class App extends React.Component { @@ -140,10 +139,10 @@ class App extends React.Component { - + - + diff --git a/components/form/index.en-US.md b/components/form/index.en-US.md index 6fa0161efcc6..2ab893647a0d 100644 --- a/components/form/index.en-US.md +++ b/components/form/index.en-US.md @@ -225,7 +225,7 @@ See more advanced usage at [async-validator](https://github.com/yiminghe/async-v ## Using in TypeScript -```jsx +```tsx import { Form } from 'antd'; import { FormComponentProps } from 'antd/lib/form'; @@ -238,12 +238,9 @@ class UserForm extends React.Component { // ... } -const App = - Form.create < - UserFormProps > - { - // ... - }(UserForm); +const App = Form.create({ + // ... +})(UserForm); ``` diff --git a/components/mentions/demo/basic.md b/components/mentions/demo/basic.md new file mode 100644 index 000000000000..ee9762c691b3 --- /dev/null +++ b/components/mentions/demo/basic.md @@ -0,0 +1,42 @@ +--- +order: 0 +title: + zh-CN: 基本使用 + en-US: Basic +--- + +## zh-CN + +基本使用 + +## en-US + +Basic usage. + +```jsx +import { Mentions } from 'antd'; + +const { Option } = Mentions; + +function onChange(value) { + console.log('Change:', value); +} + +function onSelect(option) { + console.log('select', option); +} + +ReactDOM.render( + + + + + , + mountNode, +); +``` diff --git a/components/mentions/demo/form.md b/components/mentions/demo/form.md new file mode 100644 index 000000000000..36027833b4ea --- /dev/null +++ b/components/mentions/demo/form.md @@ -0,0 +1,81 @@ +--- +order: 2 +title: + zh-CN: 配合 Form 使用 + en-US: With Form +--- + +## zh-CN + +受控模式,例如配合 Form 使用。 + +## en-US + +Controlled mode, for example, to work with `Form`. + +```jsx +import { Mentions, Form, Button } from 'antd'; + +const { Option, getMentions } = Mentions; + +class App extends React.Component { + handleReset = e => { + e.preventDefault(); + this.props.form.resetFields(); + }; + + handleSubmit = e => { + e.preventDefault(); + this.props.form.validateFields((errors, values) => { + if (errors) { + console.log('Errors in the form!!!'); + return; + } + console.log('Submit!!!'); + console.log(values); + }); + }; + + checkMention = (rule, value, callback) => { + const mentions = getMentions(value); + if (mentions.length < 2) { + callback(new Error('More than one must be selected!')); + } else { + callback(); + } + }; + + render() { + const { + form: { getFieldDecorator }, + } = this.props; + + return ( +
+ + {getFieldDecorator('mention', { + rules: [{ validator: this.checkMention }], + })( + + + + + , + )} + + + +     + + +
+ ); + } +} + +const FormDemo = Form.create()(App); + +ReactDOM.render(, mountNode); +``` diff --git a/components/mentions/demo/placement.md b/components/mentions/demo/placement.md new file mode 100644 index 000000000000..450a71eec29f --- /dev/null +++ b/components/mentions/demo/placement.md @@ -0,0 +1,29 @@ +--- +order: 5 +title: + zh-CN: 向上展开 + en-US: Placement +--- + +## zh-CN + +向上展开建议。 + +## en-US + +Change the suggestions placement. + +```jsx +import { Mentions } from 'antd'; + +const { Option } = Mentions; + +ReactDOM.render( + + + + + , + mountNode, +); +``` diff --git a/components/mentions/demo/prefix.md b/components/mentions/demo/prefix.md new file mode 100644 index 000000000000..f70a73ad37c4 --- /dev/null +++ b/components/mentions/demo/prefix.md @@ -0,0 +1,56 @@ +--- +order: 3 +title: + zh-CN: 自定义触发字符 + en-US: Customize Trigger Token +--- + +## zh-CN + +通过 `prefix` 属性自定义触发字符。默认为 `@`, 可以定义为数组。 + +## en-US + +Customize Trigger Token by `prefix` props. Default to `@`, `Array` also supported. + +```jsx +import { Mentions } from 'antd'; + +const { Option } = Mentions; + +const MOCK_DATA = { + '@': ['afc163', 'zombiej', 'yesmeck'], + '#': ['1.0', '2.0', '3.0'], +}; + +class App extends React.Component { + state = { + prefix: '@', + }; + + onSearch = (_, prefix) => { + this.setState({ prefix }); + }; + + render() { + const { prefix } = this.state; + + return ( + + {(MOCK_DATA[prefix] || []).map(value => ( + + ))} + + ); + } +} + +ReactDOM.render(, mountNode); +``` diff --git a/components/mentions/demo/readonly.md b/components/mentions/demo/readonly.md new file mode 100644 index 000000000000..864f4fcb8659 --- /dev/null +++ b/components/mentions/demo/readonly.md @@ -0,0 +1,45 @@ +--- +order: 4 +title: + zh-CN: 无效或只读 + en-US: disabled or readOnly +--- + +## zh-CN + +通过 `disabled` 属性设置是否生效。通过 `readOnly` 属性设置是否只读。 + +## en-US + +Configurate `disabled` and `readOnly`. + +```jsx +import { Mentions } from 'antd'; + +const { Option } = Mentions; + +function getOptions() { + return ['afc163', 'zombiej', 'yesmeck'].map(value => ( + + )); +} + +function App() { + return ( +
+
+ + {getOptions()} + +
+ + {getOptions()} + +
+ ); +} + +ReactDOM.render(, mountNode); +``` diff --git a/components/mentions/index.en-US.md b/components/mentions/index.en-US.md new file mode 100644 index 000000000000..547a7900780c --- /dev/null +++ b/components/mentions/index.en-US.md @@ -0,0 +1,54 @@ +--- +category: Components +type: Data Entry +title: Mentions +--- + +Mention component. + +> Mention component is deprecated. Please click [here](/components/mention) to view old document. + +## When To Use + +When need to mention someone or something. + +## API + +```jsx + + Sample + +``` + +### Mention + +| Property | Description | Type | Default | +| --- | --- | --- | --- | +| autoFocus | Auto get focus when component mounted | boolean | `false` | +| defaultValue | Default value | string | - | +| filterOption | Customize filter option logic | false \| (input: string, option: OptionProps) => boolean | - | +| notFoundContent | Set mentions content when not match | ReactNode | 'Not Found' | +| placement | Set popup placement | 'top' \| 'bottom' | 'bottom' | +| prefix | Set trigger prefix keyword | string \| string[] | '@' | +| split | Set split string before and after selected mention | string | ' ' | +| validateSearch | Customize trigger search logic | (text: string, props: MentionsProps) => void | - | +| value | Set value of mentions | string | - | +| onChange | Trigger when value changed | (text: string) => void | - | +| onSelect | Trigger when user select the option | (option: OptionProps, prefix: string) => void | - | +| onSearch | Trigger when prefix hit | (text: string, prefix: string) => void | - | +| onFocus | Trigger when mentions get focus | () => void | - | +| onBlur | Trigger when mentions lose focus | () => void | - | + +### Mention methods + +| Name | Description | +| ------- | ------------ | +| blur() | remove focus | +| focus() | get focus | + +### Option + +| Property | Description | Type | Default | +| --- | --- | --- | --- | +| children | suggestion content | ReactNode | - | +| value | value of suggestion, the value will insert into input filed while selected | string | '' | diff --git a/components/mentions/index.tsx b/components/mentions/index.tsx new file mode 100644 index 000000000000..0e756ea22c65 --- /dev/null +++ b/components/mentions/index.tsx @@ -0,0 +1,165 @@ +import classNames from 'classnames'; +import omit from 'omit.js'; +import * as React from 'react'; +import { polyfill } from 'react-lifecycles-compat'; +import RcMentions from 'rc-mentions'; +import { MentionsProps as RcMentionsProps } from 'rc-mentions/lib/Mentions'; +import { OptionProps as RcOptionProps } from 'rc-mentions/lib/Option'; +import Spin from '../spin'; +import { ConfigConsumer, ConfigConsumerProps, RenderEmptyHandler } from '../config-provider'; + +const Option: React.FunctionComponent = RcMentions.Option; + +function loadingFilterOption() { + return true; +} + +export type MentionPlacement = 'top' | 'bottom'; + +export interface OptionProps { + value: string; + children: React.ReactNode; + [key: string]: any; +} + +export interface MentionProps extends RcMentionsProps { + loading?: boolean; +} + +export interface MentionState { + focused: boolean; +} + +interface MentionsConfig { + prefix?: string | string[]; + split?: string; +} + +interface MentionsEntity { + prefix: string; + value: string; +} + +class Mentions extends React.Component { + static Option = Option; + + static getMentions = (value: string = '', config?: MentionsConfig): MentionsEntity[] => { + const { prefix = '@', split = ' ' } = config || {}; + const prefixList: string[] = Array.isArray(prefix) ? prefix : [prefix]; + + return value + .split(split) + .map( + (str = ''): MentionsEntity | null => { + let hitPrefix: string | null = null; + + prefixList.some(prefixStr => { + const startStr = str.slice(0, prefixStr.length); + if (startStr === prefixStr) { + hitPrefix = prefixStr; + return true; + } + return false; + }); + + if (hitPrefix !== null) { + return { + prefix: hitPrefix, + value: str.slice(hitPrefix!.length), + }; + } + return null; + }, + ) + .filter((entity): entity is MentionsEntity => !!entity && !!entity.value); + }; + + state = { + focused: false, + }; + + onFocus: React.FocusEventHandler = (...args) => { + const { onFocus } = this.props; + if (onFocus) { + onFocus(...args); + } + this.setState({ + focused: true, + }); + }; + + onBlur: React.FocusEventHandler = (...args) => { + const { onBlur } = this.props; + if (onBlur) { + onBlur(...args); + } + this.setState({ + focused: false, + }); + }; + + getNotFoundContent(renderEmpty: RenderEmptyHandler) { + const { notFoundContent } = this.props; + if (notFoundContent !== undefined) { + return notFoundContent; + } + + return renderEmpty('Select'); + } + + getOptions = () => { + const { children, loading } = this.props; + if (loading) { + return ( + + ); + } + + return children; + }; + + getFilterOption = (): any => { + const { filterOption, loading } = this.props; + if (loading) { + return loadingFilterOption; + } + return filterOption; + }; + + renderMentions = ({ getPrefixCls, renderEmpty }: ConfigConsumerProps) => { + const { focused } = this.state; + const { prefixCls: customizePrefixCls, className, disabled, ...restProps } = this.props; + const prefixCls = getPrefixCls('mentions', customizePrefixCls); + const mentionsProps = omit(restProps, ['loading']); + + const mergedClassName = classNames(className, { + [`${prefixCls}-disabled`]: disabled, + [`${prefixCls}-focused`]: focused, + }); + + return ( + + {this.getOptions()} + + ); + }; + + render() { + return {this.renderMentions}; + } +} + +polyfill(Mentions); + +export default Mentions; diff --git a/components/mentions/index.zh-CN.md b/components/mentions/index.zh-CN.md new file mode 100644 index 000000000000..df5877f5e622 --- /dev/null +++ b/components/mentions/index.zh-CN.md @@ -0,0 +1,64 @@ +--- +category: Components +subtitle: 提及 +type: 数据录入 +title: Mentions +--- + +提及组件。 + +> 原 Mention 组件已废弃,原文档请点击[这里](/components/mention)。 + +## 何时使用 + +用于在输入中提及某人或某事,常用于发布、聊天或评论功能。 + +## API + +```jsx + +``` + +## API + +```jsx + + Sample + +``` + +### Mention + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| autoFocus | 自动获得焦点 | boolean | `false` | +| defaultValue | 默认值 | string | - | +| filterOption | 自定义过滤逻辑 | false \| (input: string, option: OptionProps) => boolean | - | +| notFoundContent | 当下拉列表为空时显示的内容 | ReactNode | 'Not Found' | +| placement | 弹出层展示位置 | 'top' \| 'bottom' | 'bottom' | +| prefix | 设置触发关键字 | string \| string[] | '@' | +| split | 设置选中项前后分隔符 | string | ' ' | +| validateSearch | 自定义触发验证逻辑 | (text: string, props: MentionsProps) => void | - | +| value | 设置值 | string | - | +| onChange | 值改变时触发 | (text: string) => void | - | +| onSelect | 选择选项时触发 | (option: OptionProps, prefix: string) => void | - | +| onSearch | 搜索时触发 | (text: string, prefix: string) => void | - | +| onFocus | 获得焦点时触发 | () => void | - | +| onBlur | 失去焦点时触发 | () => void | - | + +### Mention 方法 + +| 名称 | 描述 | +| ------- | -------- | +| blur() | 移除焦点 | +| focus() | 获取焦点 | + +### Option + +| 参数 | 说明 | 类型 | 默认值 | +| -------- | -------------- | --------- | ------ | +| children | 选项内容 | ReactNode | - | +| value | 选择时填充的值 | string | '' | diff --git a/components/mentions/style/index.less b/components/mentions/style/index.less new file mode 100644 index 000000000000..557e63204c3a --- /dev/null +++ b/components/mentions/style/index.less @@ -0,0 +1,156 @@ +@import '../../style/themes/index'; +@import '../../style/mixins/index'; +@import '../../input/style/mixin'; + +@mention-prefix-cls: ~'@{ant-prefix}-mentions'; + +.@{mention-prefix-cls} { + .reset-component; + .input; + + position: relative; + display: inline-block; + height: auto; + white-space: pre-wrap; + padding: 0; + overflow: hidden; + vertical-align: bottom; + + // =================== Status =================== + &-disabled { + > textarea { + .disabled(); + } + } + + &-focused { + .active(); + } + + // ================= Input Area ================= + > textarea, + &-measure { + margin: 0; + padding: @input-padding-vertical-base @input-padding-horizontal-base; + overflow: inherit; + overflow-x: initial; + overflow-y: auto; + font-weight: inherit; + font-size: inherit; + font-family: inherit; + font-style: inherit; + font-variant: inherit; + font-size-adjust: inherit; + font-stretch: inherit; + line-height: inherit; + direction: inherit; + letter-spacing: inherit; + white-space: inherit; + text-align: inherit; + vertical-align: top; + word-wrap: break-word; + word-break: inherit; + tab-size: inherit; + } + + > textarea { + width: 100%; + border: none; + outline: none; + resize: none; + + &:read-only { + cursor: default; + } + } + + &-measure { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: -1; + color: transparent; + pointer-events: none; + } + + // ================== Dropdown ================== + &-dropdown { + // Ref select dropdown style + .reset-component; + + position: absolute; + top: -9999px; + left: -9999px; + z-index: @zindex-dropdown; + box-sizing: border-box; + font-size: @font-size-base; + font-variant: initial; + background-color: @component-background; + border-radius: @border-radius-base; + outline: none; + box-shadow: @box-shadow-base; + + &-hidden { + display: none; + } + + &-menu { + max-height: 250px; + margin-bottom: 0; + padding-left: 0; // Override default ul/ol + overflow: auto; + list-style: none; + outline: none; + + &-item { + position: relative; + display: block; + padding: 5px @control-padding-horizontal; + overflow: hidden; + color: @text-color; + font-weight: normal; + line-height: 22px; + white-space: nowrap; + text-overflow: ellipsis; + cursor: pointer; + min-width: 100px; + transition: background 0.3s ease; + + &:hover { + background-color: @item-hover-bg; + } + + &:first-child { + border-radius: @border-radius-base @border-radius-base 0 0; + } + + &:last-child { + border-radius: 0 0 @border-radius-base @border-radius-base; + } + + &-disabled { + color: @disabled-color; + cursor: not-allowed; + + &:hover { + color: @disabled-color; + background-color: @component-background; + cursor: not-allowed; + } + } + + &-selected { + color: @text-color; + font-weight: @select-item-selected-font-weight; + background-color: @background-color-light; + } + + &-active { + background-color: @item-active-bg; + } + } + } + } +} diff --git a/components/mentions/style/index.tsx b/components/mentions/style/index.tsx new file mode 100644 index 000000000000..5fa72cf4f674 --- /dev/null +++ b/components/mentions/style/index.tsx @@ -0,0 +1,5 @@ +import './index.less'; + +// style dependencies +import '../../empty/style'; +import '../../spin/style'; diff --git a/components/menu/MenuItem.tsx b/components/menu/MenuItem.tsx index f09cef532cea..9ee06d19322c 100644 --- a/components/menu/MenuItem.tsx +++ b/components/menu/MenuItem.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { Item } from 'rc-menu'; import { ClickParam } from '.'; import { MenuContext, MenuContextProps } from './'; -import Tooltip from '../tooltip'; +import Tooltip, { TooltipProps } from '../tooltip'; import { SiderContext, SiderContextProps } from '../layout/Sider'; export interface MenuItemProps { @@ -37,13 +37,19 @@ export default class MenuItem extends React.Component { return ( {({ inlineCollapsed }: MenuContextProps) => { + const tooltipProps: TooltipProps = {}; + let titleNode = title || (level === 1 ? children : ''); if (!siderCollapsed && !inlineCollapsed) { titleNode = null; + // Reset `visible` to fix control mode tooltip display not correct + // ref: https://github.com/ant-design/ant-design/issues/16742 + tooltipProps.visible = false; } return ( } > - + Option 1 Option 2 - - + + Option 3 Option 4 - + diff --git a/components/menu/demo/inline-collapsed.md b/components/menu/demo/inline-collapsed.md index 76936207b241..807d21f7d1ec 100644 --- a/components/menu/demo/inline-collapsed.md +++ b/components/menu/demo/inline-collapsed.md @@ -20,7 +20,7 @@ Here is [a complete demo](/components/layout/#components-layout-demo-side) with ```jsx import { Menu, Icon, Button } from 'antd'; -const SubMenu = Menu.SubMenu; +const { SubMenu } = Menu; class App extends React.Component { state = { diff --git a/components/menu/demo/inline.md b/components/menu/demo/inline.md index 5453b14bd351..2a1b85ea7eb8 100755 --- a/components/menu/demo/inline.md +++ b/components/menu/demo/inline.md @@ -16,8 +16,7 @@ Vertical menu with inline submenus. ```jsx import { Menu, Icon } from 'antd'; -const SubMenu = Menu.SubMenu; -const MenuItemGroup = Menu.ItemGroup; +const { SubMenu } = Menu; class Sider extends React.Component { handleClick = e => { @@ -42,14 +41,14 @@ class Sider extends React.Component { } > - + Option 1 Option 2 - - + + Option 3 Option 4 - + } > - + Option 1 Option 2 - - + + Option 3 Option 4 - + void; getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement; overflowedIndicator?: React.ReactNode; + forceSubMenuRender?: boolean; } type InternalMenuProps = MenuProps & SiderContextProps; @@ -78,7 +79,7 @@ export interface MenuContextProps { antdMenuTheme?: MenuTheme; } -export const MenuContext: Context = createContext({ +export const MenuContext = createContext({ inlineCollapsed: false, }); @@ -142,6 +143,12 @@ class InternalMenu extends React.Component { '`inlineCollapsed` should only be used when `mode` is inline.', ); + warning( + !(props.siderCollapsed !== undefined && 'inlineCollapsed' in props), + 'Menu', + '`inlineCollapsed` not control Menu under Sider. Should set `collapsed` on Sider instead.', + ); + let openKeys; if ('openKeys' in props) { openKeys = props.openKeys; diff --git a/components/menu/style/index.less b/components/menu/style/index.less index 78b21fb68b9c..acbfdef49efe 100644 --- a/components/menu/style/index.less +++ b/components/menu/style/index.less @@ -43,6 +43,10 @@ padding 0.15s @ease-in-out; } + &-submenu-selected { + color: @menu-highlight-color; + } + &-item:active, &-submenu-title:active { background: @menu-item-active-bg; diff --git a/components/message/demo/other.md b/components/message/demo/other.md index fb6fd3aadc9a..bf4089d5ef3e 100644 --- a/components/message/demo/other.md +++ b/components/message/demo/other.md @@ -17,15 +17,15 @@ Messages of success, error and warning types. import { message, Button } from 'antd'; const success = () => { - message.success('This is a message of success'); + message.success('This is a success message'); }; const error = () => { - message.error('This is a message of error'); + message.error('This is an error message'); }; const warning = () => { - message.warning('This is message of warning'); + message.warning('This is a warning message'); }; ReactDOM.render( diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index cb4be684cf09..d656470b4182 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -140,8 +140,6 @@ export default class Modal extends React.Component { confirmLoading: false, visible: false, okType: 'primary' as ButtonType, - okButtonDisabled: false, - cancelButtonDisabled: false, }; static propTypes = { @@ -154,7 +152,6 @@ export default class Modal extends React.Component { width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), confirmLoading: PropTypes.bool, visible: PropTypes.bool, - align: PropTypes.object, footer: PropTypes.node, title: PropTypes.node, closable: PropTypes.bool, diff --git a/components/modal/__tests__/__snapshots__/Modal.test.js.snap b/components/modal/__tests__/__snapshots__/Modal.test.js.snap index 426532fc2874..d2d8fa541722 100644 --- a/components/modal/__tests__/__snapshots__/Modal.test.js.snap +++ b/components/modal/__tests__/__snapshots__/Modal.test.js.snap @@ -28,6 +28,7 @@ exports[`Modal render correctly 1`] = ` ; diff --git a/components/tabs/demo/icon.md b/components/tabs/demo/icon.md index 5a1e8e73f12c..c395652bbea1 100644 --- a/components/tabs/demo/icon.md +++ b/components/tabs/demo/icon.md @@ -16,7 +16,7 @@ The Tab with Icon. ```jsx import { Tabs, Icon } from 'antd'; -const TabPane = Tabs.TabPane; +const { TabPane } = Tabs; ReactDOM.render( diff --git a/components/tabs/demo/nest.md b/components/tabs/demo/nest.md index 8b9b17ac657b..c4f9a9762917 100644 --- a/components/tabs/demo/nest.md +++ b/components/tabs/demo/nest.md @@ -2,7 +2,7 @@ order: 99 debug: true title: - zh-CN: 基本 + zh-CN: 嵌套 en-US: Nest --- @@ -17,8 +17,8 @@ Default activate first tab. ```jsx import { Tabs, Select } from 'antd'; -const TabPane = Tabs.TabPane; -const Option = Select.Option; +const { TabPane } = Tabs; +const { Option } = Select; const positionList = ['left', 'right', 'top', 'bottom']; diff --git a/components/tabs/demo/position.md b/components/tabs/demo/position.md index a091c5d3e80d..ac0d74a7b06c 100644 --- a/components/tabs/demo/position.md +++ b/components/tabs/demo/position.md @@ -16,8 +16,8 @@ Tab's position: left, right, top or bottom. ```jsx import { Tabs, Select } from 'antd'; -const TabPane = Tabs.TabPane; -const Option = Select.Option; +const { TabPane } = Tabs; +const { Option } = Select; class Demo extends React.Component { state = { diff --git a/components/tabs/demo/slide.md b/components/tabs/demo/slide.md index fe71fc22cc51..4cfda29993cb 100644 --- a/components/tabs/demo/slide.md +++ b/components/tabs/demo/slide.md @@ -16,7 +16,7 @@ In order to fit in more tabs, they can slide left and right (or up and down). ```jsx import { Tabs, Radio } from 'antd'; -const TabPane = Tabs.TabPane; +const { TabPane } = Tabs; class SlidingTabsDemo extends React.Component { constructor(props) { @@ -40,39 +40,11 @@ class SlidingTabsDemo extends React.Component { Vertical - - Content of tab 1 - - - Content of tab 2 - - - Content of tab 3 - - - Content of tab 4 - - - Content of tab 5 - - - Content of tab 6 - - - Content of tab 7 - - - Content of tab 8 - - - Content of tab 9 - - - Content of tab 10 - - - Content of tab 11 - + {[...Array(30).keys()].map((i) => ( + + Content of tab {i} + + ))}
); diff --git a/components/tabs/style/card-style.less b/components/tabs/style/card-style.less index 728a64cc0d11..3cea4d72a7f6 100644 --- a/components/tabs/style/card-style.less +++ b/components/tabs/style/card-style.less @@ -97,7 +97,7 @@ &-vertical&-card &-card-bar&-left-bar, &-vertical&-card &-card-bar&-right-bar { .@{tab-prefix-cls}-nav-container { - height: auto; + height: 100%; } .@{tab-prefix-cls}-tab { margin-bottom: 8px; diff --git a/components/time-picker/__tests__/__snapshots__/index.test.js.snap b/components/time-picker/__tests__/__snapshots__/index.test.js.snap index 0662234eef6b..773d6e63ab25 100644 --- a/components/time-picker/__tests__/__snapshots__/index.test.js.snap +++ b/components/time-picker/__tests__/__snapshots__/index.test.js.snap @@ -41,28 +41,53 @@ exports[`TimePicker not render clean icon when allowClear is false 1`] = ` `; exports[`TimePicker prop locale should works 1`] = ` - - +Array [ + + + + + + - - + , +
+
+
+
+ +
+
+
+
    +
  • + 00 +
  • +
  • + 01 +
  • +
  • + 02 +
  • +
  • + 03 +
  • +
  • + 04 +
  • +
  • + 05 +
  • +
  • + 06 +
  • +
  • + 07 +
  • +
  • + 08 +
  • +
  • + 09 +
  • +
  • + 10 +
  • +
  • + 11 +
  • +
  • + 12 +
  • +
  • + 13 +
  • +
  • + 14 +
  • +
  • + 15 +
  • +
  • + 16 +
  • +
  • + 17 +
  • +
  • + 18 +
  • +
  • + 19 +
  • +
  • + 20 +
  • +
  • + 21 +
  • +
  • + 22 +
  • +
  • + 23 +
  • +
+
+
+
    +
  • + 00 +
  • +
  • + 01 +
  • +
  • + 02 +
  • +
  • + 03 +
  • +
  • + 04 +
  • +
  • + 05 +
  • +
  • + 06 +
  • +
  • + 07 +
  • +
  • + 08 +
  • +
  • + 09 +
  • +
  • + 10 +
  • +
  • + 11 +
  • +
  • + 12 +
  • +
  • + 13 +
  • +
  • + 14 +
  • +
  • + 15 +
  • +
  • + 16 +
  • +
  • + 17 +
  • +
  • + 18 +
  • +
  • + 19 +
  • +
  • + 20 +
  • +
  • + 21 +
  • +
  • + 22 +
  • +
  • + 23 +
  • +
  • + 24 +
  • +
  • + 25 +
  • +
  • + 26 +
  • +
  • + 27 +
  • +
  • + 28 +
  • +
  • + 29 +
  • +
  • + 30 +
  • +
  • + 31 +
  • +
  • + 32 +
  • +
  • + 33 +
  • +
  • + 34 +
  • +
  • + 35 +
  • +
  • + 36 +
  • +
  • + 37 +
  • +
  • + 38 +
  • +
  • + 39 +
  • +
  • + 40 +
  • +
  • + 41 +
  • +
  • + 42 +
  • +
  • + 43 +
  • +
  • + 44 +
  • +
  • + 45 +
  • +
  • + 46 +
  • +
  • + 47 +
  • +
  • + 48 +
  • +
  • + 49 +
  • +
  • + 50 +
  • +
  • + 51 +
  • +
  • + 52 +
  • +
  • + 53 +
  • +
  • + 54 +
  • +
  • + 55 +
  • +
  • + 56 +
  • +
  • + 57 +
  • +
  • + 58 +
  • +
  • + 59 +
  • +
+
+
+
    +
  • + 00 +
  • +
  • + 01 +
  • +
  • + 02 +
  • +
  • + 03 +
  • +
  • + 04 +
  • +
  • + 05 +
  • +
  • + 06 +
  • +
  • + 07 +
  • +
  • + 08 +
  • +
  • + 09 +
  • +
  • + 10 +
  • +
  • + 11 +
  • +
  • + 12 +
  • +
  • + 13 +
  • +
  • + 14 +
  • +
  • + 15 +
  • +
  • + 16 +
  • +
  • + 17 +
  • +
  • + 18 +
  • +
  • + 19 +
  • +
  • + 20 +
  • +
  • + 21 +
  • +
  • + 22 +
  • +
  • + 23 +
  • +
  • + 24 +
  • +
  • + 25 +
  • +
  • + 26 +
  • +
  • + 27 +
  • +
  • + 28 +
  • +
  • + 29 +
  • +
  • + 30 +
  • +
  • + 31 +
  • +
  • + 32 +
  • +
  • + 33 +
  • +
  • + 34 +
  • +
  • + 35 +
  • +
  • + 36 +
  • +
  • + 37 +
  • +
  • + 38 +
  • +
  • + 39 +
  • +
  • + 40 +
  • +
  • + 41 +
  • +
  • + 42 +
  • +
  • + 43 +
  • +
  • + 44 +
  • +
  • + 45 +
  • +
  • + 46 +
  • +
  • + 47 +
  • +
  • + 48 +
  • +
  • + 49 +
  • +
  • + 50 +
  • +
  • + 51 +
  • +
  • + 52 +
  • +
  • + 53 +
  • +
  • + 54 +
  • +
  • + 55 +
  • +
  • + 56 +
  • +
  • + 57 +
  • +
  • + 58 +
  • +
  • + 59 +
  • +
+
+
+
+
+
, +] `; exports[`TimePicker renders addon correctly 1`] = ` diff --git a/components/time-picker/__tests__/index.test.js b/components/time-picker/__tests__/index.test.js index 1ec96fc081cf..c9074382ee6a 100644 --- a/components/time-picker/__tests__/index.test.js +++ b/components/time-picker/__tests__/index.test.js @@ -73,7 +73,7 @@ describe('TimePicker', () => { const locale = { placeholder: 'Избери дата', }; - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.render()).toMatchSnapshot(); }); }); diff --git a/components/time-picker/locale/lv_LV.tsx b/components/time-picker/locale/lv_LV.tsx new file mode 100644 index 000000000000..5e3890e7b86c --- /dev/null +++ b/components/time-picker/locale/lv_LV.tsx @@ -0,0 +1,5 @@ +const locale = { + placeholder: 'Izvēlieties laiku', +}; + +export default locale; diff --git a/components/time-picker/style/index.less b/components/time-picker/style/index.less index 372d2e91d73e..0785200e0c68 100644 --- a/components/time-picker/style/index.less +++ b/components/time-picker/style/index.less @@ -225,3 +225,14 @@ right: @control-padding-horizontal-sm - 1px; } } + +// Fix cursor height in safari +// https://stackoverflow.com/q/3843408/3040605 +// https://browserstrangeness.github.io/css_hacks.html#safari +@media not all and (min-resolution: 0.001dpcm) { + @supports (-webkit-appearance: none) and (stroke-color: transparent) { + .@{ant-prefix}-input { + line-height: @line-height-base; + } + } +} diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index 80f68ab2e116..ebbe21edc232 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -159,26 +159,25 @@ export default class TransferList extends React.Component ) : null; - const searchNotFound = !filteredItems.length && ( -
{notFoundContent}
- ); - let listBody: React.ReactNode = bodyDom; if (!listBody) { - let bodyNode: React.ReactNode = searchNotFound; - if (!bodyNode) { - const { bodyContent, customize } = renderListNode(renderList, { - ...omit(this.props, OmitProps), - filteredItems, - filteredRenderItems, - selectedKeys: checkedKeys, - }); - - // We should wrap customize list body in a classNamed div to use flex layout. - bodyNode = customize ? ( -
{bodyContent}
- ) : ( + let bodyNode: React.ReactNode; + + const { bodyContent, customize } = renderListNode(renderList, { + ...omit(this.props, OmitProps), + filteredItems, + filteredRenderItems, + selectedKeys: checkedKeys, + }); + + // We should wrap customize list body in a classNamed div to use flex layout. + if (customize) { + bodyNode =
{bodyContent}
; + } else { + bodyNode = filteredItems.length ? ( bodyContent + ) : ( +
{notFoundContent}
); } diff --git a/components/transfer/renderListBody.tsx b/components/transfer/renderListBody.tsx index 33983ef446b0..cfed6948c419 100644 --- a/components/transfer/renderListBody.tsx +++ b/components/transfer/renderListBody.tsx @@ -36,7 +36,7 @@ class ListBody extends React.Component { }); } - componentWillMount() { + componentWillUnmount() { raf.cancel(this.mountId); } diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx index 372ed33647dd..d3e58c4ea18e 100644 --- a/components/tree/Tree.tsx +++ b/components/tree/Tree.tsx @@ -25,6 +25,7 @@ export interface AntdTreeNodeAttribute { disabled: boolean; disableCheckbox: boolean; } + export interface AntTreeNodeProps { className?: string; checkable?: boolean; @@ -72,6 +73,10 @@ export interface AntTreeNodeMouseEvent { event: React.MouseEvent; } +export interface AntTreeNodeDragEnterEvent extends AntTreeNodeMouseEvent { + expandedKeys: string[]; +} + export interface AntTreeNodeDropEvent { node: AntTreeNode; dragNode: AntTreeNode; @@ -135,7 +140,7 @@ export interface TreeProps { /** 设置节点可拖拽(IE>8)*/ draggable?: boolean; onDragStart?: (options: AntTreeNodeMouseEvent) => void; - onDragEnter?: (options: AntTreeNodeMouseEvent) => void; + onDragEnter?: (options: AntTreeNodeDragEnterEvent) => void; onDragOver?: (options: AntTreeNodeMouseEvent) => void; onDragLeave?: (options: AntTreeNodeMouseEvent) => void; onDragEnd?: (options: AntTreeNodeMouseEvent) => void; diff --git a/components/tree/demo/directory.md b/components/tree/demo/directory.md index e045dcaca6f5..0bfd4e35d9f1 100644 --- a/components/tree/demo/directory.md +++ b/components/tree/demo/directory.md @@ -16,8 +16,7 @@ Built-in directory tree. `multiple` support `ctrl(Windows)` / `command(Mac)` sel ```jsx import { Tree } from 'antd'; -const DirectoryTree = Tree.DirectoryTree; -const { TreeNode } = Tree; +const { TreeNode, DirectoryTree } = Tree; class Demo extends React.Component { onSelect = (keys, event) => { diff --git a/components/tree/style/index.less b/components/tree/style/index.less index ca9053870a6d..da347b39f70d 100644 --- a/components/tree/style/index.less +++ b/components/tree/style/index.less @@ -244,7 +244,8 @@ left: 12px; width: 1px; height: 100%; - margin: 22px 0; + height: calc(100% - 22px); // Remove additional height if support + margin: 22px 0 0; border-left: 1px solid @border-color-base; content: ' '; } diff --git a/components/typography/Text.tsx b/components/typography/Text.tsx index 5af5355d3b51..25c816521abf 100644 --- a/components/typography/Text.tsx +++ b/components/typography/Text.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import warning from '../_util/warning'; import Base, { BlockProps } from './Base'; -interface TextProps extends BlockProps { +export interface TextProps extends BlockProps { ellipsis?: boolean; } @@ -10,7 +10,7 @@ const Text: React.SFC = ({ ellipsis, ...restProps }) => { warning( typeof ellipsis !== 'object', 'Typography.Text', - '`ellipsis` is only support boolean value.', + '`ellipsis` only supports boolean value.', ); return ; }; diff --git a/components/typography/index.tsx b/components/typography/index.tsx index 73bbd766d2b3..e490b21fd5be 100644 --- a/components/typography/index.tsx +++ b/components/typography/index.tsx @@ -3,7 +3,7 @@ import Text from './Text'; import Title from './Title'; import Paragraph from './Paragraph'; -type TypographyProps = typeof OriginTypography & { +export type TypographyProps = typeof OriginTypography & { Text: typeof Text; Title: typeof Title; Paragraph: typeof Paragraph; diff --git a/components/typography/style/index.less b/components/typography/style/index.less index 30c75b887944..47c691b9b912 100644 --- a/components/typography/style/index.less +++ b/components/typography/style/index.less @@ -39,11 +39,11 @@ } &&-warning { - color: @text-color-warning; + color: @warning-color; } &&-danger { - color: @text-color-danger; + color: @error-color; } &&-disabled { diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index 0751b2e6ffbc..1564fb6cbce4 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -238,7 +238,7 @@ class Upload extends React.Component { }; renderUploadList = (locale: UploadLocale) => { - const { showUploadList, listType, onPreview, previewFile } = this.props; + const { showUploadList, listType, onPreview, previewFile, disabled } = this.props; const { showRemoveIcon, showPreviewIcon } = showUploadList as any; return ( { previewFile={previewFile} onPreview={onPreview} onRemove={this.handleManualRemove} - showRemoveIcon={showRemoveIcon} + showRemoveIcon={!disabled && showRemoveIcon} showPreviewIcon={showPreviewIcon} locale={{ ...locale, ...this.props.locale }} /> diff --git a/components/upload/demo/picture-card.md b/components/upload/demo/picture-card.md index 6b9e5a926317..bafbb9811659 100644 --- a/components/upload/demo/picture-card.md +++ b/components/upload/demo/picture-card.md @@ -16,6 +16,15 @@ After users upload picture, the thumbnail will be shown in list. The upload butt ```jsx import { Upload, Icon, Modal } from 'antd'; +function getBase64(file) { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = error => reject(error); + }); +} + class PicturesWall extends React.Component { state = { previewVisible: false, @@ -32,9 +41,13 @@ class PicturesWall extends React.Component { handleCancel = () => this.setState({ previewVisible: false }); - handlePreview = file => { + handlePreview = async file => { + if (!file.url && !file.preview) { + file.preview = await getBase64(file.originFileObj); + } + this.setState({ - previewImage: file.url || file.thumbUrl, + previewImage: file.url || file.preview, previewVisible: true, }); }; diff --git a/components/upload/interface.tsx b/components/upload/interface.tsx index d744e1b5ae09..0efe181cb042 100755 --- a/components/upload/interface.tsx +++ b/components/upload/interface.tsx @@ -8,7 +8,8 @@ export interface HttpRequestHeader { export interface RcFile extends File { uid: string; - lastModifiedDate: Date; + readonly lastModifiedDate: Date; + readonly webkitRelativePath: string; } export interface UploadFile { @@ -58,7 +59,7 @@ export interface UploadProps { name?: string; defaultFileList?: Array; fileList?: Array; - action?: string | ((file: UploadFile) => PromiseLike); + action?: string | ((file: RcFile) => string) | ((file: RcFile) => PromiseLike); directory?: boolean; data?: Object | ((file: UploadFile) => any); headers?: HttpRequestHeader; @@ -70,7 +71,7 @@ export interface UploadProps { listType?: UploadListType; className?: string; onPreview?: (file: UploadFile) => void; - onRemove?: (file: UploadFile) => void | boolean; + onRemove?: (file: UploadFile) => void | boolean | Promise; supportServerRender?: boolean; style?: React.CSSProperties; disabled?: boolean; diff --git a/components/upload/style/index.less b/components/upload/style/index.less index 26f6dd58d5d9..216b71a6f367 100644 --- a/components/upload/style/index.less +++ b/components/upload/style/index.less @@ -29,6 +29,10 @@ display: inline-block; } + &&-disabled { + cursor: not-allowed; + } + &&-select-picture-card { display: table; width: @upload-picture-card-size; diff --git a/docs/react/customize-theme.en-US.md b/docs/react/customize-theme.en-US.md index 50ce459c0cd1..04cb08f06d9d 100644 --- a/docs/react/customize-theme.en-US.md +++ b/docs/react/customize-theme.en-US.md @@ -3,7 +3,7 @@ order: 5 title: Customize Theme --- -Ant Design allows you to customize some basic design aspects in order to meet the needs of UI diversity from business and brand, including primary color, border radius, border color, etc. +Ant Design allows you to customize our design tokens in order to meet the needs of UI diversity from business and brand, including primary color, border radius, border color, etc. ![customized themes](https://zos.alipayobjects.com/rmsportal/zTFoszBtDODhXfLAazfSpYbSLSEeytoG.png) diff --git a/docs/react/customize-theme.zh-CN.md b/docs/react/customize-theme.zh-CN.md index 5b002acecaa5..b7c06ab24f13 100644 --- a/docs/react/customize-theme.zh-CN.md +++ b/docs/react/customize-theme.zh-CN.md @@ -3,7 +3,7 @@ order: 5 title: 定制主题 --- -Ant Design 设计规范上支持一定程度的样式定制,以满足业务和品牌上多样化的视觉需求,包括但不限于主色、圆角、边框和部分组件的视觉定制。 +Ant Design 设计规范和技术上支持灵活的样式定制,以满足业务和品牌上多样化的视觉需求,包括但不限于全局样式(主色、圆角、边框)和指定组件的视觉定制。 ![一些配置好的主题](https://zos.alipayobjects.com/rmsportal/zTFoszBtDODhXfLAazfSpYbSLSEeytoG.png) diff --git a/docs/react/faq.en-US.md b/docs/react/faq.en-US.md index dbee697cb6fe..01953e1edae0 100644 --- a/docs/react/faq.en-US.md +++ b/docs/react/faq.en-US.md @@ -106,6 +106,19 @@ If you need some features which should not be included in antd, try to extend an You can config `nonce` by [ConfigProvider](/components/config-provider/#Content-Security-Policy). +### When set `mode` to DatePicker/RangePicker, cannot select year or month anymore? + +In real world development, you may need a YearPicker, MonthRangePicker or WeekRangePicker. You are trying to add `mode` to DatePicker/RangePicker expected to implement those pickers. However, the DatePicker/RangePicker cannot be selected and the panels won't close now! + +- Reproduce link: https://codesandbox.io/s/dank-brook-v1csy +- Same issues:[#15572](https://github.com/ant-design/ant-design/issues/15572), [#16436](https://github.com/ant-design/ant-design/issues/16436), [#11938](https://github.com/ant-design/ant-design/issues/11938), [#11735](https://github.com/ant-design/ant-design/issues/11735), [#11586](https://github.com/ant-design/ant-design/issues/11586), [#10425](https://github.com/ant-design/ant-design/issues/10425), [#11053](https://github.com/ant-design/ant-design/issues/11053) + +Like [the explaination](https://github.com/ant-design/ant-design/issues/11586#issuecomment-429189877) here, that is because `` do not equal to `YearPicker`, `` do not equal to `MonthRangePicker` either. The `mode` property was added to support [showing time picker panel in DatePicker](https://github.com/ant-design/ant-design/issues/5190) in antd 3.0, which simply control the displayed panel and won't change the original date picking behavior of `DatePicker/RangePicker` (for instance you still need to click date cell to finish selection in a DatePicker, whatever the `mode` is). + +##### Workaround + +You can refer to [this article](https://juejin.im/post/5cf65c366fb9a07eca6968f9) or [this article](https://www.cnblogs.com/zyl-Tara/p/10197177.html), using `mode` and `onPanelChange` to encapsulate a `YearPicker` or `MonthRangePicker` for your needs. Or you can wait for our [antd@4.0](https://github.com/ant-design/ant-design/issues/16911), in which we are planing to [add more XxxPickers](https://github.com/ant-design/ant-design/issues/4524#issuecomment-480576884) for those requirments. + ### How to spell Ant Design correctly? - ✅ **Ant Design**: Capitalized with space, for the design language. @@ -124,11 +137,7 @@ Here are some typical wrong examples: ### Do you guys have any channel for donation, like PayPal or Alipay? -Not yet. - -### Why not? - -Alibaba pays us. +[https://opencollective.com/ant-design](https://opencollective.com/ant-design) --- diff --git a/docs/react/faq.zh-CN.md b/docs/react/faq.zh-CN.md index 7709baa53260..086a6be067ee 100644 --- a/docs/react/faq.zh-CN.md +++ b/docs/react/faq.zh-CN.md @@ -110,6 +110,19 @@ import { Menu, Breadcrumb, Icon } from 'antd'; 你可以通过 [ConfigProvider](/components/config-provider/#Content-Security-Policy) 来配置 `nonce` 属性。 +### 当我指定了 DatePicker/RangePicker 的 `mode` 属性后,点击后无法选择年份/月份? + +在业务开发中,你可能有年份选择,月份范围选择,周范围选择等需求,此时你给现有组件增加了 `mode` 属性,却发现无法进行点击选择行为,面板也不会关闭。 + +- 重现链接:https://codesandbox.io/s/dank-brook-v1csy +- 相同 issue:[#15572](https://github.com/ant-design/ant-design/issues/15572)、[#16436](https://github.com/ant-design/ant-design/issues/16436)、[#11938](https://github.com/ant-design/ant-design/issues/11938)、[#11735](https://github.com/ant-design/ant-design/issues/11735)、[#11586](https://github.com/ant-design/ant-design/issues/11586)、[#10425](https://github.com/ant-design/ant-design/issues/10425)、[#11053](https://github.com/ant-design/ant-design/issues/11053) + +就像[这个回复](https://github.com/ant-design/ant-design/issues/15572#issuecomment-475476135)里解释的一样,这是因为 `` 不等于 `YearPicker`,`` 不等于 `MonthRangePicker`。 `mode` 属性是在 antd 3.0 时,为了控制面板展现状态而添加的属性,以支持[展示时间面板](https://github.com/ant-design/ant-design/issues/5190)等需求而添加的。`mode` 只会简单的改变当前显示的面板,不会修改默认的交互行为(比如 DatePicker 依然是点击日才会完成选择并关闭面板)。 + +##### 解决办法 + +你可以参照 [这篇文章](https://juejin.im/post/5cf65c366fb9a07eca6968f9) 或者 [这篇文章](https://www.cnblogs.com/zyl-Tara/p/10197177.html) 里的做法,利用 `mode` 和 `onPanelChange` 等方法去封装一个 `YearPicker` 等组件。我们计划在 [antd@4.0](https://github.com/ant-design/ant-design/issues/16911) 中直接[添加更多相关日期组件](https://github.com/ant-design/ant-design/issues/4524#issuecomment-480576884)来支持这些需求。 + ### 如何正确的拼写 Ant Design? - ✅ **Ant Design**:用空格分隔的首字母大写单词,指代设计语言。 @@ -128,11 +141,7 @@ import { Menu, Breadcrumb, Icon } from 'antd'; ### 你们有接受捐助的渠道吗,比如支付宝或者微信支付? -还没有。 - -### 为什么? - -马爸爸会付给我们钱。 +[https://opencollective.com/ant-design](https://opencollective.com/ant-design) --- diff --git a/docs/spec/colors.en-US.md b/docs/spec/colors.en-US.md index d34a23c2069b..e8081254cb12 100644 --- a/docs/spec/colors.en-US.md +++ b/docs/spec/colors.en-US.md @@ -52,6 +52,37 @@ import ColorPaletteTool from '../../site/theme/template/Color/ColorPaletteTool'; ReactDOM.render(, mountNode); ``` +### Programmatic Usage + +We provide Less and JavaScript usage for developers. + +- **Less** + + ```less + @import '~antd/lib/style/themes/default.less', .selector { + color: @blue-5; + background-color: @gold-2; + } + ``` + + Color less variables: [color.less](https://github.com/ant-design/ant-design/blob/5ab2783ff00d4b1da04bb213c6b12de43e7649eb/components/style/color/colors.less). + +
+ +- **JavaScript** + + ``` + npm install @ant-design/colors + ``` + + ```js + import { blue } from '@ant-design/colors'; + console.log(blue); // ['#E6F7FF', '#BAE7FF', '#91D5FF', ''#69C0FF', '#40A9FF', '#1890FF', '#096DD9', '#0050B3', '#003A8C', '#002766'] + console.log(blue.primary); // '#1890FF' + ``` + + More APIs: [@ant-design/colors](https://www.npmjs.com/package/@ant-design/colors) + --- ## Product-level Color System diff --git a/docs/spec/colors.zh-CN.md b/docs/spec/colors.zh-CN.md index 973450682e34..cea69b1a666e 100644 --- a/docs/spec/colors.zh-CN.md +++ b/docs/spec/colors.zh-CN.md @@ -38,7 +38,7 @@ Ant Design 的色板还具备进一步拓展的能力。经过设计师和程序 ### 中性色板 -中性色包含了黑、白、灰。在蚂蚁中后台的网页设计中被大量使用到,合理的选择中性色能够令页面信息具备良好的主次关系,助力阅读体验。Ant Design 的中性色板一共包含了从白到黑的 10 个颜色。 +中性色包含了黑、白、灰。在蚂蚁中后台的网页设计中被大量使用到,合理地选择中性色能够令页面信息具备良好的主次关系,助力阅读体验。Ant Design 的中性色板一共包含了从白到黑的 10 个颜色。 ```__react import Palette from '../../site/theme/template/Color/Palette'; @@ -60,6 +60,37 @@ import ColorPaletteTool from '../../site/theme/template/Color/ColorPaletteTool'; ReactDOM.render(, mountNode); ``` +### 在代码中使用色板 + +我们为程序员提供了色板的 Less 和 JavaScript 的使用方式。 + +- **Less** + + ```less + @import '~antd/lib/style/themes/default.less', .selector { + color: @blue-5; + background-color: @gold-2; + } + ``` + + 所有色板变量列表:[color.less](https://github.com/ant-design/ant-design/blob/5ab2783ff00d4b1da04bb213c6b12de43e7649eb/components/style/color/colors.less)。 + +
+ +- **JavaScript** + + ``` + npm install @ant-design/colors + ``` + + ```js + import { blue } from '@ant-design/colors'; + console.log(blue); // ['#E6F7FF', '#BAE7FF', '#91D5FF', ''#69C0FF', '#40A9FF', '#1890FF', '#096DD9', '#0050B3', '#003A8C', '#002766'] + console.log(blue.primary); // '#1890FF' + ``` + + 更多使用方式:[@ant-design/colors](https://www.npmjs.com/package/@ant-design/colors) + --- ## 产品级色彩体系 @@ -68,7 +99,7 @@ ReactDOM.render(, mountNode); -品牌色是体现产品特性和传播理念最直观的视觉元素之一。在色彩选取时,需要先明确品牌色在界面中的使用场景及范围。在基础色板中选择主色,我们建议选择色板从浅自深的第六个颜色作为主色。 Ant Design 的品牌色取自基础色板的蓝色,Hex 值为 1890FF,应用场景包括:关键行动点,操作状态、重要信息高亮,图形化等场景。 +品牌色是体现产品特性和传播理念最直观的视觉元素之一。在色彩选取时,需要先明确品牌色在界面中的使用场景及范围。在基础色板中选择主色,我们建议选择色板从浅至深的第六个颜色作为主色。 Ant Design 的品牌色取自基础色板的蓝色,Hex 值为 `#1890FF`,应用场景包括:关键行动点,操作状态、重要信息高亮,图形化等场景。 ### 功能色 diff --git a/docs/spec/feedback.en-US.md b/docs/spec/feedback.en-US.md index ed5319d5aa5c..8ed456fb8bf2 100644 --- a/docs/spec/feedback.en-US.md +++ b/docs/spec/feedback.en-US.md @@ -71,7 +71,7 @@ When the operation takes a while (usually more than 2 seconds) to complete, the
- + > Note: If the loading time is long, a cancel operation should be provided. diff --git a/docs/spec/feedback.zh-CN.md b/docs/spec/feedback.zh-CN.md index 8c5f9e484e01..8b53862661a3 100644 --- a/docs/spec/feedback.zh-CN.md +++ b/docs/spec/feedback.zh-CN.md @@ -71,7 +71,7 @@ title: 反馈
- + > 注:若加载时间较长,应提供取消操作。 diff --git a/docs/spec/values.en-US.md b/docs/spec/values.en-US.md index f33b7db64dd1..899076b51367 100644 --- a/docs/spec/values.en-US.md +++ b/docs/spec/values.en-US.md @@ -31,6 +31,6 @@ As a part of nature, it will have deep influence on user behavior, and designers The designers needs to make better design decisions and create a high-definition and low-entropy atmosphere for developer team. Meanwhile, different designers could produce the same design output which fit business needs based on the same understanding of business requirements and design system. -- **Keep restraint:** Don't make decision until we have to. Designers should focus on the valuable product features using minimal design elements to express. As Antoine de St.Exupery said: "Perfection is not to be added, but rather that there is no excuse to be removed, and nothing is done". +- **Keep restraint:** Don't make decision until we have to. Designers should focus on the valuable product features using minimal design elements to express. As Antoine de St.Exupery said: [“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.”](https://www.goodreads.com/quotes/19905-perfection-is-achieved-not-when-there-is-nothing-more-to) - **Object-oriented:** Explore design rules and abstract them as "objects" to enhance the flexibility and maintainability of user interface design while reducing designer's subjective judgement and uncertainty of real world system. For example: color value conversion, spacing typesetting. - **Modular:** Encapsulate the complex or reusable parts could provide limited interfaces to interact with other modules, ultimately reducing overall system complexity, resulting in better reliability and maintainability. Designers can use existed resources or abstract their own reusable resources, save unnecessary and low additional design to keep their focus on where creativity most needed. diff --git a/package.json b/package.json index dc54b539c9de..afda6b30c467 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "antd", - "version": "3.18.1", + "version": "3.19.3", "title": "Ant Design", "description": "An enterprise-class UI design language and React components implementation", "homepage": "http://ant.design/", @@ -42,157 +42,159 @@ "react-dom": ">=16.0.0" }, "dependencies": { + "@ant-design/create-react-context": "^0.2.4", "@ant-design/icons": "~2.0.0", - "@ant-design/icons-react": "~2.0.0", - "@types/react-slick": "^0.23.3", + "@ant-design/icons-react": "~2.0.1", + "@types/react-slick": "^0.23.4", "array-tree-filter": "^2.1.0", "babel-runtime": "6.x", "classnames": "~2.2.6", - "copy-to-clipboard": "^3.0.8", - "@ant-design/create-react-context": "^0.2.4", + "copy-to-clipboard": "^3.2.0", "css-animation": "^1.5.0", "dom-closest": "^0.2.0", "enquire.js": "^2.1.6", "lodash": "^4.17.11", "moment": "^2.24.0", - "omit.js": "^1.0.0", - "prop-types": "^15.6.2", - "raf": "^3.4.0", - "rc-animate": "^2.5.4", - "rc-calendar": "~9.13.3", - "rc-cascader": "~0.17.0", - "rc-checkbox": "~2.1.5", - "rc-collapse": "~1.11.1", + "omit.js": "^1.0.2", + "prop-types": "^15.7.2", + "raf": "^3.4.1", + "rc-animate": "^2.8.3", + "rc-calendar": "~9.15.0", + "rc-cascader": "~0.17.4", + "rc-checkbox": "~2.1.6", + "rc-collapse": "~1.11.3", "rc-dialog": "~7.4.0", - "rc-drawer": "~1.8.0", + "rc-drawer": "~1.9.8", "rc-dropdown": "~2.4.1", - "rc-editor-mention": "^1.1.7", - "rc-form": "^2.4.0", - "rc-input-number": "~4.4.0", - "rc-menu": "~7.4.12", - "rc-notification": "~3.3.0", - "rc-pagination": "~1.18.0", + "rc-editor-mention": "^1.1.13", + "rc-form": "^2.4.5", + "rc-input-number": "~4.4.5", + "rc-mentions": "~0.3.1", + "rc-menu": "~7.4.23", + "rc-notification": "~3.3.1", + "rc-pagination": "~1.20.1", "rc-progress": "~2.3.0", "rc-rate": "~2.5.0", - "rc-select": "~9.1.0", - "rc-slider": "~8.6.5", - "rc-steps": "~3.3.0", + "rc-select": "~9.1.4", + "rc-slider": "~8.6.11", + "rc-steps": "~3.4.1", "rc-switch": "~1.9.0", - "rc-table": "~6.5.0", - "rc-tabs": "~9.6.0", - "rc-time-picker": "~3.6.1", + "rc-table": "~6.6.0", + "rc-tabs": "~9.6.4", + "rc-time-picker": "~3.6.6", "rc-tooltip": "~3.7.3", "rc-tree": "~2.1.0", "rc-tree-select": "~2.9.1", "rc-trigger": "^2.6.2", - "rc-upload": "~2.6.0", - "rc-util": "^4.5.1", + "rc-upload": "~2.6.7", + "rc-util": "^4.6.0", "react-lazy-load": "^3.0.13", "react-lifecycles-compat": "^3.0.4", "react-slick": "~0.24.0", - "resize-observer-polyfill": "^1.5.0", + "resize-observer-polyfill": "^1.5.1", "shallowequal": "^1.1.0", - "warning": "~4.0.2" + "warning": "~4.0.3" }, "devDependencies": { - "@ant-design/colors": "^3.0.0", - "@sentry/browser": "^5.0.3", - "@types/classnames": "^2.2.6", - "@types/prop-types": "^15.5.6", - "@types/react": "~16.8.1", - "@types/react-dom": "^16.0.11", - "@types/react-intl": "^2.3.14", + "@ant-design/colors": "^3.1.0", + "@packtracker/webpack-plugin": "^2.0.1", + "@sentry/browser": "^5.4.0", + "@types/classnames": "^2.2.8", + "@types/prop-types": "^15.7.1", + "@types/react": "~16.8.19", + "@types/react-dom": "^16.8.4", + "@types/react-intl": "^2.3.17", "@types/warning": "^3.0.0", "@yesmeck/offline-plugin": "^5.0.5", - "ansi-styles": "^3.2.1", - "antd-theme-generator": "^1.1.4", + "ansi-styles": "^4.0.0", + "antd-theme-generator": "^1.1.6", "antd-tools": "^7.3.5", "babel-eslint": "^10.0.1", "babel-plugin-add-react-displayname": "^0.0.5", "bisheng": "^1.2.4", - "bisheng-plugin-antd": "^1.0.1", + "bisheng-plugin-antd": "^1.0.2", "bisheng-plugin-description": "^0.1.4", "bisheng-plugin-react": "^1.0.0", "bisheng-plugin-toc": "^0.4.4", "chalk": "^2.4.2", - "commander": "^2.18.0", + "commander": "^2.20.0", "cross-env": "^5.2.0", "css-split-webpack-plugin": "^0.2.6", "dekko": "^0.2.1", - "docsearch.js": "^2.5.2", + "docsearch.js": "^2.6.3", "enquire-js": "^0.2.1", - "enzyme": "^3.7.0", - "enzyme-adapter-react-16": "^1.6.0", - "enzyme-to-json": "^3.3.4", - "eslint": "^5.6.1", + "enzyme": "^3.10.0", + "enzyme-adapter-react-16": "^1.14.0", + "enzyme-to-json": "^3.3.5", + "eslint": "^5.16.0", "eslint-config-airbnb": "^17.1.0", - "eslint-config-prettier": "^4.0.0", - "eslint-plugin-babel": "^5.2.1", - "eslint-plugin-import": "^2.17.1", - "eslint-plugin-jest": "^22.4.1", - "eslint-plugin-jsx-a11y": "^6.1.2", - "eslint-plugin-markdown": "~1.0.0-beta.6", - "eslint-plugin-react": "^7.11.1", + "eslint-config-prettier": "^4.3.0", + "eslint-plugin-babel": "^5.3.0", + "eslint-plugin-import": "^2.17.3", + "eslint-plugin-jest": "^22.6.4", + "eslint-plugin-jsx-a11y": "^6.2.1", + "eslint-plugin-markdown": "~1.0.0", + "eslint-plugin-react": "^7.13.0", "eslint-tinker": "^0.5.0", "fetch-jsonp": "^1.1.3", - "glob": "^7.1.3", + "glob": "^7.1.4", "immutability-helper": "^3.0.0", "intersection-observer": "^0.7.0", - "jest": "^24.0.0", - "jsdom": "^15.0.0", + "jest": "^24.8.0", + "jsdom": "^15.1.1", "jsonml.js": "^0.1.0", - "lint-staged": "^8.0.2", - "logrocket": "^0.6.19", + "lint-staged": "^8.1.7", + "logrocket": "^1.0.0", "logrocket-react": "^3.0.0", "lz-string": "^1.4.4", - "majo": "^0.7.1", + "majo": "^0.8.0", "mockdate": "^2.0.2", - "node-fetch": "^2.3.0", + "node-fetch": "^2.6.0", "pre-commit": "^1.2.2", - "preact": "^8.3.1", - "preact-compat": "^3.18.4", - "prettier": "^1.17.0", + "preact": "^8.4.2", + "preact-compat": "^3.18.5", + "prettier": "^1.17.1", "querystring": "^0.2.0", - "rc-queue-anim": "^1.6.6", - "rc-scroll-anim": "^2.5.7", - "rc-tween-one": "^2.4.0", + "rc-queue-anim": "^1.6.12", + "rc-scroll-anim": "^2.5.8", + "rc-tween-one": "^2.4.1", "react": "^16.5.2", - "react-color": "^2.14.1", + "react-color": "^2.17.3", "react-copy-to-clipboard": "^5.0.1", - "react-dnd": "^7.0.2", - "react-dnd-html5-backend": "^7.0.2", + "react-dnd": "^7.4.5", + "react-dnd-html5-backend": "^7.4.4", "react-document-title": "^2.0.3", "react-dom": "^16.5.2", "react-github-button": "^0.1.11", "react-highlight-words": "^0.16.0", - "react-infinite-scroller": "^1.2.1", - "react-intl": "^2.7.0", + "react-infinite-scroller": "^1.2.4", + "react-intl": "^2.9.0", "react-resizable": "^1.8.0", - "react-router-dom": "^5.0.0", + "react-router-dom": "^5.0.1", "react-sticky": "^6.0.3", - "react-test-renderer": "^16.6.3", - "react-virtualized": "~9.21.0", + "react-test-renderer": "^16.8.6", + "react-virtualized": "~9.21.1", "remark-cli": "^6.0.1", - "remark-frontmatter": "^1.3.0", + "remark-frontmatter": "^1.3.1", "remark-lint": "^6.0.4", - "remark-parse": "^6.0.0", + "remark-parse": "^6.0.3", "remark-preset-lint-recommended": "^3.0.2", - "remark-stringify": "^6.0.0", - "remark-yaml-config": "^4.0.2", + "remark-stringify": "^6.0.4", + "remark-yaml-config": "^4.0.3", "reqwest": "^2.0.5", - "rimraf": "^2.6.2", + "rimraf": "^2.6.3", "scrollama": "^2.0.0", - "simple-git": "^1.110.0", - "stylelint": "^10.0.0", - "stylelint-config-prettier": "^5.0.0", - "stylelint-config-rational-order": "^0.1.0", - "stylelint-config-standard": "^18.2.0", - "stylelint-declaration-block-no-ignored-properties": "^2.0.0", + "simple-git": "^1.113.0", + "stylelint": "^10.0.1", + "stylelint-config-prettier": "^5.2.0", + "stylelint-config-rational-order": "^0.1.2", + "stylelint-config-standard": "^18.3.0", + "stylelint-declaration-block-no-ignored-properties": "^2.1.0", "stylelint-order": "^3.0.0", - "typescript": "~3.4.1", - "unified": "^7.0.0", + "typescript": "~3.5.1", + "unified": "^7.1.0", "xhr-mock": "^2.4.1", - "xhr2": "^0.1.4" + "xhr2": "^0.2.0" }, "scripts": { "test": "jest --config .jest.js --no-cache", @@ -245,5 +247,11 @@ "es/**/style/*", "lib/**/style/*", "*.less" + ], + "browserslist": [ + "last 2 version", + "Firefox ESR", + "> 1%", + "ie >= 9" ] } diff --git a/renovate.json b/renovate.json new file mode 100644 index 000000000000..5fcce1121342 --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "extends": [ + "config:base", + ":preserveSemverRanges" + ] +} diff --git a/site/bisheng.config.js b/site/bisheng.config.js index 7f4768094361..b05e034aad13 100644 --- a/site/bisheng.config.js +++ b/site/bisheng.config.js @@ -54,6 +54,7 @@ module.exports = { 'Data Display': 4, Feedback: 5, Other: 6, + Deprecated: 7, 通用: 0, 布局: 1, 导航: 2, @@ -61,6 +62,7 @@ module.exports = { 数据展示: 4, 反馈: 5, 其他: 6, + 废弃: 7, }, docVersions: { '0.9.x': 'http://09x.ant.design', diff --git a/site/theme/en-US.js b/site/theme/en-US.js index e6290419971b..201841bac6a8 100644 --- a/site/theme/en-US.js +++ b/site/theme/en-US.js @@ -12,7 +12,7 @@ module.exports = { 'app.header.menu.spec': 'Guidelines', 'app.header.menu.resource': 'Resources', 'app.header.menu.mobile': 'Mobile', - 'app.header.menu.pro': 'Ant Design Pro', + 'app.header.menu.pro.v4': 'Ant Design Pro v4', 'app.header.menu.ecosystem': 'Ecosystem', 'app.header.lang': '中文', 'app.content.edit-page': 'Edit this page on GitHub!', diff --git a/site/theme/static/toc.less b/site/theme/static/toc.less index 5092d277a5e2..ed49ef636e99 100644 --- a/site/theme/static/toc.less +++ b/site/theme/static/toc.less @@ -51,7 +51,8 @@ ul.toc > li { .ant-affix { z-index: 9; max-height: ~'calc(100vh - 16px)'; - overflow: auto; + overflow-x: hidden; + overflow-y: auto; background: #fff; } } diff --git a/site/theme/template/Content/ComponentDoc.jsx b/site/theme/template/Content/ComponentDoc.jsx index 099fca2e3a3b..80a9a2677548 100644 --- a/site/theme/template/Content/ComponentDoc.jsx +++ b/site/theme/template/Content/ComponentDoc.jsx @@ -29,11 +29,17 @@ export default class ComponentDoc extends React.Component { }); } - shouldComponentUpdate(nextProps) { + shouldComponentUpdate(nextProps, nextState) { const { location } = this.props; const { location: nextLocation } = nextProps; + const { expandAll, showRiddleButton } = this.state; + const { expandAll: nextExpandAll, showRiddleButton: nextShowRiddleButton } = nextState; - if (nextLocation.pathname === location.pathname) { + if ( + nextLocation.pathname === location.pathname && + expandAll === nextExpandAll && + showRiddleButton === nextShowRiddleButton + ) { return false; } return true; diff --git a/site/theme/template/IconDisplay/fields.ts b/site/theme/template/IconDisplay/fields.ts index f0c18fafd4cd..9a2391efdd25 100644 --- a/site/theme/template/IconDisplay/fields.ts +++ b/site/theme/template/IconDisplay/fields.ts @@ -5,6 +5,9 @@ Object.keys(manifest).forEach(theme => { allIcons = [...allIcons, ...(manifest as any)[theme]]; }); +// Hide typo-name icons +allIcons = allIcons.filter((name: string) => !['interation', 'canlendar'].includes(name)); + export const categories = { all: [...new Set(allIcons)], direction: [ diff --git a/site/theme/template/IconDisplay/index.tsx b/site/theme/template/IconDisplay/index.tsx index 746ed1674b0b..66673c796bb1 100644 --- a/site/theme/template/IconDisplay/index.tsx +++ b/site/theme/template/IconDisplay/index.tsx @@ -99,7 +99,7 @@ class IconDisplay extends React.Component { return ( <>
- + {messages['app.docs.components.icon.outlined']} diff --git a/site/theme/template/Layout/Header.jsx b/site/theme/template/Layout/Header.jsx index 55eeea37be11..957e19725767 100644 --- a/site/theme/template/Layout/Header.jsx +++ b/site/theme/template/Layout/Header.jsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { Link } from 'bisheng/router'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; -import { Select, Menu, Row, Col, Icon, Popover, Input, Button } from 'antd'; +import { Select, Menu, Row, Col, Icon, Popover, Input, Button, Badge } from 'antd'; import Santa from './Santa'; import * as utils from '../utils'; import { version as antdVersion } from '../../../../package.json'; @@ -179,7 +179,11 @@ export default class Header extends React.Component { } + title={ + + + + } > - + + + diff --git a/site/theme/zh-CN.js b/site/theme/zh-CN.js index 40ff1bba6469..8d4e84fcb69b 100644 --- a/site/theme/zh-CN.js +++ b/site/theme/zh-CN.js @@ -12,7 +12,7 @@ module.exports = { 'app.header.menu.spec': '设计语言', 'app.header.menu.resource': '资源', 'app.header.menu.mobile': '移动版', - 'app.header.menu.pro': 'Ant Design Pro', + 'app.header.menu.pro.v4': 'Ant Design Pro v4', 'app.header.menu.ecosystem': '生态', 'app.header.lang': 'English', 'app.content.edit-page': '在 GitHub 上编辑此页!', diff --git a/tests/__snapshots__/index.test.js.snap b/tests/__snapshots__/index.test.js.snap index f77ab7f9e8bd..f3ea00c0294a 100644 --- a/tests/__snapshots__/index.test.js.snap +++ b/tests/__snapshots__/index.test.js.snap @@ -21,6 +21,7 @@ Array [ "Comment", "ConfigProvider", "DatePicker", + "Descriptions", "Divider", "Dropdown", "Drawer", @@ -34,6 +35,7 @@ Array [ "LocaleProvider", "message", "Menu", + "Mentions", "Modal", "Statistic", "notification", diff --git a/webpack.config.js b/webpack.config.js index 08d3c36c2d57..9bd7822a4f9c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,7 @@ /* eslint no-param-reassign: 0 */ // This config is for building dist files const getWebpackConfig = require('antd-tools/lib/getWebpackConfig'); +const PacktrackerPlugin = require('@packtracker/webpack-plugin'); const { webpack } = getWebpackConfig; @@ -35,6 +36,15 @@ if (process.env.RUN_ENV === 'PRODUCTION') { ignoreMomentLocale(config); externalMoment(config); addLocales(config); + // https://docs.packtracker.io/uploading-your-webpack-stats/webpack-plugin + config.plugins.push( + new PacktrackerPlugin({ + project_token: '8adbb892-ee4a-4d6f-93bb-a03219fb6778', + upload: process.env.CI === 'true', + fail_build: true, + exclude_assets: name => !['antd.min.js', 'antd.min.css'].includes(name), + }), + ); }); }