Skip to content

Commit

Permalink
refactor: remove unnecessary IxPropTypes usage (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Jul 1, 2022
1 parent 310360a commit 05f22f3
Show file tree
Hide file tree
Showing 48 changed files with 1,325 additions and 756 deletions.
22 changes: 13 additions & 9 deletions packages/components/_private/collapse-transition/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes } from 'vue'

import { IxPropTypes } from '@idux/cdk/utils'
import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes, PropType } from 'vue'

export type CollapseTransitionMode = 'height' | 'width'

export const collapseTransitionProps = {
appear: IxPropTypes.bool.def(false),
name: IxPropTypes.string,
mode: IxPropTypes.oneOf<CollapseTransitionMode>(['height', 'width']).def('height'),
onAfterEnter: IxPropTypes.emit(),
onAfterLeave: IxPropTypes.emit(),
appear: {
type: Boolean,
default: false,
},
name: String,
mode: {
type: String as PropType<CollapseTransitionMode>,
default: 'height',
},
onAfterEnter: [Function, Array] as PropType<MaybeArray<() => void>>,
onAfterLeave: [Function, Array] as PropType<MaybeArray<() => void>>,
}

export type CollapseTransitionProps = ExtractInnerPropTypes<typeof collapseTransitionProps>
Expand Down
43 changes: 28 additions & 15 deletions packages/components/_private/input/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,36 @@

import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils'
import type { FormSize } from '@idux/components/form'
import type { DefineComponent, InputHTMLAttributes } from 'vue'

import { IxPropTypes } from '@idux/cdk/utils'
import type { DefineComponent, InputHTMLAttributes, PropType } from 'vue'

export const inputProps = {
addonAfter: IxPropTypes.string,
addonBefore: IxPropTypes.string,
borderless: IxPropTypes.bool,
clearable: IxPropTypes.bool,
clearIcon: IxPropTypes.string,
clearVisible: IxPropTypes.bool,
disabled: IxPropTypes.bool,
focused: IxPropTypes.bool,
prefix: IxPropTypes.string,
size: IxPropTypes.oneOf<FormSize>(['sm', 'md', 'lg']),
suffix: IxPropTypes.string,
onClear: IxPropTypes.func<(evt: MouseEvent) => void>(),
addonAfter: String,
addonBefore: String,
borderless: {
type: Boolean,
default: undefined,
},
clearable: {
type: Boolean,
default: undefined,
},
clearIcon: String,
clearVisible: {
type: Boolean,
default: undefined,
},
disabled: {
type: Boolean,
default: undefined,
},
focused: {
type: Boolean,
default: undefined,
},
prefix: String,
size: String as PropType<FormSize>,
suffix: String,
onClear: Function as PropType<(evt: MouseEvent) => void>,
}

export type InputProps = ExtractInnerPropTypes<typeof inputProps>
Expand Down
17 changes: 12 additions & 5 deletions packages/components/_private/loading/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes } from 'vue'

import { IxPropTypes } from '@idux/cdk/utils'

export const loadingProps = {
strokeWidth: IxPropTypes.number.def(4),
radius: IxPropTypes.number.def(14),
duration: IxPropTypes.number.def(2),
strokeWidth: {
type: Number,
default: 4,
},
radius: {
type: Number,
default: 14,
},
duration: {
type: Number,
default: 2,
},
}

export type LoadingProps = ExtractInnerPropTypes<typeof loadingProps>
Expand Down
19 changes: 13 additions & 6 deletions packages/components/_private/mask/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes } from 'vue'

import { IxPropTypes } from '@idux/cdk/utils'

export const maskProps = {
mask: IxPropTypes.bool.def(true),
transitionName: IxPropTypes.string.def('ix-fade'),
visible: IxPropTypes.bool.def(true),
zIndex: IxPropTypes.number,
mask: {
type: Boolean,
default: true,
},
transitionName: {
type: String,
default: 'ix-fade',
},
visible: {
type: Boolean,
default: true,
},
zIndex: Number,
}

