Browse Source

Merge pull request #26050 from ant-design/master-to-merge-feature

chore: merge master into feature
pull/26030/head
偏右 4 years ago
committed by GitHub
parent
commit
112e0e2a4c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/PULL_REQUEST_TEMPLATE.md
  2. 4
      .github/PULL_REQUEST_TEMPLATE/pr_cn.md
  3. 38
      components/_util/motion.tsx
  4. 2
      components/locale/fr_FR.tsx
  5. 3
      components/menu/index.tsx
  6. 2
      components/menu/style/rtl.less
  7. 4
      components/table/Table.tsx
  8. 13
      components/table/__tests__/Table.test.js
  9. 2
      components/table/hooks/useLazyKVMap.ts
  10. 2
      components/table/hooks/useSelection.tsx
  11. 4
      docs/resources.en-US.md
  12. 9
      package.json

2
.github/PULL_REQUEST_TEMPLATE.md

@ -18,6 +18,8 @@ Please makes sure that these form are filled before submitting your pull request
- [ ] TypeScript definition update
- [ ] Bundle size optimization
- [ ] Performance optimization
- [ ] Enhancement feature
- [ ] Internationalization
- [ ] Refactoring
- [ ] Code style optimization
- [ ] Test Case

4
.github/PULL_REQUEST_TEMPLATE/pr_cn.md

@ -14,11 +14,13 @@
- [ ] 日常 bug 修复
- [ ] 站点、文档改进
- [ ] 演示代码改进
- [ ] 组件样式改进
- [ ] 组件样式/交互改进
- [ ] TypeScript 定义更新
- [ ] 包体积优化
- [ ] 性能优化
- [ ] 重构
- [ ] 功能增强
- [ ] 国际化改进
- [ ] 代码风格优化
- [ ] 测试用例
- [ ] 分支合并

38
components/_util/motion.tsx

