From ad0d14abdaf3ab2d5b79d649e7886ee90d1c941a Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Wed, 20 Sep 2023 16:55:36 +0800 Subject: [PATCH 1/3] feat(check-cascader): add size api --- .changeset/gentle-doors-design.md | 5 + .changeset/metal-fireants-sneeze.md | 5 + .../ui/check-cascader/src/CheckCascader.tsx | 8 +- .../check-cascader/stories/index.stories.tsx | 1 + .../check-cascader/stories/size.stories.tsx | 119 ++++++++++++++++++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 .changeset/gentle-doors-design.md create mode 100644 .changeset/metal-fireants-sneeze.md create mode 100644 packages/ui/check-cascader/stories/size.stories.tsx diff --git a/.changeset/gentle-doors-design.md b/.changeset/gentle-doors-design.md new file mode 100644 index 000000000..4f7e14ac1 --- /dev/null +++ b/.changeset/gentle-doors-design.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +CheckCascader feat: add size api diff --git a/.changeset/metal-fireants-sneeze.md b/.changeset/metal-fireants-sneeze.md new file mode 100644 index 000000000..faf02f9b6 --- /dev/null +++ b/.changeset/metal-fireants-sneeze.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/check-cascader": minor +--- + +feat: add size api diff --git a/packages/ui/check-cascader/src/CheckCascader.tsx b/packages/ui/check-cascader/src/CheckCascader.tsx index 784812418..0cf1f6e87 100644 --- a/packages/ui/check-cascader/src/CheckCascader.tsx +++ b/packages/ui/check-cascader/src/CheckCascader.tsx @@ -24,7 +24,7 @@ import { flattenTreeData } from './utils' import { getNodeAncestorsWithMe, getTopDownAncestors } from '@hi-ui/tree-utils' import { useLatestCallback } from '@hi-ui/use-latest' import { isArrayNonEmpty, isUndef } from '@hi-ui/type-assertion' -import { HiBaseAppearanceEnum, useLocaleContext } from '@hi-ui/core' +import { HiBaseAppearanceEnum, HiBaseSizeEnum, useLocaleContext } from '@hi-ui/core' import { callAllFuncs } from '@hi-ui/func-utils' @@ -69,6 +69,7 @@ export const CheckCascader = forwardRef { + 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 ( + <> +

Size

+
+

sm

+ +

md

+ +

lg

+ +
+ + ) +} From de1cf49c7b4375ec6fbc982ec935899a60c091dd Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Thu, 21 Sep 2023 17:15:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?chore(check-cascader):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E9=80=89=E9=A1=B9=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/check-cascader/src/styles/check-cascader.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/ui/check-cascader/src/styles/check-cascader.scss b/packages/ui/check-cascader/src/styles/check-cascader.scss index c12fac0c9..418351fba 100644 --- a/packages/ui/check-cascader/src/styles/check-cascader.scss +++ b/packages/ui/check-cascader/src/styles/check-cascader.scss @@ -86,7 +86,6 @@ $prefix: '#{$component-prefix}-check-cascader' !default; &-item { width: 100%; - padding: use-spacing(2) 0; position: relative; cursor: pointer; display: flex; From 41572780e1b5555c2c8f30d3b20ee61c9d319245 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Thu, 21 Sep 2023 21:03:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore(check-cascader):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E9=80=89=E9=A1=B9=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/check-cascader/src/styles/check-cascader.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ui/check-cascader/src/styles/check-cascader.scss b/packages/ui/check-cascader/src/styles/check-cascader.scss index 418351fba..423b11ed3 100644 --- a/packages/ui/check-cascader/src/styles/check-cascader.scss +++ b/packages/ui/check-cascader/src/styles/check-cascader.scss @@ -86,6 +86,7 @@ $prefix: '#{$component-prefix}-check-cascader' !default; &-item { width: 100%; + padding: use-spacing(1) 0; position: relative; cursor: pointer; display: flex; @@ -108,7 +109,7 @@ $prefix: '#{$component-prefix}-check-cascader' !default; &-option { padding: 0 use-spacing(4); box-sizing: border-box; - height: 32px; + height: use-height-size(7); width: 100%; display: flex; align-items: center;