"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const reactBindingUi = require("@contember/react-binding-ui");
const ui = require("@contember/ui");
const react = require("react");
const RepeaterFieldContainer = react.memo(
  ({
    accessor,
    addButtonText,
    children,
    createNewEntity,
    addButtonComponent: AddButton = reactBindingUi.CreateNewEntityButton,
    addButtonComponentExtraProps,
    addButtonProps,
    emptyMessage,
    emptyMessageComponent,
    enableAddingNew = true,
    formatMessage,
    isEmpty,
    label,
    ...rest
  }) => {
    return /* @__PURE__ */ jsxRuntime.jsxs(
      ui.FieldContainer,
      {
        label,
        ...rest,
        useLabelElement: false,
        footer: enableAddingNew && /* @__PURE__ */ jsxRuntime.jsx(
          AddButton,
          {
            ...addButtonComponentExtraProps,
            ...addButtonProps,
            createNewEntity,
            children: addButtonText ?? label ?? formatMessage("repeater.addButton.text")
          }
        ),
        children: [
          /* @__PURE__ */ jsxRuntime.jsx(reactBindingUi.AccessorErrors, { accessor }),
          isEmpty && /* @__PURE__ */ jsxRuntime.jsx(reactBindingUi.EmptyMessage, { component: emptyMessageComponent, children: formatMessage(emptyMessage, "repeater.emptyMessage.text") }),
          isEmpty || children
        ]
      }
    );
  }
);
RepeaterFieldContainer.displayName = "RepeaterFieldContainer";
exports.RepeaterFieldContainer = RepeaterFieldContainer;
//# sourceMappingURL=RepeaterFieldContainer.cjs.map
