"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _Label = require("@patternfly/react-core/dist/esm/components/Label");
var _LabelGroup = require("@patternfly/react-core/dist/esm/components/LabelGroup");
var _Tooltip = _interopRequireDefault(require("../../Tooltip"));
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.
 */

class PatternFlyDescriptionList extends _react.default.PureComponent {
  constructor(props) {
    super(props);
    this._onClick = evt => {
      const key = evt.currentTarget.getAttribute('data-term');
      const value = evt.currentTarget.getAttribute('data-description');
      navigator.clipboard.writeText(`${key}=${value}`);
    };
    this.state = {
      className: [this.props.className, 'kui--description-list', 'kui--label-list', 'flex-fill', 'padding-content'].join(' ')
    };
  }
  render() {
    return _react.default.createElement("div", {
      className: this.state.className
    }, _react.default.createElement(_LabelGroup.LabelGroup, {
      className: "kui--description-list-group",
      numLabels: 10
    }, this.props.groups.map((group, idx) => _react.default.createElement(_Tooltip.default, {
      key: idx,
      content: "Click to copy",
      position: "bottom"
    }, _react.default.createElement(_Label.Label, {
      className: "kui--description-list-term",
      "data-term": group.term,
      "data-description": group.description,
      onClick: this._onClick
    }, _react.default.createElement("div", null, _react.default.createElement("span", {
      className: "kui--description-list-label-key"
    }, group.term), _react.default.createElement("span", {
      className: "slightly-deemphasize"
    }, "="), _react.default.createElement("span", {
      className: "map-value"
    }, group.description)))))));
  }
}
exports.default = PatternFlyDescriptionList;