@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
1 lines • 4.58 kB
Source Map (JSON)
{"version":3,"file":"timeline.vue2.mjs","sources":["../../../components/timeline/timeline.vue"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport { computed, provide, reactive, toRef } from 'vue'\r\n\r\nimport { emitEvent, useNameHelper, useProps } from '@vexip-ui/config'\r\nimport { debounceMinor, isNull } from '@vexip-ui/utils'\r\nimport { timelineProps } from './props'\r\nimport { TIMELINE_STATE } from './symbol'\r\n\r\nimport type { ItemState, TimelineState } from './symbol'\r\n\r\ndefineOptions({ name: 'Timeline' })\r\n\r\nconst _props = defineProps(timelineProps)\r\nconst props = useProps('timeline', _props, {\r\n pending: false,\r\n dashed: false,\r\n lineColor: null,\r\n spacing: null,\r\n flip: false,\r\n horizontal: false,\r\n alternate: false,\r\n})\r\n\r\nconst nh = useNameHelper('timeline')\r\nconst itemStates = reactive(new Set<ItemState>())\r\n\r\nconst className = computed(() => {\r\n return {\r\n [nh.b()]: true,\r\n [nh.bs('vars')]: true,\r\n [nh.bm('inherit')]: props.inherit,\r\n [nh.bm('pending')]: props.pending,\r\n [nh.bm('alternate')]: props.alternate,\r\n [nh.bm('flip')]: props.flip,\r\n [nh.bm('horizontal')]: props.horizontal,\r\n }\r\n})\r\nconst height = computed(() => {\r\n return Math.max(...Array.from(itemStates).map(state => state.height)) * 2\r\n})\r\n\r\ndefineExpose({ itemStates })\r\n\r\nconst refreshLabels = debounceMinor(() => {\r\n const total = itemStates.size\r\n\r\n Array.from(itemStates).forEach((item, index) => {\r\n item.index = index + 1\r\n item.total = total\r\n\r\n if (isNull(item.label)) {\r\n item.label = index + 1\r\n }\r\n })\r\n})\r\n\r\nconst state: TimelineState = reactive({\r\n dashed: toRef(props, 'dashed'),\r\n lineColor: toRef(props, 'lineColor'),\r\n spacing: toRef(props, 'spacing'),\r\n alternate: toRef(props, 'alternate'),\r\n horizontal: toRef(props, 'horizontal'),\r\n increaseItem,\r\n decreaseItem,\r\n handleSignalClick,\r\n})\r\n\r\nprovide(TIMELINE_STATE, state)\r\n\r\nfunction increaseItem(item: ItemState) {\r\n itemStates.add(item)\r\n refreshLabels()\r\n}\r\n\r\nfunction decreaseItem(item: ItemState) {\r\n itemStates.delete(item)\r\n refreshLabels()\r\n}\r\n\r\nfunction handleSignalClick(label: string | number) {\r\n emitEvent(props.onSignalClick, label)\r\n}\r\n</script>\r\n\r\n<template>\r\n <div\r\n :class=\"className\"\r\n :style=\"{ height: props.horizontal && props.alternate ? `${height}px` : undefined }\"\r\n >\r\n <slot></slot>\r\n </div>\r\n</template>\r\n"],"names":["props","useProps","__props","nh","useNameHelper","itemStates","reactive","className","computed","height","state","__expose","refreshLabels","debounceMinor","total","item","index","isNull","toRef","increaseItem","decreaseItem","handleSignalClick","provide","TIMELINE_STATE","label","emitEvent","_createElementBlock","_normalizeStyle","_unref","_renderSlot","_ctx"],"mappings":";;;;;;;;;;AAaM,UAAAA,IAAQC,EAAS,YADRC,GAC4B;AAAA,MACzC,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,SAAS;AAAA,MACT,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,WAAW;AAAA,IAAA,CACZ,GAEKC,IAAKC,EAAc,UAAU,GAC7BC,IAAaC,EAAa,oBAAA,KAAgB,GAE1CC,IAAYC,EAAS,OAClB;AAAA,MACL,CAACL,EAAG,EAAE,CAAC,GAAG;AAAA,MACV,CAACA,EAAG,GAAG,MAAM,CAAC,GAAG;AAAA,MACjB,CAACA,EAAG,GAAG,SAAS,CAAC,GAAGH,EAAM;AAAA,MAC1B,CAACG,EAAG,GAAG,SAAS,CAAC,GAAGH,EAAM;AAAA,MAC1B,CAACG,EAAG,GAAG,WAAW,CAAC,GAAGH,EAAM;AAAA,MAC5B,CAACG,EAAG,GAAG,MAAM,CAAC,GAAGH,EAAM;AAAA,MACvB,CAACG,EAAG,GAAG,YAAY,CAAC,GAAGH,EAAM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