From 81fdf5c22feadbe9b714165c5f9dedaa7950625d Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 7 May 2024 16:24:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat(cascader):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=89=8D=E7=BD=AE=E5=90=8E=E7=BD=AE=E5=86=85=E5=AE=B9(#2821)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/cascader/src/Cascader.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/ui/cascader/src/Cascader.tsx b/packages/ui/cascader/src/Cascader.tsx index 6ed121376..ae34770f3 100644 --- a/packages/ui/cascader/src/Cascader.tsx +++ b/packages/ui/cascader/src/Cascader.tsx @@ -53,6 +53,8 @@ export const Cascader = forwardRef((props, flattedSearchResult = true, visible, size = 'md', + prefix, + suffix, onOpen, onClose, renderExtraFooter, @@ -240,7 +242,8 @@ export const Cascader = forwardRef((props, clearable={clearable} placeholder={placeholder} displayRender={displayRender as any} - suffix={menuVisible ? : } + prefix={prefix} + suffix={[menuVisible ? : , suffix]} focused={menuVisible} value={value[value.length - 1]} onChange={() => { @@ -331,6 +334,14 @@ export interface CascaderProps * 设置尺寸 */ size?: HiBaseSizeEnum + /** + * 选择框前置内容 + */ + prefix?: React.ReactNode + /** + * 选择框后置内容 + */ + suffix?: React.ReactNode } if (__DEV__) { From fd742536e74a076fb0ac5d84e29fc0a5b5a4f2f1 Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 7 May 2024 16:32:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?chore(cascader):=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E8=AE=B0=E5=BD=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/fresh-waves-act.md | 5 +++++ .changeset/thin-sheep-leave.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/fresh-waves-act.md create mode 100644 .changeset/thin-sheep-leave.md diff --git a/.changeset/fresh-waves-act.md b/.changeset/fresh-waves-act.md new file mode 100644 index 000000000..7a531f9fc --- /dev/null +++ b/.changeset/fresh-waves-act.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +feat(cascader): 支持前置后置内容 diff --git a/.changeset/thin-sheep-leave.md b/.changeset/thin-sheep-leave.md new file mode 100644 index 000000000..503869fe6 --- /dev/null +++ b/.changeset/thin-sheep-leave.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/cascader": minor +--- + +feat: 支持前置后置内容 From d3b1dba1fb4340aa0c69a4e66f17e2dadc420414 Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 7 May 2024 17:15:51 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat(check-cascader):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=89=8D=E7=BD=AE=E5=90=8E=E7=BD=AE=E5=86=85=E5=AE=B9(#2821)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/check-cascader/src/CheckCascader.tsx | 13 ++- .../check-cascader/stories/addon.stories.tsx | 97 +++++++++++++++++++ .../check-cascader/stories/index.stories.tsx | 1 + 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 packages/ui/check-cascader/stories/addon.stories.tsx diff --git a/packages/ui/check-cascader/src/CheckCascader.tsx b/packages/ui/check-cascader/src/CheckCascader.tsx index 3c8fdb677..40b0aa4b9 100644 --- a/packages/ui/check-cascader/src/CheckCascader.tsx +++ b/packages/ui/check-cascader/src/CheckCascader.tsx @@ -70,6 +70,8 @@ export const CheckCascader = forwardRef : } + prefix={prefix} + suffix={[menuVisible ? : , suffix]} focused={menuVisible} appearance={appearance} value={value} @@ -379,6 +382,14 @@ export interface CheckCascaderProps extends Omit { + const [dataOnlyLeafCheckable] = React.useState(() => { + const data = [ + { + id: '手机', + title: '手机t', + children: [ + { + id: '小米', + title: '小米t', + children: [ + { + id: '小米3', + title: '小米3t', + }, + { + id: '小米4', + title: '小米4t', + }, + ], + }, + { + id: '红米', + title: '红米t', + children: [ + { + id: '红米3', + title: '红米3t', + }, + { + id: '红米4', + title: '红米4t', + }, + ], + }, + ], + }, + { + id: '电视', + title: '电视t', + children: [ + { + id: '小米电视4A', + title: '小米电视4At', + }, + { + id: '小米电视4C', + title: '小米电视4Ct', + }, + ], + }, + ] + + const getDataOnlyLeafCheckable = (data: any) => { + return data.map((item: any) => { + if (item.children) { + item.checkable = item.checkable ?? false + item.children = getDataOnlyLeafCheckable(item.children) + } + + return item + }) + } + + const dataOnlyLeafCheckable = getDataOnlyLeafCheckable(data) + + return dataOnlyLeafCheckable + }) + + return ( + <> +

Addon

+
+ } + suffix={} + changeOnSelect + data={dataOnlyLeafCheckable} + onChange={console.log} + > +
+ + ) +} diff --git a/packages/ui/check-cascader/stories/index.stories.tsx b/packages/ui/check-cascader/stories/index.stories.tsx index 59f615aed..4a3f79271 100644 --- a/packages/ui/check-cascader/stories/index.stories.tsx +++ b/packages/ui/check-cascader/stories/index.stories.tsx @@ -12,6 +12,7 @@ export * from './dynamic.stories' export * from './display-render.stories' export * from './footer.stories' export * from './dropdown-column-render.stories' +export * from './addon.stories' // export * from './flatted.stories' export default { From 9f2dd8df1fd8af5d8e625af00fb3450c974fcc71 Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 7 May 2024 17:19:07 +0800 Subject: [PATCH 4/4] =?UTF-8?q?chore(check-cascader):=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E8=AE=B0=E5=BD=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/lovely-queens-sing.md | 5 +++++ .changeset/pretty-queens-dress.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/lovely-queens-sing.md create mode 100644 .changeset/pretty-queens-dress.md diff --git a/.changeset/lovely-queens-sing.md b/.changeset/lovely-queens-sing.md new file mode 100644 index 000000000..33de8f9a5 --- /dev/null +++ b/.changeset/lovely-queens-sing.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +feat(check-cascader): 支持前置后置内容 diff --git a/.changeset/pretty-queens-dress.md b/.changeset/pretty-queens-dress.md new file mode 100644 index 000000000..18c35c3a2 --- /dev/null +++ b/.changeset/pretty-queens-dress.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/check-cascader": minor +--- + +feat: 支持前置后置内容