element-plus
Version:
A Component Library for Vue 3
1 lines • 10.6 kB
Source Map (JSON)
{"version":3,"file":"popover.mjs","sources":["../../../../../../packages/components/popover/src/popover.ts"],"sourcesContent":["import { buildProps, isBoolean } from '@element-plus/utils'\nimport {\n useTooltipContentProps,\n useTooltipTriggerProps,\n} from '@element-plus/components/tooltip'\nimport { dropdownProps } from '@element-plus/components/dropdown'\nimport { EVENT_CODE } from '@element-plus/constants'\n\nimport type { ExtractPublicPropTypes, PropType } from 'vue'\nimport type Popover from './popover.vue'\nimport type { Placement } from '@element-plus/components/popper'\nimport type { Options } from '@popperjs/core'\nimport type {\n ElTooltipContentProps,\n UseTooltipTriggerProps,\n} from '@element-plus/components/tooltip'\n\nexport interface PopoverProps {\n /**\n * @description how the popover is triggered, not valid in controlled mode\n */\n trigger?: UseTooltipTriggerProps['trigger']\n /**\n * @description When you click the mouse to focus on the trigger element, you can define a set of keyboard codes to control the display of popover through the keyboard, not valid in controlled mode\n */\n triggerKeys?: UseTooltipTriggerProps['triggerKeys']\n /**\n * @description popover placement\n */\n placement?: Placement\n /**\n * @description whether Popover is disabled\n */\n disabled?: UseTooltipTriggerProps['disabled']\n /**\n * @description whether popover is visible\n */\n visible?: ElTooltipContentProps['visible']\n /**\n * @description popover transition animation\n */\n transition?: ElTooltipContentProps['transition']\n /**\n * @description parameters for [popper.js](https://popper.js.org/docs/v2/)\n */\n popperOptions?: Partial<Options>\n /**\n * @description [tabindex](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) of Popover\n */\n tabindex?: string | number\n /**\n * @description popover content, can be replaced with a default `slot`\n */\n content?: ElTooltipContentProps['content']\n /**\n * @description custom style for popover\n */\n popperStyle?: ElTooltipContentProps['popperStyle']\n /**\n * @description custom class name for popover\n */\n popperClass?: ElTooltipContentProps['popperClass']\n /**\n * @description whether the mouse can enter the popover\n */\n enterable?: ElTooltipContentProps['enterable']\n /**\n * @description Tooltip theme, built-in theme: `dark` / `light`\n */\n effect?: ElTooltipContentProps['effect']\n /**\n * @description whether popover dropdown is teleported to the body\n */\n teleported?: ElTooltipContentProps['teleported']\n /**\n * @description which select dropdown appends to\n */\n appendTo?: ElTooltipContentProps['appendTo']\n /**\n * @description popover title\n */\n title?: string\n /**\n * @description popover width\n */\n width?: string | number\n /**\n * @description popover offset\n */\n offset?: number\n /**\n * @description delay of appearance, in millisecond, not valid in controlled mode\n */\n showAfter?: number\n /**\n * @description delay of disappear, in millisecond, not valid in controlled mode\n */\n hideAfter?: number\n /**\n * @description timeout in milliseconds to hide tooltip, not valid in controlled mode\n */\n autoClose?: number\n /**\n * @description whether a tooltip arrow is displayed or not. For more info, please refer to [ElPopper](https://github.com/element-plus/element-plus/tree/dev/packages/components/popper)\n */\n showArrow?: boolean\n /**\n * @description when popover inactive and `persistent` is `false` , popover will be destroyed\n */\n persistent?: boolean\n /**\n * @description update:visible event handler\n */\n 'onUpdate:visible'?: (visible: boolean) => void\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `PopoverProps` instead.\n */\nexport const popoverProps = buildProps({\n /**\n * @description how the popover is triggered, not valid in controlled mode\n */\n trigger: useTooltipTriggerProps.trigger,\n /**\n * @description When you click the mouse to focus on the trigger element, you can define a set of keyboard codes to control the display of popover through the keyboard, not valid in controlled mode\n */\n triggerKeys: useTooltipTriggerProps.triggerKeys,\n /**\n * @description popover placement\n */\n placement: dropdownProps.placement,\n /**\n * @description whether Popover is disabled\n */\n disabled: useTooltipTriggerProps.disabled,\n /**\n * @description whether popover is visible\n */\n visible: useTooltipContentProps.visible,\n /**\n * @description popover transition animation\n */\n transition: useTooltipContentProps.transition,\n /**\n * @description parameters for [popper.js](https://popper.js.org/docs/v2/)\n */\n popperOptions: dropdownProps.popperOptions,\n /**\n * @description [tabindex](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) of Popover\n */\n tabindex: dropdownProps.tabindex,\n /**\n * @description popover content, can be replaced with a default `slot`\n */\n content: useTooltipContentProps.content,\n /**\n * @description custom style for popover\n */\n popperStyle: useTooltipContentProps.popperStyle,\n /**\n * @description custom class name for popover\n */\n popperClass: useTooltipContentProps.popperClass,\n enterable: {\n ...useTooltipContentProps.enterable,\n default: true,\n },\n /**\n * @description Tooltip theme, built-in theme: `dark` / `light`\n */\n effect: {\n ...useTooltipContentProps.effect,\n default: 'light',\n },\n /**\n * @description whether popover dropdown is teleported to the body\n */\n teleported: useTooltipContentProps.teleported,\n /**\n * @description which select dropdown appends to\n */\n appendTo: useTooltipContentProps.appendTo,\n /**\n * @description popover title\n */\n title: String,\n /**\n * @description popover width\n */\n width: {\n type: [String, Number],\n default: 150,\n },\n /**\n * @description popover offset\n */\n offset: {\n type: Number,\n default: undefined,\n },\n /**\n * @description delay of appearance, in millisecond, not valid in controlled mode\n */\n showAfter: {\n type: Number,\n default: 0,\n },\n /**\n * @description delay of disappear, in millisecond, not valid in controlled mode\n */\n hideAfter: {\n type: Number,\n default: 200,\n },\n /**\n * @description timeout in milliseconds to hide tooltip, not valid in controlled mode\n */\n autoClose: {\n type: Number,\n default: 0,\n },\n /**\n * @description whether a tooltip arrow is displayed or not. For more info, please refer to [ElPopper](https://github.com/element-plus/element-plus/tree/dev/packages/components/popper)\n */\n showArrow: {\n type: Boolean,\n default: true,\n },\n /**\n * @description when popover inactive and `persistent` is `false` , popover will be destroyed\n */\n persistent: {\n type: Boolean,\n default: true,\n },\n 'onUpdate:visible': {\n type: Function as PropType<(visible: boolean) => void>,\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `PopoverProps` instead.\n */\nexport type PopoverPropsPublic = ExtractPublicPropTypes<typeof popoverProps>\n\nexport const popoverEmits = {\n 'update:visible': (value: boolean) => isBoolean(value),\n 'before-enter': () => true,\n 'before-leave': () => true,\n 'after-enter': () => true,\n 'after-leave': () => true,\n}\nexport type PopoverEmits = typeof popoverEmits\n\nexport type PopoverInstance = InstanceType<typeof Popover> & unknown\n\n/**\n * @description default values for PopoverProps\n */\nexport const popoverPropsDefaults = {\n trigger: 'hover',\n triggerKeys: () => [\n EVENT_CODE.enter,\n EVENT_CODE.numpadEnter,\n EVENT_CODE.space,\n ],\n placement: 'bottom',\n visible: null,\n popperOptions: () => ({}),\n tabindex: 0,\n content: '',\n popperStyle: undefined,\n enterable: true,\n effect: 'light',\n teleported: true,\n width: 150,\n offset: undefined,\n showAfter: 0,\n hideAfter: 200,\n autoClose: 0,\n showArrow: true,\n persistent: true,\n} as const\n"],"names":[],"mappings":";;;;;;;AAuHO,MAAM,eAAe,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAIrC,SAAS,sBAAA,CAAuB,OAAA;AAAA;AAAA;AAAA;AAAA,EAIhC,aAAa,sBAAA,CAAuB,WAAA;AAAA;AAAA;AAAA;AAAA,EAIpC,WAAW,aAAA,CAAc,SAAA;AAAA;AAAA;AAAA;AAAA,EAIzB,UAAU,sBAAA,CAAuB,QAAA;AAAA;AAAA;AAAA;AAAA,EAIjC,SAAS,sBAAA,CAAuB,OAAA;AAAA;AAAA;AAAA;AAAA,EAIhC,YAAY,sBAAA,CAAuB,UAAA;AAAA;AAAA;AAAA;AAAA,EAInC,eAAe,aAAA,CAAc,aAAA;AAAA;AAAA;AAAA;AAAA,EAI7B,UAAU,aAAA,CAAc,QAAA;AAAA;AAAA;AAAA;AAAA,EAIxB,SAAS,sBAAA,CAAuB,OAAA;AAAA;AAAA;AAAA;AAAA,EAIhC,aAAa,sBAAA,CAAuB,WAAA;AAAA;AAAA;AAAA;AAAA,EAIpC,aAAa,sBAAA,CAAuB,WAAA;AAAA,EACpC,SAAA,EAAW;AAAA,IACT,GAAG,sBAAA,CAAuB,SAAA;AAAA,IAC1B,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,MAAA,EAAQ;AAAA,IACN,GAAG,sBAAA,CAAuB,MAAA;AAAA,IAC1B,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,YAAY,sBAAA,CAAuB,UAAA;AAAA;AAA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