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/pisellFind/PisellFind.stories.tsx
var PisellFind_stories_exports = {};
__export(PisellFind_stories_exports, {
  Basic: () => Basic,
  DrawerMode: () => DrawerMode,
  InputMode: () => InputMode,
  MultiFieldSearch: () => MultiFieldSearch,
  NoHistory: () => NoHistory,
  Playground: () => Playground,
  TableFind: () => TableFind,
  WithConfirmButton: () => WithConfirmButton,
  WithRef: () => WithRef,
  default: () => PisellFind_stories_default
});
module.exports = __toCommonJS(PisellFind_stories_exports);
var import_react = __toESM(require("react"));
var import_index = require("./index");
var import_antd = require("antd");
var meta = {
  title: "Plus Components/PisellFind",
  component: import_index.PisellFind,
  parameters: {
    layout: "padded",
    docs: {
      description: {
        component: "基于 PisellLookup 的组件内查找组件，专门为已加载数据的查找场景优化。"
      }
    }
  },
  tags: ["autodocs"]
};
var PisellFind_stories_default = meta;
var mockProducts = [
  { id: 1, name: "iPhone 15 Pro", price: 7999, category: "手机", stock: 100 },
  { id: 2, name: "iPhone 14", price: 5999, category: "手机", stock: 150 },
  { id: 3, name: "MacBook Pro", price: 12999, category: "电脑", stock: 50 },
  { id: 4, name: "MacBook Air", price: 7999, category: "电脑", stock: 80 },
  { id: 5, name: "iPad Air", price: 4799, category: "平板", stock: 120 },
  { id: 6, name: "iPad Pro", price: 6799, category: "平板", stock: 60 },
  { id: 7, name: "AirPods Pro", price: 1899, category: "耳机", stock: 200 },
  { id: 8, name: "Apple Watch", price: 2999, category: "手表", stock: 90 }
];
var Basic = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        onSearch: (keyword) => {
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(keyword.toLowerCase())
          );
          setFilteredData(filtered);
        }
      }
    )), /* @__PURE__ */ import_react.default.createElement(
      import_antd.List,
      {
        dataSource: filteredData,
        renderItem: (item) => /* @__PURE__ */ import_react.default.createElement(import_antd.List.Item, null, /* @__PURE__ */ import_react.default.createElement(
          import_antd.List.Item.Meta,
          {
            title: item.name,
            description: /* @__PURE__ */ import_react.default.createElement(import_antd.Space, null, /* @__PURE__ */ import_react.default.createElement(import_antd.Tag, { color: "blue" }, item.category), /* @__PURE__ */ import_react.default.createElement("span", { style: { color: "#ff4d4f", fontWeight: "bold" } }, "¥", item.price), /* @__PURE__ */ import_react.default.createElement("span", null, "库存: ", item.stock))
          }
        ))
      }
    ));
  }
};
var TableFind = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    const columns = [
      { title: "商品名称", dataIndex: "name", key: "name" },
      { title: "价格", dataIndex: "price", key: "price", render: (v) => `¥${v}` },
      { title: "分类", dataIndex: "category", key: "category", render: (v) => /* @__PURE__ */ import_react.default.createElement(import_antd.Tag, null, v) },
      { title: "库存", dataIndex: "stock", key: "stock" }
    ];
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16, display: "flex", justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ import_react.default.createElement("h3", null, "商品列表"), /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        onSearch: (keyword) => {
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(keyword.toLowerCase())
          );
          setFilteredData(filtered);
        }
      }
    )), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Table,
      {
        dataSource: filteredData,
        columns,
        pagination: { pageSize: 10 }
      }
    ));
  }
};
var InputMode = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        triggerType: "input",
        placeholder: "搜索商品名称",
        onSearch: (keyword) => {
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(keyword.toLowerCase())
          );
          setFilteredData(filtered);
        }
      }
    )), /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 16 } }, filteredData.map((item) => /* @__PURE__ */ import_react.default.createElement(import_antd.Card, { key: item.id, size: "small" }, /* @__PURE__ */ import_react.default.createElement("h4", null, item.name), /* @__PURE__ */ import_react.default.createElement("p", { style: { color: "#ff4d4f", fontWeight: "bold" } }, "¥", item.price), /* @__PURE__ */ import_react.default.createElement(import_antd.Space, null, /* @__PURE__ */ import_react.default.createElement(import_antd.Tag, null, item.category), /* @__PURE__ */ import_react.default.createElement("span", null, "库存: ", item.stock))))));
  }
};
var WithRef = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    const findRef = (0, import_react.useRef)(null);
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: () => {
      var _a;
      return (_a = findRef.current) == null ? void 0 : _a.open();
    } }, "打开查找"), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: () => {
      var _a;
      return (_a = findRef.current) == null ? void 0 : _a.close();
    } }, "关闭查找"), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: () => {
      var _a;
      return (_a = findRef.current) == null ? void 0 : _a.setKeyword("iPhone");
    } }, "搜索 iPhone"), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: () => {
      var _a;
      const keyword = (_a = findRef.current) == null ? void 0 : _a.getKeyword();
      alert(`当前关键词: ${keyword}`);
    } }, "获取关键词")), /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        ref: findRef,
        onSearch: (keyword) => {
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(keyword.toLowerCase())
          );
          setFilteredData(filtered);
        }
      }
    ), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Table,
      {
        dataSource: filteredData,
        columns: [
          { title: "商品名称", dataIndex: "name" },
          { title: "价格", dataIndex: "price", render: (v) => `¥${v}` }
        ],
        style: { marginTop: 16 }
      }
    ));
  }
};
var WithConfirmButton = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        showConfirmButton: true,
        confirmButtonText: "Search",
        onSearch: (keyword) => {
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(keyword.toLowerCase())
          );
          setFilteredData(filtered);
        }
      }
    )), /* @__PURE__ */ import_react.default.createElement(
      import_antd.List,
      {
        dataSource: filteredData,
        renderItem: (item) => /* @__PURE__ */ import_react.default.createElement(import_antd.List.Item, null, /* @__PURE__ */ import_react.default.createElement(
          import_antd.List.Item.Meta,
          {
            title: item.name,
            description: `¥${item.price}`
          }
        ))
      }
    ));
  }
};
var NoHistory = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        showHistory: false,
        onSearch: (keyword) => {
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(keyword.toLowerCase())
          );
          setFilteredData(filtered);
        }
      }
    )), /* @__PURE__ */ import_react.default.createElement(
      import_antd.List,
      {
        dataSource: filteredData,
        renderItem: (item) => /* @__PURE__ */ import_react.default.createElement(import_antd.List.Item, null, item.name)
      }
    ));
  }
};
var MultiFieldSearch = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        buttonText: "搜索商品",
        onSearch: (keyword) => {
          const kw = keyword.toLowerCase();
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(kw) || item.category.toLowerCase().includes(kw)
          );
          setFilteredData(filtered);
        }
      }
    ), /* @__PURE__ */ import_react.default.createElement("p", { style: { marginTop: 8, color: "#999", fontSize: 12 } }, "支持搜索商品名称和分类")), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Table,
      {
        dataSource: filteredData,
        columns: [
          { title: "商品名称", dataIndex: "name" },
          { title: "价格", dataIndex: "price", render: (v) => `¥${v}` },
          { title: "分类", dataIndex: "category", render: (v) => /* @__PURE__ */ import_react.default.createElement(import_antd.Tag, null, v) },
          { title: "库存", dataIndex: "stock" }
        ]
      }
    ));
  }
};
var DrawerMode = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        displayType: "drawer",
        drawerPlacement: "right",
        onSearch: (keyword) => {
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(keyword.toLowerCase())
          );
          setFilteredData(filtered);
        }
      }
    )), /* @__PURE__ */ import_react.default.createElement(
      import_antd.List,
      {
        dataSource: filteredData,
        renderItem: (item) => /* @__PURE__ */ import_react.default.createElement(import_antd.List.Item, null, /* @__PURE__ */ import_react.default.createElement(
          import_antd.List.Item.Meta,
          {
            title: item.name,
            description: `¥${item.price}`
          }
        ))
      }
    ));
  }
};
var Playground = {
  render: () => {
    const [filteredData, setFilteredData] = (0, import_react.useState)(mockProducts);
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(
      import_index.PisellFind,
      {
        triggerType: "button",
        buttonText: "Find",
        showConfirmButton: false,
        showHistory: true,
        maxHistoryCount: 10,
        size: "middle",
        disabled: false,
        onSearch: (keyword) => {
          const filtered = mockProducts.filter(
            (item) => item.name.toLowerCase().includes(keyword.toLowerCase())
          );
          setFilteredData(filtered);
        }
      }
    )), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Table,
      {
        dataSource: filteredData,
        columns: [
          { title: "商品名称", dataIndex: "name" },
          { title: "价格", dataIndex: "price", render: (v) => `¥${v}` },
          { title: "分类", dataIndex: "category", render: (v) => /* @__PURE__ */ import_react.default.createElement(import_antd.Tag, null, v) }
        ]
      }
    ));
  }
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Basic,
  DrawerMode,
  InputMode,
  MultiFieldSearch,
  NoHistory,
  Playground,
  TableFind,
  WithConfirmButton,
  WithRef
});
