UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 1.33 kB
{"version":3,"file":"index.mjs","sources":["../../../../../packages/hooks/use-transition/index.ts"],"sourcesContent":["import { computed, ref, watch, nextTick } from 'vue'\n\nimport type { ExtractPropTypes, Ref } from 'vue'\n\nexport const useTransitionProps = {\n transitionDuration: {\n type: Number,\n default: 0.3,\n },\n transitionShow: String,\n transitionHide: String,\n}\n\nexport const useTransition = (\n props: ExtractPropTypes<typeof useTransitionProps>,\n indicator: Ref<boolean>\n) => {\n const transitionState = ref(indicator.value)\n watch(indicator, (val) => {\n nextTick(() => (transitionState.value = val))\n })\n\n return {\n transition: computed(() => {\n return `el-transition--${\n transitionState.value ? props.transitionShow : props.transitionHide\n }`\n }),\n transitionStyle: computed(\n () => `--el-transition-duration: ${props.transitionDuration}s`\n ),\n }\n}\n"],"names":[],"mappings":";;MAIa,qBAAqB;AAAA,EAChC,oBAAoB;AAAA,IAClB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAEX,gBAAgB;AAAA,EAChB,gBAAgB;AAAA;MAGL,gBAAgB,CAC3B,OACA,cACG;AACH,QAAM,kBAAkB,IAAI,UAAU;AACtC,QAAM,WAAW,CAAC,QAAQ;AACxB,aAAS,MAAO,gBAAgB,QAAQ;AAAA;AAG1C,SAAO;AAAA,IACL,YAAY,SAAS,MAAM;AACzB,aAAO,kBACL,gBAAgB,QAAQ,MAAM,iBAAiB,MAAM;AAAA;AAAA,IAGzD,iBAAiB,SACf,MAAM,6BAA6B,MAAM;AAAA;AAAA;;;;"}