From 65f46887ea56d2e0712fe6010f93ce1fde3dd2e6 Mon Sep 17 00:00:00 2001 From: Giampaolo Bellavite Date: Wed, 18 Oct 2023 06:37:02 -0500 Subject: [PATCH] build(types): align to internal code style (#1949) --- src/contexts/RootProvider.tsx | 7 ++++--- .../SelectMultiple/SelectMultipleContext.tsx | 9 +++++---- src/contexts/SelectRange/SelectRangeContext.tsx | 13 ++++++++----- src/contexts/SelectSingle/SelectSingleContext.tsx | 13 +++++++------ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/contexts/RootProvider.tsx b/src/contexts/RootProvider.tsx index 6c2c35254e..6a216b7574 100644 --- a/src/contexts/RootProvider.tsx +++ b/src/contexts/RootProvider.tsx @@ -1,7 +1,6 @@ -import { PropsWithChildren } from 'react'; +import { ReactNode } from 'react'; import { ModifiersProvider } from 'contexts/Modifiers/ModifiersContext'; -import { DayPickerBase } from 'types/DayPickerBase'; import { DayPickerProvider } from './DayPicker'; import { FocusProvider } from './Focus'; @@ -11,7 +10,9 @@ import { SelectRangeProvider } from './SelectRange'; import { SelectSingleProvider } from './SelectSingle'; /** The props of {@link RootProvider}. */ -export type RootContext = PropsWithChildren; +export interface RootContext { + children?: ReactNode; +} /** Provide the value for all the context providers. */ export function RootProvider(props: RootContext): JSX.Element { diff --git a/src/contexts/SelectMultiple/SelectMultipleContext.tsx b/src/contexts/SelectMultiple/SelectMultipleContext.tsx index 537108369a..8c48757794 100644 --- a/src/contexts/SelectMultiple/SelectMultipleContext.tsx +++ b/src/contexts/SelectMultiple/SelectMultipleContext.tsx @@ -38,7 +38,7 @@ export const SelectMultipleContext = createContext< export type SelectMultipleProviderProps = { initialProps: DayPickerBase; - children: ReactNode; + children?: ReactNode; }; /** Provides the values for the {@link SelectMultipleContext}. */ @@ -66,10 +66,11 @@ export function SelectMultipleProvider( ); } -type SelectMultipleProviderInternalProps = { +/** @private */ +export interface SelectMultipleProviderInternalProps { initialProps: DayPickerMultipleProps; - children: ReactNode; -}; + children?: ReactNode; +} export function SelectMultipleProviderInternal({ initialProps, diff --git a/src/contexts/SelectRange/SelectRangeContext.tsx b/src/contexts/SelectRange/SelectRangeContext.tsx index a9d3d79960..cb171fb1e1 100644 --- a/src/contexts/SelectRange/SelectRangeContext.tsx +++ b/src/contexts/SelectRange/SelectRangeContext.tsx @@ -1,4 +1,4 @@ -import { createContext, PropsWithChildren, useContext } from 'react'; +import { createContext, ReactNode, useContext } from 'react'; import { addDays, @@ -44,9 +44,10 @@ export const SelectRangeContext = createContext< SelectRangeContextValue | undefined >(undefined); -type SelectRangeProviderProps = PropsWithChildren<{ +export interface SelectRangeProviderProps { initialProps: DayPickerBase; -}>; + children?: ReactNode; +} /** Provides the values for the {@link SelectRangeProvider}. */ export function SelectRangeProvider( @@ -76,9 +77,11 @@ export function SelectRangeProvider( ); } -type SelectRangeProviderInternalProps = PropsWithChildren<{ +/** @private */ +export interface SelectRangeProviderInternalProps { initialProps: DayPickerRangeProps; -}>; + children?: ReactNode; +} export function SelectRangeProviderInternal({ initialProps, diff --git a/src/contexts/SelectSingle/SelectSingleContext.tsx b/src/contexts/SelectSingle/SelectSingleContext.tsx index e81cb8c1e1..d4b4f0d4db 100644 --- a/src/contexts/SelectSingle/SelectSingleContext.tsx +++ b/src/contexts/SelectSingle/SelectSingleContext.tsx @@ -22,10 +22,10 @@ export const SelectSingleContext = createContext< SelectSingleContextValue | undefined >(undefined); -type SelectSingleProviderProps = { +export interface SelectSingleProviderProps { initialProps: DayPickerBase; - children: ReactNode; -}; + children?: ReactNode; +} /** Provides the values for the {@link SelectSingleProvider}. */ export function SelectSingleProvider( @@ -49,10 +49,11 @@ export function SelectSingleProvider( ); } -type SelectSingleProviderInternal = { +/** @private */ +export interface SelectSingleProviderInternal { initialProps: DayPickerSingleProps; - children: ReactNode; -}; + children?: ReactNode; +} export function SelectSingleProviderInternal({ initialProps,