From 122b2fda829e7ef37e2bd9f0b4d4e7a5e7376db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=85=E6=9F=93=20=7C=20JiuRan?= <58846658+JiuRanYa@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:33:02 +0800 Subject: [PATCH] fix: popper content type check (#17040) * fix: popper content type check * fix: code lint * fix: effect type * fix: all popper effect type * fix: replace all EffectType --------- Co-authored-by: Tong Siyuan --- packages/components/popper/src/content.ts | 3 ++- packages/components/select-v2/src/defaults.ts | 8 ++++++-- packages/components/select/src/select.ts | 8 ++++++-- packages/components/time-select/src/time-select.ts | 5 +++-- packages/components/tooltip-v2/src/content.ts | 5 +++-- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/components/popper/src/content.ts b/packages/components/popper/src/content.ts index 39b1b9a8ef..b7642d4b7a 100644 --- a/packages/components/popper/src/content.ts +++ b/packages/components/popper/src/content.ts @@ -2,6 +2,7 @@ import { placements } from '@popperjs/core' import { buildProps, definePropType } from '@element-plus/utils' import { useAriaProps } from '@element-plus/hooks' +import type { PopperEffect } from './popper' import type { ExtractPropTypes, StyleValue } from 'vue' import type { Options, Placement } from '@popperjs/core' import type { Measurable } from './constants' @@ -73,7 +74,7 @@ export const popperContentProps = buildProps({ type: definePropType([String, Array, Object]), }, effect: { - type: String, + type: definePropType(String), default: 'dark', }, visible: Boolean, diff --git a/packages/components/select-v2/src/defaults.ts b/packages/components/select-v2/src/defaults.ts index 92c42e60aa..001253e317 100644 --- a/packages/components/select-v2/src/defaults.ts +++ b/packages/components/select-v2/src/defaults.ts @@ -12,7 +12,11 @@ import { defaultProps } from './useProps' import type { Option, OptionType } from './select.types' import type { Props } from './useProps' -import type { Options, Placement } from '@element-plus/components/popper' +import type { + Options, + Placement, + PopperEffect, +} from '@element-plus/components/popper' export const SelectProps = buildProps({ /** @@ -45,7 +49,7 @@ export const SelectProps = buildProps({ * @description tooltip theme, built-in theme: `dark` / `light` */ effect: { - type: definePropType<'light' | 'dark' | string>(String), + type: definePropType(String), default: 'light', }, /** diff --git a/packages/components/select/src/select.ts b/packages/components/select/src/select.ts index a5a436184a..ab7e0e6df6 100644 --- a/packages/components/select/src/select.ts +++ b/packages/components/select/src/select.ts @@ -8,7 +8,11 @@ import { buildProps, definePropType, iconPropType } from '@element-plus/utils' import { useTooltipContentProps } from '@element-plus/components/tooltip' import { ArrowDown, CircleClose } from '@element-plus/icons-vue' import { tagProps } from '@element-plus/components/tag' -import type { Options, Placement } from '@element-plus/components/popper' +import type { + Options, + Placement, + PopperEffect, +} from '@element-plus/components/popper' export const SelectProps = buildProps({ /** @@ -45,7 +49,7 @@ export const SelectProps = buildProps({ * @description tooltip theme, built-in theme: `dark` / `light` */ effect: { - type: definePropType<'light' | 'dark' | string>(String), + type: definePropType(String), default: 'light', }, /** diff --git a/packages/components/time-select/src/time-select.ts b/packages/components/time-select/src/time-select.ts index 499f0b333d..ec6fb4b3c6 100644 --- a/packages/components/time-select/src/time-select.ts +++ b/packages/components/time-select/src/time-select.ts @@ -1,8 +1,9 @@ import { buildProps, definePropType } from '@element-plus/utils' import { CircleClose, Clock } from '@element-plus/icons-vue' import { useEmptyValuesProps, useSizeProp } from '@element-plus/hooks' +import type { PopperEffect } from '@element-plus/components/popper' import type TimeSelect from './time-select.vue' -import type { Component, ExtractPropTypes, PropType } from 'vue' +import type { Component, ExtractPropTypes } from 'vue' export const timeSelectProps = buildProps({ /** @@ -31,7 +32,7 @@ export const timeSelectProps = buildProps({ * @description Tooltip theme, built-in theme: `dark` / `light` */ effect: { - type: String as PropType<'light' | 'dark' | string>, + type: definePropType(String), default: 'light', }, /** diff --git a/packages/components/tooltip-v2/src/content.ts b/packages/components/tooltip-v2/src/content.ts index 908b6286bf..6910863d6b 100644 --- a/packages/components/tooltip-v2/src/content.ts +++ b/packages/components/tooltip-v2/src/content.ts @@ -1,6 +1,7 @@ import { buildProps, definePropType } from '@element-plus/utils' import { useAriaProps } from '@element-plus/hooks' +import type { PopperEffect } from '@element-plus/components/popper' import type { ExtractPropTypes } from 'vue' import type { Placement, Strategy, VirtualElement } from '@floating-ui/dom' @@ -27,8 +28,8 @@ export const tooltipV2ContentProps = buildProps({ default: 5, }, effect: { - type: String, - default: '', + type: definePropType(String), + default: 'light', }, contentClass: String, /**