import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import React__default, { useState } from 'react';
import PropTypes from 'prop-types';
import { Accordion, AccordionItem } from '@carbon/react';

var propTypes = {
  /** Component children's to be rendered */
  children: PropTypes.node.isRequired,
  /** Section title */
  title: PropTypes.string,
  /** Section is open or not */
  isOpen: PropTypes.bool,
  /** Callback for accordion item click */
  onClick: PropTypes.func,
  testId: PropTypes.string
};
var defaultProps = {
  isOpen: true,
  onClick: function onClick() {},
  title: null,
  testId: 'tile-gallery-section'
};
var TileGallerySection = function TileGallerySection(_ref) {
  var children = _ref.children,
    title = _ref.title,
    isOpen = _ref.isOpen,
    onClick = _ref.onClick,
    testId = _ref.testId;
  var _useState = useState(isOpen),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  var galleryItems = /*#__PURE__*/React__default.createElement("div", {
    "data-testid": "".concat(testId, "-items"),
    className: "tile-gallery--section--items"
  }, children);
  return /*#__PURE__*/React__default.createElement("div", {
    "data-testid": testId,
    className: "tile-gallery--section"
  }, title ? /*#__PURE__*/React__default.createElement(Accordion, {
    "data-testid": "".concat(testId, "-accordion")
  }, /*#__PURE__*/React__default.createElement(AccordionItem, {
    title: title,
    onHeadingClick: function onHeadingClick(evt) {
      setOpen(!open);
      onClick(evt);
    },
    open: open,
    "data-testid": "".concat(testId, "-accordion-item")
  }, galleryItems)) : galleryItems);
};
TileGallerySection.propTypes = propTypes;
TileGallerySection.defaultProps = defaultProps;
TileGallerySection.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "TileGallerySection",
  "props": {
    "isOpen": {
      "defaultValue": {
        "value": "true",
        "computed": false
      },
      "description": "Section is open or not",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "onClick": {
      "defaultValue": {
        "value": "() => {}",
        "computed": false
      },
      "description": "Callback for accordion item click",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "title": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "Section title",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "'tile-gallery-section'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "children": {
      "description": "Component children's to be rendered",
      "type": {
        "name": "node"
      },
      "required": true
    }
  }
};
var TileGallerySection$1 = TileGallerySection;

export { TileGallerySection$1 as default };
