From 66c25bcdbde35acec9624a3ad895e5a12a808e57 Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Tue, 29 Aug 2023 16:21:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F(react)=20export=20more=20?= =?UTF-8?q?types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .changeset/yellow-rules-repeat.md | 5 +++++ .../react/src/components/Forms/Checkbox/index.tsx | 6 +++--- packages/react/src/components/Forms/Input/index.tsx | 6 +++--- packages/react/src/components/Forms/Radio/index.tsx | 6 +++--- .../react/src/components/Forms/Select/index.tsx | 3 +++ .../react/src/components/Forms/Switch/index.tsx | 13 ++++++++++--- 6 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 .changeset/yellow-rules-repeat.md diff --git a/.changeset/yellow-rules-repeat.md b/.changeset/yellow-rules-repeat.md new file mode 100644 index 0000000..e30b218 --- /dev/null +++ b/.changeset/yellow-rules-repeat.md @@ -0,0 +1,5 @@ +--- +"@openfun/cunningham-react": patch +--- + +export more types diff --git a/packages/react/src/components/Forms/Checkbox/index.tsx b/packages/react/src/components/Forms/Checkbox/index.tsx index b4edaa7..dafa649 100644 --- a/packages/react/src/components/Forms/Checkbox/index.tsx +++ b/packages/react/src/components/Forms/Checkbox/index.tsx @@ -9,13 +9,13 @@ import React, { import classNames from "classnames"; import { Field, FieldProps } from ":/components/Forms/Field"; -type Props = InputHTMLAttributes & +export type CheckboxProps = InputHTMLAttributes & FieldProps & { indeterminate?: boolean; label?: string; }; -export const Checkbox = forwardRef( +export const Checkbox = forwardRef( ( { indeterminate, @@ -26,7 +26,7 @@ export const Checkbox = forwardRef( rightText, state, ...props - }: Props, + }: CheckboxProps, ref, ) => { const inputRef = useRef(); diff --git a/packages/react/src/components/Forms/Input/index.tsx b/packages/react/src/components/Forms/Input/index.tsx index a1a6afe..d02c857 100644 --- a/packages/react/src/components/Forms/Input/index.tsx +++ b/packages/react/src/components/Forms/Input/index.tsx @@ -11,7 +11,7 @@ import { randomString } from ":/utils"; import { Field, FieldProps } from ":/components/Forms/Field"; import { LabelledBox } from ":/components/Forms/LabelledBox"; -type Props = InputHTMLAttributes & +export type InputProps = InputHTMLAttributes & FieldProps & { label?: string; icon?: ReactNode; @@ -20,7 +20,7 @@ type Props = InputHTMLAttributes & charCounterMax?: number; }; -export const Input = forwardRef( +export const Input = forwardRef( ( { className, @@ -36,7 +36,7 @@ export const Input = forwardRef( charCounter, charCounterMax, ...props - }: Props, + }: InputProps, ref, ) => { const classes = ["c__input"]; diff --git a/packages/react/src/components/Forms/Radio/index.tsx b/packages/react/src/components/Forms/Radio/index.tsx index 384de34..b58754f 100644 --- a/packages/react/src/components/Forms/Radio/index.tsx +++ b/packages/react/src/components/Forms/Radio/index.tsx @@ -6,13 +6,13 @@ import React, { import classNames from "classnames"; import { Field, FieldProps } from ":/components/Forms/Field"; -type Props = InputHTMLAttributes & +export type RadioProps = InputHTMLAttributes & FieldProps & { label?: string; }; -export const Radio = forwardRef( - ({ label, text, state, ...props }: Props, ref) => { +export const Radio = forwardRef( + ({ label, text, state, ...props }: RadioProps, ref) => { return (