vuestic-ui
Version:
Vue 3 UI Framework
87 lines (86 loc) • 2.43 kB
JavaScript
import { h, Fragment } from "vue";
import { u as useComponentPresetProp } from "../../composables/useComponentPreset.mjs";
const VaTimeline_vue_vue_type_style_index_0_lang = "";
const getPropsData = (slot) => slot == null ? void 0 : slot.props;
const getIsActive = (slot) => {
var _a;
return !!((_a = slot == null ? void 0 : slot.props) == null ? void 0 : _a.active) || false;
};
const isVueFragment = (slot) => slot.type === Fragment;
const isEmptyArray = (arr) => arr && arr.length === 0;
function getSlots(slots) {
var _a;
const defaultSlots = (_a = slots.default) == null ? void 0 : _a.call(slots);
if (!defaultSlots || isEmptyArray(defaultSlots)) {
return [];
}
if (isVueFragment(defaultSlots[0])) {
return defaultSlots[0].children;
}
return defaultSlots;
}
const processSlots = (context) => {
const slots = getSlots(context.slots);
slots.forEach((slot, index) => {
if (!getPropsData(slot)) {
slot.props = {};
}
const propsData = getPropsData(slot);
propsData.vertical = context.props.vertical;
if (context.props.centered) {
propsData.inverted = !!(index % 2);
}
if (index === 0) {
propsData.isFirst = true;
}
if (index === slots.length - 1) {
propsData.isLast = true;
}
const currentSlotActive = propsData.active;
if (!currentSlotActive) {
return;
}
if (index === 0) {
propsData.activePrevious = currentSlotActive;
}
if (index === slots.length - 1) {
propsData.activeNext = currentSlotActive;
}
const previousSlotActive = getIsActive(slots[index - 1]);
if (previousSlotActive) {
propsData.activePrevious = true;
}
const nextSlotActive = getIsActive(slots[index + 1]);
if (nextSlotActive) {
propsData.activeNext = true;
}
});
return slots;
};
const COMPONENT_NAME = "va-timeline";
const _sfc_main = {
name: COMPONENT_NAME,
props: {
...useComponentPresetProp,
vertical: { type: Boolean },
centered: { type: Boolean },
alignTop: { type: Boolean }
},
setup(props, { slots }) {
return () => h(
"div",
{
class: {
[COMPONENT_NAME]: true,
[`${COMPONENT_NAME}--vertical`]: props.vertical,
[`${COMPONENT_NAME}--align-top`]: props.alignTop
}
},
processSlots({ props, slots })
);
}
};
export {
_sfc_main as _
};
//# sourceMappingURL=VaTimeline.mjs.map