UNPKG

@handsontable/react

Version:

Best Data Grid for React with Spreadsheet Look and Feel.

261 lines (260 loc) • 8.5 kB
import React from 'react'; import Handsontable from 'handsontable/base'; import { RenderersPortalManager } from './renderersPortalManager'; import { HotTableProps, HotEditorElement, HotEditorCache, EditorScopeIdentifier } from './types'; /** * A Handsontable-ReactJS wrapper. * * To implement, use the `HotTable` tag with properties corresponding to Handsontable options. * For example: * * ```js * <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" /> * * // is analogous to * let hot = new Handsontable(document.getElementById('hot'), { * data: dataObject, * contextMenu: true, * colHeaders: true, * width: 600 * height: 300 * }); * * ``` * * @class HotTableCB */ declare class HotTableClass extends React.Component<HotTableProps, {}> { /** * The `id` of the main Handsontable DOM element. * * @type {String} */ id: string; /** * Reference to the Handsontable instance. * * @private * @type {Object} */ __hotInstance: Handsontable | null; /** * Reference to the main Handsontable DOM element. * * @type {HTMLElement} */ hotElementRef: HTMLElement; /** * Class name added to the component DOM element. * * @type {String} */ className: string; /** * Style object passed to the component. * * @type {React.CSSProperties} */ style: React.CSSProperties; /** * Array of object containing the column settings. * * @type {Array} */ columnSettings: Handsontable.ColumnSettings[]; /** * Component used to manage the renderer portals. * * @type {React.Component} */ renderersPortalManager: RenderersPortalManager; /** * Map that stores React portals. * @type {Map<string, React.ReactPortal>} */ portalCache: Map<string, React.ReactPortal>; /** * Portal Container Cache * * @private * @type {Map} */ private portalContainerCache; /** * The rendered cells cache. * * @private * @type {Map} */ private renderedCellCache; /** * Editor cache. * * @private * @type {Map} */ private editorCache; /** * Map with column indexes (or a string = 'global') as keys, and booleans as values. Each key represents a component-based editor * declared for the used column index, or a global one, if the key is the `global` string. * * @private * @type {Map} */ private componentRendererColumns; /** * Package version getter. * * @returns The version number of the package. */ static get version(): string; /** * Getter for the property storing the Handsontable instance. */ get hotInstance(): Handsontable | null; /** * Returns `true` if the `hotInstance` exists, but was destroyed. * * @private * @returns {boolean} */ _isHotInstanceDestroyed(): boolean; /** * Setter for the property storing the Handsontable instance. * @param {Handsontable} hotInstance The Handsontable instance. */ set hotInstance(hotInstance: Handsontable | null); /** * Prop types to be checked at runtime. */ static propTypes: object; /** * Get Portal Container Cache * * @returns {Map} */ getPortalContainerCache(): Map<string, HTMLElement>; /** * Get the rendered table cell cache. * * @returns {Map} */ getRenderedCellCache(): Map<string, HTMLTableCellElement>; /** * Get the editor cache and return it. * * @returns {Map} */ getEditorCache(): HotEditorCache; /** * Clear both the editor and the renderer cache. */ clearCache(): void; /** * Get the `Document` object corresponding to the main component element. * * @returns The `Document` object used by the component. */ getOwnerDocument(): Document | null; /** * Set the reference to the main Handsontable DOM element. * * @param {HTMLElement} element The main Handsontable DOM element. */ private setHotElementRef; /** * Return a renderer wrapper function for the provided renderer component. * * @param {React.ReactElement} rendererElement React renderer component. * @returns {Handsontable.renderers.Base} The Handsontable rendering function. */ getRendererWrapper(rendererElement: React.ReactElement): typeof Handsontable.renderers.BaseRenderer; /** * Create a fresh class to be used as an editor, based on the provided editor React element. * * @param {React.ReactElement} editorElement React editor component. * @param {string|number} [editorColumnScope] The editor scope (column index or a 'global' string). Defaults to * 'global'. * @returns {Function} A class to be passed to the Handsontable editor settings. */ getEditorClass(editorElement: HotEditorElement, editorColumnScope?: EditorScopeIdentifier): typeof Handsontable.editors.BaseEditor; /** * Create a class to be passed to the Handsontable's settings. * * @param {React.ReactElement} editorComponent React editor component. * @returns {Function} A class to be passed to the Handsontable editor settings. */ makeEditorClass(editorComponent: React.Component): typeof Handsontable.editors.BaseEditor; /** * Get the renderer element for the entire HotTable instance. * * @returns {React.ReactElement} React renderer component element. */ getGlobalRendererElement(): React.ReactElement; /** * Get the editor element for the entire HotTable instance. * * @param {React.ReactNode} [children] Children of the HotTable instance. Defaults to `this.props.children`. * @returns {React.ReactElement} React editor component element. */ getGlobalEditorElement(): HotEditorElement | null; /** * Create a new settings object containing the column settings and global editors and renderers. * * @param {boolean} [init=false] `true` if called on Handsontable initialization. * @param {HotTableProps} [prevProps] The previous properties object. * @returns {Handsontable.GridSettings} New global set of settings for Handsontable. */ createNewGlobalSettings(init?: boolean, prevProps?: HotTableProps): Handsontable.GridSettings; /** * Detect if `autoRowSize` or `autoColumnSize` is defined, and if so, throw an incompatibility warning. * * @param {Handsontable.GridSettings} newGlobalSettings New global settings passed as Handsontable config. */ displayAutoSizeWarning(newGlobalSettings: Handsontable.GridSettings): void; /** * Sets the column settings based on information received from HotColumn. * * @param {HotTableProps} columnSettings Column settings object. * @param {Number} columnIndex Column index. */ setHotColumnSettings(columnSettings: Handsontable.ColumnSettings, columnIndex: number): void; /** * Handsontable's `beforeViewRender` hook callback. */ handsontableBeforeViewRender(): void; /** * Handsontable's `afterViewRender` hook callback. */ handsontableAfterViewRender(): void; /** * Call the `updateSettings` method for the Handsontable instance. * * @param {Object} newSettings The settings object. */ private updateHot; /** * Set the renderers portal manager ref. * * @param {React.ReactComponent} pmComponent The PortalManager component. */ private setRenderersPortalManagerRef; /** * Initialize Handsontable after the component has mounted. */ componentDidMount(): void; /** * Logic performed after the component update. */ componentDidUpdate(prevProps: any): void; /** * Destroy the Handsontable instance when the parent component unmounts. */ componentWillUnmount(): void; /** * Render the component. */ render(): React.ReactElement; } export default HotTableClass; export { HotTableClass };