UNPKG

@flopflip/react-broadcast

Version:

A feature toggle wrapper to use LaunchDarkly with React

73 lines (58 loc) 3.55 kB
import { TFlagName, TFlagVariation, TAdapter, TConfigureAdapterChildren, TFlags, TConfigureAdapterProps, TAdapterIdentifiers, TReconfigureAdapter, TAdaptersStatus } from '@flopflip/types'; import React from 'react'; import { TToggleFeatureProps } from '@flopflip/react'; export { ReconfigureAdapter as ReconfigureFlopFlip, useAdapterReconfiguration } from '@flopflip/react'; type TBranchOnFeatureToggleOptions = { flag: TFlagName; variation?: TFlagVariation; }; declare function branchOnFeatureToggle<OwnProps extends Record<string, unknown>>({ flag: flagName, variation: flagVariation }: TBranchOnFeatureToggleOptions, UntoggledComponent?: React.ComponentType): (ToggledComponent: React.ComponentType<OwnProps>) => (ownProps: OwnProps) => React.JSX.Element | null; type BaseProps = { readonly children?: TConfigureAdapterChildren; readonly shouldDeferAdapterConfiguration?: boolean; readonly defaultFlags?: TFlags; }; type TProps$2<AdapterInstance extends TAdapter> = BaseProps & TConfigureAdapterProps<AdapterInstance>; declare function Configure<AdapterInstance extends TAdapter>({ children, shouldDeferAdapterConfiguration, defaultFlags, adapter, adapterArgs, }: TProps$2<AdapterInstance>): React.JSX.Element; declare namespace Configure { var displayName: string; } type InjectedProps$1 = Record<string, TFlagVariation>; declare function injectFeatureToggle<OwnProps extends Record<string, unknown>>(flagName: TFlagName, propKey?: string): (Component: React.ComponentType<any>) => React.ComponentType<OwnProps & InjectedProps$1>; type InjectedProps = Record<string, TFlags>; declare function injectFeatureToggles<OwnProps extends Record<string, unknown>>(flagNames: TFlagName[], propKey?: string): (Component: React.ComponentType) => React.ComponentType<OwnProps & InjectedProps>; type TProps$1 = { readonly children: React.ReactNode; readonly flags: TFlags; readonly adapterIdentifiers?: TAdapterIdentifiers[]; readonly reconfigure?: TReconfigureAdapter; readonly status?: TAdaptersStatus; }; declare function TestProvider({ adapterIdentifiers, reconfigure, flags, children, status, }: TProps$1): React.JSX.Element; declare namespace TestProvider { var displayName: string; } type TProps = { flag: TFlagName; variation?: TFlagVariation; } & Omit<TToggleFeatureProps, 'isFeatureEnabled'>; declare function ToggleFeature<OwnProps extends TProps>({ flag, variation, ...remainingProps }: OwnProps): React.JSX.Element; declare namespace ToggleFeature { var displayName: string; } type TUseAdapterStatusArgs = { adapterIdentifiers?: TAdapterIdentifiers[]; }; declare function useAdapterStatus({ adapterIdentifiers }?: TUseAdapterStatusArgs): { isReady: boolean; isUnconfigured: boolean; isConfiguring: boolean; isConfigured: boolean; }; declare function useAllFeatureToggles(): TFlags; declare function useFeatureToggle(flagName: TFlagName, flagVariation?: TFlagVariation): boolean; declare function useFeatureToggles(flags: TFlags): boolean[]; declare function useFlagVariation(flagName?: TFlagName): TFlagVariation; declare function useFlagVariations(flagNames: Array<TFlagName | undefined>): TFlagVariation[]; declare const version = "__@FLOPFLIP/VERSION_OF_RELEASE__"; export { Configure as ConfigureFlopFlip, TestProvider as TestProviderFlopFlip, ToggleFeature, branchOnFeatureToggle, injectFeatureToggle, injectFeatureToggles, useAdapterStatus, useAllFeatureToggles, useFeatureToggle, useFeatureToggles, useFlagVariation, useFlagVariations, version };