Skip to content

Commit

Permalink
feat: update type
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Sep 13, 2024
1 parent 339fb4a commit 49d4b31
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 23 deletions.
4 changes: 2 additions & 2 deletions components/image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion components/message/useMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const Holder = defineComponent({
'rtl',
'transitionName',
'onAllRemoved',
] as any,
'animation',
'staticGetContainer',
],
setup(props, { expose }) {
const { getPrefixCls, getPopupContainer } = useConfigInject('message', props);

Expand Down
2 changes: 2 additions & 0 deletions components/vc-image/src/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions components/vc-notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>([]);
Expand Down Expand Up @@ -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;
});
Expand Down
6 changes: 4 additions & 2 deletions components/vc-overflow/Overflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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)}
Expand Down
4 changes: 2 additions & 2 deletions components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions components/vc-table/Cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface CellProps<RecordType = DefaultRecordType> {

transformCellText?: TransformCellText<RecordType>;
}
export default defineComponent<CellProps>({
export default defineComponent({
name: 'Cell',
props: [
'prefixCls',
Expand All @@ -104,7 +104,7 @@ export default defineComponent<CellProps>({
'column',
'cellType',
'transformCellText',
] as any,
],
setup(props, { slots }) {
const contextSlots = useInjectSlots();
const { onHover, startRow, endRow } = useInjectHover();
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions components/vc-table/Footer/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions components/vc-table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 || []),
);

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion components/vc-table/hooks/useColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;
Expand Down
4 changes: 2 additions & 2 deletions components/vc-trigger/Popup/PopupInner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 49d4b31

Please sign in to comment.