var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/PisellGroupView/PisellGroupView.stories.tsx
var PisellGroupView_stories_exports = {};
__export(PisellGroupView_stories_exports, {
  Basic: () => Basic,
  Empty: () => Empty,
  GridBody: () => GridBody,
  OmitHeaderFields: () => OmitHeaderFields,
  default: () => PisellGroupView_stories_default
});
module.exports = __toCommonJS(PisellGroupView_stories_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_PisellGroupView = __toESM(require("./PisellGroupView"));
var meta = {
  title: "Layout 布局组件/PisellGroupView",
  component: import_PisellGroupView.default,
  parameters: {
    layout: "padded",
    docs: {
      description: {
        component: "通用、数据无关的分组展示容器。先按 groupBy 分组，再为每组渲染头部/统计/主体/操作四块，全部通过 render 函数自定义。"
      }
    }
  },
  tags: ["autodocs"]
};
var PisellGroupView_stories_default = meta;
var bookings = [
  { id: 1, productName: "羽毛球场 A", time: "10:00", customer: "Tom", amount: 100 },
  { id: 2, productName: "羽毛球场 A", time: "10:00", customer: "Tom", amount: 50 },
  { id: 3, productName: "羽毛球场 A", time: "11:00", customer: "Amy", amount: 80 },
  { id: 4, productName: "网球场 B", time: "11:00", customer: "Jerry", amount: 120 },
  { id: 5, productName: "网球场 B", time: "11:00", customer: "Jerry", amount: 60 }
];
var groupCardStyle = {
  border: "1px solid #eee",
  borderRadius: 8,
  padding: 16,
  marginBottom: 16
};
var Basic = {
  render: () => /* @__PURE__ */ import_react.default.createElement(
    import_PisellGroupView.default,
    {
      dataSource: bookings,
      groupBy: ["productName", "time"],
      rowKey: "id",
      renderGroup: (g, blocks) => /* @__PURE__ */ import_react.default.createElement("div", { style: groupCardStyle, "data-id": g.groupId }, blocks.header, blocks.stats, blocks.body, blocks.actions),
      renderHeader: (g) => /* @__PURE__ */ import_react.default.createElement("div", { style: { fontWeight: 600, fontSize: 15 } }, String(g.keyMap.productName), /* @__PURE__ */ import_react.default.createElement(import_antd.Tag, { style: { marginLeft: 8 } }, String(g.keyMap.time))),
      renderStats: (g) => /* @__PURE__ */ import_react.default.createElement("div", { style: { color: "#888", margin: "6px 0" } }, "共 ", g.items.length, " 项 · 合计 ￥", g.items.reduce((s, i) => s + i.amount, 0)),
      renderItem: (item) => /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          style: {
            display: "flex",
            justifyContent: "space-between",
            padding: "6px 0",
            borderTop: "1px solid #f0f0f0"
          }
        },
        /* @__PURE__ */ import_react.default.createElement("span", null, "#", item.id, " ", item.customer),
        /* @__PURE__ */ import_react.default.createElement("span", null, "￥", item.amount)
      ),
      renderActions: () => /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { style: { marginTop: 10 } }, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { size: "small" }, "批量加时"), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { size: "small", type: "primary" }, "批量编辑"))
    }
  )
};
var GridBody = {
  render: () => /* @__PURE__ */ import_react.default.createElement(
    import_PisellGroupView.default,
    {
      dataSource: bookings,
      groupBy: "productName",
      rowKey: "id",
      itemLayout: { columns: 2, gap: 8 },
      renderGroup: (g, blocks) => /* @__PURE__ */ import_react.default.createElement("div", { style: groupCardStyle }, blocks.header, blocks.body),
      renderHeader: (g) => /* @__PURE__ */ import_react.default.createElement("h4", { style: { margin: "0 0 8px" } }, String(g.keyMap.productName)),
      renderItem: (item) => /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          style: {
            padding: 12,
            border: "1px solid #eee",
            borderRadius: 6,
            background: "#fafafa"
          }
        },
        item.time,
        " · ",
        item.customer,
        " · ￥",
        item.amount
      )
    }
  )
};
var OmitHeaderFields = {
  render: () => /* @__PURE__ */ import_react.default.createElement(
    import_PisellGroupView.default,
    {
      dataSource: bookings,
      groupBy: ["productName", "time"],
      rowKey: "id",
      renderGroup: (g, blocks) => /* @__PURE__ */ import_react.default.createElement("div", { style: groupCardStyle }, blocks.header, blocks.body),
      renderHeader: (g) => /* @__PURE__ */ import_react.default.createElement("div", { style: { fontWeight: 600 } }, String(g.keyMap.productName), " · ", String(g.keyMap.time)),
      renderItem: (item, ctx) => {
        const omitted = new Set(ctx.groupKeys);
        const entries = Object.entries(item).filter(
          ([key]) => key !== "id" && !omitted.has(key)
        );
        return /* @__PURE__ */ import_react.default.createElement("div", { style: { padding: "6px 0", borderTop: "1px solid #f0f0f0" } }, "#", item.id, " ", entries.map(([k, v]) => `${k}: ${String(v)}`).join(" · "));
      }
    }
  )
};
var Empty = {
  render: () => /* @__PURE__ */ import_react.default.createElement(
    import_PisellGroupView.default,
    {
      dataSource: [],
      groupBy: "productName",
      renderEmpty: () => /* @__PURE__ */ import_react.default.createElement("div", { style: { color: "#bbb", padding: 24, textAlign: "center" } }, "暂无数据")
    }
  )
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Basic,
  Empty,
  GridBody,
  OmitHeaderFields
});
