mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 11:32:52 +08:00
refactor: 🗑 remove deprecated or compatibility css code (#20547)
* 🗑️ remove deprecated or compatibility css code * ✅ update snapshots * ✅ fix test case and compile error * ✅ fix stylelint
This commit is contained in:
parent
8ab21992d5
commit
7dea548551
@ -5,7 +5,6 @@ import KeyCode from 'rc-util/lib/KeyCode';
|
|||||||
import delayRaf from '../raf';
|
import delayRaf from '../raf';
|
||||||
import throttleByAnimationFrame from '../throttleByAnimationFrame';
|
import throttleByAnimationFrame from '../throttleByAnimationFrame';
|
||||||
import getDataOrAriaProps from '../getDataOrAriaProps';
|
import getDataOrAriaProps from '../getDataOrAriaProps';
|
||||||
import triggerEvent from '../triggerEvent';
|
|
||||||
import Wave from '../wave';
|
import Wave from '../wave';
|
||||||
import TransButton from '../transButton';
|
import TransButton from '../transButton';
|
||||||
import openAnimation from '../openAnimation';
|
import openAnimation from '../openAnimation';
|
||||||
@ -126,19 +125,6 @@ describe('Test utils function', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggerEvent', () => {
|
|
||||||
const button = document.createElement('button');
|
|
||||||
button.addEventListener(
|
|
||||||
'click',
|
|
||||||
() => {
|
|
||||||
button.style.width = '100px';
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
triggerEvent(button, 'click');
|
|
||||||
expect(button.style.width).toBe('100px');
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('wave', () => {
|
describe('wave', () => {
|
||||||
it('bindAnimationEvent should return when node is null', () => {
|
it('bindAnimationEvent should return when node is null', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
export default function triggerEvent(el: Element, type: string) {
|
|
||||||
if ('createEvent' in document) {
|
|
||||||
// modern browsers, IE9+
|
|
||||||
const e = document.createEvent('HTMLEvents');
|
|
||||||
e.initEvent(type, false, true);
|
|
||||||
el.dispatchEvent(e);
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ import ResizeObserver from 'rc-resize-observer';
|
|||||||
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||||
import { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame';
|
import { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame';
|
||||||
|
|
||||||
import warning from '../_util/warning';
|
|
||||||
import {
|
import {
|
||||||
addObserveTarget,
|
addObserveTarget,
|
||||||
removeObserveTarget,
|
removeObserveTarget,
|
||||||
@ -24,7 +23,6 @@ export interface AffixProps {
|
|||||||
* 距离窗口顶部达到指定偏移量后触发
|
* 距离窗口顶部达到指定偏移量后触发
|
||||||
*/
|
*/
|
||||||
offsetTop?: number;
|
offsetTop?: number;
|
||||||
offset?: number;
|
|
||||||
/** 距离窗口底部达到指定偏移量后触发 */
|
/** 距离窗口底部达到指定偏移量后触发 */
|
||||||
offsetBottom?: number;
|
offsetBottom?: number;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
@ -118,17 +116,8 @@ class Affix extends React.Component<AffixProps, AffixState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getOffsetTop = () => {
|
getOffsetTop = () => {
|
||||||
const { offset, offsetBottom } = this.props;
|
const { offsetBottom } = this.props;
|
||||||
let { offsetTop } = this.props;
|
let { offsetTop } = this.props;
|
||||||
if (typeof offsetTop === 'undefined') {
|
|
||||||
offsetTop = offset;
|
|
||||||
warning(
|
|
||||||
typeof offset === 'undefined',
|
|
||||||
'Affix',
|
|
||||||
'`offset` is deprecated. Please use `offsetTop` instead.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offsetBottom === undefined && offsetTop === undefined) {
|
if (offsetBottom === undefined && offsetTop === undefined) {
|
||||||
offsetTop = 0;
|
offsetTop = 0;
|
||||||
}
|
}
|
||||||
|
@ -33,19 +33,6 @@ describe('Card', () => {
|
|||||||
expect(wrapper.render()).toMatchSnapshot();
|
expect(wrapper.render()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('warning', () => {
|
|
||||||
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
||||||
mount(<Card noHovering>xxx</Card>);
|
|
||||||
expect(warnSpy).toHaveBeenCalledWith(
|
|
||||||
'Warning: [antd: Card] `noHovering` is deprecated, you can remove it safely or use `hoverable` instead.',
|
|
||||||
);
|
|
||||||
mount(<Card noHovering={false}>xxx</Card>);
|
|
||||||
expect(warnSpy).toHaveBeenCalledWith(
|
|
||||||
'Warning: [antd: Card] `noHovering={false}` is deprecated, use `hoverable` instead.',
|
|
||||||
);
|
|
||||||
warnSpy.mockRestore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('onTabChange should work', () => {
|
it('onTabChange should work', () => {
|
||||||
const tabList = [
|
const tabList = [
|
||||||
{
|
{
|
||||||
@ -70,11 +57,6 @@ describe('Card', () => {
|
|||||||
expect(onTabChange).toHaveBeenCalledWith('tab2');
|
expect(onTabChange).toHaveBeenCalledWith('tab2');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getCompatibleHoverable should work', () => {
|
|
||||||
const wrapper = mount(<Card noHovering={false}>xxx</Card>);
|
|
||||||
expect(wrapper.find('.ant-card-hoverable').length).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not render when actions is number', () => {
|
it('should not render when actions is number', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<Card title="Card title" actions={11}>
|
<Card title="Card title" actions={11}>
|
||||||
|
@ -7,7 +7,6 @@ import Tabs from '../tabs';
|
|||||||
import Row from '../row';
|
import Row from '../row';
|
||||||
import Col from '../col';
|
import Col from '../col';
|
||||||
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||||
import warning from '../_util/warning';
|
|
||||||
import { Omit } from '../_util/type';
|
import { Omit } from '../_util/type';
|
||||||
|
|
||||||
function getAction(actions: React.ReactNode[]) {
|
function getAction(actions: React.ReactNode[]) {
|
||||||
@ -41,7 +40,6 @@ export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 't
|
|||||||
bodyStyle?: React.CSSProperties;
|
bodyStyle?: React.CSSProperties;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
noHovering?: boolean;
|
|
||||||
hoverable?: boolean;
|
hoverable?: boolean;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
id?: string;
|
id?: string;
|
||||||
@ -62,30 +60,6 @@ export default class Card extends React.Component<CardProps, {}> {
|
|||||||
|
|
||||||
static Meta: typeof Meta = Meta;
|
static Meta: typeof Meta = Meta;
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
if ('noHovering' in this.props) {
|
|
||||||
warning(
|
|
||||||
!this.props.noHovering,
|
|
||||||
'Card',
|
|
||||||
'`noHovering` is deprecated, you can remove it safely or use `hoverable` instead.',
|
|
||||||
);
|
|
||||||
warning(
|
|
||||||
!!this.props.noHovering,
|
|
||||||
'Card',
|
|
||||||
'`noHovering={false}` is deprecated, use `hoverable` instead.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// For 2.x compatible
|
|
||||||
getCompatibleHoverable() {
|
|
||||||
const { noHovering, hoverable } = this.props;
|
|
||||||
if ('noHovering' in this.props) {
|
|
||||||
return !noHovering || hoverable;
|
|
||||||
}
|
|
||||||
return !!hoverable;
|
|
||||||
}
|
|
||||||
|
|
||||||
onTabChange = (key: string) => {
|
onTabChange = (key: string) => {
|
||||||
if (this.props.onTabChange) {
|
if (this.props.onTabChange) {
|
||||||
this.props.onTabChange(key);
|
this.props.onTabChange(key);
|
||||||
@ -121,6 +95,7 @@ export default class Card extends React.Component<CardProps, {}> {
|
|||||||
activeTabKey,
|
activeTabKey,
|
||||||
defaultActiveTabKey,
|
defaultActiveTabKey,
|
||||||
tabBarExtraContent,
|
tabBarExtraContent,
|
||||||
|
hoverable,
|
||||||
...others
|
...others
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
@ -128,7 +103,7 @@ export default class Card extends React.Component<CardProps, {}> {
|
|||||||
const classString = classNames(prefixCls, className, {
|
const classString = classNames(prefixCls, className, {
|
||||||
[`${prefixCls}-loading`]: loading,
|
[`${prefixCls}-loading`]: loading,
|
||||||
[`${prefixCls}-bordered`]: bordered,
|
[`${prefixCls}-bordered`]: bordered,
|
||||||
[`${prefixCls}-hoverable`]: this.getCompatibleHoverable(),
|
[`${prefixCls}-hoverable`]: hoverable,
|
||||||
[`${prefixCls}-contain-grid`]: this.isContainGrid(),
|
[`${prefixCls}-contain-grid`]: this.isContainGrid(),
|
||||||
[`${prefixCls}-contain-tabs`]: tabList && tabList.length,
|
[`${prefixCls}-contain-tabs`]: tabList && tabList.length,
|
||||||
[`${prefixCls}-${size}`]: size !== 'default',
|
[`${prefixCls}-${size}`]: size !== 'default',
|
||||||
@ -226,7 +201,7 @@ export default class Card extends React.Component<CardProps, {}> {
|
|||||||
actions && actions.length ? (
|
actions && actions.length ? (
|
||||||
<ul className={`${prefixCls}-actions`}>{getAction(actions)}</ul>
|
<ul className={`${prefixCls}-actions`}>{getAction(actions)}</ul>
|
||||||
) : null;
|
) : null;
|
||||||
const divProps = omit(others, ['onTabChange', 'noHovering', 'hoverable']);
|
const divProps = omit(others, ['onTabChange']);
|
||||||
return (
|
return (
|
||||||
<div {...divProps} className={classString}>
|
<div {...divProps} className={classString}>
|
||||||
{head}
|
{head}
|
||||||
|
@ -36,10 +36,10 @@ exports[`Carousel should works for dotPosition bottom 1`] = `
|
|||||||
|
|
||||||
exports[`Carousel should works for dotPosition left 1`] = `
|
exports[`Carousel should works for dotPosition left 1`] = `
|
||||||
<div
|
<div
|
||||||
class="ant-carousel ant-carousel-vertical"
|
class="ant-carousel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="slick-slider slick-vertical slick-initialized"
|
class="slick-slider slick-initialized"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="slick-list"
|
class="slick-list"
|
||||||
@ -70,10 +70,10 @@ exports[`Carousel should works for dotPosition left 1`] = `
|
|||||||
|
|
||||||
exports[`Carousel should works for dotPosition right 1`] = `
|
exports[`Carousel should works for dotPosition right 1`] = `
|
||||||
<div
|
<div
|
||||||
class="ant-carousel ant-carousel-vertical"
|
class="ant-carousel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="slick-slider slick-vertical slick-initialized"
|
class="slick-slider slick-initialized"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="slick-list"
|
class="slick-list"
|
||||||
|
@ -95,19 +95,6 @@ describe('Carousel', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('warning', () => {
|
|
||||||
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
||||||
mount(
|
|
||||||
<Carousel vertical>
|
|
||||||
<div />
|
|
||||||
</Carousel>,
|
|
||||||
);
|
|
||||||
expect(warnSpy).toHaveBeenCalledWith(
|
|
||||||
'Warning: [antd: Carousel] `vertical` is deprecated, please use `dotPosition` instead.',
|
|
||||||
);
|
|
||||||
warnSpy.mockRestore();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('should active when children change', () => {
|
describe('should active when children change', () => {
|
||||||
it('should active', () => {
|
it('should active', () => {
|
||||||
const wrapper = mount(<Carousel />);
|
const wrapper = mount(<Carousel />);
|
||||||
|
@ -2,7 +2,6 @@ import * as React from 'react';
|
|||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import { Settings } from '@ant-design/react-slick';
|
import { Settings } from '@ant-design/react-slick';
|
||||||
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||||
import warning from '../_util/warning';
|
|
||||||
|
|
||||||
// Use require over import (will be lifted up)
|
// Use require over import (will be lifted up)
|
||||||
// make sure matchMedia polyfill run before require('react-slick')
|
// make sure matchMedia polyfill run before require('react-slick')
|
||||||
@ -39,14 +38,6 @@ export default class Carousel extends React.Component<CarouselProps, {}> {
|
|||||||
this.onWindowResized = debounce(this.onWindowResized, 500, {
|
this.onWindowResized = debounce(this.onWindowResized, 500, {
|
||||||
leading: false,
|
leading: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if ('vertical' in this.props) {
|
|
||||||
warning(
|
|
||||||
!this.props.vertical,
|
|
||||||
'Carousel',
|
|
||||||
'`vertical` is deprecated, please use `dotPosition` instead.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -73,13 +64,8 @@ export default class Carousel extends React.Component<CarouselProps, {}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getDotPosition(): DotPosition {
|
getDotPosition(): DotPosition {
|
||||||
if (this.props.dotPosition) {
|
const { dotPosition = 'bottom' } = this.props;
|
||||||
return this.props.dotPosition;
|
return dotPosition;
|
||||||
}
|
|
||||||
if ('vertical' in this.props) {
|
|
||||||
return this.props.vertical ? 'right' : 'bottom';
|
|
||||||
}
|
|
||||||
return 'bottom';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
saveSlick = (node: any) => {
|
saveSlick = (node: any) => {
|
||||||
@ -115,14 +101,10 @@ export default class Carousel extends React.Component<CarouselProps, {}> {
|
|||||||
props.fade = true;
|
props.fade = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let className = getPrefixCls('carousel', props.prefixCls);
|
const className = getPrefixCls('carousel', props.prefixCls);
|
||||||
const dotsClass = 'slick-dots';
|
const dotsClass = 'slick-dots';
|
||||||
const dotPosition = this.getDotPosition();
|
const dotPosition = this.getDotPosition();
|
||||||
props.vertical = dotPosition === 'left' || dotPosition === 'right';
|
|
||||||
props.dotsClass = `${dotsClass} ${dotsClass}-${dotPosition || 'bottom'}`;
|
props.dotsClass = `${dotsClass} ${dotsClass}-${dotPosition || 'bottom'}`;
|
||||||
if (props.vertical) {
|
|
||||||
className = `${className} ${className}-vertical`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
|
@ -340,66 +340,6 @@ describe('Cascader', () => {
|
|||||||
).toBe(3);
|
).toBe(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://github.com/ant-design/ant-design/issues/12970
|
|
||||||
it('can use filedNames too, for compatibility', () => {
|
|
||||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
||||||
const customerOptions = [
|
|
||||||
{
|
|
||||||
code: 'zhejiang',
|
|
||||||
name: 'Zhejiang',
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
code: 'hangzhou',
|
|
||||||
name: 'Hangzhou',
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
code: 'xihu',
|
|
||||||
name: 'West Lake',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'jiangsu',
|
|
||||||
name: 'Jiangsu',
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
code: 'nanjing',
|
|
||||||
name: 'Nanjing',
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
code: 'zhonghuamen',
|
|
||||||
name: 'Zhong Hua Men',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const wrapper = mount(
|
|
||||||
<Cascader
|
|
||||||
options={customerOptions}
|
|
||||||
filedNames={{
|
|
||||||
children: 'items',
|
|
||||||
label: 'name',
|
|
||||||
value: 'code',
|
|
||||||
}}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
wrapper.instance().handleChange(['zhejiang', 'hangzhou', 'xihu'], customerOptions);
|
|
||||||
expect(
|
|
||||||
wrapper
|
|
||||||
.find('.ant-cascader-picker-label')
|
|
||||||
.text()
|
|
||||||
.split('/').length,
|
|
||||||
).toBe(3);
|
|
||||||
expect(errorSpy).toHaveBeenLastCalledWith(
|
|
||||||
'Warning: `filedNames` of Cascader is a typo usage and deprecated, please use `fieldNames` instead.',
|
|
||||||
);
|
|
||||||
errorSpy.mockReset();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show not found content when options.length is 0', () => {
|
it('should show not found content when options.length is 0', () => {
|
||||||
const customerOptions = [];
|
const customerOptions = [];
|
||||||
const wrapper = mount(<Cascader options={customerOptions} />);
|
const wrapper = mount(<Cascader options={customerOptions} />);
|
||||||
|
@ -95,8 +95,6 @@ export interface CascaderProps {
|
|||||||
popupVisible?: boolean;
|
popupVisible?: boolean;
|
||||||
/** use this after antd@3.7.0 */
|
/** use this after antd@3.7.0 */
|
||||||
fieldNames?: FieldNamesType;
|
fieldNames?: FieldNamesType;
|
||||||
/** typo props name before antd@3.7.0 */
|
|
||||||
filedNames?: FieldNamesType;
|
|
||||||
suffixIcon?: React.ReactNode;
|
suffixIcon?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,11 +164,7 @@ function defaultSortFilteredOption(
|
|||||||
return a.findIndex(callback) - b.findIndex(callback);
|
return a.findIndex(callback) - b.findIndex(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFieldNames(props: CascaderProps) {
|
function getFieldNames({ fieldNames }: CascaderProps) {
|
||||||
const { fieldNames, filedNames } = props;
|
|
||||||
if ('filedNames' in props) {
|
|
||||||
return filedNames; // For old compatibility
|
|
||||||
}
|
|
||||||
return fieldNames;
|
return fieldNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +480,6 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
|
|||||||
'sortFilteredOption',
|
'sortFilteredOption',
|
||||||
'notFoundContent',
|
'notFoundContent',
|
||||||
'fieldNames',
|
'fieldNames',
|
||||||
'filedNames', // For old compatibility
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let { options } = props;
|
let { options } = props;
|
||||||
|
@ -4,7 +4,6 @@ import { CloseOutlined } from '@ant-design/icons';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import omit from 'omit.js';
|
import omit from 'omit.js';
|
||||||
|
|
||||||
import warning from '../_util/warning';
|
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import { withConfigConsumer } from '../config-provider/context';
|
import { withConfigConsumer } from '../config-provider/context';
|
||||||
import { tuple } from '../_util/type';
|
import { tuple } from '../_util/type';
|
||||||
@ -35,8 +34,6 @@ export interface DrawerProps {
|
|||||||
visible?: boolean;
|
visible?: boolean;
|
||||||
width?: number | string;
|
width?: number | string;
|
||||||
height?: number | string;
|
height?: number | string;
|
||||||
/* deprecated, use className instead */
|
|
||||||
wrapClassName?: string;
|
|
||||||
zIndex?: number;
|
zIndex?: number;
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
push?: boolean;
|
push?: boolean;
|
||||||
@ -209,21 +206,7 @@ class Drawer extends React.Component<DrawerProps & ConfigConsumerProps, IDrawerS
|
|||||||
|
|
||||||
// render Provider for Multi-level drawer
|
// render Provider for Multi-level drawer
|
||||||
renderProvider = (value: Drawer) => {
|
renderProvider = (value: Drawer) => {
|
||||||
const {
|
const { prefixCls, placement, className, width, height, mask, ...rest } = this.props;
|
||||||
prefixCls,
|
|
||||||
placement,
|
|
||||||
className,
|
|
||||||
wrapClassName,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
mask,
|
|
||||||
...rest
|
|
||||||
} = this.props;
|
|
||||||
warning(
|
|
||||||
wrapClassName === undefined,
|
|
||||||
'Drawer',
|
|
||||||
'wrapClassName is deprecated, please use className instead.',
|
|
||||||
);
|
|
||||||
const haveMask = mask ? '' : 'no-mask';
|
const haveMask = mask ? '' : 'no-mask';
|
||||||
this.parentDrawer = value;
|
this.parentDrawer = value;
|
||||||
const offsetStyle: any = {};
|
const offsetStyle: any = {};
|
||||||
@ -261,7 +244,7 @@ class Drawer extends React.Component<DrawerProps & ConfigConsumerProps, IDrawerS
|
|||||||
showMask={mask}
|
showMask={mask}
|
||||||
placement={placement}
|
placement={placement}
|
||||||
style={this.getRcDrawerStyle()}
|
style={this.getRcDrawerStyle()}
|
||||||
className={classNames(wrapClassName, className, haveMask)}
|
className={classNames(className, haveMask)}
|
||||||
>
|
>
|
||||||
{this.renderBody()}
|
{this.renderBody()}
|
||||||
</RcDrawer>
|
</RcDrawer>
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
@import '../../style/themes/index';
|
@import '../../style/themes/index';
|
||||||
|
|
||||||
// Preserve the typo for compatibility
|
@drawer-prefix-cls: ~'@{ant-prefix}-drawer';
|
||||||
// https://github.com/ant-design/ant-design/issues/14628
|
|
||||||
@dawer-prefix-cls: ~'@{ant-prefix}-drawer';
|
|
||||||
|
|
||||||
@drawer-prefix-cls: @dawer-prefix-cls;
|
|
||||||
|
|
||||||
.@{drawer-prefix-cls} {
|
.@{drawer-prefix-cls} {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
@ -4,7 +4,6 @@ import omit from 'omit.js';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import calculateNodeHeight from './calculateNodeHeight';
|
import calculateNodeHeight from './calculateNodeHeight';
|
||||||
import raf from '../_util/raf';
|
import raf from '../_util/raf';
|
||||||
import warning from '../_util/warning';
|
|
||||||
import { TextAreaProps } from './TextArea';
|
import { TextAreaProps } from './TextArea';
|
||||||
|
|
||||||
export interface AutoSizeType {
|
export interface AutoSizeType {
|
||||||
@ -49,11 +48,11 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleResize = (size: { width: number; height: number }) => {
|
handleResize = (size: { width: number; height: number }) => {
|
||||||
const { autoSize, autosize, onResize } = this.props;
|
const { autoSize, onResize } = this.props;
|
||||||
if (typeof onResize === 'function') {
|
if (typeof onResize === 'function') {
|
||||||
onResize(size);
|
onResize(size);
|
||||||
}
|
}
|
||||||
if (autoSize || autosize) {
|
if (autoSize) {
|
||||||
this.resizeOnNextFrame();
|
this.resizeOnNextFrame();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -64,7 +63,7 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
resizeTextarea = () => {
|
resizeTextarea = () => {
|
||||||
const autoSize = this.props.autoSize || this.props.autosize;
|
const { autoSize } = this.props;
|
||||||
if (!autoSize || !this.textArea) {
|
if (!autoSize || !this.textArea) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -84,18 +83,12 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderTextArea = () => {
|
renderTextArea = () => {
|
||||||
const { prefixCls, autoSize, autosize, onResize, className, disabled } = this.props;
|
const { prefixCls, autoSize, onResize, className, disabled } = this.props;
|
||||||
const { textareaStyles, resizing } = this.state;
|
const { textareaStyles, resizing } = this.state;
|
||||||
warning(
|
|
||||||
autosize === undefined,
|
|
||||||
'Input.TextArea',
|
|
||||||
'autosize is deprecated, please use autoSize instead.',
|
|
||||||
);
|
|
||||||
const otherProps = omit(this.props, [
|
const otherProps = omit(this.props, [
|
||||||
'prefixCls',
|
'prefixCls',
|
||||||
'onPressEnter',
|
'onPressEnter',
|
||||||
'autoSize',
|
'autoSize',
|
||||||
'autosize',
|
|
||||||
'defaultValue',
|
'defaultValue',
|
||||||
'allowClear',
|
'allowClear',
|
||||||
'onResize',
|
'onResize',
|
||||||
@ -114,7 +107,7 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
|
|||||||
...(resizing ? { overflow: 'hidden' } : null),
|
...(resizing ? { overflow: 'hidden' } : null),
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<ResizeObserver onResize={this.handleResize} disabled={!(autoSize || autosize || onResize)}>
|
<ResizeObserver onResize={this.handleResize} disabled={!(autoSize || onResize)}>
|
||||||
<textarea {...otherProps} className={cls} style={style} ref={this.saveTextArea} />
|
<textarea {...otherProps} className={cls} style={style} ref={this.saveTextArea} />
|
||||||
</ResizeObserver>
|
</ResizeObserver>
|
||||||
);
|
);
|
||||||
|
@ -8,8 +8,6 @@ export type HTMLTextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement
|
|||||||
|
|
||||||
export interface TextAreaProps extends HTMLTextareaProps {
|
export interface TextAreaProps extends HTMLTextareaProps {
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
/* deprecated, use autoSize instead */
|
|
||||||
autosize?: boolean | AutoSizeType;
|
|
||||||
autoSize?: boolean | AutoSizeType;
|
autoSize?: boolean | AutoSizeType;
|
||||||
onPressEnter?: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
onPressEnter?: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
||||||
allowClear?: boolean;
|
allowClear?: boolean;
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
.@{steps-prefix-cls}-flex-not-supported {
|
|
||||||
&.@{steps-prefix-cls}-horizontal.@{steps-prefix-cls}-label-horizontal {
|
|
||||||
.@{steps-prefix-cls}-item {
|
|
||||||
margin-left: -16px;
|
|
||||||
padding-left: 16px;
|
|
||||||
background: @steps-background;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.@{steps-prefix-cls}-small .@{steps-prefix-cls}-item {
|
|
||||||
margin-left: -12px;
|
|
||||||
padding-left: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.@{steps-prefix-cls}-dot {
|
|
||||||
.@{steps-prefix-cls}-item {
|
|
||||||
&:last-child {
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
.@{steps-prefix-cls}-icon-dot::after {
|
|
||||||
right: -200px;
|
|
||||||
width: 200px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.@{steps-prefix-cls}-icon-dot::before,
|
|
||||||
.@{steps-prefix-cls}-icon-dot::after {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: -10px;
|
|
||||||
width: 10px;
|
|
||||||
height: 8px;
|
|
||||||
background: @steps-background;
|
|
||||||
content: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
.@{steps-prefix-cls}-icon-dot::after {
|
|
||||||
right: -10px;
|
|
||||||
left: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.@{steps-prefix-cls}-item-wait
|
|
||||||
.@{steps-prefix-cls}-item-icon
|
|
||||||
> .@{steps-prefix-cls}-icon
|
|
||||||
.@{steps-prefix-cls}-icon-dot {
|
|
||||||
background: #ccc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -241,4 +241,3 @@
|
|||||||
@import 'label-placement';
|
@import 'label-placement';
|
||||||
@import 'progress-dot';
|
@import 'progress-dot';
|
||||||
@import 'nav';
|
@import 'nav';
|
||||||
@import 'compatibility';
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
import './v2-compatible-reset.less';
|
|
@ -15,7 +15,7 @@ import {
|
|||||||
UploadType,
|
UploadType,
|
||||||
UploadListType,
|
UploadListType,
|
||||||
} from './interface';
|
} from './interface';
|
||||||
import { T, fileToObject, genPercentAdd, getFileItem, removeFileItem } from './utils';
|
import { T, fileToObject, getFileItem, removeFileItem } from './utils';
|
||||||
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
||||||
import defaultLocale from '../locale/default';
|
import defaultLocale from '../locale/default';
|
||||||
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||||
@ -96,10 +96,6 @@ class Upload extends React.Component<UploadProps, UploadState> {
|
|||||||
file: targetItem,
|
file: targetItem,
|
||||||
fileList: nextFileList,
|
fileList: nextFileList,
|
||||||
});
|
});
|
||||||
// fix ie progress
|
|
||||||
if (!(window as any).File || process.env.TEST_IE) {
|
|
||||||
this.autoUpdateProgress(0, targetItem);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onSuccess = (response: any, file: UploadFile, xhr: any) => {
|
onSuccess = (response: any, file: UploadFile, xhr: any) => {
|
||||||
@ -229,21 +225,6 @@ class Upload extends React.Component<UploadProps, UploadState> {
|
|||||||
clearInterval(this.progressTimer);
|
clearInterval(this.progressTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
autoUpdateProgress(_: any, file: UploadFile) {
|
|
||||||
const getPercent = genPercentAdd();
|
|
||||||
let curPercent = 0;
|
|
||||||
this.clearProgressTimer();
|
|
||||||
this.progressTimer = setInterval(() => {
|
|
||||||
curPercent = getPercent(curPercent);
|
|
||||||
this.onProgress(
|
|
||||||
{
|
|
||||||
percent: curPercent * 100,
|
|
||||||
},
|
|
||||||
file,
|
|
||||||
);
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderUploadList = (locale: UploadLocale) => {
|
renderUploadList = (locale: UploadLocale) => {
|
||||||
const {
|
const {
|
||||||
showUploadList,
|
showUploadList,
|
||||||
|
@ -3,7 +3,7 @@ import React from 'react';
|
|||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Upload from '..';
|
import Upload from '..';
|
||||||
import Form from '../../form';
|
import Form from '../../form';
|
||||||
import { T, fileToObject, genPercentAdd, getFileItem, removeFileItem } from '../utils';
|
import { T, fileToObject, getFileItem, removeFileItem } from '../utils';
|
||||||
import { setup, teardown } from './mock';
|
import { setup, teardown } from './mock';
|
||||||
import { resetWarned } from '../../_util/warning';
|
import { resetWarned } from '../../_util/warning';
|
||||||
import mountTest from '../../../tests/shared/mountTest';
|
import mountTest from '../../../tests/shared/mountTest';
|
||||||
@ -61,37 +61,6 @@ describe('Upload', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update progress in IE', done => {
|
|
||||||
const originSetInterval = window.setInterval;
|
|
||||||
process.env.TEST_IE = true;
|
|
||||||
Object.defineProperty(window, 'setInterval', {
|
|
||||||
value: fn => fn(),
|
|
||||||
});
|
|
||||||
const props = {
|
|
||||||
action: 'http://upload.com',
|
|
||||||
onChange: ({ file }) => {
|
|
||||||
if (file.status !== 'uploading') {
|
|
||||||
process.env.TEST_IE = undefined;
|
|
||||||
Object.defineProperty(window, 'setInterval', {
|
|
||||||
value: originSetInterval,
|
|
||||||
});
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const wrapper = mount(
|
|
||||||
<Upload {...props}>
|
|
||||||
<button type="button">upload</button>
|
|
||||||
</Upload>,
|
|
||||||
);
|
|
||||||
wrapper.find('input').simulate('change', {
|
|
||||||
target: {
|
|
||||||
files: [{ file: 'foo.png' }],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('beforeUpload can be falsy', done => {
|
it('beforeUpload can be falsy', done => {
|
||||||
const props = {
|
const props = {
|
||||||
action: 'http://upload.com',
|
action: 'http://upload.com',
|
||||||
@ -188,41 +157,6 @@ describe('Upload', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should increase percent automatically when call autoUpdateProgress in IE', done => {
|
|
||||||
let uploadInstance;
|
|
||||||
let lastPercent = -1;
|
|
||||||
const props = {
|
|
||||||
action: 'http://upload.com',
|
|
||||||
onChange: ({ file }) => {
|
|
||||||
if (file.percent === 0 && file.status === 'uploading') {
|
|
||||||
// manually call it
|
|
||||||
uploadInstance.autoUpdateProgress(0, file);
|
|
||||||
}
|
|
||||||
if (file.status === 'uploading') {
|
|
||||||
expect(file.percent).toBeGreaterThan(lastPercent);
|
|
||||||
lastPercent = file.percent;
|
|
||||||
}
|
|
||||||
if (file.status === 'done' || file.status === 'error') {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const wrapper = mount(
|
|
||||||
<Upload {...props}>
|
|
||||||
<button type="button">upload</button>
|
|
||||||
</Upload>,
|
|
||||||
);
|
|
||||||
|
|
||||||
wrapper.find('input').simulate('change', {
|
|
||||||
target: {
|
|
||||||
files: [{ file: 'foo.png' }],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
uploadInstance = wrapper.instance();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not stop upload when return value of beforeUpload is not false', done => {
|
it('should not stop upload when return value of beforeUpload is not false', done => {
|
||||||
const data = jest.fn();
|
const data = jest.fn();
|
||||||
const props = {
|
const props = {
|
||||||
@ -332,24 +266,6 @@ describe('Upload', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to progress from 0.1 ', () => {
|
|
||||||
// 0.1 -> 0.98
|
|
||||||
const getPercent = genPercentAdd();
|
|
||||||
let curPercent = 0;
|
|
||||||
curPercent = getPercent(curPercent);
|
|
||||||
expect(curPercent).toBe(0.1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be able to progress to 0.98 ', () => {
|
|
||||||
// 0.1 -> 0.98
|
|
||||||
const getPercent = genPercentAdd();
|
|
||||||
let curPercent = 0;
|
|
||||||
for (let i = 0; i < 500; i += 1) {
|
|
||||||
curPercent = getPercent(curPercent);
|
|
||||||
}
|
|
||||||
expect(parseFloat(curPercent.toFixed(2))).toBe(0.98);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be able to get fileItem', () => {
|
it('should be able to get fileItem', () => {
|
||||||
const file = { uid: '-1', name: 'item.jpg' };
|
const file = { uid: '-1', name: 'item.jpg' };
|
||||||
const fileList = [
|
const fileList = [
|
||||||
|
@ -87,7 +87,3 @@ Please set property `url` of each item in `fileList` to control content of link.
|
|||||||
### How to use `customRequest`?
|
### How to use `customRequest`?
|
||||||
|
|
||||||
See <https://github.com/react-component/upload#customrequest>.
|
See <https://github.com/react-component/upload#customrequest>.
|
||||||
|
|
||||||
### IE8/9 Note
|
|
||||||
|
|
||||||
See <https://github.com/react-component/upload#ie89-note>.
|
|
||||||
|
@ -87,7 +87,3 @@ title: Upload
|
|||||||
### `customRequest` 怎么使用?
|
### `customRequest` 怎么使用?
|
||||||
|
|
||||||
请参考 <https://github.com/react-component/upload#customrequest>。
|
请参考 <https://github.com/react-component/upload#customrequest>。
|
||||||
|
|
||||||
### IE8/9 问题
|
|
||||||
|
|
||||||
请参考 <https://github.com/react-component/upload#ie89-note>。
|
|
||||||
|
@ -20,29 +20,6 @@ export function fileToObject(file: RcFile): UploadFile {
|
|||||||
} as UploadFile;
|
} as UploadFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成Progress percent: 0.1 -> 0.98
|
|
||||||
* - for ie
|
|
||||||
*/
|
|
||||||
export function genPercentAdd() {
|
|
||||||
let k = 0.1;
|
|
||||||
const i = 0.01;
|
|
||||||
const end = 0.98;
|
|
||||||
return (s: number) => {
|
|
||||||
let start = s;
|
|
||||||
if (start >= end) {
|
|
||||||
return start;
|
|
||||||
}
|
|
||||||
|
|
||||||
start += k;
|
|
||||||
k -= i;
|
|
||||||
if (k < 0.001) {
|
|
||||||
k = 0.001;
|
|
||||||
}
|
|
||||||
return start;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFileItem(file: UploadFile, fileList: UploadFile[]) {
|
export function getFileItem(file: UploadFile, fileList: UploadFile[]) {
|
||||||
const matchKey = file.uid !== undefined ? 'uid' : 'name';
|
const matchKey = file.uid !== undefined ? 'uid' : 'name';
|
||||||
return fileList.filter(item => item[matchKey] === file[matchKey])[0];
|
return fileList.filter(item => item[matchKey] === file[matchKey])[0];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@import '../../../components/style/v2-compatible-reset.less';
|
@import './reset.less';
|
||||||
@import '../../../components/style/themes/default.less';
|
@import '../../../components/style/themes/default.less';
|
||||||
@import './common';
|
@import './common';
|
||||||
@import './header';
|
@import './header';
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
// For 2.x reset compatibility
|
|
||||||
// import 'antd/style/v2-compatible-reset';
|
|
||||||
// or
|
|
||||||
// @import '~antd/style/v2-compatible-reset.css';
|
|
||||||
// unify the setting of elements's margin and padding for browsers
|
|
||||||
body,
|
body,
|
||||||
div,
|
div,
|
||||||
dl,
|
dl,
|
@ -2,7 +2,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import AntdIcon, { createFromIconfontCN } from '@ant-design/icons';
|
import AntdIcon, { createFromIconfontCN } from '@ant-design/icons';
|
||||||
|
|
||||||
import { withThemeSuffix, removeTypeTheme, getThemeFromTypeName, alias } from './utils';
|
import { withThemeSuffix, removeTypeTheme, getThemeFromTypeName } from './utils';
|
||||||
import warning from '../../../../components/_util/warning';
|
import warning from '../../../../components/_util/warning';
|
||||||
|
|
||||||
const IconFont = createFromIconfontCN({
|
const IconFont = createFromIconfontCN({
|
||||||
@ -21,7 +21,7 @@ const OldIcon = props => {
|
|||||||
` the 'theme' prop '${theme}' will be ignored.`,
|
` the 'theme' prop '${theme}' will be ignored.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
computedType = withThemeSuffix(removeTypeTheme(alias(computedType)), theme || 'outlined');
|
computedType = withThemeSuffix(removeTypeTheme(computedType), theme || 'outlined');
|
||||||
return <IconFont {...props} type={`icon-${computedType}`} />;
|
return <IconFont {...props} type={`icon-${computedType}`} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,32 +46,3 @@ export function withThemeSuffix(type, theme) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For alias or compatibility
|
|
||||||
export function alias(type) {
|
|
||||||
let newType = type;
|
|
||||||
switch (type) {
|
|
||||||
case 'cross':
|
|
||||||
newType = 'close';
|
|
||||||
break;
|
|
||||||
// https://github.com/ant-design/ant-design/issues/13007
|
|
||||||
case 'interation':
|
|
||||||
newType = 'interaction';
|
|
||||||
break;
|
|
||||||
// https://github.com/ant-design/ant-design/issues/16810
|
|
||||||
case 'canlendar':
|
|
||||||
newType = 'calendar';
|
|
||||||
break;
|
|
||||||
// https://github.com/ant-design/ant-design/issues/17448
|
|
||||||
case 'colum-height':
|
|
||||||
newType = 'column-height';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
warning(
|
|
||||||
newType === type,
|
|
||||||
'Icon',
|
|
||||||
`Icon '${type}' was a typo and is now deprecated, please use '${newType}' instead.`,
|
|
||||||
);
|
|
||||||
return newType;
|
|
||||||
}
|
|
||||||
|
@ -31,8 +31,6 @@ $('lib/*/style')
|
|||||||
.hasFile('css.js')
|
.hasFile('css.js')
|
||||||
.hasFile('index.js');
|
.hasFile('index.js');
|
||||||
|
|
||||||
$('lib/style').hasFile('v2-compatible-reset.css');
|
|
||||||
|
|
||||||
// locale
|
// locale
|
||||||
const filterLocaleFile = filePath => {
|
const filterLocaleFile = filePath => {
|
||||||
const fileName = getFileName(filePath);
|
const fileName = getFileName(filePath);
|
||||||
|
Loading…
Reference in New Issue
Block a user