vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
1 lines • 2.63 kB
Source Map (JSON)
{"version":3,"file":"dropdown-item.vue2.cjs","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","_createElementBlock","_renderSlot","_ctx"],"mappings":"4PAUA,MAAMA,EAAQC,EAERC,EAAsBC,EAAAA,OAAOC,EAAA,eAAgB,IAAI,EAEjDC,EAAKC,gBAAc,UAAU,EAC7BC,EAAUC,MAAI,IAAI,EAClBC,EAAQC,EAAAA,MAAMV,EAAO,OAAO,EAC5BW,EAAcH,EAAAA,IAAIR,EAAM,SAAS,EAEjCY,EAAeC,EAAAA,SAASJ,EAAOF,CAAO,EAEtCO,EAAYC,EAAAA,SAAS,IAAM,CACzB,MAAAC,EAAYX,EAAG,GAAG,MAAM,EAEvB,MAAA,CACL,CAACW,CAAS,EAAG,GACb,CAAC,GAAGA,CAAS,YAAY,EAAGhB,EAAM,SAClC,CAAC,GAAGgB,CAAS,YAAY,EAAG,CAAChB,EAAM,UAAYA,EAAM,SACrD,CAAC,GAAGgB,CAAS,WAAW,EAAGhB,EAAM,OACnC,CAAA,CACD,EAEYiB,EAAA,CAAE,QAAAV,EAAS,aAAAW,EAAc,EAEtC,SAASA,GAAe,CAClBlB,EAAM,UAAYW,EAAY,QAI9B,OAAOT,GAAwB,YACbA,EAAA,CAACU,EAAa,KAAM,EAAG,CAACZ,EAAM,MAAQ,CAAA,CAAE,CAAC,EAGrDmB,EAAAA,UAAAnB,EAAM,SAAWY,EAAa,KAAM,EAAA,6BAK9CQ,EAAA,mBAQK,KAAA,SAPC,UAAJ,IAAIb,EACH,uBAAOO,EAAS,KAAA,EACjB,KAAK,WACL,SAAS,IACR,QAAOI,CAAA,GAERG,aAAaC,EAAA,OAAA,SAAA"}