Skip to content

Commit

Permalink
feat(Select): 增加 Trigger 单独的 class、style 配置 (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
1zumii committed Jun 14, 2024
1 parent c87f999 commit 1c11954
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion components/select/props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentObjectPropsOptions, PropType } from 'vue';
import type { CSSProperties, ComponentObjectPropsOptions, PropType } from 'vue';
import { extractPropsDefaultValue } from '../_util/utils';

import type { ExtractPublicPropTypes, GetContainer } from '../_util/interface';
Expand Down Expand Up @@ -90,6 +90,8 @@ export const selectProps = {
default: false,
},
popperClass: [String, Array, Object] as PropType<string | [] | object>,
triggerClass: [String, Array, Object] as PropType<string | [] | object>,
triggerStyle: [Object, String] as PropType<CSSProperties | string>,
} as const satisfies ComponentObjectPropsOptions;

export const selectPropsDefaultValue = extractPropsDefaultValue(selectProps);
Expand Down
7 changes: 3 additions & 4 deletions components/select/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
:collapseTags="collapseTags"
:collapseTagsLimit="collapseTagsLimit"
:tagBordered="tagBordered"
:class="[{ 'is-error': isError }, attrs.class]"
:style="attrs.style"
:class="[{ 'is-error': isError }, triggerClass]"
:style="triggerStyle"
:renderTag="$slots.tag"
@keydown.enter="onKeyDown"
@remove="onSelect"
Expand Down Expand Up @@ -96,7 +96,7 @@ export default defineComponent({
},
props: selectProps,
emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT, 'removeTag', 'visibleChange', 'focus', 'blur', 'clear', 'scroll', 'search'],
setup(props, { emit, attrs }) {
setup(props, { emit }) {
useTheme();
const { validate, isError, isFormDisabled } = useFormAdaptor({
valueType: computed(() => (props.multiple ? 'array' : 'string')),
Expand Down Expand Up @@ -416,7 +416,6 @@ export default defineComponent({
innerDisabled,
onScroll,
isLimitRef,
attrs,
hoverOptionValue,
onHover,
onKeyDown,
Expand Down
2 changes: 2 additions & 0 deletions docs/.vitepress/components/select/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ selectGroupOption.vue
| valueField | 替代 `SelectOption` 中的 `value` 字段名 | string | `value` |
| labelField | 替代 `SelectOption` 中的 `label` 字段名 | string | `label` |
| popperClass | 弹出框容器样式 | string | - |
| triggerClass | 弹出框触发器样式类 | string | - |
| triggerStyle | 弹出框触发器样式 | string / object | - |

## Select Events

Expand Down

0 comments on commit 1c11954

Please sign in to comment.