style: update prettier & format code

pull/4258/head
tangjinzhou 2021-06-23 23:08:16 +08:00
parent fdecafbbb3
commit 33c7230ee2
113 changed files with 332 additions and 423 deletions

View File

@ -11,7 +11,7 @@
"parser": "babel-eslint" "parser": "babel-eslint"
}, },
"extends": ["plugin:vue/vue3-recommended", "prettier"], "extends": ["plugin:vue/vue3-recommended", "prettier"],
"plugins": ["markdown"], "plugins": ["markdown", "jest"],
"overrides": [ "overrides": [
{ {
"files": ["**/demo/*.md"], "files": ["**/demo/*.md"],

View File

@ -3,6 +3,7 @@
"trailingComma": "all", "trailingComma": "all",
"printWidth": 100, "printWidth": 100,
"proseWrap": "never", "proseWrap": "never",
"arrowParens": "avoid",
"overrides": [ "overrides": [
{ {
"files": ".prettierrc", "files": ".prettierrc",

View File

@ -1,6 +1,6 @@
const { resolve } = require('./utils/projectHelper'); const { resolve } = require('./utils/projectHelper');
module.exports = function(modules) { module.exports = function (modules) {
const plugins = [ const plugins = [
[ [
resolve('@babel/plugin-transform-typescript'), resolve('@babel/plugin-transform-typescript'),

View File

@ -4,7 +4,7 @@ const fs = require('fs');
const assign = require('object-assign'); const assign = require('object-assign');
const { getProjectPath } = require('./utils/projectHelper'); const { getProjectPath } = require('./utils/projectHelper');
module.exports = function() { module.exports = function () {
let my = {}; let my = {};
if (fs.existsSync(getProjectPath('tsconfig.json'))) { if (fs.existsSync(getProjectPath('tsconfig.json'))) {
my = require(getProjectPath('tsconfig.json')); my = require(getProjectPath('tsconfig.json'));

View File

@ -80,7 +80,7 @@ function compileTs(stream) {
return stream return stream
.pipe(ts(tsConfig)) .pipe(ts(tsConfig))
.js.pipe( .js.pipe(
through2.obj(function(file, encoding, next) { through2.obj(function (file, encoding, next) {
// console.log(file.path, file.base); // console.log(file.path, file.base);
file.path = file.path.replace(/\.[jt]sx$/, '.js'); file.path = file.path.replace(/\.[jt]sx$/, '.js');
this.push(file); this.push(file);
@ -146,7 +146,7 @@ function compile(modules) {
const less = gulp const less = gulp
.src(['components/**/*.less']) .src(['components/**/*.less'])
.pipe( .pipe(
through2.obj(function(file, encoding, next) { through2.obj(function (file, encoding, next) {
this.push(file.clone()); this.push(file.clone());
if ( if (
file.path.match(/\/style\/index\.less$/) || file.path.match(/\/style\/index\.less$/) ||

View File

@ -1,10 +1,7 @@
const fs = require('fs'); const fs = require('fs');
module.exports = function getChangelog(file, version) { module.exports = function getChangelog(file, version) {
const lines = fs const lines = fs.readFileSync(file).toString().split('\n');
.readFileSync(file)
.toString()
.split('\n');
const changeLog = []; const changeLog = [];
const startPattern = new RegExp(`^## ${version}`); const startPattern = new RegExp(`^## ${version}`);
const stopPattern = /^## /; // 前一个版本 const stopPattern = /^## /; // 前一个版本

View File

@ -11,13 +11,7 @@ module.exports = function getRunCmdEnv() {
const nodeModulesBinDir = path.join(__dirname, '../../node_modules/.bin'); const nodeModulesBinDir = path.join(__dirname, '../../node_modules/.bin');
Object.entries(env) Object.entries(env)
.filter( .filter(v => v.slice(0, 1).pop().toLowerCase() === 'path')
v =>
v
.slice(0, 1)
.pop()
.toLowerCase() === 'path',
)
.forEach(v => { .forEach(v => {
const key = v.slice(0, 1).pop(); const key = v.slice(0, 1).pop();
env[key] = env[key] ? `${nodeModulesBinDir}:${env[key]}` : nodeModulesBinDir; env[key] = env[key] ? `${nodeModulesBinDir}:${env[key]}` : nodeModulesBinDir;

View File

@ -20,7 +20,7 @@ function injectRequire() {
const Module = require('module'); const Module = require('module');
const oriRequire = Module.prototype.require; const oriRequire = Module.prototype.require;
Module.prototype.require = function(...args) { Module.prototype.require = function (...args) {
const moduleName = args[0]; const moduleName = args[0];
try { try {
return oriRequire.apply(this, args); return oriRequire.apply(this, args);

View File

@ -163,6 +163,6 @@ export class ClassList {
* @return {ClassList} * @return {ClassList}
* @api public * @api public
*/ */
export default function(el: Element): ClassList { export default function (el: Element): ClassList {
return new ClassList(el); return new ClassList(el);
} }

View File

@ -52,7 +52,7 @@ function copy(text: string, options?: Options): boolean {
mark.style.MozUserSelect = 'text'; mark.style.MozUserSelect = 'text';
mark.style.msUserSelect = 'text'; mark.style.msUserSelect = 'text';
mark.style.userSelect = 'text'; mark.style.userSelect = 'text';
mark.addEventListener('copy', function(e) { mark.addEventListener('copy', function (e) {
e.stopPropagation(); e.stopPropagation();
if (options.format) { if (options.format) {
e.preventDefault(); e.preventDefault();

View File

@ -3,7 +3,7 @@
const deselectCurrent = (): (() => void) => { const deselectCurrent = (): (() => void) => {
const selection = document.getSelection(); const selection = document.getSelection();
if (!selection.rangeCount) { if (!selection.rangeCount) {
return function() {}; return function () {};
} }
let active = document.activeElement as any; let active = document.activeElement as any;
@ -26,11 +26,11 @@ const deselectCurrent = (): (() => void) => {
} }
selection.removeAllRanges(); selection.removeAllRanges();
return function() { return function () {
selection.type === 'Caret' && selection.removeAllRanges(); selection.type === 'Caret' && selection.removeAllRanges();
if (!selection.rangeCount) { if (!selection.rangeCount) {
ranges.forEach(function(range) { ranges.forEach(function (range) {
selection.addRange(range); selection.addRange(range);
}); });
} }

View File

@ -11,7 +11,7 @@ import matches from './dom-matches';
* @param context {Element=} * @param context {Element=}
* @return {Element} * @return {Element}
*/ */
export default function(element, selector, context) { export default function (element, selector, context) {
context = context || document; context = context || document;
// guard against orphans // guard against orphans
element = { parentNode: element }; element = { parentNode: element };

View File

@ -2,10 +2,10 @@ const availablePrefixs = ['moz', 'ms', 'webkit'];
function requestAnimationFramePolyfill() { function requestAnimationFramePolyfill() {
let lastTime = 0; let lastTime = 0;
return function(callback) { return function (callback) {
const currTime = new Date().getTime(); const currTime = new Date().getTime();
const timeToCall = Math.max(0, 16 - (currTime - lastTime)); const timeToCall = Math.max(0, 16 - (currTime - lastTime));
const id = window.setTimeout(function() { const id = window.setTimeout(function () {
callback(currTime + timeToCall); callback(currTime + timeToCall);
}, timeToCall); }, timeToCall);
lastTime = currTime + timeToCall; lastTime = currTime + timeToCall;

View File

@ -18,7 +18,7 @@ const useInjectSize = <T = SizeType>(props?: Record<any, any>): ComputedRef<T> =
? computed(() => props.size) ? computed(() => props.size)
: inject( : inject(
sizeProvider, sizeProvider,
computed(() => ('default' as unknown) as T), computed(() => 'default' as unknown as T),
); );
return size; return size;
}; };

View File

@ -3,23 +3,23 @@
* https://github.com/akiran/json2mq.git * https://github.com/akiran/json2mq.git
*/ */
const camel2hyphen = function(str) { const camel2hyphen = function (str) {
return str return str
.replace(/[A-Z]/g, function(match) { .replace(/[A-Z]/g, function (match) {
return '-' + match.toLowerCase(); return '-' + match.toLowerCase();
}) })
.toLowerCase(); .toLowerCase();
}; };
const isDimension = function(feature) { const isDimension = function (feature) {
const re = /[height|width]$/; const re = /[height|width]$/;
return re.test(feature); return re.test(feature);
}; };
const obj2mq = function(obj) { const obj2mq = function (obj) {
let mq = ''; let mq = '';
const features = Object.keys(obj); const features = Object.keys(obj);
features.forEach(function(feature, index) { features.forEach(function (feature, index) {
let value = obj[feature]; let value = obj[feature];
feature = camel2hyphen(feature); feature = camel2hyphen(feature);
// Add px to dimension features // Add px to dimension features
@ -40,14 +40,14 @@ const obj2mq = function(obj) {
return mq; return mq;
}; };
export default function(query) { export default function (query) {
let mq = ''; let mq = '';
if (typeof query === 'string') { if (typeof query === 'string') {
return query; return query;
} }
// Handling array of media queries // Handling array of media queries
if (query instanceof Array) { if (query instanceof Array) {
query.forEach(function(q, index) { query.forEach(function (q, index) {
mq += obj2mq(q); mq += obj2mq(q);
if (index < query.length - 1) { if (index < query.length - 1) {
mq += ', '; mq += ', ';

View File

@ -28,7 +28,7 @@ const parseStyleText = (cssText = '', camel) => {
const res = {}; const res = {};
const listDelimiter = /;(?![^(]*\))/g; const listDelimiter = /;(?![^(]*\))/g;
const propertyDelimiter = /:(.+)/; const propertyDelimiter = /:(.+)/;
cssText.split(listDelimiter).forEach(function(item) { cssText.split(listDelimiter).forEach(function (item) {
if (item) { if (item) {
const tmp = item.split(propertyDelimiter); const tmp = item.split(propertyDelimiter);
if (tmp.length > 1) { if (tmp.length > 1) {

View File

@ -45,6 +45,6 @@ function shallowEqual(objA, objB, compare, compareContext) {
return true; return true;
} }
export default function(value, other, customizer, thisArg) { export default function (value, other, customizer, thisArg) {
return shallowEqual(toRaw(value), toRaw(other), customizer, thisArg); return shallowEqual(toRaw(value), toRaw(other), customizer, thisArg);
} }

View File

@ -19,7 +19,7 @@ export default function throttleByAnimationFrame(fn: (...args: any[]) => void) {
export function throttleByAnimationFrameDecorator() { export function throttleByAnimationFrameDecorator() {
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
return function(target: any, key: string, descriptor: any) { return function (target: any, key: string, descriptor: any) {
const fn = descriptor.value; const fn = descriptor.value;
let definingProperty = false; let definingProperty = false;
return { return {

View File

@ -34,7 +34,7 @@ export type VueNode = VNodeChild | JSX.Element;
export const withInstall = <T>(comp: T) => { export const withInstall = <T>(comp: T) => {
const c = comp as any; const c = comp as any;
c.install = function(app: App) { c.install = function (app: App) {
app.component(c.displayName || c.name, comp); app.component(c.displayName || c.name, comp);
}; };

View File

@ -175,9 +175,9 @@ export default defineComponent({
`${prefixCls.value}-link-title-active`, `${prefixCls.value}-link-title-active`,
)[0]; )[0];
if (linkNode) { if (linkNode) {
(inkNodeRef.value as HTMLElement).style.top = `${linkNode.offsetTop + (inkNodeRef.value as HTMLElement).style.top = `${
linkNode.clientHeight / 2 - linkNode.offsetTop + linkNode.clientHeight / 2 - 4.5
4.5}px`; }px`;
} }
}; };

View File

@ -5,7 +5,7 @@ import AnchorLink, { AnchorLinkProps } from './AnchorLink';
Anchor.Link = AnchorLink; Anchor.Link = AnchorLink;
/* istanbul ignore next */ /* istanbul ignore next */
Anchor.install = function(app: App) { Anchor.install = function (app: App) {
app.component(Anchor.name, Anchor); app.component(Anchor.name, Anchor);
app.component(Anchor.Link.name, Anchor.Link); app.component(Anchor.Link.name, Anchor.Link);
return app; return app;

View File

@ -146,7 +146,7 @@ const AutoComplete = defineComponent({
}); });
/* istanbul ignore next */ /* istanbul ignore next */
AutoComplete.install = function(app: App) { AutoComplete.install = function (app: App) {
app.component(AutoComplete.name, AutoComplete); app.component(AutoComplete.name, AutoComplete);
app.component(AutoComplete.Option.displayName, AutoComplete.Option); app.component(AutoComplete.Option.displayName, AutoComplete.Option);
app.component(AutoComplete.OptGroup.displayName, AutoComplete.OptGroup); app.component(AutoComplete.OptGroup.displayName, AutoComplete.OptGroup);

View File

@ -8,7 +8,7 @@ export { AvatarGroupProps } from './Group';
Avatar.Group = Group; Avatar.Group = Group;
/* istanbul ignore next */ /* istanbul ignore next */
Avatar.install = function(app: App) { Avatar.install = function (app: App) {
app.component(Avatar.name, Avatar); app.component(Avatar.name, Avatar);
app.component(Group.name, Group); app.component(Group.name, Group);
return app; return app;

View File

@ -44,9 +44,11 @@ export default defineComponent({
// ================================ Misc ================================ // ================================ Misc ================================
const numberedDisplayCount = computed(() => { const numberedDisplayCount = computed(() => {
return ((props.count as number) > (props.overflowCount as number) return (
? `${props.overflowCount}+` (props.count as number) > (props.overflowCount as number)
: props.count) as string | number | null; ? `${props.overflowCount}+`
: props.count
) as string | number | null;
}); });
const hasStatus = computed( const hasStatus = computed(

View File

@ -35,7 +35,7 @@ export default defineComponent({
count, count,
title, title,
show, show,
component: Tag = ('sup' as unknown) as DefineComponent, component: Tag = 'sup' as unknown as DefineComponent,
class: className, class: className,
style, style,
...restProps ...restProps

View File

@ -1,15 +1,15 @@
import { App, Plugin } from 'vue'; import { App, Plugin } from 'vue';
import Badge from './Badge'; import Badge from './Badge';
import Ribbon from './Ribbon'; import Ribbon from './Ribbon';
export type { BadgeProps } from './Badge' export type { BadgeProps } from './Badge';
Badge.install = function(app: App) { Badge.install = function (app: App) {
app.component(Badge.name, Badge); app.component(Badge.name, Badge);
app.component(Ribbon.name, Ribbon); app.component(Ribbon.name, Ribbon);
return app; return app;
}; };
export {Ribbon as BadgeRibbon} export { Ribbon as BadgeRibbon };
export default Badge as typeof Badge & export default Badge as typeof Badge &
Plugin & { Plugin & {

View File

@ -4,14 +4,14 @@ import BreadcrumbItem from './BreadcrumbItem';
import BreadcrumbSeparator from './BreadcrumbSeparator'; import BreadcrumbSeparator from './BreadcrumbSeparator';
export type { BreadcrumbProps } from './Breadcrumb'; export type { BreadcrumbProps } from './Breadcrumb';
export type { BreadcrumbItemProps } from './BreadcrumbItem'; export type { BreadcrumbItemProps } from './BreadcrumbItem';
export type { BreadcrumbSeparatorProps } from './BreadcrumbSeparator'; export type { BreadcrumbSeparatorProps } from './BreadcrumbSeparator';
Breadcrumb.Item = BreadcrumbItem; Breadcrumb.Item = BreadcrumbItem;
Breadcrumb.Separator = BreadcrumbSeparator; Breadcrumb.Separator = BreadcrumbSeparator;
/* istanbul ignore next */ /* istanbul ignore next */
Breadcrumb.install = function(app: App) { Breadcrumb.install = function (app: App) {
app.component(Breadcrumb.name, Breadcrumb); app.component(Breadcrumb.name, Breadcrumb);
app.component(BreadcrumbItem.name, BreadcrumbItem); app.component(BreadcrumbItem.name, BreadcrumbItem);
app.component(BreadcrumbSeparator.name, BreadcrumbSeparator); app.component(BreadcrumbSeparator.name, BreadcrumbSeparator);

View File

@ -1,17 +1,17 @@
import { App, Plugin } from 'vue'; import { App, Plugin } from 'vue';
import Button from './button'; import Button from './button';
import ButtonGroup from './button-group'; import ButtonGroup from './button-group';
export type {ButtonProps} from './button' export type { ButtonProps } from './button';
Button.Group = ButtonGroup; Button.Group = ButtonGroup;
/* istanbul ignore next */ /* istanbul ignore next */
Button.install = function(app: App) { Button.install = function (app: App) {
app.component(Button.name, Button); app.component(Button.name, Button);
app.component(ButtonGroup.name, ButtonGroup); app.component(ButtonGroup.name, ButtonGroup);
return app; return app;
}; };
export {ButtonGroup} export { ButtonGroup };
export default Button as typeof Button & export default Button as typeof Button &
Plugin & { Plugin & {
readonly Group: typeof ButtonGroup; readonly Group: typeof ButtonGroup;

View File

@ -3,20 +3,20 @@ import Card from './Card';
import Meta from './Meta'; import Meta from './Meta';
import Grid from './Grid'; import Grid from './Grid';
export type {CardProps} from './Card' export type { CardProps } from './Card';
Card.Meta = Meta; Card.Meta = Meta;
Card.Grid = Grid; Card.Grid = Grid;
/* istanbul ignore next */ /* istanbul ignore next */
Card.install = function(app: App) { Card.install = function (app: App) {
app.component(Card.name, Card); app.component(Card.name, Card);
app.component(Meta.name, Meta); app.component(Meta.name, Meta);
app.component(Grid.name, Grid); app.component(Grid.name, Grid);
return app; return app;
}; };
export {Meta as CardMeta, Grid as CardGrid} export { Meta as CardMeta, Grid as CardGrid };
export default Card as typeof Card & export default Card as typeof Card &
Plugin & { Plugin & {

View File

@ -110,9 +110,7 @@ describe('Cascader', () => {
}); });
await asyncExpect(() => { await asyncExpect(() => {
$$('.ant-cascader-menu')[0] $$('.ant-cascader-menu')[0].querySelectorAll('.ant-cascader-menu-item')[0].click();
.querySelectorAll('.ant-cascader-menu-item')[0]
.click();
}); });
await asyncExpect(() => { await asyncExpect(() => {
@ -120,9 +118,7 @@ describe('Cascader', () => {
}); });
await asyncExpect(() => { await asyncExpect(() => {
$$('.ant-cascader-menu')[1] $$('.ant-cascader-menu')[1].querySelectorAll('.ant-cascader-menu-item')[0].click();
.querySelectorAll('.ant-cascader-menu-item')[0]
.click();
}); });
await asyncExpect(() => { await asyncExpect(() => {
@ -130,9 +126,7 @@ describe('Cascader', () => {
}); });
await asyncExpect(() => { await asyncExpect(() => {
$$('.ant-cascader-menu')[2] $$('.ant-cascader-menu')[2].querySelectorAll('.ant-cascader-menu-item')[0].click();
.querySelectorAll('.ant-cascader-menu-item')[0]
.click();
}); });
await asyncExpect(() => { await asyncExpect(() => {

View File

@ -5,7 +5,7 @@ import CheckboxGroup from './Group';
Checkbox.Group = CheckboxGroup; Checkbox.Group = CheckboxGroup;
/* istanbul ignore next */ /* istanbul ignore next */
Checkbox.install = function(app: App) { Checkbox.install = function (app: App) {
app.component(Checkbox.name, Checkbox); app.component(Checkbox.name, Checkbox);
app.component(CheckboxGroup.name, CheckboxGroup); app.component(CheckboxGroup.name, CheckboxGroup);
return app; return app;

View File

@ -1,4 +1,4 @@
import { Col } from '../grid'; import { Col } from '../grid';
import { withInstall } from '../_util/type'; import { withInstall } from '../_util/type';
export type {ColProps} from '../grid' export type { ColProps } from '../grid';
export default withInstall(Col); export default withInstall(Col);

View File

@ -1,20 +1,19 @@
import { App, Plugin } from 'vue'; import { App, Plugin } from 'vue';
import Collapse from './Collapse'; import Collapse from './Collapse';
import CollapsePanel from './CollapsePanel'; import CollapsePanel from './CollapsePanel';
export type {CollapseProps} from './Collapse' export type { CollapseProps } from './Collapse';
export type {CollapsePanelProps} from './CollapsePanel' export type { CollapsePanelProps } from './CollapsePanel';
Collapse.Panel = CollapsePanel; Collapse.Panel = CollapsePanel;
/* istanbul ignore next */ /* istanbul ignore next */
Collapse.install = function(app: App) { Collapse.install = function (app: App) {
app.component(Collapse.name, Collapse); app.component(Collapse.name, Collapse);
app.component(CollapsePanel.name, CollapsePanel); app.component(CollapsePanel.name, CollapsePanel);
return app; return app;
}; };
export {CollapsePanel} export { CollapsePanel };
export default Collapse as typeof Collapse & export default Collapse as typeof Collapse &
Plugin & { Plugin & {
readonly Panel: typeof CollapsePanel; readonly Panel: typeof CollapsePanel;

View File

@ -97,7 +97,7 @@ export default {
this.createPickr(); this.createPickr();
this.eventsBinding(); this.eventsBinding();
}, },
setColor: debounce(function(val) { setColor: debounce(function (val) {
this.pickr.setColor(val); this.pickr.setColor(val);
}, 1000), }, 1000),
eventsBinding() { eventsBinding() {

View File

@ -1,6 +1,6 @@
import ColorPicker from './ColorPicker'; import ColorPicker from './ColorPicker';
/* istanbul ignore next */ /* istanbul ignore next */
ColorPicker.install = function(app) { ColorPicker.install = function (app) {
app.component(ColorPicker.name, ColorPicker); app.component(ColorPicker.name, ColorPicker);
return app; return app;
}; };

View File

@ -1,4 +1,3 @@
export type { AffixProps } from './affix'; export type { AffixProps } from './affix';
export { default as Affix } from './affix'; export { default as Affix } from './affix';
@ -6,7 +5,7 @@ export type { AnchorProps, AnchorLinkProps } from './anchor';
export { default as Anchor, AnchorLink } from './anchor'; export { default as Anchor, AnchorLink } from './anchor';
export type { AutoCompleteProps } from './auto-complete'; export type { AutoCompleteProps } from './auto-complete';
export {default as AutoComplete, AutoCompleteOptGroup, AutoCompleteOption } from './auto-complete' export { default as AutoComplete, AutoCompleteOptGroup, AutoCompleteOption } from './auto-complete';
export type { AlertProps } from './alert'; export type { AlertProps } from './alert';
export { default as Alert } from './alert'; export { default as Alert } from './alert';
@ -86,7 +85,7 @@ export { default as Layout, LayoutHeader, LayouSider, LayouFooter, LayouContent
export type { ListProps } from './list'; export type { ListProps } from './list';
export { default as List, ListItem, ListItemMeta } from './list'; export { default as List, ListItem, ListItemMeta } from './list';
export type { MessageArgsProps } from './message'; export type { MessageArgsProps } from './message';
export { default as message } from './message'; export { default as message } from './message';
export type { MenuProps, MenuTheme, SubMenuProps, MenuItemProps } from './menu'; export type { MenuProps, MenuTheme, SubMenuProps, MenuItemProps } from './menu';
@ -131,7 +130,13 @@ export type { SelectProps } from './select';
export { default as Select, SelectOptGroup, SelectOption } from './select'; export { default as Select, SelectOptGroup, SelectOption } from './select';
export type { SkeletonProps } from './skeleton'; export type { SkeletonProps } from './skeleton';
export { default as Skeleton, SkeletonButton, SkeletonAvatar, SkeletonInput, SkeletonImage } from './skeleton'; export {
default as Skeleton,
SkeletonButton,
SkeletonAvatar,
SkeletonInput,
SkeletonImage,
} from './skeleton';
export { default as Slider } from './slider'; export { default as Slider } from './slider';
@ -171,7 +176,13 @@ export type { TooltipProps } from './tooltip';
export { default as Tooltip } from './tooltip'; export { default as Tooltip } from './tooltip';
export type { TypographyProps } from './typography'; export type { TypographyProps } from './typography';
export { default as Typography, TypographyLink, TypographyParagraph, TypographyText, TypographyTitle } from './typography'; export {
default as Typography,
TypographyLink,
TypographyParagraph,
TypographyText,
TypographyTitle,
} from './typography';
export type { UploadProps } from './upload'; export type { UploadProps } from './upload';

View File

@ -195,11 +195,9 @@ describe('RangePicker', () => {
$$('.ant-calendar-picker-input')[0].click(); $$('.ant-calendar-picker-input')[0].click();
}); });
await asyncExpect(() => { await asyncExpect(() => {
expect( expect($$('.ant-calendar-cell')[23].getAttribute('class').split(' ')).toContain(
$$('.ant-calendar-cell')[23] 'ant-calendar-in-range-cell',
.getAttribute('class') );
.split(' '),
).toContain('ant-calendar-in-range-cell');
}); });
}); });

View File

@ -124,30 +124,22 @@ describe('RangePicker with showTime', () => {
); );
await asyncExpect(() => { await asyncExpect(() => {
expect( expect($$('.ant-calendar-time-picker-btn')[0].getAttribute('class').split(' ')).toContain(
$$('.ant-calendar-time-picker-btn')[0] 'ant-calendar-time-picker-btn-disabled',
.getAttribute('class') );
.split(' '), expect($$('.ant-calendar-ok-btn')[0].getAttribute('class').split(' ')).toContain(
).toContain('ant-calendar-time-picker-btn-disabled'); 'ant-calendar-ok-btn-disabled',
expect( );
$$('.ant-calendar-ok-btn')[0]
.getAttribute('class')
.split(' '),
).toContain('ant-calendar-ok-btn-disabled');
}); });
$$('.ant-calendar-date')[10].click(); $$('.ant-calendar-date')[10].click();
$$('.ant-calendar-date')[11].click(); $$('.ant-calendar-date')[11].click();
await asyncExpect(() => { await asyncExpect(() => {
expect( expect($$('.ant-calendar-time-picker-btn')[0].getAttribute('class').split(' ')).not.toContain(
$$('.ant-calendar-time-picker-btn')[0] 'ant-calendar-time-picker-btn-disabled',
.getAttribute('class') );
.split(' '), expect($$('.ant-calendar-ok-btn')[0].getAttribute('class').split(' ')).not.toContain(
).not.toContain('ant-calendar-time-picker-btn-disabled'); 'ant-calendar-ok-btn-disabled',
expect( );
$$('.ant-calendar-ok-btn')[0]
.getAttribute('class')
.split(' '),
).not.toContain('ant-calendar-ok-btn-disabled');
}); });
expect(onChangeFn).toHaveBeenCalled(); expect(onChangeFn).toHaveBeenCalled();
expect(onOpenChangeFn).not.toHaveBeenCalled(); expect(onOpenChangeFn).not.toHaveBeenCalled();

View File

@ -13,33 +13,33 @@ import {
WeekPickerPropsTypes, WeekPickerPropsTypes,
} from './interface'; } from './interface';
const WrappedRangePicker = (wrapPicker( const WrappedRangePicker = wrapPicker(
RangePicker as any, RangePicker as any,
RangePickerProps, RangePickerProps,
'date', 'date',
) as unknown) as DefineComponent<RangePickerPropsTypes>; ) as unknown as DefineComponent<RangePickerPropsTypes>;
const WrappedWeekPicker = (wrapPicker( const WrappedWeekPicker = wrapPicker(
WeekPicker as any, WeekPicker as any,
WeekPickerProps, WeekPickerProps,
'week', 'week',
) as unknown) as DefineComponent<WeekPickerPropsTypes>; ) as unknown as DefineComponent<WeekPickerPropsTypes>;
const DatePicker = (wrapPicker( const DatePicker = wrapPicker(
createPicker(VcCalendar as any, DatePickerProps, 'ADatePicker'), createPicker(VcCalendar as any, DatePickerProps, 'ADatePicker'),
DatePickerProps, DatePickerProps,
'date', 'date',
) as unknown) as DefineComponent<DatePickerPropsTypes> & { ) as unknown as DefineComponent<DatePickerPropsTypes> & {
readonly RangePicker: typeof WrappedRangePicker; readonly RangePicker: typeof WrappedRangePicker;
readonly MonthPicker: typeof MonthPicker; readonly MonthPicker: typeof MonthPicker;
readonly WeekPicker: typeof WrappedWeekPicker; readonly WeekPicker: typeof WrappedWeekPicker;
}; };
const MonthPicker = (wrapPicker( const MonthPicker = wrapPicker(
createPicker(MonthCalendar as any, MonthPickerProps, 'AMonthPicker'), createPicker(MonthCalendar as any, MonthPickerProps, 'AMonthPicker'),
MonthPickerProps, MonthPickerProps,
'month', 'month',
) as unknown) as DefineComponent<MonthPickerPropsTypes>; ) as unknown as DefineComponent<MonthPickerPropsTypes>;
Object.assign(DatePicker, { Object.assign(DatePicker, {
RangePicker: WrappedRangePicker, RangePicker: WrappedRangePicker,
@ -48,7 +48,7 @@ Object.assign(DatePicker, {
}); });
/* istanbul ignore next */ /* istanbul ignore next */
DatePicker.install = function(app: App) { DatePicker.install = function (app: App) {
app.component(DatePicker.name, DatePicker); app.component(DatePicker.name, DatePicker);
app.component(DatePicker.RangePicker.name, DatePicker.RangePicker); app.component(DatePicker.RangePicker.name, DatePicker.RangePicker);
app.component(DatePicker.MonthPicker.name, DatePicker.MonthPicker); app.component(DatePicker.MonthPicker.name, DatePicker.MonthPicker);

View File

@ -56,9 +56,7 @@ export interface DatePickerPropsTypes extends PickerProps, SinglePickerProps {
showTime?: Record<string, any> | boolean; showTime?: Record<string, any> | boolean;
showToday?: boolean; showToday?: boolean;
open?: boolean; open?: boolean;
disabledTime?: ( disabledTime?: (current?: moment.Moment | null) => {
current?: moment.Moment | null,
) => {
disabledHours?: () => number[]; disabledHours?: () => number[];
disabledMinutes?: () => number[]; disabledMinutes?: () => number[];
disabledSeconds?: () => number[]; disabledSeconds?: () => number[];

View File

@ -154,9 +154,8 @@ export interface DescriptionsContextProp {
contentStyle?: Ref<CSSProperties>; contentStyle?: Ref<CSSProperties>;
} }
export const descriptionsContext: InjectionKey<DescriptionsContextProp> = Symbol( export const descriptionsContext: InjectionKey<DescriptionsContextProp> =
'descriptionsContext', Symbol('descriptionsContext');
);
const Descriptions = defineComponent({ const Descriptions = defineComponent({
name: 'ADescriptions', name: 'ADescriptions',
@ -244,7 +243,7 @@ const Descriptions = defineComponent({
}, },
}); });
Descriptions.install = function(app: App) { Descriptions.install = function (app: App) {
app.component(Descriptions.name, Descriptions); app.component(Descriptions.name, Descriptions);
app.component(Descriptions.Item.name, Descriptions.Item); app.component(Descriptions.Item.name, Descriptions.Item);
return app; return app;

View File

@ -8,13 +8,13 @@ export type { DropdownButtonProps } from './dropdown-button';
Dropdown.Button = DropdownButton; Dropdown.Button = DropdownButton;
/* istanbul ignore next */ /* istanbul ignore next */
Dropdown.install = function(app: App) { Dropdown.install = function (app: App) {
app.component(Dropdown.name, Dropdown); app.component(Dropdown.name, Dropdown);
app.component(DropdownButton.name, DropdownButton); app.component(DropdownButton.name, DropdownButton);
return app; return app;
}; };
export {DropdownButton} export { DropdownButton };
export default Dropdown as typeof Dropdown & export default Dropdown as typeof Dropdown &
Plugin & { Plugin & {

View File

@ -1,12 +1,12 @@
import { App, Plugin } from 'vue'; import { App, Plugin } from 'vue';
import Form, {formProps} from './Form'; import Form, { formProps } from './Form';
import FormItem, {formItemProps} from './FormItem'; import FormItem, { formItemProps } from './FormItem';
export type { FormProps } from './Form'; export type { FormProps } from './Form';
export type { FormItemProps } from './FormItem'; export type { FormItemProps } from './FormItem';
/* istanbul ignore next */ /* istanbul ignore next */
Form.install = function(app: App) { Form.install = function (app: App) {
app.component(Form.name, Form); app.component(Form.name, Form);
app.component(Form.Item.name, Form.Item); app.component(Form.Item.name, Form.Item);
return app; return app;

View File

@ -211,9 +211,8 @@ export function validateRules(
validateRule(name, value, rule, options, messageVariables), validateRule(name, value, rule, options, messageVariables),
); );
summaryPromise = (validateFirst summaryPromise = (
? finishOnFirstFailed(rulePromises) validateFirst ? finishOnFirstFailed(rulePromises) : finishOnAllFailed(rulePromises)
: finishOnAllFailed(rulePromises)
).then((errors: string[]): string[] | Promise<string[]> => { ).then((errors: string[]): string[] | Promise<string[]> => {
if (!errors.length) { if (!errors.length) {
return []; return [];

View File

@ -28,7 +28,7 @@ export { imageProps };
Image.PreviewGroup = PreviewGroup; Image.PreviewGroup = PreviewGroup;
Image.install = function(app: App) { Image.install = function (app: App) {
app.component(Image.name, Image); app.component(Image.name, Image);
app.component(Image.PreviewGroup.name, Image.PreviewGroup); app.component(Image.PreviewGroup.name, Image.PreviewGroup);
return app; return app;

View File

@ -4,7 +4,7 @@ import * as components from './components';
import { default as version } from './version'; import { default as version } from './version';
export * from './components'; export * from './components';
export const install = function(app: App) { export const install = function (app: App) {
Object.keys(components).forEach(key => { Object.keys(components).forEach(key => {
const component = components[key]; const component = components[key];
if (component.install) { if (component.install) {

View File

@ -64,7 +64,12 @@ const InputNumber = defineComponent({
}, },
render() { render() {
const { prefixCls: customizePrefixCls, size, class: className, ...others } = { const {
prefixCls: customizePrefixCls,
size,
class: className,
...others
} = {
...getOptionProps(this), ...getOptionProps(this),
...this.$attrs, ...this.$attrs,
} as any; } as any;

View File

@ -11,7 +11,7 @@ Input.TextArea = TextArea;
Input.Password = Password; Input.Password = Password;
/* istanbul ignore next */ /* istanbul ignore next */
Input.install = function(app: App) { Input.install = function (app: App) {
app.component(Input.name, Input); app.component(Input.name, Input);
app.component(Input.Group.name, Input.Group); app.component(Input.Group.name, Input.Group);
app.component(Input.Search.name, Input.Search); app.component(Input.Search.name, Input.Search);

View File

@ -8,7 +8,7 @@ export { SiderProps } from './Sider';
Layout.Sider = Sider; Layout.Sider = Sider;
/* istanbul ignore next */ /* istanbul ignore next */
Layout.install = function(app: App) { Layout.install = function (app: App) {
app.component(Layout.name, Layout); app.component(Layout.name, Layout);
app.component(Layout.Header.name, Layout.Header); app.component(Layout.Header.name, Layout.Header);
app.component(Layout.Footer.name, Layout.Footer); app.component(Layout.Footer.name, Layout.Footer);

View File

@ -322,7 +322,7 @@ const List = defineComponent({
}); });
/* istanbul ignore next */ /* istanbul ignore next */
List.install = function(app: App) { List.install = function (app: App) {
app.component(List.name, List); app.component(List.name, List);
app.component(List.Item.name, List.Item); app.component(List.Item.name, List.Item);
app.component(List.Item.Meta.name, List.Item.Meta); app.component(List.Item.Meta.name, List.Item.Meta);

View File

@ -221,9 +221,10 @@ describe('Locale Provider', () => {
{ sync: false, attachTo: 'body' }, { sync: false, attachTo: 'body' },
); );
await sleep(); await sleep();
const currentConfirmNode = document.querySelectorAll('.ant-modal-confirm')[ const currentConfirmNode =
document.querySelectorAll('.ant-modal-confirm').length - 1 document.querySelectorAll('.ant-modal-confirm')[
]; document.querySelectorAll('.ant-modal-confirm').length - 1
];
let cancelButtonText = currentConfirmNode.querySelectorAll( let cancelButtonText = currentConfirmNode.querySelectorAll(
'.ant-btn:not(.ant-btn-primary) span', '.ant-btn:not(.ant-btn-primary) span',
)[0].innerHTML; )[0].innerHTML;

View File

@ -89,7 +89,7 @@ const LocaleProvider = defineComponent({
}); });
/* istanbul ignore next */ /* istanbul ignore next */
LocaleProvider.install = function(app: App) { LocaleProvider.install = function (app: App) {
app.component(LocaleProvider.name, LocaleProvider); app.component(LocaleProvider.name, LocaleProvider);
return app; return app;
}; };

View File

@ -211,7 +211,7 @@ const Mentions = defineComponent({
}); });
/* istanbul ignore next */ /* istanbul ignore next */
Mentions.install = function(app: App) { Mentions.install = function (app: App) {
app.component(Mentions.name, Mentions); app.component(Mentions.name, Mentions);
app.component(Mentions.Option.name, Mentions.Option); app.component(Mentions.Option.name, Mentions.Option);
return app; return app;

View File

@ -6,7 +6,7 @@ import Divider from './src/Divider';
import { App, Plugin } from 'vue'; import { App, Plugin } from 'vue';
import { MenuTheme } from './src/interface'; import { MenuTheme } from './src/interface';
/* istanbul ignore next */ /* istanbul ignore next */
Menu.install = function(app: App) { Menu.install = function (app: App) {
app.component(Menu.name, Menu); app.component(Menu.name, Menu);
app.component(MenuItem.name, MenuItem); app.component(MenuItem.name, MenuItem);
app.component(SubMenu.name, SubMenu); app.component(SubMenu.name, SubMenu);

View File

@ -133,9 +133,7 @@ export interface ModalFuncProps {
type getContainerFunc = () => HTMLElement; type getContainerFunc = () => HTMLElement;
export type ModalFunc = ( export type ModalFunc = (props: ModalFuncProps) => {
props: ModalFuncProps,
) => {
destroy: () => void; destroy: () => void;
update: (newConfig: ModalFuncProps) => void; update: (newConfig: ModalFuncProps) => void;
}; };

View File

@ -9,7 +9,7 @@ import ExclamationCircleOutlined from '@ant-design/icons-vue/ExclamationCircleOu
export { IActionButtonProps as ActionButtonProps } from './ActionButton'; export { IActionButtonProps as ActionButtonProps } from './ActionButton';
export { ModalProps, ModalFuncProps } from './Modal'; export { ModalProps, ModalFuncProps } from './Modal';
const info = function(props: ModalFuncProps) { const info = function (props: ModalFuncProps) {
const config = { const config = {
type: 'info', type: 'info',
icon: <InfoCircleOutlined />, icon: <InfoCircleOutlined />,
@ -19,7 +19,7 @@ const info = function(props: ModalFuncProps) {
return modalConfirm(config); return modalConfirm(config);
}; };
const success = function(props: ModalFuncProps) { const success = function (props: ModalFuncProps) {
const config = { const config = {
type: 'success', type: 'success',
icon: <CheckCircleOutlined />, icon: <CheckCircleOutlined />,
@ -29,7 +29,7 @@ const success = function(props: ModalFuncProps) {
return modalConfirm(config); return modalConfirm(config);
}; };
const error = function(props: ModalFuncProps) { const error = function (props: ModalFuncProps) {
const config = { const config = {
type: 'error', type: 'error',
icon: <CloseCircleOutlined />, icon: <CloseCircleOutlined />,
@ -39,7 +39,7 @@ const error = function(props: ModalFuncProps) {
return modalConfirm(config); return modalConfirm(config);
}; };
const warning = function(props: ModalFuncProps) { const warning = function (props: ModalFuncProps) {
const config = { const config = {
type: 'warning', type: 'warning',
icon: <ExclamationCircleOutlined />, icon: <ExclamationCircleOutlined />,
@ -75,7 +75,7 @@ Modal.destroyAll = function destroyAllFn() {
}; };
/* istanbul ignore next */ /* istanbul ignore next */
Modal.install = function(app: App) { Modal.install = function (app: App) {
app.component(Modal.name, Modal); app.component(Modal.name, Modal);
return app; return app;
}; };

View File

@ -51,15 +51,8 @@ export const handleGradient = strokeColor => {
}; };
const Line = (_, { attrs, slots }) => { const Line = (_, { attrs, slots }) => {
const { const { prefixCls, percent, successPercent, strokeWidth, size, strokeColor, strokeLinecap } =
prefixCls, attrs;
percent,
successPercent,
strokeWidth,
size,
strokeColor,
strokeLinecap,
} = attrs;
let backgroundProps; let backgroundProps;
if (strokeColor && typeof strokeColor !== 'string') { if (strokeColor && typeof strokeColor !== 'string') {
backgroundProps = handleGradient(strokeColor); backgroundProps = handleGradient(strokeColor);

View File

@ -9,7 +9,7 @@ Radio.Group = Group;
Radio.Button = Button; Radio.Button = Button;
/* istanbul ignore next */ /* istanbul ignore next */
Radio.install = function(app: App) { Radio.install = function (app: App) {
app.component(Radio.name, Radio); app.component(Radio.name, Radio);
app.component(Radio.Group.name, Radio.Group); app.component(Radio.Group.name, Radio.Group);
app.component(Radio.Button.name, Radio.Button); app.component(Radio.Button.name, Radio.Button);

View File

@ -93,7 +93,7 @@ Result.PRESENTED_IMAGE_404 = ExceptionMap[404];
Result.PRESENTED_IMAGE_500 = ExceptionMap[500]; Result.PRESENTED_IMAGE_500 = ExceptionMap[500];
/* istanbul ignore next */ /* istanbul ignore next */
Result.install = function(app: App) { Result.install = function (app: App) {
app.component(Result.name, Result); app.component(Result.name, Result);
return app; return app;
}; };

View File

@ -1,6 +1,6 @@
import { Row } from '../grid'; import { Row } from '../grid';
import { withInstall } from '../_util/type'; import { withInstall } from '../_util/type';
export type {RowProps} from '../grid' export type { RowProps } from '../grid';
export default withInstall(Row); export default withInstall(Row);

View File

@ -200,7 +200,7 @@ const Select = defineComponent({
}, },
}); });
/* istanbul ignore next */ /* istanbul ignore next */
Select.install = function(app: App) { Select.install = function (app: App) {
app.component(Select.name, Select); app.component(Select.name, Select);
app.component(Select.Option.displayName, Select.Option); app.component(Select.Option.displayName, Select.Option);
app.component(Select.OptGroup.displayName, Select.OptGroup); app.component(Select.OptGroup.displayName, Select.OptGroup);

View File

@ -13,7 +13,7 @@ Skeleton.Input = SkeletonInput;
Skeleton.Image = SkeletonImage; Skeleton.Image = SkeletonImage;
/* istanbul ignore next */ /* istanbul ignore next */
Skeleton.install = function(app: App) { Skeleton.install = function (app: App) {
app.component(Skeleton.name, Skeleton); app.component(Skeleton.name, Skeleton);
app.component(Skeleton.Button.name, SkeletonButton); app.component(Skeleton.Button.name, SkeletonButton);
app.component(Skeleton.Avatar.name, SkeletonAvatar); app.component(Skeleton.Avatar.name, SkeletonAvatar);

View File

@ -50,9 +50,12 @@ const Space = defineComponent({
watch( watch(
size, size,
() => { () => {
[horizontalSize.value, verticalSize.value] = ((Array.isArray(size.value) [horizontalSize.value, verticalSize.value] = (
? size.value (Array.isArray(size.value) ? size.value : [size.value, size.value]) as [
: [size.value, size.value]) as [SpaceSize, SpaceSize]).map(item => getNumberSize(item)); SpaceSize,
SpaceSize,
]
).map(item => getNumberSize(item));
}, },
{ immediate: true }, { immediate: true },
); );

View File

@ -13,12 +13,7 @@ describe('delay spinning', () => {
}; };
const wrapper = mount(Spin, props); const wrapper = mount(Spin, props);
await asyncExpect(() => { await asyncExpect(() => {
expect( expect(wrapper.find('.ant-spin').classes().includes('ant-spin-spinning')).toEqual(false);
wrapper
.find('.ant-spin')
.classes()
.includes('ant-spin-spinning'),
).toEqual(false);
}); });
}); });
@ -32,23 +27,13 @@ describe('delay spinning', () => {
}; };
const wrapper = mount(Spin, props); const wrapper = mount(Spin, props);
expect( expect(wrapper.findAll('.ant-spin')[0].classes().includes('ant-spin-spinning')).toEqual(false);
wrapper
.findAll('.ant-spin')[0]
.classes()
.includes('ant-spin-spinning'),
).toEqual(false);
// use await not jest.runAllTimers() // use await not jest.runAllTimers()
// because of https://github.com/facebook/jest/issues/3465 // because of https://github.com/facebook/jest/issues/3465
await new Promise(resolve => setTimeout(resolve, 500)); await new Promise(resolve => setTimeout(resolve, 500));
expect( expect(wrapper.findAll('.ant-spin')[0].classes().includes('ant-spin-spinning')).toEqual(true);
wrapper
.findAll('.ant-spin')[0]
.classes()
.includes('ant-spin-spinning'),
).toEqual(true);
}); });
it('should cancel debounce function when unmount', async () => { it('should cancel debounce function when unmount', async () => {

View File

@ -6,7 +6,7 @@ export { SpinProps, getSpinProps } from './Spin';
Spin.setDefaultIndicator = setDefaultIndicator; Spin.setDefaultIndicator = setDefaultIndicator;
/* istanbul ignore next */ /* istanbul ignore next */
Spin.install = function(app: App) { Spin.install = function (app: App) {
app.component(Spin.name, Spin); app.component(Spin.name, Spin);
return app; return app;
}; };

View File

@ -65,12 +65,7 @@ describe('Statistic', () => {
describe('Countdown', () => { describe('Countdown', () => {
it('render correctly', () => { it('render correctly', () => {
const now = moment() const now = moment().add(2, 'd').add(11, 'h').add(28, 'm').add(9, 's').add(3, 'ms');
.add(2, 'd')
.add(11, 'h')
.add(28, 'm')
.add(9, 's')
.add(3, 'ms');
[ [
['H:m:s', '59:28:9'], ['H:m:s', '59:28:9'],

View File

@ -2,17 +2,17 @@ import { App, Plugin } from 'vue';
import Statistic from './Statistic'; import Statistic from './Statistic';
import Countdown from './Countdown'; import Countdown from './Countdown';
export type {StatisticProps} from './Statistic' export type { StatisticProps } from './Statistic';
Statistic.Countdown = Countdown; Statistic.Countdown = Countdown;
/* istanbul ignore next */ /* istanbul ignore next */
Statistic.install = function(app: App) { Statistic.install = function (app: App) {
app.component(Statistic.name, Statistic); app.component(Statistic.name, Statistic);
app.component(Statistic.Countdown.name, Statistic.Countdown); app.component(Statistic.Countdown.name, Statistic.Countdown);
return app; return app;
}; };
export const StatisticCountdown = Statistic.Countdown export const StatisticCountdown = Statistic.Countdown;
export default Statistic as typeof Statistic & export default Statistic as typeof Statistic &
Plugin & { Plugin & {

View File

@ -70,7 +70,7 @@ const Steps = defineComponent({
}); });
/* istanbul ignore next */ /* istanbul ignore next */
Steps.install = function(app: App) { Steps.install = function (app: App) {
app.component(Steps.name, Steps); app.component(Steps.name, Steps);
app.component(Steps.Step.name, Steps.Step); app.component(Steps.Step.name, Steps.Step);
return app; return app;

View File

@ -1216,10 +1216,8 @@ export default defineComponent({
transformCellText: customizeTransformCellText, transformCellText: customizeTransformCellText,
} = this; } = this;
const data = this.getCurrentPageData(); const data = this.getCurrentPageData();
const { const { getPopupContainer: getContextPopupContainer, transformCellText: tct } =
getPopupContainer: getContextPopupContainer, this.configProvider;
transformCellText: tct,
} = this.configProvider;
const getPopupContainer = this.getPopupContainer || getContextPopupContainer; const getPopupContainer = this.getPopupContainer || getContextPopupContainer;
const transformCellText = customizeTransformCellText || tct; const transformCellText = customizeTransformCellText || tct;
let loading = this.loading; let loading = this.loading;

View File

@ -310,16 +310,10 @@ describe('Table.rowSelection', () => {
); );
expect(dropdownWrapper.findAll('.ant-dropdown-menu-item').length).toBe(4); expect(dropdownWrapper.findAll('.ant-dropdown-menu-item').length).toBe(4);
dropdownWrapper dropdownWrapper.findAll('.ant-dropdown-menu-item > div').at(2).trigger('click');
.findAll('.ant-dropdown-menu-item > div')
.at(2)
.trigger('click');
expect(handleSelectOdd).toBeCalledWith([0, 1, 2, 3]); expect(handleSelectOdd).toBeCalledWith([0, 1, 2, 3]);
dropdownWrapper dropdownWrapper.findAll('.ant-dropdown-menu-item > div').at(3).trigger('click');
.findAll('.ant-dropdown-menu-item > div')
.at(3)
.trigger('click');
expect(handleSelectEven).toBeCalledWith([0, 1, 2, 3]); expect(handleSelectEven).toBeCalledWith([0, 1, 2, 3]);
}); });

View File

@ -93,7 +93,7 @@ const Table = defineComponent({
}, },
}); });
/* istanbul ignore next */ /* istanbul ignore next */
Table.install = function(app: App) { Table.install = function (app: App) {
app.component(Table.name, Table); app.component(Table.name, Table);
app.component(Table.Column.name, Table.Column); app.component(Table.Column.name, Table.Column);
app.component(Table.ColumnGroup.name, Table.ColumnGroup); app.component(Table.ColumnGroup.name, Table.ColumnGroup);

View File

@ -7,7 +7,7 @@ Tabs.TabPane = { ...TabPane, name: 'ATabPane', __ANT_TAB_PANE: true };
Tabs.TabContent = { ...TabContent, name: 'ATabContent' }; Tabs.TabContent = { ...TabContent, name: 'ATabContent' };
/* istanbul ignore next */ /* istanbul ignore next */
Tabs.install = function(app: App) { Tabs.install = function (app: App) {
app.component(Tabs.name, Tabs); app.component(Tabs.name, Tabs);
app.component(Tabs.TabPane.name, Tabs.TabPane); app.component(Tabs.TabPane.name, Tabs.TabPane);
app.component(Tabs.TabContent.name, Tabs.TabContent); app.component(Tabs.TabContent.name, Tabs.TabContent);

View File

@ -140,7 +140,7 @@ const Tag = defineComponent({
Tag.CheckableTag = CheckableTag; Tag.CheckableTag = CheckableTag;
Tag.install = function(app: App) { Tag.install = function (app: App) {
app.component(Tag.name, Tag); app.component(Tag.name, Tag);
app.component(CheckableTag.name, CheckableTag); app.component(CheckableTag.name, CheckableTag);
return app; return app;

View File

@ -8,12 +8,12 @@ export type { TimelineItemProps } from './TimelineItem';
Timeline.Item = TimelineItem; Timeline.Item = TimelineItem;
/* istanbul ignore next */ /* istanbul ignore next */
Timeline.install = function(app: App) { Timeline.install = function (app: App) {
app.component(Timeline.name, Timeline); app.component(Timeline.name, Timeline);
app.component(TimelineItem.name, TimelineItem); app.component(TimelineItem.name, TimelineItem);
return app; return app;
}; };
export {TimelineItem} export { TimelineItem };
export default Timeline as typeof Timeline & export default Timeline as typeof Timeline &
Plugin & { Plugin & {
readonly Item: typeof TimelineItem; readonly Item: typeof TimelineItem;

View File

@ -197,7 +197,7 @@ const TreeSelect = defineComponent({
}); });
/* istanbul ignore next */ /* istanbul ignore next */
TreeSelect.install = function(app: App) { TreeSelect.install = function (app: App) {
app.component(TreeSelect.name, TreeSelect); app.component(TreeSelect.name, TreeSelect);
app.component(TreeSelect.TreeNode.displayName, TreeSelect.TreeNode); app.component(TreeSelect.TreeNode.displayName, TreeSelect.TreeNode);
return app; return app;

View File

@ -5,7 +5,7 @@ import DirectoryTree from './DirectoryTree';
Tree.TreeNode.name = 'ATreeNode'; Tree.TreeNode.name = 'ATreeNode';
Tree.DirectoryTree = DirectoryTree; Tree.DirectoryTree = DirectoryTree;
/* istanbul ignore next */ /* istanbul ignore next */
Tree.install = function(app: App) { Tree.install = function (app: App) {
app.component(Tree.name, Tree); app.component(Tree.name, Tree);
app.component(Tree.TreeNode.name, Tree.TreeNode); app.component(Tree.TreeNode.name, Tree.TreeNode);
app.component(DirectoryTree.name, DirectoryTree); app.component(DirectoryTree.name, DirectoryTree);

View File

@ -123,18 +123,16 @@ const Base = defineComponent<InternalBlockProps>({
const contentRef = ref(); const contentRef = ref();
const editIcon = ref(); const editIcon = ref();
const ellipsis = computed( const ellipsis = computed((): EllipsisConfig => {
(): EllipsisConfig => { const ellipsis = props.ellipsis;
const ellipsis = props.ellipsis; if (!ellipsis) return {};
if (!ellipsis) return {};
return { return {
rows: 1, rows: 1,
expandable: false, expandable: false,
...(typeof ellipsis === 'object' ? ellipsis : null), ...(typeof ellipsis === 'object' ? ellipsis : null),
}; };
}, });
);
onMounted(() => { onMounted(() => {
state.clientRendered = true; state.clientRendered = true;
}); });
@ -294,7 +292,11 @@ const Base = defineComponent<InternalBlockProps>({
// Do not measure if css already support ellipsis // Do not measure if css already support ellipsis
if (canUseCSSEllipsis.value) return; if (canUseCSSEllipsis.value) return;
const { content, text, ellipsis: ell } = measure( const {
content,
text,
ellipsis: ell,
} = measure(
contentRef.value?.$el, contentRef.value?.$el,
{ rows, suffix }, { rows, suffix },
props.content, props.content,
@ -451,7 +453,14 @@ const Base = defineComponent<InternalBlockProps>({
<LocaleReceiver <LocaleReceiver
componentName="Text" componentName="Text"
children={(locale: Locale) => { children={(locale: Locale) => {
const { type, disabled, content, class: className, style, ...restProps } = { const {
type,
disabled,
content,
class: className,
style,
...restProps
} = {
...props, ...props,
...attrs, ...attrs,
}; };

View File

@ -20,8 +20,10 @@ describe('Typography', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
// Mock offsetHeight // Mock offsetHeight
const originOffsetHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetHeight') const originOffsetHeight = Object.getOwnPropertyDescriptor(
.get; HTMLElement.prototype,
'offsetHeight',
).get;
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
get() { get() {
let html = this.innerHTML; let html = this.innerHTML;

View File

@ -6,16 +6,15 @@ import Text from './Text';
import Title from './Title'; import Title from './Title';
import Typography from './Typography'; import Typography from './Typography';
export type {TypographyProps} from './Typography' export type { TypographyProps } from './Typography';
Typography.Text = Text;
Typography.Title = Title;
Typography.Paragraph = Paragraph;
Typography.Link = Link;
Typography.Base = Base;
Typography.Text = Text Typography.install = function (app: App) {
Typography.Title = Title
Typography.Paragraph = Paragraph
Typography.Link = Link
Typography.Base = Base
Typography.install = function(app: App) {
app.component(Typography.name, Typography); app.component(Typography.name, Typography);
app.component(Typography.Text.displayName, Text); app.component(Typography.Text.displayName, Text);
app.component(Typography.Title.displayName, Title); app.component(Typography.Title.displayName, Title);
@ -29,7 +28,7 @@ export {
Title as TypographyTitle, Title as TypographyTitle,
Paragraph as TypographyParagraph, Paragraph as TypographyParagraph,
Link as TypographyLink, Link as TypographyLink,
} };
export default Typography as typeof Typography & export default Typography as typeof Typography &
Plugin & { Plugin & {

View File

@ -93,10 +93,7 @@ describe('Upload List', () => {
const wrapper = mount(Upload, props); const wrapper = mount(Upload, props);
setTimeout(async () => { setTimeout(async () => {
expect(wrapper.findAll('.ant-upload-list-item').length).toBe(2); expect(wrapper.findAll('.ant-upload-list-item').length).toBe(2);
wrapper wrapper.findAll('.ant-upload-list-item')[0].find('.anticon-delete').trigger('click');
.findAll('.ant-upload-list-item')[0]
.find('.anticon-delete')
.trigger('click');
await delay(400); await delay(400);
// wrapper.update(); // wrapper.update();
expect(wrapper.findAll('.ant-upload-list-item').length).toBe(1); expect(wrapper.findAll('.ant-upload-list-item').length).toBe(1);

View File

@ -7,7 +7,7 @@ export { UploadProps, UploadListProps, UploadChangeParam } from './interface';
Upload.Dragger = Dragger; Upload.Dragger = Dragger;
/* istanbul ignore next */ /* istanbul ignore next */
Upload.install = function(app: App) { Upload.install = function (app: App) {
app.component(Upload.name, Upload); app.component(Upload.name, Upload);
app.component(Dragger.name, Dragger); app.component(Dragger.name, Dragger);
return app; return app;

View File

@ -26,7 +26,7 @@ export function genPercentAdd() {
let k = 0.1; let k = 0.1;
const i = 0.01; const i = 0.01;
const end = 0.98; const end = 0.98;
return function(s) { return function (s) {
let start = s; let start = s;
if (start >= end) { if (start >= end) {
return start; return start;

View File

@ -178,12 +178,7 @@ const DateTBody = {
cls += ` ${nextMonthDayClass}`; cls += ` ${nextMonthDayClass}`;
} }
if ( if (current.clone().endOf('month').date() === current.date()) {
current
.clone()
.endOf('month')
.date() === current.date()
) {
cls += ` ${lastDayOfMonthClass}`; cls += ` ${lastDayOfMonthClass}`;
} }

View File

@ -59,15 +59,8 @@ const MonthPanel = {
}, },
render() { render() {
const { const { sValue, cellRender, contentRender, locale, rootPrefixCls, disabledDate, renderFooter } =
sValue, this;
cellRender,
contentRender,
locale,
rootPrefixCls,
disabledDate,
renderFooter,
} = this;
const year = sValue.year(); const year = sValue.year();
const prefixCls = `${rootPrefixCls}-month-panel`; const prefixCls = `${rootPrefixCls}-month-panel`;

View File

@ -100,18 +100,8 @@ export default defineComponent({
}, },
render() { render() {
const { const { prefixCls, name, id, type, disabled, readonly, tabindex, autofocus, value, ...others } =
prefixCls, getOptionProps(this);
name,
id,
type,
disabled,
readonly,
tabindex,
autofocus,
value,
...others
} = getOptionProps(this);
const { class: className, onFocus, onBlur } = this.$attrs; const { class: className, onFocus, onBlur } = this.$attrs;
const globalProps = Object.keys({ ...others, ...this.$attrs }).reduce((prev, key) => { const globalProps = Object.keys({ ...others, ...this.$attrs }).reduce((prev, key) => {
if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') { if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') {

View File

@ -190,15 +190,8 @@ const ImageInternal = defineComponent({
return l; return l;
}; };
return () => { return () => {
const { const { prefixCls, wrapperClassName, fallback, src, preview, placeholder, wrapperStyle } =
prefixCls, props;
wrapperClassName,
fallback,
src,
preview,
placeholder,
wrapperStyle,
} = props;
const { const {
width, width,
height, height,

View File

@ -26,9 +26,9 @@ export interface OverflowContextProviderValueType {
className?: string; className?: string;
} }
const OverflowContextProviderKey: InjectionKey<ComputedRef<OverflowContextProviderValueType | null>> = Symbol( const OverflowContextProviderKey: InjectionKey<
'OverflowContextProviderKey', ComputedRef<OverflowContextProviderValueType | null>
); > = Symbol('OverflowContextProviderKey');
export const OverflowContextProvider = defineComponent({ export const OverflowContextProvider = defineComponent({
name: 'OverflowContextProvider', name: 'OverflowContextProvider',
@ -45,9 +45,10 @@ export const OverflowContextProvider = defineComponent({
}, },
}); });
export const useInjectOverflowContext = (): ComputedRef<OverflowContextProviderValueType | null> => { export const useInjectOverflowContext =
return inject( (): ComputedRef<OverflowContextProviderValueType | null> => {
OverflowContextProviderKey, return inject(
computed(() => null), OverflowContextProviderKey,
); computed(() => null),
}; );
};

View File

@ -63,9 +63,8 @@ const RefSelect = generateSelector<SelectOptionsType>({
fillOptionsWithMissingValue, fillOptionsWithMissingValue,
}); });
export type ExportedSelectProps< export type ExportedSelectProps<ValueType extends DefaultValueType = DefaultValueType> =
ValueType extends DefaultValueType = DefaultValueType SelectProps<SelectOptionsType, ValueType>;
> = SelectProps<SelectOptionsType, ValueType>;
const Select = defineComponent<Omit<ExportedSelectProps, 'children'>>({ const Select = defineComponent<Omit<ExportedSelectProps, 'children'>>({
setup(props, { attrs, expose, slots }) { setup(props, { attrs, expose, slots }) {

View File

@ -56,8 +56,8 @@ const props = {
maxTagCount: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), maxTagCount: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
maxTagTextLength: PropTypes.number, maxTagTextLength: PropTypes.number,
maxTagPlaceholder: PropTypes.any.def(() => (omittedValues: LabelValueType[]) => maxTagPlaceholder: PropTypes.any.def(
`+ ${omittedValues.length} ...`, () => (omittedValues: LabelValueType[]) => `+ ${omittedValues.length} ...`,
), ),
tagRender: PropTypes.func, tagRender: PropTypes.func,

View File

@ -326,7 +326,7 @@ export default function generateSelector<
label?: VNodeChild; label?: VNodeChild;
key?: Key; key?: Key;
disabled?: boolean; disabled?: boolean;
}[] }[],
>(config: GenerateConfig<OptionsType>) { >(config: GenerateConfig<OptionsType>) {
const { const {
prefixCls: defaultPrefixCls, prefixCls: defaultPrefixCls,
@ -442,29 +442,27 @@ export default function generateSelector<
return mergedSearchValue; return mergedSearchValue;
}); });
const mergedOptions = computed( const mergedOptions = computed((): OptionsType => {
(): OptionsType => { let newOptions = props.options;
let newOptions = props.options; if (newOptions === undefined) {
if (newOptions === undefined) { newOptions = convertChildrenToData(props.children);
newOptions = convertChildrenToData(props.children); }
}
/** /**
* `tags` should fill un-list item. * `tags` should fill un-list item.
* This is not cool here since TreeSelect do not need this * This is not cool here since TreeSelect do not need this
*/ */
if (props.mode === 'tags' && fillOptionsWithMissingValue) { if (props.mode === 'tags' && fillOptionsWithMissingValue) {
newOptions = fillOptionsWithMissingValue( newOptions = fillOptionsWithMissingValue(
newOptions, newOptions,
mergedValue.value, mergedValue.value,
mergedOptionLabelProp.value, mergedOptionLabelProp.value,
props.labelInValue, props.labelInValue,
); );
} }
return newOptions || ([] as OptionsType); return newOptions || ([] as OptionsType);
}, });
);
const mergedFlattenOptions = computed(() => flattenOptions(mergedOptions.value, props)); const mergedFlattenOptions = computed(() => flattenOptions(mergedOptions.value, props));
@ -553,14 +551,16 @@ export default function generateSelector<
const { internalProps = {} } = props; const { internalProps = {} } = props;
if (!internalProps.skipTriggerSelect) { if (!internalProps.skipTriggerSelect) {
// Skip trigger `onSelect` or `onDeselect` if configured // Skip trigger `onSelect` or `onDeselect` if configured
const selectValue = (mergedLabelInValue.value const selectValue = (
? getLabeledValue(newValue, { mergedLabelInValue.value
options: newValueOption, ? getLabeledValue(newValue, {
prevValueMap: mergedValueMap.value, options: newValueOption,
labelInValue: mergedLabelInValue.value, prevValueMap: mergedValueMap.value,
optionLabelProp: mergedOptionLabelProp.value, labelInValue: mergedLabelInValue.value,
}) optionLabelProp: mergedOptionLabelProp.value,
: newValue) as SingleType<ValueType>; })
: newValue
) as SingleType<ValueType>;
if (isSelect && props.onSelect) { if (isSelect && props.onSelect) {
props.onSelect(selectValue, outOption); props.onSelect(selectValue, outOption);

View File

@ -7,7 +7,7 @@ export default function useCacheOptions<
label?: VNodeChild; label?: VNodeChild;
key?: Key; key?: Key;
disabled?: boolean; disabled?: boolean;
}[] }[],
>(options: Ref) { >(options: Ref) {
const optionMap = computed(() => { const optionMap = computed(() => {
const map: Map<RawValueType, FlattenOptionsType<OptionsType>[number]> = new Map(); const map: Map<RawValueType, FlattenOptionsType<OptionsType>[number]> = new Map();

View File

@ -80,7 +80,7 @@ export function toOuterValues<FOT extends FlattenOptionsType>(
export function removeLastEnabledValue< export function removeLastEnabledValue<
T extends { disabled?: boolean }, T extends { disabled?: boolean },
P extends RawValueType | object P extends RawValueType | object,
>(measureValues: T[], values: P[]): { values: P[]; removedValue: P } { >(measureValues: T[], values: P[]): { values: P[]; removedValue: P } {
const newValues = [...values]; const newValues = [...values];

View File

@ -178,9 +178,7 @@ function getFilterFunction(optionFilterProp: string) {
// Group label search // Group label search
if ('options' in option) { if ('options' in option) {
return toRawString(option.label) return toRawString(option.label).toLowerCase().includes(lowerSearchText);
.toLowerCase()
.includes(lowerSearchText);
} }
// Option value search // Option value search
const rawValue = option[optionFilterProp]; const rawValue = option[optionFilterProp];
@ -277,9 +275,7 @@ export function fillOptionsWithMissingValue(
optionLabelProp: string, optionLabelProp: string,
labelInValue: boolean, labelInValue: boolean,
): SelectOptionsType { ): SelectOptionsType {
const values = toArray<RawValueType | LabelValueType>(value) const values = toArray<RawValueType | LabelValueType>(value).slice().sort();
.slice()
.sort();
const cloneOptions = [...options]; const cloneOptions = [...options];
// Convert options value to set // Convert options value to set

View File

@ -137,9 +137,9 @@ function warningProps(props: SelectProps) {
if (invalidateChildType) { if (invalidateChildType) {
warning( warning(
false, false,
`\`children\` should be \`Select.Option\` or \`Select.OptGroup\` instead of \`${invalidateChildType.displayName || `\`children\` should be \`Select.Option\` or \`Select.OptGroup\` instead of \`${
invalidateChildType.name || invalidateChildType.displayName || invalidateChildType.name || invalidateChildType
invalidateChildType}\`.`, }\`.`,
); );
} }

View File

@ -14,7 +14,7 @@ function handler(options, handle, e) {
const PrevArrow = (_, { attrs }) => { const PrevArrow = (_, { attrs }) => {
const { clickHandler, infinite, currentSlide, slideCount, slidesToShow } = attrs; const { clickHandler, infinite, currentSlide, slideCount, slidesToShow } = attrs;
const prevClasses = { 'slick-arrow': true, 'slick-prev': true }; const prevClasses = { 'slick-arrow': true, 'slick-prev': true };
let prevHandler = function(e) { let prevHandler = function (e) {
handler({ message: 'previous' }, clickHandler, e); handler({ message: 'previous' }, clickHandler, e);
}; };
@ -67,7 +67,7 @@ const NextArrow = (_, { attrs }) => {
const { clickHandler, currentSlide, slideCount } = attrs; const { clickHandler, currentSlide, slideCount } = attrs;
const nextClasses = { 'slick-arrow': true, 'slick-next': true }; const nextClasses = { 'slick-arrow': true, 'slick-next': true };
let nextHandler = function(e) { let nextHandler = function (e) {
handler({ message: 'next' }, clickHandler, e); handler({ message: 'next' }, clickHandler, e);
}; };
if (!canGoNext(attrs)) { if (!canGoNext(attrs)) {

View File

@ -1,7 +1,7 @@
import classnames from '../../_util/classNames'; import classnames from '../../_util/classNames';
import { cloneElement } from '../../_util/vnode'; import { cloneElement } from '../../_util/vnode';
const getDotCount = function(spec) { const getDotCount = function (spec) {
let dots; let dots;
if (spec.infinite) { if (spec.infinite) {

View File

@ -56,7 +56,7 @@ export default defineComponent({
} }
}, },
beforeUnmount() { beforeUnmount() {
this._responsiveMediaHandlers.forEach(function(obj) { this._responsiveMediaHandlers.forEach(function (obj) {
obj.mql.removeListener(obj.listener); obj.mql.removeListener(obj.listener);
}); });
}, },

View File

@ -34,7 +34,7 @@ const getSlideClasses = spec => {
}; };
}; };
const getSlideStyle = function(spec) { const getSlideStyle = function (spec) {
const style = {}; const style = {};
if (spec.variableWidth === undefined || spec.variableWidth === false) { if (spec.variableWidth === undefined || spec.variableWidth === false) {
@ -76,7 +76,7 @@ const getSlideStyle = function(spec) {
const getKey = (child, fallbackKey) => child.key || (child.key === 0 && '0') || fallbackKey; const getKey = (child, fallbackKey) => child.key || (child.key === 0 && '0') || fallbackKey;
const renderSlides = function(spec, children) { const renderSlides = function (spec, children) {
let key; let key;
const slides = []; const slides = [];
const preCloneSlides = []; const preCloneSlides = [];

View File

@ -73,17 +73,8 @@ export default defineComponent({
}, },
}, },
render() { render() {
const { const { prefixCls, vertical, reverse, offset, disabled, min, max, value, tabindex } =
prefixCls, getOptionProps(this);
vertical,
reverse,
offset,
disabled,
min,
max,
value,
tabindex,
} = getOptionProps(this);
const className = classNames(this.$attrs.class, { const className = classNames(this.$attrs.class, {
[`${prefixCls}-handle-click-focused`]: this.clickFocused, [`${prefixCls}-handle-click-focused`]: this.clickFocused,
}); });

View File

@ -40,9 +40,8 @@ export default defineComponent({
this.__emit('stepClick', this.stepIndex); this.__emit('stepClick', this.stepIndex);
}, },
renderIconNode() { renderIconNode() {
const { prefixCls, stepNumber, status, iconPrefix, icons, progressDot } = getOptionProps( const { prefixCls, stepNumber, status, iconPrefix, icons, progressDot } =
this, getOptionProps(this);
);
const icon = getComponent(this, 'icon'); const icon = getComponent(this, 'icon');
const title = getComponent(this, 'title'); const title = getComponent(this, 'title');
const description = getComponent(this, 'description'); const description = getComponent(this, 'description');

Some files were not shown because too many files have changed in this diff Show More