test: Update snapshot

This commit is contained in:
zombiej 2021-12-01 22:52:49 +08:00
commit 1698426161
24 changed files with 161 additions and 107 deletions

View File

@ -62,9 +62,6 @@ jobs:
- name: deploy
uses: peaceiris/actions-gh-pages@v3
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./_site
with:
emptyCommits: false
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./_site

View File

@ -15,6 +15,17 @@ timeline: true
---
## 4.17.2
`2021-11-26`
- 💄 Fix Form broken layout when set `wrapperCol={{ span: 24 }}`. [#32981](https://github.com/ant-design/ant-design/pull/32981)
- 🐞 Fix Modal `centered` was not centered vertically. [#33022](https://github.com/ant-design/ant-design/pull/33022)
- 🐞 Cascader typescript fix definition missing `suffixIcon` and support generic of `options` type. [#33008](https://github.com/ant-design/ant-design/pull/33008)
- 🐞 Fix Input.Search don't trigger click event on element inside `enterButton`. [#32999](https://github.com/ant-design/ant-design/pull/32999)
- 🇪🇪 Added missing Estonian translations. [#33005](https://github.com/ant-design/ant-design/pull/33005) [@wedeso](https://github.com/wedeso)
- 🤖 Tree support generic to work more well with `fieldNames`. [#32992](https://github.com/ant-design/ant-design/pull/32992)
## 4.17.1
`2021-11-22`

View File

@ -15,6 +15,17 @@ timeline: true
---
## 4.17.2
`2021-11-26`
- 💄 修复 Form `wrapperCol={{ span: 24 }}` 时样式错乱的问题。[#32981](https://github.com/ant-design/ant-design/pull/32981)
- 🐞 修复 Modal `centered` 略微偏上的问题。[#33022](https://github.com/ant-design/ant-design/pull/33022)
- 🐞 Cascader 丢失 `suffixIcon` 定义问题并且支持 `options` 泛型定义。[#33008](https://github.com/ant-design/ant-design/pull/33008)
- 🐞 修复 Input.Search 下 `enterButton` 内元素上的 `onClick` 未被触发的问题。[#32999](https://github.com/ant-design/ant-design/pull/32999)
- 🇪🇪 补充爱沙尼亚语言包。[#33005](https://github.com/ant-design/ant-design/pull/33005) [@wedeso](https://github.com/wedeso)
- 🤖 Tree 支持泛型以更好的配合 `fieldNames`。[#32992](https://github.com/ant-design/ant-design/pull/32992)
## 4.17.1
`2021-11-22`

View File

@ -1,6 +1,5 @@
import React from 'react';
import { mount, ReactWrapper, HTMLAttributes } from 'enzyme';
import ResizeObserverImpl from 'rc-resize-observer';
import { mount, ReactWrapper } from 'enzyme';
import Affix, { AffixProps, AffixState } from '..';
import { getObserverEntities } from '../utils';
import Button from '../../button';
@ -206,24 +205,7 @@ describe('Affix Render', () => {
// Mock trigger resize
updateCalled.mockReset();
const resizeObserverInstance: ReactWrapper<HTMLAttributes, unknown, ResizeObserverImpl> =
affixMounterWrapper.find('ResizeObserver') as any;
resizeObserverInstance
.at(index)
.instance()
.onResize(
[
{
target: {
getBoundingClientRect: () => ({ width: 99, height: 99 }),
} as Element,
contentRect: {} as DOMRect,
borderBoxSize: [],
contentBoxSize: [],
},
],
{} as unknown as ResizeObserver,
);
(affixMounterWrapper as any).triggerResize(index);
await sleep(20);
expect(updateCalled).toHaveBeenCalled();

View File

@ -184,18 +184,25 @@ exports[`Avatar Render should show image on success after a failure state 1`] =
<ResizeObserver
onResize={[Function]}
>
<span
className="ant-avatar-string"
style={
Object {
"WebkitTransform": "scale(1) translateX(-50%)",
"msTransform": "scale(1) translateX(-50%)",
"transform": "scale(1) translateX(-50%)",
}
}
<SingleObserver
key="rc-observer-key-0"
onResize={[Function]}
>
Fallback
</span>
<DomWrapper>
<span
className="ant-avatar-string"
style={
Object {
"WebkitTransform": "scale(1) translateX(-50%)",
"msTransform": "scale(1) translateX(-50%)",
"transform": "scale(1) translateX(-50%)",
}
}
>
Fallback
</span>
</DomWrapper>
</SingleObserver>
</ResizeObserver>
</span>
</Avatar>

View File

@ -177,12 +177,8 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
};
// =============== Update Loading ===============
let loadingOrDelay: Loading;
if (typeof loading === 'object' && loading.delay) {
loadingOrDelay = loading.delay || true;
} else {
loadingOrDelay = !!loading;
}
const loadingOrDelay: Loading =
typeof loading === 'object' && loading.delay ? loading.delay || true : !!loading;
React.useEffect(() => {
clearTimeout(delayTimeoutRef.current);
@ -222,19 +218,9 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
const prefixCls = getPrefixCls('btn', customizePrefixCls);
const autoInsertSpace = autoInsertSpaceInButton !== false;
// large => lg
// small => sm
let sizeCls = '';
switch (customizeSize || size) {
case 'large':
sizeCls = 'lg';
break;
case 'small':
sizeCls = 'sm';
break;
default:
break;
}
const sizeClassNameMap = { large: 'lg', small: 'sm', middle: undefined };
const sizeFullname = customizeSize || size;
const sizeCls = sizeFullname ? sizeClassNameMap[sizeFullname] || '' : '';
const iconType = innerLoading ? 'loading' : icon;

View File

@ -25,7 +25,7 @@ export interface CarouselRef {
goTo: (slide: number, dontAnimate?: boolean) => void;
next: () => void;
prev: () => void;
autoPlay: boolean;
autoPlay: (palyType?: 'update' | 'leave' | 'blur') => void;
innerSlider: any;
}

View File

@ -475,17 +475,30 @@ describe('Cascader', () => {
expect(onChange).toHaveBeenCalledWith(['Zhejiang', 'Hangzhou', 'West Lake'], expect.anything());
});
it('legacy props', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const wrapper = mount(<Cascader open popupPlacement="topRight" popupClassName="mock-cls" />);
describe('legacy props', () => {
it('popupClassName', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const wrapper = mount(<Cascader open popupPlacement="topRight" popupClassName="mock-cls" />);
expect(wrapper.exists('.mock-cls')).toBeTruthy();
expect(wrapper.find('Trigger').prop('popupPlacement')).toEqual('topRight');
expect(wrapper.exists('.mock-cls')).toBeTruthy();
expect(wrapper.find('Trigger').prop('popupPlacement')).toEqual('topRight');
expect(errorSpy).toHaveBeenCalledWith(
'Warning: [antd: Cascader] `popupClassName` is deprecated. Please use `dropdownClassName` instead.',
);
expect(errorSpy).toHaveBeenCalledWith(
'Warning: [antd: Cascader] `popupClassName` is deprecated. Please use `dropdownClassName` instead.',
);
errorSpy.mockRestore();
errorSpy.mockRestore();
});
it('displayRender & multiple', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
mount(<Cascader multiple displayRender={() => null} />);
expect(errorSpy).toHaveBeenCalledWith(
'Warning: [antd: Cascader] `displayRender` not work on `multiple`. Please use `tagRender` instead.',
);
errorSpy.mockRestore();
});
});
});

View File

@ -28,7 +28,7 @@ Cascade selection box.
| className | The additional css class | string | - | |
| defaultValue | Initial selected value | string\[] \| number\[] | \[] | |
| disabled | Whether disabled select | boolean | false | |
| displayRender | The render function of displaying selected options | (label, selectedOptions) => ReactNode | label => label.join(`/`) | |
| displayRender | The render function of displaying single selected options. You can use tagRender for multiple mode | (label, selectedOptions) => ReactNode | label => label.join(`/`) | |
| dropdownClassName | The additional className of popup overlay | string | - | 4.17.0 |
| dropdownRender | Customize dropdown content | (menus: ReactNode) => ReactNode | - | 4.4.0 |
| expandIcon | Customize the current item expand icon | ReactNode | - | 4.4.0 |

View File

@ -130,6 +130,12 @@ const Cascader = React.forwardRef((props: CascaderProps<any>, ref: React.Ref<Cas
'Cascader',
'`popupClassName` is deprecated. Please use `dropdownClassName` instead.',
);
devWarning(
!multiple || !props.displayRender,
'Cascader',
'`displayRender` not work on `multiple`. Please use `tagRender` instead.',
);
}
// =================== No Found ====================

View File

@ -29,7 +29,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/UdS8y8xyZ/Cascader.svg
| className | 自定义类名 | string | - | |
| defaultValue | 默认的选中项 | string\[] \| number\[] | \[] | |
| disabled | 禁用 | boolean | false | |
| displayRender | 选择后展示的渲染函数 | (label, selectedOptions) => ReactNode | label => label.join(`/`) | |
| displayRender | 单选模式下选择后展示的渲染函数,多选请使用 tagRender | (label, selectedOptions) => ReactNode | label => label.join(`/`) | |
| dropdownClassName | 自定义浮层类名 | string | - | 4.17.0 |
| dropdownRender | 自定义下拉框内容 | (menus: ReactNode) => ReactNode | - | 4.4.0 |
| expandIcon | 自定义次级菜单展开图标 | ReactNode | - | 4.4.0 |

View File

@ -22,6 +22,7 @@
}
> .@{collapse-prefix-cls}-header {
position: relative; // Compatible with old version of antd, should remove in next version
display: flex;
flex-wrap: nowrap;
align-items: flex-start;

View File

@ -7,11 +7,6 @@
// = Children Component =
// ================================================================
.@{form-item-prefix-cls} {
.@{ant-prefix}-mentions,
textarea.@{ant-prefix}-input {
height: auto;
}
// input[type=file]
.@{ant-prefix}-upload {
background: transparent;

View File

@ -3363,6 +3363,19 @@ Array [
]
`;
exports[`renders ./components/input/demo/textarea-show-count.md correctly 1`] = `
<div
class="ant-input-textarea ant-input-textarea-show-count"
data-count="0 / 100"
style="height:120px"
>
<textarea
class="ant-input"
maxlength="100"
/>
</div>
`;
exports[`renders ./components/input/demo/tooltip.md correctly 1`] = `
<input
class="ant-input"

View File

@ -139,18 +139,7 @@ describe('TextArea', () => {
const onResize = jest.fn();
const wrapper = mount(<TextArea onResize={onResize} autoSize />);
await sleep(100);
wrapper
.find('ResizeObserver')
.instance()
.onResize([
{
target: {
getBoundingClientRect() {
return {};
},
},
},
]);
wrapper.triggerResize();
await Promise.resolve();
expect(onResize).toHaveBeenCalledWith(

View File

@ -0,0 +1,29 @@
---
order: 12
title:
zh-CN: 带字数提示的文本域
en-US: Textarea with character counting
---
## zh-CN
展示字数提示。
## en-US
Show character counting.
```jsx
import { Input } from 'antd';
const { TextArea } = Input;
const onChange = e => {
console.log('Change:', e.target.value);
};
ReactDOM.render(
<TextArea showCount maxLength={100} style={{ height: 120 }} onChange={onChange} />,
mountNode,
);
```

View File

@ -47,8 +47,13 @@
}
}
&-textarea {
&-show-count::after {
&-textarea-show-count {
// https://github.com/ant-design/ant-design/issues/33049
> .@{input-prefix-cls} {
height: 100%;
}
&::after {
float: right;
color: @text-color-secondary;
white-space: nowrap;

View File

@ -69,6 +69,7 @@ const localeValues: Locale = {
back: '返回',
},
Form: {
optional: '(可選)',
defaultValidateMessages: {
default: '字段驗證錯誤${label}',
required: '請輸入${label}',

View File

@ -157,6 +157,6 @@ describe('PageHeader', () => {
wrapper.triggerResize();
await Promise.resolve();
wrapper.update();
expect(wrapper.find('.ant-page-header').hasClass('ant-page-header-compact')).toBe(true);
expect(wrapper.find('.ant-page-header').hasClass('ant-page-header-compact')).toBeTruthy();
});
});

View File

@ -8,7 +8,7 @@ title:
## zh-CN
在不同大小的屏幕下,应该有不同的表现
在不同大小的屏幕下,应该有不同的表现
## en-US

View File

@ -89,12 +89,12 @@ Select component to select value from options.
### Option props
| Property | Description | Type | Default | Version |
| --------- | ------------------------------------------ | ---------------- | ------- | ------- |
| className | The additional class to option | string | - | |
| disabled | Disable this option | boolean | false | |
| title | `title` of Select after select this Option | string | - | |
| value | Default to filter with this property | string \| number | - | |
| Property | Description | Type | Default | Version |
| --------- | ------------------------------------ | ---------------- | ------- | ------- |
| className | The additional class to option | string | - | |
| disabled | Disable this option | boolean | false | |
| title | `title` attribute of Select Option | string | - | |
| value | Default to filter with this property | string \| number | - | |
### OptGroup props

View File

@ -90,12 +90,12 @@ cover: https://gw.alipayobjects.com/zos/alicdn/_0XzgOis7/Select.svg
### Option props
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --------- | --------------------------------- | ---------------- | ------ | ---- |
| className | Option 器类名 | string | - | |
| disabled | 是否禁用 | boolean | false | |
| title | 选中该 Option 后Select 的 title | string | - | |
| value | 默认根据此属性值进行筛选 | string \| number | - | |
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --------- | ------------------------ | ---------------- | ------ | ---- |
| className | Option 器类名 | string | - | |
| disabled | 是否禁用 | boolean | false | |
| title | 选项上的原生 title 提示 | string | - | |
| value | 默认根据此属性值进行筛选 | string \| number | - | |
### OptGroup props

View File

@ -1,6 +1,6 @@
{
"name": "antd",
"version": "4.17.1",
"version": "4.17.2",
"description": "An enterprise-class UI design language and React components implementation",
"title": "Ant Design",
"keywords": [
@ -138,7 +138,7 @@
"rc-picker": "~2.5.17",
"rc-progress": "~3.1.0",
"rc-rate": "~2.9.0",
"rc-resize-observer": "^1.0.0",
"rc-resize-observer": "^1.1.0",
"rc-select": "~13.1.0-alpha.0",
"rc-slider": "~9.7.4",
"rc-steps": "~4.1.0",

View File

@ -1,4 +1,6 @@
const React = require('react');
const { _rs: onLibResize } = require('rc-resize-observer/lib/utils/observerUtil');
const { _rs: onEsResize } = require('rc-resize-observer/es/utils/observerUtil');
// eslint-disable-next-line no-console
console.log('Current React Version:', React.version);
@ -44,11 +46,17 @@ const Adapter =
Enzyme.configure({ adapter: new Adapter() });
Object.assign(Enzyme.ReactWrapper.prototype, {
findObserver() {
return this.find('ResizeObserver');
findObserver(index = 0) {
return this.find('ResizeObserver').at(index);
},
triggerResize() {
const ob = this.findObserver();
ob.instance().onResize([{ target: ob.getDOMNode() }]);
triggerResize(index = 0) {
const target = this.findObserver(index).getDOMNode();
const originGetBoundingClientRect = target.getBoundingClientRect;
target.getBoundingClientRect = () => ({ width: 510, height: 903 });
onLibResize([{ target }]);
onEsResize([{ target }]);
target.getBoundingClientRect = originGetBoundingClientRect;
},
});