@meonode/ui
Version:
A structured approach to component composition, direct CSS-first prop styling, built-in theming, smart prop handling (including raw property pass-through), and dynamic children.
140 lines • 6.33 kB
TypeScript
/**
* Custom React Type Checker (TypeScript Version)
* Provides utilities for identifying and checking React component/element types.
* Inspired by react-is package but implemented in TypeScript with type safety.
*/
import React from 'react';
/**
* Symbol identifiers for React internal component types
* These are used to identify different kinds of React elements and components
*/
export declare const REACT_ELEMENT_TYPE: unique symbol;
export declare const REACT_PORTAL_TYPE: unique symbol;
export declare const REACT_FRAGMENT_TYPE: unique symbol;
export declare const REACT_STRICT_MODE_TYPE: unique symbol;
export declare const REACT_PROFILER_TYPE: unique symbol;
export declare const REACT_PROVIDER_TYPE: unique symbol;
export declare const REACT_CONSUMER_TYPE: unique symbol;
export declare const REACT_CONTEXT_TYPE: unique symbol;
export declare const REACT_FORWARD_REF_TYPE: unique symbol;
export declare const REACT_SUSPENSE_TYPE: unique symbol;
export declare const REACT_SUSPENSE_LIST_TYPE: unique symbol;
export declare const REACT_MEMO_TYPE: unique symbol;
export declare const REACT_LAZY_TYPE: unique symbol;
export declare const REACT_VIEW_TRANSITION_TYPE: unique symbol;
export declare const REACT_CLIENT_REFERENCE: unique symbol;
export declare const REACT_ACTIVITY_TYPE: unique symbol;
/**
* Union type of all possible React internal type symbols.
* Used to strongly type return values from type checking functions.
*/
export type ReactTypeSymbols = typeof REACT_ELEMENT_TYPE | typeof REACT_PORTAL_TYPE | typeof REACT_FRAGMENT_TYPE | typeof REACT_STRICT_MODE_TYPE | typeof REACT_PROFILER_TYPE | typeof REACT_PROVIDER_TYPE | typeof REACT_CONSUMER_TYPE | typeof REACT_CONTEXT_TYPE | typeof REACT_FORWARD_REF_TYPE | typeof REACT_SUSPENSE_TYPE | typeof REACT_SUSPENSE_LIST_TYPE | typeof REACT_MEMO_TYPE | typeof REACT_LAZY_TYPE | typeof REACT_VIEW_TRANSITION_TYPE | typeof REACT_CLIENT_REFERENCE | typeof REACT_ACTIVITY_TYPE;
/**
* Interface describing the minimal shape of a React element-like object.
* Used for type checking without coupling to React's internal element type.
*/
export interface ReactElementLike {
$$typeof?: symbol;
type?: any;
[key: string]: any;
}
/**
* Determines the internal React type of an object.
* Examines the object's $$typeof property and nested type properties
* to identify what kind of React element or component it represents.
* @param {unknown} object The object to check
* @returns {boolean} - The matching React type symbol or undefined if not a React object
*/
export declare function typeOf(object: unknown): ReactTypeSymbols | undefined;
/**
* Checks if an object is a React Context Consumer
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a Context.Consumer
*/
export declare const isContextConsumer: (object: unknown) => boolean;
/**
* Checks if an object is a React Context Provider
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a Context.Provider
*/
export declare const isContextProvider: (object: unknown) => boolean;
/**
* Checks if an object is a valid React element
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a React element
*/
export declare const isElement: (object: unknown) => boolean;
/**
* Checks if an object is a React forwardRef component
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a forwardRef component
*/
export declare const isForwardRef: (object: unknown) => boolean;
/**
* Checks if an object is a React Fragment
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a Fragment
*/
export declare const isFragment: (object: unknown) => boolean;
/**
* Checks if an object is a React lazy component
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a lazy component
*/
export declare const isLazy: (object: unknown) => boolean;
/**
* Checks if an object is a React memo component
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a memo component
*/
export declare const isMemo: (object: unknown) => boolean;
/**
* Checks if an object is a React portal
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a portal
*/
export declare const isPortal: (object: unknown) => boolean;
/**
* Checks if an object is a React Profiler
* @param {unknown} object Object to check
* @returns {boolean} - True if object is a Profiler
*/
export declare const isProfiler: (object: unknown) => boolean;
/**
* Checks if an object is a React StrictMode component
* @param {unknown} object Object to check
* @returns {boolean} - True if object is StrictMode
*/
export declare const isStrictMode: (object: unknown) => boolean;
/**
* Checks if an object is a React Suspense component
* @param {unknown} object Object to check
* @returns {boolean} - True if object is Suspense
*/
export declare const isSuspense: (object: unknown) => boolean;
/**
* Checks if an object is a React SuspenseList component
* @param {unknown} object Object to check
* @returns {boolean} - True if `object` is SuspenseList
*/
export declare const isSuspenseList: (object: unknown) => boolean;
/**
* Checks if a type is a valid React element type that can be rendered.
* This includes strings (for DOM elements), functions (for components),
* and various React-specific types like Fragment, Context, etc.
*
* Acts as a type guard so callers can narrow an `unknown`/`any` candidate to
* `ElementType` without casting (e.g. resolving the polymorphic `as` target).
* @param {unknown} type The type to validate
* @returns {boolean} - True if the type can be rendered as a React element
*/
export declare const isValidElementType: (type: unknown) => type is React.ElementType;
/**
* Type guard that checks if a component is a React class component.
* Examines the component's prototype for the isReactComponent marker property
* that React adds to all class components.
* @param {unknown} component Component to check
* @returns {boolean} - True if component is a React class component
*/
export declare const isReactClassComponent: (component: unknown) => component is React.ComponentType;
//# sourceMappingURL=react-is.helper.d.ts.map