🏷️(react) support ReactNode as input label

There are use cases that required to put links inside Checkboxes or
Radio inputs.
This commit is contained in:
Nathan Vasse
2023-11-24 15:50:10 +01:00
committed by NathanVss
parent 6b6c0ea942
commit e3882eb308
3 changed files with 9 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@openfun/cunningham-react": patch
---
support ReactNode as input label

View File

@@ -5,13 +5,14 @@ import React, {
useEffect, useEffect,
useRef, useRef,
useState, useState,
ReactNode,
} from "react"; } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { Field, FieldProps } from ":/components/Forms/Field"; import { Field, FieldProps } from ":/components/Forms/Field";
export type CheckboxOnlyProps = { export type CheckboxOnlyProps = {
indeterminate?: boolean; indeterminate?: boolean;
label?: string; label?: ReactNode;
}; };
export type CheckboxProps = InputHTMLAttributes<HTMLInputElement> & export type CheckboxProps = InputHTMLAttributes<HTMLInputElement> &

View File

@@ -2,12 +2,13 @@ import React, {
InputHTMLAttributes, InputHTMLAttributes,
PropsWithChildren, PropsWithChildren,
forwardRef, forwardRef,
ReactNode,
} from "react"; } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { Field, FieldProps } from ":/components/Forms/Field"; import { Field, FieldProps } from ":/components/Forms/Field";
export type RadioOnlyProps = { export type RadioOnlyProps = {
label?: string; label?: ReactNode;
}; };
export type RadioProps = InputHTMLAttributes<HTMLInputElement> & export type RadioProps = InputHTMLAttributes<HTMLInputElement> &