@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.
Files changed (43) hide show
  1. package/LICENSE.txt +25 -0
  2. package/README.md +136 -0
  3. package/commonjs/react-handsontable.js +2139 -0
  4. package/commonjs/src/helpers.d.ts +105 -0
  5. package/commonjs/src/hotColumn.d.ts +5 -0
  6. package/commonjs/src/hotColumnContext.d.ts +16 -0
  7. package/commonjs/src/hotEditor.d.ts +33 -0
  8. package/commonjs/src/hotTable.d.ts +29 -0
  9. package/commonjs/src/hotTableContext.d.ts +55 -0
  10. package/commonjs/src/hotTableInner.d.ts +5 -0
  11. package/commonjs/src/index.d.ts +5 -0
  12. package/commonjs/src/renderersPortalManager.d.ts +6 -0
  13. package/commonjs/src/settingsMapper.d.ts +18 -0
  14. package/commonjs/src/types.d.ts +78 -0
  15. package/dist/react-handsontable.js +1133 -0
  16. package/dist/react-handsontable.js.map +1 -0
  17. package/dist/react-handsontable.min.js +31 -0
  18. package/dist/react-handsontable.min.js.map +1 -0
  19. package/dist/src/helpers.d.ts +105 -0
  20. package/dist/src/hotColumn.d.ts +5 -0
  21. package/dist/src/hotColumnContext.d.ts +16 -0
  22. package/dist/src/hotEditor.d.ts +33 -0
  23. package/dist/src/hotTable.d.ts +29 -0
  24. package/dist/src/hotTableContext.d.ts +55 -0
  25. package/dist/src/hotTableInner.d.ts +5 -0
  26. package/dist/src/index.d.ts +5 -0
  27. package/dist/src/renderersPortalManager.d.ts +6 -0
  28. package/dist/src/settingsMapper.d.ts +18 -0
  29. package/dist/src/types.d.ts +78 -0
  30. package/es/react-handsontable.mjs +2125 -0
  31. package/handsontable-non-commercial-license.pdf +0 -0
  32. package/helpers.d.ts +105 -0
  33. package/hotColumn.d.ts +5 -0
  34. package/hotColumnContext.d.ts +16 -0
  35. package/hotEditor.d.ts +33 -0
  36. package/hotTable.d.ts +29 -0
  37. package/hotTableContext.d.ts +55 -0
  38. package/hotTableInner.d.ts +5 -0
  39. package/index.d.ts +5 -0
  40. package/package.json +130 -0
  41. package/renderersPortalManager.d.ts +6 -0
  42. package/settingsMapper.d.ts +18 -0
  43. package/types.d.ts +78 -0
@@ -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,5 @@
1
+ import React from 'react';
2
+ import { HotTableProps, HotTableRef } from './types';
3
+ declare const HotTableInner: React.ForwardRefExoticComponent<HotTableProps & React.RefAttributes<HotTableRef>>;
4
+ export default HotTableInner;
5
+ export { HotTableInner };
@@ -0,0 +1,5 @@
1
+ export * from './hotColumn';
2
+ export * from './hotTable';
3
+ export { useHotEditor } from './hotEditor';
4
+ export * from './types';
5
+ export { default } from './hotTable';
@@ -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 {};