From 825f38fe5f6ffee6572cc51a9b0dbe54937f8070 Mon Sep 17 00:00:00 2001 From: xiamiao Date: Fri, 14 Jun 2024 14:16:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat(search):=20=E6=94=AF=E6=8C=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=AD=97=E6=AE=B5=E5=88=AB=E5=90=8D(#2885)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/breadcrumb/src/Breadcrumb.tsx | 13 ++++++++++- packages/ui/breadcrumb/src/util.ts | 28 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 packages/ui/breadcrumb/src/util.ts diff --git a/packages/ui/breadcrumb/src/Breadcrumb.tsx b/packages/ui/breadcrumb/src/Breadcrumb.tsx index d12f18f2c..f3f6a47a3 100644 --- a/packages/ui/breadcrumb/src/Breadcrumb.tsx +++ b/packages/ui/breadcrumb/src/Breadcrumb.tsx @@ -1,8 +1,9 @@ -import React, { forwardRef } from 'react' +import React, { forwardRef, useMemo } from 'react' import { cx, getPrefixCls } from '@hi-ui/classname' import { __DEV__ } from '@hi-ui/env' import { BreadcrumbDataItem, BreadcrumbSizeEnum } from './types' import { HiBaseHTMLProps } from '@hi-ui/core' +import { transformData } from './util' const _role = 'breadcrumb' const _prefix = getPrefixCls(_role) @@ -17,6 +18,7 @@ export const Breadcrumb = forwardRef( role = _role, className, data, + fieldNames, separator = '/', onClick, size = 'md', @@ -26,6 +28,11 @@ export const Breadcrumb = forwardRef( ) => { const cls = cx(prefixCls, `${prefixCls}--${size}`, className) + data = useMemo((): BreadcrumbDataItem[] | undefined => { + if (data) return transformData(data, fieldNames) + return data + }, [data, fieldNames]) + return (