From 556049d76d54489abececebddec47d93388e5116 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Wed, 20 Sep 2023 17:07:59 +0800 Subject: [PATCH] feat(tree-select): add size api --- .changeset/nasty-geckos-push.md | 5 + .changeset/tricky-impalas-notice.md | 5 + packages/ui/tree-select/src/TreeSelect.tsx | 8 +- .../ui/tree-select/stories/index.stories.tsx | 1 + .../ui/tree-select/stories/size.stories.tsx | 119 ++++++++++++++++++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 .changeset/nasty-geckos-push.md create mode 100644 .changeset/tricky-impalas-notice.md create mode 100644 packages/ui/tree-select/stories/size.stories.tsx diff --git a/.changeset/nasty-geckos-push.md b/.changeset/nasty-geckos-push.md new file mode 100644 index 000000000..b05dbfbe9 --- /dev/null +++ b/.changeset/nasty-geckos-push.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/tree-select": minor +--- + +feat: add size api diff --git a/.changeset/tricky-impalas-notice.md b/.changeset/tricky-impalas-notice.md new file mode 100644 index 000000000..fd318a376 --- /dev/null +++ b/.changeset/tricky-impalas-notice.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +TreeSelect feat: add size api diff --git a/packages/ui/tree-select/src/TreeSelect.tsx b/packages/ui/tree-select/src/TreeSelect.tsx index 2d7707539..b34be76a1 100644 --- a/packages/ui/tree-select/src/TreeSelect.tsx +++ b/packages/ui/tree-select/src/TreeSelect.tsx @@ -12,7 +12,7 @@ import { uniqBy } from '@hi-ui/array-utils' import { Highlighter } from '@hi-ui/highlighter' import { MockInput } from '@hi-ui/input' import { DownOutlined, UpOutlined } from '@hi-ui/icons' -import { HiBaseAppearanceEnum, useLocaleContext } from '@hi-ui/core' +import { HiBaseAppearanceEnum, HiBaseSizeEnum, useLocaleContext } from '@hi-ui/core' import { callAllFuncs } from '@hi-ui/func-utils' import { UseDataSource } from '@hi-ui/use-data-source' @@ -74,6 +74,7 @@ export const TreeSelect = forwardRef( virtual, itemHeight, height, + size = 'md', ...rest }, ref @@ -245,6 +246,7 @@ export const TreeSelect = forwardRef( trigger={ { + const [data] = React.useState([ + { + title: '手机类', + id: '0', + disabled: true, + children: [ + { + title: 'Redmi系列', + id: '0-0', + children: [ + { + id: '0-0-1', + title: 'Redmi K30', + }, + { + id: '0-0-2', + title: 'Redmi K30 Pro', + }, + { + id: '0-0-3', + title: 'Redmi 10X 5G', + }, + { + id: '0-0-4', + title: 'Redmi Note 8', + }, + { + id: '0-0-5', + title: 'Redmi 9', + }, + { + id: '0-0-6', + title: 'Redmi 9A', + }, + ], + }, + { + title: '小米手机', + id: '0-1', + children: [ + { + id: '0-1-1', + title: '小米10 Pro', + }, + { + id: '0-1-2', + title: '小米10', + }, + { + id: '0-1-3', + title: '小米10 青春版 5G', + }, + { + id: '0-1-4', + title: '小米MIX Alpha', + }, + ], + }, + ], + }, + { + title: '电视', + id: '1', + children: [ + { + title: '小米电视 大师 65英寸OLED', + id: '1-0', + }, + { + title: 'Redmi 智能电视 MAX 98', + id: '1-1', + }, + { + title: '小米电视4A 60英寸', + id: '1-2', + }, + ], + }, + ]) + + return ( + <> +

Size

+
+

sm

+ { + console.log('TreeSelect onChange: ', checkedIds, selectItem) + }} + /> +

md

+ { + console.log('TreeSelect onChange: ', checkedIds, selectItem) + }} + /> +

lg

+ { + console.log('TreeSelect onChange: ', checkedIds, selectItem) + }} + /> +
+ + ) +}