@handsontable/react-wrapper 18.1.2-rc2 → 19.0.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -17
- package/commonjs/react-handsontable.js +877 -190
- package/dist/react-handsontable.js +880 -193
- package/dist/react-handsontable.js.map +1 -1
- package/dist/react-handsontable.min.js +2 -2
- package/dist/react-handsontable.min.js.map +1 -1
- package/es/react-handsontable.mjs +878 -191
- package/helpers.d.ts +125 -12
- package/hotColumnContext.d.ts +6 -0
- package/hotEditor.d.ts +24 -6
- package/hotTableContext.d.ts +10 -8
- package/package.json +15 -4
- package/settingsMapper.d.ts +27 -4
- package/types.d.ts +41 -4
package/helpers.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { ComponentType, CSSProperties, DependencyList, EffectCallback, ReactNode, ReactPortal } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import Handsontable from 'handsontable/base';
|
|
3
|
+
import { HotRendererProps, HotTableProps } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
|
|
5
6
|
*/
|
|
@@ -20,6 +21,19 @@ export declare const UNEXPECTED_HOTTABLE_CHILDREN_WARNING: string;
|
|
|
20
21
|
* Warning message for the unexpected children of HotColumn component.
|
|
21
22
|
*/
|
|
22
23
|
export declare const UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING: string;
|
|
24
|
+
/**
|
|
25
|
+
* Warning when a Handsontable function renderer is passed to the React `renderer` prop.
|
|
26
|
+
*
|
|
27
|
+
* That prop is a React component. A classic function renderer belongs on `hotRenderer`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CLASSIC_FUNCTION_RENDERER_WARNING: string;
|
|
30
|
+
/**
|
|
31
|
+
* Warning when a Handsontable editor (an editor class or a registered editor name) is passed to the
|
|
32
|
+
* React `editor` prop.
|
|
33
|
+
*
|
|
34
|
+
* That prop is a React component. A Handsontable editor belongs on `hotEditor`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const NATIVE_EDITOR_IN_EDITOR_PROP_WARNING: string;
|
|
23
37
|
/**
|
|
24
38
|
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
|
25
39
|
*/
|
|
@@ -28,15 +42,37 @@ export declare const HOT_DESTROYED_WARNING: string;
|
|
|
28
42
|
* Default classname given to the wrapper container.
|
|
29
43
|
*/
|
|
30
44
|
export declare const DEFAULT_CLASSNAME = "hot-wrapper-editor-container";
|
|
45
|
+
/**
|
|
46
|
+
* Classname for the stable host that holds React editor portals.
|
|
47
|
+
* Distinct from `DEFAULT_CLASSNAME` so page CSS and `querySelector` do not hit both nodes.
|
|
48
|
+
*/
|
|
49
|
+
export declare const EDITOR_PORTAL_HOST_CLASSNAME = "hot-wrapper-editor-portal-host";
|
|
50
|
+
/**
|
|
51
|
+
* Warning when the editor portal host cannot be moved into `rootPortalElement`.
|
|
52
|
+
*/
|
|
53
|
+
export declare const MISSING_ROOT_PORTAL_WARNING: string;
|
|
31
54
|
/**
|
|
32
55
|
* Logs warn to the console if the `console` object is exposed.
|
|
33
56
|
*
|
|
34
57
|
* @param {...*} args Values which will be logged.
|
|
35
58
|
*/
|
|
36
59
|
export declare function warn(...args: any[]): void;
|
|
60
|
+
/**
|
|
61
|
+
* Warn when `renderer` holds a Handsontable function renderer.
|
|
62
|
+
*
|
|
63
|
+
* A React component is called with one props object, so its `length` stays below 3.
|
|
64
|
+
* A classic renderer declares `(instance, td, row, col, prop, value, cellProperties)`,
|
|
65
|
+
* so its `length` is at least 3. The prop is still rendered as a component. Picking
|
|
66
|
+
* the call style from `length` would change behavior, because a component with default
|
|
67
|
+
* parameters reports `length` 0.
|
|
68
|
+
*
|
|
69
|
+
* @param {ComponentType} renderer Component passed through the `renderer` prop.
|
|
70
|
+
*/
|
|
71
|
+
export declare function warnAboutClassicFunctionRenderer(renderer: ComponentType<HotRendererProps>): void;
|
|
37
72
|
/**
|
|
38
73
|
* Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning.
|
|
39
74
|
*
|
|
75
|
+
* @param {ReactNode} children Component children nodes.
|
|
40
76
|
* @returns {boolean} 'true' if the warning was issued
|
|
41
77
|
*/
|
|
42
78
|
export declare function displayObsoleteRenderersEditorsWarning(children: ReactNode): boolean;
|
|
@@ -55,22 +91,76 @@ export declare function displayChildrenOfTypeWarning(children: ReactNode, Compon
|
|
|
55
91
|
* @returns {boolean} 'true' if the warning was issued
|
|
56
92
|
*/
|
|
57
93
|
export declare function displayAnyChildrenWarning(children: ReactNode): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Check whether the `editor` prop holds a component editor, as opposed to a boolean flag or a
|
|
96
|
+
* Handsontable editor passed there by mistake.
|
|
97
|
+
*
|
|
98
|
+
* Both editor props accept a boolean, so a truthy check alone is not enough to tell a component
|
|
99
|
+
* apart from a bare `editor={true}`. An editor class or editor name is not a component either (see
|
|
100
|
+
* `isNativeEditor()`).
|
|
101
|
+
*
|
|
102
|
+
* @param {HotTableProps['editor']} editor The `editor` prop.
|
|
103
|
+
* @returns {boolean} `true` when the prop carries a React component to render.
|
|
104
|
+
*/
|
|
105
|
+
export declare function isComponentEditor(editor: HotTableProps['editor']): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Check whether a value is a Handsontable editor: a registered editor name or an editor class.
|
|
108
|
+
*
|
|
109
|
+
* A class is recognized by the `BaseEditor` methods on its prototype rather than with `instanceof`,
|
|
110
|
+
* so a class built on another copy of Handsontable is still recognized. A React class component
|
|
111
|
+
* carries `prototype.isReactComponent`, and a function component does not have these methods, so
|
|
112
|
+
* neither one matches.
|
|
113
|
+
*
|
|
114
|
+
* @param {*} editor The value to check.
|
|
115
|
+
* @returns {boolean} `true` when the value is a Handsontable editor.
|
|
116
|
+
*/
|
|
117
|
+
export declare function isNativeEditor(editor: unknown): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Resolve the Handsontable `editor` setting from the two editor props.
|
|
120
|
+
*
|
|
121
|
+
* `editor` carries the component editor and `hotEditor` the Handsontable-native one, but both accept
|
|
122
|
+
* a boolean:
|
|
123
|
+
*
|
|
124
|
+
* - `false` disables editing.
|
|
125
|
+
* - `true` names no editor, so it is treated as if the prop were not provided. It must never reach
|
|
126
|
+
* the core, which accepts only a string or a constructor and throws on anything else.
|
|
127
|
+
* - Any other nullish or falsy value (`null`, `0`, `''`) is also treated as "not provided", so a
|
|
128
|
+
* column written as `editor={cond ? MyEditor : null}` inherits instead of locking.
|
|
129
|
+
*
|
|
130
|
+
* `hotEditor` is resolved before a falsy `editor`, so an editor named there still wins over a bare
|
|
131
|
+
* `editor={false}` — the behavior in every released version, where `editor={false}` fell through to
|
|
132
|
+
* the `hotEditor` value. A component `editor` outranks both: it is picked by `isComponentEditor()`
|
|
133
|
+
* before this function is reached, so `editor={MyComponent} hotEditor={false}` keeps the component.
|
|
134
|
+
*
|
|
135
|
+
* A Handsontable editor (a class or a registered name) passed to `editor` is a mistake: that prop
|
|
136
|
+
* renders a React component. It is used as if it were passed to `hotEditor`, with a one-time
|
|
137
|
+
* warning. A `hotEditor` value that names an editor or disables editing still wins over it. A name
|
|
138
|
+
* that no editor is registered under is dropped after the warning, so a typo does not make the core
|
|
139
|
+
* throw.
|
|
140
|
+
*
|
|
141
|
+
* @param {HotTableProps['editor']} editor The `editor` prop.
|
|
142
|
+
* @param {HotTableProps['hotEditor']} hotEditor The `hotEditor` prop.
|
|
143
|
+
* @returns {*} The editor setting, or `undefined` when neither prop names one.
|
|
144
|
+
*/
|
|
145
|
+
export declare function resolveEditorSetting(editor: HotTableProps['editor'], hotEditor: HotTableProps['hotEditor']): Handsontable.GridSettings['editor'] | undefined;
|
|
58
146
|
/**
|
|
59
147
|
* Create an editor portal.
|
|
60
148
|
*
|
|
61
149
|
* @param {Document} doc Document to be used.
|
|
62
150
|
* @param {ComponentType} Editor Editor component or render function.
|
|
151
|
+
* @param {HTMLElement} portalHost Host element to portal into. Required – do not fall back to `doc.body`.
|
|
63
152
|
* @returns {ReactPortal} The portal for the editor.
|
|
64
153
|
*/
|
|
65
|
-
export declare function createEditorPortal(doc: Document | null, Editor: HotTableProps['editor'] | undefined | boolean): ReactPortal | null;
|
|
154
|
+
export declare function createEditorPortal(doc: Document | null, Editor: HotTableProps['editor'] | undefined | boolean, portalHost?: HTMLElement | null): ReactPortal | null;
|
|
66
155
|
/**
|
|
67
156
|
* Render a cell component to an external DOM node.
|
|
68
157
|
*
|
|
69
158
|
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
70
159
|
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
71
|
-
* @param {
|
|
160
|
+
* @param {string} portalKey The key to be used for the portal.
|
|
72
161
|
* @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
|
|
162
|
+
* @returns {{portal: ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its
|
|
163
|
+
* container.
|
|
74
164
|
*/
|
|
75
165
|
export declare function createPortal(rElement: React.ReactElement, ownerDocument: Document | null | undefined, portalKey: string, cachedContainer?: HTMLElement): {
|
|
76
166
|
portal: ReactPortal;
|
|
@@ -81,9 +171,10 @@ export declare function createPortal(rElement: React.ReactElement, ownerDocument
|
|
|
81
171
|
* component.
|
|
82
172
|
*
|
|
83
173
|
* @param {HotTableProps} props Object containing the React element props.
|
|
84
|
-
* @param {
|
|
85
|
-
*
|
|
86
|
-
*
|
|
174
|
+
* @param {boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was
|
|
175
|
+
* present in the `prop` object.
|
|
176
|
+
* @returns {{id?: string, className: string, style: CSSProperties}} An object containing the `id`, `className`
|
|
177
|
+
* and `style` keys, representing the corresponding props passed to the component.
|
|
87
178
|
*/
|
|
88
179
|
export declare function getContainerAttributesProps(props: HotTableProps, randomizeId?: boolean): {
|
|
89
180
|
id?: string;
|
|
@@ -93,21 +184,43 @@ export declare function getContainerAttributesProps(props: HotTableProps, random
|
|
|
93
184
|
/**
|
|
94
185
|
* Checks if the environment that the code runs in is a browser.
|
|
95
186
|
*
|
|
96
|
-
* @returns {boolean}
|
|
187
|
+
* @returns {boolean} `true` when running in a browser environment.
|
|
97
188
|
*/
|
|
98
189
|
export declare function isCSR(): boolean;
|
|
99
190
|
/**
|
|
100
|
-
* Deep-compare plain objects and arrays used by wrapper settings.
|
|
191
|
+
* Deep-compare plain objects and arrays used by wrapper settings. Functions, class instances and any
|
|
192
|
+
* other value are compared by reference, and a `RegExp` by its source and flags. A pair of objects
|
|
193
|
+
* already being compared higher up reads as equal, so a value with a cycle (tree rows with a `parent`
|
|
194
|
+
* link) ends instead of overflowing the stack.
|
|
101
195
|
*
|
|
102
196
|
* @param {unknown} previousValue Previous value.
|
|
103
197
|
* @param {unknown} currentValue Current value.
|
|
198
|
+
* @param {WeakMap<object, WeakSet<object>>} [visited] The object pairs on the current comparison path.
|
|
104
199
|
* @returns {boolean} `true` if values are equivalent.
|
|
105
200
|
*/
|
|
106
|
-
export declare function areEquivalentSettingsValue(previousValue: unknown, currentValue: unknown): boolean;
|
|
201
|
+
export declare function areEquivalentSettingsValue(previousValue: unknown, currentValue: unknown, visited?: WeakMap<object, WeakSet<object>>): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Copies the plain objects and arrays of a settings value, keeping every other value (functions, class
|
|
204
|
+
* instances) by reference. The copy is what an update compares the next value with, so a value the app
|
|
205
|
+
* changes in place reads as changed. A value with a cycle is copied with the same cycle.
|
|
206
|
+
*
|
|
207
|
+
* @param {unknown} value The value to copy.
|
|
208
|
+
* @param {WeakMap<object, unknown>} [copies] The copies made so far, by original.
|
|
209
|
+
* @returns {unknown} The copy.
|
|
210
|
+
*/
|
|
211
|
+
export declare function copySettingsValue(value: unknown, copies?: WeakMap<object, unknown>): unknown;
|
|
107
212
|
/**
|
|
108
213
|
* A variant of useEffect hook that does not trigger on initial mount, only updates
|
|
109
214
|
*
|
|
110
|
-
* @param effect Effect function
|
|
111
|
-
* @param deps Effect dependencies
|
|
215
|
+
* @param {EffectCallback} effect Effect function
|
|
216
|
+
* @param {DependencyList} [deps] Effect dependencies
|
|
112
217
|
*/
|
|
113
218
|
export declare function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void;
|
|
219
|
+
/**
|
|
220
|
+
* Returns the element a cell's content belongs in: the grid's clipping wrapper when the cell holds
|
|
221
|
+
* exactly that wrapper, and the cell itself otherwise.
|
|
222
|
+
*
|
|
223
|
+
* @param {HTMLElement} TD The table cell.
|
|
224
|
+
* @returns {Element}
|
|
225
|
+
*/
|
|
226
|
+
export declare function getCellContentRoot(TD: HTMLElement): Element;
|
package/hotColumnContext.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export interface HotColumnContextImpl {
|
|
|
10
10
|
* @returns The `Document` object used by the component.
|
|
11
11
|
*/
|
|
12
12
|
readonly getOwnerDocument: () => Document | null;
|
|
13
|
+
/**
|
|
14
|
+
* Get the stable host element for React editor portals.
|
|
15
|
+
*
|
|
16
|
+
* @returns The host element, or `null` before a document is available.
|
|
17
|
+
*/
|
|
18
|
+
readonly getEditorPortalHost: () => HTMLElement | null;
|
|
13
19
|
}
|
|
14
20
|
declare const HotColumnContextProvider: FC<PropsWithChildren<HotColumnContextImpl>>;
|
|
15
21
|
declare const useHotColumnContext: () => HotColumnContextImpl;
|
package/hotEditor.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import React, { DependencyList, FC, MutableRefObject, ReactNode, Ref, RefObject,
|
|
|
2
2
|
import Handsontable from 'handsontable/base';
|
|
3
3
|
import { HotEditorHooks, UseHotEditorImpl } from './types';
|
|
4
4
|
/**
|
|
5
|
-
* Create a class to be passed to the Handsontable's settings
|
|
5
|
+
* Create a class to be passed to the Handsontable's settings, or return the one made for the same hooks
|
|
6
|
+
* reference.
|
|
6
7
|
*
|
|
7
8
|
* @param {RefObject<HotEditorHooks>} hooksRef Reference to component-based editor overridden hooks object.
|
|
8
9
|
* @param {RefObject} instanceRef Reference to Handsontable-native custom editor class instance.
|
|
@@ -26,12 +27,15 @@ interface EditorContextProviderProps {
|
|
|
26
27
|
* Provider of the context that exposes Handsontable-native editor instance and passes hooks object
|
|
27
28
|
* for custom editor components.
|
|
28
29
|
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
30
|
+
* @param {object} root0 The provider props.
|
|
31
|
+
* @param {Ref} root0.hooksRef Reference for component-based editor overridden hooks object.
|
|
32
|
+
* @param {RefObject} root0.hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
|
|
33
|
+
* @param {ReactNode} root0.children The provider's children.
|
|
34
|
+
* @returns {ReactElement} The provider component.
|
|
31
35
|
*/
|
|
32
36
|
export declare const EditorContextProvider: FC<EditorContextProviderProps>;
|
|
33
37
|
/**
|
|
34
|
-
* Hook that allows encapsulating custom
|
|
38
|
+
* Hook that allows encapsulating custom behaviors of component-based editor by customizing passed ref with overridden hooks object.
|
|
35
39
|
*
|
|
36
40
|
* @param {HotEditorHooks} overriddenHooks Overrides specific for the custom editor.
|
|
37
41
|
* @param {DependencyList} deps Overridden hooks object React dependency list.
|
|
@@ -50,7 +54,7 @@ declare type EditorChildrenProps<T> = {
|
|
|
50
54
|
declare type EditorRenderProp<T> = (props: EditorChildrenProps<T>) => React.ReactNode;
|
|
51
55
|
declare type EditorComponentProps = {
|
|
52
56
|
onPrepare?: (row: number, column: number, prop: string | number, TD: HTMLTableCellElement, originalValue: any, cellProperties: Handsontable.CellProperties) => void;
|
|
53
|
-
onOpen?:
|
|
57
|
+
onOpen?(event?: Event): void;
|
|
54
58
|
onClose?: () => void;
|
|
55
59
|
onFocus?: () => void;
|
|
56
60
|
shortcutsGroup?: string;
|
|
@@ -63,10 +67,24 @@ declare type EditorComponentProps = {
|
|
|
63
67
|
preventDefault?: boolean;
|
|
64
68
|
stopPropagation?: boolean;
|
|
65
69
|
relativeToGroup?: string;
|
|
66
|
-
position?:
|
|
70
|
+
position?: 'before' | 'after';
|
|
67
71
|
forwardToContext?: any;
|
|
68
72
|
}[];
|
|
69
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Component-based editor. Renders the `children` render prop inside the editor's positioned overlay
|
|
76
|
+
* and wires up its shortcuts and scroll-repositioning.
|
|
77
|
+
*
|
|
78
|
+
* @param {object} root0 The component props.
|
|
79
|
+
* @param {Function} [root0.onPrepare] Called when the editor is prepared for a cell.
|
|
80
|
+
* @param {Function} [root0.onClose] Called when the editor closes.
|
|
81
|
+
* @param {Function} [root0.onOpen] Called when the editor opens. Receives the DOM event that opened the editor. It is `undefined` when you call `beginEditing()`.
|
|
82
|
+
* @param {Function} [root0.onFocus] Called when the editor is focused.
|
|
83
|
+
* @param {EditorRenderProp} [root0.children] Render prop returning the editor's UI.
|
|
84
|
+
* @param {string} [root0.shortcutsGroup] The shortcuts group name to register under.
|
|
85
|
+
* @param {Array} [root0.shortcuts] The editor's keyboard shortcuts.
|
|
86
|
+
* @returns {React.ReactElement} The editor overlay element.
|
|
87
|
+
*/
|
|
70
88
|
export declare function EditorComponent<T = any>({ onPrepare, onClose, onOpen, onFocus, children, shortcutsGroup, shortcuts, }: EditorComponentProps & {
|
|
71
89
|
children?: EditorRenderProp<T>;
|
|
72
90
|
}): React.ReactElement;
|
package/hotTableContext.d.ts
CHANGED
|
@@ -16,14 +16,14 @@ export interface HotTableContextImpl {
|
|
|
16
16
|
* Sets the column settings based on information received from HotColumn.
|
|
17
17
|
*
|
|
18
18
|
* @param {HotTableProps} columnSettings Column settings object.
|
|
19
|
-
* @param {
|
|
19
|
+
* @param {number} columnIndex Column index.
|
|
20
20
|
*/
|
|
21
21
|
readonly emitColumnSettings: (columnSettings: Handsontable.ColumnSettings, columnIndex: number) => void;
|
|
22
22
|
/**
|
|
23
23
|
* Trim the column settings array to the given length. Used to drop slots
|
|
24
24
|
* left over from HotColumn children that have unmounted.
|
|
25
25
|
*
|
|
26
|
-
* @param {
|
|
26
|
+
* @param {number} length Target length for the column settings array.
|
|
27
27
|
*/
|
|
28
28
|
readonly trimColumnSettings: (length: number) => void;
|
|
29
29
|
/**
|
|
@@ -34,13 +34,15 @@ export interface HotTableContextImpl {
|
|
|
34
34
|
*/
|
|
35
35
|
readonly getRendererWrapper: (Renderer: ComponentType<HotRendererProps>) => typeof Handsontable.renderers.BaseRenderer;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Starts a view-render pass: forgets which portal containers the previous pass rendered.
|
|
38
38
|
*/
|
|
39
|
-
readonly
|
|
39
|
+
readonly resetRenderedPortals: () => void;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Records a cell element the grid painted in the current view-render pass, whatever its renderer.
|
|
42
|
+
*
|
|
43
|
+
* @param {HTMLTableCellElement} TD The painted cell element.
|
|
42
44
|
*/
|
|
43
|
-
readonly
|
|
45
|
+
readonly markCellPainted: (TD: HTMLTableCellElement) => void;
|
|
44
46
|
/**
|
|
45
47
|
* Returns the number of portal containers currently retained by the cache.
|
|
46
48
|
* Diagnostic hook used to assert the cache stays bounded to the viewport
|
|
@@ -56,7 +58,7 @@ export interface HotTableContextImpl {
|
|
|
56
58
|
*/
|
|
57
59
|
readonly setRenderersPortalManagerRef: (pm: RenderersPortalManagerRef) => void;
|
|
58
60
|
/**
|
|
59
|
-
*
|
|
61
|
+
* Evicts the portals of the cells that left the grid and puts the rest into the portal manager.
|
|
60
62
|
*/
|
|
61
63
|
readonly pushCellPortalsIntoPortalManager: () => void;
|
|
62
64
|
}
|
|
@@ -64,7 +66,7 @@ declare const HotTableContextProvider: FC<PropsWithChildren>;
|
|
|
64
66
|
/**
|
|
65
67
|
* Exposes the table context object to components
|
|
66
68
|
*
|
|
67
|
-
* @returns HotTableContext
|
|
69
|
+
* @returns {HotTableContextImpl} HotTableContext
|
|
68
70
|
*/
|
|
69
71
|
declare function useHotTableContext(): HotTableContextImpl;
|
|
70
72
|
export { HotTableContextProvider, useHotTableContext };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handsontable/react-wrapper",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "19.0.0-rc1",
|
|
4
|
+
"description": "Handsontable DataGrid for React with a spreadsheet look and feel.",
|
|
5
5
|
"author": "Handsoncode <hello@handsoncode.net> (https://handsoncode.net)",
|
|
6
6
|
"homepage": "https://handsontable.com",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -72,8 +72,12 @@
|
|
|
72
72
|
"@types/react": "^18.2.0",
|
|
73
73
|
"@types/react-dom": "^18.2.0",
|
|
74
74
|
"@types/react-redux": "^7.1.7",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
76
|
+
"@typescript-eslint/parser": "^5.4.0",
|
|
75
77
|
"cross-env": "^7.0.3",
|
|
76
|
-
"
|
|
78
|
+
"eslint": "^8.57.1",
|
|
79
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
80
|
+
"handsontable": "^19.0.0",
|
|
77
81
|
"jest": "^27.5.1",
|
|
78
82
|
"jest-environment-jsdom": "^27.5.1",
|
|
79
83
|
"prop-types": "^15.7.2",
|
|
@@ -88,7 +92,9 @@
|
|
|
88
92
|
"uglify-js": "^3.4.9"
|
|
89
93
|
},
|
|
90
94
|
"peerDependencies": {
|
|
91
|
-
"handsontable": "^
|
|
95
|
+
"handsontable": "^19.0.0",
|
|
96
|
+
"react": ">=18.0.0",
|
|
97
|
+
"react-dom": ">=18.0.0"
|
|
92
98
|
},
|
|
93
99
|
"scripts": {
|
|
94
100
|
"build": "npm run clean && npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:min && npm run prepare:types",
|
|
@@ -98,6 +104,7 @@
|
|
|
98
104
|
"build:min": "cross-env NODE_ENV=min rollup -c --bundleConfigAsCjs",
|
|
99
105
|
"prepare:types": "node scripts/prepare-types.mjs",
|
|
100
106
|
"clean": "node scripts/clean.mjs",
|
|
107
|
+
"lint": "eslint --ext .js,.ts,.tsx src test",
|
|
101
108
|
"publish-package": "npm publish",
|
|
102
109
|
"create-package": "npm pack",
|
|
103
110
|
"test": "jest",
|
|
@@ -110,9 +117,13 @@
|
|
|
110
117
|
"testURL": "http://localhost/",
|
|
111
118
|
"testTimeout": 60000,
|
|
112
119
|
"transform": {
|
|
120
|
+
"hyperformula-ui.+\\.js$": "<rootDir>/test/hyperformulaUiTransform.js",
|
|
113
121
|
"^.+\\.tsx?$": "babel-jest",
|
|
114
122
|
"^.+\\.js$": "babel-jest"
|
|
115
123
|
},
|
|
124
|
+
"transformIgnorePatterns": [
|
|
125
|
+
"/node_modules/(?!(\\.pnpm/)?hyperformula-ui[@/])"
|
|
126
|
+
],
|
|
116
127
|
"testRegex": "(/test/(.*).(test|spec)).(jsx?|tsx?)$",
|
|
117
128
|
"moduleFileExtensions": [
|
|
118
129
|
"ts",
|
package/settingsMapper.d.ts
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import Handsontable from 'handsontable/base';
|
|
2
2
|
import { HotTableProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Copies of the values last passed to the grid, by setting name. The component keeps one per grid
|
|
5
|
+
* instance and passes it to every update.
|
|
6
|
+
*/
|
|
7
|
+
export declare type ForwardedSettings = Map<string, unknown>;
|
|
3
8
|
export declare class SettingsMapper {
|
|
4
9
|
/**
|
|
5
10
|
* Parse component settings into Handsontable-compatible settings.
|
|
6
11
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
12
|
+
* A prop whose value is `undefined` counts as not passed and is left out, so the option keeps its
|
|
13
|
+
* default. An own `undefined` key would shadow that default in the settings cascade. On an update
|
|
14
|
+
* of a prop that had a value in the previous props, the option's default is forwarded instead, so
|
|
15
|
+
* the grid matches a fresh mount with the same props (`copyPaste={on ? false : undefined}` turns
|
|
16
|
+
* copy and paste back on). `height` and `width` are forwarded as `null`, because core leaves the
|
|
17
|
+
* size in place for `undefined` (`height={full ? undefined : 400}` clears the height).
|
|
18
|
+
* A hook has no default to fall back to, so a hook prop that had a callback and is now `undefined`
|
|
19
|
+
* is forwarded as `null`, which removes the callback (`afterChange={on ? logChange : undefined}`).
|
|
20
|
+
* So is a hook prop that had a callback and is no longer passed at all, and, on an update, a hook
|
|
21
|
+
* prop that holds anything but a callback (`afterChange={on && logChange}` gives `false`).
|
|
22
|
+
* For an option that is not a hook, `null` and `false` are real values and are forwarded.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} properties Object containing properties from the HotTable object.
|
|
25
|
+
* @param {object} additionalSettings Additional settings.
|
|
9
26
|
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
|
10
27
|
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
|
11
|
-
* @
|
|
28
|
+
* @param {HotTableProps} additionalSettings.prevProps The component's props before the current update.
|
|
29
|
+
* @param {Handsontable.GridSettings} additionalSettings.currentSettings The grid's current live settings.
|
|
30
|
+
* @param {ForwardedSettings} additionalSettings.forwardedSettings The values last passed to the grid. A
|
|
31
|
+
* setting whose value equals the one recorded there is left out, and every setting passed is recorded.
|
|
32
|
+
* @returns {object} Handsontable-compatible settings object.
|
|
12
33
|
*/
|
|
13
|
-
static getSettings(properties: HotTableProps, { prevProps, isInit, initOnlySettingKeys }?: {
|
|
34
|
+
static getSettings(properties: HotTableProps, { prevProps, isInit, initOnlySettingKeys, currentSettings, forwardedSettings, }?: {
|
|
14
35
|
prevProps?: HotTableProps;
|
|
15
36
|
isInit?: boolean;
|
|
16
37
|
initOnlySettingKeys?: Array<keyof Handsontable.GridSettings>;
|
|
38
|
+
currentSettings?: Handsontable.GridSettings;
|
|
39
|
+
forwardedSettings?: ForwardedSettings;
|
|
17
40
|
}): Handsontable.GridSettings;
|
|
18
41
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Handsontable, { RemoveIndexSignature } from 'handsontable/base';
|
|
1
|
+
import Handsontable, { RemoveIndexSignature, OmitHooks } from 'handsontable/base';
|
|
2
2
|
import { ComponentType, CSSProperties, Dispatch, DispatchWithoutAction, ReactNode } from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Type of the identifier under which the cached components are stored.
|
|
@@ -20,7 +20,12 @@ export interface HotRendererProps {
|
|
|
20
20
|
* Interface for component-based editor overridden hooks object.
|
|
21
21
|
*/
|
|
22
22
|
export interface HotEditorHooks {
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Called when the editor opens.
|
|
25
|
+
*
|
|
26
|
+
* @param {Event} [event] The DOM event that opened the editor. It is `undefined` when you call `beginEditing()`.
|
|
27
|
+
*/
|
|
28
|
+
onOpen?(event?: Event): void;
|
|
24
29
|
onClose?: () => void;
|
|
25
30
|
onPrepare?: (row: number, column: number, prop: string | number, TD: HTMLTableCellElement, originalValue: any, cellProperties: Handsontable.CellProperties) => void;
|
|
26
31
|
onFocus?: () => void;
|
|
@@ -59,9 +64,33 @@ declare type ReplaceRenderersEditors<T> = Omit<RemoveIndexSignature<T>, 'rendere
|
|
|
59
64
|
renderer?: infer R;
|
|
60
65
|
} ? R : never;
|
|
61
66
|
renderer?: ComponentType<HotRendererProps>;
|
|
67
|
+
/**
|
|
68
|
+
* The Handsontable-native editor: a registered editor name, an editor class, or a boolean.
|
|
69
|
+
*
|
|
70
|
+
* Set it to `false` to disable editing. Setting it to `true` — or to any other falsy value, such as
|
|
71
|
+
* `null` — is treated as if the prop were not provided, so the cell keeps the editor its column
|
|
72
|
+
* type or the grid supplies.
|
|
73
|
+
*
|
|
74
|
+
* A component passed to `editor` outranks this prop. A native editor named here outranks
|
|
75
|
+
* `editor={false}`.
|
|
76
|
+
*/
|
|
62
77
|
hotEditor?: T extends {
|
|
63
78
|
editor?: infer E;
|
|
64
79
|
} ? E : never;
|
|
80
|
+
/**
|
|
81
|
+
* The component-based editor, rendered through a React portal.
|
|
82
|
+
*
|
|
83
|
+
* Set it to `false` to disable editing. Setting it to `true` — or to any other falsy value, such as
|
|
84
|
+
* `null` — is treated as if the prop were not provided, so the cell keeps the editor its column
|
|
85
|
+
* type or the grid supplies.
|
|
86
|
+
*
|
|
87
|
+
* A component passed here wins over `hotEditor`. A bare `editor={false}` does not: an editor named
|
|
88
|
+
* in `hotEditor` still applies.
|
|
89
|
+
*
|
|
90
|
+
* A Handsontable editor class or editor name belongs in `hotEditor`. When one is passed here, it
|
|
91
|
+
* is used as `hotEditor`, and the console shows a one-time warning. A name with no registered
|
|
92
|
+
* editor is ignored after the warning.
|
|
93
|
+
*/
|
|
65
94
|
editor?: ComponentType | boolean;
|
|
66
95
|
} & {
|
|
67
96
|
[key: string]: any;
|
|
@@ -71,15 +100,23 @@ declare type ReplaceRenderersEditors<T> = Omit<RemoveIndexSignature<T>, 'rendere
|
|
|
71
100
|
* `Omit`) plus the column-specific `data` type. `data` is taken from `ColumnSettings` — an explicit
|
|
72
101
|
* member that resolves even though `ColumnSettings` itself carries the broad index signature — so the
|
|
73
102
|
* column form (`string | number | getter/setter`) overrides the grid's whole-table `data` type.
|
|
103
|
+
*
|
|
104
|
+
* Hook callbacks (`afterChange`, `beforeKeyDown`, ...) are left out because hooks run from the
|
|
105
|
+
* grid-level settings only, so `<HotColumn>` must not suggest them. `OmitHooks` comes from core for
|
|
106
|
+
* the same reason as `RemoveIndexSignature`. A hook passed to a column still type-checks through the
|
|
107
|
+
* `[key: string]: any` hatch on `ReplaceRenderersEditors`; it just is not suggested.
|
|
74
108
|
*/
|
|
75
|
-
declare type ColumnGridSettings = Omit<RemoveIndexSignature<Handsontable.GridSettings
|
|
109
|
+
declare type ColumnGridSettings = Omit<OmitHooks<RemoveIndexSignature<Handsontable.GridSettings>>, 'data'> & {
|
|
76
110
|
data?: Handsontable.ColumnSettings['data'];
|
|
77
111
|
};
|
|
78
112
|
/**
|
|
79
113
|
* Interface for the `prop` of the HotTable component - extending the default Handsontable settings with additional,
|
|
80
114
|
* component-related properties.
|
|
115
|
+
*
|
|
116
|
+
* The props are built from `SettingsUpdate`, the settings `updateSettings()` takes, so a hook prop may be
|
|
117
|
+
* `null`, which removes its callback (`afterChange={isTracking ? logChange : null}`).
|
|
81
118
|
*/
|
|
82
|
-
export interface HotTableProps extends ReplaceRenderersEditors<Handsontable.
|
|
119
|
+
export interface HotTableProps extends ReplaceRenderersEditors<Handsontable.SettingsUpdate> {
|
|
83
120
|
id?: string;
|
|
84
121
|
className?: string;
|
|
85
122
|
style?: CSSProperties;
|