import { Dict_Imgs } from "@/dict";
import { createAttrsForm } from "../../defines/createAttrsForm";
import { createCompHooks } from "../../defines/createCompHooks";

export { Component } from "./component";

export const options = {
  name: "图片",
  thumbnail: require("@/modules/editor/assets/icons/picture.svg"),
};

export const { createComp, useCompData } = createCompHooks({
  value: {
    url: Dict_Imgs.Default,
    x: 0,
    y: 0,
    s: 1,
    showLink: false,
    link: "",
  },
  layout: {
    size: [750, 400],
  },
});

export const Form = createAttrsForm([
  // {
  //   label: "图片",
  //   dataIndex: "value.url",
  //   component: "Input",
  // },
  // {
  //   label: "x偏移",
  //   dataIndex: "value.x",
  //   component: "Input",
  // },
  // {
  //   label: "y偏移",
  //   dataIndex: "value.y",
  //   component: "Input",
  // },
  // {
  //   label: "缩放",
  //   dataIndex: "value.s",
  //   component: "Input",
  // },
  {
    label: "添加链接",
    dataIndex: "value.showLink",
    component: "Switch",
  },
  {
    dataIndex: "value.link",
    component: "Input",
    props: {
      placeholder: "http://",
    },
    isVisible: (value, data) => data?.value?.showLink == true,
  },
]);
