From c3fb29b9b344a9fd61bf0e7f6a6bd3f1d150e982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Sat, 31 Aug 2024 17:58:02 +0800 Subject: [PATCH 01/33] chore: replace type alias path to relative path (#3297) From 5bc6bd6b02c4a4993a9c101ee80abe9fb782d519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Mon, 2 Sep 2024 16:45:18 +0800 Subject: [PATCH 02/33] fix(Select): fix keyboard event conflict with self-defined components (#3303) --- src/select/select.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/select/select.tsx b/src/select/select.tsx index cda6c6228..8c30280a2 100644 --- a/src/select/select.tsx +++ b/src/select/select.tsx @@ -453,7 +453,7 @@ export default defineComponent({ }; if (displayOptionsLength === 0) return; const preventKeys = ['ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab']; - if (preventKeys.includes(e.code)) { + if (preventKeys.includes(e.code) && selectInputRef.value.$el.contains(e.target)) { e.preventDefault(); } switch (e.code) { From a416cb9e3448da88cb0f8e559178060bf9b5a707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Mon, 2 Sep 2024 17:10:14 +0800 Subject: [PATCH 03/33] chore: optimize (#3304) --- src/select/select.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/select/select.tsx b/src/select/select.tsx index 8c30280a2..22a5d989e 100644 --- a/src/select/select.tsx +++ b/src/select/select.tsx @@ -453,7 +453,7 @@ export default defineComponent({ }; if (displayOptionsLength === 0) return; const preventKeys = ['ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab']; - if (preventKeys.includes(e.code) && selectInputRef.value.$el.contains(e.target)) { + if (preventKeys.includes(e.code) && selectInputRef.value?.$el.contains(e.target)) { e.preventDefault(); } switch (e.code) { From 75af0ab54edddf7aee3ee7f2c41cdb76a430a97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=81=E9=B9=85=E5=B2=9B=E5=B2=9B=E4=B8=BB?= <76833996+zhengchengshi@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:39:31 +0800 Subject: [PATCH 04/33] fix(Select): support checkAll option when using filterable API (#3295) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf(select): 全选常驻 * perf(select): 选择器搜索时支持全选选项常驻 * chore(select): 支持搜索词保留 --- src/select/select-panel.tsx | 1 + src/select/select.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/select/select-panel.tsx b/src/select/select-panel.tsx index a07e225bc..86cd73204 100644 --- a/src/select/select-panel.tsx +++ b/src/select/select-panel.tsx @@ -92,6 +92,7 @@ export default defineComponent({ if (isFunction(props.filter)) { return props.filter(`${props.inputValue}`, option); } + if ((option as TdOptionProps)?.checkAll === true) return true; return option.label?.toLowerCase?.().indexOf(`${props.inputValue}`.toLowerCase()) > -1; }; diff --git a/src/select/select.tsx b/src/select/select.tsx index 22a5d989e..c9642090f 100644 --- a/src/select/select.tsx +++ b/src/select/select.tsx @@ -12,7 +12,7 @@ import useVModel from '../hooks/useVModel'; import { useTNodeJSX } from '../hooks/tnode'; import { useConfig, usePrefixClass } from '../config-provider/useConfig'; import { - TdSelectProps, SelectValue, TdOptionProps, SelectValueChangeTrigger, + TdSelectProps, SelectValue, TdOptionProps, SelectValueChangeTrigger, SelectOption, } from './type'; import props from './props'; import TLoading from '../loading'; @@ -296,14 +296,22 @@ export default defineComponent({ // 全选点击回调,t-option 的事件调用到这里处理 const handleCheckAllClick = (e: MouseEvent | KeyboardEvent) => { + const filterMethods = (option: SelectOption) => { + if (isFunction(props.filter)) { + return props.filter(`${tInputValue.value}`, option); + } + return option.label?.toLowerCase?.().indexOf(`${tInputValue.value}`.toLowerCase()) > -1; + }; setInnerValue( isAllOptionsChecked.value ? [] : getAllSelectableOption(optionsList.value) + .filter(filterMethods) .map((option) => option.value) .slice(0, max.value || Infinity), { e, trigger: isAllOptionsChecked.value ? 'uncheck' : 'check' }, ); + !reserveKeyword?.value && setTInputValue(''); }; const handleCreate = () => { From 0ce47459688c43b326f773c9b450541d16323e71 Mon Sep 17 00:00:00 2001 From: setcy Date: Tue, 3 Sep 2024 17:43:03 +0800 Subject: [PATCH 05/33] feat(menu): support multiple head menu (#3296) * feat(menu): support multiple head menu * feat(menu): lint multiple head menu code * fix(menu): update snap files * fix(menu): fix code style --- src/menu/_example-composition/multi-head.vue | 160 ++++ src/menu/_example/multi-head.vue | 170 ++++ src/menu/head-menu.tsx | 14 +- src/menu/submenu.tsx | 7 +- src/menu/v-menu.ts | 12 +- test/snap/__snapshots__/csr.test.js.snap | 829 +++++++++++++++++++ test/snap/__snapshots__/ssr.test.js.snap | 2 + 7 files changed, 1184 insertions(+), 10 deletions(-) create mode 100644 src/menu/_example-composition/multi-head.vue create mode 100644 src/menu/_example/multi-head.vue diff --git a/src/menu/_example-composition/multi-head.vue b/src/menu/_example-composition/multi-head.vue new file mode 100644 index 000000000..b5210be2e --- /dev/null +++ b/src/menu/_example-composition/multi-head.vue @@ -0,0 +1,160 @@ + + + + + diff --git a/src/menu/_example/multi-head.vue b/src/menu/_example/multi-head.vue new file mode 100644 index 000000000..12299ade7 --- /dev/null +++ b/src/menu/_example/multi-head.vue @@ -0,0 +1,170 @@ + + + + diff --git a/src/menu/head-menu.tsx b/src/menu/head-menu.tsx index 7e90a0f4c..8fc307fb7 100644 --- a/src/menu/head-menu.tsx +++ b/src/menu/head-menu.tsx @@ -7,6 +7,7 @@ import { TdMenuInterface, TdOpenType } from './const'; import { Tabs, TabPanel } from '../tabs'; import { renderContent, renderTNodeJSX } from '../utils/render-tnode'; import VMenu from './v-menu'; +import type { VMenuData } from './v-menu'; import { usePrefixClass } from '../hooks/useConfig'; export default defineComponent({ @@ -131,14 +132,19 @@ export default defineComponent({ }; }, methods: { - renderNormalSubmenu() { - if (this.submenu.length === 0) return null; + renderNormalSubmenu(node: VMenuData[], depth: number) { + if (node.length === 0) return null; + return (