From c0aedacdac1e6a2411b7f3fc9784f66eec4f8f0d Mon Sep 17 00:00:00 2001 From: xiamiao Date: Fri, 19 Apr 2024 09:51:52 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat(descriptions):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=97=E9=97=B4=E8=B7=9D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD(#2796)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/descriptions/src/Cell.tsx | 4 +++- packages/ui/descriptions/src/Descriptions.tsx | 7 +++++++ packages/ui/descriptions/src/Row.tsx | 10 +++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/ui/descriptions/src/Cell.tsx b/packages/ui/descriptions/src/Cell.tsx index 10d3b17e3..ae27b427e 100644 --- a/packages/ui/descriptions/src/Cell.tsx +++ b/packages/ui/descriptions/src/Cell.tsx @@ -13,6 +13,7 @@ export const Cell: React.FC = ({ label, content, labelWidth, + cellColumnGap, }) => { const Component: any = component @@ -42,7 +43,7 @@ export const Cell: React.FC = ({ return ( -
+
{!isNullish(label) && ( {label} @@ -67,4 +68,5 @@ export interface CellProps { label?: React.ReactNode content?: React.ReactNode labelWidth?: React.ReactText + cellColumnGap?: React.ReactText } diff --git a/packages/ui/descriptions/src/Descriptions.tsx b/packages/ui/descriptions/src/Descriptions.tsx index 5876e5d3d..9220da768 100644 --- a/packages/ui/descriptions/src/Descriptions.tsx +++ b/packages/ui/descriptions/src/Descriptions.tsx @@ -29,6 +29,7 @@ export const Descriptions = forwardRef appearance = 'unset', labelPlacement = 'left', labelWidth, + columnGap, size = 'md', ...rest }, @@ -66,6 +67,7 @@ export const Descriptions = forwardRef noBackground={noBackground} labelPlacement={labelPlacement} rootLabelWidth={labelWidth} + cellColumnGap={columnGap} /> ))} @@ -100,6 +102,11 @@ export interface DescriptionsProps extends HiBaseHTMLProps<'div'> { * label宽度 */ labelWidth?: React.ReactText + /** + * 单元格列间距 + * 注:在无边框场景下生效 + */ + columnGap?: React.ReactText /** * 设置大小 */ diff --git a/packages/ui/descriptions/src/Row.tsx b/packages/ui/descriptions/src/Row.tsx index aaec27471..c5117cb42 100644 --- a/packages/ui/descriptions/src/Row.tsx +++ b/packages/ui/descriptions/src/Row.tsx @@ -49,6 +49,7 @@ export interface RowProps { noBackground?: boolean labelPlacement?: 'left' | 'center' | 'right' rootLabelWidth?: React.ReactText + cellColumnGap?: React.ReactText } interface CellConfig { @@ -60,7 +61,13 @@ interface CellConfig { function renderCols( items: React.ReactElement[], - { prefixCls, bordered, labelPlacement: labelPlacementContext, rootLabelWidth }: RowProps, + { + prefixCls, + bordered, + labelPlacement: labelPlacementContext, + rootLabelWidth, + cellColumnGap, + }: RowProps, { component, type, showLabel, showContent }: CellConfig ) { return items.map( @@ -95,6 +102,7 @@ function renderCols( label={showLabel ? label : null} content={showContent ? children : null} labelWidth={labelWidth ?? rootLabelWidth} + cellColumnGap={index === items.length - 1 ? 0 : cellColumnGap} /> ) } From fbaf242b0e36729787ee576e7e3ab05ed4115cf4 Mon Sep 17 00:00:00 2001 From: xiamiao Date: Fri, 19 Apr 2024 09:59:20 +0800 Subject: [PATCH 2/4] =?UTF-8?q?chore(descriptions):=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/late-birds-jam.md | 5 +++++ .changeset/orange-seals-laugh.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/late-birds-jam.md create mode 100644 .changeset/orange-seals-laugh.md diff --git a/.changeset/late-birds-jam.md b/.changeset/late-birds-jam.md new file mode 100644 index 000000000..d10d10b66 --- /dev/null +++ b/.changeset/late-birds-jam.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": minor +--- + +feat(descriptions): 新增自定义列间距功能 diff --git a/.changeset/orange-seals-laugh.md b/.changeset/orange-seals-laugh.md new file mode 100644 index 000000000..b4955f1d3 --- /dev/null +++ b/.changeset/orange-seals-laugh.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/descriptions": minor +--- + +feat: 新增自定义列间距功能 From cda8add9576772a727eb57871d233391215f0bd6 Mon Sep 17 00:00:00 2001 From: xiamiao Date: Fri, 19 Apr 2024 19:04:26 +0800 Subject: [PATCH 3/4] =?UTF-8?q?chore(descriptions):=20=E4=BD=BF=E7=94=A8cs?= =?UTF-8?q?s=E5=8F=98=E9=87=8F=E4=BC=A0=E9=80=92=E9=97=B4=E8=B7=9D?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/descriptions/src/Cell.tsx | 10 ++++++++-- packages/ui/descriptions/src/styles/descriptions.scss | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/ui/descriptions/src/Cell.tsx b/packages/ui/descriptions/src/Cell.tsx index ae27b427e..fc1a23582 100644 --- a/packages/ui/descriptions/src/Cell.tsx +++ b/packages/ui/descriptions/src/Cell.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { cx } from '@hi-ui/classname' +import { cx, getPrefixStyleVar } from '@hi-ui/classname' import { isNullish } from '@hi-ui/type-assertion' export const Cell: React.FC = ({ @@ -43,7 +43,13 @@ export const Cell: React.FC = ({ return ( -
+
{!isNullish(label) && ( {label} diff --git a/packages/ui/descriptions/src/styles/descriptions.scss b/packages/ui/descriptions/src/styles/descriptions.scss index c274dcba0..d0d9a7ecb 100644 --- a/packages/ui/descriptions/src/styles/descriptions.scss +++ b/packages/ui/descriptions/src/styles/descriptions.scss @@ -36,6 +36,7 @@ $prefix: '#{$component-prefix}-descriptions' !default; &__container { box-sizing: border-box; display: flex; + padding-right: var(--hi-v4-container-padding-right, 0); } &__label, From 36dbe71f740e565c9f7312779483073b5d5ea686 Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 23 Apr 2024 10:08:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?chore(descriptions):=20=E4=BF=AE=E6=94=B9?= =?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/late-birds-jam.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/late-birds-jam.md b/.changeset/late-birds-jam.md index d10d10b66..84977cdf7 100644 --- a/.changeset/late-birds-jam.md +++ b/.changeset/late-birds-jam.md @@ -1,5 +1,5 @@ --- -"@hi-ui/hiui": minor +"@hi-ui/hiui": patch --- feat(descriptions): 新增自定义列间距功能