import { createContext, Dispatch, MutableRefObject, SetStateAction } from 'react' import type { NativeSyntheticEvent, Animated, ScaledSize } from 'react-native' import { noop } from '@mpxjs/utils' export type LabelContextValue = MutableRefObject<{ triggerChange: (evt: NativeSyntheticEvent) => void }> export type KeyboardAvoidContextValue = MutableRefObject<{ cursorSpacing: number ref: MutableRefObject adjustPosition: boolean holdKeyboard?: boolean keyboardHeight?: number /** @internal bindfocus 异步延迟上报方法 */ onKeyboardShow?: () => void /** @internal 多个 Input 切换聚焦场景标记位 */ readyToShow?: boolean } | null> export interface GroupValue { [key: string]: { checked: boolean; setValue: Dispatch> } } export interface GroupContextValue { groupValue: GroupValue notifyChange: (evt: NativeSyntheticEvent) => void } export interface FormFieldValue { getValue: () => any resetValue: ({ newVal, type }: { newVal?: any; type?: string }) => void } export interface FormContextValue { formValuesMap: Map submit: () => void reset: () => void } export interface IntersectionObserver { [key: number]: { throttleMeasure: () => void } } export interface PortalContextValue { mount: (children: React.ReactNode, key?: number | null, id?: number | null) => number | undefined update: (key: number, children: React.ReactNode) => void unmount: (key: number) => void } export interface ScrollViewContextValue { gestureRef: React.RefObject | null scrollOffset: Animated.Value | null } export interface RouteContextValue { pageId: number navigation: Record } export interface DimensionsValue { window: ScaledSize; screen: ScaledSize; } export interface StickyContextValue { registerStickyHeader: Function unregisterStickyHeader: Function } export const MovableAreaContext = createContext({ width: 0, height: 0 }) export const FormContext = createContext(null) export const CheckboxGroupContext = createContext(null) export const RadioGroupContext = createContext(null) export const LabelContext = createContext(null) export const PickerContext = createContext(null) export const VarContext = createContext({}) export const IntersectionObserverContext = createContext(null) export const RouteContext = createContext(null) export const SwiperContext = createContext({}) export const KeyboardAvoidContext = createContext(null) export const ScrollViewContext = createContext({ gestureRef: null, scrollOffset: null }) export const PortalContext = createContext(null as any) export const StickyContext = createContext({ registerStickyHeader: noop, unregisterStickyHeader: noop }) export const ProviderContext = createContext(null)