Skip to content

Commit

Permalink
111
Browse files Browse the repository at this point in the history
  • Loading branch information
dengfuping committed Jul 26, 2024
1 parent 721d1b0 commit 85617a6
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 34 deletions.
4 changes: 2 additions & 2 deletions packages/design/src/segmented/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const genSegmentedStyle: GenerateStyle<SegmentedToken> = (
};

export default (prefixCls: string) => {
const useStyle = genComponentStyleHook('Segmented', (token: SegmentedToken) => {
return [genSegmentedStyle(token)];
const useStyle = genComponentStyleHook('Segmented', token => {
return [genSegmentedStyle(token as SegmentedToken)];
});
return useStyle(prefixCls);
};
4 changes: 2 additions & 2 deletions packages/design/src/select/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const genSelectStyle: GenerateStyle<SelectToken> = (token: SelectToken):
};

export default (prefixCls: string) => {
const useStyle = genComponentStyleHook('Select', (token: SelectToken) => {
return [genSelectStyle(token)];
const useStyle = genComponentStyleHook('Select', token => {
return [genSelectStyle(token as SelectToken)];
});
return useStyle(prefixCls);
};
4 changes: 2 additions & 2 deletions packages/design/src/space/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const genSpaceStyle: GenerateStyle<SpaceToken> = (token: SpaceToken): CSS
};

export default (prefixCls: string) => {
const useStyle = genComponentStyleHook('Space', (token: SpaceToken) => {
return [genSpaceStyle(token)];
const useStyle = genComponentStyleHook('Space', token => {
return [genSpaceStyle(token as SpaceToken)];
});
return useStyle(prefixCls);
};
20 changes: 10 additions & 10 deletions packages/design/src/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export interface TableProps<T> extends AntTableProps<T> {
collapseText?: string;
openText?: string;
hiddenCancelBtn?: boolean;
toolOptionsRender?: (selectedRowKeys, selectedRows) => ReactNode[];
toolAlertRender?: false | ((selectedRowKeys, selectedRows) => ReactNode);
toolSelectedContent?: (selectedRowKeys, selectedRows) => ReactNode;
toolOptionsRender?: (selectedRowKeys: React.Key[], selectedRows: T[]) => ReactNode[];
toolAlertRender?: false | ((selectedRowKeys: React.Key[], selectedRows: T[]) => ReactNode);
toolSelectedContent?: (selectedRowKeys: React.Key[], selectedRows: T[]) => ReactNode;
locale?: TableLocale;
}

function Table<T>(props: TableProps<T>, ref: React.Ref<Reference>) {
function Table<T extends Record<string, any>>(props: TableProps<T>, ref: React.Ref<Reference>) {
const {
locale: customLocale,
columns,
Expand Down Expand Up @@ -99,7 +99,7 @@ function Table<T>(props: TableProps<T>, ref: React.Ref<Reference>) {
showTitle: false,
...item.ellipsis,
},
render: (text, record, index) => {
render: (text: any, record: T, index: number) => {
const element = (
item.render ? item.render(text, record, index) : record[(item as any).dataIndex]
) as ReactElement | undefined;
Expand All @@ -125,14 +125,14 @@ function Table<T>(props: TableProps<T>, ref: React.Ref<Reference>) {
return item;
});

const handleSelectedData = (selectedRowKeys, selectedRows, info) => {
const handleSelectedData = (selectedRowKeys: React.Key[], selectedRows: T[], info: any) => {
setCurrentSelectedRowKeys(selectedRowKeys);
setCurrentSelectedRows(selectedRows);
setCurrentSelectedInfo(info);
};

const handleOptionsCancel = () => {
rowSelection?.onChange([], [], currentSelectedInfo);
rowSelection?.onChange?.([], [], currentSelectedInfo);
handleSelectedData([], [], currentSelectedInfo);
};

Expand Down Expand Up @@ -182,8 +182,8 @@ function Table<T>(props: TableProps<T>, ref: React.Ref<Reference>) {
>
<a onClick={() => setOpenPopover(!openPopover)}>
{openPopover
? collapseText ?? batchOperationBar?.collapse
: openText ?? batchOperationBar?.open}
? (collapseText ?? batchOperationBar?.collapse)
: (openText ?? batchOperationBar?.open)}
</a>
</Popover>
)}
Expand Down Expand Up @@ -221,7 +221,7 @@ function Table<T>(props: TableProps<T>, ref: React.Ref<Reference>) {
}
) => {
handleSelectedData(selectedRowKeys, selectedRows, info);
rowSelection?.onChange(selectedRowKeys, selectedRows, info);
rowSelection?.onChange?.(selectedRowKeys, selectedRows, info);
},
}
: undefined
Expand Down
14 changes: 7 additions & 7 deletions packages/design/src/tag/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ export const genTagStyle: GenerateStyle<TagToken> = (token: TagToken): CSSObject
};

export default (prefixCls: string) => {
const useStyle = genComponentStyleHook('Tag', (token: TagToken) => {
const useStyle = genComponentStyleHook('Tag', token => {
return [
genTagStyle(token),
genPresetStyle(token),
genTagPresetStatusStyle(token, 'success'),
genTagPresetStatusStyle(token, 'error'),
genTagPresetStatusStyle(token, 'processing'),
genTagPresetStatusStyle(token, 'warning'),
genTagStyle(token as TagToken),
genPresetStyle(token as TagToken),
genTagPresetStatusStyle(token as TagToken, 'success'),
genTagPresetStatusStyle(token as TagToken, 'error'),
genTagPresetStatusStyle(token as TagToken, 'processing'),
genTagPresetStatusStyle(token as TagToken, 'warning'),
];
});
return useStyle(prefixCls);
Expand Down
8 changes: 4 additions & 4 deletions packages/design/src/theme/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ const defaultTheme: ThemeConfig = {
defaultTheme.token = {
...defaultTheme.token,
// preset colors below should be same with semantic colors
blue: defaultTheme.token.colorInfo,
green: defaultTheme.token.colorSuccess,
yellow: defaultTheme.token.colorWarning,
red: defaultTheme.token.colorError,
blue: defaultTheme?.token?.colorInfo,
green: defaultTheme?.token?.colorSuccess,
yellow: defaultTheme?.token?.colorWarning,
red: defaultTheme?.token?.colorError,
};

export default formatTheme(defaultTheme);
7 changes: 4 additions & 3 deletions packages/design/src/theme/util/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import type { ThemeConfig } from 'antd';
import { isString, toLower } from 'lodash';

export function formatTheme(theme: ThemeConfig) {
const token = theme.token;
const token = (theme.token || {}) as Record<string, any>;
// convert token color value to lower case
Object.keys(token).forEach(key => {
if (isString(token[key])) {
token[key] = toLower(token[key]);
}
});
Object.keys(theme.components).forEach(componentName => {
const componentToken = theme.components[componentName] || {};
const components = (theme.components || {}) as Record<string, any>;
Object.keys(components).forEach(componentName => {
const componentToken = components[componentName] || {};
// convert token color value to lower case
Object.keys(componentToken).forEach(key => {
if (isString(componentToken[key])) {
Expand Down
1 change: 1 addition & 0 deletions packages/design/src/tooltip/MouseTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useMouse, useSize } from 'ahooks';
import type { TooltipPropsWithTitle as AntTooltipPropsWithTitle } from 'antd/es/tooltip';
import React, { useRef, useState } from 'react';
// @ts-ignore
import ReactStickyMouseTooltip from 'react-sticky-mouse-tooltip';
import theme from '../theme';

Expand Down
4 changes: 2 additions & 2 deletions packages/design/src/tree-select/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const genTreeSelectStyle: GenerateStyle<TreeSelectToken> = (
};

export default (prefixCls: string) => {
const useStyle = genComponentStyleHook('TreeSelect', (token: TreeSelectToken) => {
return [genTreeSelectStyle(token)];
const useStyle = genComponentStyleHook('TreeSelect', token => {
return [genTreeSelectStyle(token as TreeSelectToken)];
});
return useStyle(prefixCls);
};
4 changes: 2 additions & 2 deletions packages/design/src/typography/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export const genTypographyStyle: GenerateStyle<TypographyToken> = (
};

export default (prefixCls: string) => {
const useStyle = genComponentStyleHook('Typography', (token: TypographyToken) => {
return [genTypographyStyle(token)];
const useStyle = genComponentStyleHook('Typography', token => {
return [genTypographyStyle(token as TypographyToken)];
});
return useStyle(prefixCls);
};

0 comments on commit 85617a6

Please sign in to comment.