UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 2.73 kB
{"version":3,"file":"timeline.mjs","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"],"names":[],"mappings":";;;;;;AASO,MAAM,gBAAgB,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAItC,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,MAAA;AAAA,IACN,MAAA,EAAQ,CAAC,OAAA,EAAS,WAAA,EAAa,qBAAqB,KAAK,CAAA;AAAA,IACzD,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,OAAA,EAAS;AACX,CAAU;AAIV,MAAM,WAAW,eA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