From 222ee1f3ad0a1857fc3c635e6d2105d741ebdffc Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Sun, 30 Jan 2022 15:49:24 +0800 Subject: [PATCH 01/22] Revert "revert: Revert "Merge branch 'feature' into master" (#33903)" This reverts commit 6b1a48d5edaca3d10380568f8ca1a6a867cb599e. --- components/_util/motion.tsx | 13 +- components/{tooltip => _util}/placements.tsx | 3 +- components/breadcrumb/BreadcrumbItem.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 235 +++ .../__tests__/__snapshots__/demo.test.js.snap | 145 ++ components/cascader/__tests__/index.test.js | 23 +- components/cascader/demo/placement.md | 77 + components/cascader/index.en-US.md | 2 +- components/cascader/index.tsx | 22 +- components/cascader/index.zh-CN.md | 2 +- .../date-picker/__tests__/DatePicker.test.js | 32 + .../__snapshots__/demo-extend.test.ts.snap | 1861 +++++++++++++++++ .../__tests__/__snapshots__/demo.test.js.snap | 210 ++ components/date-picker/demo/placement.md | 47 + .../generatePicker/generateRangePicker.tsx | 4 +- .../generatePicker/generateSinglePicker.tsx | 4 +- .../date-picker/generatePicker/index.tsx | 20 +- components/date-picker/index.en-US.md | 1 + components/date-picker/index.zh-CN.md | 1 + components/date-picker/util.ts | 55 + .../__snapshots__/demo-extend.test.ts.snap | 1292 +++++++++++- .../__tests__/__snapshots__/demo.test.js.snap | 62 +- components/dropdown/__tests__/index.test.js | 20 + components/dropdown/demo/arrow-center.md | 75 + components/dropdown/demo/arrow.md | 8 +- components/dropdown/demo/dropdown-button.md | 2 +- components/dropdown/demo/placement.md | 8 +- components/dropdown/dropdown.tsx | 33 +- components/dropdown/index.en-US.md | 6 +- components/dropdown/index.zh-CN.md | 6 +- components/dropdown/style/index.less | 24 +- .../__snapshots__/demo-extend.test.ts.snap | 71 + .../__tests__/__snapshots__/demo.test.js.snap | 71 + .../notification/__tests__/placement.test.js | 32 + components/notification/demo/placement.md | 13 + components/notification/index.tsx | 24 +- components/notification/index.zh-CN.md | 2 +- components/notification/style/index.less | 14 + .../__snapshots__/demo-extend.test.ts.snap | 247 +++ .../__tests__/__snapshots__/demo.test.js.snap | 148 ++ components/select/demo/placement.md | 53 + components/select/index.en-US.md | 3 +- components/select/index.tsx | 23 +- components/select/index.zh-CN.md | 3 +- components/skeleton/Input.tsx | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 14 +- .../__tests__/__snapshots__/demo.test.js.snap | 14 +- components/skeleton/demo/element.md | 9 +- components/skeleton/style/index.less | 9 +- components/space/index.tsx | 6 +- components/style/themes/variable.less | 4 +- .../table/__tests__/Table.sorter.test.js | 95 +- .../__snapshots__/Table.sorter.test.js.snap | 1 + .../__snapshots__/demo-extend.test.ts.snap | 1 + .../__tests__/__snapshots__/demo.test.js.snap | 1 + components/table/hooks/useSorter.tsx | 9 + components/time-picker/index.en-US.md | 37 +- components/time-picker/index.zh-CN.md | 45 +- components/tooltip/index.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 427 ++++ .../__tests__/__snapshots__/demo.test.js.snap | 142 ++ components/tree-select/demo/placement.md | 64 + components/tree-select/index.en-US.md | 1 + components/tree-select/index.tsx | 21 +- components/tree-select/index.zh-CN.md | 1 + package.json | 2 +- site/theme/template/Content/MainContent.jsx | 2 +- 67 files changed, 5796 insertions(+), 122 deletions(-) rename components/{tooltip => _util}/placements.tsx (97%) create mode 100644 components/cascader/demo/placement.md create mode 100644 components/date-picker/demo/placement.md create mode 100644 components/dropdown/demo/arrow-center.md create mode 100644 components/select/demo/placement.md create mode 100644 components/tree-select/demo/placement.md diff --git a/components/_util/motion.tsx b/components/_util/motion.tsx index 1c69a9f05a..edac9ccda1 100644 --- a/components/_util/motion.tsx +++ b/components/_util/motion.tsx @@ -1,5 +1,6 @@ import { CSSMotionProps, MotionEventHandler, MotionEndEventHandler } from 'rc-motion'; import { MotionEvent } from 'rc-motion/lib/interface'; +import { tuple } from './type'; // ================== Collapse Motion ================== const getCollapsedHeight: MotionEventHandler = () => ({ height: 0, opacity: 0 }); @@ -25,11 +26,21 @@ const collapseMotion: CSSMotionProps = { motionDeadline: 500, }; +const SelectPlacements = tuple('bottomLeft', 'bottomRight', 'topLeft', 'topRight'); +export type SelectCommonPlacement = typeof SelectPlacements[number]; + +const getTransitionDirection = (placement: SelectCommonPlacement | undefined) => { + if (placement !== undefined && (placement === 'topLeft' || placement === 'topRight')) { + return `slide-down`; + } + return `slide-up`; +}; + const getTransitionName = (rootPrefixCls: string, motion: string, transitionName?: string) => { if (transitionName !== undefined) { return transitionName; } return `${rootPrefixCls}-${motion}`; }; -export { getTransitionName }; +export { getTransitionName, getTransitionDirection }; export default collapseMotion; diff --git a/components/tooltip/placements.tsx b/components/_util/placements.tsx similarity index 97% rename from components/tooltip/placements.tsx rename to components/_util/placements.tsx index 3fc9152268..eb4dead8a8 100644 --- a/components/tooltip/placements.tsx +++ b/components/_util/placements.tsx @@ -42,6 +42,7 @@ export default function getPlacements(config: PlacementsConfig) { horizontalArrowShift = 16, verticalArrowShift = 8, autoAdjustOverflow, + arrowPointAtCenter, } = config; const placementMap: BuildInPlacements = { left: { @@ -94,7 +95,7 @@ export default function getPlacements(config: PlacementsConfig) { }, }; Object.keys(placementMap).forEach(key => { - placementMap[key] = config.arrowPointAtCenter + placementMap[key] = arrowPointAtCenter ? { ...placementMap[key], overflow: getOverflowOptions(autoAdjustOverflow), diff --git a/components/breadcrumb/BreadcrumbItem.tsx b/components/breadcrumb/BreadcrumbItem.tsx index fd29f24a85..860971e847 100644 --- a/components/breadcrumb/BreadcrumbItem.tsx +++ b/components/breadcrumb/BreadcrumbItem.tsx @@ -30,7 +30,7 @@ const BreadcrumbItem: BreadcrumbItemInterface = ({ const renderBreadcrumbNode = (breadcrumbItem: React.ReactNode) => { if (overlay) { return ( - + {breadcrumbItem} @@ -62,9 +62,7 @@ const BreadcrumbItem: BreadcrumbItemInterface = ({ return ( {link} - {separator && ( - {separator} - )} + {separator && {separator}} ); } diff --git a/components/cascader/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/cascader/__tests__/__snapshots__/demo-extend.test.ts.snap index cec599fae5..7a472fce2b 100644 --- a/components/cascader/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/cascader/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -1674,6 +1674,241 @@ exports[`renders ./components/cascader/demo/multiple.md extend context correctly `; +exports[`renders ./components/cascader/demo/placement.md extend context correctly 1`] = ` +Array [ +
+ + + + +
, +
, +
, +
+
+ + + + + Please select + +
+
+
+
+
+ +
+
+
+
+ +
, +] +`; + exports[`renders ./components/cascader/demo/search.md extend context correctly 1`] = `