@ -1,36 +1,14 @@
import * as React from 'react';
type MotionFunc = (element: HTMLElement) => React.CSSProperties;
type MotionEndFunc = (element: HTMLElement, event: TransitionEvent) => boolean;
interface Motion {
visible?: boolean;
motionName?: string; // It also support object, but we only use string here.
motionAppear?: boolean;
motionEnter?: boolean;
motionLeave?: boolean;
motionLeaveImmediately?: boolean; // Trigger leave motion immediately
motionDeadline?: number;
removeOnLeave?: boolean;
leavedClassName?: string;
onAppearStart?: MotionFunc;
onAppearActive?: MotionFunc;
onAppearEnd?: MotionEndFunc;
onEnterStart?: MotionFunc;
onEnterActive?: MotionFunc;
onEnterEnd?: MotionEndFunc;
onLeaveStart?: MotionFunc;
onLeaveActive?: MotionFunc;
onLeaveEnd?: MotionEndFunc;
}
import { CSSMotionProps } from 'rc-motion';
import { MotionEventHandler, MotionEndEventHandler } from 'rc-motion/lib/CSSMotion';
// ================== Collapse Motion ==================
const getCollapsedHeight: MotionFunc = () => ({ height: 0, opacity: 0 });
const getRealHeight: MotionFunc = node => ({ height: node.scrollHeight, opacity: 1 });
const getCurrentHeight: MotionFunc = node => ({ height: node.offsetHeight });
const skipOpacityTransition: MotionEndFunc = (_, event) => event.propertyName === 'height';
const getCollapsedHeight: MotionEventHandler = () => ({ height: 0, opacity: 0 });
const getRealHeight: MotionEventHandler = node => ({ height: node.scrollHeight, opacity: 1 });
const getCurrentHeight: MotionEventHandler = node => ({ height: node.offsetHeight });
const skipOpacityTransition: MotionEndEventHandler = (_, event) =>
(event as TransitionEvent).propertyName === 'height';
const collapseMotion: Motion = {
const collapseMotion: CSSMotionProps = {
motionName: 'ant-motion-collapse',
onAppearStart: getCollapsedHeight,
onEnterStart: getCollapsedHeight,

2
components/locale/fr_FR.tsx

@ -22,7 +22,7 @@ const localeValues: Locale = {
collapse: 'Réduire la ligne',
triggerDesc: 'Trier par ordre décroissant',
triggerAsc: 'Trier par ordre croissant',
cancelSort: 'Annuler le trie',
cancelSort: 'Annuler le tri',
},
Modal: {
okText: 'OK',

3
components/menu/index.tsx

@ -1,7 +1,6 @@
import * as React from 'react';
import RcMenu, { Divider, ItemGroup, MenuProps as RcMenuProps } from 'rc-menu';
import classNames from 'classnames';
import { MotionType } from 'rc-trigger/lib/interface';
import SubMenu from './SubMenu';
import Item from './MenuItem';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
@ -57,7 +56,7 @@ class InternalMenu extends React.Component<InternalMenuProps> {
const { prefixCls: customizePrefixCls, className, theme } = this.props;
const defaultMotions = {
horizontal: { motionName: 'slide-up' },
inline: collapseMotion as MotionType,
inline: collapseMotion,
other: { motionName: 'zoom-big' },
};

2
components/menu/style/rtl.less

@ -4,7 +4,7 @@
@menu-prefix-cls: ~'@{ant-prefix}-menu';
.@{menu-prefix-cls} {
&-rtl {
&&-rtl {
direction: rtl;
text-align: right;
}

4
components/table/Table.tsx

@ -162,7 +162,7 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
const { childrenColumnName = 'children' } = mergedExpandable;
const expandType: ExpandType = React.useMemo<ExpandType>(() => {
if (rawData.some(item => (item as any)[childrenColumnName])) {
if (rawData.some(item => (item as any)?.[childrenColumnName])) {
return 'nest';
}
@ -183,7 +183,7 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
return rowKey;
}
return (record: RecordType) => (record as any)[rowKey as string];
return (record: RecordType) => (record as any)?.[rowKey as string];
}, [rowKey]);
const [getRecordByKey] = useLazyKVMap(rawData, childrenColumnName, getRowKey);

13
components/table/__tests__/Table.test.js

@ -160,6 +160,19 @@ describe('Table', () => {
);
});
it('should not crash when dataSource is array with none-object items', () => {
mount(
<Table
columns={[
{
title: 'name',
},
]}
dataSource={['1', 2, undefined, {}, null, true, false, 0]}
/>,
);
});
it('prevent touch event', () => {
const wrapper = mount(
<Table

2
components/table/hooks/useLazyKVMap.ts

@ -30,7 +30,7 @@ export default function useLazyKVMap<RecordType>(
const rowKey = getRowKey(record, index);
kvMap.set(rowKey, record);
if (childrenColumnName in record) {
if (record && typeof record === 'object' && childrenColumnName in record) {
dig((record as any)[childrenColumnName] || []);
}
});

2
components/table/hooks/useSelection.tsx

@ -59,7 +59,7 @@ function flattenData<RecordType>(
(data || []).forEach(record => {
list.push(record);
if (childrenColumnName in record) {
if (record && typeof record === 'object' && childrenColumnName in record) {
list = [
...list,
...flattenData<RecordType>((record as any)[childrenColumnName], childrenColumnName),

4
docs/resources.en-US.md

@ -50,6 +50,10 @@ Please find below some of the design resources and tools about Ant Design that w
- https://gw.alipayobjects.com/zos/basement_prod/7b9ed3f2-6f05-4ddb-bac3-d55feb71e0ac.svg
- Library of components for Desktop
- https://www.antforfigma.com
- UI Kit for Adobe XD
- https://uploads-ssl.webflow.com/5ecbd337fe499992c9ed75ba/5f2a7a30f3e817085cec5ac9_ant-xd-svg.svg
- Library of components for Desktop
- https://gumroad.com/l/antdesign-xd
- Figma Open Source Library
- https://i.imgur.com/kopdWeX.png
- Free open source Figma library with complete accrate to code components

9
package.json

@ -126,7 +126,8 @@
"rc-field-form": "~1.9.2",
"rc-input-number": "~6.0.0",
"rc-mentions": "~1.4.0",
"rc-menu": "~8.5.0",
"rc-menu": "~8.5.2",
"rc-motion": "^1.0.0",
"rc-notification": "~4.4.0",
"rc-pagination": "~2.4.5",
"rc-picker": "~1.15.1",
@ -141,9 +142,9 @@
"rc-tabs": "~11.5.0",
"rc-textarea": "~0.3.0",
"rc-tooltip": "~4.2.0",
"rc-tree": "~3.8.0",
"rc-tree-select": "~4.1.0",
"rc-trigger": "~4.3.0",
"rc-tree": "~3.8.5",
"rc-tree-select": "~4.1.1",
"rc-trigger": "~4.4.0",
"rc-upload": "~3.2.0",
"rc-util": "^5.0.1",
"scroll-into-view-if-needed": "^2.2.25",

Loading…
Cancel
Save