element-plus
Version:
A Component Library for Vue 3
1 lines • 2.21 kB
Source Map (JSON)
{"version":3,"file":"timeline.mjs","names":[],"sources":["../../../../../../packages/components/timeline/src/timeline.ts"],"sourcesContent":["import { computed, defineComponent, h, provide } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { TIMELINE_INJECTION_KEY } from './tokens'\nimport { buildProps, flattedChildren } from '@element-plus/utils'\n\nimport type { VNodeChildAtom } from '@element-plus/utils'\nimport type { ExtractPropTypes, ExtractPublicPropTypes } from 'vue'\nimport type { TimelineProvider } from './tokens'\n\nexport const timelineProps = buildProps({\n /**\n * @description relative position of timeline and content\n */\n mode: {\n type: String,\n values: ['start', 'alternate', 'alternate-reverse', 'end'],\n default: 'start',\n },\n /**\n * @description whether reverse order\n */\n reverse: Boolean,\n} as const)\nexport type TimelineProps = ExtractPropTypes<typeof timelineProps>\nexport type TimelinePropsPublic = ExtractPublicPropTypes<typeof timelineProps>\n\nconst Timeline = defineComponent({\n name: 'ElTimeline',\n props: timelineProps,\n\n setup(props, { slots }) {\n const ns = useNamespace('timeline')\n\n provide<TimelineProvider>(TIMELINE_INJECTION_KEY, { props, slots })\n\n const timelineKls = computed(() => [ns.b(), ns.is(props.mode)])\n\n return () => {\n const children = flattedChildren(\n slots.default?.() ?? []\n ) as VNodeChildAtom[]\n\n return h(\n 'ul',\n { class: timelineKls.value },\n props.reverse ? children.reverse() : children\n )\n }\n },\n})\n\nexport default Timeline\nexport type TimelineInstance = InstanceType<typeof Timeline> & unknown\n"],"mappings":";;;;;;;AASA,MAAa,gBAAgB,WAAW;CAItC,MAAM;EACJ,MAAM;EACN,QAAQ;GAAC;GAAS;GAAa;GAAqB;GAAM;EAC1D,SAAS;EACV;CAID,SAAS;CACV,CAAU;AAIX,MAAM,WAAW,gBAAgB;CAC/B,MAAM;CACN,OAAO;CAEP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,KAAK,aAAa,WAAW;AAEnC,UAA0B,wBAAwB;GAAE;GAAO;GAAO,CAAC;EAEnE,MAAM,cAAc,eAAe,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,MAAM,KAAK,CAAC,CAAC;AAE/D,eAAa;GACX,MAAM,WAAW,gBACf,MAAM,WAAW,IAAI,EAAE,CACxB;AAED,UAAO,EACL,MACA,EAAE,OAAO,YAAY,OAAO,EAC5B,MAAM,UAAU,SAAS,SAAS,GAAG,SACtC;;;CAGN,CAAC"}