import { Input, Button } from "@alifd/next";
import React from "react";
import TableActionExpandedRow from "./components/tableActionExpandedRow.tsx";
import TableActionToast from "./components/tableActionToast.tsx";
import TableColumnText from "./components/tableColumnText.tsx";

function BlurSubmitInput(props) {
  return <Input onBlur={() => props.refresh()} {...props} />;
}

export default {
  /**
   * 扩展筛选区域的组件
   * 扩展map中的key对应filterSchema中的type值
   */
  filterCompsMap: {
    BlurSubmitInput,
  },

  /**
   * 表格column定制组件
   * 扩展map中的key对应tableSchema中的type值
   */
  tableColumnsMap: {
    Text: TableColumnText,
    ExpandedRow: TableActionExpandedRow,
  },

  /**
   * 表格操作column里面，定制的每个操作组件，例如操作里面，查看、编辑、下载等按钮操作等
   * 扩展map中的key对应返回列表数据中actions数组每个元素中的type值
   * 例如list数据中结构:
   * [
      "gender": "female",
      "name": {
        "title": "Mrs",
        "first": "Becky",
        "last": "Franklin"
      },
      "actions": [
        {
          "type": "openLink",
          "text": "点击跳转",
          "href": "https://taobao.com"
        }
      ],
    ]
   *
   *
   *
   */
  tableActionsMap: {
    actToast: TableActionToast,
    action1: (props: any) => {
      return (
        <Button
          text
          type="primary"
          style={{ marginRight: 8 }}
          onClick={(e) => {
            props.refresh(e, true);
          }}
        >
          操作1
        </Button>
      );
    },
    action2: (props: any) => {
      return (
        <Button
          text
          type="primary"
          style={{ marginRight: 8 }}
          onClick={() => {
            props.refresh();
          }}
        >
          操作2
        </Button>
      );
    },
    action3: () => {
      return (
        <Button text type="primary" style={{ marginRight: 8 }}>
          操作2
        </Button>
      );
    },
    action4: () => {
      return (
        <Button text type="primary">
          操作2
        </Button>
      );
    },
  },
};
