refactor(cascader): clean code

This commit is contained in:
07akioni 2021-09-09 00:17:18 +08:00
parent 305538f402
commit 3b50cc4c68

View File

@ -132,9 +132,9 @@ export default defineComponent({
return (
<Transition name="fade-in-scale-up-transition" appear={this.isMounted}>
{{
default: () =>
this.show
? withDirectives(
default: () => {
if (!this.show) return null
return withDirectives(
<div
tabindex="0"
ref="selfElRef"
@ -150,11 +150,8 @@ export default defineComponent({
}
>
{this.menuModel[0].length ? (
<div
class={`${mergedClsPrefix}-cascader-submenu-wrapper`}
>
{this.menuModel.map((submenuOptions, index) => {
return (
<div class={`${mergedClsPrefix}-cascader-submenu-wrapper`}>
{this.menuModel.map((submenuOptions, index) => (
<NCascaderSubmenu
ref={
((instance: CascaderSubmenuInstance) => {
@ -167,8 +164,7 @@ export default defineComponent({
tmNodes={submenuOptions}
depth={index + 1}
/>
)
})}
))}
<NBaseMenuMask
clsPrefix={mergedClsPrefix}
ref="maskInstRef"
@ -176,12 +172,10 @@ export default defineComponent({
</div>
) : (
<div class={`${mergedClsPrefix}-cascader-menu__empty`}>
{renderSlot($slots, 'empty', undefined, () => [
<NEmpty />
])}
{renderSlot($slots, 'empty', undefined, () => [<NEmpty />])}
</div>
)}
{$slots.action ? (
{$slots.action && (
<div
class={`${mergedClsPrefix}-cascader-menu-action`}
data-action
@ -190,12 +184,12 @@ export default defineComponent({
default: $slots.action
}}
</div>
) : null}
)}
<FocusDetector onFocus={this.onTabout} />
</div>,
[[clickoutside, this.handleClickOutside]]
)
: null
}
}}
</Transition>
)