From 05f22f3106809cef61fab4adc9b7fb5faa2ac609 Mon Sep 17 00:00:00 2001 From: saller Date: Fri, 1 Jul 2022 17:10:25 +0800 Subject: [PATCH] refactor: remove unnecessary IxPropTypes usage (#992) --- .../_private/collapse-transition/src/types.ts | 22 +- .../components/_private/input/src/types.ts | 43 ++- .../components/_private/loading/src/types.ts | 17 +- .../components/_private/mask/src/types.ts | 19 +- .../components/_private/overflow/src/types.ts | 44 ++- .../components/_private/overlay/src/types.ts | 81 ++--- packages/components/affix/src/types.ts | 13 +- packages/components/alert/src/types.ts | 36 ++- packages/components/anchor/src/types.ts | 35 ++- packages/components/avatar/src/types.ts | 30 +- packages/components/back-top/src/types.ts | 14 +- packages/components/badge/src/types.ts | 21 +- packages/components/breadcrumb/src/types.ts | 9 +- packages/components/button/src/types.ts | 48 ++- packages/components/card/src/types.ts | 58 ++-- packages/components/collapse/src/types.ts | 34 ++- packages/components/divider/src/types.ts | 29 +- packages/components/drawer/src/types.ts | 72 +++-- packages/components/dropdown/src/types.ts | 38 ++- packages/components/empty/src/types.ts | 10 +- packages/components/form/src/types.ts | 77 +++-- packages/components/grid/src/types.ts | 24 +- packages/components/icon/src/types.ts | 18 +- packages/components/image/src/types.ts | 44 ++- packages/components/input-number/src/types.ts | 52 ++-- packages/components/layout/src/types.ts | 15 +- packages/components/list/src/types.ts | 30 +- packages/components/menu/src/types.ts | 57 ++-- packages/components/message/src/types.ts | 31 +- packages/components/modal/src/types.ts | 99 ++++--- packages/components/notification/src/types.ts | 44 +-- packages/components/pagination/src/types.ts | 67 +++-- packages/components/popconfirm/src/types.ts | 29 +- packages/components/popover/src/types.ts | 14 +- packages/components/progress/src/types.ts | 46 +-- packages/components/rate/src/types.ts | 86 ++++-- packages/components/result/src/types.ts | 12 +- packages/components/skeleton/src/types.ts | 28 +- packages/components/space/src/types.ts | 31 +- packages/components/spin/src/types.ts | 28 +- packages/components/statistic/src/types.ts | 18 +- packages/components/stepper/src/types.ts | 46 ++- packages/components/switch/src/types.ts | 39 ++- packages/components/tag/src/types.ts | 51 ++-- packages/components/timeline/src/types.ts | 37 ++- packages/components/tooltip/src/types.ts | 24 +- packages/components/tree/src/types.ts | 276 ++++++++++++------ packages/components/upload/src/types.ts | 85 +++--- 48 files changed, 1325 insertions(+), 756 deletions(-) diff --git a/packages/components/_private/collapse-transition/src/types.ts b/packages/components/_private/collapse-transition/src/types.ts index f82a97939..3e28b4fa2 100644 --- a/packages/components/_private/collapse-transition/src/types.ts +++ b/packages/components/_private/collapse-transition/src/types.ts @@ -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(['height', 'width']).def('height'), - onAfterEnter: IxPropTypes.emit(), - onAfterLeave: IxPropTypes.emit(), + appear: { + type: Boolean, + default: false, + }, + name: String, + mode: { + type: String as PropType, + default: 'height', + }, + onAfterEnter: [Function, Array] as PropType void>>, + onAfterLeave: [Function, Array] as PropType void>>, } export type CollapseTransitionProps = ExtractInnerPropTypes diff --git a/packages/components/_private/input/src/types.ts b/packages/components/_private/input/src/types.ts index ba6ba3e64..cb7bb743f 100644 --- a/packages/components/_private/input/src/types.ts +++ b/packages/components/_private/input/src/types.ts @@ -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(['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, + suffix: String, + onClear: Function as PropType<(evt: MouseEvent) => void>, } export type InputProps = ExtractInnerPropTypes diff --git a/packages/components/_private/loading/src/types.ts b/packages/components/_private/loading/src/types.ts index 46a53429b..f4f0cef35 100644 --- a/packages/components/_private/loading/src/types.ts +++ b/packages/components/_private/loading/src/types.ts @@ -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 diff --git a/packages/components/_private/mask/src/types.ts b/packages/components/_private/mask/src/types.ts index 0d36f15b5..7848a543c 100644 --- a/packages/components/_private/mask/src/types.ts +++ b/packages/components/_private/mask/src/types.ts @@ -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 diff --git a/packages/components/_private/overflow/src/types.ts b/packages/components/_private/overflow/src/types.ts index 3fce42352..adc7bdd1a 100644 --- a/packages/components/_private/overflow/src/types.ts +++ b/packages/components/_private/overflow/src/types.ts @@ -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 @@ -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(), - 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, + required: true, + }, + data: Object as PropType, + 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, + 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 diff --git a/packages/components/_private/overlay/src/types.ts b/packages/components/_private/overlay/src/types.ts index 8254740fd..1c9a960d5 100644 --- a/packages/components/_private/overlay/src/types.ts +++ b/packages/components/_private/overlay/src/types.ts @@ -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([ - 'topStart', - 'top', - 'topEnd', - 'rightStart', - 'right', - 'rightEnd', - 'bottomStart', - 'bottom', - 'bottomEnd', - 'leftStart', - 'left', - 'leftEnd', -]) -export const overlayTriggerDef = IxPropTypes.oneOf(['click', 'hover', 'focus', 'contextmenu', 'manual']) -export const overlayDelayDef = IxPropTypes.oneOfType([ - Number, - IxPropTypes.array() as unknown as VueTypeDef<[number | null, number | null]>, -]) +export const overlayPlacementDef = String as PropType +export const overlayTriggerDef = String as PropType +export const overlayDelayDef = [Number, Array] as PropType 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)>, + 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 void>>, + 'onUpdate:placement': [Function, Array] as PropType void>>, + onAfterLeave: [Function, Array] as PropType void>>, } export interface OverlayBindings { diff --git a/packages/components/affix/src/types.ts b/packages/components/affix/src/types.ts index faa29682d..8ecab1d64 100644 --- a/packages/components/affix/src/types.ts +++ b/packages/components/affix/src/types.ts @@ -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> export const affixProps = { - offset: IxPropTypes.oneOfType([Number, String, IxPropTypes.object()]).def(0), - target: IxPropTypes.oneOfType([String, HTMLElement, IxPropTypes.func<() => string | HTMLElement>()]), - onChange: IxPropTypes.func<(value: boolean) => void>(), + offset: { + type: [Number, String, Object] as PropType, + default: 0, + }, + target: [String, HTMLElement, Function] as PropType string | HTMLElement)>, + onChange: Function as PropType<(value: boolean) => void>, } export interface AffixBindings { diff --git a/packages/components/alert/src/types.ts b/packages/components/alert/src/types.ts index f33ef30c2..a0dfcc064 100644 --- a/packages/components/alert/src/types.ts +++ b/packages/components/alert/src/types.ts @@ -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()]).def(false), - type: IxPropTypes.oneOf(['success', 'info', 'warning', 'error']).def('info'), - onBeforeClose: IxPropTypes.emit<() => void | boolean | Promise>(), - onClose: IxPropTypes.emit<() => void>(), + closable: { + type: Boolean, + default: undefined, + }, + closeIcon: { + type: String, + default: 'close', + }, + description: String, + icon: String, + title: [String, Array] as PropType, + pagination: { + type: [Boolean, Object] as PropType, + default: false, + }, + type: { + type: String as PropType, + default: 'info', + }, + onBeforeClose: [Function, Array] as PropType void | boolean | Promise>>, + onClose: [Function, Array] as PropType void>>, } export type AlertProps = ExtractInnerPropTypes diff --git a/packages/components/anchor/src/types.ts b/packages/components/anchor/src/types.ts index 303122bae..610df8c58 100644 --- a/packages/components/anchor/src/types.ts +++ b/packages/components/anchor/src/types.ts @@ -5,22 +5,26 @@ * 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 anchorProps = { - affix: IxPropTypes.bool.def(true), - bounds: IxPropTypes.number, - hideLinkBall: IxPropTypes.bool, - offsetTop: IxPropTypes.number, - target: IxPropTypes.oneOfType([String, HTMLElement, IxPropTypes.func<() => string | HTMLElement>()]), - targetOffset: IxPropTypes.number, + affix: { + type: Boolean, + default: true, + }, + bounds: Number, + hideLinkBall: { + type: Boolean, + default: undefined, + }, + offsetTop: Number, + target: [String, HTMLElement, Function] as PropType string | HTMLElement)>, + targetOffset: Number, // events - onChange: IxPropTypes.emit<(activeLink: string) => void>(), - onClick: IxPropTypes.emit<(evt: MouseEvent, link: AnchorLinkProps) => void>(), + onChange: [Function, Array] as PropType void>>, + onClick: [Function, Array] as PropType void>>, } export type AnchorProps = ExtractInnerPropTypes @@ -29,8 +33,11 @@ export type AnchorComponent = DefineComponent> export const linkProps = { - href: IxPropTypes.string.isRequired, - title: IxPropTypes.string, + href: { + type: String, + required: true, + }, + title: String, } export type AnchorLinkProps = ExtractInnerPropTypes diff --git a/packages/components/avatar/src/types.ts b/packages/components/avatar/src/types.ts index 2a41d8c4d..dd7919d41 100644 --- a/packages/components/avatar/src/types.ts +++ b/packages/components/avatar/src/types.ts @@ -6,32 +6,24 @@ */ import type { BreakpointKey } from '@idux/cdk/breakpoint' -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, VNode } from 'vue' export type AvatarShape = 'circle' | 'square' export type AvatarSize = number | 'lg' | 'md' | 'sm' -const sizeProp = IxPropTypes.oneOfType>>([ - Number, - IxPropTypes.oneOf(['lg', 'md', 'sm'] as const), - IxPropTypes.object>(), -]) - export const avatarProps = { - alt: IxPropTypes.string, - gap: IxPropTypes.number, - icon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - shape: IxPropTypes.oneOf(['circle', 'square']), - size: sizeProp, - src: IxPropTypes.string, - srcset: IxPropTypes.string, - text: IxPropTypes.string, + alt: String, + gap: Number, + icon: [String, Object] as PropType, + shape: String as PropType, + size: [Number, String, Object] as PropType>, + src: String, + srcset: String, + text: String, // events - onError: IxPropTypes.emit<(evt: Event) => boolean | void>(), + onError: [Function, Array] as PropType boolean | void>>, } export type AvatarProps = ExtractInnerPropTypes diff --git a/packages/components/back-top/src/types.ts b/packages/components/back-top/src/types.ts index 86e349a2b..c02e74720 100644 --- a/packages/components/back-top/src/types.ts +++ b/packages/components/back-top/src/types.ts @@ -5,17 +5,15 @@ * 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 backTopProps = { - target: IxPropTypes.oneOfType([String, HTMLElement, IxPropTypes.func<() => string | HTMLElement>()]), - duration: IxPropTypes.number, - visibilityHeight: IxPropTypes.number, + target: [String, HTMLElement, Function] as PropType string | HTMLElement)>, + duration: Number, + visibilityHeight: Number, - onClick: IxPropTypes.emit<(evt: MouseEvent) => void>(), + onClick: [Function, Array] as PropType void>>, } export type BackTopProps = ExtractInnerPropTypes diff --git a/packages/components/badge/src/types.ts b/packages/components/badge/src/types.ts index 5aae9b53a..90805bfdb 100644 --- a/packages/components/badge/src/types.ts +++ b/packages/components/badge/src/types.ts @@ -8,14 +8,21 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' import type { DefineComponent, HTMLAttributes } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export const backTopProps = { - count: IxPropTypes.oneOfType([Number, String]).def(0), - showZero: IxPropTypes.bool, - overflowCount: IxPropTypes.number, - dot: IxPropTypes.bool, - color: IxPropTypes.string, + count: { + type: [String, Number], + default: 0, + }, + showZero: { + type: Boolean, + default: undefined, + }, + overflowCount: Number, + dot: { + type: Boolean, + default: undefined, + }, + color: String, } export type BadgeProps = ExtractInnerPropTypes diff --git a/packages/components/breadcrumb/src/types.ts b/packages/components/breadcrumb/src/types.ts index 2edc41301..1e5931369 100644 --- a/packages/components/breadcrumb/src/types.ts +++ b/packages/components/breadcrumb/src/types.ts @@ -8,10 +8,11 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' import type { DefineComponent, HTMLAttributes } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export const breadcrumbProps = { - separator: IxPropTypes.string.def('/'), + separator: { + type: String, + default: '/', + }, } export type BreadcrumbProps = ExtractInnerPropTypes @@ -22,7 +23,7 @@ export type BreadcrumbComponent = DefineComponent< export type BreadcrumbInstance = InstanceType> export const breadcrumbItemProps = { - separator: IxPropTypes.string, + separator: String, } export type BreadcrumbItemProps = ExtractInnerPropTypes diff --git a/packages/components/button/src/types.ts b/packages/components/button/src/types.ts index 6e9f59161..d5997c20a 100644 --- a/packages/components/button/src/types.ts +++ b/packages/components/button/src/types.ts @@ -6,9 +6,7 @@ */ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' -import type { AnchorHTMLAttributes, ButtonHTMLAttributes, DefineComponent, HTMLAttributes } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { AnchorHTMLAttributes, ButtonHTMLAttributes, DefineComponent, HTMLAttributes, PropType } from 'vue' export type ButtonMode = 'primary' | 'default' | 'dashed' | 'text' | 'link' export type ButtonShape = 'circle' | 'round' @@ -16,16 +14,34 @@ export type ButtonSize = 'lg' | 'xl' | 'md' | 'sm' | 'xs' export type ButtonType = 'button' | 'submit' | 'reset' export const buttonProps = { - mode: IxPropTypes.oneOf(['primary', 'default', 'dashed', 'text', 'link']), - danger: IxPropTypes.bool, - ghost: IxPropTypes.bool, - disabled: IxPropTypes.bool, - loading: IxPropTypes.bool, - size: IxPropTypes.oneOf(['lg', 'xl', 'md', 'sm', 'xs']), - shape: IxPropTypes.oneOf(['circle', 'round']), - block: IxPropTypes.bool, - icon: IxPropTypes.string, - type: IxPropTypes.oneOf(['button', 'submit', 'reset']).def('button'), + mode: String as PropType, + danger: { + type: Boolean, + default: undefined, + }, + ghost: { + type: Boolean, + default: undefined, + }, + disabled: { + type: Boolean, + default: undefined, + }, + loading: { + type: Boolean, + default: undefined, + }, + size: String as PropType, + shape: String as PropType, + block: { + type: Boolean, + default: undefined, + }, + icon: String, + type: { + type: String as PropType, + default: 'button', + }, } export type ButtonProps = ExtractInnerPropTypes @@ -36,9 +52,9 @@ export type ButtonComponent = DefineComponent< export type ButtonInstance = InstanceType> export const buttonGroupProps = { - mode: IxPropTypes.oneOf(['primary', 'default', 'dashed', 'text', 'link']), - size: IxPropTypes.oneOf(['lg', 'xl', 'md', 'sm', 'xs']), - shape: IxPropTypes.oneOf(['circle', 'round']), + mode: String as PropType, + size: String as PropType, + shape: String as PropType, } export type ButtonGroupProps = ExtractInnerPropTypes diff --git a/packages/components/card/src/types.ts b/packages/components/card/src/types.ts index aee49901f..ae2520b9d 100644 --- a/packages/components/card/src/types.ts +++ b/packages/components/card/src/types.ts @@ -5,12 +5,10 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils' import type { ButtonProps } from '@idux/components/button' import type { HeaderProps } from '@idux/components/header' -import type { DefineComponent, HTMLAttributes, VNode } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { DefineComponent, HTMLAttributes, PropType, VNode } from 'vue' export type CardSize = 'sm' | 'md' | 'lg' export interface CardCover { @@ -27,21 +25,42 @@ export interface CardButtonProps extends ButtonProps { } export const cardProps = { - borderless: IxPropTypes.bool, - cover: IxPropTypes.oneOfType([String, IxPropTypes.object()]), - header: IxPropTypes.oneOfType([String, IxPropTypes.object()]), - hoverable: IxPropTypes.bool, - shadow: IxPropTypes.bool.def(true), - loading: IxPropTypes.bool.def(false), - size: IxPropTypes.oneOf(['sm', 'md', 'lg']), - footer: IxPropTypes.array(), - disabled: IxPropTypes.bool.def(false), - selected: IxPropTypes.bool.def(false), - selectable: IxPropTypes.bool.def(false), + borderless: { + type: Boolean, + default: undefined, + }, + cover: [String, Object] as PropType, + header: [String, Object] as PropType, + hoverable: { + type: Boolean, + default: undefined, + }, + shadow: { + type: Boolean, + default: true, + }, + loading: { + type: Boolean, + default: false, + }, + size: String as PropType, + footer: Array as PropType<(CardButtonProps | VNode)[]>, + disabled: { + type: Boolean, + default: false, + }, + selected: { + type: Boolean, + default: false, + }, + selectable: { + type: Boolean, + default: false, + }, // event - 'onUpdate:selected': IxPropTypes.emit<(selected: boolean) => void>(), - onSelectedChange: IxPropTypes.emit<(selected: boolean) => void>(), + 'onUpdate:selected': [Function, Array] as PropType void>>, + onSelectedChange: [Function, Array] as PropType void>>, } export type CardProps = ExtractInnerPropTypes @@ -50,7 +69,10 @@ export type CardComponent = DefineComponent> export const cardGridProps = { - hoverable: IxPropTypes.bool, + hoverable: { + type: Boolean, + default: undefined, + }, } export type CardGridProps = ExtractInnerPropTypes diff --git a/packages/components/collapse/src/types.ts b/packages/components/collapse/src/types.ts index 1b420e18b..9732166d3 100644 --- a/packages/components/collapse/src/types.ts +++ b/packages/components/collapse/src/types.ts @@ -5,21 +5,28 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { HeaderProps } from '@idux/components/header' -import type { DefineComponent, HTMLAttributes } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { DefineComponent, HTMLAttributes, PropType } from 'vue' export const collapseProps = { - expandedKeys: IxPropTypes.array(), - accordion: IxPropTypes.bool, - borderless: IxPropTypes.bool, - expandIcon: IxPropTypes.string, - ghost: IxPropTypes.bool, + expandedKeys: Array as PropType, + accordion: { + type: Boolean, + default: undefined, + }, + borderless: { + type: Boolean, + default: undefined, + }, + expandIcon: String, + ghost: { + type: Boolean, + default: undefined, + }, // events - 'onUpdate:expandedKeys': IxPropTypes.emit<(expandedKeys: K[]) => void>(), + 'onUpdate:expandedKeys': [Function, Array] as PropType(expandedKeys: K[]) => void>>, } export type CollapseProps = ExtractInnerPropTypes @@ -28,8 +35,11 @@ export type CollapseComponent = DefineComponent> export const collapsePanelProps = { - disabled: IxPropTypes.bool.def(false), - header: IxPropTypes.oneOfType([String, IxPropTypes.object()]), + disabled: { + type: Boolean, + default: false, + }, + header: [String, Object] as PropType, } export type CollapsePanelProps = ExtractInnerPropTypes diff --git a/packages/components/divider/src/types.ts b/packages/components/divider/src/types.ts index 8e94f5f50..dff2a7c4a 100644 --- a/packages/components/divider/src/types.ts +++ b/packages/components/divider/src/types.ts @@ -5,19 +5,28 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import { type DefineComponent, type HTMLAttributes } from 'vue' +import { type DefineComponent, type HTMLAttributes, type PropType } from 'vue' -import { type ExtractInnerPropTypes, type ExtractPublicPropTypes, IxPropTypes } from '@idux/cdk/utils' +import { type ExtractInnerPropTypes, type ExtractPublicPropTypes } from '@idux/cdk/utils' export const dividerProps = { - dashed: IxPropTypes.bool, - label: IxPropTypes.string, - labelPlacement: IxPropTypes.oneOf(['start', 'center', 'end'] as const), - plain: IxPropTypes.bool, - position: IxPropTypes.oneOf(['left', 'center', 'right'] as const), - size: IxPropTypes.oneOf(['sm', 'md', 'lg'] as const), - type: IxPropTypes.oneOf(['horizontal', 'vertical'] as const), - vertical: IxPropTypes.bool, + dashed: { + type: Boolean, + default: undefined, + }, + label: String, + labelPlacement: String as PropType<'start' | 'center' | 'end'>, + plain: { + type: Boolean, + default: undefined, + }, + position: String as PropType<'left' | 'center' | 'right'>, + size: String as PropType<'sm' | 'md' | 'lg'>, + type: String as PropType<'horizontal' | 'vertical'>, + vertical: { + type: Boolean, + default: undefined, + }, } export type DividerProps = ExtractInnerPropTypes diff --git a/packages/components/drawer/src/types.ts b/packages/components/drawer/src/types.ts index 4eb6fde03..99bfe61fe 100644 --- a/packages/components/drawer/src/types.ts +++ b/packages/components/drawer/src/types.ts @@ -7,13 +7,11 @@ import type { PortalTargetType } from '@idux/cdk/portal' import type { ScrollStrategy } from '@idux/cdk/scroll' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { ɵFooterButtonProps } from '@idux/components/_private/footer' import type { HeaderProps } from '@idux/components/header' import type { DefineComponent, HTMLAttributes, PropType, VNode, VNodeProps } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export type DrawerPlacement = 'top' | 'bottom' | 'start' | 'end' export type DrawerButtonProps = ɵFooterButtonProps @@ -31,33 +29,59 @@ export interface DrawerRef extends DrawerBindings { } export const drawerProps = { - visible: IxPropTypes.bool, - closable: IxPropTypes.bool, - closeIcon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - closeOnEsc: IxPropTypes.bool, - destroyOnHide: IxPropTypes.bool.def(false), - footer: IxPropTypes.oneOfType([IxPropTypes.array(), IxPropTypes.vNode]), - header: IxPropTypes.oneOfType([String, IxPropTypes.object()]), - height: IxPropTypes.oneOfType([String, Number]), - mask: IxPropTypes.bool, - maskClosable: IxPropTypes.bool, - offset: IxPropTypes.oneOfType([String, Number]).def(0), - placement: IxPropTypes.oneOf(['top', 'bottom', 'start', 'end']).def('end'), - scrollStrategy: IxPropTypes.object(), + visible: { + type: Boolean, + default: undefined, + }, + closable: { + type: Boolean, + default: undefined, + }, + closeIcon: [String, Object] as PropType, + closeOnEsc: { + type: Boolean, + default: undefined, + }, + destroyOnHide: { + type: Boolean, + default: false, + }, + footer: [Array, Object] as PropType, + header: [String, Object] as PropType, + height: [String, Number], + mask: { + type: Boolean, + default: undefined, + }, + maskClosable: { + type: Boolean, + default: undefined, + }, + offset: { + type: [String, Number], + default: 0, + }, + placement: { + type: String as PropType, + default: 'end', + }, + scrollStrategy: Object as PropType, target: { type: [String, HTMLElement, Function] as PropType, default: undefined, }, - width: IxPropTypes.oneOfType([String, Number]), - wrapperClassName: IxPropTypes.string, - zIndex: IxPropTypes.number, + width: [String, Number], + wrapperClassName: String, + zIndex: Number, // events - 'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(), - onAfterOpen: IxPropTypes.emit<() => void>(), - onAfterClose: IxPropTypes.emit<() => void>(), - onBeforeClose: IxPropTypes.emit<(evt?: Event | unknown) => void | boolean | Promise>(), - onClose: IxPropTypes.emit<(evt?: Event | unknown) => void>(), + 'onUpdate:visible': [Function, Array] as PropType void>>, + onAfterOpen: [Function, Array] as PropType void>>, + onAfterClose: [Function, Array] as PropType void>>, + onBeforeClose: [Function, Array] as PropType< + MaybeArray<(evt?: Event | unknown) => void | boolean | Promise> + >, + onClose: [Function, Array] as PropType void>>, } export type DrawerProps = ExtractInnerPropTypes diff --git a/packages/components/dropdown/src/types.ts b/packages/components/dropdown/src/types.ts index 020e4c989..40d1ed677 100644 --- a/packages/components/dropdown/src/types.ts +++ b/packages/components/dropdown/src/types.ts @@ -6,26 +6,42 @@ */ import type { PortalTargetType } from '@idux/cdk/portal' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils' import type { DefineComponent, HTMLAttributes, PropType } from 'vue' -import type { VueTypeDef } from 'vue-types' -import { IxPropTypes } from '@idux/cdk/utils' import { ɵOverlayPlacementDef, ɵOverlayTriggerDef } from '@idux/components/_private/overlay' export const dropdownProps = { - visible: IxPropTypes.bool, - autoAdjust: IxPropTypes.bool, - destroyOnHide: IxPropTypes.bool, - disabled: IxPropTypes.bool.def(false), - hideOnClick: IxPropTypes.bool.def(true), - offset: IxPropTypes.array() as unknown as VueTypeDef<[number, number]>, + visible: { + type: Boolean, + default: undefined, + }, + autoAdjust: { + type: Boolean, + default: undefined, + }, + destroyOnHide: { + type: Boolean, + default: undefined, + }, + disabled: { + type: Boolean, + default: false, + }, + hideOnClick: { + type: Boolean, + default: true, + }, + offset: Array as unknown as PropType<[number, number]>, overlayContainer: { type: [String, HTMLElement, Function] as PropType, default: undefined, }, placement: ɵOverlayPlacementDef, - showArrow: IxPropTypes.bool, + showArrow: { + type: Boolean, + default: undefined, + }, /** * @deprecated please use `overlayContainer` instead' */ @@ -36,7 +52,7 @@ export const dropdownProps = { trigger: ɵOverlayTriggerDef, // events - 'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(), + 'onUpdate:visible': [Function, Array] as PropType void>>, } export type DropdownProps = ExtractInnerPropTypes diff --git a/packages/components/empty/src/types.ts b/packages/components/empty/src/types.ts index 7541724e3..5204f6808 100644 --- a/packages/components/empty/src/types.ts +++ b/packages/components/empty/src/types.ts @@ -6,14 +6,12 @@ */ 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, VNode } from 'vue' export const emptyProps = { - description: IxPropTypes.string, - icon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - image: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), + description: String, + icon: [String, Object] as PropType, + image: [String, Object] as PropType, } export type EmptyProps = ExtractInnerPropTypes diff --git a/packages/components/form/src/types.ts b/packages/components/form/src/types.ts index 2701078bc..ab5c7708c 100644 --- a/packages/components/form/src/types.ts +++ b/packages/components/form/src/types.ts @@ -10,22 +10,29 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/ut import type { ColProps } from '@idux/components/grid' import type { DefineComponent, HTMLAttributes, PropType } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - -const colProp = IxPropTypes.oneOfType([Number, String, IxPropTypes.object()]) +const colProp = [Number, String, Object] as PropType export const formProps = { control: { type: [String, Number, Object] as PropType, default: undefined }, - colonless: IxPropTypes.bool, + colonless: { + type: Boolean, + default: undefined, + }, controlCol: colProp, - controlTooltipIcon: IxPropTypes.string, - hasFeedback: IxPropTypes.bool, - labelAlign: IxPropTypes.oneOf(['start', 'end']), + controlTooltipIcon: String, + hasFeedback: { + type: Boolean, + default: undefined, + }, + labelAlign: String as PropType, labelCol: colProp, - labelTooltipIcon: IxPropTypes.string, - layout: IxPropTypes.oneOf(['horizontal', 'vertical', 'inline']), - size: IxPropTypes.oneOf(['lg', 'md', 'sm']), - statusIcon: IxPropTypes.oneOfType([Boolean, IxPropTypes.object>()]).def(false), + labelTooltipIcon: String, + layout: String as PropType, + size: String as PropType, + statusIcon: { + type: [Boolean, Object] as PropType>, + default: false, + }, } export type FormProps = ExtractInnerPropTypes @@ -40,28 +47,38 @@ export type FormValidateMessage = Partial, default: undefined }, controlCol: colProp, - controlTooltip: IxPropTypes.string, - controlTooltipIcon: IxPropTypes.string, - hasFeedback: IxPropTypes.bool, - extra: IxPropTypes.string, - extraMessage: IxPropTypes.string, - label: IxPropTypes.string, - labelAlign: IxPropTypes.oneOf(['start', 'end']), + controlTooltip: String, + controlTooltipIcon: String, + hasFeedback: { + type: Boolean, + default: undefined, + }, + extra: String, + extraMessage: String, + label: String, + labelAlign: String as PropType, labelCol: colProp, - labelFor: IxPropTypes.string, - labelTooltip: IxPropTypes.string, - labelTooltipIcon: IxPropTypes.string, - required: IxPropTypes.bool.def(false), - message: IxPropTypes.oneOfType([ - String, - IxPropTypes.func<(control: AbstractControl) => string>(), - IxPropTypes.object(), - ]), - status: IxPropTypes.oneOf(['valid', 'invalid', 'validating']), - statusIcon: IxPropTypes.oneOfType([Boolean, IxPropTypes.object>()]), + labelFor: String, + labelTooltip: String, + labelTooltipIcon: String, + required: { + type: Boolean, + default: false, + }, + message: [String, Function, Object] as PropType< + string | ((control: AbstractControl) => string) | FormValidateMessage + >, + status: String as PropType, + statusIcon: { + type: [Boolean, Object] as PropType>, + default: undefined, + }, } export type FormItemProps = ExtractInnerPropTypes diff --git a/packages/components/grid/src/types.ts b/packages/components/grid/src/types.ts index 01877efe9..e58f53d29 100644 --- a/packages/components/grid/src/types.ts +++ b/packages/components/grid/src/types.ts @@ -5,25 +5,23 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import { type DefineComponent, type HTMLAttributes } from 'vue' +import { type DefineComponent, type HTMLAttributes, PropType } from 'vue' import { type BreakpointKey } from '@idux/cdk/breakpoint' -import { type ExtractInnerPropTypes, type ExtractPublicPropTypes, IxPropTypes } from '@idux/cdk/utils' +import { type ExtractInnerPropTypes, type ExtractPublicPropTypes } from '@idux/cdk/utils' export type RowAlign = 'start' | 'center' | 'end' | 'baseline' | 'stretch' export type RowJustify = 'start' | 'center' | 'end' | 'space-around' | 'space-between' export type RowGutter = number | string | Array | Partial> export const rowProps = { - align: IxPropTypes.oneOf(['start', 'center', 'end', 'baseline', 'stretch']), - justify: IxPropTypes.oneOf(['start', 'end', 'center', 'space-around', 'space-between']), - gutter: IxPropTypes.oneOfType([ - Number, - String, - IxPropTypes.array(), - IxPropTypes.object>>(), - ]).def(0), - wrap: IxPropTypes.bool, + align: String as PropType, + justify: String as PropType, + gutter: [Number, String, Array, Object] as PropType, + wrap: { + type: Boolean, + default: undefined, + }, } export type RowProps = ExtractInnerPropTypes @@ -39,9 +37,9 @@ export interface ColBreakpointConfig { pull?: number | string } -const singleProp = IxPropTypes.oneOfType([Number, String]) +const singleProp = [Number, String] -const breakpointConfig = IxPropTypes.oneOfType([Number, String, IxPropTypes.object()]) +const breakpointConfig = [Number, String, Object] as PropType export const colProps = { flex: singleProp, diff --git a/packages/components/icon/src/types.ts b/packages/components/icon/src/types.ts index a9155312c..39983ff69 100644 --- a/packages/components/icon/src/types.ts +++ b/packages/components/icon/src/types.ts @@ -8,14 +8,18 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' import type { DefineComponent, HTMLAttributes } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export const iconProps = { - name: IxPropTypes.string, - iconfont: IxPropTypes.bool.def(false), - rotate: IxPropTypes.oneOfType([Boolean, Number, String]), - color: IxPropTypes.string, - size: IxPropTypes.oneOfType([String, Number]), + name: String, + iconfont: { + type: Boolean, + default: false, + }, + rotate: { + type: [Boolean, Number, String], + default: undefined, + }, + color: String, + size: [String, Number], } export type IconProps = ExtractInnerPropTypes diff --git a/packages/components/image/src/types.ts b/packages/components/image/src/types.ts index d6948f8c3..f203f0453 100644 --- a/packages/components/image/src/types.ts +++ b/packages/components/image/src/types.ts @@ -6,7 +6,7 @@ */ import type { PortalTargetType } from '@idux/cdk/portal' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils' import type { DefineComponent, HTMLAttributes, PropType } from 'vue' import { IxPropTypes } from '@idux/cdk/utils' @@ -19,27 +19,45 @@ const zoomValidator = { } export const imageViewerProps = { - visible: IxPropTypes.bool, - activeIndex: IxPropTypes.number, - images: IxPropTypes.array().def([]), + visible: { + type: Boolean, + default: undefined, + }, + activeIndex: Number, + images: { + type: Array as PropType, + default: (): string[] => [], + }, zoom: IxPropTypes.custom(zoomValidator.validator, zoomValidator.msg), - loop: IxPropTypes.bool, + loop: { + type: Boolean, + default: undefined, + }, target: { type: [String, HTMLElement, Function] as PropType, default: undefined, }, - maskClosable: IxPropTypes.bool, + maskClosable: { + type: Boolean, + default: undefined, + }, - 'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(), - 'onUpdate:activeIndex': IxPropTypes.emit<(curIndex: number) => void>(), + 'onUpdate:visible': [Function, Array] as PropType void>>, + 'onUpdate:activeIndex': [Function, Array] as PropType void>>, } export const imageProps = { - src: IxPropTypes.string.isRequired, - preview: IxPropTypes.bool, - imageViewer: IxPropTypes.shape({ ...imageViewerProps, images: IxPropTypes.array() }), - onLoad: IxPropTypes.emit<(e: Event) => void>(), - onError: IxPropTypes.emit<(e: Event) => void>(), + src: { + type: String, + required: true, + }, + preview: { + type: Boolean, + default: undefined, + }, + imageViewer: Object as PropType, + onLoad: [Function, Array] as PropType void>>, + onError: [Function, Array] as PropType void>>, } export type ImageProps = ExtractInnerPropTypes diff --git a/packages/components/input-number/src/types.ts b/packages/components/input-number/src/types.ts index 13b32af27..fe277a5ab 100644 --- a/packages/components/input-number/src/types.ts +++ b/packages/components/input-number/src/types.ts @@ -6,32 +6,50 @@ */ import type { AbstractControl } from '@idux/cdk/forms' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils' import type { FormSize } from '@idux/components/form' import type { DefineComponent, HTMLAttributes, PropType } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export type InputNumberButtonPosition = 'inner' | 'outer' export const inputNumberProps = { - value: IxPropTypes.oneOfType([IxPropTypes.number]), + value: [Number, null] as PropType, control: { type: [String, Number, Object] as PropType, default: undefined }, - disabled: IxPropTypes.bool.def(false), - keyboard: IxPropTypes.bool, - max: IxPropTypes.number.def(Infinity), - min: IxPropTypes.number.def(-Infinity), - placeholder: IxPropTypes.string, - precision: IxPropTypes.number, - readonly: IxPropTypes.bool.def(false), - size: IxPropTypes.oneOf(['sm', 'md', 'lg']), - step: IxPropTypes.number.def(1), + disabled: { + type: Boolean, + default: false, + }, + keyboard: { + type: Boolean, + default: undefined, + }, + max: { + type: Number, + default: Infinity, + }, + min: { + type: Number, + default: -Infinity, + }, + placeholder: String, + precision: Number, + readonly: { + type: Boolean, + default: false, + }, + size: String as PropType, + step: { + type: Number, + default: 1, + }, // events - 'onUpdate:value': IxPropTypes.emit<(value: number | null) => void>(), - onChange: IxPropTypes.emit<(value: number | null, oldValue: number | null | undefined) => void>(), - onFocus: IxPropTypes.emit<(evt: FocusEvent) => void>(), - onBlur: IxPropTypes.emit<(evt: FocusEvent) => void>(), + 'onUpdate:value': [Function, Array] as PropType void>>, + onChange: [Function, Array] as PropType< + MaybeArray<(value: number | null, oldValue: number | null | undefined) => void> + >, + onFocus: [Function, Array] as PropType void>>, + onBlur: [Function, Array] as PropType void>>, } export type InputNumberProps = ExtractInnerPropTypes diff --git a/packages/components/layout/src/types.ts b/packages/components/layout/src/types.ts index 76e8c5cc1..86cb2161f 100644 --- a/packages/components/layout/src/types.ts +++ b/packages/components/layout/src/types.ts @@ -6,10 +6,8 @@ */ import type { BreakpointKey } from '@idux/cdk/breakpoint' -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 layoutProps = {} @@ -46,11 +44,14 @@ export type LayoutFooterComponent = DefineComponent< export type LayoutFooterInstance = InstanceType> export const layoutSiderProps = { - collapsed: IxPropTypes.bool, - breakpoint: IxPropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), + collapsed: { + type: Boolean, + default: undefined, + }, + breakpoint: String as PropType, // events - 'onUpdate:collapsed': IxPropTypes.emit<(collapsed: boolean) => void>(), + 'onUpdate:collapsed': [Function, Array] as PropType void>>, } export type LayoutSiderProps = ExtractInnerPropTypes diff --git a/packages/components/list/src/types.ts b/packages/components/list/src/types.ts index b8829ae1f..376b2cb3b 100644 --- a/packages/components/list/src/types.ts +++ b/packages/components/list/src/types.ts @@ -8,9 +8,7 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' import type { RowProps } from '@idux/components/grid' import type { SpinProps } from '@idux/components/spin' -import type { DefineComponent, HTMLAttributes } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { DefineComponent, HTMLAttributes, PropType } from 'vue' export type ListSize = 'sm' | 'md' | 'lg' export interface ListGridProps extends RowProps { @@ -24,13 +22,19 @@ export interface ListGridProps extends RowProps { } export const listProps = { - header: IxPropTypes.string, - footer: IxPropTypes.string, - empty: IxPropTypes.string, - borderless: IxPropTypes.bool, - loading: IxPropTypes.bool.def(false) || IxPropTypes.object(), - size: IxPropTypes.oneOf(['sm', 'md', 'lg']), - grid: IxPropTypes.object(), + header: String, + footer: String, + empty: String, + borderless: { + type: Boolean, + default: undefined, + }, + loading: { + type: [Boolean, Object] as PropType, + default: false, + }, + size: String as PropType, + grid: Object as PropType, } export type ListProps = ExtractInnerPropTypes @@ -39,9 +43,9 @@ export type ListComponent = DefineComponent> export const listItemProps = { - title: IxPropTypes.string, - content: IxPropTypes.string, - extra: IxPropTypes.string, + title: String, + content: String, + extra: String, } export type ListItemProps = ExtractInnerPropTypes diff --git a/packages/components/menu/src/types.ts b/packages/components/menu/src/types.ts index 0853f354c..d7785d897 100644 --- a/packages/components/menu/src/types.ts +++ b/packages/components/menu/src/types.ts @@ -8,11 +8,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import type { PortalTargetType } from '@idux/cdk/portal' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { DefineComponent, FunctionalComponent, HTMLAttributes, PropType, VNode, VNodeChild } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export type MenuMode = 'vertical' | 'horizontal' | 'inline' export type MenuTheme = 'light' | 'dark' @@ -23,22 +21,34 @@ export interface MenuClickOptions { } export const menuProps = { - expandedKeys: IxPropTypes.arrayOf(IxPropTypes.oneOfType([String, Number, Symbol])), - selectedKeys: IxPropTypes.arrayOf(IxPropTypes.oneOfType([String, Number, Symbol])), + expandedKeys: Array as PropType, + selectedKeys: Array as PropType, - collapsed: IxPropTypes.bool.def(false), + collapsed: { + type: Boolean, + default: false, + }, customAdditional: { type: Object as PropType, default: undefined }, - dataSource: IxPropTypes.array(), + dataSource: Array as PropType, getKey: { type: [String, Function] as PropType(data: MenuData) => K)>, default: undefined }, - indent: IxPropTypes.number, - mode: IxPropTypes.oneOf(['vertical', 'horizontal', 'inline']).def('vertical'), - multiple: IxPropTypes.bool.def(false), - overlayClassName: IxPropTypes.string, + indent: Number, + mode: { + type: String as PropType, + default: 'vertical', + }, + multiple: { + type: Boolean, + default: false, + }, + overlayClassName: String, overlayContainer: { type: [String, HTMLElement, Function] as PropType, default: undefined, }, - selectable: IxPropTypes.bool.def(true), + selectable: { + type: Boolean, + default: true, + }, /** * @deprecated please use `overlayContainer` instead' */ @@ -46,12 +56,12 @@ export const menuProps = { type: [String, HTMLElement, Function] as PropType, default: undefined, }, - theme: IxPropTypes.oneOf(['light', 'dark']), + theme: String as PropType, // events - 'onUpdate:expandedKeys': IxPropTypes.emit<(expandedKeys: K[]) => void>(), - 'onUpdate:selectedKeys': IxPropTypes.emit<(selectedKeys: K[]) => void>(), - onClick: IxPropTypes.emit<(options: MenuClickOptions) => void>(), + 'onUpdate:expandedKeys': [Function, Array] as PropType(expandedKeys: K[]) => void>>, + 'onUpdate:selectedKeys': [Function, Array] as PropType(selectedKeys: K[]) => void>>, + onClick: [Function, Array] as PropType(options: MenuClickOptions) => void>>, } export type MenuProps = ExtractInnerPropTypes @@ -185,16 +195,25 @@ export type MenuCustomAdditional = (options: { // private export const menuItemProps = { - data: IxPropTypes.object().isRequired, + data: { + type: Object as PropType, + required: true, + }, index: { type: Number, required: true }, } as const export const menuItemGroupProps = { - data: IxPropTypes.object().isRequired, + data: { + type: Object as PropType, + required: true, + }, index: { type: Number, required: true }, } as const export const menuSubProps = { - data: IxPropTypes.object().isRequired, + data: { + type: Object as PropType, + required: true, + }, index: { type: Number, required: true }, } as const diff --git a/packages/components/message/src/types.ts b/packages/components/message/src/types.ts index 9d760224d..54e6f9ca2 100644 --- a/packages/components/message/src/types.ts +++ b/packages/components/message/src/types.ts @@ -6,11 +6,9 @@ */ import type { PortalTargetType } from '@idux/cdk/portal' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { DefineComponent, HTMLAttributes, PropType, VNode } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export type MessageType = 'info' | 'success' | 'warning' | 'error' | 'loading' export interface MessageOptions extends MessagePublicProps { @@ -25,15 +23,24 @@ export interface MessageRef { } export const messageProps = { - visible: IxPropTypes.bool, - destroyOnHover: IxPropTypes.bool, - duration: IxPropTypes.number, - icon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - type: IxPropTypes.oneOf(['info', 'success', 'warning', 'error', 'loading']).def('info'), + visible: { + type: Boolean, + default: undefined, + }, + destroyOnHover: { + type: Boolean, + default: undefined, + }, + duration: Number, + icon: [String, Object] as PropType, + type: { + type: String as PropType, + default: 'info', + }, // events - 'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(), - onClose: IxPropTypes.emit<(evt?: Event) => void>(), + 'onUpdate:visible': [Function, Array] as PropType void>>, + onClose: [Function, Array] as PropType void>>, } export type MessageProps = ExtractInnerPropTypes @@ -42,8 +49,8 @@ export type MessageComponent = DefineComponent> export const messageProviderProps = { - maxCount: IxPropTypes.number, - top: IxPropTypes.oneOfType([String, Number]), + maxCount: Number, + top: [String, Number], target: { type: [String, HTMLElement, Function] as PropType, default: undefined, diff --git a/packages/components/modal/src/types.ts b/packages/components/modal/src/types.ts index 549d1b0a9..c5a313d86 100644 --- a/packages/components/modal/src/types.ts +++ b/packages/components/modal/src/types.ts @@ -7,14 +7,12 @@ import type { PortalTargetType } from '@idux/cdk/portal' import type { ScrollStrategy } from '@idux/cdk/scroll' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { ɵFooterButtonProps } from '@idux/components/_private/footer' import type { ButtonProps } from '@idux/components/button' import type { HeaderProps } from '@idux/components/header' import type { DefineComponent, HTMLAttributes, PropType, VNode, VNodeProps } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export type ModalType = 'default' | 'confirm' | 'info' | 'success' | 'warning' | 'error' export type ModalButtonProps = ɵFooterButtonProps export interface ModalOptions extends ModalPublicProps { @@ -30,43 +28,78 @@ export interface ModalRef extends ModalBindings { } export const modalProps = { - visible: IxPropTypes.bool, - cancelButton: IxPropTypes.object(), - cancelText: IxPropTypes.string, - centered: IxPropTypes.bool, - closable: IxPropTypes.bool, - closeIcon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - closeOnEsc: IxPropTypes.bool, - destroyOnHide: IxPropTypes.bool.def(false), - footer: IxPropTypes.oneOfType([Boolean, IxPropTypes.array(), IxPropTypes.vNode]).def(true), - header: IxPropTypes.oneOfType([String, IxPropTypes.object()]), - icon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - mask: IxPropTypes.bool, - maskClosable: IxPropTypes.bool, - animatable: IxPropTypes.bool.def(true), - offset: IxPropTypes.oneOfType([String, Number]).def(128), - okButton: IxPropTypes.object(), - okText: IxPropTypes.string, - scrollStrategy: IxPropTypes.object(), + visible: { + type: Boolean, + default: undefined, + }, + cancelButton: Object as PropType, + cancelText: String, + centered: { + type: Boolean, + default: undefined, + }, + closable: { + type: Boolean, + default: undefined, + }, + closeIcon: [String, Object] as PropType, + closeOnEsc: { + type: Boolean, + default: undefined, + }, + destroyOnHide: { + type: Boolean, + default: false, + }, + footer: { + type: [Boolean, Array, Object] as PropType, + default: true, + }, + header: [String, Object] as PropType, + icon: [String, Object] as PropType, + mask: { + type: Boolean, + default: undefined, + }, + maskClosable: { + type: Boolean, + default: undefined, + }, + animatable: { + type: Boolean, + default: true, + }, + offset: { + type: [String, Number], + default: 128, + }, + okButton: Object as PropType, + okText: String, + scrollStrategy: Object as PropType, target: { type: [String, HTMLElement, Function] as PropType, default: undefined, }, - title: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - type: IxPropTypes.oneOf(['default', 'confirm', 'info', 'success', 'warning', 'error']).def('default'), - width: IxPropTypes.oneOfType([String, Number]), - wrapperClassName: IxPropTypes.string, - zIndex: IxPropTypes.number, + title: [String, Object] as PropType, + type: { + type: String as PropType, + default: 'default', + }, + width: [String, Number], + wrapperClassName: String, + zIndex: Number, draggable: { type: Boolean, default: false }, // events - 'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(), - onAfterOpen: IxPropTypes.emit<() => void>(), - onAfterClose: IxPropTypes.emit<() => void>(), - onBeforeClose: IxPropTypes.emit<(evt?: Event | unknown) => void | boolean | Promise>(), - onClose: IxPropTypes.emit<(evt?: Event | unknown) => void>(), - onCancel: IxPropTypes.emit<(evt?: Event | unknown) => unknown>(), - onOk: IxPropTypes.emit<(evt?: Event | unknown) => unknown>(), + 'onUpdate:visible': [Function, Array] as PropType void>>, + onAfterOpen: [Function, Array] as PropType void>>, + onAfterClose: [Function, Array] as PropType void>>, + onBeforeClose: [Function, Array] as PropType< + MaybeArray<(evt?: Event | unknown) => void | boolean | Promise> + >, + onClose: [Function, Array] as PropType void>>, + onCancel: [Function, Array] as PropType unknown>>, + onOk: [Function, Array] as PropType unknown>>, } export type ModalProps = ExtractInnerPropTypes diff --git a/packages/components/notification/src/types.ts b/packages/components/notification/src/types.ts index 3c3eb3616..9ca65ef87 100644 --- a/packages/components/notification/src/types.ts +++ b/packages/components/notification/src/types.ts @@ -6,12 +6,10 @@ */ import type { PortalTargetType } from '@idux/cdk/portal' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { ButtonProps } from '@idux/components/button' import type { DefineComponent, HTMLAttributes, PropType, VNode } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - // 挑出部分必填的属性 type PickRequire = Pick> & Required> @@ -29,29 +27,31 @@ export interface SlotProps { export const notificationType = ['info', 'success', 'warning', 'error'] as const export const notificationPlacement = ['topStart', 'topEnd', 'bottomStart', 'bottomEnd'] as const export const notificationProps = { - visible: IxPropTypes.bool, - destroyOnHover: IxPropTypes.bool, - duration: IxPropTypes.number, - icon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - closeIcon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - type: IxPropTypes.oneOf(['info', 'success', 'warning', 'error']), - key: IxPropTypes.oneOfType([String, Number, Symbol]), - title: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - content: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - footer: IxPropTypes.oneOfType([ - IxPropTypes.array(), - IxPropTypes.vNode, - String, - ]), - placement: IxPropTypes.oneOf(['topStart', 'topEnd', 'bottomStart', 'bottomEnd']), + visible: { + type: Boolean, + default: undefined, + }, + destroyOnHover: { + type: Boolean, + default: undefined, + }, + duration: Number, + icon: [String, Object] as PropType, + closeIcon: [String, Object] as PropType, + type: String as PropType, + key: [String, Number, Symbol] as PropType, + title: [String, Object] as PropType, + content: [String, Object] as PropType, + footer: [String, Array, Object] as PropType, + placement: String as PropType, // event - 'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(), - onClose: IxPropTypes.emit<(evt?: Event) => void>(), + 'onUpdate:visible': [Function, Array] as PropType void>>, + onClose: [Function, Array] as PropType void>>, } export const notificationProviderProps = { - offset: IxPropTypes.oneOfType([String, Number, Array]), - maxCount: IxPropTypes.number, + offset: [String, Number, Array] as PropType, + maxCount: Number, target: { type: [String, HTMLElement, Function] as PropType, default: undefined, diff --git a/packages/components/pagination/src/types.ts b/packages/components/pagination/src/types.ts index 5efce3235..ee2db5041 100644 --- a/packages/components/pagination/src/types.ts +++ b/packages/components/pagination/src/types.ts @@ -5,10 +5,8 @@ * 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, VNode } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils' +import type { DefineComponent, HTMLAttributes, PropType, VNode } from 'vue' export type PaginationSize = 'sm' | 'md' export type PaginationItemType = 'page' | 'prev' | 'next' | 'prev5' | 'next5' @@ -21,22 +19,43 @@ export interface PaginationItemRenderOptions { } export const paginationProps = { - pageIndex: IxPropTypes.number, - pageSize: IxPropTypes.number, - disabled: IxPropTypes.bool.def(false), - pageSizes: IxPropTypes.arrayOf(Number), - showQuickJumper: IxPropTypes.bool, - showSizeChanger: IxPropTypes.bool, - showTitle: IxPropTypes.bool, - showTotal: IxPropTypes.bool, - simple: IxPropTypes.bool, - size: IxPropTypes.oneOf(['sm', 'md']), - total: IxPropTypes.number.def(0), + pageIndex: Number, + pageSize: Number, + disabled: { + type: Boolean, + default: false, + }, + pageSizes: Array as PropType, + showQuickJumper: { + type: Boolean, + default: undefined, + }, + showSizeChanger: { + type: Boolean, + default: undefined, + }, + showTitle: { + type: Boolean, + default: undefined, + }, + showTotal: { + type: Boolean, + default: undefined, + }, + simple: { + type: Boolean, + default: undefined, + }, + size: String as PropType, + total: { + type: Number, + default: 0, + }, // events - 'onUpdate:pageIndex': IxPropTypes.emit<(pageIndex: number) => void>(), - 'onUpdate:pageSize': IxPropTypes.emit<(pageSize: number) => void>(), - onChange: IxPropTypes.emit<(pageIndex: number, pageSize: number) => void>(), + 'onUpdate:pageIndex': [Function, Array] as PropType void>>, + 'onUpdate:pageSize': [Function, Array] as PropType void>>, + onChange: [Function, Array] as PropType void>>, } export type PaginationProps = ExtractInnerPropTypes @@ -47,9 +66,15 @@ export type PaginationComponent = DefineComponent< export type PaginationInstance = InstanceType> export const paginationItemProps = { - disabled: IxPropTypes.bool, - index: IxPropTypes.number, - type: IxPropTypes.oneOf(['page', 'prev', 'next', 'prev5', 'next5']).isRequired, + disabled: { + type: Boolean, + default: undefined, + }, + index: Number, + type: { + type: String as PropType, + required: true, + }, } export type PaginationItemProps = ExtractInnerPropTypes diff --git a/packages/components/popconfirm/src/types.ts b/packages/components/popconfirm/src/types.ts index c761fc6cf..ebf8f3cff 100644 --- a/packages/components/popconfirm/src/types.ts +++ b/packages/components/popconfirm/src/types.ts @@ -5,25 +5,30 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { ButtonProps } from '@idux/components/button' -import type { DefineComponent, HTMLAttributes, VNode } from 'vue' +import type { DefineComponent, HTMLAttributes, PropType, VNode } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' import { ɵTooltipProps } from '@idux/components/tooltip' export const popconfirmProps = { ...ɵTooltipProps, - cancelButton: IxPropTypes.object(), - cancelText: IxPropTypes.string, - okButton: IxPropTypes.object(), - okText: IxPropTypes.string, - icon: IxPropTypes.string.def('exclamation-circle-filled'), - footer: IxPropTypes.oneOfType([Boolean, IxPropTypes.array(), IxPropTypes.vNode]).def(true), + cancelButton: Object as PropType, + cancelText: String, + okButton: Object as PropType, + okText: String, + icon: { + type: String, + default: 'exclamation-circle-filled', + }, + footer: { + type: [Boolean, Array, Object] as PropType, + default: true, + }, - 'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(), - onCancel: IxPropTypes.emit<(evt?: Event | unknown) => unknown>(), - onOk: IxPropTypes.emit<(evt?: Event | unknown) => unknown>(), + 'onUpdate:visible': [Function, Array] as PropType void>>, + onCancel: [Function, Array] as PropType unknown>>, + onOk: [Function, Array] as PropType unknown>>, } export interface PopconfirmButtonProps extends ButtonProps { key?: K diff --git a/packages/components/popover/src/types.ts b/packages/components/popover/src/types.ts index 8076fd1ee..8785ca8e3 100644 --- a/packages/components/popover/src/types.ts +++ b/packages/components/popover/src/types.ts @@ -7,17 +7,19 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' import type { HeaderProps } from '@idux/components/header' -import type { DefineComponent, HTMLAttributes } from 'vue' +import type { DefineComponent, HTMLAttributes, PropType, VNode } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' import { ɵTooltipProps } from '@idux/components/tooltip' export const popoverProps = { ...ɵTooltipProps, - closable: IxPropTypes.bool.def(false), - closeIcon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - header: IxPropTypes.oneOfType([String, IxPropTypes.object()]), - content: IxPropTypes.string, + closable: { + type: Boolean, + default: false, + }, + closeIcon: [String, Object] as PropType, + header: [String, Object] as PropType, + content: String, } export type PopoverProps = ExtractInnerPropTypes diff --git a/packages/components/progress/src/types.ts b/packages/components/progress/src/types.ts index e5376fc63..670b2e2b2 100644 --- a/packages/components/progress/src/types.ts +++ b/packages/components/progress/src/types.ts @@ -6,9 +6,7 @@ */ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' -import type { DefineComponent, HTMLAttributes, VNode, VNodeChild } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { DefineComponent, HTMLAttributes, PropType, VNode, VNodeChild } from 'vue' export type ProgressSize = 'sm' | 'md' | 'lg' export type ProgressFormat = (percent: number, successPercent?: number) => VNodeChild @@ -37,21 +35,33 @@ export interface ProgressIcons { export const progressStatus = ['normal', 'success', 'exception', 'active'] as const export const progressProps = { - type: IxPropTypes.oneOf(['line', 'circle', 'dashboard']).def('line'), - format: IxPropTypes.func(), - percent: IxPropTypes.oneOfType([String, Number]).def(0), - status: IxPropTypes.oneOf(['normal', 'success', 'exception', 'active']), - hideInfo: IxPropTypes.bool.def(false), - success: IxPropTypes.object(), - trailColor: IxPropTypes.string, - strokeColor: IxPropTypes.oneOfType([String, IxPropTypes.object()]), - strokeLinecap: IxPropTypes.oneOf(['round', 'square']), - strokeWidth: IxPropTypes.oneOfType([String, Number]), - gapDegree: IxPropTypes.oneOfType([String, Number]), - gapPosition: IxPropTypes.oneOf(['top', 'bottom', 'left', 'right']), - width: IxPropTypes.oneOfType([String, Number]).def(132), - size: IxPropTypes.oneOf(['sm', 'md', 'lg']), - icons: IxPropTypes.object(), + type: { + type: String as PropType, + default: 'line', + }, + format: Function as PropType, + percent: { + type: [String, Number], + default: 0, + }, + status: String as PropType, + hideInfo: { + type: Boolean, + default: false, + }, + success: Object as PropType, + trailColor: String, + strokeColor: [String, Object] as PropType, + strokeLinecap: String as PropType, + strokeWidth: [String, Number], + gapDegree: [String, Number], + gapPosition: String as PropType, + width: { + type: [String, Number], + default: 132, + }, + size: String as PropType, + icons: Object as PropType, } export type ProgressProps = ExtractInnerPropTypes diff --git a/packages/components/rate/src/types.ts b/packages/components/rate/src/types.ts index 974b5ae17..f3e52d082 100644 --- a/packages/components/rate/src/types.ts +++ b/packages/components/rate/src/types.ts @@ -5,28 +5,38 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils' import type { FormSize } from '@idux/components/form' -import type { DefineComponent, HTMLAttributes } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { DefineComponent, HTMLAttributes, PropType } from 'vue' export const rateProps = { - value: IxPropTypes.oneOfType([Number, String]), - allowHalf: IxPropTypes.bool, - clearable: IxPropTypes.bool, - count: IxPropTypes.oneOfType([Number, String]), - disabled: IxPropTypes.bool.def(false), - icon: IxPropTypes.string, - tooltips: IxPropTypes.arrayOf(String).def(() => []), - size: IxPropTypes.oneOf(['sm', 'md', 'lg']), + value: [Number, String], + allowHalf: { + type: Boolean, + default: undefined, + }, + clearable: { + type: Boolean, + default: undefined, + }, + count: [Number, String], + disabled: { + type: Boolean, + default: false, + }, + icon: String, + tooltips: { + type: Array as PropType, + default: (): string[] => [], + }, + size: String as PropType, // events - 'onUpdate:value': IxPropTypes.emit<(value: number) => void>(), - onChange: IxPropTypes.emit<(value: number) => void>(), - onBlur: IxPropTypes.emit<(evt: FocusEvent) => void>(), - onFocus: IxPropTypes.emit<(evt: FocusEvent) => void>(), - onKeyDown: IxPropTypes.emit<(evt: KeyboardEvent) => void>(), + 'onUpdate:value': [Function, Array] as PropType void>>, + onChange: [Function, Array] as PropType void>>, + onBlur: [Function, Array] as PropType void>>, + onFocus: [Function, Array] as PropType void>>, + onKeyDown: [Function, Array] as PropType void>>, } export type RateProps = ExtractInnerPropTypes @@ -40,15 +50,39 @@ export type RateInstance = InstanceType // private export const rateItemProps = { - count: IxPropTypes.number.isRequired, - disabled: IxPropTypes.bool.isRequired, - focused: IxPropTypes.bool.isRequired, - index: IxPropTypes.number.isRequired, - prefixCls: IxPropTypes.string.isRequired, - tooltip: IxPropTypes.string, - value: IxPropTypes.number.isRequired, + count: { + type: Number, + required: true, + }, + disabled: { + type: Boolean, + required: true, + }, + focused: { + type: Boolean, + required: true, + }, + index: { + type: Number, + required: true, + }, + prefixCls: { + type: String, + required: true, + }, + tooltip: String, + value: { + type: Number, + required: true, + }, // events - onClick: IxPropTypes.func<(evt: MouseEvent, element: HTMLElement, index: number) => void>().isRequired, - onMouseMove: IxPropTypes.func<(evt: MouseEvent, element: HTMLElement, index: number) => void>().isRequired, + onClick: { + type: Function as PropType<(evt: MouseEvent, element: HTMLElement, index: number) => void>, + required: true, + }, + onMouseMove: { + type: Function as PropType<(evt: MouseEvent, element: HTMLElement, index: number) => void>, + required: true, + }, } diff --git a/packages/components/result/src/types.ts b/packages/components/result/src/types.ts index 8a11166df..1890a6dd8 100644 --- a/packages/components/result/src/types.ts +++ b/packages/components/result/src/types.ts @@ -6,17 +6,15 @@ */ 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, VNode } from 'vue' export type ResultStatus = 'success' | 'error' | 'info' | 'warning' export const resultProps = { - icon: IxPropTypes.oneOfType([String, IxPropTypes.vNode]), - status: IxPropTypes.oneOf(['success', 'error', 'info', 'warning']), - subtitle: IxPropTypes.string, - title: IxPropTypes.string, + icon: [String, Object] as PropType, + status: String as PropType, + subtitle: String, + title: String, } export type ResultProps = ExtractInnerPropTypes diff --git a/packages/components/skeleton/src/types.ts b/packages/components/skeleton/src/types.ts index 645e599f5..aeeccbb1f 100644 --- a/packages/components/skeleton/src/types.ts +++ b/packages/components/skeleton/src/types.ts @@ -6,19 +6,29 @@ */ 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' type SkeletonType = 'text' | 'rect' | 'round' | 'circle' export const skeletonProps = { - animated: IxPropTypes.bool, - loading: IxPropTypes.bool.def(true), - type: IxPropTypes.oneOf(['round', 'circle', 'text', 'rect']).def('text'), - width: IxPropTypes.oneOfType([String, Number]), - height: IxPropTypes.oneOfType([String, Number]), - repeat: IxPropTypes.number.def(1), + animated: { + type: Boolean, + default: undefined, + }, + loading: { + type: Boolean, + default: true, + }, + type: { + type: String as PropType, + default: 'text', + }, + width: [String, Number], + height: [String, Number], + repeat: { + type: Number, + default: 1, + }, } export type SkeletonProps = ExtractInnerPropTypes diff --git a/packages/components/space/src/types.ts b/packages/components/space/src/types.ts index 896700c30..50d20945b 100644 --- a/packages/components/space/src/types.ts +++ b/packages/components/space/src/types.ts @@ -6,9 +6,7 @@ */ 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 SpaceAlign = 'start' | 'center' | 'end' | 'baseline' | 'stretch' export type SpaceJustify = 'start' | 'center' | 'end' | 'space-around' | 'space-between' @@ -16,18 +14,27 @@ export type SpaceDirection = 'vertical' | 'horizontal' export type SpaceSize = 'sm' | 'md' | 'lg' export const spaceProps = { - align: IxPropTypes.oneOf(['start', 'center', 'end', 'baseline', 'stretch']), - block: IxPropTypes.bool, + align: String as PropType, + block: { + type: Boolean, + default: undefined, + }, /** * @deprecated please use `vertical` instead' */ - direction: IxPropTypes.oneOf(['vertical', 'horizontal']), - justify: IxPropTypes.oneOf(['start', 'center', 'end', 'space-around', 'space-between']), - size: IxPropTypes.oneOfType([Number, String, IxPropTypes.array()]), - split: IxPropTypes.string, - separator: IxPropTypes.string, - vertical: IxPropTypes.bool, - wrap: IxPropTypes.bool, + direction: String as PropType, + justify: String as PropType, + size: [Number, String, Array] as PropType, + split: String, + separator: String, + vertical: { + type: Boolean, + default: undefined, + }, + wrap: { + type: Boolean, + default: undefined, + }, } export type SpaceProps = ExtractInnerPropTypes diff --git a/packages/components/spin/src/types.ts b/packages/components/spin/src/types.ts index 91d9b1dee..c49553cb3 100644 --- a/packages/components/spin/src/types.ts +++ b/packages/components/spin/src/types.ts @@ -6,23 +6,27 @@ */ 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 SpinTipAlignType = 'horizontal' | 'vertical' export type SpinSize = 'lg' | 'md' | 'sm' export const spinProps = { - strokeWidth: IxPropTypes.number, - radius: IxPropTypes.number, - duration: IxPropTypes.number, - spinning: IxPropTypes.bool.def(true), - rotate: IxPropTypes.bool.def(true), - icon: IxPropTypes.string, - tip: IxPropTypes.string, - tipAlign: IxPropTypes.oneOf(['horizontal', 'vertical'] as const), - size: IxPropTypes.oneOf(['lg', 'md', 'sm'] as const), + strokeWidth: Number, + radius: Number, + duration: Number, + spinning: { + type: Boolean, + default: true, + }, + rotate: { + type: Boolean, + default: true, + }, + icon: String, + tip: String, + tipAlign: String as PropType<'horizontal' | 'vertical'>, + size: String as PropType<'lg' | 'md' | 'sm'>, } export type SpinProps = ExtractInnerPropTypes diff --git a/packages/components/statistic/src/types.ts b/packages/components/statistic/src/types.ts index 041c65d38..49f0185f0 100644 --- a/packages/components/statistic/src/types.ts +++ b/packages/components/statistic/src/types.ts @@ -6,18 +6,20 @@ */ import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' -import type { DefineComponent, HTMLAttributes } from 'vue' +import type { DefineComponent, HTMLAttributes, PropType } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' import { NumFormatter } from '@idux/components/config' export const statisticProps = { - formatter: IxPropTypes.func(), - precision: IxPropTypes.number, - prefix: IxPropTypes.string, - suffix: IxPropTypes.string, - title: IxPropTypes.string, - value: IxPropTypes.oneOfType([String, Number]).def(''), + formatter: Function as PropType, + precision: Number, + prefix: String, + suffix: String, + title: String, + value: { + type: [String, Number], + default: '', + }, } export type StatisticProps = ExtractInnerPropTypes diff --git a/packages/components/stepper/src/types.ts b/packages/components/stepper/src/types.ts index 12ca9aa96..a31f20f46 100644 --- a/packages/components/stepper/src/types.ts +++ b/packages/components/stepper/src/types.ts @@ -5,24 +5,39 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import { type DefineComponent, type HTMLAttributes } from 'vue' +import { type DefineComponent, type HTMLAttributes, PropType } from 'vue' -import { type ExtractInnerPropTypes, type ExtractPublicPropTypes, IxPropTypes, type VKey } from '@idux/cdk/utils' +import { + type ExtractInnerPropTypes, + type ExtractPublicPropTypes, + IxPropTypes, + MaybeArray, + type VKey, +} from '@idux/cdk/utils' export type StepperLabelPlacement = 'end' | 'bottom' export type StepperSize = 'md' | 'sm' export type StepperStatus = 'process' | 'finish' | 'wait' | 'error' export const stepperProps = { - activeKey: IxPropTypes.oneOfType([String, Number, Symbol]), - clickable: IxPropTypes.bool, - labelPlacement: IxPropTypes.oneOf(['end', 'bottom']), + activeKey: [String, Number, Symbol] as PropType, + clickable: { + type: Boolean, + default: undefined, + }, + labelPlacement: String as PropType, percent: IxPropTypes.range(0, 100), - size: IxPropTypes.oneOf(['md', 'sm']), - status: IxPropTypes.oneOf(['process', 'finish', 'wait', 'error']).def('process'), - vertical: IxPropTypes.bool.def(false), + size: String as PropType, + status: { + type: String as PropType, + default: 'process', + }, + vertical: { + type: Boolean, + default: false, + }, - 'onUpdate:activeKey': IxPropTypes.emit<(key: K) => void>(), + 'onUpdate:activeKey': [Function, Array] as PropType(key: K) => void>>, } export type StepperProps = ExtractInnerPropTypes @@ -31,11 +46,14 @@ export type StepperComponent = DefineComponent> export const stepperItemProps = { - description: IxPropTypes.string, - disabled: IxPropTypes.bool.def(false), - icon: IxPropTypes.string, - title: IxPropTypes.string, - status: IxPropTypes.oneOf(['process', 'finish', 'wait', 'error']), + description: String, + disabled: { + type: Boolean, + default: false, + }, + icon: String, + title: String, + status: String as PropType, } export type StepperItemProps = ExtractInnerPropTypes diff --git a/packages/components/switch/src/types.ts b/packages/components/switch/src/types.ts index af904f52f..1966e9831 100644 --- a/packages/components/switch/src/types.ts +++ b/packages/components/switch/src/types.ts @@ -6,25 +6,38 @@ */ import type { AbstractControl } from '@idux/cdk/forms' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils' import type { DefineComponent, HTMLAttributes, PropType } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export const switchProps = { - checked: IxPropTypes.bool, + checked: { + type: Boolean, + default: undefined, + }, control: { type: [String, Number, Object] as PropType, default: undefined }, - autofocus: IxPropTypes.bool.def(false), - disabled: IxPropTypes.bool.def(false), - labels: IxPropTypes.arrayOf(String).def(() => []), - loading: IxPropTypes.bool.def(false), - size: IxPropTypes.oneOf(['sm', 'md', 'lg'] as const), + autofocus: { + type: Boolean, + default: false, + }, + disabled: { + type: Boolean, + default: false, + }, + labels: { + type: Array as PropType, + default: (): string[] => [], + }, + loading: { + type: Boolean, + default: false, + }, + size: String as PropType<'sm' | 'md' | 'lg'>, // events - 'onUpdate:checked': IxPropTypes.emit<(checked: boolean) => void>(), - onChange: IxPropTypes.emit<(checked: boolean) => void>(), - onBlur: IxPropTypes.emit<(evt: FocusEvent) => void>(), - onFocus: IxPropTypes.emit<(evt: FocusEvent) => void>(), + 'onUpdate:checked': [Function, Array] as PropType void>>, + onChange: [Function, Array] as PropType void>>, + onBlur: [Function, Array] as PropType void>>, + onFocus: [Function, Array] as PropType void>>, } export type SwitchProps = ExtractInnerPropTypes diff --git a/packages/components/tag/src/types.ts b/packages/components/tag/src/types.ts index c0bfee22e..86ef085e3 100644 --- a/packages/components/tag/src/types.ts +++ b/packages/components/tag/src/types.ts @@ -5,18 +5,16 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' -import type { DefineComponent, HTMLAttributes } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' +import type { DefineComponent, HTMLAttributes, PropType } from 'vue' export type TagShape = 'round' | 'rect' export const tagProps = { - color: IxPropTypes.string, - icon: IxPropTypes.string, - number: IxPropTypes.number, - shape: IxPropTypes.oneOf(['round', 'rect']), + color: String, + icon: String, + number: Number, + shape: String as PropType, } export type TagProps = ExtractInnerPropTypes @@ -30,17 +28,32 @@ export interface TagData extends Omit { } export const tagGroupProps = { - activeKeys: IxPropTypes.array().def(() => []), - clickable: IxPropTypes.bool.def(false), - closable: IxPropTypes.bool.def(false), - closeIcon: IxPropTypes.string.def('close'), - dataSource: IxPropTypes.array(), - gap: IxPropTypes.oneOfType([Number, String]), - wrap: IxPropTypes.bool, - shape: IxPropTypes.oneOf(['rect', 'round']), - 'onUpdate:activeKeys': IxPropTypes.emit<(activeKeys: K[]) => void>(), - onClick: IxPropTypes.emit<(key: K, evt: MouseEvent) => void>(), - onClose: IxPropTypes.emit<(key: K, evt: MouseEvent) => void>(), + activeKeys: { + type: Array as PropType, + default: (): VKey[] => [], + }, + clickable: { + type: Boolean, + default: false, + }, + closable: { + type: Boolean, + default: false, + }, + closeIcon: { + type: String, + default: 'close', + }, + dataSource: Array as PropType, + gap: [Number, String], + wrap: { + type: Boolean, + default: undefined, + }, + shape: String as PropType, + 'onUpdate:activeKeys': [Function, Array] as PropType(activeKeys: K[]) => void>>, + onClick: [Function, Array] as PropType void>>, + onClose: [Function, Array] as PropType void>>, } export type TagGroupProps = ExtractInnerPropTypes diff --git a/packages/components/timeline/src/types.ts b/packages/components/timeline/src/types.ts index 29201b048..eda271878 100644 --- a/packages/components/timeline/src/types.ts +++ b/packages/components/timeline/src/types.ts @@ -6,19 +6,29 @@ */ 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 TimelinePlacement = 'start' | 'alternate' | 'end' export type TimelineItemPlacement = 'start' | 'end' export const timelineProps = { - pending: IxPropTypes.oneOfType([String, Boolean]).def(false), - pendingDot: IxPropTypes.string, - reverse: IxPropTypes.bool.def(false), - placement: IxPropTypes.oneOf(['start', 'alternate', 'end']).def('end'), - both: IxPropTypes.bool.def(true), + pending: { + type: [String, Boolean], + default: false, + }, + pendingDot: String, + reverse: { + type: Boolean, + default: false, + }, + placement: { + type: String as PropType, + default: 'end', + }, + both: { + type: Boolean, + default: true, + }, } export type TimelineProps = ExtractInnerPropTypes @@ -27,10 +37,13 @@ export type TimelineComponent = DefineComponent> export const timelineItemProps = { - color: IxPropTypes.string.def('primary'), - dot: IxPropTypes.string, - label: IxPropTypes.string, - placement: IxPropTypes.oneOf(['start', 'end']), + color: { + type: String, + default: 'primary', + }, + dot: String, + label: String, + placement: String as PropType, } export type TimelineItemProps = ExtractInnerPropTypes diff --git a/packages/components/tooltip/src/types.ts b/packages/components/tooltip/src/types.ts index f60705872..f57456254 100644 --- a/packages/components/tooltip/src/types.ts +++ b/packages/components/tooltip/src/types.ts @@ -6,28 +6,36 @@ */ import type { PortalTargetType } from '@idux/cdk/portal' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '@idux/cdk/utils' import type { DefineComponent, HTMLAttributes, PropType } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' import { ɵOverlayDelayDef, ɵOverlayPlacementDef, ɵOverlayTriggerDef } from '@idux/components/_private/overlay' export const tooltipProps = { - visible: IxPropTypes.bool, - autoAdjust: IxPropTypes.bool, - destroyOnHide: IxPropTypes.bool, + visible: { + type: Boolean, + default: undefined, + }, + autoAdjust: { + type: Boolean, + default: undefined, + }, + destroyOnHide: { + type: Boolean, + default: undefined, + }, delay: ɵOverlayDelayDef, placement: ɵOverlayPlacementDef, target: { type: [String, HTMLElement, Function] as PropType, default: undefined, }, - title: IxPropTypes.string, + title: String, trigger: ɵOverlayTriggerDef, - zIndex: IxPropTypes.number, + zIndex: Number, // events - 'onUpdate:visible': IxPropTypes.emit<(visible: boolean) => void>(), + 'onUpdate:visible': [Function, Array] as PropType void>>, } export type TooltipProps = ExtractInnerPropTypes diff --git a/packages/components/tree/src/types.ts b/packages/components/tree/src/types.ts index ce5653c0d..417d52e84 100644 --- a/packages/components/tree/src/types.ts +++ b/packages/components/tree/src/types.ts @@ -9,77 +9,109 @@ import type { MergedNode } from './composables/useDataSource' import type { VirtualScrollToFn } from '@idux/cdk/scroll' -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { EmptyProps } from '@idux/components/empty' import type { DefineComponent, HTMLAttributes, PropType } from 'vue' -import { IxPropTypes } from '@idux/cdk/utils' - export type CheckStrategy = 'all' | 'parent' | 'child' export const treeProps = { - checkedKeys: IxPropTypes.array(), - expandedKeys: IxPropTypes.array(), - indeterminateKeys: IxPropTypes.array(), - loadedKeys: IxPropTypes.array(), - selectedKeys: IxPropTypes.array(), - - blocked: IxPropTypes.bool, - cascade: IxPropTypes.bool.def(false), - checkable: IxPropTypes.bool.def(false), - childrenKey: IxPropTypes.string, - checkStrategy: IxPropTypes.oneOf(['all', 'parent', 'child']).def('all'), + checkedKeys: Array as PropType, + expandedKeys: Array as PropType, + indeterminateKeys: Array as PropType, + loadedKeys: Array as PropType, + selectedKeys: Array as PropType, + + blocked: { + type: Boolean, + default: undefined, + }, + cascade: { + type: Boolean, + default: false, + }, + checkable: { + type: Boolean, + default: false, + }, + childrenKey: String, + checkStrategy: { + type: String as PropType, + default: 'all', + }, customAdditional: { type: Object as PropType, default: undefined }, - dataSource: IxPropTypes.array().def(() => []), - disabled: IxPropTypes.func<(node: TreeNode) => boolean | TreeNodeDisabled>(), - draggable: IxPropTypes.bool.def(false), + dataSource: { + type: Array as PropType, + default: (): TreeNode[] => [], + }, + disabled: Function as PropType<(node: TreeNode) => boolean | TreeNodeDisabled>, + draggable: { + type: Boolean, + default: false, + }, draggableIcon: { type: String, default: undefined }, - droppable: IxPropTypes.func(), - empty: IxPropTypes.oneOfType([String, IxPropTypes.object()]), + droppable: Function as PropType, + empty: [String, Object] as PropType, expandIcon: { type: [String, Array] as PropType, default: undefined }, getKey: { type: [String, Function] as PropType VKey)>, default: undefined }, - height: IxPropTypes.number, - labelKey: IxPropTypes.string, - leafLineIcon: IxPropTypes.string, - loadChildren: IxPropTypes.func<(node: TreeNode) => Promise>(), + height: Number, + labelKey: String, + leafLineIcon: String, + loadChildren: Function as PropType<(node: TreeNode) => Promise>, /** * @deprecated please use `getKey` instead' */ - nodeKey: IxPropTypes.oneOfType([String, IxPropTypes.func<(node: TreeNode) => VKey>()]), - searchFn: IxPropTypes.func<(node: TreeNode, searchValue?: string) => boolean>(), - searchValue: IxPropTypes.string, - selectable: IxPropTypes.oneOfType([Boolean, IxPropTypes.oneOf(['multiple'])]).def(true), - showLine: IxPropTypes.bool, - virtual: IxPropTypes.bool.def(false), + nodeKey: [String, Function] as PropType VKey)>, + searchFn: Function as PropType<(node: TreeNode, searchValue?: string) => boolean>, + searchValue: String, + selectable: { + type: [Boolean, String] as PropType, + default: true, + }, + showLine: { + type: Boolean, + default: undefined, + }, + virtual: { + type: Boolean, + default: false, + }, // events - 'onUpdate:checkedKeys': IxPropTypes.emit<(keys: K[]) => void>(), - 'onUpdate:expandedKeys': IxPropTypes.emit<(keys: K[]) => void>(), - 'onUpdate:loadedKeys': IxPropTypes.emit<(keys: K[]) => void>(), - 'onUpdate:selectedKeys': IxPropTypes.emit<(keys: K[]) => void>(), - onCheck: IxPropTypes.emit<(checked: boolean, node: TreeNode) => void>(), - onCheckedChange: IxPropTypes.emit<(checkedKeys: K[], checkedNodes: TreeNode[]) => void>(), - onDragstart: IxPropTypes.emit<(options: TreeDragDropOptions) => void>(), - onDragend: IxPropTypes.emit<(options: TreeDragDropOptions) => void>(), - onDragenter: IxPropTypes.emit<(options: TreeDragDropOptions) => void>(), - onDragleave: IxPropTypes.emit<(options: TreeDragDropOptions) => void>(), - onDragover: IxPropTypes.emit<(options: TreeDragDropOptions) => void>(), - onDrop: IxPropTypes.emit<(options: TreeDragDropOptions) => void>(), - onExpand: IxPropTypes.emit<(expanded: boolean, node: TreeNode) => void>(), - onExpandedChange: IxPropTypes.emit<(expendedKeys: K[], expendedNodes: TreeNode[]) => void>(), - onLoaded: IxPropTypes.emit<(loadedKeys: K[], node: TreeNode) => void>(), - onSelect: IxPropTypes.emit<(selected: boolean, node: TreeNode) => void>(), - onSelectedChange: IxPropTypes.emit<(selectedKeys: K[], selectedNodes: TreeNode[]) => void>(), - onFocus: IxPropTypes.emit<(evt: FocusEvent) => void>(), - onBlur: IxPropTypes.emit<(evt: FocusEvent) => void>(), - onKeydown: IxPropTypes.emit<(evt: KeyboardEvent) => void>(), - onKeyup: IxPropTypes.emit<(evt: KeyboardEvent) => void>(), - onNodeClick: IxPropTypes.emit<(evt: Event, node: TreeNode) => void>(), - onNodeContextmenu: IxPropTypes.emit<(evt: Event, node: TreeNode) => void>(), - onScroll: IxPropTypes.emit<(evt: Event) => void>(), - onScrolledChange: - IxPropTypes.emit<(startIndex: number, endIndex: number, visibleNodes: TreeNode[]) => void>(), - onScrolledBottom: IxPropTypes.emit<() => void>(), + 'onUpdate:checkedKeys': [Function, Array] as PropType(keys: K[]) => void>>, + 'onUpdate:expandedKeys': [Function, Array] as PropType(keys: K[]) => void>>, + 'onUpdate:loadedKeys': [Function, Array] as PropType(keys: K[]) => void>>, + 'onUpdate:selectedKeys': [Function, Array] as PropType(keys: K[]) => void>>, + onCheck: [Function, Array] as PropType(checked: boolean, node: TreeNode) => void>>, + onCheckedChange: [Function, Array] as PropType< + MaybeArray<(checkedKeys: K[], checkedNodes: TreeNode[]) => void> + >, + onDragstart: [Function, Array] as PropType(options: TreeDragDropOptions) => void>>, + onDragend: [Function, Array] as PropType(options: TreeDragDropOptions) => void>>, + onDragenter: [Function, Array] as PropType(options: TreeDragDropOptions) => void>>, + onDragleave: [Function, Array] as PropType(options: TreeDragDropOptions) => void>>, + onDragover: [Function, Array] as PropType(options: TreeDragDropOptions) => void>>, + onDrop: [Function, Array] as PropType(options: TreeDragDropOptions) => void>>, + onExpand: [Function, Array] as PropType(expanded: boolean, node: TreeNode) => void>>, + onExpandedChange: [Function, Array] as PropType< + MaybeArray<(expendedKeys: K[], expendedNodes: TreeNode[]) => void> + >, + onLoaded: [Function, Array] as PropType(loadedKeys: K[], node: TreeNode) => void>>, + onSelect: [Function, Array] as PropType(selected: boolean, node: TreeNode) => void>>, + onSelectedChange: [Function, Array] as PropType< + MaybeArray<(selectedKeys: K[], selectedNodes: TreeNode[]) => void> + >, + onFocus: [Function, Array] as PropType void>>, + onBlur: [Function, Array] as PropType void>>, + onKeydown: [Function, Array] as PropType void>>, + onKeyup: [Function, Array] as PropType void>>, + onNodeClick: [Function, Array] as PropType(evt: Event, node: TreeNode) => void>>, + onNodeContextmenu: [Function, Array] as PropType(evt: Event, node: TreeNode) => void>>, + onScroll: [Function, Array] as PropType void>>, + onScrolledChange: [Function, Array] as PropType< + MaybeArray<(startIndex: number, endIndex: number, visibleNodes: TreeNode[]) => void> + >, + onScrolledBottom: [Function, Array] as PropType void>>, } export type TreeProps = ExtractInnerPropTypes @@ -155,46 +187,118 @@ export interface TreeDragDropOptions { // private export const motionTreeNodeProps = { - expanded: IxPropTypes.bool, - expandedNodes: IxPropTypes.array(), - node: IxPropTypes.object(), - prefixCls: IxPropTypes.string.isRequired, + expanded: { + type: Boolean, + default: undefined, + }, + expandedNodes: Array as PropType, + node: Object as PropType, + prefixCls: { + type: String, + required: true, + }, } export const treeNodeProps = { - node: IxPropTypes.object().isRequired, - isLeaf: IxPropTypes.bool.isRequired, - isFirst: IxPropTypes.bool.isRequired, - isLast: IxPropTypes.bool.isRequired, - label: IxPropTypes.string, - level: IxPropTypes.number.isRequired, - rawNode: IxPropTypes.object().isRequired, - expanded: IxPropTypes.bool.isRequired, - children: IxPropTypes.array(), - parentKey: IxPropTypes.oneOfType([String, Number, Symbol]), - checkDisabled: IxPropTypes.bool, - dragDisabled: IxPropTypes.bool, - dropDisabled: IxPropTypes.bool, - selectDisabled: IxPropTypes.bool, + node: { + type: Object as PropType, + required: true, + }, + isLeaf: { + type: Boolean, + required: true, + }, + isFirst: { + type: Boolean, + required: true, + }, + isLast: { + type: Boolean, + required: true, + }, + label: String, + level: { + type: Number, + required: true, + }, + rawNode: { + type: Object as PropType, + required: true, + }, + expanded: { + type: Boolean, + required: true, + }, + children: Array as PropType, + parentKey: [String, Number, Symbol] as PropType, + checkDisabled: { + type: Boolean, + default: undefined, + }, + dragDisabled: { + type: Boolean, + default: undefined, + }, + dropDisabled: { + type: Boolean, + default: undefined, + }, + selectDisabled: { + type: Boolean, + default: undefined, + }, } export const treeNodeCheckboxProps = { - node: IxPropTypes.object().isRequired, - checkDisabled: IxPropTypes.bool, + node: { + type: Object as PropType, + required: true, + }, + checkDisabled: { + type: Boolean, + default: undefined, + }, } export const treeNodeExpandProps = { - expanded: IxPropTypes.bool.isRequired, - hasTopLine: IxPropTypes.bool, - isLeaf: IxPropTypes.bool, - nodeKey: IxPropTypes.oneOfType([String, Number, Symbol]).isRequired, - rawNode: IxPropTypes.object().isRequired, + expanded: { + type: Boolean, + required: true, + }, + hasTopLine: { + type: Boolean, + default: undefined, + }, + isLeaf: { + type: Boolean, + default: undefined, + }, + nodeKey: { + type: [String, Number, Symbol] as PropType, + required: true, + }, + rawNode: { + type: Object as PropType, + required: true, + }, } export const treeNodeContentProps = { - disabled: IxPropTypes.bool, - nodeKey: IxPropTypes.oneOfType([String, Number, Symbol]).isRequired, - label: IxPropTypes.string, - rawNode: IxPropTypes.object().isRequired, - selected: IxPropTypes.bool, + disabled: { + type: Boolean, + default: undefined, + }, + nodeKey: { + type: [String, Number, Symbol] as PropType, + required: true, + }, + label: String, + rawNode: { + type: Object as PropType, + required: true, + }, + selected: { + type: Boolean, + default: undefined, + }, } diff --git a/packages/components/upload/src/types.ts b/packages/components/upload/src/types.ts index f8bae4438..26d137b22 100644 --- a/packages/components/upload/src/types.ts +++ b/packages/components/upload/src/types.ts @@ -5,11 +5,9 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import type { ExtractInnerPropTypes, ExtractPublicPropTypes, VKey } from '@idux/cdk/utils' +import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils' import type { ProgressProps } from '@idux/components/progress' -import type { DefineComponent, HTMLAttributes, VNode } from 'vue' - -import { IxPropTypes } from '@idux/cdk/utils' +import type { DefineComponent, HTMLAttributes, PropType, VNode } from 'vue' type DataType = Record export type UploadRequestHeader = Record @@ -60,30 +58,49 @@ export interface UploadRequestChangeOption { } export const uploadProps = { - files: IxPropTypes.array().isRequired, - accept: IxPropTypes.string, - action: IxPropTypes.oneOfType([String, IxPropTypes.func<(file: UploadFile) => Promise>()]).isRequired, - dragable: IxPropTypes.bool, - directory: IxPropTypes.bool, - disabled: IxPropTypes.bool, - maxCount: IxPropTypes.number, - multiple: IxPropTypes.bool, - progress: IxPropTypes.object(), - name: IxPropTypes.string, - customRequest: IxPropTypes.func<(option: UploadRequestOption) => { abort: () => void }>(), - withCredentials: IxPropTypes.bool, - requestData: IxPropTypes.oneOfType DataType | Promise)>([ - Object, - IxPropTypes.func<(file: UploadFile) => DataType | Promise>(), - ]), - requestHeaders: IxPropTypes.object(), - requestMethod: IxPropTypes.oneOf(['POST', 'PUT', 'PATCH', 'post', 'put', 'patch']), - 'onUpdate:files': IxPropTypes.emit<(fileList: UploadFile[]) => void>(), - onSelect: IxPropTypes.emit<(file: File[]) => boolean | File[] | Promise>(), - onBeforeUpload: - IxPropTypes.emit<(file: UploadFile) => boolean | UploadFile | Promise>>(), - onFileStatusChange: IxPropTypes.emit<(file: UploadFile) => void>(), - onRequestChange: IxPropTypes.emit<(option: UploadRequestChangeOption) => void>(), + files: { + type: Array as PropType, + required: true, + }, + accept: String, + action: { + type: [String, Function] as PropType<(file: UploadFile) => Promise>, + required: true, + }, + dragable: { + type: Boolean, + default: undefined, + }, + directory: { + type: Boolean, + default: undefined, + }, + disabled: { + type: Boolean, + default: undefined, + }, + maxCount: Number, + multiple: { + type: Boolean, + default: undefined, + }, + progress: Object as PropType, + name: String, + customRequest: Function as PropType<(option: UploadRequestOption) => { abort: () => void }>, + withCredentials: { + type: Boolean, + default: undefined, + }, + requestData: [Object, Function] as PropType DataType | Promise)>, + requestHeaders: Object as PropType, + requestMethod: String as PropType<'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch'>, + 'onUpdate:files': [Function, Array] as PropType(fileList: UploadFile[]) => void>>, + onSelect: [Function, Array] as PropType boolean | File[] | Promise>>, + onBeforeUpload: [Function, Array] as PropType< + MaybeArray<(file: UploadFile) => boolean | UploadFile | Promise>> + >, + onFileStatusChange: [Function, Array] as PropType(file: UploadFile) => void>>, + onRequestChange: [Function, Array] as PropType(option: UploadRequestChangeOption) => void>>, } export type UploadProps = ExtractInnerPropTypes export type UploadPublicProps = ExtractPublicPropTypes @@ -91,12 +108,12 @@ export type UploadComponent = DefineComponent> export const uploadFilesProps = { - type: IxPropTypes.oneOf(['text', 'image', 'imageCard']), - icon: IxPropTypes.object>>(), - onDownload: IxPropTypes.emit<(file: UploadFile) => void>(), - onPreview: IxPropTypes.emit<(file: UploadFile) => void>(), - onRemove: IxPropTypes.emit<(file: UploadFile) => boolean | Promise>(), - onRetry: IxPropTypes.emit<(file: UploadFile) => void>(), + type: String as PropType, + icon: Object as PropType>>, + onDownload: [Function, Array] as PropType(file: UploadFile) => void>>, + onPreview: [Function, Array] as PropType(file: UploadFile) => void>>, + onRemove: [Function, Array] as PropType(file: UploadFile) => boolean | Promise>>, + onRetry: [Function, Array] as PropType(file: UploadFile) => void>>, } export type UploadFilesProps = ExtractInnerPropTypes export type UploadFilesPublicProps = ExtractPublicPropTypes