diff --git a/README-zh_CN.md b/README-zh_CN.md index 4ef823884f..aa59baaf1c 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -31,13 +31,13 @@ ## 🖥 支持环境 -- 现代浏览器和 IE9 及以上。 +- 现代浏览器和 IE11 及以上。 - 支持服务端渲染。 - [Electron](http://electron.atom.io/) | [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Opera](http://godban.github.io/browsers-support-badges/)
Opera | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | | --- | --- | --- | --- | --- | --- | -| IE9, IE10, IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | +| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | ## 📦 安装 diff --git a/README.md b/README.md index 92fb153836..0009fa8486 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ English | [简体中文](./README-zh_CN.md) | [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Opera](http://godban.github.io/browsers-support-badges/)
Opera | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | | --- | --- | --- | --- | --- | --- | -| IE9, IE10, IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | +| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | ## 📦 Install diff --git a/components/_util/responsiveObserve.ts b/components/_util/responsiveObserve.ts index a977331022..06e2ee2483 100644 --- a/components/_util/responsiveObserve.ts +++ b/components/_util/responsiveObserve.ts @@ -1,23 +1,3 @@ -// matchMedia polyfill for -// https://github.com/WickyNilliams/enquire.js/issues/82 -let enquire: any; - -// TODO: Will be removed in antd 4.0 because we will no longer support ie9 -if (typeof window !== 'undefined') { - const matchMediaPolyfill = (mediaQuery: string) => { - return { - media: mediaQuery, - matches: false, - addListener() {}, - removeListener() {}, - }; - }; - // ref: https://github.com/ant-design/ant-design/issues/18774 - if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any; - // eslint-disable-next-line global-require - enquire = require('enquire.js'); -} - export type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs'; export type BreakpointMap = Partial>; @@ -42,6 +22,7 @@ let subUid = -1; let screens = {}; const responsiveObserve = { + matchHandlers: {}, dispatch(pointMap: BreakpointMap) { screens = pointMap; if (subscribers.length < 1) { @@ -73,31 +54,30 @@ const responsiveObserve = { } }, unregister() { - Object.keys(responsiveMap).map((screen: Breakpoint) => - enquire.unregister(responsiveMap[screen]), - ); + Object.keys(responsiveMap).forEach((screen: Breakpoint) => { + const matchMediaQuery = responsiveMap[screen]!; + const handler = this.matchHandlers[matchMediaQuery]; + if (handler && handler.mql && handler.listener) { + handler.mql.removeListener(handler.listener); + } + }); }, 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() {}, - }), - ); + Object.keys(responsiveMap).forEach((screen: Breakpoint) => { + const matchMediaQuery = responsiveMap[screen]!; + const listener = ({ matches }: { matches: boolean }) => { + this.dispatch({ + ...screens, + [screen]: matches, + }); + }; + const mql = window.matchMedia(matchMediaQuery); + mql.addListener(listener); + this.matchHandlers[matchMediaQuery] = { + mql, + listener, + }; + }); }, }; diff --git a/components/affix/index.tsx b/components/affix/index.tsx index b974914a01..27fc945957 100644 --- a/components/affix/index.tsx +++ b/components/affix/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import classNames from 'classnames'; import omit from 'omit.js'; import ResizeObserver from 'rc-resize-observer'; @@ -299,6 +298,4 @@ class Affix extends React.Component { } } -polyfill(Affix); - export default Affix; diff --git a/components/anchor/AnchorLink.tsx b/components/anchor/AnchorLink.tsx index 532f5d804c..9f4acad869 100644 --- a/components/anchor/AnchorLink.tsx +++ b/components/anchor/AnchorLink.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; -import { polyfill } from 'react-lifecycles-compat'; import classNames from 'classnames'; import { AntAnchor } from './Anchor'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; @@ -83,6 +82,4 @@ class AnchorLink extends React.Component { } } -polyfill(AnchorLink); - export default AnchorLink; diff --git a/components/badge/ScrollNumber.tsx b/components/badge/ScrollNumber.tsx index 9917d7a52e..33920dfd02 100644 --- a/components/badge/ScrollNumber.tsx +++ b/components/badge/ScrollNumber.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import omit from 'omit.js'; import classNames from 'classnames'; -import { polyfill } from 'react-lifecycles-compat'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; function getNumberArray(num: string | number | undefined | null) { @@ -208,6 +207,4 @@ class ScrollNumber extends React.Component } } -polyfill(ScrollNumber); - export default ScrollNumber; diff --git a/components/badge/index.tsx b/components/badge/index.tsx index 7fa8051fc2..8b403ea678 100644 --- a/components/badge/index.tsx +++ b/components/badge/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import Animate from 'rc-animate'; import omit from 'omit.js'; import classNames from 'classnames'; @@ -40,13 +39,6 @@ export default class Badge extends React.Component { overflowCount: 99, }; - static propTypes = { - count: PropTypes.node, - showZero: PropTypes.bool, - dot: PropTypes.bool, - overflowCount: PropTypes.number, - }; - getNumberedDispayCount() { const { count, overflowCount } = this.props; const displayCount = diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index 278e82674a..df8f7ff722 100755 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import classNames from 'classnames'; import toArray from 'rc-util/lib/Children/toArray'; import omit from 'omit.js'; @@ -68,12 +67,6 @@ export default class Breadcrumb extends React.Component { separator: '/', }; - static propTypes = { - prefixCls: PropTypes.string, - separator: PropTypes.node, - routes: PropTypes.array, - }; - getPath = (path: string, params: any) => { path = (path || '').replace(/^\//, ''); Object.keys(params).forEach(key => { diff --git a/components/breadcrumb/BreadcrumbItem.tsx b/components/breadcrumb/BreadcrumbItem.tsx index 6d54b0e54c..7bc07f7331 100644 --- a/components/breadcrumb/BreadcrumbItem.tsx +++ b/components/breadcrumb/BreadcrumbItem.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import { DownOutlined } from '@ant-design/icons'; import omit from 'omit.js'; @@ -21,12 +20,6 @@ export default class BreadcrumbItem extends React.Component { const { prefixCls: customizePrefixCls, separator, children, ...restProps } = this.props; const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls); diff --git a/components/button/button.tsx b/components/button/button.tsx index 74d9ce7b9e..f0760bb89e 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -1,9 +1,7 @@ /* eslint-disable react/button-has-type */ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import classNames from 'classnames'; import { LoadingOutlined } from '@ant-design/icons'; -import { polyfill } from 'react-lifecycles-compat'; import omit from 'omit.js'; import Group from './button-group'; @@ -124,19 +122,6 @@ class Button extends React.Component { htmlType: 'button', }; - static propTypes = { - type: PropTypes.string, - shape: PropTypes.oneOf(ButtonShapes), - size: PropTypes.oneOf(ButtonSizes), - htmlType: PropTypes.oneOf(ButtonHTMLTypes), - onClick: PropTypes.func, - loading: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), - className: PropTypes.string, - icon: PropTypes.node, - block: PropTypes.bool, - title: PropTypes.string, - }; - private delayTimeout: number; private buttonNode: HTMLElement | null; @@ -318,6 +303,4 @@ class Button extends React.Component { } } -polyfill(Button); - export default Button; diff --git a/components/carousel/index.tsx b/components/carousel/index.tsx index 24cfeae13d..3f695a0b4e 100644 --- a/components/carousel/index.tsx +++ b/components/carousel/index.tsx @@ -4,21 +4,6 @@ import { Settings } from 'react-slick'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import warning from '../_util/warning'; -// matchMedia polyfill for -// https://github.com/WickyNilliams/enquire.js/issues/82 -// TODO: Will be removed in antd 4.0 because we will no longer support ie9 -if (typeof window !== 'undefined') { - const matchMediaPolyfill = (mediaQuery: string) => { - return { - media: mediaQuery, - matches: false, - addListener() {}, - removeListener() {}, - }; - }; - // ref: https://github.com/ant-design/ant-design/issues/18774 - if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any; -} // Use require over import (will be lifted up) // make sure matchMedia polyfill run before require('react-slick') // Fix https://github.com/ant-design/ant-design/issues/6560 diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index e68c562705..f5adab0fb0 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -4,7 +4,6 @@ import arrayTreeFilter from 'array-tree-filter'; import classNames from 'classnames'; import omit from 'omit.js'; import KeyCode from 'rc-util/lib/KeyCode'; -import { polyfill } from 'react-lifecycles-compat'; import { CloseCircleFilled, DownOutlined, RightOutlined, RedoOutlined } from '@ant-design/icons'; import Input from '../input'; @@ -601,6 +600,4 @@ class Cascader extends React.Component { } } -polyfill(Cascader); - export default Cascader; diff --git a/components/checkbox/Checkbox.tsx b/components/checkbox/Checkbox.tsx index 39e9e44f48..f00a79c310 100644 --- a/components/checkbox/Checkbox.tsx +++ b/components/checkbox/Checkbox.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; -import { polyfill } from 'react-lifecycles-compat'; import classNames from 'classnames'; import RcCheckbox from 'rc-checkbox'; import shallowEqual from 'shallowequal'; @@ -174,6 +173,4 @@ class Checkbox extends React.Component { } } -polyfill(Checkbox); - export default Checkbox; diff --git a/components/checkbox/Group.tsx b/components/checkbox/Group.tsx index 88988cf084..99f9819fd5 100644 --- a/components/checkbox/Group.tsx +++ b/components/checkbox/Group.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; -import { polyfill } from 'react-lifecycles-compat'; import classNames from 'classnames'; import shallowEqual from 'shallowequal'; import omit from 'omit.js'; @@ -187,6 +186,4 @@ class CheckboxGroup extends React.Component
+ > + + + + +
@@ -18556,7 +18569,20 @@ exports[`ConfigProvider components Upload normal 1`] = ` >
+ > + + + + +
@@ -18668,7 +18694,20 @@ exports[`ConfigProvider components Upload prefixCls 1`] = ` >
+ > + + + + +
diff --git a/components/config-provider/__tests__/components.test.js b/components/config-provider/__tests__/components.test.js index 327a4ebc60..7123718635 100644 --- a/components/config-provider/__tests__/components.test.js +++ b/components/config-provider/__tests__/components.test.js @@ -54,7 +54,6 @@ import Tree from '../../tree'; import TreeSelect from '../../tree-select'; import Upload from '../../upload'; -jest.mock('draft-js/lib/generateRandomKey', () => () => '123'); jest.mock('rc-util/lib/Portal'); describe('ConfigProvider', () => { diff --git a/components/descriptions/__tests__/index.test.js b/components/descriptions/__tests__/index.test.js index d141e2596b..6e745708e9 100644 --- a/components/descriptions/__tests__/index.test.js +++ b/components/descriptions/__tests__/index.test.js @@ -5,29 +5,20 @@ import Descriptions from '..'; import mountTest from '../../../tests/shared/mountTest'; import { resetWarned } from '../../_util/warning'; -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', () => { mountTest(Descriptions); const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + jest.spyOn(window, 'matchMedia').mockImplementationOnce(query => ({ + addListener: (listener) => { + if (query === '(max-width: 575px)') { + listener({ matches: true }); + } + }, + removeListener: jest.fn(), + })); + afterEach(() => { MockDate.reset(); errorSpy.mockReset(); @@ -38,8 +29,6 @@ describe('Descriptions', () => { }); it('when max-width: 575px,column=1', () => { - // eslint-disable-next-line global-require - const enquire = require('enquire.js'); const wrapper = mount( Cloud Database @@ -51,14 +40,11 @@ describe('Descriptions', () => { ); expect(wrapper.find('tr')).toHaveLength(5); expect(wrapper.find('.ant-descriptions-item-no-label')).toHaveLength(1); - - 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 @@ -68,8 +54,6 @@ describe('Descriptions', () => { , ); expect(wrapper.find('tr')).toHaveLength(2); - - enquire.callunmatch(); wrapper.unmount(); }); diff --git a/components/drawer/index.tsx b/components/drawer/index.tsx index e16128e252..bbec5386f1 100644 --- a/components/drawer/index.tsx +++ b/components/drawer/index.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import RcDrawer from 'rc-drawer'; -import createReactContext from '@ant-design/create-react-context'; import { CloseOutlined } from '@ant-design/icons'; import classNames from 'classnames'; import omit from 'omit.js'; @@ -10,7 +9,7 @@ import { ConfigConsumerProps } from '../config-provider'; import { withConfigConsumer } from '../config-provider/context'; import { tuple } from '../_util/type'; -const DrawerContext = createReactContext(null); +const DrawerContext = React.createContext(null); type EventType = | React.KeyboardEvent diff --git a/components/form/__tests__/__snapshots__/demo.test.js.snap b/components/form/__tests__/__snapshots__/demo.test.js.snap index 19308f5926..fdfe0d494c 100644 --- a/components/form/__tests__/__snapshots__/demo.test.js.snap +++ b/components/form/__tests__/__snapshots__/demo.test.js.snap @@ -4038,7 +4038,48 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = ` >
+ > + + + + +
@@ -4073,7 +4114,58 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
+ > + + +
+

+ + + +

+

+ Click or drag file to this area to upload +

+

+ Support for a single or bulk upload. +

+
+
+
diff --git a/components/form/__tests__/index.test.js b/components/form/__tests__/index.test.js index 848cd54988..6a5cd3452e 100644 --- a/components/form/__tests__/index.test.js +++ b/components/form/__tests__/index.test.js @@ -1,12 +1,12 @@ import React from 'react'; import { mount } from 'enzyme'; -import scrollIntoView from 'dom-scroll-into-view'; +import scrollIntoView from 'scroll-into-view-if-needed'; import Form from '..'; import Input from '../../input'; import Button from '../../button'; import mountTest from '../../../tests/shared/mountTest'; -jest.mock('dom-scroll-into-view'); +jest.mock('scroll-into-view-if-needed'); const delay = () => new Promise(resolve => { diff --git a/components/form/util.ts b/components/form/util.ts index d2648249b1..70df36c5e8 100644 --- a/components/form/util.ts +++ b/components/form/util.ts @@ -1,6 +1,6 @@ import * as React from 'react'; import { useForm as useRcForm, FormInstance as RcFormInstance } from 'rc-field-form'; -import scrollIntoView from 'dom-scroll-into-view'; +import scrollIntoView from 'scroll-into-view-if-needed'; type InternalNamePath = (string | number)[]; @@ -70,26 +70,6 @@ export function getFieldId(namePath: InternalNamePath, formName?: string): strin return formName ? `${formName}_${mergedId}` : mergedId; } -// Source: https://github.com/react-component/form/blob/master/src/createDOMForm.js -function getScrollableContainer(current: HTMLElement) { - let node: HTMLElement | null = current; - let nodeName; - /* eslint no-cond-assign:0 */ - while (node && (nodeName = node.nodeName.toLowerCase()) !== 'body') { - const { overflowY } = getComputedStyle(node); - // https://stackoverflow.com/a/36900407/3040605 - if ( - node !== current && - (overflowY === 'auto' || overflowY === 'scroll') && - node.scrollHeight > node.clientHeight - ) { - return node; - } - node = node.parentElement; - } - return nodeName === 'body' ? node!.ownerDocument : node; -} - export interface FormInstance extends RcFormInstance { scrollToField: (name: string | number | InternalNamePath) => void; __INTERNAL__: { @@ -107,8 +87,9 @@ export function useForm(form?: FormInstance): [FormInstance] { const node: HTMLElement | null = fieldId ? document.getElementById(fieldId) : null; if (node) { - scrollIntoView(node, getScrollableContainer(node), { - onlyScrollIfNeeded: true, + scrollIntoView(node, { + scrollMode: 'if-needed', + block: 'nearest', }); } }, diff --git a/components/grid/RowContext.tsx b/components/grid/RowContext.tsx index ec246b1727..5b0e2dd2af 100644 --- a/components/grid/RowContext.tsx +++ b/components/grid/RowContext.tsx @@ -1,4 +1,4 @@ -import createContext, { Context } from '@ant-design/create-react-context'; +import { createContext, Context } from 'react'; export interface RowContextState { gutter?: [number, number]; diff --git a/components/grid/__tests__/index.test.js b/components/grid/__tests__/index.test.js index 79a3c3e7f9..fe64b37d29 100644 --- a/components/grid/__tests__/index.test.js +++ b/components/grid/__tests__/index.test.js @@ -3,23 +3,14 @@ import { render, mount } from 'enzyme'; import { Col, Row } from '..'; import mountTest from '../../../tests/shared/mountTest'; -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); - }, - }; -}); +jest.spyOn(window, 'matchMedia').mockImplementationOnce(query => ({ + addListener: (listener) => { + if (query === '(max-width: 575px)') { + listener({ matches: true }); + } + }, + removeListener: jest.fn(), +})); describe('Grid', () => { mountTest(Row); @@ -88,22 +79,11 @@ describe('Grid', () => { }); it('should work correct when gutter is object', () => { - // eslint-disable-next-line global-require - const enquire = require('enquire.js'); const wrapper = mount(); expect(wrapper.find('div').prop('style')).toEqual({ marginLeft: -10, marginRight: -10, }); - enquire.callunmatch(); - expect( - wrapper - .update() - .find('div') - .prop('style'), - ).toEqual({}); - wrapper.unmount(); - expect(enquire.unregister).toHaveBeenCalled(); }); it('should work currect when gutter is array', () => { diff --git a/components/input/ClearableLabeledInput.tsx b/components/input/ClearableLabeledInput.tsx index c36a9a29eb..dd57ec0151 100644 --- a/components/input/ClearableLabeledInput.tsx +++ b/components/input/ClearableLabeledInput.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import classNames from 'classnames'; import { CloseCircleFilled } from '@ant-design/icons'; import { tuple } from '../_util/type'; @@ -16,7 +15,7 @@ export function hasPrefixSuffix(props: InputProps | ClearableInputProps) { */ interface BasicProps { prefixCls: string; - inputType: (typeof ClearableInputType)[number]; + inputType: typeof ClearableInputType[number]; value?: any; defaultValue?: any; allowClear?: boolean; @@ -31,7 +30,7 @@ interface BasicProps { * This props only for input. */ interface ClearableInputProps extends BasicProps { - size?: (typeof InputSizes)[number]; + size?: typeof InputSizes[number]; suffix?: React.ReactNode; prefix?: React.ReactNode; addonBefore?: React.ReactNode; @@ -168,6 +167,4 @@ class ClearableLabeledInput extends React.Component { } } -polyfill(ClearableLabeledInput); - export default ClearableLabeledInput; diff --git a/components/input/Input.tsx b/components/input/Input.tsx index 7ba206f053..3d5d429dd2 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import classNames from 'classnames'; import omit from 'omit.js'; import Group from './Group'; @@ -16,7 +15,7 @@ export const InputSizes = tuple('small', 'default', 'large'); export interface InputProps extends Omit, 'size' | 'prefix'> { prefixCls?: string; - size?: (typeof InputSizes)[number]; + size?: typeof InputSizes[number]; onPressEnter?: React.KeyboardEventHandler; addonBefore?: React.ReactNode; addonAfter?: React.ReactNode; @@ -60,7 +59,7 @@ export function resolveOnChange( export function getInputClassName( prefixCls: string, - size?: (typeof InputSizes)[number], + size?: typeof InputSizes[number], disabled?: boolean, ) { return classNames(prefixCls, { @@ -87,28 +86,6 @@ class Input extends React.Component { type: 'text', }; - static propTypes = { - type: PropTypes.string, - id: PropTypes.string, - size: PropTypes.oneOf(InputSizes), - maxLength: PropTypes.number, - disabled: PropTypes.bool, - value: PropTypes.any, - defaultValue: PropTypes.any, - className: PropTypes.string, - addonBefore: PropTypes.node, - addonAfter: PropTypes.node, - prefixCls: PropTypes.string, - onPressEnter: PropTypes.func, - onKeyDown: PropTypes.func, - onKeyUp: PropTypes.func, - onFocus: PropTypes.func, - onBlur: PropTypes.func, - prefix: PropTypes.node, - suffix: PropTypes.node, - allowClear: PropTypes.bool, - }; - input: HTMLInputElement; clearableInput: ClearableLabeledInput; diff --git a/components/input/ResizableTextArea.tsx b/components/input/ResizableTextArea.tsx index adb45f1871..48905ecf5b 100644 --- a/components/input/ResizableTextArea.tsx +++ b/components/input/ResizableTextArea.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import ResizeObserver from 'rc-resize-observer'; import omit from 'omit.js'; import classNames from 'classnames'; @@ -115,6 +114,4 @@ class ResizableTextArea extends React.Component { } } -polyfill(ResizableTextArea); - export default ResizableTextArea; diff --git a/components/input/TextArea.tsx b/components/input/TextArea.tsx index 555c4296e3..d6634ead58 100644 --- a/components/input/TextArea.tsx +++ b/components/input/TextArea.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import ClearableLabeledInput from './ClearableLabeledInput'; import ResizableTextArea, { AutoSizeType } from './ResizableTextArea'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; @@ -123,6 +122,4 @@ class TextArea extends React.Component { } } -polyfill(TextArea); - export default TextArea; diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index fc4e456f6a..aeac75fed7 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -1,7 +1,4 @@ -import createContext, { Context } from '@ant-design/create-react-context'; - import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import classNames from 'classnames'; import omit from 'omit.js'; import { BarsOutlined, RightOutlined, LeftOutlined } from '@ant-design/icons'; @@ -10,22 +7,6 @@ import { LayoutContext, LayoutContextProps } from './layout'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import isNumeric from '../_util/isNumeric'; -// matchMedia polyfill for -// https://github.com/WickyNilliams/enquire.js/issues/82 -// TODO: Will be removed in antd 4.0 because we will no longer support ie9 -if (typeof window !== 'undefined') { - const matchMediaPolyfill = (mediaQuery: string) => { - return { - media: mediaQuery, - matches: false, - addListener() {}, - removeListener() {}, - }; - }; - // ref: https://github.com/ant-design/ant-design/issues/18774 - if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any; -} - const dimensionMaxMap = { xs: '479.98px', sm: '575.98px', @@ -40,7 +21,7 @@ export interface SiderContextProps { collapsedWidth?: string | number; } -export const SiderContext: Context = createContext({}); +export const SiderContext: React.Context = React.createContext({}); export type CollapseType = 'clickTrigger' | 'responsive'; @@ -272,8 +253,6 @@ class InternalSider extends React.Component { } } -polyfill(InternalSider); - // eslint-disable-next-line react/prefer-stateless-function export default class Sider extends React.Component { render() { diff --git a/components/layout/__tests__/index.test.js b/components/layout/__tests__/index.test.js index 458b8bf767..ec5fc98fdf 100644 --- a/components/layout/__tests__/index.test.js +++ b/components/layout/__tests__/index.test.js @@ -154,16 +154,6 @@ describe('Sider', () => { errorSpy.mockRestore(); }); - beforeAll(() => { - Object.defineProperty(window, 'matchMedia', { - value: jest.fn(() => ({ - matches: true, - addListener: () => {}, - removeListener: () => {}, - })), - }); - }); - it('should trigger onBreakpoint', async () => { const onBreakpoint = jest.fn(); diff --git a/components/layout/layout.tsx b/components/layout/layout.tsx index 4e8a7a324c..7ff3fae455 100644 --- a/components/layout/layout.tsx +++ b/components/layout/layout.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import classNames from 'classnames'; -import createContext from '@ant-design/create-react-context'; import { SiderProps } from './Sider'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; @@ -19,7 +18,7 @@ export interface LayoutContextProps { removeSider: (id: string) => void; }; } -export const LayoutContext = createContext({ +export const LayoutContext = React.createContext({ siderHook: { addSider: () => null, removeSider: () => null, diff --git a/components/locale-provider/index.tsx b/components/locale-provider/index.tsx index 3f34e425e3..e6adb2873e 100644 --- a/components/locale-provider/index.tsx +++ b/components/locale-provider/index.tsx @@ -36,10 +36,6 @@ function setMomentLocale(locale: Locale) { } export default class LocaleProvider extends React.Component { - static propTypes = { - locale: PropTypes.object, - }; - static defaultProps = { locale: {}, }; diff --git a/components/mentions/index.tsx b/components/mentions/index.tsx index 8121463fe7..aa6fcf9149 100644 --- a/components/mentions/index.tsx +++ b/components/mentions/index.tsx @@ -1,7 +1,6 @@ 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 Spin from '../spin'; @@ -172,6 +171,4 @@ class Mentions extends React.Component { } } -polyfill(Mentions); - export default Mentions; diff --git a/components/menu/MenuContext.tsx b/components/menu/MenuContext.tsx index 2870e011e2..3125d47ae1 100644 --- a/components/menu/MenuContext.tsx +++ b/components/menu/MenuContext.tsx @@ -1,4 +1,4 @@ -import createContext from '@ant-design/create-react-context'; +import { createContext } from 'react'; export type MenuTheme = 'light' | 'dark'; diff --git a/components/menu/__tests__/index.test.js b/components/menu/__tests__/index.test.js index 5cb410c584..85ffb8209c 100644 --- a/components/menu/__tests__/index.test.js +++ b/components/menu/__tests__/index.test.js @@ -6,13 +6,6 @@ import Layout from '../../layout'; import mountTest from '../../../tests/shared/mountTest'; import { resetWarned } from '../../_util/warning'; -jest.mock('mutationobserver-shim', () => { - global.MutationObserver = function MutationObserver() { - this.observe = () => {}; - this.disconnect = () => {}; - }; -}); - const { SubMenu } = Menu; describe('Menu', () => { diff --git a/components/menu/index.tsx b/components/menu/index.tsx index 02453a5914..31bcf57d4c 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import RcMenu, { Divider, ItemGroup } from 'rc-menu'; import classNames from 'classnames'; import omit from 'omit.js'; -import { polyfill } from 'react-lifecycles-compat'; import SubMenu from './SubMenu'; import Item from './MenuItem'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; @@ -334,8 +333,6 @@ class InternalMenu extends React.Component { } } -polyfill(InternalMenu); - // We should keep this as ref-able export default class Menu extends React.Component { static Divider = Divider; diff --git a/components/menu/style/index.less b/components/menu/style/index.less index 6ebbb75223..c8a05cdd7e 100644 --- a/components/menu/style/index.less +++ b/components/menu/style/index.less @@ -232,12 +232,8 @@ width: 6px; height: 1.5px; // background + background-image to makes before & after cross have same color. - // Since `linear-gradient` not work on IE9, we should hack it. // ref: https://github.com/ant-design/ant-design/issues/15910 - background: @menu-bg; - background: ~'@{menu-item-color} \9'; background-image: linear-gradient(to right, @menu-item-color, @menu-item-color); - background-image: ~'none \9'; border-radius: 2px; transition: background 0.3s @ease-in-out, transform 0.3s @ease-in-out, top 0.3s @ease-in-out; diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index c85767ce31..ba70a1563b 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import Dialog from 'rc-dialog'; -import * as PropTypes from 'prop-types'; import classNames from 'classnames'; import addEventListener from 'rc-util/lib/Dom/addEventListener'; import { CloseOutlined } from '@ant-design/icons'; @@ -151,22 +150,6 @@ export default class Modal extends React.Component { okType: 'primary' as ButtonType, }; - static propTypes = { - prefixCls: PropTypes.string, - onOk: PropTypes.func, - onCancel: PropTypes.func, - okText: PropTypes.node, - cancelText: PropTypes.node, - centered: PropTypes.bool, - width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - confirmLoading: PropTypes.bool, - visible: PropTypes.bool, - footer: PropTypes.node, - title: PropTypes.node, - closable: PropTypes.bool, - closeIcon: PropTypes.node, - }; - handleCancel = (e: React.MouseEvent) => { const { onCancel } = this.props; if (onCancel) { diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index cfe3ec4b63..e852655c6a 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import { ExclamationCircleFilled } from '@ant-design/icons'; import Tooltip, { AbstractTooltipProps } from '../tooltip'; @@ -166,6 +165,4 @@ class Popconfirm extends React.Component { } } -polyfill(Popconfirm); - export default Popconfirm; diff --git a/components/progress/progress.tsx b/components/progress/progress.tsx index b06fbb4d74..997a7b030c 100644 --- a/components/progress/progress.tsx +++ b/components/progress/progress.tsx @@ -1,4 +1,3 @@ -import * as PropTypes from 'prop-types'; import * as React from 'react'; import classNames from 'classnames'; import omit from 'omit.js'; @@ -56,20 +55,6 @@ export default class Progress extends React.Component { strokeLinecap: 'round', }; - static propTypes = { - status: PropTypes.oneOf(ProgressStatuses), - type: PropTypes.oneOf(ProgressTypes), - showInfo: PropTypes.bool, - percent: PropTypes.number, - width: PropTypes.number, - strokeWidth: PropTypes.number, - strokeLinecap: PropTypes.oneOf(['round', 'square']), - strokeColor: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), - trailColor: PropTypes.string, - format: PropTypes.func, - gapDegree: PropTypes.number, - }; - getPercentNumber() { const { successPercent, percent = 0 } = this.props; return parseInt( diff --git a/components/radio/group.tsx b/components/radio/group.tsx index b50e4a79aa..9cfa501142 100644 --- a/components/radio/group.tsx +++ b/components/radio/group.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; import classNames from 'classnames'; import shallowEqual from 'shallowequal'; -import { polyfill } from 'react-lifecycles-compat'; import Radio from './radio'; import { RadioGroupProps, @@ -161,5 +160,4 @@ class RadioGroup extends React.Component { } } -polyfill(RadioGroup); export default RadioGroup; diff --git a/components/rate/index.tsx b/components/rate/index.tsx index 8dcd5a14cd..4143cc8e50 100644 --- a/components/rate/index.tsx +++ b/components/rate/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import RcRate from 'rc-rate'; import omit from 'omit.js'; import { StarFilled } from '@ant-design/icons'; @@ -28,11 +27,6 @@ interface RateNodeProps { } export default class Rate extends React.Component { - static propTypes = { - prefixCls: PropTypes.string, - character: PropTypes.node, - }; - static defaultProps = { character: , }; diff --git a/components/spin/index.tsx b/components/spin/index.tsx index 3f07daea93..c29235e6d2 100644 --- a/components/spin/index.tsx +++ b/components/spin/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import classNames from 'classnames'; import omit from 'omit.js'; import debounce from 'lodash/debounce'; @@ -72,15 +71,6 @@ class Spin extends React.Component { wrapperClassName: '', }; - static propTypes = { - prefixCls: PropTypes.string, - className: PropTypes.string, - spinning: PropTypes.bool, - size: PropTypes.oneOf(SpinSizes), - wrapperClassName: PropTypes.string, - indicator: PropTypes.element, - }; - static setDefaultIndicator(indicator: React.ReactNode) { defaultIndicator = indicator; } diff --git a/components/statistic/Countdown.tsx b/components/statistic/Countdown.tsx index 4803ef74d6..45ffdd1d54 100644 --- a/components/statistic/Countdown.tsx +++ b/components/statistic/Countdown.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import * as moment from 'moment'; import interopDefault from '../_util/interopDefault'; import Statistic, { StatisticProps } from './Statistic'; @@ -86,6 +85,4 @@ class Countdown extends React.Component { } } -polyfill(Countdown); - export default Countdown; diff --git a/components/steps/index.tsx b/components/steps/index.tsx index b00cf6292b..b89460238e 100644 --- a/components/steps/index.tsx +++ b/components/steps/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import RcSteps from 'rc-steps'; import { CheckOutlined, CloseOutlined } from '@ant-design/icons'; @@ -40,12 +39,6 @@ export default class Steps extends React.Component { current: 0, }; - static propTypes = { - prefixCls: PropTypes.string, - iconPrefix: PropTypes.string, - current: PropTypes.number, - }; - renderSteps = ({ getPrefixCls }: ConfigConsumerProps) => { const prefixCls = getPrefixCls('steps', this.props.prefixCls); const iconPrefix = getPrefixCls('', this.props.iconPrefix); diff --git a/components/style/core/motion.less b/components/style/core/motion.less index 4eaf988322..74c3103964 100644 --- a/components/style/core/motion.less +++ b/components/style/core/motion.less @@ -3,7 +3,6 @@ @import 'motion/move'; @import 'motion/other'; @import 'motion/slide'; -@import 'motion/swing'; @import 'motion/zoom'; // For common/openAnimation diff --git a/components/style/core/motion/swing.less b/components/style/core/motion/swing.less deleted file mode 100644 index 138a942d47..0000000000 --- a/components/style/core/motion/swing.less +++ /dev/null @@ -1,34 +0,0 @@ -.swing-motion(@className, @keyframeName) { - .@{className}-enter, - .@{className}-appear { - .motion-common(); - - animation-play-state: paused; - } - .@{className}-enter.@{className}-enter-active, - .@{className}-appear.@{className}-appear-active { - animation-name: ~'@{keyframeName}In'; - animation-play-state: running; - } -} - -.swing-motion(swing, antSwing); - -@keyframes antSwingIn { - 0%, - 100% { - transform: translateX(0); - } - 20% { - transform: translateX(-10px); - } - 40% { - transform: translateX(10px); - } - 60% { - transform: translateX(-5px); - } - 80% { - transform: translateX(5px); - } -} diff --git a/components/style/mixins/compatibility.less b/components/style/mixins/compatibility.less index 8be87515a7..33812652db 100644 --- a/components/style/mixins/compatibility.less +++ b/components/style/mixins/compatibility.less @@ -3,16 +3,7 @@ // Placeholder text .placeholder(@color: @input-placeholder-color) { // Firefox - &::-moz-placeholder { - color: @color; - opacity: 1; // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526 - } - // Internet Explorer 10+ - &:-ms-input-placeholder { - color: @color; - } - // Safari and Chrome - &::-webkit-input-placeholder { + &::placeholder { color: @color; } diff --git a/components/style/mixins/iconfont.less b/components/style/mixins/iconfont.less index 13438599e8..413591b371 100644 --- a/components/style/mixins/iconfont.less +++ b/components/style/mixins/iconfont.less @@ -28,16 +28,9 @@ } // for iconfont font size -// fix chrome 12px bug, support ie +// fix chrome 12px bug .iconfont-size-under-12px(@size, @rotate: 0deg) { display: inline-block; @font-scale: unit(@size / 12px); - font-size: 12px; - // IE9 - font-size: ~'@{size} \9'; - transform: scale(@font-scale) rotate(@rotate); - :root & { - font-size: @font-size-sm; // reset IE9 and above - } } diff --git a/components/switch/index.tsx b/components/switch/index.tsx index 060af6836e..7db2faf3f1 100755 --- a/components/switch/index.tsx +++ b/components/switch/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import RcSwitch from 'rc-switch'; import classNames from 'classnames'; import omit from 'omit.js'; @@ -33,16 +32,6 @@ export interface SwitchProps { export default class Switch extends React.Component { static __ANT_SWITCH = true; - static propTypes = { - prefixCls: PropTypes.string, - // HACK: https://github.com/ant-design/ant-design/issues/5368 - // size=default and size=large are the same - size: PropTypes.oneOf(['small', 'default', 'large']) as PropTypes.Requireable< - SwitchProps['size'] - >, - className: PropTypes.string, - }; - private rcSwitch: typeof RcSwitch; constructor(props: SwitchProps) { diff --git a/components/tag/index.tsx b/components/tag/index.tsx index 2dff9e4d70..d76f3695a7 100644 --- a/components/tag/index.tsx +++ b/components/tag/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import classNames from 'classnames'; import omit from 'omit.js'; -import { polyfill } from 'react-lifecycles-compat'; import { CloseOutlined } from '@ant-design/icons'; import CheckableTag from './CheckableTag'; @@ -133,6 +132,4 @@ class Tag extends React.Component { } } -polyfill(Tag); - export default Tag; diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index 54642460ba..c557a42095 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import RcTooltip from 'rc-tooltip'; import classNames from 'classnames'; import { AlignType, ActionType, BuildInPlacements } from 'rc-trigger/lib/interface'; @@ -280,6 +279,4 @@ class Tooltip extends React.Component { } } -polyfill(Tooltip); - export default Tooltip; diff --git a/components/transfer/ListItem.tsx b/components/transfer/ListItem.tsx index 4f446e182d..6f0f65dd8a 100644 --- a/components/transfer/ListItem.tsx +++ b/components/transfer/ListItem.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import classNames from 'classnames'; import PureRenderMixin from 'rc-util/lib/PureRenderMixin'; -import Lazyload from 'react-lazy-load'; import Checkbox from '../checkbox'; export default class ListItem extends React.Component { @@ -10,16 +9,7 @@ export default class ListItem extends React.Component { } render() { - const { - renderedText, - renderedEl, - item, - lazy, - checked, - disabled, - prefixCls, - onClick, - } = this.props; + const { renderedText, renderedEl, item, checked, disabled, prefixCls, onClick } = this.props; const className = classNames({ [`${prefixCls}-content-item`]: true, @@ -42,20 +32,7 @@ export default class ListItem extends React.Component { {renderedEl} ); - let children: JSX.Element | null = null; - if (lazy) { - const lazyProps = { - height: 32, - offset: 500, - throttle: 0, - debounce: false, - ...lazy, - }; - children = {listItem}; - } else { - children = listItem; - } - return children; + return listItem; } } diff --git a/components/transfer/__tests__/__snapshots__/demo.test.js.snap b/components/transfer/__tests__/__snapshots__/demo.test.js.snap index be96485a5c..233226f331 100644 --- a/components/transfer/__tests__/__snapshots__/demo.test.js.snap +++ b/components/transfer/__tests__/__snapshots__/demo.test.js.snap @@ -388,62 +388,363 @@ exports[`renders ./components/transfer/demo/basic.md correctly 1`] = `
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +
  • + + + content1 + +
  • +
  • + + + content2 + +
  • +
  • + + + content4 + +
  • +
  • + + + content5 + +
  • +
  • + + + content7 + +
  • +
  • + + + content8 + +
  • +
  • + + + content10 + +
  • +
  • + + + content11 + +
  • +
  • + + + content13 + +
  • +
  • + + + content14 + +
  • +
  • + + + content16 + +
  • +
  • + + + content17 + +
  • +
  • + + + content19 + +
  • +
  • + + + content20 + +
@@ -543,30 +844,156 @@ exports[`renders ./components/transfer/demo/basic.md correctly 1`] = `
    -
    -
    -
    -
    -
    -
    +
  • + + + content3 + +
  • +
  • + + + content6 + +
  • +
  • + + + content9 + +
  • +
  • + + + content12 + +
  • +
  • + + + content15 + +
  • +
  • + + + content18 + +
diff --git a/components/transfer/__tests__/__snapshots__/index.test.js.snap b/components/transfer/__tests__/__snapshots__/index.test.js.snap index a70e961056..91ad89c896 100644 --- a/components/transfer/__tests__/__snapshots__/index.test.js.snap +++ b/components/transfer/__tests__/__snapshots__/index.test.js.snap @@ -480,7 +480,6 @@ exports[`Transfer should support render value and label in item 1`] = ` handleFilter={[Function]} itemUnit="item" itemsUnit="items" - lazy={Object {}} notFoundContent={ [Function] @@ -593,7 +592,6 @@ exports[`Transfer should support render value and label in item 1`] = ` } itemUnit="item" itemsUnit="items" - lazy={Object {}} notFoundContent={ [Function] @@ -615,78 +613,74 @@ exports[`Transfer should support render value and label in item 1`] = ` ] } > - -
    - - - -
    - - - -
-
+ + + + + + + + + + label + + + +
@@ -899,7 +893,6 @@ exports[`Transfer should support render value and label in item 1`] = ` handleFilter={[Function]} itemUnit="item" itemsUnit="items" - lazy={Object {}} notFoundContent={ [Function] diff --git a/components/transfer/__tests__/index.test.js b/components/transfer/__tests__/index.test.js index f106c1d4ef..9f1ae3a67a 100644 --- a/components/transfer/__tests__/index.test.js +++ b/components/transfer/__tests__/index.test.js @@ -30,7 +30,6 @@ const listCommonProps = { ], selectedKeys: ['a'], targetKeys: ['b'], - lazy: false, }; const listDisabledProps = { @@ -47,7 +46,6 @@ const listDisabledProps = { ], selectedKeys: ['a', 'b'], targetKeys: [], - lazy: false, }; const searchTransferProps = { @@ -91,7 +89,6 @@ const searchTransferProps = { ], selectedKeys: [], targetKeys: ['3', '4'], - lazy: false, }; describe('Transfer', () => { diff --git a/components/transfer/__tests__/list.test.js b/components/transfer/__tests__/list.test.js index 9f707487ac..c2c115e5da 100644 --- a/components/transfer/__tests__/list.test.js +++ b/components/transfer/__tests__/list.test.js @@ -22,23 +22,12 @@ const listCommonProps = { ], checkedKeys: ['a'], notFoundContent: 'Not Found', - lazy: false, }; describe('Transfer.List', () => { - beforeAll(() => { - jest.useFakeTimers(); - }); - - afterAll(() => { - jest.useRealTimers(); - }); - it('should render correctly', () => { const wrapper = mount(); - jest.runAllTimers(); wrapper.update(); - expect(wrapper.find('ListBody').state().mounted).toBeTruthy(); expect(wrapper.render()).toMatchSnapshot(); }); diff --git a/components/transfer/__tests__/search.test.js b/components/transfer/__tests__/search.test.js index 8eb484d752..f279b1c8fd 100644 --- a/components/transfer/__tests__/search.test.js +++ b/components/transfer/__tests__/search.test.js @@ -60,7 +60,6 @@ describe('Transfer.Search', () => { .find('.ant-input') .at(0) .simulate('change', { target: { value: 'a' } }); - jest.runAllTimers(); expect(onSearch).toHaveBeenCalledWith('left', 'a'); onSearch.mockReset(); @@ -84,7 +83,6 @@ describe('Transfer.Search', () => { .find('.ant-input') .at(0) .simulate('change', { target: { value: 'a' } }); - jest.runAllTimers(); expect(errorSpy.mock.calls.length).toBe(0); expect(onSearchChange).not.toHaveBeenCalled(); diff --git a/components/transfer/index.en-US.md b/components/transfer/index.en-US.md index f6e701c79e..fe18d14cda 100644 --- a/components/transfer/index.en-US.md +++ b/components/transfer/index.en-US.md @@ -25,7 +25,6 @@ One or more elements can be selected from either column, one click on the proper | disabled | Whether disabled transfer | boolean | false | | | filterOption | A function to determine whether an item should show in search result list | (inputValue, option): boolean | | | | footer | A function used for rendering the footer. | (props) => ReactNode | | | -| lazy | property of [react-lazy-load](https://github.com/loktar00/react-lazy-load) for lazy rendering items. Turn off it by set to `false`. | object\|boolean | `{ height: 32, offset: 32 }` | | | listStyle | A custom CSS style used for rendering the transfer columns. | object\|({direction: 'left'\|'right'}) => object | | | | locale | i18n text including filter, empty text, item unit, etc | { itemUnit: string; itemsUnit: string; searchPlaceholder: string; notFoundContent: ReactNode; } | `{ itemUnit: 'item', itemsUnit: 'items', notFoundContent: 'The list is empty', searchPlaceholder: 'Search here' }` | | | operations | A set of operations that are sorted from top to bottom. | string\[] | \['>', '<'] | | diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 319d1d96d5..427f035351 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -1,7 +1,5 @@ import * as React from 'react'; -import * as PropTypes from 'prop-types'; import classNames from 'classnames'; -import { polyfill } from 'react-lifecycles-compat'; import List, { TransferListProps } from './list'; import Operation from './operation'; import Search from './search'; @@ -58,8 +56,7 @@ export interface TransferProps { footer?: (props: TransferListProps) => React.ReactNode; rowKey?: (record: TransferItem) => string; onSearch?: (direction: TransferDirection, value: string) => void; - lazy?: {} | boolean; - onScroll?: (direction: TransferDirection, e: React.SyntheticEvent) => void; + onScroll?: (direction: TransferDirection, e: React.SyntheticEvent) => void; children?: (props: TransferListBodyProps) => React.ReactNode; showSelectAll?: boolean; } @@ -87,28 +84,6 @@ class Transfer extends React.Component { listStyle: () => {}, }; - static propTypes = { - prefixCls: PropTypes.string, - disabled: PropTypes.bool, - dataSource: PropTypes.array as PropTypes.Validator, - render: PropTypes.func, - targetKeys: PropTypes.array, - onChange: PropTypes.func, - height: PropTypes.number, - style: PropTypes.object, - listStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), - operationStyle: PropTypes.object, - className: PropTypes.string, - titles: PropTypes.array, - operations: PropTypes.array, - showSearch: PropTypes.bool, - filterOption: PropTypes.func, - locale: PropTypes.object, - footer: PropTypes.func, - rowKey: PropTypes.func, - lazy: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]), - }; - static getDerivedStateFromProps(nextProps: TransferProps) { if (nextProps.selectedKeys) { const targetKeys = nextProps.targetKeys || []; @@ -259,16 +234,16 @@ class Transfer extends React.Component { onRightItemSelect = (selectedKey: string, checked: boolean) => this.onItemSelect('right', selectedKey, checked); - handleScroll = (direction: TransferDirection, e: React.SyntheticEvent) => { + handleScroll = (direction: TransferDirection, e: React.SyntheticEvent) => { const { onScroll } = this.props; if (onScroll) { onScroll(direction, e); } }; - handleLeftScroll = (e: React.SyntheticEvent) => this.handleScroll('left', e); + handleLeftScroll = (e: React.SyntheticEvent) => this.handleScroll('left', e); - handleRightScroll = (e: React.SyntheticEvent) => this.handleScroll('right', e); + handleRightScroll = (e: React.SyntheticEvent) => this.handleScroll('right', e); handleSelectChange(direction: TransferDirection, holder: string[]) { const { sourceSelectedKeys, targetSelectedKeys } = this.state; @@ -335,7 +310,6 @@ class Transfer extends React.Component { operationStyle, filterOption, render, - lazy, children, showSelectAll, } = this.props; @@ -374,7 +348,6 @@ class Transfer extends React.Component { showSearch={showSearch} renderList={children} footer={footer} - lazy={lazy} onScroll={this.handleLeftScroll} disabled={disabled} direction="left" @@ -407,7 +380,6 @@ class Transfer extends React.Component { showSearch={showSearch} renderList={children} footer={footer} - lazy={lazy} onScroll={this.handleRightScroll} disabled={disabled} direction="right" @@ -429,6 +401,4 @@ class Transfer extends React.Component { } } -polyfill(Transfer); - export default Transfer; diff --git a/components/transfer/index.zh-CN.md b/components/transfer/index.zh-CN.md index 91e07b2ab9..1cc0772afe 100644 --- a/components/transfer/index.zh-CN.md +++ b/components/transfer/index.zh-CN.md @@ -28,7 +28,6 @@ title: Transfer | disabled | 是否禁用 | boolean | false | | | filterOption | 接收 `inputValue` `option` 两个参数,当 `option` 符合筛选条件时,应返回 `true`,反之则返回 `false`。 | | (inputValue, option): boolean | | | | footer | 底部渲染函数 | (props) => ReactNode | | | -| lazy | Transfer 使用了 [react-lazy-load](https://github.com/loktar00/react-lazy-load) 优化性能,这里可以设置相关参数。设为 `false` 可以关闭懒加载。 | object\|boolean | `{ height: 32, offset: 32 }` | | | listStyle | 两个穿梭框的自定义样式 | object\|({direction: 'left'\|'right'}) => object | | | | locale | 各种语言 | { itemUnit: string; itemsUnit: string; searchPlaceholder: string; notFoundContent: ReactNode; } | `{ itemUnit: '项', itemsUnit: '项', searchPlaceholder: '请输入搜索内容' }` | | | operations | 操作文案集合,顺序从上至下 | string\[] | \['>', '<'] | | diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index ab5f05e237..b9707c8e82 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as ReactDOM from 'react-dom'; import omit from 'omit.js'; import classNames from 'classnames'; import PureRenderMixin from 'rc-util/lib/PureRenderMixin'; @@ -7,7 +6,6 @@ import Checkbox from '../checkbox'; import { TransferItem, TransferDirection, RenderResult, RenderResultObject } from './index'; import Search from './search'; import defaultRenderList, { TransferListBodyProps, OmitProps } from './renderListBody'; -import triggerEvent from '../_util/triggerEvent'; const defaultRender = () => null; @@ -46,8 +44,7 @@ export interface TransferListProps { itemsUnit: string; renderList?: RenderListFunction; footer?: (props: TransferListProps) => React.ReactNode; - lazy?: boolean | {}; - onScroll: Function; + onScroll: (e: React.UIEvent) => void; disabled?: boolean; direction: TransferDirection; showSelectAll?: boolean; @@ -75,7 +72,6 @@ export default class TransferList extends React.Component { - const transferNode = ReactDOM.findDOMNode(this) as Element; - const listNode = transferNode.querySelectorAll('.ant-transfer-list-content')[0]; - if (listNode) { - triggerEvent(listNode, 'scroll'); - } - }, 0); }; handleClear = () => { diff --git a/components/transfer/renderListBody.tsx b/components/transfer/renderListBody.tsx index 983cb07ce1..792f4ec933 100644 --- a/components/transfer/renderListBody.tsx +++ b/components/transfer/renderListBody.tsx @@ -1,14 +1,11 @@ import * as React from 'react'; -import { findDOMNode } from 'react-dom'; -import Animate from 'rc-animate'; -import raf from '../_util/raf'; import { Omit, tuple } from '../_util/type'; import { TransferItem } from '.'; import { TransferListProps, RenderedItem } from './list'; import ListItem from './ListItem'; export const OmitProps = tuple('handleFilter', 'handleClear', 'checkedKeys'); -export type OmitProp = (typeof OmitProps)[number]; +export type OmitProp = typeof OmitProps[number]; type PartialTransferListProps = Omit; export interface TransferListBodyProps extends PartialTransferListProps { @@ -18,41 +15,6 @@ export interface TransferListBodyProps extends PartialTransferListProps { } class ListBody extends React.Component { - state = { - mounted: false, - }; - - private mountId: number; - - private lazyId: number; - - componentDidMount() { - this.mountId = raf(() => { - this.setState({ mounted: true }); - }); - } - - componentDidUpdate(prevProps: TransferListBodyProps) { - const { filteredRenderItems, lazy } = this.props; - if (prevProps.filteredRenderItems.length !== filteredRenderItems.length && lazy !== false) { - // TODO: Replace this with ref when react 15 support removed. - const container = findDOMNode(this); - - raf.cancel(this.lazyId); - this.lazyId = raf(() => { - if (container) { - const scrollEvent = new Event('scroll', { bubbles: true }); - container.dispatchEvent(scrollEvent); - } - }); - } - } - - componentWillUnmount() { - raf.cancel(this.mountId); - raf.cancel(this.lazyId); - } - onItemSelect = (item: TransferItem) => { const { onItemSelect, selectedKeys } = this.props; const checked = selectedKeys.indexOf(item.key) >= 0; @@ -60,24 +22,16 @@ class ListBody extends React.Component { }; render() { - const { mounted } = this.state; const { prefixCls, onScroll, filteredRenderItems, - lazy, selectedKeys, disabled: globalDisabled, } = this.props; return ( - +
    {filteredRenderItems.map(({ renderedEl, renderedText, item }: RenderedItem) => { const { disabled } = item; const checked = selectedKeys.indexOf(item.key) >= 0; @@ -87,7 +41,6 @@ class ListBody extends React.Component { disabled={globalDisabled || disabled} key={item.key} item={item} - lazy={lazy} renderedText={renderedText} renderedEl={renderedEl} checked={checked} @@ -96,7 +49,7 @@ class ListBody extends React.Component { /> ); })} - +
); } } diff --git a/components/tree/DirectoryTree.tsx b/components/tree/DirectoryTree.tsx index 65e7bd871f..8bae1446da 100644 --- a/components/tree/DirectoryTree.tsx +++ b/components/tree/DirectoryTree.tsx @@ -4,7 +4,6 @@ import omit from 'omit.js'; import debounce from 'lodash/debounce'; import { conductExpandParent } from 'rc-tree/lib/util'; import { convertDataToEntities, convertTreeToData } from 'rc-tree/lib/utils/treeUtil'; -import { polyfill } from 'react-lifecycles-compat'; import { FileOutlined, FolderOpenOutlined, FolderOutlined } from '@ant-design/icons'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; @@ -243,6 +242,4 @@ class DirectoryTree extends React.Component({ prefixCls: 'typography', })(Base); diff --git a/components/typography/Editable.tsx b/components/typography/Editable.tsx index 5c1825008d..441c895b0a 100644 --- a/components/typography/Editable.tsx +++ b/components/typography/Editable.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import KeyCode from 'rc-util/lib/KeyCode'; -import { polyfill } from 'react-lifecycles-compat'; import { EnterOutlined } from '@ant-design/icons'; import TextArea from '../input/TextArea'; @@ -134,6 +133,4 @@ class Editable extends React.Component { } } -polyfill(Editable); - export default Editable; diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index 2ae3b48e5b..7bc2d094df 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; import RcUpload from 'rc-upload'; import classNames from 'classnames'; import uniqBy from 'lodash/uniqBy'; @@ -377,6 +376,4 @@ class Upload extends React.Component { } } -polyfill(Upload); - export default Upload; diff --git a/components/upload/__tests__/__snapshots__/demo.test.js.snap b/components/upload/__tests__/__snapshots__/demo.test.js.snap index 23434ccaf9..66bc5812a9 100644 --- a/components/upload/__tests__/__snapshots__/demo.test.js.snap +++ b/components/upload/__tests__/__snapshots__/demo.test.js.snap @@ -6,7 +6,50 @@ exports[`renders ./components/upload/demo/avatar.md correctly 1`] = ` >
+ > + + +
+ + + +
+ Upload +
+
+
+
`; @@ -16,7 +59,47 @@ exports[`renders ./components/upload/demo/basic.md correctly 1`] = ` >
+ > + + + + +
@@ -29,7 +112,47 @@ exports[`renders ./components/upload/demo/defaultFileList.md correctly 1`] = ` >
+ > + + + + +
@@ -318,7 +441,49 @@ exports[`renders ./components/upload/demo/directory.md correctly 1`] = ` >
+ > + + + + +
@@ -329,7 +494,58 @@ exports[`renders ./components/upload/demo/drag.md correctly 1`] = `
+ > + + +
+

+ + + +

+

+ Click or drag file to this area to upload +

+

+ Support for a single or bulk upload. Strictly prohibit from uploading company data or other band files +

+
+
+
@@ -342,7 +558,48 @@ exports[`renders ./components/upload/demo/fileList.md correctly 1`] = ` >
+ > + + + + +
@@ -1022,7 +1279,50 @@ exports[`renders ./components/upload/demo/picture-card.md correctly 1`] = `
+ > + + +
+ + + +
+ Upload +
+
+
+
`; @@ -1034,7 +1334,47 @@ exports[`renders ./components/upload/demo/picture-style.md correctly 1`] = ` >
+ > + + + + +
@@ -1227,7 +1567,47 @@ exports[`renders ./components/upload/demo/picture-style.md correctly 1`] = ` >
+ > + + + + +
@@ -1423,7 +1803,47 @@ exports[`renders ./components/upload/demo/preview-file.md correctly 1`] = ` >
+ > + + + + +
@@ -1438,7 +1858,47 @@ exports[`renders ./components/upload/demo/transform-file.md correctly 1`] = ` >
+ > + + + + +
@@ -1453,7 +1913,47 @@ exports[`renders ./components/upload/demo/upload-manually.md correctly 1`] = ` >
+ > + + + + +
@@ -1500,7 +2000,47 @@ exports[`renders ./components/upload/demo/upload-with-aliyun-oss.md correctly 1` >
+ > + + + + +
diff --git a/docs/react/getting-started.en-US.md b/docs/react/getting-started.en-US.md index 0c1878f2cf..bc1a4d1139 100755 --- a/docs/react/getting-started.en-US.md +++ b/docs/react/getting-started.en-US.md @@ -94,23 +94,19 @@ In the real world you will need a development workflow consisting of `compile/bu ## Compatibility -Ant Design React supports all modern browsers and IE9+. +Ant Design React supports all modern browsers and IE11+. | [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Opera](http://godban.github.io/browsers-support-badges/)
Opera | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | | --- | --- | --- | --- | --- | --- | -| IE9, IE10, IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | - -We offer very limited support for IE9/10 which means some styles and animations will be mininal for them. Also, we use Flex layout in a few components. - -> Note: Different than Ant Design, Ant Design Pro supports IE11+. +| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | Polyfills are needed for IE browsers. We recommend [babel-preset-env](https://babeljs.io/docs/en/babel-preset-env) for it. You can set `targets` config if you are using [umi](http://umijs.org/). Ant Design 3.0 supports both React 15 and 16 but we strongly suggest React 16 for better performance and fewer bugs. -#### IE8 note +#### IE note -> We don't support IE8 after `antd@2.0`. +> We drop support of IE8 after `antd@2.0`, IE9/10 after `antd@4.0`, ## Customized Work Flow diff --git a/docs/react/getting-started.zh-CN.md b/docs/react/getting-started.zh-CN.md index f65a3cd296..745774f976 100755 --- a/docs/react/getting-started.zh-CN.md +++ b/docs/react/getting-started.zh-CN.md @@ -101,23 +101,19 @@ ReactDOM.render(, document.getElementById('root')); ## 兼容性 -Ant Design React 支持所有的现代浏览器和 IE9+。 +Ant Design React 支持所有的现代浏览器和 IE11+。 | [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Opera](http://godban.github.io/browsers-support-badges/)
Opera | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | | --- | --- | --- | --- | --- | --- | -| IE9, IE10, IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | - -我们对 IE9/10 提供有限度的支持,部分样式和动画在 IE9/10 下的表现会比较裸。少数组件使用到了 Flex 布局,在 IE9/10 下也会有问题。 - -> 注意,不同于 Ant Design,Ant Design Pro 是只支持到 IE11+ 的。 +| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | 对于 IE 系列浏览器,需要提供相应的 Polyfill 支持,建议使用 [babel-preset-env](https://babeljs.io/docs/en/babel-preset-env) 来解决浏览器兼容问题。如果你在使用 [umi](http://umijs.org/),可以直接使用 [targets](https://umijs.org/zh/config/#targets) 配置。 Ant Design 3.0 对 React 15/16 两个版本提供支持,但是我们强烈建议你升级到 React 16,以便获得更好的性能和遇到更少的问题。 -#### IE8 note +#### IE note -> `antd@2.0` 之后将不再支持 IE8。 +> `antd@2.0` 之后将不再支持 IE8,`antd@4.0` 之后将不再支持 IE9/10。 ## 自行构建 diff --git a/docs/react/introduce.en-US.md b/docs/react/introduce.en-US.md index 80f9458277..606472b593 100644 --- a/docs/react/introduce.en-US.md +++ b/docs/react/introduce.en-US.md @@ -34,7 +34,7 @@ Following the Ant Design specification, we developed a React UI library `antd` t ## Environment Support -- Modern browsers and Internet Explorer 9+ (with [polyfills](https://ant.design/docs/react/getting-started#Compatibility)) +- Modern browsers and Internet Explorer 11+ (with [polyfills](https://ant.design/docs/react/getting-started#Compatibility)) - Server-side Rendering - [Electron](http://electron.atom.io/) diff --git a/docs/react/introduce.zh-CN.md b/docs/react/introduce.zh-CN.md index 7318e7a6a0..e39ea4cca7 100644 --- a/docs/react/introduce.zh-CN.md +++ b/docs/react/introduce.zh-CN.md @@ -34,7 +34,7 @@ title: Ant Design of React ## 支持环境 -- 现代浏览器和 IE9 及以上(需要 [polyfills](https://ant.design/docs/react/getting-started-cn#兼容性))。 +- 现代浏览器和 IE11 及以上(需要 [polyfills](https://ant.design/docs/react/getting-started-cn#兼容性))。 - 支持服务端渲染。 - [Electron](https://electronjs.org/) diff --git a/package.json b/package.json index 11a1a2381d..92764db373 100644 --- a/package.json +++ b/package.json @@ -86,21 +86,15 @@ "last 2 version", "Firefox ESR", "> 1%", - "ie >= 9" + "ie >= 11" ], "dependencies": { - "@ant-design/create-react-context": "^0.2.4", "@ant-design/icons": "^4.0.0-alpha.11", - "@ant-design/icons-svg": "^4.0.0-alpha.0", "@types/react-slick": "^0.23.4", "array-tree-filter": "^2.1.0", - "babel-runtime": "6.x", "classnames": "~2.2.6", "copy-to-clipboard": "^3.2.0", "css-animation": "^1.5.0", - "dom-closest": "^0.2.0", - "dom-scroll-into-view": "^1.2.1", - "enquire.js": "^2.1.6", "lodash": "^4.17.13", "moment": "^2.24.0", "omit.js": "^1.0.2", @@ -115,8 +109,8 @@ "rc-dropdown": "~3.0.0-alpha.0", "rc-field-form": "^0.0.0-alpha.17", "rc-input-number": "~4.5.0", - "rc-mentions": "~1.0.0-alpha.0", - "rc-menu": "~8.0.0-alpha.4", + "rc-mentions": "~1.0.0-alpha.3", + "rc-menu": "~8.0.0-alpha.7", "rc-notification": "~3.3.1", "rc-pagination": "~1.20.11", "rc-picker": "^0.0.1-alpha.58", @@ -124,27 +118,27 @@ "rc-rate": "~2.5.0", "rc-resize-observer": "^0.1.0", "rc-select": "~10.0.0-alpha.34", - "rc-slider": "~8.7.1", + "rc-slider": "~9.0.0-alpha.0", "rc-steps": "~3.5.0", "rc-switch": "~1.9.0", "rc-table": "~7.0.0-alpha.20", - "rc-tabs": "~9.7.0", + "rc-tabs": "~10.0.0-alpha.0", "rc-time-picker": "~4.0.0-alpha.2", "rc-tooltip": "~4.0.0-alpha.3", "rc-tree": "~3.0.0-alpha.37", "rc-tree-select": "~3.0.0-alpha.5", "rc-trigger": "~4.0.0-alpha.7", - "rc-upload": "~2.9.1", + "rc-upload": "~3.0.0-alpha.0", "rc-util": "~4.16.1", "rc-virtual-list": "^0.0.0-alpha.25", - "react-lazy-load": "^3.0.13", - "react-lifecycles-compat": "^3.0.4", "react-slick": "~0.25.2", "resize-observer-polyfill": "^1.5.1", + "scroll-into-view-if-needed": "^2.2.20", "shallowequal": "^1.1.0", "warning": "~4.0.3" }, "devDependencies": { + "@ant-design/bisheng-plugin": "^2.0.1", "@ant-design/colors": "^3.2.2", "@ant-design/tools": "^8.0.4", "@packtracker/webpack-plugin": "^2.0.1", @@ -166,7 +160,6 @@ "babel-eslint": "^10.0.1", "babel-plugin-add-react-displayname": "^0.0.5", "bisheng": "~1.3.3", - "bisheng-plugin-antd": "^1.3.1", "bisheng-plugin-description": "^0.1.4", "bisheng-plugin-react": "^1.1.0", "bisheng-plugin-toc": "^0.4.4", @@ -216,7 +209,6 @@ "rc-footer": "^0.6.0", "rc-queue-anim": "^1.6.12", "rc-scroll-anim": "^2.5.8", - "rc-trigger": "^4.0.0-alpha.5", "rc-tween-one": "^2.4.1", "react": "^16.9.0", "react-color": "^2.17.3", @@ -261,11 +253,11 @@ "bundlesize": [ { "path": "./dist/antd.min.js", - "maxSize": "540 kB" + "maxSize": "300 kB" }, { "path": "./dist/antd.min.css", - "maxSize": "60 kB" + "maxSize": "55 kB" } ], "title": "Ant Design" diff --git a/site/theme/index.js b/site/theme/index.js index d3c75fd8a4..e43b1dc8b2 100644 --- a/site/theme/index.js +++ b/site/theme/index.js @@ -48,7 +48,7 @@ module.exports = { plugins: [ 'bisheng-plugin-description', 'bisheng-plugin-toc?maxDepth=2&keepElem', - 'bisheng-plugin-antd?injectProvider', + '@ant-design/bisheng-plugin?injectProvider', 'bisheng-plugin-react?lang=__react', ], routes: { diff --git a/site/theme/static/template.html b/site/theme/static/template.html index cc6d549201..31332ba159 100644 --- a/site/theme/static/template.html +++ b/site/theme/static/template.html @@ -20,7 +20,7 @@ } - + + {% for jsFile in manifest["js"] %} + {% endfor %} diff --git a/tests/__mocks__/create-react-context.js b/tests/__mocks__/create-react-context.js deleted file mode 100644 index be08fbd11f..0000000000 --- a/tests/__mocks__/create-react-context.js +++ /dev/null @@ -1,3 +0,0 @@ -import createReactContext from '@ant-design/create-react-context/lib/implementation'; - -export default createReactContext; diff --git a/tests/setup.js b/tests/setup.js index b18a8889ab..8fddc467a3 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -11,6 +11,16 @@ if (typeof window !== 'undefined') { global.window.dispatchEvent(new Event('resize')); }; global.window.scrollTo = () => {}; + // ref: https://github.com/ant-design/ant-design/issues/18774 + if (!global.window.matchMedia) { + Object.defineProperty(global.window, 'matchMedia', { + value: jest.fn(() => ({ + matches: true, + addListener: () => {}, + removeListener: () => {}, + })), + }); + } } // The built-in requestAnimationFrame and cancelAnimationFrame not working with jest.runFakeTimes() diff --git a/typings/custom-typings.d.ts b/typings/custom-typings.d.ts index dc9538ec29..7074107910 100644 --- a/typings/custom-typings.d.ts +++ b/typings/custom-typings.d.ts @@ -23,8 +23,6 @@ declare module 'rc-tabs*'; declare module 'rc-tree'; declare module 'rc-tree/lib/util'; -declare module 'rc-calendar'; - declare module 'rc-input-number'; declare module 'rc-collapse'; @@ -51,12 +49,6 @@ declare module 'rc-switch'; declare module 'rc-upload'; -declare module 'react-lazy-load'; - -declare module 'dom-closest'; - -declare module 'dom-scroll-into-view'; - declare module '*.json' { const value: any; export const version: string; @@ -64,6 +56,3 @@ declare module '*.json' { } declare module 'react-copy-to-clipboard'; - -// https://github.com/ant-design/ant-design/pull/19254 -declare module 'react-lifecycles-compat';