From 9be456ec092031eab5ab6097f8276cde0bd4721d Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Fri, 22 Sep 2023 18:23:58 +0800 Subject: [PATCH] feat(check-cascader): #2595 --- .changeset/afraid-guests-smoke.md | 5 + .changeset/red-plants-sleep.md | 5 + packages/ui/cascader/src/CascaderMenuList.tsx | 16 +- .../ui/check-cascader/src/CheckCascader.tsx | 14 +- .../check-cascader/src/CheckCascaderMenu.tsx | 3 +- .../src/CheckCascaderMenuList.tsx | 18 ++- .../dropdown-column-render.stories.tsx | 153 ++++++++++++++++++ .../check-cascader/stories/footer.stories.tsx | 94 +++++++++++ .../check-cascader/stories/index.stories.tsx | 2 + 9 files changed, 299 insertions(+), 11 deletions(-) create mode 100644 .changeset/afraid-guests-smoke.md create mode 100644 .changeset/red-plants-sleep.md create mode 100644 packages/ui/check-cascader/stories/dropdown-column-render.stories.tsx create mode 100644 packages/ui/check-cascader/stories/footer.stories.tsx diff --git a/.changeset/afraid-guests-smoke.md b/.changeset/afraid-guests-smoke.md new file mode 100644 index 000000000..c7049c2f6 --- /dev/null +++ b/.changeset/afraid-guests-smoke.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/check-cascader": minor +--- + +feat: 增加 renderExtraFooter 和 dropdownColumnRender api diff --git a/.changeset/red-plants-sleep.md b/.changeset/red-plants-sleep.md new file mode 100644 index 000000000..c23c5be2a --- /dev/null +++ b/.changeset/red-plants-sleep.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +feat: 增加 renderExtraFooter 和 dropdownColumnRender api diff --git a/packages/ui/cascader/src/CascaderMenuList.tsx b/packages/ui/cascader/src/CascaderMenuList.tsx index 4def2a00b..50761d9dd 100644 --- a/packages/ui/cascader/src/CascaderMenuList.tsx +++ b/packages/ui/cascader/src/CascaderMenuList.tsx @@ -7,21 +7,26 @@ import { checkCanLoadChildren, getItemEventData } from './utils' import { useCascaderContext } from './context' import { CascaderDataItem, FlattedCascaderDataItem, CascaderItemEventData } from './types' import { getTopDownAncestors } from '@hi-ui/tree-utils' -import { isArrayNonEmpty } from '@hi-ui/type-assertion' +import { isArrayNonEmpty, isFunction } from '@hi-ui/type-assertion' const menuListPrefix = getPrefixCls('cascader-menu-list') export const CascaderMenuList = forwardRef( ({ prefixCls = menuListPrefix, className, ...rest }, ref) => { - const { flatted, menuList } = useCascaderContext() + const { flatted, menuList, dropdownColumnRender } = useCascaderContext() const cls = cx(prefixCls, className, flatted && `${prefixCls}--flatted`) return (
{menuList.map((menu, menuIndex) => { - // @ts-ignore - return isArrayNonEmpty(menu) ? : null + return isArrayNonEmpty(menu) ? ( + isFunction(dropdownColumnRender) ? ( + dropdownColumnRender(, menuIndex) + ) : ( + + ) + ) : null })}
) @@ -40,6 +45,7 @@ export const CascaderMenu = ({ prefixCls = menuPrefix, role = 'menu', className, + style, data: menu, }: CascaderMenuProps) => { const { @@ -56,7 +62,7 @@ export const CascaderMenu = ({ const cls = cx(prefixCls, className) return ( -