"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DefinitionTable = void 0;

var _preact = require("preact");

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

/**
 * @typedef DefinitionTableProps
 * @property {{
 *   [key: string]: () => import('preact').VNode | string
 * }} data
 */

/**
 * DefinitionTable Generates a table of name / value cells, given a data prop
 *
 * @type {import('preact').FunctionComponent}
 * @param {DefinitionTableProps} Props
 */
const DefinitionTable = (_ref) => {
  let {
    data
  } = _ref,
      rest = _objectWithoutProperties(_ref, ["data"]);

  return (0, _preact.h)("table", rest, Object.keys(data).map(key => (0, _preact.h)("tr", {
    key: key
  }, (0, _preact.h)("td", {
    className: "fw6 no-wrap v-top"
  }, key, ":"), (0, _preact.h)("td", {
    className: "v-top"
  }, data[key] == null ? (0, _preact.h)("span", {
    className: "black-40"
  }, "(none)") : data[key]))));
};

exports.DefinitionTable = DefinitionTable;