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

export default defineComponent({
	name: "GnActionList",
	props: {
		items: { type: Array, default: () => [] }
	},
	setup(props, { attrs, slots }) {
		return () => h("ul", { ...attrs, class: cx("list list-actions", attrs.class) }, props.items.map(item => h("li", {
			class: cx("list-item", item.muted && "list-item-muted")
		}, [
			h("div", { class: "list-content" }, [
				h("div", { class: "list-title" }, slots.title?.({ item }) || item.title),
				(item.subtitle || slots.subtitle) && h("div", { class: "list-subtitle" }, slots.subtitle?.({ item }) || item.subtitle)
			]),
			slots.controls && h("div", { class: "list-controls" }, slots.controls({ item }))
		])));
	}
});
