@handsontable/react-wrapper 0.0.0-next-7cc7ef7-20241028
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.txt +25 -0
- package/README.md +136 -0
- package/commonjs/react-handsontable.js +2139 -0
- package/commonjs/src/helpers.d.ts +105 -0
- package/commonjs/src/hotColumn.d.ts +5 -0
- package/commonjs/src/hotColumnContext.d.ts +16 -0
- package/commonjs/src/hotEditor.d.ts +33 -0
- package/commonjs/src/hotTable.d.ts +29 -0
- package/commonjs/src/hotTableContext.d.ts +55 -0
- package/commonjs/src/hotTableInner.d.ts +5 -0
- package/commonjs/src/index.d.ts +5 -0
- package/commonjs/src/renderersPortalManager.d.ts +6 -0
- package/commonjs/src/settingsMapper.d.ts +18 -0
- package/commonjs/src/types.d.ts +78 -0
- package/dist/react-handsontable.js +1133 -0
- package/dist/react-handsontable.js.map +1 -0
- package/dist/react-handsontable.min.js +31 -0
- package/dist/react-handsontable.min.js.map +1 -0
- package/dist/src/helpers.d.ts +105 -0
- package/dist/src/hotColumn.d.ts +5 -0
- package/dist/src/hotColumnContext.d.ts +16 -0
- package/dist/src/hotEditor.d.ts +33 -0
- package/dist/src/hotTable.d.ts +29 -0
- package/dist/src/hotTableContext.d.ts +55 -0
- package/dist/src/hotTableInner.d.ts +5 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/renderersPortalManager.d.ts +6 -0
- package/dist/src/settingsMapper.d.ts +18 -0
- package/dist/src/types.d.ts +78 -0
- package/es/react-handsontable.mjs +2125 -0
- package/handsontable-non-commercial-license.pdf +0 -0
- package/helpers.d.ts +105 -0
- package/hotColumn.d.ts +5 -0
- package/hotColumnContext.d.ts +16 -0
- package/hotEditor.d.ts +33 -0
- package/hotTable.d.ts +29 -0
- package/hotTableContext.d.ts +55 -0
- package/hotTableInner.d.ts +5 -0
- package/index.d.ts +5 -0
- package/package.json +130 -0
- package/renderersPortalManager.d.ts +6 -0
- package/settingsMapper.d.ts +18 -0
- package/types.d.ts +78 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
import React, { ComponentType, CSSProperties, DependencyList, EffectCallback, ReactNode, ReactPortal } from 'react';
|
2
|
+
import { HotTableProps } from './types';
|
3
|
+
/**
|
4
|
+
* Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
|
5
|
+
*/
|
6
|
+
export declare const AUTOSIZE_WARNING: string;
|
7
|
+
/**
|
8
|
+
* Warning message for the `hot-renderer` obsolete renderer passing method.
|
9
|
+
*/
|
10
|
+
export declare const OBSOLETE_HOTRENDERER_WARNING: string;
|
11
|
+
/**
|
12
|
+
* Warning message for the `hot-editor` obsolete editor passing method.
|
13
|
+
*/
|
14
|
+
export declare const OBSOLETE_HOTEDITOR_WARNING: string;
|
15
|
+
/**
|
16
|
+
* Warning message for the unexpected children of HotTable component.
|
17
|
+
*/
|
18
|
+
export declare const UNEXPECTED_HOTTABLE_CHILDREN_WARNING: string;
|
19
|
+
/**
|
20
|
+
* Warning message for the unexpected children of HotColumn component.
|
21
|
+
*/
|
22
|
+
export declare const UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING: string;
|
23
|
+
/**
|
24
|
+
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
25
|
+
*/
|
26
|
+
export declare const HOT_DESTROYED_WARNING: string;
|
27
|
+
/**
|
28
|
+
* Default classname given to the wrapper container.
|
29
|
+
*/
|
30
|
+
export declare const DEFAULT_CLASSNAME = "hot-wrapper-editor-container";
|
31
|
+
/**
|
32
|
+
* Logs warn to the console if the `console` object is exposed.
|
33
|
+
*
|
34
|
+
* @param {...*} args Values which will be logged.
|
35
|
+
*/
|
36
|
+
export declare function warn(...args: any[]): void;
|
37
|
+
/**
|
38
|
+
* Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning.
|
39
|
+
*
|
40
|
+
* @returns {boolean} 'true' if the warning was issued
|
41
|
+
*/
|
42
|
+
export declare function displayObsoleteRenderersEditorsWarning(children: ReactNode): boolean;
|
43
|
+
/**
|
44
|
+
* Detect if children of specified type are defined, and if so, throw an incompatibility warning.
|
45
|
+
*
|
46
|
+
* @param {ReactNode} children Component children nodes
|
47
|
+
* @param {ComponentType} Component Component type to check
|
48
|
+
* @returns {boolean} 'true' if the warning was issued
|
49
|
+
*/
|
50
|
+
export declare function displayChildrenOfTypeWarning(children: ReactNode, Component: ComponentType): boolean;
|
51
|
+
/**
|
52
|
+
* Detect if children is defined, and if so, throw an incompatibility warning.
|
53
|
+
*
|
54
|
+
* @param {ReactNode} children Component children nodes
|
55
|
+
* @returns {boolean} 'true' if the warning was issued
|
56
|
+
*/
|
57
|
+
export declare function displayAnyChildrenWarning(children: ReactNode): boolean;
|
58
|
+
/**
|
59
|
+
* Create an editor portal.
|
60
|
+
*
|
61
|
+
* @param {Document} doc Document to be used.
|
62
|
+
* @param {ComponentType} Editor Editor component or render function.
|
63
|
+
* @returns {ReactPortal} The portal for the editor.
|
64
|
+
*/
|
65
|
+
export declare function createEditorPortal(doc: Document | null, Editor: HotTableProps['editor'] | undefined): ReactPortal | null;
|
66
|
+
/**
|
67
|
+
* Render a cell component to an external DOM node.
|
68
|
+
*
|
69
|
+
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
70
|
+
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
71
|
+
* @param {String} portalKey The key to be used for the portal.
|
72
|
+
* @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
|
73
|
+
* @returns {{portal: ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
74
|
+
*/
|
75
|
+
export declare function createPortal(rElement: React.ReactElement, ownerDocument: Document | null | undefined, portalKey: string, cachedContainer?: HTMLElement): {
|
76
|
+
portal: ReactPortal;
|
77
|
+
portalContainer: HTMLElement;
|
78
|
+
};
|
79
|
+
/**
|
80
|
+
* Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
81
|
+
* component.
|
82
|
+
*
|
83
|
+
* @param {HotTableProps} props Object containing the React element props.
|
84
|
+
* @param {Boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was present in the `prop` object.
|
85
|
+
* @returns An object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
86
|
+
* component.
|
87
|
+
*/
|
88
|
+
export declare function getContainerAttributesProps(props: HotTableProps, randomizeId?: boolean): {
|
89
|
+
id?: string;
|
90
|
+
className: string;
|
91
|
+
style: CSSProperties;
|
92
|
+
};
|
93
|
+
/**
|
94
|
+
* Checks if the environment that the code runs in is a browser.
|
95
|
+
*
|
96
|
+
* @returns {boolean}
|
97
|
+
*/
|
98
|
+
export declare function isCSR(): boolean;
|
99
|
+
/**
|
100
|
+
* A variant of useEffect hook that does not trigger on initial mount, only updates
|
101
|
+
*
|
102
|
+
* @param effect Effect function
|
103
|
+
* @param deps Effect dependencies
|
104
|
+
*/
|
105
|
+
export declare function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import React, { FC } from 'react';
|
2
|
+
import { HotColumnProps } from './types';
|
3
|
+
declare const isHotColumn: (childNode: any) => childNode is React.ReactElement<any, string | ((props: any, deprecatedLegacyContext?: any) => React.ReactElement<any, any> | null) | (new (props: any, deprecatedLegacyContext?: any) => React.Component<any, any, any>)>;
|
4
|
+
declare const HotColumn: FC<HotColumnProps>;
|
5
|
+
export { HotColumn, isHotColumn };
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
2
|
+
export interface HotColumnContextImpl {
|
3
|
+
/**
|
4
|
+
* Column index within a HotTable.
|
5
|
+
*/
|
6
|
+
readonly columnIndex: number;
|
7
|
+
/**
|
8
|
+
* Get the `Document` object corresponding to the main component element.
|
9
|
+
*
|
10
|
+
* @returns The `Document` object used by the component.
|
11
|
+
*/
|
12
|
+
readonly getOwnerDocument: () => Document | null;
|
13
|
+
}
|
14
|
+
declare const HotColumnContextProvider: FC<PropsWithChildren<HotColumnContextImpl>>;
|
15
|
+
declare const useHotColumnContext: () => HotColumnContextImpl;
|
16
|
+
export { useHotColumnContext, HotColumnContextProvider };
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { DependencyList, FC, MutableRefObject, ReactNode, Ref, RefObject } from 'react';
|
2
|
+
import Handsontable from 'handsontable/base';
|
3
|
+
import { HotEditorHooks, UseHotEditorImpl } from './types';
|
4
|
+
/**
|
5
|
+
* Create a class to be passed to the Handsontable's settings.
|
6
|
+
*
|
7
|
+
* @param {RefObject<HotEditorHooks>} hooksRef Reference to component-based editor overridden hooks object.
|
8
|
+
* @param {RefObject} instanceRef Reference to Handsontable-native custom editor class instance.
|
9
|
+
* @returns {Function} A class to be passed to the Handsontable editor settings.
|
10
|
+
*/
|
11
|
+
export declare function makeEditorClass(hooksRef: MutableRefObject<HotEditorHooks | null>, instanceRef: MutableRefObject<Handsontable.editors.BaseEditor | null>): typeof Handsontable.editors.BaseEditor;
|
12
|
+
interface EditorContextProviderProps {
|
13
|
+
hooksRef: Ref<HotEditorHooks>;
|
14
|
+
hotCustomEditorInstanceRef: RefObject<Handsontable.editors.BaseEditor>;
|
15
|
+
children: ReactNode;
|
16
|
+
}
|
17
|
+
/**
|
18
|
+
* Provider of the context that exposes Handsontable-native editor instance and passes hooks object
|
19
|
+
* for custom editor components.
|
20
|
+
*
|
21
|
+
* @param {Ref} hooksRef Reference for component-based editor overridden hooks object.
|
22
|
+
* @param {RefObject} hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
|
23
|
+
*/
|
24
|
+
export declare const EditorContextProvider: FC<EditorContextProviderProps>;
|
25
|
+
/**
|
26
|
+
* Hook that allows encapsulating custom behaviours of component-based editor by customizing passed ref with overridden hooks object.
|
27
|
+
*
|
28
|
+
* @param {HotEditorHooks} overriddenHooks Overrides specific for the custom editor.
|
29
|
+
* @param {DependencyList} deps Overridden hooks object React dependency list.
|
30
|
+
* @returns {UseHotEditorImpl} Editor API methods
|
31
|
+
*/
|
32
|
+
export declare function useHotEditor<T>(overriddenHooks?: HotEditorHooks, deps?: DependencyList): UseHotEditorImpl<T>;
|
33
|
+
export {};
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
2
|
+
import { HotTableProps, HotTableRef } from './types';
|
3
|
+
interface Version {
|
4
|
+
version?: string;
|
5
|
+
}
|
6
|
+
declare type HotTable = ForwardRefExoticComponent<HotTableProps & RefAttributes<HotTableRef>> & Version;
|
7
|
+
/**
|
8
|
+
* A Handsontable-ReactJS wrapper.
|
9
|
+
*
|
10
|
+
* To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
|
11
|
+
* For example:
|
12
|
+
*
|
13
|
+
* ```js
|
14
|
+
* <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
|
15
|
+
*
|
16
|
+
* // is analogous to
|
17
|
+
* let hot = new Handsontable(document.getElementById('hot'), {
|
18
|
+
* data: dataObject,
|
19
|
+
* contextMenu: true,
|
20
|
+
* colHeaders: true,
|
21
|
+
* width: 600
|
22
|
+
* height: 300
|
23
|
+
* });
|
24
|
+
*
|
25
|
+
* ```
|
26
|
+
*/
|
27
|
+
declare const HotTable: HotTable;
|
28
|
+
export default HotTable;
|
29
|
+
export { HotTable };
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import Handsontable from 'handsontable/base';
|
2
|
+
import { ComponentType, FC, PropsWithChildren } from 'react';
|
3
|
+
import { ScopeIdentifier, HotRendererProps } from './types';
|
4
|
+
import { RenderersPortalManagerRef } from './renderersPortalManager';
|
5
|
+
export interface HotTableContextImpl {
|
6
|
+
/**
|
7
|
+
* Map with column indexes (or a string = 'global') as keys, and booleans as values. Each key represents a component-based editor
|
8
|
+
* declared for the used column index, or a global one, if the key is the `global` string.
|
9
|
+
*/
|
10
|
+
readonly componentRendererColumns: Map<ScopeIdentifier, boolean>;
|
11
|
+
/**
|
12
|
+
* Array of object containing the column settings.
|
13
|
+
*/
|
14
|
+
readonly columnsSettings: Handsontable.ColumnSettings[];
|
15
|
+
/**
|
16
|
+
* Sets the column settings based on information received from HotColumn.
|
17
|
+
*
|
18
|
+
* @param {HotTableProps} columnSettings Column settings object.
|
19
|
+
* @param {Number} columnIndex Column index.
|
20
|
+
*/
|
21
|
+
readonly emitColumnSettings: (columnSettings: Handsontable.ColumnSettings, columnIndex: number) => void;
|
22
|
+
/**
|
23
|
+
* Return a renderer wrapper function for the provided renderer component.
|
24
|
+
*
|
25
|
+
* @param {ComponentType<HotRendererProps>} Renderer React renderer component.
|
26
|
+
* @returns {Handsontable.renderers.BaseRenderer} The Handsontable rendering function.
|
27
|
+
*/
|
28
|
+
readonly getRendererWrapper: (Renderer: ComponentType<HotRendererProps>) => typeof Handsontable.renderers.BaseRenderer;
|
29
|
+
/**
|
30
|
+
* Clears portals cache.
|
31
|
+
*/
|
32
|
+
readonly clearPortalCache: () => void;
|
33
|
+
/**
|
34
|
+
* Clears rendered cells cache.
|
35
|
+
*/
|
36
|
+
readonly clearRenderedCellCache: () => void;
|
37
|
+
/**
|
38
|
+
* Set the renderers portal manager dispatch function.
|
39
|
+
*
|
40
|
+
* @param {RenderersPortalManagerRef} pm The PortalManager dispatch function.
|
41
|
+
*/
|
42
|
+
readonly setRenderersPortalManagerRef: (pm: RenderersPortalManagerRef) => void;
|
43
|
+
/**
|
44
|
+
* Puts cell portals into portal manager and purges portals cache.
|
45
|
+
*/
|
46
|
+
readonly pushCellPortalsIntoPortalManager: () => void;
|
47
|
+
}
|
48
|
+
declare const HotTableContextProvider: FC<PropsWithChildren>;
|
49
|
+
/**
|
50
|
+
* Exposes the table context object to components
|
51
|
+
*
|
52
|
+
* @returns HotTableContext
|
53
|
+
*/
|
54
|
+
declare function useHotTableContext(): HotTableContextImpl;
|
55
|
+
export { HotTableContextProvider, useHotTableContext };
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import React, { Dispatch, ReactPortal } from 'react';
|
2
|
+
export declare type RenderersPortalManagerRef = Dispatch<ReactPortal[]>;
|
3
|
+
/**
|
4
|
+
* Component used to manage the renderer component portals.
|
5
|
+
*/
|
6
|
+
export declare const RenderersPortalManager: React.ForwardRefExoticComponent<React.RefAttributes<React.Dispatch<React.ReactPortal[]>>>;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import Handsontable from 'handsontable/base';
|
2
|
+
import { HotTableProps } from './types';
|
3
|
+
export declare class SettingsMapper {
|
4
|
+
/**
|
5
|
+
* Parse component settings into Handsontable-compatible settings.
|
6
|
+
*
|
7
|
+
* @param {Object} properties Object containing properties from the HotTable object.
|
8
|
+
* @param {Object} additionalSettings Additional settings.
|
9
|
+
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
10
|
+
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
11
|
+
* @returns {Object} Handsontable-compatible settings object.
|
12
|
+
*/
|
13
|
+
static getSettings(properties: HotTableProps, { prevProps, isInit, initOnlySettingKeys }?: {
|
14
|
+
prevProps?: HotTableProps;
|
15
|
+
isInit?: boolean;
|
16
|
+
initOnlySettingKeys?: Array<keyof Handsontable.GridSettings>;
|
17
|
+
}): Handsontable.GridSettings;
|
18
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import Handsontable from 'handsontable/base';
|
2
|
+
import { ComponentType, CSSProperties, Dispatch, DispatchWithoutAction, ReactNode } from 'react';
|
3
|
+
/**
|
4
|
+
* Type of the identifier under which the cached components are stored.
|
5
|
+
*/
|
6
|
+
export declare type ScopeIdentifier = 'global' | number;
|
7
|
+
/**
|
8
|
+
* Interface for the props of the component-based renderers.
|
9
|
+
*/
|
10
|
+
export interface HotRendererProps {
|
11
|
+
instance: Handsontable.Core;
|
12
|
+
TD: HTMLTableCellElement;
|
13
|
+
row: number;
|
14
|
+
col: number;
|
15
|
+
prop: string | number;
|
16
|
+
value: any;
|
17
|
+
cellProperties: Handsontable.CellProperties;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Interface for component-based editor overridden hooks object.
|
21
|
+
*/
|
22
|
+
export interface HotEditorHooks {
|
23
|
+
onOpen?: () => void;
|
24
|
+
onClose?: () => void;
|
25
|
+
onPrepare?: (row: number, column: number, prop: string | number, TD: HTMLTableCellElement, originalValue: any, cellProperties: Handsontable.CellProperties) => void;
|
26
|
+
onFocus?: () => void;
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Interface for custom component-based editor API exposed by useHotEditor
|
30
|
+
*/
|
31
|
+
export interface UseHotEditorImpl<T> {
|
32
|
+
value?: T;
|
33
|
+
setValue: Dispatch<T>;
|
34
|
+
isOpen: boolean;
|
35
|
+
finishEditing: DispatchWithoutAction;
|
36
|
+
row?: number;
|
37
|
+
col?: number;
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* Helper type to expose GridSettings/ColumnSettings props with native renderers/editors separately
|
41
|
+
* from component-based render prop.
|
42
|
+
*/
|
43
|
+
declare type ReplaceRenderersEditors<T extends Pick<Handsontable.GridSettings, 'renderer' | 'editor'>> = Omit<T, 'renderer' | 'editor'> & {
|
44
|
+
hotRenderer?: T['renderer'];
|
45
|
+
renderer?: ComponentType<HotRendererProps>;
|
46
|
+
hotEditor?: T['editor'];
|
47
|
+
editor?: ComponentType;
|
48
|
+
};
|
49
|
+
/**
|
50
|
+
* Interface for the `prop` of the HotTable component - extending the default Handsontable settings with additional,
|
51
|
+
* component-related properties.
|
52
|
+
*/
|
53
|
+
export interface HotTableProps extends ReplaceRenderersEditors<Handsontable.GridSettings> {
|
54
|
+
id?: string;
|
55
|
+
className?: string;
|
56
|
+
style?: CSSProperties;
|
57
|
+
children?: ReactNode;
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* Properties related to the HotColumn architecture.
|
61
|
+
*/
|
62
|
+
export interface HotColumnProps extends ReplaceRenderersEditors<Handsontable.ColumnSettings> {
|
63
|
+
children?: ReactNode;
|
64
|
+
}
|
65
|
+
/**
|
66
|
+
* Type of interface exposed to parent components by HotTable instance via React ref
|
67
|
+
*/
|
68
|
+
export interface HotTableRef {
|
69
|
+
/**
|
70
|
+
* Reference to the main Handsontable DOM element.
|
71
|
+
*/
|
72
|
+
hotElementRef: HTMLElement;
|
73
|
+
/**
|
74
|
+
* Reference to the Handsontable instance.
|
75
|
+
*/
|
76
|
+
hotInstance: Handsontable | null;
|
77
|
+
}
|
78
|
+
export {};
|