-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Zheng-Changfu/dev
Dev
- Loading branch information
Showing
27 changed files
with
366 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
packages/components/src/drawer-form/components/drawer-content/drawer-content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import type { SlotsType } from 'vue' | ||
import type { ProDrawerContentSlots } from './slots' | ||
import { NDrawerContent, NFlex } from 'naive-ui' | ||
import { resolveSlotWithProps } from '../../../_utils/resolve-slot' | ||
import { useOmitProps, useOverrideProps } from '../../../composables' | ||
import Footer from './footer' | ||
import { proDrawerContentExtendProps, proDrawerContentProps } from './props' | ||
|
||
const name = 'ProDrawerContent' | ||
export default defineComponent({ | ||
name, | ||
props: proDrawerContentProps, | ||
slots: Object as SlotsType<ProDrawerContentSlots>, | ||
setup(props) { | ||
const overridedProps = useOverrideProps( | ||
name, | ||
props, | ||
) | ||
|
||
const nDrawerContentProps = useOmitProps( | ||
overridedProps, | ||
proDrawerContentExtendProps, | ||
) | ||
|
||
const showFooter = computed(() => { | ||
const { | ||
footer, | ||
resetButtonProps, | ||
submitButtonProps, | ||
} = overridedProps.value | ||
|
||
return footer !== false | ||
&& (resetButtonProps !== false || submitButtonProps !== false) | ||
}) | ||
|
||
return { | ||
showFooter, | ||
nDrawerContentProps, | ||
footer: computed(() => overridedProps.value.footer), | ||
resetButtonProps: computed(() => overridedProps.value.resetButtonProps), | ||
submitButtonProps: computed(() => overridedProps.value.submitButtonProps), | ||
} | ||
}, | ||
render() { | ||
return ( | ||
<NDrawerContent {...this.nDrawerContentProps}> | ||
{{ | ||
...this.$slots, | ||
footer: this.showFooter | ||
? () => { | ||
const footerDom = ( | ||
<Footer | ||
resetButtonProps={this.resetButtonProps} | ||
submitButtonProps={this.submitButtonProps} | ||
/> | ||
) | ||
|
||
return resolveSlotWithProps(this.$slots.footer, { | ||
footerDom, | ||
}, () => { | ||
return this.footer | ||
? this.footer({ footerDom }) | ||
: <NFlex justify="flex-end" size={[8, 8]}>{footerDom}</NFlex> | ||
}) | ||
} | ||
: null, | ||
}} | ||
</NDrawerContent> | ||
) | ||
}, | ||
}) |
Oops, something went wrong.