🏷️(react) export more types

Based on recent developers feedbacks that needed to use props types
in order to wrap the lib's component they were stuck because we were
not exporting all of them.

Fixes #143
This commit is contained in:
Nathan Vasse
2023-08-29 16:21:19 +02:00
committed by NathanVss
parent b6e5a876d3
commit 66c25bcdbd
6 changed files with 27 additions and 12 deletions

View File

@@ -0,0 +1,5 @@
---
"@openfun/cunningham-react": patch
---
export more types

View File

@@ -9,13 +9,13 @@ import React, {
import classNames from "classnames";
import { Field, FieldProps } from ":/components/Forms/Field";
type Props = InputHTMLAttributes<HTMLInputElement> &
export type CheckboxProps = InputHTMLAttributes<HTMLInputElement> &
FieldProps & {
indeterminate?: boolean;
label?: string;
};
export const Checkbox = forwardRef<HTMLInputElement, Props>(
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
(
{
indeterminate,
@@ -26,7 +26,7 @@ export const Checkbox = forwardRef<HTMLInputElement, Props>(
rightText,
state,
...props
}: Props,
}: CheckboxProps,
ref,
) => {
const inputRef = useRef<HTMLInputElement>();

View File

@@ -11,7 +11,7 @@ import { randomString } from ":/utils";
import { Field, FieldProps } from ":/components/Forms/Field";
import { LabelledBox } from ":/components/Forms/LabelledBox";
type Props = InputHTMLAttributes<HTMLInputElement> &
export type InputProps = InputHTMLAttributes<HTMLInputElement> &
FieldProps & {
label?: string;
icon?: ReactNode;
@@ -20,7 +20,7 @@ type Props = InputHTMLAttributes<HTMLInputElement> &
charCounterMax?: number;
};
export const Input = forwardRef<HTMLInputElement, Props>(
export const Input = forwardRef<HTMLInputElement, InputProps>(
(
{
className,
@@ -36,7 +36,7 @@ export const Input = forwardRef<HTMLInputElement, Props>(
charCounter,
charCounterMax,
...props
}: Props,
}: InputProps,
ref,
) => {
const classes = ["c__input"];

View File

@@ -6,13 +6,13 @@ import React, {
import classNames from "classnames";
import { Field, FieldProps } from ":/components/Forms/Field";
type Props = InputHTMLAttributes<HTMLInputElement> &
export type RadioProps = InputHTMLAttributes<HTMLInputElement> &
FieldProps & {
label?: string;
};
export const Radio = forwardRef<HTMLInputElement, Props>(
({ label, text, state, ...props }: Props, ref) => {
export const Radio = forwardRef<HTMLInputElement, RadioProps>(
({ label, text, state, ...props }: RadioProps, ref) => {
return (
<label
className={classNames("c__checkbox", "c__radio", {

View File

@@ -2,6 +2,9 @@ import React from "react";
import { SelectMulti } from ":/components/Forms/Select/multi";
import { SelectMono, SelectProps } from ":/components/Forms/Select/mono";
export * from ":/components/Forms/Select/mono";
export * from ":/components/Forms/Select/multi";
export const Select = (props: SelectProps) => {
if (props.defaultValue && props.value) {
throw new Error(

View File

@@ -2,15 +2,22 @@ import React, { InputHTMLAttributes, forwardRef } from "react";
import classNames from "classnames";
import { Field, FieldProps } from ":/components/Forms/Field";
type Props = InputHTMLAttributes<HTMLInputElement> &
export type SwitchProps = InputHTMLAttributes<HTMLInputElement> &
FieldProps & {
label?: string;
labelSide?: "left" | "right";
};
export const Switch = forwardRef<HTMLInputElement, Props>(
export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
(
{ label, text, state, fullWidth, labelSide = "left", ...props }: Props,
{
label,
text,
state,
fullWidth,
labelSide = "left",
...props
}: SwitchProps,
ref,
) => {
return (