export type Props = { [key: string]: any };
export type NumberPropFactory = (props: Props) => number;
export type BooleanPropFactory = (props: Props) => boolean;
export type StaggerDirectionPropFactory = (props: Props) => 1 | -1;
export type TransitionFactory = (props: Props) => TD | A | false;
export type ApplyResolve = (props: Props) => string | number;
export type ApplyMap = {
[key: string]: ApplyResolve | string | number;
};
export type TransitionMap = {
[key: string]: TD | A | false | TransitionFactory;
};
export type TransitionMapFactory = (
props: Props
) => TransitionMap;
export type Pose = {
transition?: TransitionMap | TransitionMapFactory;
delay?: number | NumberPropFactory;
delayChildren?: number | NumberPropFactory;
staggerChildren?: number | NumberPropFactory;
staggerDirection?: 1 | -1 | StaggerDirectionPropFactory;
beforeChildren?: boolean | BooleanPropFactory;
afterChildren?: boolean | BooleanPropFactory;
preTransform?: () => any;
preTransition?: (props: Props) => any;
applyAtStart?: ApplyMap;
applyAtEnd?: ApplyMap;
[key: string]: any;
};
export type ValueMap = Map;
export type AncestorValue = {
label?: string;
values: ValueMap;
};
export type AncestorValueList = Array>;
export type Transformer = (v: any) => any;
export type PassiveValueMap = {
[key: string]: [string, any, boolean | string | void];
};
export type OnChangeCallbacks = {
[key: string]: (v: any) => any;
};
export type ActiveActions = Map;
export type ActivePoses = Map;
export type ChildPosers = Set>;
export type PoseMap = {
[key: string]: Pose;
};
export type PoserFactory = (
config: PoserConfig
) => Poser;
export interface Poser {
set: (next: string, props?: Props) => Promise;
unset: (toUnset: string, props?: Props) => Promise;
get: (key?: string) => any;
has: (key: string) => boolean;
setProps: (props: Props) => void;
destroy: () => void;
_addChild: (
config: PoserConfig,
factory: PoserFactory
) => Poser;
removeChild: (child: Poser) => void;
clearChildren: () => void;
}
export type PoserState = {
activeActions: ActiveActions;
activePoses: ActivePoses;
children: ChildPosers;
values: ValueMap;
props: Props;
};
export type PoserConfig = {
[key: string]: any;
label?: string;
props?: Props;
values?: { [key: string]: V };
parentValues?: ValueMap;
ancestorValues?: AncestorValueList;
onChange?: OnChangeCallbacks;
passive?: PassiveValueMap;
initialPose?: string | string[];
};
export type ReadValue = (value: V) => any;
export type ResolveTarget = (value: V, target: any) => any;
export type CreateValueProps = any;
export type CreateValue = (
init: any,
key: string,
props: Props,
createValueProps?: CreateValueProps
) => V;
export type ConvertValue = (value: any, key: string, props: Props) => V;
export type StartAction = (
value: V,
action: A,
complete: () => any
) => C;
export type StopAction = (controls: C) => any;
export type GetInstantTransition = (value: V, props: Props) => A;
export type AddTransitionDelay = (delay: number, transition: A) => A;
export type ExtendAPI = (
api: Poser,
state: PoserState,
config: PoserConfig
) => Poser;
export type GetTransitionProps = (
value: V,
target: number,
props: Props
) => Props;
export type SelectValueToRead = (value: V) => any;
export type TransformPose = (
pose: Pose,
key: string,
state: PoserState
) => Pose;
export type ReadValueFromSource = (key: string, props: Props) => any;
export type SetValue = (v: V, value: any) => void;
export type SetValueNative = (key: string, value: any, props: Props) => void;
export type ConvertTransitionDefinition = (
value: V,
transitionDef: TD | A,
props: Props
) => A;
export type PoseFactoryConfig = {
getDefaultProps?: (config: PoserConfig) => Props;
defaultTransitions?: Map>;
bindOnChange: (
values: ValueMap,
onChange: OnChangeCallbacks
) => (key: string) => any;
readValue: ReadValue;
readValueFromSource?: ReadValueFromSource;
setValue: SetValue;
setValueNative: SetValueNative;
createValue: CreateValue;
convertValue: ConvertValue;
resolveTarget: ResolveTarget;
getTransitionProps: GetTransitionProps;
convertTransitionDefinition: ConvertTransitionDefinition;
startAction: StartAction;
stopAction: StopAction;
getInstantTransition: GetInstantTransition;
addActionDelay: AddTransitionDelay;
selectValueToRead: SelectValueToRead;
extendAPI: ExtendAPI;
transformPose?: TransformPose;
posePriority?: string[];
forceRender?: (props: Props) => any;
};