"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataTableSubRowToggle = DataTableSubRowToggle;
const react_1 = __importDefault(require("react"));
const aksel_icons_1 = require("@navikt/aksel-icons");
const button_1 = require("../../../button");
const DataTableRoot_context_1 = require("../root/DataTableRoot.context");
function DataTableSubRowToggle({ details }) {
    const { tableItems } = (0, DataTableRoot_context_1.useDataTableContext)();
    const subRows = details.children;
    const hasSubRows = subRows && subRows.length > 0;
    const isRowExpanded = tableItems.isSubRowExpanded(details.id);
    return (react_1.default.createElement("div", { className: "aksel-data-table__nested-toggle" }, hasSubRows && (react_1.default.createElement(button_1.Button, { variant: "tertiary", "data-color": "neutral", size: "small", onClick: (e) => {
            e.stopPropagation();
            tableItems.onExpandedRowIdsChange(details.id);
        }, "aria-expanded": isRowExpanded, "aria-label": isRowExpanded ? "Skjul under-rader" : "Vis under-rader", icon: isRowExpanded ? (react_1.default.createElement(aksel_icons_1.ChevronDownIcon, { "aria-hidden": true })) : (react_1.default.createElement(aksel_icons_1.ChevronRightIcon, { "aria-hidden": true })) }))));
}
//# sourceMappingURL=DataTableSubRowToggle.js.map