UNPKG

@dolthub/react-contexts

Version:

A collection of React contexts for common tasks

46 lines (40 loc) 1.66 kB
import React, { SyntheticEvent, Context, ReactNode } from 'react'; type CommentFormContextType = { getFormPositionOnPage: () => void; commentFormRef: React.RefObject<HTMLDivElement>; commentFormIsVisible: boolean; inputRef: React.RefObject<HTMLTextAreaElement>; loading: boolean; comment: string; setComment: (c: string) => void; onSubmit: (e: SyntheticEvent) => Promise<void>; error?: Error; }; declare const CommentFormContext: React.Context<CommentFormContextType>; type Props$2 = { children: React.ReactNode; containerId: string; commentId: string; createComment: (comment: string) => Promise<boolean>; loading: boolean; error?: Error; }; declare function CommentFormProvider(props: Props$2): JSX.Element; declare function useCommentFormContext(): CommentFormContextType; declare function createCustomContext<T>(displayName: string): Context<T>; declare function createContextWithDisplayName<T>(defaultValue: T, displayName: string): Context<T>; type FeatureMap = Map<string, boolean>; type Props$1 = { children: ReactNode; showAll?: boolean; featureMap: FeatureMap; }; declare function FeatureProvider({ children, showAll, featureMap, }: Props$1): React.JSX.Element; type Props = { name: string; children: JSX.Element; notFound?: JSX.Element; show?: boolean; }; declare function FeatureGate({ name, children, notFound, show, }: Props): JSX.Element | null; export { CommentFormContext, type CommentFormContextType, CommentFormProvider, FeatureGate, FeatureProvider as FeatureGateProvider, createContextWithDisplayName, createCustomContext, useCommentFormContext };