feat: update type

pull/7839/head 4.2.4
tangjinzhou 2 months ago
parent 339fb4a230
commit 49d4b3166e

@ -13,10 +13,10 @@ export type ImageProps = Partial<
ExtractPropTypes<ReturnType<typeof imageProps>> &
Omit<ImgHTMLAttributes, 'placeholder' | 'onClick'>
>;
const Image = defineComponent<ImageProps>({
const Image = defineComponent({
name: 'AImage',
inheritAttrs: false,
props: imageProps() as any,
props: imageProps(),
setup(props, { slots, attrs }) {
const { prefixCls, rootPrefixCls, configProvider } = useConfigInject('image', props);
// Style

@ -47,7 +47,9 @@ const Holder = defineComponent({
'rtl',
'transitionName',
'onAllRemoved',
] as any,
'animation',
'staticGetContainer',
],
setup(props, { expose }) {
const { getPrefixCls, getPopupContainer } = useConfigInject('message', props);

@ -32,6 +32,8 @@ export const imageProps = () => ({
rootClassName: String,
prefixCls: String,
previewPrefixCls: String,
width: [Number, String],
height: [Number, String],
previewMask: {
type: [Boolean, Function] as PropType<false | (() => any)>,
default: undefined,

@ -2,6 +2,7 @@ import { getTransitionGroupProps } from '../_util/transition';
import type { Key, VueNode } from '../_util/type';
import type { CSSProperties } from 'vue';
import {
toRaw,
shallowRef,
createVNode,
computed,
@ -72,10 +73,10 @@ type NotificationState = {
holderCallback?: HolderReadyCallback;
}[];
const Notification = defineComponent<NotificationProps>({
const Notification = defineComponent({
name: 'Notification',
inheritAttrs: false,
props: ['prefixCls', 'transitionName', 'animation', 'maxCount', 'closeIcon', 'hashId'] as any,
props: ['prefixCls', 'transitionName', 'animation', 'maxCount', 'closeIcon', 'hashId'],
setup(props, { attrs, expose, slots }) {
const hookRefs = new Map<Key, HTMLDivElement>();
const notices = ref<NotificationState>([]);
@ -125,7 +126,7 @@ const Notification = defineComponent<NotificationProps>({
};
const remove = (removeKey: Key) => {
notices.value = notices.value.filter(({ notice: { key, userPassKey } }) => {
notices.value = toRaw(notices.value as any).filter(({ notice: { key, userPassKey } }) => {
const mergedKey = userPassKey || key;
return mergedKey !== removeKey;
});

@ -39,14 +39,15 @@ const overflowProps = () => {
/** When set to `full`, ssr will render full items by default and remove at client side */
ssr: String as PropType<'full'>,
onMousedown: Function as PropType<MouseEventHandler>,
role: String,
};
};
type InterOverflowProps = Partial<ExtractPropTypes<ReturnType<typeof overflowProps>>>;
export type OverflowProps = HTMLAttributes & InterOverflowProps;
const Overflow = defineComponent<OverflowProps>({
const Overflow = defineComponent({
name: 'Overflow',
inheritAttrs: false,
props: overflowProps() as any,
props: overflowProps(),
emits: ['visibleChange'],
setup(props, { attrs, emit, slots }) {
const fullySSR = computed(() => props.ssr === 'full');
@ -331,6 +332,7 @@ const Overflow = defineComponent<OverflowProps>({
class={classNames(!invalidate.value && prefixCls, className)}
style={style}
onMousedown={onMousedown}
role={props.role}
{...restAttrs}
>
{mergedData.value.map(internalRenderItemNode)}

@ -18,9 +18,9 @@ export type TimeUnitColumnProps = {
onSelect?: (value: number) => void;
};
export default defineComponent<TimeUnitColumnProps>({
export default defineComponent({
name: 'TimeUnitColumn',
props: ['prefixCls', 'units', 'onSelect', 'value', 'active', 'hideDisabledOptions'] as any,
props: ['prefixCls', 'units', 'onSelect', 'value', 'active', 'hideDisabledOptions'],
setup(props) {
const { open } = useInjectPanel();

@ -77,7 +77,7 @@ export interface CellProps<RecordType = DefaultRecordType> {
transformCellText?: TransformCellText<RecordType>;
}
export default defineComponent<CellProps>({
export default defineComponent({
name: 'Cell',
props: [
'prefixCls',
@ -104,7 +104,7 @@ export default defineComponent<CellProps>({
'column',
'cellType',
'transformCellText',
] as any,
],
setup(props, { slots }) {
const contextSlots = useInjectSlots();
const { onHover, startRow, endRow } = useInjectHover();
@ -318,7 +318,7 @@ export default defineComponent<CellProps>({
// ====================== Render ======================
let title: string;
const ellipsisConfig: CellEllipsisType = ellipsis === true ? { showTitle: true } : ellipsis;
const ellipsisConfig = ellipsis === true ? { showTitle: true } : ellipsis;
if (ellipsisConfig && (ellipsisConfig.showTitle || rowType === 'header')) {
if (typeof childNode === 'string' || typeof childNode === 'number') {
title = childNode.toString();

@ -12,9 +12,9 @@ export interface SummaryCellProps {
align?: AlignType;
}
export default defineComponent<SummaryCellProps>({
export default defineComponent({
name: 'ATableSummaryCell',
props: ['index', 'colSpan', 'rowSpan', 'align'] as any,
props: ['index', 'colSpan', 'rowSpan', 'align'],
setup(props, { attrs, slots }) {
const tableContext = useInjectTable();
const summaryContext = useInjectSummary();

@ -149,7 +149,7 @@ export interface TableProps<RecordType = DefaultRecordType> {
transformCellText?: TransformCellText<RecordType>;
}
export default defineComponent<TableProps<DefaultRecordType>>({
export default defineComponent({
name: 'VcTable',
inheritAttrs: false,
props: [
@ -191,7 +191,7 @@ export default defineComponent<TableProps<DefaultRecordType>>({
'canExpandable',
'onUpdateInternalRefs',
'transformCellText',
] as any,
],
emits: ['expand', 'expandedRowsChange', 'updateInternalRefs', 'update:expandedRowKeys'],
setup(props, { attrs, slots, emit }) {
const mergedData = computed(() => props.data || EMPTY_DATA);
@ -271,7 +271,7 @@ export default defineComponent<TableProps<DefaultRecordType>>({
// defalutXxxx
stop();
const mergedExpandedKeys = computed(
const mergedExpandedKeys = computed<Set<Key>>(
() => new Set(props.expandedRowKeys || innerExpandedKeys.value || []),
);
@ -282,9 +282,9 @@ export default defineComponent<TableProps<DefaultRecordType>>({
const hasKey = mergedExpandedKeys.value.has(key);
if (hasKey) {
mergedExpandedKeys.value.delete(key);
newExpandedKeys = [...mergedExpandedKeys.value];
newExpandedKeys = [...(mergedExpandedKeys.value as any)];
} else {
newExpandedKeys = [...mergedExpandedKeys.value, key];
newExpandedKeys = [...(mergedExpandedKeys.value as any), key];
}
innerExpandedKeys.value = newExpandedKeys;

@ -108,7 +108,7 @@ function useColumns<RecordType>(
prefixCls?: Ref<string>;
columns?: Ref<ColumnsType<RecordType>>;
expandable: Ref<boolean>;
expandedKeys: Ref<Set<Key>>;
expandedKeys: ComputedRef<Set<Key>>;
getRowKey: Ref<GetRowKey<RecordType>>;
onTriggerExpand: TriggerEventHandler<RecordType>;
expandIcon?: Ref<RenderExpandIcon<RecordType>>;

@ -204,11 +204,11 @@ export default defineComponent({
class={mergedClassName}
onMouseenter={onMouseenter}
onMouseleave={onMouseleave}
onMousedown={withModifiers(onMousedown, ['capture'])}
onMousedown={withModifiers(onMousedown, ['capture'] as any)}
{...{
[supportsPassive ? 'onTouchstartPassive' : 'onTouchstart']: withModifiers(
onTouchstart,
['capture'],
['capture'] as any,
),
}}
style={mergedStyle}

Loading…
Cancel
Save