Skip to content

Commit

Permalink
fix: unit coding style && name to import (#333)
Browse files Browse the repository at this point in the history
* fix: unit coding style && name to import

* fix: update contextMenu snapshot

---------

Co-authored-by: beier <beier@dtstack.com>
  • Loading branch information
shiqiWang0 and beier committed May 5, 2023
1 parent 20183e2 commit 02dd422
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 92 deletions.
12 changes: 6 additions & 6 deletions src/blockHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, ReactNode } from 'react';
import { QuestionCircleOutlined, UpOutlined } from '@ant-design/icons';
import { Tooltip } from 'antd';
import classNames from 'classnames';
Expand All @@ -10,13 +10,13 @@ export interface IBlockHeaderProps {
// 标题
title: string;
// 标题前的图标,默认是一个色块
beforeTitle?: React.ReactNode;
beforeTitle?: ReactNode;
// 标题后的提示图标或文案
afterTitle?: React.ReactNode;
afterTitle?: ReactNode;
// 默认展示为问号的tooltip
tooltip?: React.ReactNode;
tooltip?: ReactNode;
// 后缀自定义内容块
addonAfter?: React.ReactNode;
addonAfter?: ReactNode;
/**
* 小标题 font-size: 12px; line-height: 32px
* 中标题 font-size: 14px; line-height: 40px
Expand All @@ -35,7 +35,7 @@ export interface IBlockHeaderProps {
defaultExpand?: boolean;
// 展开/收起时的回调
onChange?: (expand: boolean) => void;
children?: React.ReactNode;
children?: ReactNode;
}
const BlockHeader: React.FC<IBlockHeaderProps> = function (props) {
const prefixCls = 'dtc-block-header';
Expand Down
10 changes: 5 additions & 5 deletions src/collapsibleActionItems/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React from 'react';
import React, { ReactNode } from 'react';
import { Button, ButtonProps, Divider, Dropdown, DropDownProps, Menu } from 'antd';
import { EllipsisOutlined } from '@ant-design/icons';

type ActionItem = {
key: React.Key;
name: React.ReactNode;
name: ReactNode;
disabled?: boolean;
render?: () => React.ReactNode;
render?: () => ReactNode;
[propName: string]: any;
};

interface ICollapsibleActionItems {
maxCount?: number; // 最多展示数量,超出折叠到下拉菜单中
actionItems: ActionItem[];
className?: string;
divider?: React.ReactNode; // 分隔符
collapseIcon?: React.ReactNode; // 折叠菜单图标
divider?: ReactNode; // 分隔符
collapseIcon?: ReactNode; // 折叠菜单图标
dropdownProps?: Partial<DropDownProps>;
buttonProps?: Partial<ButtonProps>;
onItemClick?(key: React.Key): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`test contextMenu should match snapshot 1`] = `
style="opacity: 0;"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light dt-contextMenu-menu"
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light dtc-contextMenu-menu"
data-menu-list="true"
role="menu"
tabindex="0"
Expand Down
6 changes: 3 additions & 3 deletions src/contextMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { CSSProperties, PropsWithChildren } from 'react';
import React, { CSSProperties, PropsWithChildren, ReactNode } from 'react';
import { Dropdown, Menu, DropdownProps, Popconfirm, PopconfirmProps } from 'antd';
import './style.scss';

Expand All @@ -10,7 +10,7 @@ interface IMenuProps {
/**
* 菜单栏的标题文案
*/
text: React.ReactNode;
text: ReactNode;
/**
* 菜单栏的样式
*/
Expand Down Expand Up @@ -46,7 +46,7 @@ export default function ContextMenu({
}: PropsWithChildren<IContextMenu>) {
const menu = (
<Menu
className="dt-contextMenu-menu"
className="dtc-contextMenu-menu"
onClick={(item) => {
item.domEvent.stopPropagation();
data.find((i) => i.key === item.key)?.cb?.();
Expand Down
2 changes: 1 addition & 1 deletion src/contextMenu/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.dt-contextMenu-menu {
.dtc-contextMenu-menu {
padding: 0;
background: #FFF;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
Expand Down
8 changes: 4 additions & 4 deletions src/copy/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode, CSSProperties } from 'react';
import { Tooltip, message } from 'antd';
import { CopyOutlined } from '@ant-design/icons';
import useClippy from 'use-clippy';
Expand All @@ -7,10 +7,10 @@ import './style.scss';

export interface ICopyProps {
text: string;
title?: React.ReactNode;
button?: React.ReactNode;
title?: ReactNode;
button?: ReactNode;
hideTooltip?: boolean;
style?: React.CSSProperties;
style?: CSSProperties;
className?: string;
onCopy?: (text: string) => void;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dropdown/select.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, ReactNode } from 'react';
import { Button, Checkbox, Col, Dropdown, Row, Space, type DropDownProps } from 'antd';
import classNames from 'classnames';
import List from 'rc-virtual-list';
Expand All @@ -10,7 +10,7 @@ import './style.scss';
interface IDropdownSelectProps
extends Pick<DropDownProps, 'getPopupContainer'>,
Required<Pick<CheckboxGroupProps, 'value' | 'options' | 'onChange'>> {
children: React.ReactNode;
children: ReactNode;
className?: string;
onSubmit?: (value: CheckboxValueType[]) => void;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ellipsisText/demos/valueType.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode, Component } from 'react';
import { EllipsisText } from 'dt-react-component';
import { Divider } from 'antd';

Expand All @@ -18,8 +18,8 @@ const element = (

const useEllipsisText = () => element;

class WithEllipsisText extends React.Component {
render(): React.ReactNode {
class WithEllipsisText extends Component {
render(): ReactNode {
return element;
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/ellipsisText/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import React, { useRef, useState, useLayoutEffect, useCallback, ReactNode } from 'react';
import React, {
useRef,
useState,
useLayoutEffect,
useCallback,
ReactNode,
CSSProperties,
} from 'react';
import { Tooltip } from 'antd';
import { AbstractTooltipProps, RenderFunction } from 'antd/lib/tooltip';
import classNames from 'classnames';
Expand Down Expand Up @@ -199,7 +206,7 @@ const EllipsisText = (props: IEllipsisTextProps) => {
};

const renderText = useCallback(() => {
const style: React.CSSProperties = {
const style: CSSProperties = {
maxWidth: width,
cursor,
};
Expand Down
10 changes: 5 additions & 5 deletions src/empty/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode, CSSProperties } from 'react';
import { Empty as AntdEmpty, EmptyProps } from 'antd';
import './style.scss';

Expand All @@ -14,16 +14,16 @@ export const IMG_MAP = {
interface IProps {
type?: 'default' | 'search' | 'chart' | 'project' | 'overview' | 'permission';
height?: number;
image?: React.ReactNode;
imageStyle?: React.CSSProperties;
image?: ReactNode;
imageStyle?: CSSProperties;
}

const Empty = (props: EmptyProps & IProps) => {
const { type = 'default', height = 80, image, imageStyle, ...restProps } = props;
let newImage: React.ReactNode = IMG_MAP[type] ? (
let newImage: ReactNode = IMG_MAP[type] ? (
<img src={require('./emptyImg/' + IMG_MAP[type])}></img>
) : null;
if (image) newImage = image as React.ReactNode;
if (image) newImage = image as ReactNode;
const newImageStyle = imageStyle ? { height, ...imageStyle } : { height };
return (
<div className="dtc-empty">
Expand Down
13 changes: 5 additions & 8 deletions src/errorBoundary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import React from 'react';
import React, { ReactNode, Component, ErrorInfo } from 'react';
import LoadError from './loadError';

interface IErrorBoundaryProps {
children?: React.ReactNode;
errorPage?: React.ReactNode;
children?: ReactNode;
errorPage?: ReactNode;
onError?: (error: Error) => void;
}

interface IErrorBoundaryState {
hasError: boolean;
}
export default class ErrorBoundary extends React.Component<
IErrorBoundaryProps,
IErrorBoundaryState
> {
export default class ErrorBoundary extends Component<IErrorBoundaryProps, IErrorBoundaryState> {
state = { hasError: false };
static getDerivedStateFromError(_error: any) {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}

componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
this.setState({ hasError: true });
this.props.onError?.(error);
console.log(error);
Expand Down
4 changes: 2 additions & 2 deletions src/form/table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useMemo, ReactNode } from 'react';
import { Form, Table, type FormListFieldData, type TableProps } from 'antd';
import classnames from 'classnames';
import utils from '../utils';
Expand Down Expand Up @@ -78,7 +78,7 @@ export interface ColumnType
record: FormListFieldData,
namePath: OverrideParameters,
formInstance?: RcFormInstance
) => React.ReactNode;
) => ReactNode;
}

const className = 'dtc-form__table';
Expand Down
10 changes: 5 additions & 5 deletions src/fullscreen/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from 'antd';
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, ReactNode, CSSProperties, HTMLAttributes } from 'react';
import KeyEventListener from '../keyEventListener';
import MyIcon from './icon';

Expand All @@ -24,12 +24,12 @@ interface DocumentWithFullscreen extends Document {
}

export interface IFullscreenProps
extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
extends React.DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> {
themeDark?: boolean;
target?: string;
iconStyle?: React.CSSProperties;
fullIcon?: React.ReactNode;
exitFullIcon?: React.ReactNode;
iconStyle?: CSSProperties;
fullIcon?: ReactNode;
exitFullIcon?: ReactNode;
onFullscreen?: (isFullScreen: boolean) => void;
}

Expand Down
6 changes: 3 additions & 3 deletions src/keyEventListener/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useCallback, useEffect } from 'react';
import { useCallback, useEffect, ReactNode, ForwardRefExoticComponent } from 'react';
import KeyCombiner from './listener';

export interface IKeyEventListenerProps {
onKeyDown?: (e: KeyboardEvent) => void;
onKeyUp?: (e: KeyboardEvent) => void;
children?: React.ReactNode;
children?: ReactNode;
}
interface CompoundedComponent extends React.ForwardRefExoticComponent<IKeyEventListenerProps> {
interface CompoundedComponent extends ForwardRefExoticComponent<IKeyEventListenerProps> {
KeyCombiner: typeof KeyCombiner;
}

Expand Down
4 changes: 2 additions & 2 deletions src/keyEventListener/listener.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import React, { useCallback, useEffect, useRef, useState, ReactNode } from 'react';

export interface IKeyCombinerProps {
onTrigger?: (evt: any) => void;
keyMap?: {
[key: string]: boolean;
};
children?: React.ReactNode;
children?: ReactNode;
}

export default ({ onTrigger, keyMap, children }: IKeyCombinerProps) => {
Expand Down
25 changes: 0 additions & 25 deletions src/loadError/index.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/progressLine/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';
import React, { ReactNode } from 'react';
import { Tooltip } from 'antd';
import { TooltipProps } from 'antd/lib/tooltip';
import './style.scss';

interface IProgressLineProps {
// 顶部左侧的内容
title?: React.ReactNode;
title?: ReactNode;
// 顶部右侧的百分比,需要带上 %
percent?: string;
// 进度条的颜色
Expand Down
4 changes: 2 additions & 2 deletions src/resize/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useEffect } from 'react';
import React, { useEffect, ReactNode } from 'react';

export interface ResizeProps {
observerEle?: HTMLElement | null;
children?: React.ReactNode;
children?: ReactNode;
onResize?: () => void;
}

Expand Down
10 changes: 5 additions & 5 deletions src/slidePane/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropsWithChildren } from 'react';
import React, { PropsWithChildren, CSSProperties, MouseEvent, KeyboardEvent } from 'react';
import classNames from 'classnames';
import { assign } from 'lodash';
import RcDrawer from 'rc-drawer';
Expand All @@ -7,9 +7,9 @@ import './style.scss';
export interface ISlidePaneProps {
visible: boolean;
className?: string;
style?: React.CSSProperties;
bodyStyle?: React.CSSProperties;
onClose?: (e: React.MouseEvent | React.KeyboardEvent) => void;
style?: CSSProperties;
bodyStyle?: CSSProperties;
onClose?: (e: MouseEvent | KeyboardEvent) => void;
}
const SlidePane = ({
visible,
Expand All @@ -20,7 +20,7 @@ const SlidePane = ({
onClose,
}: PropsWithChildren<ISlidePaneProps>) => {
const slidePrefixCls = 'dtc-slide-pane';
let rootStyle: React.CSSProperties = {
let rootStyle: CSSProperties = {
top: 0,
right: 0,
transform: visible ? undefined : 'translate3d(150%, 0, 0)',
Expand Down
4 changes: 2 additions & 2 deletions src/spreadSheet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export interface ISpreadSheetProps {
const SpreadSheet: React.FC<ISpreadSheetProps> = ({ data, columns = [], className, options }) => {
const tableRef = useRef<any>(null);
const copyUtils = new CopyUtils();
const _timer = useRef<number>();
const _timer = useRef<NodeJS.Timeout>();

useEffect(() => {
if (tableRef.current) {
removeRenderClock();
_timer.current = window.setTimeout(() => {
_timer.current = setTimeout(() => {
tableRef.current.hotInstance.render();
}, 100);
}
Expand Down
Loading

0 comments on commit 02dd422

Please sign in to comment.