element-plus
Version:
A Component Library for Vue 3
1 lines • 8.8 kB
Source Map (JSON)
{"version":3,"file":"dropdown.mjs","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"],"names":[],"mappings":";;;;;;;AA2BO,MAAM,gBAAgB,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAItC,OAAA,EAAS;AAAA,IACP,GAAG,sBAAA,CAAuB,OAAA;AAAA,IAC1B,MAAM,cAAA,CAAgE;AAAA,MACpE,MAAA;AAAA,MACA;AAAA,KACD;AAAA,GACH;AAAA,EACA,WAAA,EAAa;AAAA,IACX,IAAA,EAAM,eAAyB,KAAK,CAAA;AAAA,IACpC,SAAS,MAAM;AAAA,MACb,UAAA,CAAW,KAAA;AAAA,MACX,UAAA,CAAW,WAAA;AAAA,MACX,UAAA,CAAW,KAAA;AAAA,MACX,UAAA,CAAW;AAAA;AACb,GACF;AAAA;AAAA;AAAA;AAAA,EAIA,mBAAmB,sBAAA,CAAuB,iBAAA;AAAA;AAAA;AAAA;AAAA,EAI1C,YAAY,sBAAA,CAAuB,UAAA;AAAA;AAAA;AAAA;AAAA,EAInC,MAAA,EAAQ;AAAA,IACN,GAAG,sBAAA,CAAuB,MAAA;AAAA,IAC1B,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,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