import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
import { computed } from "vue";
import { pick } from "@veno-ui/utils";
import { defineComponent } from "../../utils";
import { CheckboxGroup } from "../checkbox-group";
import { DatePicker } from "../date-picker";
import { FormControl } from "../form-control/form-control";
import { Input } from "../input";
import { RadioGroup } from "../radio-group";
import { Select } from "../select";
import { Switch } from "../switch";
const FormChildren = defineComponent({
  name: "VeFormChildren",
  props: {
    /**
     * @zh 数据驱动的表单列表项
     */
    items: Array
  },
  setup(props, {
    slots
  }) {
    const items = computed(() => {
      return props.items?.map((item) => {
        const {
          $type: type,
          ...props2
        } = item;
        return {
          type,
          props: props2
        };
      });
    });
    return () => slots.default?.() ?? items.value?.map(({
      type,
      props: itemProps
    }) => {
      switch (type) {
        case "textarea":
          return _createVNode(Input, _mergeProps({
            "type": "textarea"
          }, itemProps), null);
        case "select":
          return _createVNode(Select, itemProps, null);
        case "switch":
          const [controlProps, switchProps] = pick(itemProps || {}, ["label"]);
          return _createVNode(FormControl, controlProps, {
            default: () => [_createVNode(Switch, switchProps, null)]
          });
        case "date-picker":
          return _createVNode(DatePicker, itemProps, null);
        case "checkbox":
          return _createVNode(CheckboxGroup, itemProps, null);
        case "radio":
          return _createVNode(RadioGroup, itemProps, null);
        case "input":
        default:
          return _createVNode(Input, itemProps, null);
      }
    });
  }
});
export {
  FormChildren
};
//# sourceMappingURL=form-children.mjs.map
