UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 9.29 kB
{"version":3,"file":"popover.mjs","names":[],"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"],"mappings":";;;;;;;;;;;AAuHA,MAAa,eAAe,WAAW;CAIrC,SAAS,uBAAuB;CAIhC,aAAa,uBAAuB;CAIpC,WAAW,cAAc;CAIzB,UAAU,uBAAuB;CAIjC,SAAS,uBAAuB;CAIhC,YAAY,uBAAuB;CAInC,eAAe,cAAc;CAI7B,UAAU,cAAc;CAIxB,SAAS,uBAAuB;CAIhC,aAAa,uBAAuB;CAIpC,aAAa,uBAAuB;CACpC,WAAW;EACT,GAAG,uBAAuB;EAC1B,SAAS;EACV;CAID,QAAQ;EACN,GAAG,uBAAuB;EAC1B,SAAS;EACV;CAID,YAAY,uBAAuB;CAInC,UAAU,uBAAuB;CAIjC,OAAO;CAIP,OAAO;EACL,MAAM,CAAC,QAAQ,OAAO;EACtB,SAAS;EACV;CAID,QAAQ;EACN,MAAM;EACN,SAAS;EACV;CAID,WAAW;EACT,MAAM;EACN,SAAS;EACV;CAID,WAAW;EACT,MAAM;EACN,SAAS;EACV;CAID,WAAW;EACT,MAAM;EACN,SAAS;EACV;CAID,WAAW;EACT,MAAM;EACN,SAAS;EACV;CAID,YAAY;EACV,MAAM;EACN,SAAS;EACV;CACD,oBAAoB,EAClB,MAAM,UACP;CACF,CAAU;AAOX,MAAa,eAAe;CAC1B,mBAAmB,UAAmB,UAAU,MAAM;CACtD,sBAAsB;CACtB,sBAAsB;CACtB,qBAAqB;CACrB,qBAAqB;CACtB;;;;AAQD,MAAa,uBAAuB;CAClC,SAAS;CACT,mBAAmB;EACjB,WAAW;EACX,WAAW;EACX,WAAW;EACZ;CACD,WAAW;CACX,SAAS;CACT,sBAAsB,EAAE;CACxB,UAAU;CACV,SAAS;CACT,aAAa;CACb,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,OAAO;CACP,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,YAAY;CACb"}