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

45 lines
1.7 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('eventOpposite', { index })" v-bind="getPTOptions('eventOpposite', index)">
2022-09-06 12:03:37 +00:00
<slot name="opposite" :item="item" :index="index"></slot>
</div>
<div :class="cx('eventSeparator')" v-bind="getPTOptions('eventSeparator', index)">
2022-09-06 12:03:37 +00:00
<slot name="marker" :item="item" :index="index">
<div :class="cx('eventMarker')" v-bind="getPTOptions('eventMarker', 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('eventConnector')" v-bind="getPTOptions('eventConnector', index)"></div>
2022-09-06 12:03:37 +00:00
</slot>
</div>
<div :class="cx('eventContent')" v-bind="getPTOptions('eventContent', 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>