{"version":3,"file":"dropdown.mjs","sources":["../../../../../../packages/components/dropdown/src/dropdown.ts"],"sourcesContent":["import { EVENT_CODE } from '@sgui-plus/utils/aria'\r\nimport { buildProps, definePropType } from '@sgui-plus/utils/props'\r\nimport { createCollectionWithScope } from '@sgui-plus/components/collection'\r\nimport {\r\n  useTooltipContentProps,\r\n} from '@sgui-plus/components/tooltip'\r\nimport type { ExtractPropTypes } from 'vue'\r\n\r\nimport type { Placement } from '@sgui-plus/components/popper'\r\nimport type { ComponentInternalInstance, ComputedRef, InjectionKey } from 'vue'\r\nimport type { Nullable } from '@sgui-plus/utils/types'\r\n\r\nexport interface ISgDropdownInstance {\r\n  instance?: ComponentInternalInstance\r\n  dropdownSize?: ComputedRef<string>\r\n  handleClick?: () => void\r\n  commandHandler?: (...arg) => void\r\n  show?: () => void\r\n  hide?: () => void\r\n  trigger?: ComputedRef<string>\r\n  hideOnClick?: ComputedRef<boolean>\r\n  triggerElm?: ComputedRef<Nullable<HTMLButtonElement>>\r\n}\r\n\r\n\r\nexport const dropdownProps = {\r\n  trigger: {\r\n    type: String,\r\n    values: ['hover', 'custom', 'click', 'contextMenu'],\r\n    default: 'hover'\r\n  },\r\n  visible: useTooltipContentProps.visible,\r\n  transfer: useTooltipContentProps.transfer,\r\n  ...buildProps({\r\n    placement: {\r\n      type: definePropType<Placement>(String),\r\n      default: 'bottom-start',\r\n    },\r\n    hideAfterClick: {\r\n      type: Boolean,\r\n      default: true,\r\n    },\r\n    maxHeight: {\r\n      type: definePropType<number | string>([Number, String]),\r\n      default: '',\r\n    },\r\n    dropClassName: {\r\n      type: String,\r\n      default: '',\r\n    },\r\n    title: {\r\n      type: String,\r\n      default: ''\r\n    },\r\n    dropdownStyle: {\r\n      type: String,\r\n      values: ['normal', 'simple'],\r\n      default: 'normal'\r\n    },\r\n    calculateDropdownMinWidth: {\r\n      type: Boolean,\r\n      default: false\r\n    }\r\n  } as const),\r\n} as const\r\n\r\nexport const dropdownItemProps = buildProps({\r\n  name: {\r\n    type: [Object, String, Number],\r\n    default: () => ({}),\r\n  },\r\n  disabled: Boolean,\r\n  divided: Boolean,\r\n  textValue: String,\r\n  selected: {\r\n    type: Boolean,\r\n    default: false,\r\n  },\r\n} as const)\r\n\r\nexport const dropdownMenuProps = buildProps({\r\n  onKeydown: { type: definePropType<(e: KeyboardEvent) => void>(Function) },\r\n})\r\n\r\nexport const FIRST_KEYS = [\r\n  EVENT_CODE.down,\r\n  EVENT_CODE.pageDown,\r\n  EVENT_CODE.home,\r\n]\r\n\r\nexport const LAST_KEYS = [EVENT_CODE.up, EVENT_CODE.pageUp, EVENT_CODE.end]\r\n\r\nexport const FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS]\r\n\r\nconst {\r\n  SgCollection,\r\n  SgCollectionItem,\r\n  COLLECTION_INJECTION_KEY,\r\n  COLLECTION_ITEM_INJECTION_KEY,\r\n} = createCollectionWithScope('Dropdown')\r\n\r\nexport {\r\n  SgCollection,\r\n  SgCollectionItem,\r\n  COLLECTION_INJECTION_KEY as DROPDOWN_COLLECTION_INJECTION_KEY,\r\n  COLLECTION_ITEM_INJECTION_KEY as DROPDOWN_COLLECTION_ITEM_INJECTION_KEY,\r\n}\r\n\r\nexport type DropdownProps = ExtractPropTypes<typeof dropdownProps>\r\nexport type DropdownItemProps = ExtractPropTypes<typeof dropdownItemProps>\r\n\r\nexport interface DropdownContext {\r\n  onClickItem: Function\r\n}\r\n\r\nexport const DropdownContextKey: InjectionKey<DropdownContext> = Symbol('DropdownContextKey')\r\n"],"names":[],"mappings":";;;;;;;AAMY,MAAC,aAAa,GAAG;AAC7B,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC;AACvD,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,EAAE,OAAO,EAAE,sBAAsB,CAAC,OAAO;AACzC,EAAE,QAA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