element-plus
Version:
A Component Library for Vue 3
1 lines • 8.66 kB
Source Map (JSON)
{"version":3,"file":"mention.mjs","sources":["../../../../../../packages/components/mention/src/mention.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isFunction,\n isObject,\n isString,\n} from '@element-plus/utils'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { inputProps } from '@element-plus/components/input'\nimport { filterOption } from './helper'\nimport { useTooltipContentProps } from '@element-plus/components/tooltip'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type Mention from './mention.vue'\nimport type { MentionOption } from './types'\nimport type { Options } from '@element-plus/components/popper'\nimport type { InputProps } from '@element-plus/components/input'\nimport type { ElTooltipContentProps } from '@element-plus/components/tooltip'\n\nexport interface MentionProps extends InputProps {\n /**\n * @description mention options list\n */\n options?: MentionOption[]\n /**\n * @description prefix character to trigger mentions. The string length must be exactly 1.\n */\n prefix?: string | string[]\n /**\n * @description character to split mentions. The string length must be exactly 1.\n */\n split?: string\n /**\n * @description customize filter option logic.\n */\n filterOption?: false | typeof filterOption\n /**\n * @description set popup placement\n */\n placement?: 'bottom' | 'top'\n /**\n * @description whether the dropdown panel has an arrow\n */\n showArrow?: boolean\n /**\n * @description offset of the dropdown panel\n */\n offset?: number\n /**\n * @description when backspace is pressed to delete, whether the mention content is deleted as a whole\n */\n whole?: boolean\n /**\n * @description when backspace is pressed to delete, check if the mention is a whole\n */\n checkIsWhole?: (pattern: string, prefix: string) => boolean\n /**\n * @description input value\n */\n modelValue?: string\n /**\n * @description whether the dropdown panel of mentions is in a loading state.\n */\n loading?: boolean\n /**\n * @description custom class name for dropdown panel\n */\n popperClass?: ElTooltipContentProps['popperClass']\n /**\n * @description custom style for dropdown panel\n */\n popperStyle?: ElTooltipContentProps['popperStyle']\n /**\n * @description [popper.js](https://popper.js.org/docs/v2/) parameters\n */\n popperOptions?: Partial<Options>\n /**\n * @description configuration options\n */\n props?: MentionOptionProps\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `MentionProps` instead.\n */\nexport const mentionProps = buildProps({\n ...inputProps,\n /**\n * @description mention options list\n */\n options: {\n type: definePropType<MentionOption[]>(Array),\n default: () => [],\n },\n /**\n * @description prefix character to trigger mentions. The string length must be exactly 1.\n */\n prefix: {\n type: definePropType<string | string[]>([String, Array]),\n default: '@',\n validator: (val: string | string[]) => {\n if (isString(val)) return val.length === 1\n return val.every((v) => isString(v) && v.length === 1)\n },\n },\n /**\n * @description character to split mentions. The string length must be exactly 1.\n */\n split: {\n type: String,\n default: ' ',\n validator: (val: string) => val.length === 1,\n },\n /**\n * @description customize filter option logic.\n */\n filterOption: {\n type: definePropType<false | typeof filterOption>([Boolean, Function]),\n default: () => filterOption,\n validator: (val) => {\n if (val === false) return true\n return isFunction(val)\n },\n },\n /**\n * @description set popup placement\n */\n placement: {\n type: definePropType<'bottom' | 'top'>(String),\n default: 'bottom',\n },\n /**\n * @description whether the dropdown panel has an arrow\n */\n showArrow: Boolean,\n /**\n * @description offset of the dropdown panel\n */\n offset: {\n type: Number,\n default: 0,\n },\n /**\n * @description when backspace is pressed to delete, whether the mention content is deleted as a whole\n */\n whole: Boolean,\n /**\n * @description when backspace is pressed to delete, check if the mention is a whole\n */\n checkIsWhole: {\n type: definePropType<(pattern: string, prefix: string) => boolean>(\n Function\n ),\n },\n /**\n * @description input value\n */\n modelValue: String,\n /**\n * @description whether the dropdown panel of mentions is in a loading state.\n */\n loading: Boolean,\n /**\n * @description custom class name for dropdown panel\n */\n popperClass: useTooltipContentProps.popperClass,\n /**\n * @description custom style for dropdown panel\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 configuration options\n */\n props: {\n type: definePropType<MentionOptionProps>(Object),\n default: () => mentionDefaultProps,\n },\n})\n\nexport const mentionEmits = {\n [UPDATE_MODEL_EVENT]: (value: string) => isString(value),\n 'whole-remove': (pattern: string, prefix: string) =>\n isString(pattern) && isString(prefix),\n input: (value: string) => isString(value),\n search: (pattern: string, prefix: string) =>\n isString(pattern) && isString(prefix),\n select: (option: MentionOption, prefix: string) =>\n isObject(option) && isString(prefix),\n focus: (evt: FocusEvent) => evt instanceof FocusEvent,\n blur: (evt: FocusEvent) => evt instanceof FocusEvent,\n}\n\nexport type MentionEmits = typeof mentionEmits\n/**\n * @deprecated Removed after 3.0.0, Use `MentionProps` instead.\n */\nexport type MentionPropsPublic = ExtractPublicPropTypes<typeof mentionProps>\nexport type MentionInstance = InstanceType<typeof Mention> & unknown\n\nexport type { MentionOption } from './types'\n\nexport type MentionOptionProps = {\n value?: string\n label?: string\n disabled?: string\n [key: string]: string | undefined\n}\n\nexport const mentionDefaultProps: Required<MentionOptionProps> = {\n value: 'value',\n label: 'label',\n disabled: 'disabled',\n}\n"],"names":[],"mappings":";;;;;;;AAqFO,MAAM,eAAe,UAAA,CAAW;AAAA,EACrC,GAAG,UAAA;AAAA;AAAA;AAAA;AAAA,EAIH,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,eAAgC,KAAK,CAAA;AAAA,IAC3C,OAAA,EAAS,MAAM;AAAC,GAClB;AAAA;AAAA;AAAA;AAAA,EAIA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,cAAA,CAAkC,CAAC,MAAA,EAAQ,KAAK,CAAC,CAAA;AAAA,IACvD,OAAA,EAAS,GAAA;AAAA,IACT,SAAA,EAAW,CAAC,GAAA,KAA2B;AACrC,MAAA,IAAI,QAAA,CAAS,GAAG,CAAA,EAAG,OAAO,IAAI,MAAA,KAAW,CAAA;AACzC,MAAA,OAAO,GAAA,CAAI,MAAM,CAAC,CAAA,KAAM,SAAS,CAAC,CAAA,IAAK,CAAA,CAAE,MAAA,KAAW,CAAC,CAAA;AAAA,IACvD;AAAA,GACF;AAAA;AAAA;AAAA;AAAA,EAIA,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,MA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