@atlaskit/datetime-picker
Version:
A date time picker allows the user to select an associated date and time.
35 lines (34 loc) • 1.54 kB
TypeScript
import { type ComponentType, type FC, type PropsWithoutRef, type PropsWithRef, type RefAttributes } from 'react';
/**
* Gets all available ref types from two prop sets and returns
* them in a ref prop
*
* @example
* ```
* type P1 = { ref: Ref(HTMLDivElement), ... };
* type P2 = { ref: Ref(HTMLSpanElement), ... };
*
* GetRefAttributes(P1, P2) // {ref: Ref(HTMLDivElement | HTMLSpanElement)}
* ```
*/
type GetRefAttributes<A, B> = A extends RefAttributes<infer RefA> ? B extends RefAttributes<infer RefB> ? RefAttributes<RefA | RefB> : RefAttributes<RefA> : B extends RefAttributes<infer OnlyRefB> ? RefAttributes<OnlyRefB> : unknown;
/**
* Returns one of components depending on a boolean condition.
* The result component will be a union of the two props and
* an or on both ref types.
*
* @example
* ```
* const Component = componentWithCondition(
* isBooleanConditionMet,
* ComponentWithConditionMet,
* ComponentWithConditionNotMet,
* );
*
* @param condition Function returning boolean value
* @param componentTrue Component that will be returned if conditionGetter is "true"
* @param componentFalse Component that will be returned if conditionGetter is "false"
* @returns Component Depending on a Condition result
*/
export declare function componentWithCondition<A extends {}, B extends {}>(condition: () => boolean, ComponentTrue: ComponentType<A>, ComponentFalse: ComponentType<B>): FC<PropsWithoutRef<A> & PropsWithoutRef<B> & GetRefAttributes<PropsWithRef<A>, PropsWithRef<B>>>;
export {};