primevue-mirror/components/lib/timeline/Timeline.vue

45 lines
1.6 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
2024-02-11 23:48:46 +00:00
<div :class="cx('root')" v-bind="ptmi('root')">
<div v-for="(item, index) of value" :key="getKey(item, index)" :class="cx('event')" v-bind="getPTOptions('event', index)">
<div :class="cx('opposite', { index })" v-bind="getPTOptions('opposite', index)">
2022-09-06 12:03:37 +00:00
<slot name="opposite" :item="item" :index="index"></slot>
</div>
<div :class="cx('separator')" v-bind="getPTOptions('separator', index)">
2022-09-06 12:03:37 +00:00
<slot name="marker" :item="item" :index="index">
<div :class="cx('marker')" v-bind="getPTOptions('marker', index)"></div>
2022-09-06 12:03:37 +00:00
</slot>
2022-09-14 11:26:01 +00:00
<slot v-if="index !== value.length - 1" name="connector" :item="item" :index="index">
<div :class="cx('connector')" v-bind="getPTOptions('connector', index)"></div>
2022-09-06 12:03:37 +00:00
</slot>
</div>
<div :class="cx('content')" v-bind="getPTOptions('content', index)">
2022-09-06 12:03:37 +00:00
<slot name="content" :item="item" :index="index"></slot>
</div>
</div>
</div>
</template>
<script>
2022-09-14 11:26:01 +00:00
import { ObjectUtils } from 'primevue/utils';
2023-06-13 13:24:14 +00:00
import BaseTimeline from './BaseTimeline.vue';
2022-09-06 12:03:37 +00:00
export default {
name: 'Timeline',
2023-06-13 13:24:14 +00:00
extends: BaseTimeline,
2024-02-11 23:48:46 +00:00
inheritAttrs: false,
2022-09-06 12:03:37 +00:00
methods: {
getKey(item, index) {
return this.dataKey ? ObjectUtils.resolveFieldData(item, this.dataKey) : index;
},
getPTOptions(key, index) {
return this.ptm(key, {
context: {
index,
count: this.value.length
}
});
2022-09-06 12:03:37 +00:00
}
}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
</script>