From e0a9a5cac6463d197ca56679b705f6b14d72db55 Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Tue, 14 Nov 2023 09:46:39 -0500 Subject: [PATCH] Make DroppableChildrenFn type available --- docs/api/droppable.md | 9 ++++++++- docs/guides/types.md | 5 ++++- src/index.js | 3 ++- src/view/draggable/draggable-types.js | 4 ++-- src/view/droppable/droppable-types.js | 11 ++++++++--- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/api/droppable.md b/docs/api/droppable.md index 6d18137a2e..1fa17897b1 100644 --- a/docs/api/droppable.md +++ b/docs/api/droppable.md @@ -36,7 +36,7 @@ type Props = {| ignoreContainerClipping?: boolean, renderClone?: DraggableChildrenFn, getContainerForClone?: () => HTMLElement, - children: (DroppableProvided, DroppableStateSnapshot) => Node, + children: DroppableChildrenFn, |}; type DroppableMode = 'standard' | 'virtual'; @@ -72,6 +72,13 @@ The `React` children of a `` must be a function that returns a [`Re ``` +```js +type DroppableChildrenFn = ( + DroppableProvided, + DroppableStateSnapshot, +) => Node; +``` + The function is provided with two arguments: ### 1. provided: (DroppableProvided) diff --git a/docs/guides/types.md b/docs/guides/types.md index c6484b3e8a..91dc5cd8f2 100644 --- a/docs/guides/types.md +++ b/docs/guides/types.md @@ -132,6 +132,10 @@ type DroppableStateSnapshot = {| draggingFromThisWith: ?DraggableId, isUsingPlaceholder: boolean, |}; +type DroppableChildrenFn = ( + DroppableProvided, + DroppableStateSnapshot, +) => Node; ``` ### Draggable @@ -164,7 +168,6 @@ type DraggableChildrenFn = ( DraggableStateSnapshot, DraggableRubric, ) => Node | null; -|}; type DraggableStyle = DraggingStyle | NotDraggingStyle; type DraggingStyle = {| position: 'fixed', diff --git a/src/index.js b/src/index.js index 98302ac1a5..0af4a8d6df 100644 --- a/src/index.js +++ b/src/index.js @@ -51,6 +51,7 @@ export type { Provided as DroppableProvided, StateSnapshot as DroppableStateSnapshot, DroppableProps, + DroppableChildrenFn, } from './view/droppable/droppable-types'; // Draggable types @@ -63,5 +64,5 @@ export type { DraggableStyle, DraggingStyle, NotDraggingStyle, - ChildrenFn as DraggableChildrenFn, + DraggableChildrenFn, } from './view/draggable/draggable-types'; diff --git a/src/view/draggable/draggable-types.js b/src/view/draggable/draggable-types.js index e5ebe9a94e..05bf404c19 100644 --- a/src/view/draggable/draggable-types.js +++ b/src/view/draggable/draggable-types.js @@ -152,7 +152,7 @@ export type MapProps = {| // secondary: ?SecondaryMapProps, |}; -export type ChildrenFn = ( +export type DraggableChildrenFn = ( Provided, StateSnapshot, DraggableRubric, @@ -161,7 +161,7 @@ export type ChildrenFn = ( export type PublicOwnProps = {| draggableId: DraggableId, index: number, - children: ChildrenFn, + children: DraggableChildrenFn, // optional own props isDragDisabled?: boolean, diff --git a/src/view/droppable/droppable-types.js b/src/view/droppable/droppable-types.js index 64ecb52dfe..98fbb0c7a6 100644 --- a/src/view/droppable/droppable-types.js +++ b/src/view/droppable/droppable-types.js @@ -11,10 +11,10 @@ import type { DraggableRubric, DroppableMode, } from '../../types'; -import type { ChildrenFn } from '../draggable/draggable-types'; +import type { DraggableChildrenFn } from '../draggable/draggable-types'; import { updateViewportMaxScroll } from '../../state/action-creators'; -export type DraggableChildrenFn = ChildrenFn; +export type DraggableChildrenFn; export type DroppableProps = {| // used for shared global styles @@ -73,9 +73,14 @@ export type DispatchProps = {| updateViewportMaxScroll: typeof updateViewportMaxScroll, |}; +export type DroppableChildrenFn = ( + Provided, + StateSnapshot, +) => Node; + export type OwnProps = {| ...DefaultProps, - children: (Provided, StateSnapshot) => Node, + children: DroppableChildrenFn, droppableId: DroppableId, renderClone: ?DraggableChildrenFn, |};