var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React, { forwardRef } from "react";
import { cl } from "../utils/helpers/index.js";
import { useControllableState } from "../utils/hooks/index.js";
import ExpansionCardContent from "./ExpansionCardContent.js";
import { ExpansionCardDescription, } from "./ExpansionCardDescription.js";
import ExpansionCardHeader from "./ExpansionCardHeader.js";
import { ExpansionCardTitle, } from "./ExpansionCardTitle.js";
import { ExpansionCardContext } from "./context.js";
/**
 * A component that displays an expandable card.
 *
 * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/expansioncard)
 * @see 🏷️ {@link ExpansionCardProps}
 *
 * @example
 * ```jsx
 * <ExpansionCard aria-label="Utbetaling av sykepenger">
 *   <ExpansionCard.Header>
 *     <ExpansionCard.Title>Utbetaling av sykepenger</ExpansionCard.Title>
 *   </ExpansionCard.Header>
 *   <ExpansionCard.Content>
 *     <Innhold />
 *   </ExpansionCard.Content>
 * </ExpansionCard>
 * ```
 */
export const ExpansionCard = forwardRef((_a, ref) => {
    var { className, onToggle, open, defaultOpen = false, size = "medium", "data-color": color = "neutral" } = _a, rest = __rest(_a, ["className", "onToggle", "open", "defaultOpen", "size", "data-color"]);
    const [_open, _setOpen] = useControllableState({
        value: open,
        onChange: onToggle,
        defaultValue: defaultOpen,
    });
    return (React.createElement(ExpansionCardContext.Provider, { value: {
            open: open !== null && open !== void 0 ? open : _open,
            toggleOpen: () => _setOpen((x) => !x),
            size,
        } },
        React.createElement("section", Object.assign({ "data-color": color }, rest, { className: cl("aksel-expansioncard", className, `aksel-expansioncard--${size}`), ref: ref }))));
});
ExpansionCard.Header = ExpansionCardHeader;
ExpansionCard.Content = ExpansionCardContent;
ExpansionCard.Title = ExpansionCardTitle;
ExpansionCard.Description = ExpansionCardDescription;
export default ExpansionCard;
//# sourceMappingURL=ExpansionCard.js.map