element-plus
Version:
A Component Library for Vue 3
1 lines • 7.3 kB
Source Map (JSON)
{"version":3,"file":"dropdown.mjs","names":[],"sources":["../../../../../../packages/components/dropdown/src/dropdown.ts"],"sourcesContent":["import { buildProps, definePropType, iconPropType } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport {\n useTooltipContentProps,\n useTooltipTriggerProps,\n} from '@element-plus/components/tooltip'\nimport { roleTypes } from '@element-plus/components/popper'\n\nimport type { TooltipTriggerType } from '@element-plus/components/tooltip'\nimport type { Placement } from '@element-plus/components/popper'\nimport type { Options } from '@popperjs/core'\nimport type { ButtonProps, ButtonType } from '@element-plus/components/button'\nimport type { ComponentInternalInstance, ComputedRef } from 'vue'\nimport type { Arrayable, Nullable } from '@element-plus/utils'\n\nexport interface IElDropdownInstance {\n instance?: ComponentInternalInstance\n dropdownSize?: ComputedRef<string>\n handleClick?: () => void\n commandHandler?: (...arg: any[]) => void\n show?: () => void\n hide?: () => void\n trigger?: ComputedRef<string>\n hideOnClick?: ComputedRef<boolean>\n triggerElm?: ComputedRef<Nullable<HTMLButtonElement>>\n}\n\nexport const dropdownProps = buildProps({\n /**\n * @description how to trigger\n */\n trigger: {\n ...useTooltipTriggerProps.trigger,\n type: definePropType<Arrayable<Exclude<TooltipTriggerType, 'focus'>>>([\n String,\n Array,\n ]),\n },\n triggerKeys: {\n type: definePropType<string[]>(Array),\n default: () => [\n EVENT_CODE.enter,\n EVENT_CODE.numpadEnter,\n EVENT_CODE.space,\n EVENT_CODE.down,\n ],\n },\n /**\n * @description Indicates whether virtual triggering is enabled\n */\n virtualTriggering: useTooltipTriggerProps.virtualTriggering,\n /**\n * @description Indicates the reference element to which the dropdown is attached\n */\n virtualRef: useTooltipTriggerProps.virtualRef,\n /**\n * @description Tooltip theme, built-in theme: `dark` / `light`\n */\n effect: {\n ...useTooltipContentProps.effect,\n default: 'light',\n },\n /**\n * @description menu button type, refer to `Button` Component, only works when `split-button` is true\n */\n type: {\n type: definePropType<ButtonType>(String),\n },\n /**\n * @description placement of pop menu\n */\n placement: {\n type: definePropType<Placement>(String),\n default: 'bottom',\n },\n /**\n * @description [popper.js](https://popper.js.org/docs/v2/) parameters\n */\n popperOptions: {\n type: definePropType<Partial<Options>>(Object),\n default: () => ({}),\n },\n id: String,\n /**\n * @description menu size, also works on the split button\n */\n size: {\n type: String,\n default: '',\n },\n /**\n * @description whether a button group is displayed\n */\n splitButton: Boolean,\n /**\n * @description whether to hide menu after clicking menu-item\n */\n hideOnClick: {\n type: Boolean,\n default: true,\n },\n loop: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether the tooltip content has an arrow\n */\n showArrow: {\n type: Boolean,\n default: true,\n },\n /**\n * @description delay time before show a dropdown (only works when trigger is `hover`)\n */\n showTimeout: {\n type: Number,\n default: 150,\n },\n /**\n * @description delay time before hide a dropdown (only works when trigger is `hover`)\n */\n hideTimeout: {\n type: Number,\n default: 150,\n },\n /**\n * @description [tabindex](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) of Dropdown\n */\n tabindex: {\n type: definePropType<number | string>([Number, String]),\n default: 0,\n },\n /**\n * @description the max height of menu\n */\n maxHeight: {\n type: definePropType<number | string>([Number, String]),\n default: '',\n },\n /**\n * @description custom class name for Dropdown's dropdown\n */\n popperClass: useTooltipContentProps.popperClass,\n /**\n * @description custom style for Dropdown's dropdown\n */\n popperStyle: useTooltipContentProps.popperStyle,\n /**\n * @description whether to disable\n */\n disabled: Boolean,\n /**\n * @description the ARIA role attribute for the dropdown menu. Depending on the use case, you may want to change this to 'navigation'\n */\n role: {\n type: String,\n values: roleTypes,\n default: 'menu',\n },\n buttonProps: {\n type: definePropType<Partial<ButtonProps>>(Object),\n },\n /**\n * @description whether the dropdown popup is teleported to the body\n */\n teleported: useTooltipContentProps.teleported,\n /**\n * @description which element the dropdown CONTENT appends to\n */\n appendTo: useTooltipContentProps.appendTo,\n /**\n * @description when dropdown inactive and `persistent` is `false` , dropdown menu will be destroyed\n */\n persistent: {\n type: Boolean,\n default: true,\n },\n} as const)\n\nexport const dropdownItemProps = buildProps({\n /**\n * @description a command to be dispatched to Dropdown's `command` callback\n */\n command: {\n type: [Object, String, Number],\n default: () => ({}),\n },\n /**\n * @description whether the item is disabled\n */\n disabled: Boolean,\n /**\n * @description whether a divider is displayed\n */\n divided: Boolean,\n textValue: String,\n /**\n * @description custom icon\n */\n icon: {\n type: iconPropType,\n },\n} as const)\n\nexport const dropdownMenuProps = buildProps({\n onKeydown: { type: definePropType<(e: KeyboardEvent) => void>(Function) },\n})\n\nexport const FIRST_KEYS = [\n EVENT_CODE.down,\n EVENT_CODE.pageDown,\n EVENT_CODE.home,\n]\n\nexport const LAST_KEYS = [EVENT_CODE.up, EVENT_CODE.pageUp, EVENT_CODE.end]\n\nexport const FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS]\n"],"mappings":";;;;;;;;AA2BA,MAAa,gBAAgB,WAAW;CAItC,SAAS;EACP,GAAG,uBAAuB;EAC1B,MAAM,eAAgE,CACpE,QACA,MACD,CAAC;EACH;CACD,aAAa;EACX,MAAM,eAAyB,MAAM;EACrC,eAAe;GACb,WAAW;GACX,WAAW;GACX,WAAW;GACX,WAAW;GACZ;EACF;CAID,mBAAmB,uBAAuB;CAI1C,YAAY,uBAAuB;CAInC,QAAQ;EACN,GAAG,uBAAuB;EAC1B,SAAS;EACV;CAID,MAAM,EACJ,MAAM,eAA2B,OAAO,EACzC;CAID,WAAW;EACT,MAAM,eAA0B,OAAO;EACvC,SAAS;EACV;CAID,eAAe;EACb,MAAM,eAAiC,OAAO;EAC9C,gBAAgB,EAAE;EACnB;CACD,IAAI;CAIJ,MAAM;EACJ,MAAM;EACN,SAAS;EACV;CAID,aAAa;CAIb,aAAa;EACX,MAAM;EACN,SAAS;EACV;CACD,MAAM;EACJ,MAAM;EACN,SAAS;EACV;CAID,WAAW;EACT,MAAM;EACN,SAAS;EACV;CAID,aAAa;EACX,MAAM;EACN,SAAS;EACV;CA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