import React, { forwardRef } from "react"; import { BodyLong, ErrorMessage } from "../../typography"; import { useId } from "../../utils-external"; import { cl } from "../../utils/helpers"; import { Checkbox, CheckboxProps } from "../checkbox"; import { useFormField } from "../useFormField"; export interface ConfirmationPanelProps extends Omit< CheckboxProps, "children" | "indeterminate" | "hideLabel" | "error" | "readOnly" > { /** * Additional information on panel */ children?: React.ReactNode; /** * Checkbox label */ label: React.ReactNode; /** * Error message for element */ error?: React.ReactNode; /** * Override internal errorId */ errorId?: string; } /** * A component that displays a confirmation checkbox with a label. * @deprecated Use `Checkbox` instead. See [new pattern documentation](https://aksel.nav.no/monster-maler/soknadsdialog/introside-for-soknadsdialoger#8346a8cb849b) for more information. * * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/confirmationpanel) * @see 🏷️ {@link ConfirmationPanelProps} * * @example * ```jsx setState((x) => !x)} > For å komme videre må du gi oss lov til å hente inn og bruke opplysninger om deg. * ``` */ export const ConfirmationPanel = forwardRef< HTMLInputElement, ConfirmationPanelProps >(({ className, children, label, ...props }, ref) => { const { errorId, showErrorMsg, hasError, size, inputProps } = useFormField( props, "confirmation-panel", ); const id = useId(); const currentColor = hasError ? "danger" : props.checked ? "success" : "warning"; return (
{children && ( {children} )} {label}
); }); export default ConfirmationPanel;