export type MaskProps = ExtractInnerPropTypes<typeof maskProps>
Expand Down
44 changes: 32 additions & 12 deletions packages/components/_private/overflow/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
*/

import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes } from 'vue'

import { IxPropTypes, vKeyPropDef } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes, PropType } from 'vue'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type SafeAny = any
Expand All @@ -19,18 +17,40 @@ export interface ItemData {
}

export const overflowItemProps = {
prefixCls: IxPropTypes.string.isRequired,
display: IxPropTypes.bool.def(true),
itemKey: vKeyPropDef.isRequired,
data: IxPropTypes.object<ItemData>(),
onSizeChange: IxPropTypes.func<(itemEl: Element, key?: VKey) => void>(),
prefixCls: {
type: String,
required: true,
},
display: {
type: Boolean,
default: true,
},
itemKey: {
type: [Number, String, Symbol] as PropType<VKey>,
required: true,
},
data: Object as PropType<ItemData>,
onSizeChange: Function as PropType<(itemEl: Element, key?: VKey) => void>,
}

export const overflowProps = {
maxLabel: IxPropTypes.oneOfType([IxPropTypes.number, IxPropTypes.oneOf(['responsive'])]).def(Number.MAX_SAFE_INTEGER),
getKey: IxPropTypes.func<(item: SafeAny) => VKey>().isRequired,
prefixCls: IxPropTypes.string.isRequired,
dataSource: IxPropTypes.array().def(() => []),
maxLabel: {
type: [Number, String] as PropType<number | 'responsive'>,
default: Number.MAX_SAFE_INTEGER,
},
getKey: {
type: Function as PropType<(item: SafeAny) => VKey>,
required: true,
},
prefixCls: {
type: String,
required: true,
},
dataSource: {
type: Array,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
default: () => [],
},
}

export type OverflowProps = ExtractInnerPropTypes<typeof overflowProps>
Expand Down
81 changes: 43 additions & 38 deletions packages/components/_private/overlay/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,58 @@
*/

import type { PopperOptions, PopperPlacement, PopperTrigger } from '@idux/cdk/popper'
import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes } from 'vue'
import type { VueTypeDef } from 'vue-types'
import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes, PropType } from 'vue'

import { IxPropTypes } from '@idux/cdk/utils'

export const overlayPlacementDef = IxPropTypes.oneOf<PopperPlacement>([
'topStart',
'top',
'topEnd',
'rightStart',
'right',
'rightEnd',
'bottomStart',
'bottom',
'bottomEnd',
'leftStart',
'left',
'leftEnd',
])
export const overlayTriggerDef = IxPropTypes.oneOf<PopperTrigger>(['click', 'hover', 'focus', 'contextmenu', 'manual'])
export const overlayDelayDef = IxPropTypes.oneOfType<number | [number | null, number | null]>([
Number,
IxPropTypes.array() as unknown as VueTypeDef<[number | null, number | null]>,
])
export const overlayPlacementDef = String as PropType<PopperPlacement>
export const overlayTriggerDef = String as PropType<PopperTrigger>
export const overlayDelayDef = [Number, Array] as PropType<number | [number | null, number | null]>

