Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat(cascader): support checkStrictly" #1191

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion src/cascader/cascader.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ title | String / Slot / Function | - | Typescript:`string \| TNode`。[see mor
value | String / Number | - | `v-model` and `v-model:value` is supported | N
defaultValue | String / Number | - | uncontrolled property | N
visible | Boolean | false | \- | N
checkStrictly | Boolean | false | \- | N
placeholder | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
onChange | Function | | Typescript:`(value: string \| number, selectedOptions: string[]) => void`<br/> | N
onClose | Function | | Typescript:`(trigger: TriggerSource) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/cascader/type.ts)。<br/>`type TriggerSource = 'overlay' \| 'close-btn' \| 'finish'`<br/> | N
Expand Down
1 change: 0 additions & 1 deletion src/cascader/cascader.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ title | String / Slot / Function | - | 标题。TS 类型:`string \| TNode`。
value | String / Number | - | 选项值。支持语法糖 `v-model` 或 `v-model:value` | N
defaultValue | String / Number | - | 选项值。非受控属性 | N
visible | Boolean | false | 是否展示 | N
checkStrictly | Boolean | false | 父子节点选中状态不再关联,可各自选中或取消 | N
placeholder | String / Slot / Function | 选择选项 | 未选中时的提示文案。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
onChange | Function | | TS 类型:`(value: string \| number, selectedOptions: string[]) => void`<br/>值发生变更时触发 | N
onClose | Function | | TS 类型:`(trigger: TriggerSource) => void`<br/>关闭时触发。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/cascader/type.ts)。<br/>`type TriggerSource = 'overlay' \| 'close-btn' \| 'finish'`<br/> | N
Expand Down
18 changes: 2 additions & 16 deletions src/cascader/cascader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,11 @@ export default defineComponent({
);

const close = (trigger: string) => {
if (props.checkStrictly) onCloseChange();
props.onClose?.({ trigger });
};

const onVisibleChange = (visible: boolean, e?: any) => {
if (e?.trigger === 'overlay') close('overlay');
};

const onCloseChange = () => {
if (!stepIndex.value) {
setCascaderValue('', []);
} else {
const item = items[stepIndex.value - 1][selectedIndexes[stepIndex.value - 1]];

setCascaderValue(
item[(keys as Ref<KeysType>).value?.value ?? 'value'],
items.slice(0, stepIndex.value).map((item, index) => toRaw(item?.[selectedIndexes[index]])),
);
}
const onVisibleChange = (visible: boolean) => {
close('overlay');
};

const onClose = () => {
Expand Down
5 changes: 0 additions & 5 deletions src/cascader/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ export default {
},
/** 是否展示 */
visible: Boolean,
/** 父子节点选中状态不再关联,可各自选中或取消 */
checkStrictly: {
type: Boolean,
default: false,
},
/** 值发生变更时触发 */
onChange: Function as PropType<TdCascaderProps['onChange']>,
/** 关闭时触发 */
Expand Down
Loading