mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-19 06:43:16 +08:00
type: breadcroumb use AnyObject (#43717)
* fix: breadcroumb use AnyObject * fix: 显示声明import type * style: 修改代码格式
This commit is contained in:
parent
66c686ed16
commit
5104bf9981
@ -13,6 +13,7 @@ import type { DropdownProps } from '../dropdown';
|
|||||||
import useStyle from './style';
|
import useStyle from './style';
|
||||||
import useItemRender from './useItemRender';
|
import useItemRender from './useItemRender';
|
||||||
import useItems from './useItems';
|
import useItems from './useItems';
|
||||||
|
import type { AnyObject } from '../_util/type';
|
||||||
|
|
||||||
export interface BreadcrumbItemType {
|
export interface BreadcrumbItemType {
|
||||||
key?: React.Key;
|
key?: React.Key;
|
||||||
@ -46,7 +47,7 @@ export type ItemType = Partial<BreadcrumbItemType & BreadcrumbSeparatorType>;
|
|||||||
|
|
||||||
export type InternalRouteType = Partial<BreadcrumbItemType & BreadcrumbSeparatorType>;
|
export type InternalRouteType = Partial<BreadcrumbItemType & BreadcrumbSeparatorType>;
|
||||||
|
|
||||||
export interface BreadcrumbProps<T extends Record<PropertyKey, any> = any> {
|
export interface BreadcrumbProps<T extends AnyObject = AnyObject> {
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
params?: T;
|
params?: T;
|
||||||
separator?: React.ReactNode;
|
separator?: React.ReactNode;
|
||||||
@ -63,7 +64,7 @@ export interface BreadcrumbProps<T extends Record<PropertyKey, any> = any> {
|
|||||||
itemRender?: (route: ItemType, params: T, routes: ItemType[], paths: string[]) => React.ReactNode;
|
itemRender?: (route: ItemType, params: T, routes: ItemType[], paths: string[]) => React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPath = <T extends Record<PropertyKey, any> = any>(params: T, path?: string) => {
|
const getPath = <T extends AnyObject = AnyObject>(params: T, path?: string) => {
|
||||||
if (path === undefined) {
|
if (path === undefined) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ const getPath = <T extends Record<PropertyKey, any> = any>(params: T, path?: str
|
|||||||
return mergedPath;
|
return mergedPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Breadcrumb = <T extends Record<PropertyKey, any> = any>(props: BreadcrumbProps<T>) => {
|
const Breadcrumb = <T extends AnyObject = AnyObject>(props: BreadcrumbProps<T>) => {
|
||||||
const {
|
const {
|
||||||
prefixCls: customizePrefixCls,
|
prefixCls: customizePrefixCls,
|
||||||
separator = '/',
|
separator = '/',
|
||||||
@ -151,10 +152,7 @@ const Breadcrumb = <T extends Record<PropertyKey, any> = any>(props: BreadcrumbP
|
|||||||
<InternalBreadcrumbItem
|
<InternalBreadcrumbItem
|
||||||
key={mergedKey}
|
key={mergedKey}
|
||||||
{...itemProps}
|
{...itemProps}
|
||||||
{...pickAttrs(item, {
|
{...pickAttrs(item, { data: true, aria: true })}
|
||||||
data: true,
|
|
||||||
aria: true,
|
|
||||||
})}
|
|
||||||
className={itemClassName}
|
className={itemClassName}
|
||||||
dropdownProps={dropdownProps}
|
dropdownProps={dropdownProps}
|
||||||
href={href}
|
href={href}
|
||||||
|
Loading…
Reference in New Issue
Block a user