Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
2e85fa6
feat(cascader): add panelHeader/panelFooter slots with cascade filter…
RSS1102 Jan 26, 2026
84ca131
feat: 增加 panelFooter 的 options 和 onFilter 参数
RSS1102 Jan 26, 2026
c2b4c0a
feat: 新增级联选择器面板底部插槽功能
RSS1102 Jan 26, 2026
75421a8
feat(cascader): 支持过滤函数类型的搜索词,优化级联选择器面板的过滤逻辑
RSS1102 Jan 28, 2026
4863497
feat(cascader): 优化过滤状态判断逻辑,确保面板显示条件更准确
RSS1102 Jan 28, 2026
d903cdf
test(cascader): 增强级联选择器面板的过滤功能,支持自定义过滤器和面板插槽
RSS1102 Jan 29, 2026
94c8509
feat(cascader): 将面板头部和底部插槽重命名为弹出层头部和底部,增强可读性
RSS1102 Jan 29, 2026
cee9286
feat(cascader): 将面板头部和底部插槽重命名为弹出层头部和底部,增强可读性并更新类型定义
RSS1102 Jan 29, 2026
aae7191
feat(cascader): 增强级联选择器的过滤功能,支持自定义过滤器和面板插槽,优化文档描述
RSS1102 Jan 30, 2026
92fe87e
test(cascader): 增强过滤功能测试,确保过滤函数存在并正确应用
RSS1102 Jan 30, 2026
97b4d16
feat(cascader): 更新示例和文档,增强面板过滤功能,支持大小写敏感过滤
RSS1102 Jan 30, 2026
2692f4a
feat(cascader): 移除未使用的变量和过滤函数,简化代码结构
RSS1102 Jan 30, 2026
174ebd6
fix: 清理过期的级联面板回调
RSS1102 Feb 2, 2026
a76a3c9
refactor: 优化 Cascader Panel 参数传递逻辑
RSS1102 Feb 2, 2026
2e8ede2
test: 优化级联选择器测试用例和类型定义
RSS1102 Feb 2, 2026
d67a456
Merge branch 'develop' into rss1102/feat/cascader/panel-header
RSS1102 Feb 3, 2026
61a4b53
refactor(cascader): update panel header/footer slots to panelContentT…
RSS1102 Feb 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
680 changes: 565 additions & 115 deletions packages/components/cascader/__tests__/cascader.test.tsx

Large diffs are not rendered by default.

99 changes: 85 additions & 14 deletions packages/components/cascader/_example/base.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,67 @@
<template>
<t-cascader v-model="value" :options="options" clearable @change="onChange" @focus="onFocus" @blur="onBlur" />
<t-space direction="vertical" style="width: 100%">
<!-- 基础搜索:每个层级独立过滤 -->
<t-cascader v-model="value" :options="options">
<template #popupHeader="{ panelIndex, onFilter }">
<t-input
v-model="searchValues1[panelIndex]"
:placeholder="`搜索第${panelIndex + 1}级`"
@change="(val) => onFilter(val)"
/>
</template>
</t-cascader>

<!-- 级联搜索:搜索某级后,后续级别只显示匹配项的子节点 -->
<t-cascader v-model="value2" :options="options">
<template #popupHeader="{ panelIndex, onFilter }">
<t-input
v-model="searchValues2[panelIndex]"
:placeholder="`搜索第${panelIndex + 1}级(级联)`"
@change="(val) => onFilter(val, { cascade: true })"
/>
</template>
</t-cascader>

<!-- 基础搜索 + 底部搜索框(位置不同但功能相同) -->
<t-cascader v-model="value3" :options="options">
<template #popupHeader="{ panelIndex, onFilter }">
<t-input
v-model="searchValues3[panelIndex]"
:placeholder="'搜索第' + (panelIndex + 1) + '级(顶部)'"
@change="(val) => onFilter(val)"
/>
</template>
<template #popupFooter="{ panelIndex, onFilter }">
<t-input
v-model="searchValues3[panelIndex]"
:placeholder="'搜索第' + (panelIndex + 1) + '级(底部)'"
@change="(val) => onFilter(val)"
/>
</template>
</t-cascader>

<!-- 级联搜索 + 底部搜索框(位置不同但功能相同) -->
<t-cascader v-model="value4" :options="options">
<template #popupHeader="{ panelIndex, onFilter }">
<t-input
v-model="searchValues4[panelIndex]"
:placeholder="'搜索第' + (panelIndex + 1) + '级(级联-顶部)'"
@change="(val) => onFilter(val, { cascade: true })"
/>
</template>
<template #popupFooter="{ panelIndex, onFilter }">
<t-input
v-model="searchValues4[panelIndex]"
:placeholder="'搜索第' + (panelIndex + 1) + '级(级联-底部)'"
@change="(val) => onFilter(val, { cascade: true })"
/>
</template>
</t-cascader>
</t-space>
</template>

