@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
1 lines • 2.79 kB
Source Map (JSON)
{"version":3,"file":"dropdown-item.vue2.mjs","sources":["../../../components/dropdown/dropdown-item.vue"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport { computed, inject, ref, toRef } from 'vue'\r\n\r\nimport { emitEvent, useNameHelper } from '@vexip-ui/config'\r\nimport { dropdownItemProps } from './props'\r\nimport { useLabel } from './hooks'\r\nimport { SELECT_HANDLER } from './symbol'\r\n\r\ndefineOptions({ name: 'DropdownItem' })\r\n\r\nconst props = defineProps(dropdownItemProps)\r\n\r\nconst parentSelectHandler = inject(SELECT_HANDLER, null)\r\n\r\nconst nh = useNameHelper('dropdown')\r\nconst wrapper = ref(null)\r\nconst label = toRef(props, 'label')\r\nconst isReference = ref(props.reference)\r\n\r\nconst currentLabel = useLabel(label, wrapper)\r\n\r\nconst className = computed(() => {\r\n const baseClass = nh.be('item')\r\n\r\n return {\r\n [baseClass]: true,\r\n [`${baseClass}--disabled`]: props.disabled,\r\n [`${baseClass}--selected`]: !props.disabled && props.selected,\r\n [`${baseClass}--divided`]: props.divided,\r\n }\r\n})\r\n\r\ndefineExpose({ wrapper, handleSelect })\r\n\r\nfunction handleSelect() {\r\n if (props.disabled || isReference.value) {\r\n return\r\n }\r\n\r\n if (typeof parentSelectHandler === 'function') {\r\n parentSelectHandler([currentLabel.value!], [props.meta || {}])\r\n }\r\n\r\n emitEvent(props.onSelect!, currentLabel.value!)\r\n}\r\n</script>\r\n\r\n<template>\r\n <li\r\n ref=\"wrapper\"\r\n :class=\"className\"\r\n role=\"menuitem\"\r\n tabindex=\"0\"\r\n @click=\"handleSelect\"\r\n >\r\n <slot></slot>\r\n </li>\r\n</template>\r\n"],"names":["props","__props","parentSelectHandler","inject","SELECT_HANDLER","nh","useNameHelper","wrapper","ref","label","toRef","isReference","currentLabel","useLabel","className","computed","baseClass","__expose","handleSelect","emitEvent","_createElementBlock","_renderSlot","_ctx"],"mappings":";;;;;;;;;;AAUA,UAAMA,IAAQC,GAERC,IAAsBC,EAAOC,GAAgB,IAAI,GAEjDC,IAAKC,EAAc,UAAU,GAC7BC,IAAUC,EAAI,IAAI,GAClBC,IAAQC,EAAMV,GAAO,OAAO,GAC5BW,IAAcH,EAAIR,EAAM,SAAS,GAEjCY,IAAeC,EAASJ,GAAOF,CAAO,GAEtCO,IAAYC,EAAS,MAAM;AACzB,YAAAC,IAAYX,EAAG,GAAG,MAAM;AAEvB,aAAA;AAAA,QACL,CAACW,CAAS,GAAG;AAAA,QACb,CAAC,GAAGA,CAAS,YAAY,GAAGhB,EAAM;AAAA,QAClC,CAAC,GAAGgB,CAAS,YAAY,GAAG,CAAChB,EAAM,YAAYA,EAAM;AAAA,QACrD,CAAC,GAAGgB,CAAS,WAAW,GAAGhB,EAAM;AAAA,MACnC;AAAA,IAAA,CACD;AAEY,IAAAiB,EAAA,EAAE,SAAAV,GAAS,cAAAW,GAAc;AAEtC,aAASA,IAAe;AAClB,MAAAlB,EAAM,YAAYW,EAAY,UAI9B,OAAOT,KAAwB,cACbA,EAAA,CAACU,EAAa,KAAM,GAAG,CAACZ,EAAM,QAAQ,CAAA,CAAE,CAAC,GAGrDmB,EAAAnB,EAAM,UAAWY,EAAa,KAAM;AAAA,IAAA;2BAK9CQ,EAQK,MAAA;AAAA,eAPC;AAAA,MAAJ,KAAIb;AAAA,MACH,SAAOO,EAAS,KAAA;AAAA,MACjB,MAAK;AAAA,MACL,UAAS;AAAA,MACR,SAAOI;AAAA,IAAA;MAERG,EAAaC,EAAA,QAAA,SAAA;AAAA;;;"}