@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
1 lines • 2.48 kB
Source Map (JSON)
{"version":3,"file":"dropdown-item.vue2.mjs","sources":["../../../components/dropdown/dropdown-item.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, inject, ref, toRef } from 'vue'\n\nimport { emitEvent, useNameHelper } from '@vexip-ui/config'\nimport { dropdownItemProps } from './props'\nimport { useLabel } from './hooks'\nimport { SELECT_HANDLER } from './symbol'\n\ndefineOptions({ name: 'DropdownItem' })\n\nconst props = defineProps(dropdownItemProps)\n\nconst parentSelectHandler = inject(SELECT_HANDLER, null)\n\nconst nh = useNameHelper('dropdown')\nconst wrapper = ref(null)\nconst label = toRef(props, 'label')\nconst isReference = ref(props.reference)\n\nconst currentLabel = useLabel(label, wrapper)\n\nconst className = computed(() => {\n const baseClass = nh.be('item')\n\n return {\n [baseClass]: true,\n [`${baseClass}--disabled`]: props.disabled,\n [`${baseClass}--selected`]: !props.disabled && props.selected,\n [`${baseClass}--divided`]: props.divided\n }\n})\n\ndefineExpose({ wrapper, handleSelect })\n\nfunction handleSelect() {\n if (props.disabled || isReference.value) {\n return\n }\n\n if (typeof parentSelectHandler === 'function') {\n parentSelectHandler([currentLabel.value!], [props.meta || {}])\n }\n\n emitEvent(props.onSelect!, currentLabel.value!)\n}\n</script>\n\n<template>\n <li\n ref=\"wrapper\"\n :class=\"className\"\n role=\"menuitem\"\n tabindex=\"0\"\n @click=\"handleSelect\"\n >\n <slot></slot>\n </li>\n</template>\n"],"names":["props","__props","parentSelectHandler","inject","SELECT_HANDLER","nh","useNameHelper","wrapper","ref","label","toRef","isReference","currentLabel","useLabel","className","computed","baseClass","__expose","handleSelect","emitEvent"],"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;;;;;;;;;;;;;"}