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

+ +
+ + ) +}