import _extends from '@babel/runtime/helpers/extends';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import React__default from 'react';
import { TableCell } from '@carbon/react';
import Button from '../../../Button/Button.js';
import { settings } from '../../../../constants/Settings.js';
import { ChevronRight } from '@carbon/icons-react';

var _excluded = ["ariaLabel", "className", "children", "isExpanded", "onExpand", "expandIconDescription", "isSelected", "expandHeaderId", "rowId", "langDir"];
var prefix = settings.prefix,
  iotPrefix = settings.iotPrefix;
var propTypes = {
  /**
   * Specify the string read by a voice reader when the expand trigger is
   * focused
   */
  ariaLabel: PropTypes.string.isRequired,
  children: PropTypes.node,
  className: PropTypes.string,
  /**
   * The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
   */
  expandHeaderId: PropTypes.string,
  /**
   * The description of the chevron right icon, to be put in its SVG `<title>` element.
   */
  expandIconDescription: PropTypes.string,
  /**
   * Specify whether this row is expanded or not. This helps coordinate data
   * attributes so that `TableExpandRow` and `TableExpandedRow` work together
   */
  isExpanded: PropTypes.bool.isRequired,
  /**
   * Specify if the row is selected
   */
  isSelected: PropTypes.bool,
  /**
   * Hook for when a listener initiates a request to expand the given row
   */
  onExpand: PropTypes.func.isRequired,
  /**
   * Unique row id
   */
  rowId: PropTypes.string.isRequired,
  /**
   * direction of document
   */
  langDir: PropTypes.oneOf(['ltr', 'rtl'])
};
var defaultProps = {
  children: [],
  className: '',
  expandHeaderId: 'expand',
  expandIconDescription: 'Click to expand content',
  isSelected: false,
  langDir: 'ltr'
};
var TableExpandRow = function TableExpandRow(_ref) {
  var ariaLabel = _ref.ariaLabel,
    rowClassName = _ref.className,
    children = _ref.children,
    isExpanded = _ref.isExpanded,
    onExpand = _ref.onExpand,
    expandIconDescription = _ref.expandIconDescription,
    isSelected = _ref.isSelected,
    expandHeaderId = _ref.expandHeaderId,
    rowId = _ref.rowId,
    langDir = _ref.langDir,
    rest = _objectWithoutProperties(_ref, _excluded);
  var className = classnames(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefix, "--parent-row"), true), "".concat(prefix, "--expandable-row"), isExpanded), "".concat(prefix, "--data-table--selected"), isSelected), rowClassName);
  var previousValue = isExpanded ? 'collapsed' : undefined;
  return /*#__PURE__*/React__default.createElement("tr", _extends({}, rest, {
    className: className,
    "data-parent-row": true,
    "data-testid": "expand-row-".concat(rowId)
  }), /*#__PURE__*/React__default.createElement(TableCell, {
    className: "".concat(prefix, "--table-expand"),
    "data-previous-value": previousValue,
    headers: expandHeaderId
  }, /*#__PURE__*/React__default.createElement(Button, {
    "aria-label": ariaLabel,
    testId: "expand-icon-button-".concat(rowId),
    className: classnames("".concat(prefix, "--table-expand__button"), "".concat(iotPrefix, "--table-expand__button"), "".concat(iotPrefix, "--tooltip-svg-wrapper"), _defineProperty({}, "".concat(iotPrefix, "--table-expand__button--close"), isExpanded)),
    onClick: onExpand,
    iconDescription: expandIconDescription,
    renderIcon: ChevronRight,
    size: "sm",
    tooltipAlignment: langDir === 'ltr' ? 'start' : 'end',
    tooltipPosition: "top",
    kind: "icon-selection"
  })), children);
};
TableExpandRow.propTypes = propTypes;
TableExpandRow.defaultProps = defaultProps;
TableExpandRow.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "TableExpandRow",
  "props": {
    "children": {
      "defaultValue": {
        "value": "[]",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "node"
      },
      "required": false
    },
    "className": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "expandHeaderId": {
      "defaultValue": {
        "value": "'expand'",
        "computed": false
      },
      "description": "The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "expandIconDescription": {
      "defaultValue": {
        "value": "'Click to expand content'",
        "computed": false
      },
      "description": "The description of the chevron right icon, to be put in its SVG `<title>` element.",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "isSelected": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "Specify if the row is selected",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "langDir": {
      "defaultValue": {
        "value": "'ltr'",
        "computed": false
      },
      "description": "direction of document",
      "type": {
        "name": "enum",
        "value": [{
          "value": "'ltr'",
          "computed": false
        }, {
          "value": "'rtl'",
          "computed": false
        }]
      },
      "required": false
    },
    "ariaLabel": {
      "description": "Specify the string read by a voice reader when the expand trigger is\nfocused",
      "type": {
        "name": "string"
      },
      "required": true
    },
    "isExpanded": {
      "description": "Specify whether this row is expanded or not. This helps coordinate data\nattributes so that `TableExpandRow` and `TableExpandedRow` work together",
      "type": {
        "name": "bool"
      },
      "required": true
    },
    "onExpand": {
      "description": "Hook for when a listener initiates a request to expand the given row",
      "type": {
        "name": "func"
      },
      "required": true
    },
    "rowId": {
      "description": "Unique row id",
      "type": {
        "name": "string"
      },
      "required": true
    }
  }
};
var TableExpandRow$1 = TableExpandRow;

export { TableExpandRow$1 as default };
