element-plus
Version:
A Component Library for Vue 3
1 lines • 14.4 kB
Source Map (JSON)
{"version":3,"file":"defaults.mjs","sources":["../../../../../../packages/components/select-v2/src/defaults.ts"],"sourcesContent":["import { placements } from '@popperjs/core'\nimport {\n useAriaProps,\n useEmptyValuesProps,\n useSizeProp,\n} from '@element-plus/hooks'\nimport {\n buildProps,\n definePropType,\n iconPropType,\n isBoolean,\n isNumber,\n} from '@element-plus/utils'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { useTooltipContentProps } from '@element-plus/components/tooltip'\nimport { ArrowDown, CircleClose } from '@element-plus/icons-vue'\nimport { tagProps } from '../../tag'\nimport { defaultProps } from './useProps'\n\nimport type SelectV2 from './select.vue'\nimport type { Option, OptionType } from './select.types'\nimport type { Props } from './useProps'\nimport type { EmitFn } from '@element-plus/utils/vue/typescript'\nimport type { ExtractPropTypes, ExtractPublicPropTypes } from 'vue'\nimport type {\n Options,\n Placement,\n PopperEffect,\n} from '@element-plus/components/popper'\n\nexport const selectV2Props = buildProps({\n /**\n * @description whether creating new items is allowed. To use this, `filterable` must be true\n */\n allowCreate: Boolean,\n /**\n * @description autocomplete of select input\n */\n autocomplete: {\n type: definePropType<'none' | 'both' | 'list' | 'inline'>(String),\n default: 'none',\n },\n /**\n * @description for non-filterable Select, this prop decides if the option menu pops up when the input is focused\n */\n automaticDropdown: Boolean,\n /**\n * @description whether select can be cleared\n */\n clearable: Boolean,\n /**\n * @description custom clear icon\n */\n clearIcon: {\n type: iconPropType,\n default: CircleClose,\n },\n /**\n * @description tooltip theme, built-in theme: `dark` / `light`\n */\n effect: {\n type: definePropType<PopperEffect>(String),\n default: 'light',\n },\n /**\n * @description whether to collapse tags to a text when multiple selecting\n */\n collapseTags: Boolean,\n /**\n * @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true\n */\n collapseTagsTooltip: Boolean,\n /**\n * @description The max tags number to be shown. To use this, `collapse-tags` must be true\n */\n maxCollapseTags: {\n type: Number,\n default: 1,\n },\n /**\n * @description\n */\n defaultFirstOption: Boolean,\n /**\n * @description is disabled\n */\n disabled: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description\n */\n estimatedOptionHeight: {\n type: Number,\n default: undefined,\n },\n /**\n * @description whether Select is filterable\n */\n filterable: Boolean,\n /**\n * @description custom filter method, the first parameter is the current input value. To use this, `filterable` must be true\n */\n filterMethod: {\n type: definePropType<(query: string) => void>(Function),\n },\n /**\n * @description The height of the dropdown panel, 34px for each item\n */\n height: {\n type: Number,\n default: 274, // same as select dropdown menu\n },\n /**\n * @description The height of the dropdown item\n */\n itemHeight: {\n type: Number,\n default: 34,\n },\n /**\n * @description native input id\n */\n id: String,\n /**\n * @description whether Select is loading data from server\n */\n loading: Boolean,\n /**\n * @description displayed text while loading data from server, default is 'Loading'\n */\n loadingText: String,\n /**\n * @description biding value\n */\n modelValue: {\n type: definePropType<\n any[] | string | number | boolean | Record<string, any> | any\n >([Array, String, Number, Boolean, Object]),\n default: undefined,\n },\n /**\n * @description is multiple\n */\n multiple: Boolean,\n /**\n * @description maximum number of options user can select when multiple is true. No limit when set to 0\n */\n multipleLimit: {\n type: Number,\n default: 0,\n },\n /**\n * @description the name attribute of select input\n */\n name: String,\n /**\n * @description displayed text when there is no options, you can also use slot empty, the default is 'No Data'\n */\n noDataText: String,\n /**\n * @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data'\n */\n noMatchText: String,\n /**\n * @description function that gets called when the input value changes. Its parameter is the current input value. To use this, `filterable` must be true\n */\n remoteMethod: {\n type: definePropType<(query: string) => void>(Function),\n },\n /**\n * @description whether reserve the keyword after select filtered option.\n */\n reserveKeyword: {\n type: Boolean,\n default: true,\n },\n /**\n * @description data of the options, the key of `value` and `label` can be customize by `props`\n */\n options: {\n type: definePropType<OptionType[]>(Array),\n required: true,\n },\n /**\n * @description placeholder, the default is 'Please select'\n */\n placeholder: {\n type: String,\n },\n /**\n * @description whether select dropdown is teleported, if `true` it will be teleported to where `append-to` sets\n */\n teleported: useTooltipContentProps.teleported,\n /**\n * @description when select dropdown is inactive and `persistent` is `false`, select dropdown will be destroyed\n */\n persistent: {\n type: Boolean,\n default: true,\n },\n /**\n * @description custom class name for Select's dropdown\n */\n popperClass: useTooltipContentProps.popperClass,\n /**\n * @description custom style for Select's dropdown\n */\n popperStyle: useTooltipContentProps.popperStyle,\n /**\n * @description [popper.js](https://popper.js.org/docs/v2/) parameters\n */\n popperOptions: {\n type: definePropType<Partial<Options>>(Object),\n default: () => ({}) as Partial<Options>,\n },\n /**\n * @description whether search data from server\n */\n remote: Boolean,\n /**\n * @description debounce delay during remote search, in milliseconds\n */\n debounce: {\n type: Number,\n default: 300,\n },\n /**\n * @description size of component\n */\n size: useSizeProp,\n /**\n * @description configuration options, see the following table\n */\n props: {\n type: definePropType<Props>(Object),\n default: () => defaultProps,\n },\n /**\n * @description unique identity key name for value, required when value is an object\n */\n valueKey: {\n type: String,\n default: 'value',\n },\n /**\n * @description Controls whether the scrollbar is always displayed\n */\n scrollbarAlwaysOn: Boolean,\n /**\n * @description whether to trigger form validation\n */\n validateEvent: {\n type: Boolean,\n default: true,\n },\n /**\n * @description offset of the dropdown\n */\n offset: {\n type: Number,\n default: 12,\n },\n /**\n * @description in remote search method show suffix icon\n */\n remoteShowSuffix: Boolean,\n /**\n * @description Determines whether the arrow is displayed\n */\n showArrow: {\n type: Boolean,\n default: true,\n },\n /**\n * @description position of dropdown\n */\n placement: {\n type: definePropType<Placement>(String),\n values: placements,\n default: 'bottom-start',\n },\n /**\n * @description list of possible positions for dropdown\n */\n fallbackPlacements: {\n type: definePropType<Placement[]>(Array),\n default: ['bottom-start', 'top-start', 'right', 'left'],\n },\n /**\n * @description tag type\n */\n tagType: { ...tagProps.type, default: 'info' },\n /**\n * @description tag effect\n */\n tagEffect: { ...tagProps.effect, default: 'light' },\n /**\n * @description tabindex for input\n */\n tabindex: {\n type: [String, Number],\n default: 0,\n },\n /**\n * @description which element the select dropdown appends to\n */\n appendTo: useTooltipContentProps.appendTo,\n /**\n * @description if it is `true`, the width of the dropdown panel is the same as the input box.\n * if it is `false`, the width is automatically calculated based on the value of `label`,\n * or it can be set to a number to make it a fixed width\n */\n fitInputWidth: {\n type: [Boolean, Number],\n default: true,\n validator(val) {\n return isBoolean(val) || isNumber(val)\n },\n },\n suffixIcon: {\n type: iconPropType,\n default: ArrowDown,\n },\n ...useEmptyValuesProps,\n ...useAriaProps(['ariaLabel']),\n} as const)\n\nexport const optionV2Props = buildProps({\n data: Array,\n disabled: Boolean,\n hovering: Boolean,\n item: {\n type: definePropType<Option>(Object),\n required: true,\n },\n index: Number,\n style: Object,\n selected: Boolean,\n created: Boolean,\n} as const)\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\nexport const selectV2Emits = {\n [UPDATE_MODEL_EVENT]: (val: SelectV2Props['modelValue']) => true,\n [CHANGE_EVENT]: (val: SelectV2Props['modelValue']) => true,\n 'remove-tag': (val: unknown) => true,\n 'visible-change': (visible: boolean) => true,\n focus: (evt: FocusEvent) => evt instanceof FocusEvent,\n blur: (evt: FocusEvent) => evt instanceof FocusEvent,\n clear: () => true,\n}\nexport const optionV2Emits = {\n hover: (index?: number) => isNumber(index),\n select: (val: Option, index?: number) => true,\n}\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nexport type SelectV2Props = ExtractPropTypes<typeof selectV2Props>\nexport type SelectV2PropsPublic = ExtractPublicPropTypes<typeof selectV2Props>\nexport type OptionV2Props = ExtractPropTypes<typeof optionV2Props>\nexport type OptionV2PropsPublic = ExtractPublicPropTypes<typeof optionV2Props>\nexport type SelectV2EmitFn = EmitFn<typeof selectV2Emits>\nexport type OptionV2EmitFn = EmitFn<typeof optionV2Emits>\n\nexport type SelectV2Instance = InstanceType<typeof SelectV2> & unknown\n"],"names":[],"mappings":";;;;;;;;;;;;;AA8BO,MAAM,gBAAgB,UAAW,CAAA;AAAA,EAItC,WAAa,EAAA,OAAA;AAAA,EAIb,YAAc,E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