refactor: extract public props use utils type

This commit is contained in:
07akioni 2021-04-15 20:09:54 +08:00
parent 0a60b418b9
commit 97952d4407
16 changed files with 49 additions and 55 deletions

View File

@ -11,6 +11,7 @@ export {
} from './vue'
export type { MaybeArray } from './vue'
export { warn, warnOnce, throwError, smallerSize, largerSize } from './naive'
export type { ExtractPublicPropTypes } from './naive'
export { formatLength } from './css'
export { createKey } from './cssr'
export * from './composable'

View File

@ -0,0 +1,9 @@
import { ExtractPropTypes } from '@vue/runtime-core'
import { useTheme } from '../../_mixins'
type themePropKeys = keyof typeof useTheme.props
export type ExtractPublicPropTypes<T> = Omit<
Partial<ExtractPropTypes<T>>,
themePropKeys
>

View File

@ -1,2 +1,3 @@
export { warn, warnOnce, throwError } from './warn'
export { smallerSize, largerSize } from './prop'
export type { ExtractPublicPropTypes } from './extract-public-props'

View File

@ -6,12 +6,12 @@ import {
defineComponent,
CSSProperties,
PropType,
h,
ExtractPropTypes
h
} from 'vue'
import { getScrollParent, unwrapElement } from 'seemly'
import { useConfig, useStyle } from '../../_mixins'
import { warn, keysOf } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import style from './styles/index.cssr'
export const affixProps = {
@ -54,7 +54,7 @@ export const affixProps = {
export const affixPropKeys = keysOf(affixProps)
export type AffixProps = Partial<ExtractPropTypes<typeof affixProps>>
export type AffixProps = ExtractPublicPropTypes<typeof affixProps>
export default defineComponent({
name: 'Affix',

View File

@ -5,8 +5,7 @@ import {
defineComponent,
PropType,
mergeProps,
renderSlot,
ExtractPropTypes
renderSlot
} from 'vue'
import { getMargin } from 'seemly'
import {
@ -19,6 +18,7 @@ import { NFadeInExpandTransition, NBaseClose, NBaseIcon } from '../../_internal'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { warn, createKey } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import { alertLight } from '../styles'
import type { AlertTheme } from '../styles'
import style from './styles/index.cssr'
@ -63,7 +63,7 @@ const alertProps = {
}
}
export type AlertProps = Partial<ExtractPropTypes<typeof alertProps>>
export type AlertProps = ExtractPublicPropTypes<typeof alertProps>
export default defineComponent({
name: 'Alert',

View File

@ -1,15 +1,9 @@
import {
h,
defineComponent,
computed,
ref,
CSSProperties,
ExtractPropTypes
} from 'vue'
import { h, defineComponent, computed, ref, CSSProperties } from 'vue'
import { NAffix } from '../../affix'
import { affixProps, affixPropKeys } from '../../affix/src/Affix'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import type { ExtractPublicPropTypes } from '../../_utils'
import { keep } from '../../_utils'
import { anchorLight } from '../styles'
import type { AnchorTheme } from '../styles'
@ -31,7 +25,7 @@ const anchorProps = {
...baseAnchorProps
} as const
export type AnchorProps = Partial<ExtractPropTypes<typeof anchorProps>>
export type AnchorProps = ExtractPublicPropTypes<typeof anchorProps>
export default defineComponent({
name: 'Anchor',

View File

@ -6,7 +6,6 @@ import {
renderSlot,
defineComponent,
watch,
ExtractPropTypes,
Ref,
InjectionKey
} from 'vue'
@ -15,6 +14,7 @@ import {
useInjectionCollection,
useInjectionElementCollection
} from '../../_utils/composable'
import type { ExtractPublicPropTypes } from '../../_utils'
export interface AnchorInjection {
activeHref: Ref<string | null>
@ -34,7 +34,7 @@ const anchorLinkProps = {
href: String
} as const
export type AnchorLinkProps = Partial<ExtractPropTypes<typeof anchorLinkProps>>
export type AnchorLinkProps = ExtractPublicPropTypes<typeof anchorLinkProps>
export default defineComponent({
name: 'AnchorLink',

View File

@ -7,8 +7,7 @@ import {
Transition,
PropType,
withDirectives,
CSSProperties,
ExtractPropTypes
CSSProperties
} from 'vue'
import { createTreeMate } from 'treemate'
import { VBinder, VTarget, VFollower } from 'vueuc'
@ -22,6 +21,7 @@ import {
MaybeArray,
getFirstSlotVNode
} from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import { NInternalSelectMenu, InternalSelectMenuRef } from '../../_internal'
import { NInput } from '../../input'
@ -98,9 +98,7 @@ const autoCompleteProps = {
}
} as const
export type AutoCompleteProps = Partial<
ExtractPropTypes<typeof autoCompleteProps>
>
export type AutoCompleteProps = ExtractPublicPropTypes<typeof autoCompleteProps>
export default defineComponent({
name: 'AutoComplete',

View File

@ -5,14 +5,14 @@ import {
onUpdated,
onMounted,
defineComponent,
PropType,
ExtractPropTypes
PropType
} from 'vue'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { avatarLight } from '../styles'
import type { AvatarTheme } from '../styles'
import { createKey } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import style from './styles/index.cssr'
const avatarProps = {
@ -35,7 +35,7 @@ const avatarProps = {
color: String
} as const
export type AvatarProps = Partial<ExtractPropTypes<typeof avatarProps>>
export type AvatarProps = ExtractPublicPropTypes<typeof avatarProps>
export default defineComponent({
name: 'Avatar',

View File

@ -11,8 +11,7 @@ import {
Transition,
PropType,
onMounted,
onBeforeUnmount,
ExtractPropTypes
onBeforeUnmount
} from 'vue'
import { VLazyTeleport } from 'vueuc'
import { useIsMounted, useMergedState } from 'vooks'
@ -21,6 +20,7 @@ import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { NBaseIcon } from '../../_internal'
import { formatLength, warn } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import { backTopLight } from '../styles'
import type { BackTopTheme } from '../styles'
import BackTopIcon from './BackTopIcon'
@ -92,7 +92,7 @@ const backTopProps = {
}
} as const
export type BackTopProps = Partial<ExtractPropTypes<typeof backTopProps>>
export type BackTopProps = ExtractPublicPropTypes<typeof backTopProps>
export default defineComponent({
name: 'BackTop',

View File

@ -7,13 +7,13 @@ import {
defineComponent,
renderSlot,
Transition,
CSSProperties,
ExtractPropTypes
CSSProperties
} from 'vue'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { NBaseSlotMachine, NBaseWave } from '../../_internal'
import { createKey } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import { badgeLight } from '../styles'
import type { BadgeTheme } from '../styles'
import style from './styles/index.cssr'
@ -47,7 +47,7 @@ const badgeProps = {
color: String
} as const
export type BadgeProps = Partial<ExtractPropTypes<typeof badgeProps>>
export type BadgeProps = ExtractPublicPropTypes<typeof badgeProps>
export default defineComponent({
name: 'Badge',

View File

@ -4,7 +4,6 @@ import {
defineComponent,
CSSProperties,
provide,
ExtractPropTypes,
InjectionKey,
Ref,
toRef
@ -14,6 +13,7 @@ import type { ThemeProps } from '../../_mixins'
import { breadcrumbLight } from '../styles'
import type { BreadcrumbTheme } from '../styles'
import style from './styles/index.cssr'
import type { ExtractPublicPropTypes } from '../../_utils'
export interface BreadcrumbInjection {
separatorRef: Ref<string>
@ -32,7 +32,7 @@ const breadcrumbProps = {
}
} as const
export type BreadcrumbProps = Partial<ExtractPropTypes<typeof breadcrumbProps>>
export type BreadcrumbProps = ExtractPublicPropTypes<typeof breadcrumbProps>
export default defineComponent({
name: 'Breadcrumb',

View File

@ -7,8 +7,7 @@ import {
defineComponent,
PropType,
renderSlot,
CSSProperties,
ExtractPropTypes
CSSProperties
} from 'vue'
import { useMemo } from 'vooks'
import { createHoverColor, createPressedColor } from '../../_utils/color/index'
@ -22,7 +21,7 @@ import {
} from '../../_internal'
import type { BaseWaveRef } from '../../_internal'
import { call, createKey } from '../../_utils'
import type { MaybeArray } from '../../_utils'
import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils'
import { buttonLight } from '../styles'
import type { ButtonTheme } from '../styles'
import { buttonGroupInjectionKey } from './ButtonGroup'
@ -92,7 +91,7 @@ const buttonProps = {
}
} as const
export type ButtonProps = Partial<ExtractPropTypes<typeof buttonProps>>
export type ButtonProps = ExtractPublicPropTypes<typeof buttonProps>
export default defineComponent({
name: 'Button',

View File

@ -1,12 +1,6 @@
import {
h,
PropType,
defineComponent,
provide,
InjectionKey,
ExtractPropTypes
} from 'vue'
import { h, PropType, defineComponent, provide, InjectionKey } from 'vue'
import { useConfig, useStyle } from '../../_mixins'
import type { ExtractPublicPropTypes } from '../../_utils'
import type { Size } from './interface'
import style from './styles/button-group.cssr'
@ -26,9 +20,7 @@ const buttonGroupProps = {
vertical: Boolean
} as const
export type ButtonGroupProps = Partial<
ExtractPropTypes<typeof buttonGroupProps>
>
export type ButtonGroupProps = ExtractPublicPropTypes<typeof buttonGroupProps>
export default defineComponent({
name: 'ButtonGroup',

View File

@ -1,7 +1,6 @@
import {
computed,
defineComponent,
ExtractPropTypes,
h,
ref,
PropType,
@ -23,7 +22,8 @@ import { useMergedState } from 'vooks'
import { dateArray } from '../../date-picker/src/utils'
import { ChevronLeftIcon, ChevronRightIcon } from '../../_internal/icons'
import { NBaseIcon } from '../../_internal'
import { call, MaybeArray } from '../../_utils'
import { call } from '../../_utils'
import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils'
import { NButton, NButtonGroup } from '../../button'
import { useConfig, useLocale, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
@ -47,7 +47,7 @@ const calendarProps = {
>
} as const
export type CalendarProps = Partial<ExtractPropTypes<typeof calendarProps>>
export type CalendarProps = ExtractPublicPropTypes<typeof calendarProps>
interface DateItem {
year: number

View File

@ -4,12 +4,12 @@ import {
computed,
PropType,
renderSlot,
CSSProperties,
ExtractPropTypes
CSSProperties
} from 'vue'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { call, createKey, keysOf, MaybeArray } from '../../_utils'
import { call, createKey, keysOf } from '../../_utils'
import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils'
import { NBaseClose } from '../../_internal'
import { cardLight } from '../styles'
import type { CardTheme } from '../styles'
@ -54,7 +54,7 @@ const cardProps = {
...cardBaseProps
}
export type CardProps = Partial<ExtractPropTypes<typeof cardProps>>
export type CardProps = ExtractPublicPropTypes<typeof cardProps>
export default defineComponent({
name: 'Card',