chore: udpate lint, close #6896
parent
418d8b33dd
commit
deada0aeb8
|
@ -7,4 +7,6 @@ es/
|
||||||
lib/
|
lib/
|
||||||
_site/
|
_site/
|
||||||
dist/
|
dist/
|
||||||
|
site/dist/
|
||||||
components/version/version.tsx
|
components/version/version.tsx
|
||||||
|
site/src/router/demoRoutes.js
|
||||||
|
|
28
.eslintrc.js
28
.eslintrc.js
|
@ -15,9 +15,20 @@ module.exports = {
|
||||||
'plugin:vue/vue3-recommended',
|
'plugin:vue/vue3-recommended',
|
||||||
'plugin:import/recommended',
|
'plugin:import/recommended',
|
||||||
'plugin:import/typescript',
|
'plugin:import/typescript',
|
||||||
'prettier',
|
'@vue/typescript/recommended',
|
||||||
|
'@vue/prettier',
|
||||||
|
// 'prettier',
|
||||||
],
|
],
|
||||||
|
// extends: [
|
||||||
|
// 'eslint:recommended',
|
||||||
|
// 'plugin:vue/vue3-recommended',
|
||||||
|
// '@vue/typescript/recommended',
|
||||||
|
// '@vue/prettier',
|
||||||
|
// ],
|
||||||
plugins: ['markdown', 'jest', '@typescript-eslint', 'import'],
|
plugins: ['markdown', 'jest', '@typescript-eslint', 'import'],
|
||||||
|
globals: {
|
||||||
|
defineProps: 'readonly',
|
||||||
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
files: ['*.md'],
|
files: ['*.md'],
|
||||||
|
@ -28,12 +39,11 @@ module.exports = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['*.ts', '*.tsx'],
|
files: ['*.ts', '*.tsx'],
|
||||||
extends: ['@vue/typescript/recommended', '@vue/prettier', '@vue/prettier/@typescript-eslint'],
|
// extends: ['@vue/typescript/recommended', '@vue/prettier'],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: './tsconfig.json',
|
project: './tsconfig.json',
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/no-explicit-any': 0,
|
|
||||||
'@typescript-eslint/ban-types': 0,
|
'@typescript-eslint/ban-types': 0,
|
||||||
'@typescript-eslint/consistent-type-imports': 'error',
|
'@typescript-eslint/consistent-type-imports': 'error',
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 0,
|
'@typescript-eslint/explicit-module-boundary-types': 0,
|
||||||
|
@ -51,17 +61,21 @@ module.exports = {
|
||||||
parser: 'vue-eslint-parser',
|
parser: 'vue-eslint-parser',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
|
ecmaVersion: 2021,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'no-console': 'off',
|
'no-console': 'off',
|
||||||
'@typescript-eslint/no-unused-vars': [
|
'vue/no-reserved-component-names': 'off',
|
||||||
'error',
|
|
||||||
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
|
'@typescript-eslint/no-explicit-any': 0,
|
||||||
|
'@typescript-eslint/no-empty-function': 0,
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true, argsIgnorePattern: '^_' },
|
||||||
|
],
|
||||||
'import/no-named-as-default': 'off',
|
'import/no-named-as-default': 'off',
|
||||||
'import/namespace': [2, { allowComputed: true }],
|
'import/namespace': [2, { allowComputed: true }],
|
||||||
'import/no-named-as-default-member': 'off',
|
'import/no-named-as-default-member': 'off',
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { getOptionProps } from './props-util';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
setState(state = {}, callback) {
|
setState(state = {}, callback: () => any) {
|
||||||
let newState = typeof state === 'function' ? state(this.$data, this.$props) : state;
|
let newState = typeof state === 'function' ? state(this.$data, this.$props) : state;
|
||||||
if (this.getDerivedStateFromProps) {
|
if (this.getDerivedStateFromProps) {
|
||||||
const s = this.getDerivedStateFromProps(getOptionProps(this), {
|
const s = this.getDerivedStateFromProps(getOptionProps(this), {
|
||||||
|
@ -26,6 +26,7 @@ export default {
|
||||||
},
|
},
|
||||||
__emit() {
|
__emit() {
|
||||||
// 直接调用事件,底层组件不需要vueTool记录events
|
// 直接调用事件,底层组件不需要vueTool记录events
|
||||||
|
// eslint-disable-next-line prefer-rest-params
|
||||||
const args = [].slice.call(arguments, 0);
|
const args = [].slice.call(arguments, 0);
|
||||||
let eventName = args[0];
|
let eventName = args[0];
|
||||||
eventName = `on${eventName[0].toUpperCase()}${eventName.substring(1)}`;
|
eventName = `on${eventName[0].toUpperCase()}${eventName.substring(1)}`;
|
|
@ -1,8 +1,10 @@
|
||||||
function onCompositionStart(e) {
|
import type { Directive } from 'vue';
|
||||||
|
|
||||||
|
function onCompositionStart(e: any) {
|
||||||
e.target.composing = true;
|
e.target.composing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCompositionEnd(e) {
|
function onCompositionEnd(e: any) {
|
||||||
// prevent triggering an input event for no reason
|
// prevent triggering an input event for no reason
|
||||||
if (!e.target.composing) return;
|
if (!e.target.composing) return;
|
||||||
e.target.composing = false;
|
e.target.composing = false;
|
||||||
|
@ -15,10 +17,15 @@ function trigger(el, type) {
|
||||||
el.dispatchEvent(e);
|
el.dispatchEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addEventListener(el, event, handler, options) {
|
export function addEventListener(
|
||||||
|
el: HTMLElement,
|
||||||
|
event: string,
|
||||||
|
handler: EventListenerOrEventListenerObject,
|
||||||
|
options?: boolean | AddEventListenerOptions,
|
||||||
|
) {
|
||||||
el.addEventListener(event, handler, options);
|
el.addEventListener(event, handler, options);
|
||||||
}
|
}
|
||||||
const antInput = {
|
const antInput: Directive = {
|
||||||
created(el, binding) {
|
created(el, binding) {
|
||||||
if (!binding.modifiers || !binding.modifiers.lazy) {
|
if (!binding.modifiers || !binding.modifiers.lazy) {
|
||||||
addEventListener(el, 'compositionstart', onCompositionStart);
|
addEventListener(el, 'compositionstart', onCompositionStart);
|
|
@ -3,7 +3,7 @@
|
||||||
* https://github.com/akiran/json2mq.git
|
* https://github.com/akiran/json2mq.git
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const camel2hyphen = function (str) {
|
const camel2hyphen = function (str: string) {
|
||||||
return str
|
return str
|
||||||
.replace(/[A-Z]/g, function (match) {
|
.replace(/[A-Z]/g, function (match) {
|
||||||
return '-' + match.toLowerCase();
|
return '-' + match.toLowerCase();
|
||||||
|
@ -11,12 +11,12 @@ const camel2hyphen = function (str) {
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
};
|
};
|
||||||
|
|
||||||
const isDimension = function (feature) {
|
const isDimension = function (feature: string) {
|
||||||
const re = /[height|width]$/;
|
const re = /[height|width]$/;
|
||||||
return re.test(feature);
|
return re.test(feature);
|
||||||
};
|
};
|
||||||
|
|
||||||
const obj2mq = function (obj) {
|
const obj2mq = function (obj: { [x: string]: any }) {
|
||||||
let mq = '';
|
let mq = '';
|
||||||
const features = Object.keys(obj);
|
const features = Object.keys(obj);
|
||||||
features.forEach(function (feature, index) {
|
features.forEach(function (feature, index) {
|
||||||
|
@ -40,7 +40,7 @@ const obj2mq = function (obj) {
|
||||||
return mq;
|
return mq;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function (query) {
|
export default function (query: any[]) {
|
||||||
let mq = '';
|
let mq = '';
|
||||||
if (typeof query === 'string') {
|
if (typeof query === 'string') {
|
||||||
return query;
|
return query;
|
|
@ -1,19 +1,19 @@
|
||||||
import isPlainObject from 'lodash-es/isPlainObject';
|
|
||||||
import classNames from '../classNames';
|
import classNames from '../classNames';
|
||||||
import { isVNode, Fragment, Comment, Text, h } from 'vue';
|
import { isVNode, Fragment, Comment, Text } from 'vue';
|
||||||
import { camelize, hyphenate, isOn, resolvePropValue } from '../util';
|
import { camelize, hyphenate, isOn, resolvePropValue } from '../util';
|
||||||
import isValid from '../isValid';
|
import isValid from '../isValid';
|
||||||
import initDefaultProps from './initDefaultProps';
|
import initDefaultProps from './initDefaultProps';
|
||||||
|
import type { VueInstance } from '../hooks/_vueuse/unrefElement';
|
||||||
// function getType(fn) {
|
// function getType(fn) {
|
||||||
// const match = fn && fn.toString().match(/^\s*function (\w+)/);
|
// const match = fn && fn.toString().match(/^\s*function (\w+)/);
|
||||||
// return match ? match[1] : '';
|
// return match ? match[1] : '';
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const splitAttrs = attrs => {
|
const splitAttrs = (attrs: any) => {
|
||||||
const allAttrs = Object.keys(attrs);
|
const allAttrs = Object.keys(attrs);
|
||||||
const eventAttrs = {};
|
const eventAttrs: Record<string, any> = {};
|
||||||
const onEvents = {};
|
const onEvents: Record<string, any> = {};
|
||||||
const extraAttrs = {};
|
const extraAttrs: Record<string, any> = {};
|
||||||
for (let i = 0, l = allAttrs.length; i < l; i++) {
|
for (let i = 0, l = allAttrs.length; i < l; i++) {
|
||||||
const key = allAttrs[i];
|
const key = allAttrs[i];
|
||||||
if (isOn(key)) {
|
if (isOn(key)) {
|
||||||
|
@ -25,7 +25,7 @@ const splitAttrs = attrs => {
|
||||||
}
|
}
|
||||||
return { onEvents, events: eventAttrs, extraAttrs };
|
return { onEvents, events: eventAttrs, extraAttrs };
|
||||||
};
|
};
|
||||||
const parseStyleText = (cssText = '', camel) => {
|
const parseStyleText = (cssText = '', camel = false) => {
|
||||||
const res = {};
|
const res = {};
|
||||||
const listDelimiter = /;(?![^(]*\))/g;
|
const listDelimiter = /;(?![^(]*\))/g;
|
||||||
const propertyDelimiter = /:(.+)/;
|
const propertyDelimiter = /:(.+)/;
|
||||||
|
@ -42,34 +42,9 @@ const parseStyleText = (cssText = '', camel) => {
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasProp = (instance, prop) => {
|
const hasProp = (instance: any, prop: string) => {
|
||||||
return instance[prop] !== undefined;
|
return instance[prop] !== undefined;
|
||||||
};
|
};
|
||||||
// 重构后直接使用 hasProp 替换
|
|
||||||
const slotHasProp = (slot, prop) => {
|
|
||||||
return hasProp(slot, prop);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getScopedSlots = ele => {
|
|
||||||
return (ele.data && ele.data.scopedSlots) || {};
|
|
||||||
};
|
|
||||||
|
|
||||||
const getSlots = ele => {
|
|
||||||
let componentOptions = ele.componentOptions || {};
|
|
||||||
if (ele.$vnode) {
|
|
||||||
componentOptions = ele.$vnode.componentOptions || {};
|
|
||||||
}
|
|
||||||
const children = ele.children || componentOptions.children || [];
|
|
||||||
const slots = {};
|
|
||||||
children.forEach(child => {
|
|
||||||
if (!isEmptyElement(child)) {
|
|
||||||
const name = (child.data && child.data.slot) || 'default';
|
|
||||||
slots[name] = slots[name] || [];
|
|
||||||
slots[name].push(child);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return { ...slots, ...getScopedSlots(ele) };
|
|
||||||
};
|
|
||||||
|
|
||||||
export const skipFlattenKey = Symbol('skipFlatten');
|
export const skipFlattenKey = Symbol('skipFlatten');
|
||||||
const flattenChildren = (children = [], filterEmpty = true) => {
|
const flattenChildren = (children = [], filterEmpty = true) => {
|
||||||
|
@ -97,39 +72,29 @@ const flattenChildren = (children = [], filterEmpty = true) => {
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSlot = (self, name = 'default', options = {}) => {
|
const getSlot = (self: any, name = 'default', options = {}) => {
|
||||||
if (isVNode(self)) {
|
if (isVNode(self)) {
|
||||||
if (self.type === Fragment) {
|
if (self.type === Fragment) {
|
||||||
return name === 'default' ? flattenChildren(self.children) : [];
|
return name === 'default' ? flattenChildren(self.children as any[]) : [];
|
||||||
} else if (self.children && self.children[name]) {
|
} else if (self.children && self.children[name]) {
|
||||||
return flattenChildren(self.children[name](options));
|
return flattenChildren(self.children[name](options));
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let res = self.$slots[name] && self.$slots[name](options);
|
const res = self.$slots[name] && self.$slots[name](options);
|
||||||
return flattenChildren(res);
|
return flattenChildren(res);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAllChildren = ele => {
|
const findDOMNode = (instance: any) => {
|
||||||
let componentOptions = ele.componentOptions || {};
|
|
||||||
if (ele.$vnode) {
|
|
||||||
componentOptions = ele.$vnode.componentOptions || {};
|
|
||||||
}
|
|
||||||
return ele.children || componentOptions.children || [];
|
|
||||||
};
|
|
||||||
const getSlotOptions = () => {
|
|
||||||
throw Error('使用 .type 直接取值');
|
|
||||||
};
|
|
||||||
const findDOMNode = instance => {
|
|
||||||
let node = instance?.vnode?.el || (instance && (instance.$el || instance));
|
let node = instance?.vnode?.el || (instance && (instance.$el || instance));
|
||||||
while (node && !node.tagName) {
|
while (node && !node.tagName) {
|
||||||
node = node.nextSibling;
|
node = node.nextSibling;
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
const getOptionProps = instance => {
|
const getOptionProps = (instance: VueInstance) => {
|
||||||
const res = {};
|
const res = {};
|
||||||
if (instance.$ && instance.$.vnode) {
|
if (instance.$ && instance.$.vnode) {
|
||||||
const props = instance.$.vnode.props || {};
|
const props = instance.$.vnode.props || {};
|
||||||
|
@ -146,7 +111,7 @@ const getOptionProps = instance => {
|
||||||
Object.keys(originProps).forEach(key => {
|
Object.keys(originProps).forEach(key => {
|
||||||
props[camelize(key)] = originProps[key];
|
props[camelize(key)] = originProps[key];
|
||||||
});
|
});
|
||||||
const options = instance.type.props || {};
|
const options = (instance.type as any).props || {};
|
||||||
Object.keys(options).forEach(k => {
|
Object.keys(options).forEach(k => {
|
||||||
const v = resolvePropValue(options, props, k, props[k]);
|
const v = resolvePropValue(options, props, k, props[k]);
|
||||||
if (v !== undefined || k in props) {
|
if (v !== undefined || k in props) {
|
||||||
|
@ -156,7 +121,7 @@ const getOptionProps = instance => {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
const getComponent = (instance, prop = 'default', options = instance, execute = true) => {
|
const getComponent = (instance: any, prop = 'default', options = instance, execute = true) => {
|
||||||
let com = undefined;
|
let com = undefined;
|
||||||
if (instance.$) {
|
if (instance.$) {
|
||||||
const temp = instance[prop];
|
const temp = instance[prop];
|
||||||
|
@ -184,94 +149,13 @@ const getComponent = (instance, prop = 'default', options = instance, execute =
|
||||||
}
|
}
|
||||||
return com;
|
return com;
|
||||||
};
|
};
|
||||||
const getComponentFromProp = (instance, prop, options = instance, execute = true) => {
|
|
||||||
if (instance.$createElement) {
|
|
||||||
// const h = instance.$createElement;
|
|
||||||
const temp = instance[prop];
|
|
||||||
if (temp !== undefined) {
|
|
||||||
return typeof temp === 'function' && execute ? temp(h, options) : temp;
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
(instance.$scopedSlots[prop] && execute && instance.$scopedSlots[prop](options)) ||
|
|
||||||
instance.$scopedSlots[prop] ||
|
|
||||||
instance.$slots[prop] ||
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// const h = instance.context.$createElement;
|
|
||||||
const temp = getPropsData(instance)[prop];
|
|
||||||
if (temp !== undefined) {
|
|
||||||
return typeof temp === 'function' && execute ? temp(h, options) : temp;
|
|
||||||
}
|
|
||||||
const slotScope = getScopedSlots(instance)[prop];
|
|
||||||
if (slotScope !== undefined) {
|
|
||||||
return typeof slotScope === 'function' && execute ? slotScope(h, options) : slotScope;
|
|
||||||
}
|
|
||||||
const slotsProp = [];
|
|
||||||
const componentOptions = instance.componentOptions || {};
|
|
||||||
(componentOptions.children || []).forEach(child => {
|
|
||||||
if (child.data && child.data.slot === prop) {
|
|
||||||
if (child.data.attrs) {
|
|
||||||
delete child.data.attrs.slot;
|
|
||||||
}
|
|
||||||
if (child.tag === 'template') {
|
|
||||||
slotsProp.push(child.children);
|
|
||||||
} else {
|
|
||||||
slotsProp.push(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return slotsProp.length ? slotsProp : undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getAllProps = ele => {
|
const getKey = (ele: any) => {
|
||||||
let props = getOptionProps(ele);
|
const key = ele.key;
|
||||||
if (ele.$) {
|
|
||||||
props = { ...props, ...this.$attrs };
|
|
||||||
} else {
|
|
||||||
props = { ...ele.props, ...props };
|
|
||||||
}
|
|
||||||
return props;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getPropsData = ins => {
|
|
||||||
const vnode = ins.$ ? ins.$ : ins;
|
|
||||||
const res = {};
|
|
||||||
const originProps = vnode.props || {};
|
|
||||||
const props = {};
|
|
||||||
Object.keys(originProps).forEach(key => {
|
|
||||||
props[camelize(key)] = originProps[key];
|
|
||||||
});
|
|
||||||
const options = isPlainObject(vnode.type) ? vnode.type.props : {};
|
|
||||||
options &&
|
|
||||||
Object.keys(options).forEach(k => {
|
|
||||||
const v = resolvePropValue(options, props, k, props[k]);
|
|
||||||
if (k in props) {
|
|
||||||
// 仅包含 props,不包含默认值
|
|
||||||
res[k] = v;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return { ...props, ...res }; // 合并事件、未声明属性等
|
|
||||||
};
|
|
||||||
const getValueByProp = (ele, prop) => {
|
|
||||||
return getPropsData(ele)[prop];
|
|
||||||
};
|
|
||||||
|
|
||||||
const getAttrs = ele => {
|
|
||||||
let data = ele.data;
|
|
||||||
if (ele.$vnode) {
|
|
||||||
data = ele.$vnode.data;
|
|
||||||
}
|
|
||||||
return data ? data.attrs || {} : {};
|
|
||||||
};
|
|
||||||
|
|
||||||
const getKey = ele => {
|
|
||||||
let key = ele.key;
|
|
||||||
return key;
|
return key;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getEvents(ele = {}, on = true) {
|
export function getEvents(ele: any = {}, on = true) {
|
||||||
let props = {};
|
let props = {};
|
||||||
if (ele.$) {
|
if (ele.$) {
|
||||||
props = { ...props, ...ele.$attrs };
|
props = { ...props, ...ele.$attrs };
|
||||||
|
@ -281,27 +165,9 @@ export function getEvents(ele = {}, on = true) {
|
||||||
return splitAttrs(props)[on ? 'onEvents' : 'events'];
|
return splitAttrs(props)[on ? 'onEvents' : 'events'];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getEvent(child, event) {
|
export function getClass(ele: any) {
|
||||||
return child.props && child.props[event];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取 xxx.native 或者 原生标签 事件
|
|
||||||
export function getDataEvents(child) {
|
|
||||||
let events = {};
|
|
||||||
if (child.data && child.data.on) {
|
|
||||||
events = child.data.on;
|
|
||||||
}
|
|
||||||
return { ...events };
|
|
||||||
}
|
|
||||||
|
|
||||||
// use getListeners instead this.$listeners
|
|
||||||
// https://github.com/vueComponent/ant-design-vue/issues/1705
|
|
||||||
export function getListeners(context) {
|
|
||||||
return (context.$vnode ? context.$vnode.componentOptions.listeners : context.$listeners) || {};
|
|
||||||
}
|
|
||||||
export function getClass(ele) {
|
|
||||||
const props = (isVNode(ele) ? ele.props : ele.$attrs) || {};
|
const props = (isVNode(ele) ? ele.props : ele.$attrs) || {};
|
||||||
let tempCls = props.class || {};
|
const tempCls = props.class || {};
|
||||||
let cls = {};
|
let cls = {};
|
||||||
if (typeof tempCls === 'string') {
|
if (typeof tempCls === 'string') {
|
||||||
tempCls.split(' ').forEach(c => {
|
tempCls.split(' ').forEach(c => {
|
||||||
|
@ -318,7 +184,7 @@ export function getClass(ele) {
|
||||||
}
|
}
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
export function getStyle(ele, camel) {
|
export function getStyle(ele: any, camel?: boolean) {
|
||||||
const props = (isVNode(ele) ? ele.props : ele.$attrs) || {};
|
const props = (isVNode(ele) ? ele.props : ele.$attrs) || {};
|
||||||
let style = props.style || {};
|
let style = props.style || {};
|
||||||
if (typeof style === 'string') {
|
if (typeof style === 'string') {
|
||||||
|
@ -332,19 +198,19 @@ export function getStyle(ele, camel) {
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getComponentName(opts) {
|
export function getComponentName(opts: any) {
|
||||||
return opts && (opts.Ctor.options.name || opts.tag);
|
return opts && (opts.Ctor.options.name || opts.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFragment(c) {
|
export function isFragment(c: any) {
|
||||||
return c.length === 1 && c[0].type === Fragment;
|
return c.length === 1 && c[0].type === Fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isEmptyContent(c) {
|
export function isEmptyContent(c: any) {
|
||||||
return c === undefined || c === null || c === '' || (Array.isArray(c) && c.length === 0);
|
return c === undefined || c === null || c === '' || (Array.isArray(c) && c.length === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isEmptyElement(c) {
|
export function isEmptyElement(c: any) {
|
||||||
return (
|
return (
|
||||||
c &&
|
c &&
|
||||||
(c.type === Comment ||
|
(c.type === Comment ||
|
||||||
|
@ -353,11 +219,11 @@ export function isEmptyElement(c) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isEmptySlot(c) {
|
export function isEmptySlot(c: any) {
|
||||||
return !c || c().every(isEmptyElement);
|
return !c || c().every(isEmptyElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isStringElement(c) {
|
export function isStringElement(c: any) {
|
||||||
return c && c.type === Text;
|
return c && c.type === Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +241,7 @@ export function filterEmpty(children = []) {
|
||||||
return res.filter(c => !isEmptyElement(c));
|
return res.filter(c => !isEmptyElement(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function filterEmptyWithUndefined(children) {
|
export function filterEmptyWithUndefined(children: any[]) {
|
||||||
if (children) {
|
if (children) {
|
||||||
const coms = filterEmpty(children);
|
const coms = filterEmpty(children);
|
||||||
return coms.length ? coms : undefined;
|
return coms.length ? coms : undefined;
|
||||||
|
@ -384,34 +250,18 @@ export function filterEmptyWithUndefined(children) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mergeProps() {
|
function isValidElement(element: any) {
|
||||||
const args = [].slice.call(arguments, 0);
|
|
||||||
const props = {};
|
|
||||||
args.forEach((p = {}) => {
|
|
||||||
for (const [k, v] of Object.entries(p)) {
|
|
||||||
props[k] = props[k] || {};
|
|
||||||
if (isPlainObject(v)) {
|
|
||||||
Object.assign(props[k], v);
|
|
||||||
} else {
|
|
||||||
props[k] = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return props;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isValidElement(element) {
|
|
||||||
if (Array.isArray(element) && element.length === 1) {
|
if (Array.isArray(element) && element.length === 1) {
|
||||||
element = element[0];
|
element = element[0];
|
||||||
}
|
}
|
||||||
return element && element.__v_isVNode && typeof element.type !== 'symbol'; // remove text node
|
return element && element.__v_isVNode && typeof element.type !== 'symbol'; // remove text node
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPropsSlot(slots, props, prop = 'default') {
|
function getPropsSlot(slots: any, props: any, prop = 'default') {
|
||||||
return props[prop] ?? slots[prop]?.();
|
return props[prop] ?? slots[prop]?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTextFromElement = ele => {
|
export const getTextFromElement = (ele: any) => {
|
||||||
if (isValidElement(ele) && isStringElement(ele[0])) {
|
if (isValidElement(ele) && isStringElement(ele[0])) {
|
||||||
return ele[0].children;
|
return ele[0].children;
|
||||||
}
|
}
|
||||||
|
@ -422,21 +272,12 @@ export {
|
||||||
hasProp,
|
hasProp,
|
||||||
getOptionProps,
|
getOptionProps,
|
||||||
getComponent,
|
getComponent,
|
||||||
getComponentFromProp,
|
|
||||||
getSlotOptions,
|
|
||||||
slotHasProp,
|
|
||||||
getPropsData,
|
|
||||||
getKey,
|
getKey,
|
||||||
getAttrs,
|
|
||||||
getValueByProp,
|
|
||||||
parseStyleText,
|
parseStyleText,
|
||||||
initDefaultProps,
|
initDefaultProps,
|
||||||
isValidElement,
|
isValidElement,
|
||||||
camelize,
|
camelize,
|
||||||
getSlots,
|
|
||||||
getSlot,
|
getSlot,
|
||||||
getAllProps,
|
|
||||||
getAllChildren,
|
|
||||||
findDOMNode,
|
findDOMNode,
|
||||||
flattenChildren,
|
flattenChildren,
|
||||||
getPropsSlot,
|
getPropsSlot,
|
|
@ -59,7 +59,7 @@ const formState = reactive<FormState>({
|
||||||
checkPass: '',
|
checkPass: '',
|
||||||
age: undefined,
|
age: undefined,
|
||||||
});
|
});
|
||||||
let checkAge = async (_rule: Rule, value: number) => {
|
const checkAge = async (_rule: Rule, value: number) => {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return Promise.reject('Please input the age');
|
return Promise.reject('Please input the age');
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ let checkAge = async (_rule: Rule, value: number) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let validatePass = async (_rule: Rule, value: string) => {
|
const validatePass = async (_rule: Rule, value: string) => {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
return Promise.reject('Please input the password');
|
return Promise.reject('Please input the password');
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,7 +83,7 @@ let validatePass = async (_rule: Rule, value: string) => {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let validatePass2 = async (_rule: Rule, value: string) => {
|
const validatePass2 = async (_rule: Rule, value: string) => {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
return Promise.reject('Please input the password again');
|
return Promise.reject('Please input the password again');
|
||||||
} else if (value !== formState.pass) {
|
} else if (value !== formState.pass) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ const resetForm = () => {
|
||||||
formRef.value.resetFields();
|
formRef.value.resetFields();
|
||||||
};
|
};
|
||||||
const removeDomain = (item: Domain) => {
|
const removeDomain = (item: Domain) => {
|
||||||
let index = dynamicValidateForm.domains.indexOf(item);
|
const index = dynamicValidateForm.domains.indexOf(item);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
dynamicValidateForm.domains.splice(index, 1);
|
dynamicValidateForm.domains.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ watch(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const removeSight = (item: Sights) => {
|
const removeSight = (item: Sights) => {
|
||||||
let index = dynamicValidateForm.sights.indexOf(item);
|
const index = dynamicValidateForm.sights.indexOf(item);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
dynamicValidateForm.sights.splice(index, 1);
|
dynamicValidateForm.sights.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ const dynamicValidateForm = reactive<{ users: User[] }>({
|
||||||
users: [],
|
users: [],
|
||||||
});
|
});
|
||||||
const removeUser = (item: User) => {
|
const removeUser = (item: User) => {
|
||||||
let index = dynamicValidateForm.users.indexOf(item);
|
const index = dynamicValidateForm.users.indexOf(item);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
dynamicValidateForm.users.splice(index, 1);
|
dynamicValidateForm.users.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ Input type of password.
|
||||||
<a-space direction="vertical" size="middle" style="width: 100%">
|
<a-space direction="vertical" size="middle" style="width: 100%">
|
||||||
<a-input-password v-model:value="value" placeholder="input password" />
|
<a-input-password v-model:value="value" placeholder="input password" />
|
||||||
<a-input-password v-model:value="value2" placeholder="input password">
|
<a-input-password v-model:value="value2" placeholder="input password">
|
||||||
<template #iconRender="visible">
|
<template #iconRender="v">
|
||||||
<EyeTwoTone v-if="visible"></EyeTwoTone>
|
<EyeTwoTone v-if="v"></EyeTwoTone>
|
||||||
<EyeInvisibleOutlined v-else></EyeInvisibleOutlined>
|
<EyeInvisibleOutlined v-else></EyeInvisibleOutlined>
|
||||||
</template>
|
</template>
|
||||||
</a-input-password>
|
</a-input-password>
|
||||||
|
|
|
@ -76,7 +76,7 @@ const state = reactive({
|
||||||
});
|
});
|
||||||
const onOpenChange = (openKeys: string[]) => {
|
const onOpenChange = (openKeys: string[]) => {
|
||||||
const latestOpenKey = openKeys.find(key => state.openKeys.indexOf(key) === -1);
|
const latestOpenKey = openKeys.find(key => state.openKeys.indexOf(key) === -1);
|
||||||
if (state.rootSubmenuKeys.indexOf(latestOpenKey!) === -1) {
|
if (state.rootSubmenuKeys.indexOf(latestOpenKey) === -1) {
|
||||||
state.openKeys = openKeys;
|
state.openKeys = openKeys;
|
||||||
} else {
|
} else {
|
||||||
state.openKeys = latestOpenKey ? [latestOpenKey] : [];
|
state.openKeys = latestOpenKey ? [latestOpenKey] : [];
|
||||||
|
|
|
@ -109,7 +109,7 @@ const handleTableChange: TableProps['onChange'] = (
|
||||||
sorter: any,
|
sorter: any,
|
||||||
) => {
|
) => {
|
||||||
run({
|
run({
|
||||||
results: pag.pageSize!,
|
results: pag.pageSize,
|
||||||
page: pag?.current,
|
page: pag?.current,
|
||||||
sortField: sorter.field,
|
sortField: sorter.field,
|
||||||
sortOrder: sorter.order,
|
sortOrder: sorter.order,
|
||||||
|
|
|
@ -42,18 +42,18 @@ const Dots = (_, { attrs }) => {
|
||||||
const mouseEvents = { onMouseenter, onMouseover, onMouseleave };
|
const mouseEvents = { onMouseenter, onMouseover, onMouseleave };
|
||||||
let dots = [];
|
let dots = [];
|
||||||
for (let i = 0; i < dotCount; i++) {
|
for (let i = 0; i < dotCount; i++) {
|
||||||
let _rightBound = (i + 1) * slidesToScroll - 1;
|
const _rightBound = (i + 1) * slidesToScroll - 1;
|
||||||
let rightBound = infinite ? _rightBound : clamp(_rightBound, 0, slideCount - 1);
|
const rightBound = infinite ? _rightBound : clamp(_rightBound, 0, slideCount - 1);
|
||||||
let _leftBound = rightBound - (slidesToScroll - 1);
|
const _leftBound = rightBound - (slidesToScroll - 1);
|
||||||
let leftBound = infinite ? _leftBound : clamp(_leftBound, 0, slideCount - 1);
|
const leftBound = infinite ? _leftBound : clamp(_leftBound, 0, slideCount - 1);
|
||||||
|
|
||||||
let className = classnames({
|
const className = classnames({
|
||||||
'slick-active': infinite
|
'slick-active': infinite
|
||||||
? currentSlide >= leftBound && currentSlide <= rightBound
|
? currentSlide >= leftBound && currentSlide <= rightBound
|
||||||
: currentSlide === leftBound,
|
: currentSlide === leftBound,
|
||||||
});
|
});
|
||||||
|
|
||||||
let dotOptions = {
|
const dotOptions = {
|
||||||
message: 'dots',
|
message: 'dots',
|
||||||
index: i,
|
index: i,
|
||||||
slidesToScroll,
|
slidesToScroll,
|
||||||
|
|
|
@ -310,7 +310,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
checkImagesLoad() {
|
checkImagesLoad() {
|
||||||
let images =
|
const images =
|
||||||
(this.list &&
|
(this.list &&
|
||||||
this.list.querySelectorAll &&
|
this.list.querySelectorAll &&
|
||||||
this.list.querySelectorAll('.slick-slide img')) ||
|
this.list.querySelectorAll('.slick-slide img')) ||
|
||||||
|
|
10
package.json
10
package.json
|
@ -128,10 +128,10 @@
|
||||||
"@vitejs/plugin-vue": "^3.0.0",
|
"@vitejs/plugin-vue": "^3.0.0",
|
||||||
"@vitejs/plugin-vue-jsx": "^2.0.0",
|
"@vitejs/plugin-vue-jsx": "^2.0.0",
|
||||||
"@vue/babel-plugin-jsx": "^1.0.0",
|
"@vue/babel-plugin-jsx": "^1.0.0",
|
||||||
"@vue/cli-plugin-eslint": "^5.0.0-0",
|
"@vue/cli-plugin-eslint": "^5.0.0",
|
||||||
"@vue/compiler-sfc": "^3.2.0",
|
"@vue/compiler-sfc": "^3.2.0",
|
||||||
"@vue/eslint-config-prettier": "^6.0.0",
|
"@vue/eslint-config-prettier": "^8.0.0",
|
||||||
"@vue/eslint-config-typescript": "^9.0.0",
|
"@vue/eslint-config-typescript": "^11.0.0",
|
||||||
"@vue/test-utils": "^2.0.2",
|
"@vue/test-utils": "^2.0.2",
|
||||||
"@vue/vue3-jest": "28",
|
"@vue/vue3-jest": "28",
|
||||||
"@vueuse/core": "^8.3.1",
|
"@vueuse/core": "^8.3.1",
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
"eslint-plugin-markdown": "^2.0.0",
|
"eslint-plugin-markdown": "^2.0.0",
|
||||||
"eslint-plugin-no-explicit-type-exports": "^0.12.0",
|
"eslint-plugin-no-explicit-type-exports": "^0.12.0",
|
||||||
"eslint-plugin-prettier": "^3.1.0",
|
"eslint-plugin-prettier": "^3.1.0",
|
||||||
"eslint-plugin-vue": "^8.1.1",
|
"eslint-plugin-vue": "^9.17.0",
|
||||||
"fast-glob": "^3.2.7",
|
"fast-glob": "^3.2.7",
|
||||||
"fetch-jsonp": "^1.1.3",
|
"fetch-jsonp": "^1.1.3",
|
||||||
"fs-extra": "^10.0.0",
|
"fs-extra": "^10.0.0",
|
||||||
|
@ -261,7 +261,7 @@
|
||||||
"vue": "^3.2.0",
|
"vue": "^3.2.0",
|
||||||
"vue-clipboard2": "0.3.3",
|
"vue-clipboard2": "0.3.3",
|
||||||
"vue-drag-resize": "^2.0.3",
|
"vue-drag-resize": "^2.0.3",
|
||||||
"vue-eslint-parser": "^8.0.0",
|
"vue-eslint-parser": "^9.3.1",
|
||||||
"vue-i18n": "^9.1.7",
|
"vue-i18n": "^9.1.7",
|
||||||
"vue-infinite-scroll": "^2.0.2",
|
"vue-infinite-scroll": "^2.0.2",
|
||||||
"vue-loader": "^17.0.0",
|
"vue-loader": "^17.0.0",
|
||||||
|
|
Loading…
Reference in New Issue