export const overlayProps = {
visible: IxPropTypes.bool,
allowEnter: IxPropTypes.bool,
autoAdjust: IxPropTypes.bool,
clickOutside: IxPropTypes.bool,
visible: {
type: Boolean,
default: undefined,
},
allowEnter: {
type: Boolean,
default: undefined,
},
autoAdjust: {
type: Boolean,
default: undefined,
},
clickOutside: {
type: Boolean,
default: undefined,
},
delay: overlayDelayDef,
destroyOnHide: IxPropTypes.bool,
disabled: IxPropTypes.bool,
offset: IxPropTypes.array() as unknown as VueTypeDef<[number, number]>,
destroyOnHide: {
type: Boolean,
default: undefined,
},
disabled: {
type: Boolean,
default: undefined,
},
offset: Array as unknown as PropType<[number, number]>,
placement: overlayPlacementDef,
showArrow: IxPropTypes.bool,
target: IxPropTypes.oneOfType([String, HTMLElement, IxPropTypes.func<() => string | HTMLElement>()]).isRequired,
transitionName: IxPropTypes.string,
showArrow: {
type: Boolean,
default: undefined,
},
target: {
type: [String, HTMLElement, Function] as PropType<string | HTMLElement | (() => string | HTMLElement)>,
required: true,
},
transitionName: String,
trigger: overlayTriggerDef,
triggerId: { type: null, default: undefined },
zIndex: IxPropTypes.number,
zIndex: Number,

// events
'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(),
'onUpdate:placement': IxPropTypes.emit<(placement: PopperPlacement) => void>(),
onAfterLeave: IxPropTypes.emit<() => void>(),
'onUpdate:visible': [Function, Array] as PropType<MaybeArray<(visible: boolean) => void>>,
'onUpdate:placement': [Function, Array] as PropType<MaybeArray<(placement: PopperPlacement) => void>>,
onAfterLeave: [Function, Array] as PropType<MaybeArray<() => void>>,
}

export interface OverlayBindings {
Expand Down
13 changes: 7 additions & 6 deletions packages/components/affix/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
*/

import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes } from 'vue'

import { IxPropTypes } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes, PropType } from 'vue'

export type AffixDirection = 'top' | 'bottom' | 'left' | 'right'
export type AffixOffset = number | string | Partial<Record<AffixDirection, number | string>>

export const affixProps = {
offset: IxPropTypes.oneOfType([Number, String, IxPropTypes.object<AffixOffset>()]).def(0),
target: IxPropTypes.oneOfType([String, HTMLElement, IxPropTypes.func<() => string | HTMLElement>()]),
onChange: IxPropTypes.func<(value: boolean) => void>(),
offset: {
type: [Number, String, Object] as PropType<AffixOffset>,
default: 0,
},
target: [String, HTMLElement, Function] as PropType<string | HTMLElement | (() => string | HTMLElement)>,
onChange: Function as PropType<(value: boolean) => void>,
}

export interface AffixBindings {
Expand Down
36 changes: 23 additions & 13 deletions packages/components/alert/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,31 @@
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes } from 'vue'

import { IxPropTypes } from '@idux/cdk/utils'
import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils'
import type { DefineComponent, HTMLAttributes, PropType } from 'vue'

export const alertProps = {
closable: IxPropTypes.bool,
closeIcon: IxPropTypes.string.def('close'),
description: IxPropTypes.string,
icon: IxPropTypes.string,
title: IxPropTypes.oneOfType([String, IxPropTypes.arrayOf(String)]),
pagination: IxPropTypes.oneOfType([Boolean, IxPropTypes.object<AlertPagination>()]).def(false),
type: IxPropTypes.oneOf<AlertType>(['success', 'info', 'warning', 'error']).def('info'),
onBeforeClose: IxPropTypes.emit<() => void | boolean | Promise<boolean>>(),
onClose: IxPropTypes.emit<() => void>(),
closable: {
type: Boolean,
default: undefined,
},
closeIcon: {
type: String,
default: 'close',
},
description: String,
icon: String,
title: [String, Array] as PropType<string | string[]>,
pagination: {
type: [Boolean, Object] as PropType<boolean | AlertPagination>,
default: false,
},
type: {
type: String as PropType<AlertType>,
default: 'info',
},
onBeforeClose: [Function, Array] as PropType<MaybeArray<() => void | boolean | Promise<boolean>>>,
onClose: [Function, Array] as PropType<MaybeArray<() => void>>,
}

export type AlertProps = ExtractInnerPropTypes<typeof alertProps>
Expand Down
Loading

0 comments on commit 05f22f3

Please sign in to comment.