<script setup>
import { ref } from 'vue';
import { ref, reactive } from 'vue';

const options = [
{
Expand All @@ -13,10 +71,15 @@ const options = [
{
label: '子选项一',
value: '1.1',
children: [
{ label: '三级-1', value: '1.1.1' },
{ label: '三级-2', value: '1.1.2' },
],
},
{
label: '子选项二',
value: '1.2',
children: [{ label: '三级-3', value: '1.2.1' }],
},
{
label: '子选项三',
Expand All @@ -31,26 +94,34 @@ const options = [
{
label: '子选项一',
value: '2.1',
children: [{ label: '三级-4', value: '2.1.1' }],
},
{
label: '子选项二',
value: '2.2',
},
],
},
{
label: '选项三',
value: '3',
children: [
{
label: '子选项一',
value: '3.1',
},
],
},
];

const value = ref('1.1');

const onChange = (val, context) => {
console.log(val, context);
};

const onFocus = (ctx) => {
console.log('focus', ctx);
};
const value = ref('1.1.1');
const value2 = ref('1.1.1');
const value3 = ref('1.1.1');
const value4 = ref('1.1.1');

const onBlur = (ctx) => {
console.log('blur', ctx);
};
// 使用 reactive 维护搜索状态
const searchValues1 = reactive({});
const searchValues2 = reactive({});
const searchValues3 = reactive({});
const searchValues4 = reactive({});
</script>
2 changes: 2 additions & 0 deletions packages/components/cascader/cascader.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ option | Slot / Function | - | customize one option。Typescript:`TNode<{ item
options | Array | [] | Typescript:`Array<CascaderOption>` | N
panelBottomContent | String / Slot / Function | - | bottom content of the cascader panel。Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
panelTopContent | String / Slot / Function | - | top content of the cascader panel。Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
popupFooter | Slot / Function | - | footer of each column in the popup panel, supports custom rendering. `panelIndex` is the current column index, `options` is the current column options, `onFilter` is used to filter options。Typescript:`TNode<{ panelIndex: number; options: TreeOptionData[]; onFilter: (filter: string \| ((node: TreeOptionData, panelIndex: number) => boolean), opts?: { cascade?: boolean }) => void }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
popupHeader | Slot / Function | - | header of each column in the popup panel, supports custom rendering. `panelIndex` is the current column index, `options` is the current column options, `onFilter` is used to filter options。Typescript:`TNode<{ panelIndex: number; options: TreeOptionData[]; onFilter: (filter: string \| ((node: TreeOptionData, panelIndex: number) => boolean), opts?: { cascade?: boolean }) => void }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
placeholder | String | undefined | \- | N
popupProps | Object | - | Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/cascader/type.ts) | N
popupVisible | Boolean | - | \- | N
Expand Down
2 changes: 2 additions & 0 deletions packages/components/cascader/cascader.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ option | Slot / Function | - | 自定义单个级联选项, item 是选项本身
options | Array | [] | 可选项数据源。TS 类型:`Array<CascaderOption>` | N
panelBottomContent | String / Slot / Function | - | 面板内的底部内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
panelTopContent | String / Slot / Function | - | 面板内的顶部内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
popupFooter | Slot / Function | - | 弹出层内每一列的页脚,支持自定义渲染。`panelIndex` 表示当前列索引,`options` 表示当前列选项,`onFilter` 用于过滤当前列选项。TS 类型:`TNode<{ panelIndex: number; options: TreeOptionData[]; onFilter: (filter: string \| ((node: TreeOptionData, panelIndex: number) => boolean), opts?: { cascade?: boolean }) => void }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
popupHeader | Slot / Function | - | 弹出层内每一列的标题,支持自定义渲染。`panelIndex` 表示当前列索引,`options` 表示当前列选项,`onFilter` 用于过滤当前列选项。TS 类型:`TNode<{ panelIndex: number; options: TreeOptionData[]; onFilter: (filter: string \| ((node: TreeOptionData, panelIndex: number) => boolean), opts?: { cascade?: boolean }) => void }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
placeholder | String | undefined | 占位符 | N
popupProps | Object | - | 参考 popup 组件 API。TS 类型:`PopupProps`,[Popup API Documents](./popup?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/cascader/type.ts) | N
popupVisible | Boolean | - | 是否显示下拉框 | N
Expand Down
8 changes: 7 additions & 1 deletion packages/components/cascader/cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ export default defineComponent({
loading={props.loading}
loadingText={props.loadingText}
cascaderContext={cascaderContext.value}
v-slots={{ option: slots.option, empty: slots.empty, loadingText: slots.loadingText }}
v-slots={{
option: slots.option,
empty: slots.empty,
loadingText: slots.loadingText,
popupHeader: slots.popupHeader,
popupFooter: slots.popupFooter,
}}
/>
{renderTNodeJSX('panelBottomContent')}
</>
Expand Down
Loading
Loading