import React, { ComponentType, CSSProperties, DependencyList, EffectCallback, ReactNode, ReactPortal } from 'react'; import Handsontable from 'handsontable/base'; import { HotRendererProps, HotTableProps } from './types'; /** * Warning message for the `autoRowSize`/`autoColumnSize` compatibility check. */ export declare const AUTOSIZE_WARNING: string; /** * Warning message for the `hot-renderer` obsolete renderer passing method. */ export declare const OBSOLETE_HOTRENDERER_WARNING: string; /** * Warning message for the `hot-editor` obsolete editor passing method. */ export declare const OBSOLETE_HOTEDITOR_WARNING: string; /** * Warning message for the unexpected children of HotTable component. */ export declare const UNEXPECTED_HOTTABLE_CHILDREN_WARNING: string; /** * Warning message for the unexpected children of HotColumn component. */ export declare const UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING: string; /** * Warning when a Handsontable function renderer is passed to the React `renderer` prop. * * That prop is a React component. A classic function renderer belongs on `hotRenderer`. */ export declare const CLASSIC_FUNCTION_RENDERER_WARNING: string; /** * Warning when a Handsontable editor (an editor class or a registered editor name) is passed to the * React `editor` prop. * * That prop is a React component. A Handsontable editor belongs on `hotEditor`. */ export declare const NATIVE_EDITOR_IN_EDITOR_PROP_WARNING: string; /** * Message for the warning thrown if the Handsontable instance has been destroyed. */ export declare const HOT_DESTROYED_WARNING: string; /** * Default classname given to the wrapper container. */ export declare const DEFAULT_CLASSNAME = "hot-wrapper-editor-container"; /** * Classname for the stable host that holds React editor portals. * Distinct from `DEFAULT_CLASSNAME` so page CSS and `querySelector` do not hit both nodes. */ export declare const EDITOR_PORTAL_HOST_CLASSNAME = "hot-wrapper-editor-portal-host"; /** * Warning when the editor portal host cannot be moved into `rootPortalElement`. */ export declare const MISSING_ROOT_PORTAL_WARNING: string; /** * Logs warn to the console if the `console` object is exposed. * * @param {...*} args Values which will be logged. */ export declare function warn(...args: any[]): void; /** * Warn when `renderer` holds a Handsontable function renderer. * * A React component is called with one props object, so its `length` stays below 3. * A classic renderer declares `(instance, td, row, col, prop, value, cellProperties)`, * so its `length` is at least 3. The prop is still rendered as a component. Picking * the call style from `length` would change behavior, because a component with default * parameters reports `length` 0. * * @param {ComponentType} renderer Component passed through the `renderer` prop. */ export declare function warnAboutClassicFunctionRenderer(renderer: ComponentType): void; /** * Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning. * * @param {ReactNode} children Component children nodes. * @returns {boolean} 'true' if the warning was issued */ export declare function displayObsoleteRenderersEditorsWarning(children: ReactNode): boolean; /** * Detect if children of specified type are defined, and if so, throw an incompatibility warning. * * @param {ReactNode} children Component children nodes * @param {ComponentType} Component Component type to check * @returns {boolean} 'true' if the warning was issued */ export declare function displayChildrenOfTypeWarning(children: ReactNode, Component: ComponentType): boolean; /** * Detect if children is defined, and if so, throw an incompatibility warning. * * @param {ReactNode} children Component children nodes * @returns {boolean} 'true' if the warning was issued */ export declare function displayAnyChildrenWarning(children: ReactNode): boolean; /** * Check whether the `editor` prop holds a component editor, as opposed to a boolean flag or a * Handsontable editor passed there by mistake. * * Both editor props accept a boolean, so a truthy check alone is not enough to tell a component * apart from a bare `editor={true}`. An editor class or editor name is not a component either (see * `isNativeEditor()`). * * @param {HotTableProps['editor']} editor The `editor` prop. * @returns {boolean} `true` when the prop carries a React component to render. */ export declare function isComponentEditor(editor: HotTableProps['editor']): boolean; /** * Check whether a value is a Handsontable editor: a registered editor name or an editor class. * * A class is recognized by the `BaseEditor` methods on its prototype rather than with `instanceof`, * so a class built on another copy of Handsontable is still recognized. A React class component * carries `prototype.isReactComponent`, and a function component does not have these methods, so * neither one matches. * * @param {*} editor The value to check. * @returns {boolean} `true` when the value is a Handsontable editor. */ export declare function isNativeEditor(editor: unknown): boolean; /** * Resolve the Handsontable `editor` setting from the two editor props. * * `editor` carries the component editor and `hotEditor` the Handsontable-native one, but both accept * a boolean: * * - `false` disables editing. * - `true` names no editor, so it is treated as if the prop were not provided. It must never reach * the core, which accepts only a string or a constructor and throws on anything else. * - Any other nullish or falsy value (`null`, `0`, `''`) is also treated as "not provided", so a * column written as `editor={cond ? MyEditor : null}` inherits instead of locking. * * `hotEditor` is resolved before a falsy `editor`, so an editor named there still wins over a bare * `editor={false}` — the behavior in every released version, where `editor={false}` fell through to * the `hotEditor` value. A component `editor` outranks both: it is picked by `isComponentEditor()` * before this function is reached, so `editor={MyComponent} hotEditor={false}` keeps the component. * * A Handsontable editor (a class or a registered name) passed to `editor` is a mistake: that prop * renders a React component. It is used as if it were passed to `hotEditor`, with a one-time * warning. A `hotEditor` value that names an editor or disables editing still wins over it. A name * that no editor is registered under is dropped after the warning, so a typo does not make the core * throw. * * @param {HotTableProps['editor']} editor The `editor` prop. * @param {HotTableProps['hotEditor']} hotEditor The `hotEditor` prop. * @returns {*} The editor setting, or `undefined` when neither prop names one. */ export declare function resolveEditorSetting(editor: HotTableProps['editor'], hotEditor: HotTableProps['hotEditor']): Handsontable.GridSettings['editor'] | undefined; /** * Create an editor portal. * * @param {Document} doc Document to be used. * @param {ComponentType} Editor Editor component or render function. * @param {HTMLElement} portalHost Host element to portal into. Required – do not fall back to `doc.body`. * @returns {ReactPortal} The portal for the editor. */ export declare function createEditorPortal(doc: Document | null, Editor: HotTableProps['editor'] | undefined | boolean, portalHost?: HTMLElement | null): ReactPortal | null; /** * Render a cell component to an external DOM node. * * @param {React.ReactElement} rElement React element to be used as a base for the component. * @param {Document} [ownerDocument] The owner document to set the portal up into. * @param {string} portalKey The key to be used for the portal. * @param {HTMLElement} [cachedContainer] The cached container to be used for the portal. * @returns {{portal: ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its * container. */ export declare function createPortal(rElement: React.ReactElement, ownerDocument: Document | null | undefined, portalKey: string, cachedContainer?: HTMLElement): { portal: ReactPortal; portalContainer: HTMLElement; }; /** * Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the * component. * * @param {HotTableProps} props Object containing the React element props. * @param {boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was * present in the `prop` object. * @returns {{id?: string, className: string, style: CSSProperties}} An object containing the `id`, `className` * and `style` keys, representing the corresponding props passed to the component. */ export declare function getContainerAttributesProps(props: HotTableProps, randomizeId?: boolean): { id?: string; className: string; style: CSSProperties; }; /** * Checks if the environment that the code runs in is a browser. * * @returns {boolean} `true` when running in a browser environment. */ export declare function isCSR(): boolean; /** * Deep-compare plain objects and arrays used by wrapper settings. Functions, class instances and any * other value are compared by reference, and a `RegExp` by its source and flags. A pair of objects * already being compared higher up reads as equal, so a value with a cycle (tree rows with a `parent` * link) ends instead of overflowing the stack. * * @param {unknown} previousValue Previous value. * @param {unknown} currentValue Current value. * @param {WeakMap>} [visited] The object pairs on the current comparison path. * @returns {boolean} `true` if values are equivalent. */ export declare function areEquivalentSettingsValue(previousValue: unknown, currentValue: unknown, visited?: WeakMap>): boolean; /** * Copies the plain objects and arrays of a settings value, keeping every other value (functions, class * instances) by reference. The copy is what an update compares the next value with, so a value the app * changes in place reads as changed. A value with a cycle is copied with the same cycle. * * @param {unknown} value The value to copy. * @param {WeakMap} [copies] The copies made so far, by original. * @returns {unknown} The copy. */ export declare function copySettingsValue(value: unknown, copies?: WeakMap): unknown; /** * A variant of useEffect hook that does not trigger on initial mount, only updates * * @param {EffectCallback} effect Effect function * @param {DependencyList} [deps] Effect dependencies */ export declare function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void; /** * Returns the element a cell's content belongs in: the grid's clipping wrapper when the cell holds * exactly that wrapper, and the cell itself otherwise. * * @param {HTMLElement} TD The table cell. * @returns {Element} */ export declare function getCellContentRoot(TD: HTMLElement): Element;