UNPKG

@extclp/vexip-ui

Version:

A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good

1 lines 2.62 kB
{"version":3,"file":"wheel-item.vue2.mjs","sources":["../../../components/wheel/wheel-item.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, inject, onBeforeUnmount, onMounted, reactive, ref, toRef } from 'vue'\n\nimport { useNameHelper } from '@vexip-ui/config'\nimport { WHEEL_STATE } from './symbol'\n\ndefineOptions({ name: 'WheelItem' })\n\nconst props = defineProps({\n value: {\n type: [Number, String],\n default: null\n },\n disabled: {\n type: Boolean,\n default: false\n },\n active: {\n type: Boolean,\n default: false\n },\n meta: {\n type: [String, Number, Object],\n default: null\n }\n})\n\nconst nh = useNameHelper('wheel')\n\nconst wheelState = inject(WHEEL_STATE, null)\n\nconst width = ref(0)\nconst height = ref(0)\n\nconst wrapper = ref<HTMLElement>()\n\nconst state = reactive({\n width,\n height,\n el: wrapper,\n value: toRef(props, 'value'),\n disabled: toRef(props, 'disabled'),\n meta: toRef(props, 'meta')\n})\n\nconst style = computed(() => {\n return {\n width: width.value ? `${width.value}px` : undefined,\n height: height.value ? `${height.value}px` : undefined\n }\n})\n\nif (wheelState) {\n onMounted(() => {\n wheelState.increaseItem(state)\n })\n\n onBeforeUnmount(() => {\n wheelState.decreaseItem(state)\n })\n}\n\ndefineExpose({ wrapper })\n</script>\n\n<template>\n <li\n ref=\"wrapper\"\n :class=\"[\n nh.be('item'),\n disabled && nh.bem('item', 'disabled'),\n active && nh.bem('item', 'active')\n ]\"\n role=\"option\"\n :aria-disabled=\"disabled ? 'true' : undefined\"\n :aria-selected=\"active\"\n :style=\"style\"\n >\n <slot>\n {{ value }}\n </slot>\n </li>\n</template>\n"],"names":["props","__props","nh","useNameHelper","wheelState","inject","WHEEL_STATE","width","ref","height","wrapper","state","reactive","toRef","style","computed","onMounted","onBeforeUnmount","__expose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAQA,UAAMA,IAAQC,GAmBRC,IAAKC,EAAc,OAAO,GAE1BC,IAAaC,EAAOC,GAAa,IAAI,GAErCC,IAAQC,EAAI,CAAC,GACbC,IAASD,EAAI,CAAC,GAEdE,IAAUF,EAAiB,GAE3BG,IAAQC,EAAS;AAAA,MACrB,OAAAL;AAAA,MACA,QAAAE;AAAA,MACA,IAAIC;AAAA,MACJ,OAAOG,EAAMb,GAAO,OAAO;AAAA,MAC3B,UAAUa,EAAMb,GAAO,UAAU;AAAA,MACjC,MAAMa,EAAMb,GAAO,MAAM;AAAA,IAAA,CAC1B,GAEKc,IAAQC,EAAS,OACd;AAAA,MACL,OAAOR,EAAM,QAAQ,GAAGA,EAAM,KAAK,OAAO;AAAA,MAC1C,QAAQE,EAAO,QAAQ,GAAGA,EAAO,KAAK,OAAO;AAAA,IAC/C,EACD;AAED,WAAIL,MACFY,EAAU,MAAM;AACd,MAAAZ,EAAW,aAAaO,CAAK;AAAA,IAAA,CAC9B,GAEDM,EAAgB,MAAM;AACpB,MAAAb,EAAW,aAAaO,CAAK;AAAA,IAAA,CAC9B,IAGUO,EAAA,EAAE,SAAAR,GAAS;;;;;;;;;;;;;;;;;;;"}