"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.RowExpandCell = RowExpandCell;
var _react = _interopRequireWildcard(require("react"));
var _faChevronRight = require("@fortawesome/free-solid-svg-icons/faChevronRight");
var _classnames = _interopRequireDefault(require("classnames"));
var _button = require("../../../button");
var _fontAwesomeIcon = require("../../../font-awesome-icon");
var _useTableKeyboardNavigation = require("../../../hooks/use-table-keyboard-navigation");
var _useTranslation = require("../../../hooks/use-translation");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function RowExpandCell({
  row,
  keyboardNavCellId,
  expandRowButtonAriaLabel
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  const keyboardNavContext = (0, _react.useContext)(_useTableKeyboardNavigation.TableKeyboardNavigationContext);
  keyboardNavContext?.registerCustomCellAction(keyboardNavCellId, e => {
    e.stopPropagation();
    row.getToggleExpandedHandler()();
  });
  const isRowExpanded = row.getIsExpanded();
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
    accentType: _button.ACCENT_TYPES.COMMAND,
    className: (0, _classnames.default)('row-expand-button', {
      'row-expanded': isRowExpanded
    }),
    onClick: e => {
      e.stopPropagation();
      row.getToggleExpandedHandler()();
    },
    testId: "row-expand-button",
    "aria-label": expandRowButtonAriaLabel ?? t('Expand Row'),
    "aria-expanded": isRowExpanded,
    tabIndex: -1,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
      icon: _faChevronRight.faChevronRight
    })
  });
}