Skip to content

Commit

Permalink
type: fix IconTagType issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 19, 2023
1 parent ceb9d72 commit 2efe580
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/react-button/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Icon, { IconProps } from '@uiw/react-icon';
import Icon, { IconProps, IconTagType } from '@uiw/react-icon';
import { IProps, HTMLButtonProps } from '@uiw/utils';
import './style/index.less';

Expand All @@ -12,7 +12,7 @@ export interface ButtonProps extends IProps, Omit<HTMLButtonProps, 'size'> {
active?: boolean;
loading?: boolean;
block?: boolean;
icon?: IconProps['type'];
icon?: IconProps<IconTagType>['type'];
type?: ButtonType;
size?: ButtonSize;
htmlType?: 'button' | 'submit' | 'reset';
Expand Down
4 changes: 2 additions & 2 deletions packages/react-collapse/src/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from 'react';
import { CSSTransition } from 'react-transition-group';
import { TransitionStatus } from 'react-transition-group/Transition';
import { IProps, HTMLDivProps } from '@uiw/utils';
import Icon, { IconProps } from '@uiw/react-icon';
import Icon, { IconProps, IconTagType } from '@uiw/react-icon';

export interface CollapsePanelProps extends IProps, HTMLDivProps {
disabled?: boolean;
showArrow?: boolean;
isActive?: boolean;
header?: React.ReactNode;
icon?: IconProps['type'];
icon?: IconProps<IconTagType>['type'];
extra?: React.ReactNode;
onItemClick?: (evn: React.MouseEvent<HTMLDivElement>) => void;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-input/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useEffect, useImperativeHandle } from 'react';
import Icon, { IconProps } from '@uiw/react-icon';
import Icon, { IconProps, IconTagType } from '@uiw/react-icon';
import { IProps, HTMLInputProps } from '@uiw/utils';
import './style/input.less';
export * from './InputNumber';
export { default as InputNumber } from './InputNumber';

export interface InputProps extends IProps, Omit<HTMLInputProps, 'size'> {
preIcon?: IconProps['type'];
preIcon?: IconProps<IconTagType>['type'];
addonAfter?: React.ReactNode;
size?: 'large' | 'default' | 'small';
inputStyle?: React.CSSProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import getWindowSizes, { WindowSize } from './getWindowSizes';
import getClientRect from './getClientRect';
import isIE from './isIE';

export interface IBoundingClientRect {
export interface IBoundingClientRect extends DOMRect {
left: number;
right: number;
top: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-overlay-trigger/src/util/getClientRect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @argument {Object} offsets
* @returns {Object} ClientRect like output
*/
export default function getClientRect(offsets: ClientRect): ClientRect {
export default function getClientRect(offsets: DOMRect): DOMRect {
return {
...offsets,
right: offsets.left + offsets.width,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-overlay-trigger/src/util/getWindowSizes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function getSize(axis: 'Height' | 'Width', body: BodyElement, html: IHTMLElement
html[`offset${axis}`],
html[`scroll${axis}`],
isIE(10)
? parseInt(html[`offset${axis}`], 10) +
? parseInt(html[`offset${axis}` as keyof IHTMLElement], 10) +
parseInt(computedStyle[`margin${axis === 'Height' ? 'Top' : 'Left'}`], 10) +
parseInt(computedStyle[`margin${axis === 'Height' ? 'Bottom' : 'Right'}`], 10)
: 0,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-progress/src/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Icon, { IconProps } from '@uiw/react-icon';
import Icon, { IconProps, IconTagType } from '@uiw/react-icon';

export function IconProgress<T>(props: { type: IconProps<T>['type'] }): JSX.Element {
export function IconProgress<T extends IconTagType>(props: { type: IconProps<T>['type'] }): JSX.Element {
return <Icon type={props.type} />;
}
4 changes: 2 additions & 2 deletions packages/react-steps/src/Step.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { CSSProperties } from 'react';
import Icon, { IconProps, IconsName } from '@uiw/react-icon';
import Icon, { IconProps, IconsName, IconTagType } from '@uiw/react-icon';
import { IProps, HTMLDivProps } from '@uiw/utils';
import './style/index.less';

Expand All @@ -11,7 +11,7 @@ export interface StepProps extends IProps, Omit<HTMLDivProps, 'title'> {
itemWidth?: number;
stepNumber?: string;
adjustMarginRight?: number;
icon?: IconProps['type'];
icon?: IconProps<IconTagType>['type'];
}

export default function Step(props: StepProps) {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-table/src/ThComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { TableColumns, TableProps, LocationWidth } from './';
import { locationFixed } from './util';

interface ThComponentProps<T> {
interface ThComponentProps<T extends { [key: string]: V } = any, V = any> {
colNum: number;
rightNum: number;
item: TableColumns<T>;
Expand All @@ -13,7 +13,7 @@ interface ThComponentProps<T> {
locationWidth: { [key: string]: LocationWidth };
updateLocation: (params: LocationWidth, index: string, key: string, colSpan?: number) => void;
}
export default class ThComponent<T> extends Component<ThComponentProps<T>> {
export default class ThComponent<T extends { [key: string]: V } = any, V = any> extends Component<ThComponentProps<T>> {
wrapper = React.createRef<HTMLTableCellElement>();
componentDidMount() {
this.props.updateLocation(
Expand Down
2 changes: 1 addition & 1 deletion packages/react-table/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default function Table<T extends { [key: string]: V }, V>(props: TablePro
const arr1: Array<T[keyof T] | number> = [];
const arr = params.map((it: T, index: number) => {
if (Array.isArray(it[childKey])) {
arr1.push(...deep(it[childKey]));
arr1.push(...deep(it[childKey] as TableColumns<T>));
}
return rowKey ? it[rowKey] : index;
});
Expand Down
5 changes: 3 additions & 2 deletions packages/react-tree/src/TreeNode.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useMemo } from 'react';
import { CSSTransition } from 'react-transition-group';
import Icon, { IconProps } from '@uiw/react-icon';
import Icon, { IconProps, IconTagType } from '@uiw/react-icon';
import { IProps, noop } from '@uiw/utils';
import { TreeData, TreeProps, getChildKeys } from './';

Expand All @@ -18,7 +18,8 @@ interface DisabledObj {
disabledClass?: string;
disabledStyle?: React.CSSProperties;
}
interface TreeNodeProps<T = (data: TreeData, props: TreeNodeIconProps) => IconProps['type']> extends IProps {
interface TreeNodeProps<T = (data: TreeData, props: TreeNodeIconProps) => IconProps<IconTagType>['type']>
extends IProps {
data: TreeData[];
level: number;
parent?: TreeData;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-tree/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { IconProps } from '@uiw/react-icon';
import { IconProps, IconTagType } from '@uiw/react-icon';
import { IProps, HTMLDivProps, noop } from '@uiw/utils';
import TreeNode from './TreeNode';
import './style/index.less';
Expand All @@ -16,7 +16,7 @@ export type TreeRenderTitleNode = {
};

export interface TreeProps extends IProps, Omit<HTMLDivProps, 'onChange'> {
icon?: IconProps['type'];
icon?: IconProps<IconTagType>['type'];
data?: TreeData[];
openKeys?: TreeData['key'][];
selectedKeys?: TreeData['key'][];
Expand Down

0 comments on commit 2efe580

Please sign in to comment.