"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DetailItem = exports.DetailList = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const react_core_1 = require("@patternfly/react-core");
require("./DetailList.css");
const RenderIf_1 = require("./RenderIf");
const DetailList = ({ children, title, titleComponent = 'h2', }) => (react_1.default.createElement(react_core_1.Content, null,
    title && react_1.default.createElement(react_core_1.Content, { component: titleComponent }, title),
    react_1.default.createElement(react_core_1.Content, { component: react_core_1.ContentVariants.dl, className: "detail-list" }, children)));
exports.DetailList = DetailList;
const hasDetailItemList = (data) => {
    return Array.isArray(data);
};
const DetailItem = ({ title, value = '', idPrefix, testId, isHidden = false, classNameValue, }) => isHidden ? null : (react_1.default.createElement(react_1.default.Fragment, null,
    react_1.default.createElement(RenderIf_1.RenderIf, { condition: title !== undefined },
        react_1.default.createElement(react_core_1.Content, { component: react_core_1.ContentVariants.dt, id: idPrefix ? `${idPrefix}-title` : undefined, "data-testid": testId ? `${testId}-title` : undefined }, title)),
    react_1.default.createElement(react_core_1.Content, { component: react_core_1.ContentVariants.dd, id: idPrefix ? `${idPrefix}-value` : undefined, "data-testid": testId ? `${testId}-value` : undefined, className: classNameValue }, hasDetailItemList(value) ? (react_1.default.createElement(react_core_1.Content, { component: react_core_1.ContentVariants.dl }, value.map((item, idx) => [
        react_1.default.createElement(react_core_1.Content, { "data-testid": testId ? `${testId}-title-${idx}` : undefined, key: item.title, component: react_core_1.ContentVariants.dt }, item.title),
        react_1.default.createElement(react_core_1.Content, { "data-testid": testId ? `${testId}-value-${idx}` : undefined, key: `dd-${item.title}`, component: react_core_1.ContentVariants.dd }, item.value),
    ]))) : (value))));
exports.DetailItem = DetailItem;
//# sourceMappingURL=DetailList.js.map