import { defineComponent, h } from "vue";
import { cx } from "../utils.js";

export default defineComponent({
	name: "GnDescriptionList",
	props: {
		items: { type: Array, default: () => [] },
		compact: { type: Boolean, default: false }
	},
	setup(props, { attrs, slots }) {
		return () => h("dl", {
			...attrs,
			class: cx("description-list", { "description-list-compact": props.compact }, attrs.class)
		}, props.items.map(item => h("div", { class: "description-list-row" }, [
			h("dt", { class: "description-list-term" }, item.term || item.label),
			h("dd", { class: cx("description-list-value", item.muted && "description-list-value-muted") },
				slots[item.key]?.({ item }) || item.value
			)
		])));
	}
});
