mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
refactor(cascader): clean code
This commit is contained in:
parent
305538f402
commit
3b50cc4c68
@ -132,9 +132,9 @@ export default defineComponent({
|
|||||||
return (
|
return (
|
||||||
<Transition name="fade-in-scale-up-transition" appear={this.isMounted}>
|
<Transition name="fade-in-scale-up-transition" appear={this.isMounted}>
|
||||||
{{
|
{{
|
||||||
default: () =>
|
default: () => {
|
||||||
this.show
|
if (!this.show) return null
|
||||||
? withDirectives(
|
return withDirectives(
|
||||||
<div
|
<div
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
ref="selfElRef"
|
ref="selfElRef"
|
||||||
@ -150,11 +150,8 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{this.menuModel[0].length ? (
|
{this.menuModel[0].length ? (
|
||||||
<div
|
<div class={`${mergedClsPrefix}-cascader-submenu-wrapper`}>
|
||||||
class={`${mergedClsPrefix}-cascader-submenu-wrapper`}
|
{this.menuModel.map((submenuOptions, index) => (
|
||||||
>
|
|
||||||
{this.menuModel.map((submenuOptions, index) => {
|
|
||||||
return (
|
|
||||||
<NCascaderSubmenu
|
<NCascaderSubmenu
|
||||||
ref={
|
ref={
|
||||||
((instance: CascaderSubmenuInstance) => {
|
((instance: CascaderSubmenuInstance) => {
|
||||||
@ -167,8 +164,7 @@ export default defineComponent({
|
|||||||
tmNodes={submenuOptions}
|
tmNodes={submenuOptions}
|
||||||
depth={index + 1}
|
depth={index + 1}
|
||||||
/>
|
/>
|
||||||
)
|
))}
|
||||||
})}
|
|
||||||
<NBaseMenuMask
|
<NBaseMenuMask
|
||||||
clsPrefix={mergedClsPrefix}
|
clsPrefix={mergedClsPrefix}
|
||||||
ref="maskInstRef"
|
ref="maskInstRef"
|
||||||
@ -176,12 +172,10 @@ export default defineComponent({
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div class={`${mergedClsPrefix}-cascader-menu__empty`}>
|
<div class={`${mergedClsPrefix}-cascader-menu__empty`}>
|
||||||
{renderSlot($slots, 'empty', undefined, () => [
|
{renderSlot($slots, 'empty', undefined, () => [<NEmpty />])}
|
||||||
<NEmpty />
|
|
||||||
])}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{$slots.action ? (
|
{$slots.action && (
|
||||||
<div
|
<div
|
||||||
class={`${mergedClsPrefix}-cascader-menu-action`}
|
class={`${mergedClsPrefix}-cascader-menu-action`}
|
||||||
data-action
|
data-action
|
||||||
@ -190,12 +184,12 @@ export default defineComponent({
|
|||||||
default: $slots.action
|
default: $slots.action
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
)}
|
||||||
<FocusDetector onFocus={this.onTabout} />
|
<FocusDetector onFocus={this.onTabout} />
|
||||||
</div>,
|
</div>,
|
||||||
[[clickoutside, this.handleClickOutside]]
|
[[clickoutside, this.handleClickOutside]]
|
||||||
)
|
)
|
||||||
: null
|
}
|
||||||
}}
|
}}
|
||||||
</Transition>
|
</Transition>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user