UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 10.2 kB
{"version":3,"file":"input-tag.mjs","sources":["../../../../../../packages/components/input-tag/src/input-tag.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n iconPropType,\n isArray,\n isNumber,\n isString,\n isUndefined,\n} from '@element-plus/utils'\nimport { useSizeProp } from '@element-plus/hooks'\nimport {\n CHANGE_EVENT,\n EVENT_CODE,\n INPUT_EVENT,\n UPDATE_MODEL_EVENT,\n} from '@element-plus/constants'\nimport { tagProps } from '@element-plus/components/tag/src/tag'\nimport { CircleClose } from '@element-plus/icons-vue'\n\nimport type { Component, ExtractPublicPropTypes } from 'vue'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type { PopperEffect } from '@element-plus/components/popper'\nimport type { TagProps } from '@element-plus/components/tag'\n\nexport interface InputTagProps {\n /**\n * @description binding value\n */\n modelValue?: string[]\n /**\n * @description max number tags that can be enter\n */\n max?: number\n /**\n * @description tag type\n */\n tagType?: TagProps['type']\n /**\n * @description tag effect\n */\n tagEffect?: TagProps['effect']\n /**\n * @description tooltip theme, built-in theme: `dark` / `light`\n */\n effect?: PopperEffect\n /**\n * @description the key to trigger input tag\n */\n trigger?: 'Enter' | 'Space'\n /**\n * @description whether tags can be dragged\n */\n draggable?: boolean\n /**\n * @description add a tag when a delimiter is matched\n */\n delimiter?: string | RegExp\n /**\n * @description input box size\n */\n size?: ComponentSize\n /**\n * @description whether to show clear button\n */\n clearable?: boolean\n /**\n * @description custom clear icon component\n */\n clearIcon?: string | Component\n /**\n * @description whether to disable input-tag\n */\n disabled?: boolean\n /**\n * @description whether to trigger form validation\n */\n validateEvent?: boolean\n /**\n * @description native input readonly\n */\n readonly?: boolean\n /**\n * @description native input autofocus\n */\n autofocus?: boolean\n /**\n * @description same as `id` in native input\n */\n id?: string\n /**\n * @description same as `tabindex` in native input\n */\n tabindex?: string | number\n /**\n * @description same as `maxlength` in native input\n */\n maxlength?: string | number\n /**\n * @description same as `minlength` in native input\n */\n minlength?: string | number\n /**\n * @description placeholder of input\n */\n placeholder?: string\n /**\n * @description native input autocomplete\n * - When the number of literal types in a union exceeds 315, the TS2590 error occurs. see: https://github.com/vuejs/core/issues/10514\n */\n autocomplete?: string // HTMLInputElement['autocomplete']\n /**\n * @description whether to save the input value when the input loses focus\n */\n saveOnBlur?: boolean\n /**\n * @description whether to collapse tags to a text\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?: number\n /**\n * @description native `aria-label` attribute\n */\n ariaLabel?: string\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `InputTagProps` instead.\n */\nexport const inputTagProps = buildProps({\n /**\n * @description binding value\n */\n modelValue: {\n type: definePropType<string[]>(Array),\n },\n /**\n * @description max number tags that can be enter\n */\n max: Number,\n /**\n * @description tag type\n */\n tagType: { ...tagProps.type, default: 'info' },\n /**\n * @description tag effect\n */\n tagEffect: tagProps.effect,\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 the key to trigger input tag\n */\n trigger: {\n type: definePropType<'Enter' | 'Space'>(String),\n default: EVENT_CODE.enter,\n },\n /**\n * @description whether tags can be dragged\n */\n draggable: Boolean,\n /**\n * @description add a tag when a delimiter is matched\n */\n delimiter: {\n type: [String, RegExp],\n default: '',\n },\n /**\n * @description input box size\n */\n size: useSizeProp,\n /**\n * @description whether to show clear button\n */\n clearable: Boolean,\n /**\n * @description custom clear icon component\n */\n clearIcon: {\n type: iconPropType,\n default: CircleClose,\n },\n /**\n * @description whether to disable input-tag\n */\n disabled: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description whether to trigger form validation\n */\n validateEvent: {\n type: Boolean,\n default: true,\n },\n /**\n * @description native input readonly\n */\n readonly: Boolean,\n /**\n * @description native input autofocus\n */\n autofocus: Boolean,\n /**\n * @description same as `id` in native input\n */\n id: {\n type: String,\n default: undefined,\n },\n /**\n * @description same as `tabindex` in native input\n */\n tabindex: {\n type: [String, Number],\n default: 0,\n },\n /**\n * @description same as `maxlength` in native input\n */\n maxlength: {\n type: [String, Number],\n },\n /**\n * @description same as `minlength` in native input\n */\n minlength: {\n type: [String, Number],\n },\n /**\n * @description placeholder of input\n */\n placeholder: String,\n /**\n * @description native input autocomplete\n */\n autocomplete: {\n type: definePropType<HTMLInputElement['autocomplete']>(String),\n default: 'off',\n },\n /**\n * @description whether to save the input value when the input loses focus\n */\n saveOnBlur: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether to collapse tags to a text\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 native `aria-label` attribute\n */\n ariaLabel: String,\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `InputTagProps` instead.\n */\nexport type InputTagPropsPublic = ExtractPublicPropTypes<typeof inputTagProps>\n\nexport const inputTagEmits = {\n [UPDATE_MODEL_EVENT]: (value?: string[]) =>\n isArray(value) || isUndefined(value),\n [CHANGE_EVENT]: (value?: string[]) => isArray(value) || isUndefined(value),\n [INPUT_EVENT]: (value: string) => isString(value),\n 'add-tag': (value: string | string[]) => isString(value) || isArray(value),\n 'remove-tag': (value: string, index: number) =>\n isString(value) && isNumber(index),\n 'drag-tag': (oldIndex: number, newIndex: number, value: string) =>\n isNumber(oldIndex) && isNumber(newIndex) && isString(value),\n focus: (evt: FocusEvent) => evt instanceof FocusEvent,\n blur: (evt: FocusEvent) => evt instanceof FocusEvent,\n clear: () => true,\n}\nexport type InputTagEmits = typeof inputTagEmits\n"],"names":[],"mappings":";;;;;;;;;;AAuIO,MA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