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/table/Table/tableConfig/body/index.tsx
var body_exports = {};
__export(body_exports, {
  EditableContext: () => EditableContext,
  default: () => body_default
});
module.exports = __toCommonJS(body_exports);
var import_antd = require("antd");
var import_sortable = require("@dnd-kit/sortable");
var import_utilities = require("@dnd-kit/utilities");
var import_icons = require("@ant-design/icons");
var import_classnames = __toESM(require("classnames"));
var import_react = __toESM(require("react"));
var import_CellProvider = __toESM(require("./CellProvider"));
var import_locales = require("../../../../../locales");
var import_index = require("./index.less");
var EditableContext = import_react.default.createContext(
  null
);
var EditableRow = ({
  index,
  __is_group,
  children,
  // __table_group_field,
  // __table_data_source_children,
  __is_drag_sort,
  ...props
}) => {
  const [form] = import_antd.Form.useForm();
  const parentForm = import_antd.Form.useFormInstance();
  const order_by = import_antd.Form.useWatch("order_by", parentForm);
  const {
    attributes,
    listeners,
    setNodeRef,
    setActivatorNodeRef,
    transform,
    transition,
    isDragging
  } = (0, import_sortable.useSortable)({
    id: props["data-row-key"]
  });
  const style = {
    ...props.style,
    transform: import_utilities.CSS.Transform.toString(transform && { ...transform, scaleY: 1 }),
    transition,
    ...isDragging && __is_drag_sort ? { position: "relative", zIndex: 9999 } : {}
  };
  const cells = (0, import_react.useMemo)(() => {
    if (__is_group) {
      return children;
    }
    return import_react.default.Children.map(children, (child) => {
      if (child.key === "__sort") {
        const handleIcon = order_by ? /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: (0, import_locales.getText)("table-column-drag-sort-disabled-tip") }, /* @__PURE__ */ import_react.default.createElement(import_icons.MenuOutlined, { className: "pisell-lowcode-menu-out-lined-icon" })) : /* @__PURE__ */ import_react.default.createElement(
          import_icons.MenuOutlined,
          {
            ref: setActivatorNodeRef,
            className: "pisell-lowcode-menu-out-lined-icon",
            ...listeners
          }
        );
        return import_react.default.cloneElement(child, {
          children: handleIcon
        });
      }
      return child;
    });
  }, [__is_group, children, order_by, setActivatorNodeRef, listeners]);
  return /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { form, component: false }, /* @__PURE__ */ import_react.default.createElement(EditableContext.Provider, { value: form }, __is_group && /* @__PURE__ */ import_react.default.createElement("tr", { style: { height: 12 } }), /* @__PURE__ */ import_react.default.createElement("tr", { ...props, ref: setNodeRef, style, ...attributes }, cells)));
};
var EditableCell = (props) => {
  const {
    title,
    editable,
    children,
    dataIndex,
    field_type,
    record,
    handleSave,
    lock,
    render,
    ...restProps
  } = props;
  return /* @__PURE__ */ import_react.default.createElement(
    "td",
    {
      ...restProps,
      className: (0, import_classnames.default)(
        restProps.className,
        "ant-table-cell",
        "materials-grid-table-cell"
      )
    },
    /* @__PURE__ */ import_react.default.createElement(import_CellProvider.default, { ...props })
  );
};
var body_default = {
  Row: EditableRow,
  Coll: EditableCell
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  EditableContext
});
