style: lint format

pull/5820/head
tangjinzhou 2022-05-22 16:39:57 +08:00
parent 37d35f7801
commit 5b583962db
11 changed files with 46 additions and 17 deletions

View File

@ -71,6 +71,7 @@ const getSlots = ele => {
return { ...slots, ...getScopedSlots(ele) }; return { ...slots, ...getScopedSlots(ele) };
}; };
export const skipFlattenKey = Symbol('skipFlatten');
const flattenChildren = (children = [], filterEmpty = true) => { const flattenChildren = (children = [], filterEmpty = true) => {
const temp = Array.isArray(children) ? children : [children]; const temp = Array.isArray(children) ? children : [children];
const res = []; const res = [];
@ -78,7 +79,7 @@ const flattenChildren = (children = [], filterEmpty = true) => {
if (Array.isArray(child)) { if (Array.isArray(child)) {
res.push(...flattenChildren(child, filterEmpty)); res.push(...flattenChildren(child, filterEmpty));
} else if (child && child.type === Fragment) { } else if (child && child.type === Fragment) {
if (child.props && child.props.skipFlatten) { if (child.key === skipFlattenKey) {
res.push(child); res.push(child);
} else { } else {
res.push(...flattenChildren(child.children, filterEmpty)); res.push(...flattenChildren(child.children, filterEmpty));

View File

@ -11,7 +11,7 @@ export default defineComponent({
useProvideRadioOptionTypeContext('button'); useProvideRadioOptionTypeContext('button');
return () => { return () => {
return ( return (
<Radio {...props} prefixCls={prefixCls.value} type="radio"> <Radio {...props} prefixCls={prefixCls.value}>
{slots.default?.()} {slots.default?.()}
</Radio> </Radio>
); );

View File

@ -50,7 +50,6 @@ export const listItemProps = () => {
}; };
export type ListItemProps = Partial<ExtractPropTypes<ReturnType<typeof listItemProps>>>; export type ListItemProps = Partial<ExtractPropTypes<ReturnType<typeof listItemProps>>>;
export default defineComponent({ export default defineComponent({
name: 'ListItem', name: 'ListItem',
inheritAttrs: false, inheritAttrs: false,
@ -110,7 +109,7 @@ export default defineComponent({
src={file.thumbUrl || file.url} src={file.thumbUrl || file.url}
alt={file.name} alt={file.name}
class={`${prefixCls}-list-item-image`} class={`${prefixCls}-list-item-image`}
crossOrigin={file.crossOrigin} crossorigin={file.crossOrigin}
/> />
) : ( ) : (
iconNode iconNode

View File

@ -4,7 +4,7 @@ import type {
} from '../vc-upload/interface'; } from '../vc-upload/interface';
import type { ProgressProps } from '../progress'; import type { ProgressProps } from '../progress';
import type { VueNode } from '../_util/type'; import type { VueNode } from '../_util/type';
import type { ExtractPropTypes, PropType, CSSProperties } from 'vue'; import type { ExtractPropTypes, PropType, CSSProperties, ImgHTMLAttributes } from 'vue';
export interface FileType extends OriRcFile { export interface FileType extends OriRcFile {
readonly lastModifiedDate: Date; readonly lastModifiedDate: Date;
@ -27,7 +27,7 @@ export interface UploadFile<T = any> {
status?: UploadFileStatus; status?: UploadFileStatus;
percent?: number; percent?: number;
thumbUrl?: string; thumbUrl?: string;
crossOrigin?: HTMLImageElement['crossOrigin']; crossOrigin?: ImgHTMLAttributes['crossorigin'];
originFileObj?: FileType; originFileObj?: FileType;
response?: T; response?: T;
error?: any; error?: any;

View File

@ -5,6 +5,7 @@ import Trigger from '../vc-trigger';
import placements from './placements'; import placements from './placements';
import { cloneElement } from '../_util/vnode'; import { cloneElement } from '../_util/vnode';
import classNames from '../_util/classNames'; import classNames from '../_util/classNames';
import { skipFlattenKey } from '../_util/props-util';
export default defineComponent({ export default defineComponent({
props: { props: {
@ -72,7 +73,7 @@ export default defineComponent({
getPopupContainer: () => triggerRef.value.getPopupDomNode(), getPopupContainer: () => triggerRef.value.getPopupDomNode(),
}; };
return ( return (
<Fragment skipFlatten> <Fragment key={skipFlattenKey}>
{props.arrow && <div class={`${props.prefixCls}-arrow`} />} {props.arrow && <div class={`${props.prefixCls}-arrow`} />}
{cloneElement(overlayElement, extraOverlayProps, false)} {cloneElement(overlayElement, extraOverlayProps, false)}
</Fragment> </Fragment>

View File

@ -1,3 +1,4 @@
import type { CSSProperties } from 'vue';
import { defineComponent, ref } from 'vue'; import { defineComponent, ref } from 'vue';
import classNames from '../_util/classNames'; import classNames from '../_util/classNames';
import type { MouseEventHandler } from '../_util/EventInterface'; import type { MouseEventHandler } from '../_util/EventInterface';
@ -101,7 +102,7 @@ export default defineComponent({
element = ( element = (
<span <span
class={affixWrapperCls} class={affixWrapperCls}
style={attrs.style} style={attrs.style as CSSProperties}
hidden={!hasAddon({ addonAfter, addonBefore }) && hidden} hidden={!hasAddon({ addonAfter, addonBefore }) && hidden}
onMousedown={onInputMouseDown} onMousedown={onInputMouseDown}
ref={containerRef} ref={containerRef}
@ -136,7 +137,7 @@ export default defineComponent({
// Need another wrapper for changing display:table to display:inline-block // Need another wrapper for changing display:table to display:inline-block
// and put style prop in wrapper // and put style prop in wrapper
return ( return (
<span class={mergedGroupClassName} style={attrs.style} hidden={hidden}> <span class={mergedGroupClassName} style={attrs.style as CSSProperties} hidden={hidden}>
<span class={mergedWrapperClassName}> <span class={mergedWrapperClassName}>
{addonBefore && <span class={addonCls}>{addonBefore}</span>} {addonBefore && <span class={addonCls}>{addonBefore}</span>}
{cloneElement(element, { style: null, hidden: null })} {cloneElement(element, { style: null, hidden: null })}

View File

@ -30,7 +30,7 @@ import { conductCheck } from '../vc-tree/utils/conductUtil';
import { warning } from '../vc-util/warning'; import { warning } from '../vc-util/warning';
import { toReactive } from '../_util/toReactive'; import { toReactive } from '../_util/toReactive';
import useMaxLevel from '../vc-tree/useMaxLevel'; import useMaxLevel from '../vc-tree/useMaxLevel';
import type { ExpandAction } from '../tree/DirectoryTree'; import type { ExpandAction } from '../vc-tree/props';
export type OnInternalSelect = (value: RawValueType, info: { selected: boolean }) => void; export type OnInternalSelect = (value: RawValueType, info: { selected: boolean }) => void;

View File

@ -1,6 +1,6 @@
import type { InjectionKey } from 'vue'; import type { InjectionKey } from 'vue';
import { provide, inject } from 'vue'; import { provide, inject } from 'vue';
import type { ExpandAction } from '../tree/DirectoryTree'; import type { ExpandAction } from '../vc-tree/props';
import type { DefaultOptionType, InternalFieldName, OnInternalSelect } from './TreeSelect'; import type { DefaultOptionType, InternalFieldName, OnInternalSelect } from './TreeSelect';
export interface TreeSelectContextProps { export interface TreeSelectContextProps {

View File

@ -65,6 +65,7 @@ export default defineComponent({
disabled: false, disabled: false,
checkStrictly: false, checkStrictly: false,
draggable: false, draggable: false,
expandAction: false,
defaultExpandParent: true, defaultExpandParent: true,
autoExpandParent: false, autoExpandParent: false,
defaultExpandAll: false, defaultExpandAll: false,
@ -617,16 +618,34 @@ export default defineComponent({
dragNode = null; dragNode = null;
}; };
const triggerExpandActionExpand: NodeMouseEventHandler = (e, treeNode) => {
const { expanded, key } = treeNode;
const node = flattenNodes.value.filter(nodeItem => nodeItem.key === key)[0];
const eventNode = convertNodePropsToEventData({
...getTreeNodeProps(key, treeNodeRequiredProps.value),
data: node.data,
});
setExpandedKeys(expanded ? arrDel(expandedKeys.value, key) : arrAdd(expandedKeys.value, key));
onNodeExpand(e, eventNode);
};
const onNodeClick: NodeMouseEventHandler = (e, treeNode) => { const onNodeClick: NodeMouseEventHandler = (e, treeNode) => {
const { onClick } = props; const { onClick, expandAction } = props;
if (expandAction === 'click') {
triggerExpandActionExpand(e, treeNode);
}
if (onClick) { if (onClick) {
onClick(e, treeNode); onClick(e, treeNode);
} }
}; };
const onNodeDoubleClick: NodeMouseEventHandler = (e, treeNode) => { const onNodeDoubleClick: NodeMouseEventHandler = (e, treeNode) => {
const { onDblclick } = props; const { onDblclick, expandAction } = props;
if (expandAction === 'doubleclick' || expandAction === 'dblclick') {
triggerExpandActionExpand(e, treeNode);
}
if (onDblclick) { if (onDblclick) {
onDblclick(e, treeNode); onDblclick(e, treeNode);
} }
@ -1107,6 +1126,8 @@ export default defineComponent({
onContextmenu, onContextmenu,
onScroll, onScroll,
direction, direction,
rootClassName,
rootStyle,
} = props; } = props;
const { class: className, style } = attrs; const { class: className, style } = attrs;
@ -1179,11 +1200,12 @@ export default defineComponent({
> >
<div <div
role="tree" role="tree"
class={classNames(prefixCls, className, { class={classNames(prefixCls, className, rootClassName, {
[`${prefixCls}-show-line`]: showLine, [`${prefixCls}-show-line`]: showLine,
[`${prefixCls}-focused`]: focused.value, [`${prefixCls}-focused`]: focused.value,
[`${prefixCls}-active-focused`]: activeKey.value !== null, [`${prefixCls}-active-focused`]: activeKey.value !== null,
})} })}
style={rootStyle}
> >
<NodeList <NodeList
ref={listRef} ref={listRef}

View File

@ -1,4 +1,4 @@
// base rc-tree 5.4.4 // base rc-tree 5.6.3
import type { TreeProps, TreeNodeProps } from './props'; import type { TreeProps, TreeNodeProps } from './props';
import Tree from './Tree'; import Tree from './Tree';
import TreeNode from './TreeNode'; import TreeNode from './TreeNode';

View File

@ -1,4 +1,4 @@
import type { ExtractPropTypes, PropType } from 'vue'; import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';
import type { BasicDataNode } from '.'; import type { BasicDataNode } from '.';
import type { EventHandler } from '../_util/EventInterface'; import type { EventHandler } from '../_util/EventInterface';
import PropTypes from '../_util/vue-types'; import PropTypes from '../_util/vue-types';
@ -110,6 +110,7 @@ export type AllowDrop<TreeDataType extends BasicDataNode = DataNode> = (
) => boolean; ) => boolean;
export type DraggableFn = (node: DataNode) => boolean; export type DraggableFn = (node: DataNode) => boolean;
export type ExpandAction = false | 'click' | 'doubleclick' | 'dblclick';
export const treeProps = () => ({ export const treeProps = () => ({
prefixCls: String, prefixCls: String,
focusable: { type: Boolean, default: undefined }, focusable: { type: Boolean, default: undefined },
@ -125,6 +126,7 @@ export const treeProps = () => ({
showIcon: { type: Boolean, default: undefined }, showIcon: { type: Boolean, default: undefined },
icon: PropTypes.any, icon: PropTypes.any,
selectable: { type: Boolean, default: undefined }, selectable: { type: Boolean, default: undefined },
expandAction: [String, Boolean] as PropType<ExpandAction>,
disabled: { type: Boolean, default: undefined }, disabled: { type: Boolean, default: undefined },
multiple: { type: Boolean, default: undefined }, multiple: { type: Boolean, default: undefined },
checkable: { type: Boolean, default: undefined }, checkable: { type: Boolean, default: undefined },
@ -203,7 +205,7 @@ export const treeProps = () => ({
) => void ) => void
>, >,
}, },
loadData: { type: Function as PropType<(treeNode: EventDataNode) => Promise<void>> }, loadData: { type: Function as PropType<(treeNode: EventDataNode) => Promise<any>> },
loadedKeys: { type: Array as PropType<Key[]> }, loadedKeys: { type: Array as PropType<Key[]> },
onMouseenter: { type: Function as PropType<(info: NodeMouseEventParams) => void> }, onMouseenter: { type: Function as PropType<(info: NodeMouseEventParams) => void> },
onMouseleave: { type: Function as PropType<(info: NodeMouseEventParams) => void> }, onMouseleave: { type: Function as PropType<(info: NodeMouseEventParams) => void> },
@ -245,6 +247,9 @@ export const treeProps = () => ({
// direction for drag logic // direction for drag logic
direction: { type: String as PropType<Direction> }, direction: { type: String as PropType<Direction> },
rootClassName: String,
rootStyle: Object as PropType<CSSProperties>,
}); });
export type TreeProps = Partial<ExtractPropTypes<ReturnType<typeof treeProps>>>; export type TreeProps = Partial<ExtractPropTypes<ReturnType<typeof treeProps>>>;