"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = PatternFlyDescriptionList;
var _react = _interopRequireDefault(require("react"));
var _DescriptionList = require("@patternfly/react-core/dist/esm/components/DescriptionList");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*
 * Copyright 2021 The Kubernetes Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

function columnModifier(maxWidth) {
  if (maxWidth > 40) {
    return {
      default: '1Col',
      lg: '2Col',
      xl: '2Col'
    };
  } else {
    return {
      default: '1Col',
      lg: '2Col',
      xl: '3Col'
    };
  }
}
function PatternFlyDescriptionList(props) {
  const maxWidth = props.groups.reduce((max, group) => Math.max(max, group.term.length, group.description.toString().length), 0);
  return _react.default.createElement(_DescriptionList.DescriptionList, {
    isAutoColumnWidths: true,
    className: [props.className, 'kui--description-list', 'flex-fill'].join(' '),
    columnModifier: columnModifier(maxWidth)
  }, props.groups.map((group, idx) => _react.default.createElement(_DescriptionList.DescriptionListGroup, {
    key: idx,
    className: "kui--description-list-group"
  }, _react.default.createElement(_DescriptionList.DescriptionListTerm, {
    className: "kui--description-list-term",
    "data-term": group.term
  }, group.term), _react.default.createElement(_DescriptionList.DescriptionListDescription, {
    className: "kui--description-list-description"
  }, group.description))));
}