Skip to content

Commit

Permalink
Revert "feat(cascader): support checkStrictly (#1186)"
Browse files Browse the repository at this point in the history
This reverts commit bf8f262.
  • Loading branch information
anlyyao authored Dec 22, 2023
1 parent 1013bbd commit f6449cb
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 23 deletions.
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

0 comments on commit f6449cb

Please sign in to comment.