@handsontable/react 14.1.0 → 14.2.0-next-7ae341f-20240229
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/commonjs/react-handsontable.js +86 -39
- package/dist/react-handsontable.js +89 -44
- 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 +86 -40
- package/helpers.d.ts +3 -1
- package/hotTableClass.d.ts +17 -3
- package/index.d.ts +1 -0
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import Handsontable from 'handsontable/base';
|
|
4
|
+
import { getRenderer } from 'handsontable/renderers/registry';
|
|
5
|
+
import { getEditor } from 'handsontable/editors/registry';
|
|
4
6
|
|
|
5
7
|
function _callSuper(t, o, e) {
|
|
6
8
|
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
@@ -300,23 +302,27 @@ function getExtendedEditorElement(children, editorCache) {
|
|
|
300
302
|
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
301
303
|
* @param {Object} props Props to be passed to the cloned element.
|
|
302
304
|
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
305
|
+
* @param {String} portalKey The key to be used for the portal.
|
|
306
|
+
* @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
|
|
303
307
|
* @returns {{portal: React.ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
304
308
|
*/
|
|
305
309
|
function createPortal(rElement, props) {
|
|
306
310
|
var ownerDocument = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document;
|
|
311
|
+
var portalKey = arguments.length > 3 ? arguments[3] : undefined;
|
|
312
|
+
var cachedContainer = arguments.length > 4 ? arguments[4] : undefined;
|
|
307
313
|
if (!ownerDocument) {
|
|
308
314
|
ownerDocument = document;
|
|
309
315
|
}
|
|
310
316
|
if (!bulkComponentContainer) {
|
|
311
317
|
bulkComponentContainer = ownerDocument.createDocumentFragment();
|
|
312
318
|
}
|
|
313
|
-
var portalContainer = ownerDocument.createElement('DIV');
|
|
319
|
+
var portalContainer = cachedContainer !== null && cachedContainer !== void 0 ? cachedContainer : ownerDocument.createElement('DIV');
|
|
314
320
|
bulkComponentContainer.appendChild(portalContainer);
|
|
315
321
|
var extendedRendererElement = React.cloneElement(rElement, _objectSpread2({
|
|
316
322
|
key: "".concat(props.row, "-").concat(props.col)
|
|
317
323
|
}, props));
|
|
318
324
|
return {
|
|
319
|
-
portal: ReactDOM.createPortal(extendedRendererElement, portalContainer,
|
|
325
|
+
portal: ReactDOM.createPortal(extendedRendererElement, portalContainer, portalKey),
|
|
320
326
|
portalContainer: portalContainer
|
|
321
327
|
};
|
|
322
328
|
}
|
|
@@ -501,7 +507,7 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
|
|
|
501
507
|
return RenderersPortalManager;
|
|
502
508
|
}(React.Component);
|
|
503
509
|
|
|
504
|
-
var version="14.
|
|
510
|
+
var version="14.2.0-next-7ae341f-20240229";
|
|
505
511
|
|
|
506
512
|
function createCommonjsModule(fn, module) {
|
|
507
513
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
@@ -1682,9 +1688,17 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1682
1688
|
*/
|
|
1683
1689
|
_this.renderersPortalManager = null;
|
|
1684
1690
|
/**
|
|
1685
|
-
*
|
|
1691
|
+
* Map that stores React portals.
|
|
1692
|
+
* @type {Map<string, React.ReactPortal>}
|
|
1686
1693
|
*/
|
|
1687
|
-
_this.
|
|
1694
|
+
_this.portalCache = new Map();
|
|
1695
|
+
/**
|
|
1696
|
+
* Portal Container Cache
|
|
1697
|
+
*
|
|
1698
|
+
* @private
|
|
1699
|
+
* @type {Map}
|
|
1700
|
+
*/
|
|
1701
|
+
_this.portalContainerCache = new Map();
|
|
1688
1702
|
/**
|
|
1689
1703
|
* The rendered cells cache.
|
|
1690
1704
|
*
|
|
@@ -1736,6 +1750,16 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1736
1750
|
set: function set(hotInstance) {
|
|
1737
1751
|
this.__hotInstance = hotInstance;
|
|
1738
1752
|
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Get Portal Container Cache
|
|
1755
|
+
*
|
|
1756
|
+
* @returns {Map}
|
|
1757
|
+
*/
|
|
1758
|
+
}, {
|
|
1759
|
+
key: "getPortalContainerCache",
|
|
1760
|
+
value: function getPortalContainerCache() {
|
|
1761
|
+
return this.portalContainerCache;
|
|
1762
|
+
}
|
|
1739
1763
|
/**
|
|
1740
1764
|
* Get the rendered table cell cache.
|
|
1741
1765
|
*
|
|
@@ -1798,30 +1822,44 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1798
1822
|
key: "getRendererWrapper",
|
|
1799
1823
|
value: function getRendererWrapper(rendererElement) {
|
|
1800
1824
|
var hotTableComponent = this;
|
|
1801
|
-
return function (instance, TD, row, col, prop, value, cellProperties) {
|
|
1825
|
+
return function __internalRenderer(instance, TD, row, col, prop, value, cellProperties) {
|
|
1802
1826
|
var renderedCellCache = hotTableComponent.getRenderedCellCache();
|
|
1803
|
-
|
|
1804
|
-
|
|
1827
|
+
var portalContainerCache = hotTableComponent.getPortalContainerCache();
|
|
1828
|
+
var key = "".concat(row, "-").concat(col);
|
|
1829
|
+
// Handsontable.Core type is missing guid
|
|
1830
|
+
var instanceGuid = instance.guid;
|
|
1831
|
+
var portalContainerKey = "".concat(instanceGuid, "-").concat(key);
|
|
1832
|
+
var portalKey = "".concat(key, "-").concat(instanceGuid);
|
|
1833
|
+
if (renderedCellCache.has(key)) {
|
|
1834
|
+
TD.innerHTML = renderedCellCache.get(key).innerHTML;
|
|
1805
1835
|
}
|
|
1806
1836
|
if (TD && !TD.getAttribute('ghost-table')) {
|
|
1807
|
-
var
|
|
1808
|
-
|
|
1809
|
-
row: row,
|
|
1810
|
-
col: col,
|
|
1811
|
-
prop: prop,
|
|
1812
|
-
value: value,
|
|
1813
|
-
cellProperties: cellProperties,
|
|
1814
|
-
isRenderer: true
|
|
1815
|
-
}, TD.ownerDocument),
|
|
1816
|
-
portal = _createPortal.portal,
|
|
1817
|
-
portalContainer = _createPortal.portalContainer;
|
|
1837
|
+
var cachedPortal = hotTableComponent.portalCache.get(portalKey);
|
|
1838
|
+
var cachedPortalContainer = portalContainerCache.get(portalContainerKey);
|
|
1818
1839
|
while (TD.firstChild) {
|
|
1819
1840
|
TD.removeChild(TD.firstChild);
|
|
1820
1841
|
}
|
|
1821
|
-
|
|
1822
|
-
|
|
1842
|
+
// if portal already exists, do not recreate
|
|
1843
|
+
if (cachedPortal && cachedPortalContainer) {
|
|
1844
|
+
TD.appendChild(cachedPortalContainer);
|
|
1845
|
+
} else {
|
|
1846
|
+
var _createPortal = createPortal(rendererElement, {
|
|
1847
|
+
TD: TD,
|
|
1848
|
+
row: row,
|
|
1849
|
+
col: col,
|
|
1850
|
+
prop: prop,
|
|
1851
|
+
value: value,
|
|
1852
|
+
cellProperties: cellProperties,
|
|
1853
|
+
isRenderer: true
|
|
1854
|
+
}, TD.ownerDocument, portalKey, cachedPortalContainer),
|
|
1855
|
+
portal = _createPortal.portal,
|
|
1856
|
+
portalContainer = _createPortal.portalContainer;
|
|
1857
|
+
portalContainerCache.set(portalContainerKey, portalContainer);
|
|
1858
|
+
TD.appendChild(portalContainer);
|
|
1859
|
+
hotTableComponent.portalCache.set(portalKey, portal);
|
|
1860
|
+
}
|
|
1823
1861
|
}
|
|
1824
|
-
renderedCellCache.set(
|
|
1862
|
+
renderedCellCache.set(key, TD);
|
|
1825
1863
|
return TD;
|
|
1826
1864
|
};
|
|
1827
1865
|
}
|
|
@@ -1930,13 +1968,23 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1930
1968
|
if (globalEditorNode) {
|
|
1931
1969
|
newSettings.editor = this.getEditorClass(globalEditorNode, GLOBAL_EDITOR_SCOPE);
|
|
1932
1970
|
} else {
|
|
1933
|
-
|
|
1971
|
+
var _this$props$settings;
|
|
1972
|
+
if (this.props.editor || (_this$props$settings = this.props.settings) !== null && _this$props$settings !== void 0 && _this$props$settings.editor) {
|
|
1973
|
+
newSettings.editor = this.props.editor || this.props.settings.editor;
|
|
1974
|
+
} else {
|
|
1975
|
+
newSettings.editor = getEditor('text');
|
|
1976
|
+
}
|
|
1934
1977
|
}
|
|
1935
1978
|
if (globalRendererNode) {
|
|
1936
1979
|
newSettings.renderer = this.getRendererWrapper(globalRendererNode);
|
|
1937
1980
|
this.componentRendererColumns.set('global', true);
|
|
1938
1981
|
} else {
|
|
1939
|
-
|
|
1982
|
+
var _this$props$settings2;
|
|
1983
|
+
if (this.props.renderer || (_this$props$settings2 = this.props.settings) !== null && _this$props$settings2 !== void 0 && _this$props$settings2.renderer) {
|
|
1984
|
+
newSettings.renderer = this.props.renderer || this.props.settings.renderer;
|
|
1985
|
+
} else {
|
|
1986
|
+
newSettings.renderer = getRenderer('text');
|
|
1987
|
+
}
|
|
1940
1988
|
}
|
|
1941
1989
|
return newSettings;
|
|
1942
1990
|
}
|
|
@@ -1972,6 +2020,7 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1972
2020
|
}, {
|
|
1973
2021
|
key: "handsontableBeforeViewRender",
|
|
1974
2022
|
value: function handsontableBeforeViewRender() {
|
|
2023
|
+
this.portalCache.clear();
|
|
1975
2024
|
this.getRenderedCellCache().clear();
|
|
1976
2025
|
}
|
|
1977
2026
|
/**
|
|
@@ -1980,11 +2029,8 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1980
2029
|
}, {
|
|
1981
2030
|
key: "handsontableAfterViewRender",
|
|
1982
2031
|
value: function handsontableAfterViewRender() {
|
|
1983
|
-
var _this3 = this;
|
|
1984
2032
|
this.renderersPortalManager.setState({
|
|
1985
|
-
portals: _toConsumableArray(this.
|
|
1986
|
-
}, function () {
|
|
1987
|
-
_this3.portalCacheArray = [];
|
|
2033
|
+
portals: _toConsumableArray(this.portalCache.values())
|
|
1988
2034
|
});
|
|
1989
2035
|
}
|
|
1990
2036
|
/**
|
|
@@ -2020,14 +2066,14 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
2020
2066
|
}, {
|
|
2021
2067
|
key: "componentDidMount",
|
|
2022
2068
|
value: function componentDidMount() {
|
|
2023
|
-
var
|
|
2069
|
+
var _this3 = this;
|
|
2024
2070
|
var newGlobalSettings = this.createNewGlobalSettings();
|
|
2025
2071
|
this.hotInstance = new Handsontable.Core(this.hotElementRef, newGlobalSettings);
|
|
2026
2072
|
this.hotInstance.addHook('beforeViewRender', function () {
|
|
2027
|
-
return
|
|
2073
|
+
return _this3.handsontableBeforeViewRender();
|
|
2028
2074
|
});
|
|
2029
2075
|
this.hotInstance.addHook('afterViewRender', function () {
|
|
2030
|
-
return
|
|
2076
|
+
return _this3.handsontableAfterViewRender();
|
|
2031
2077
|
});
|
|
2032
2078
|
// `init` missing in Handsontable's type definitions.
|
|
2033
2079
|
this.hotInstance.init();
|
|
@@ -2061,7 +2107,7 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
2061
2107
|
}, {
|
|
2062
2108
|
key: "render",
|
|
2063
2109
|
value: function render() {
|
|
2064
|
-
var
|
|
2110
|
+
var _this4 = this;
|
|
2065
2111
|
var isHotColumn = function isHotColumn(childNode) {
|
|
2066
2112
|
return childNode.type === HotColumn;
|
|
2067
2113
|
};
|
|
@@ -2071,14 +2117,14 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
2071
2117
|
return isHotColumn(childNode);
|
|
2072
2118
|
}).map(function (childNode, columnIndex) {
|
|
2073
2119
|
return React.cloneElement(childNode, {
|
|
2074
|
-
_componentRendererColumns:
|
|
2075
|
-
_emitColumnSettings:
|
|
2120
|
+
_componentRendererColumns: _this4.componentRendererColumns,
|
|
2121
|
+
_emitColumnSettings: _this4.setHotColumnSettings.bind(_this4),
|
|
2076
2122
|
_columnIndex: columnIndex,
|
|
2077
|
-
_getChildElementByType: getChildElementByType.bind(
|
|
2078
|
-
_getRendererWrapper:
|
|
2079
|
-
_getEditorClass:
|
|
2080
|
-
_getOwnerDocument:
|
|
2081
|
-
_getEditorCache:
|
|
2123
|
+
_getChildElementByType: getChildElementByType.bind(_this4),
|
|
2124
|
+
_getRendererWrapper: _this4.getRendererWrapper.bind(_this4),
|
|
2125
|
+
_getEditorClass: _this4.getEditorClass.bind(_this4),
|
|
2126
|
+
_getOwnerDocument: _this4.getOwnerDocument.bind(_this4),
|
|
2127
|
+
_getEditorCache: _this4.getEditorCache.bind(_this4),
|
|
2082
2128
|
children: childNode.props.children
|
|
2083
2129
|
});
|
|
2084
2130
|
});
|
|
@@ -2390,4 +2436,4 @@ var BaseEditorComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
2390
2436
|
return BaseEditorComponent;
|
|
2391
2437
|
}(React.Component);
|
|
2392
2438
|
|
|
2393
|
-
export { BaseEditorComponent, HotColumn, HotTable, HotTable as default };
|
|
2439
|
+
export { BaseEditorComponent, HotColumn, HotTable, HotTableClass, HotTable as default };
|
package/helpers.d.ts
CHANGED
|
@@ -61,9 +61,11 @@ export declare function getExtendedEditorElement(children: React.ReactNode, edit
|
|
|
61
61
|
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
62
62
|
* @param {Object} props Props to be passed to the cloned element.
|
|
63
63
|
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
64
|
+
* @param {String} portalKey The key to be used for the portal.
|
|
65
|
+
* @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
|
|
64
66
|
* @returns {{portal: React.ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
65
67
|
*/
|
|
66
|
-
export declare function createPortal(rElement: React.ReactElement, props: any, ownerDocument?:
|
|
68
|
+
export declare function createPortal(rElement: React.ReactElement, props: any, ownerDocument: Document, portalKey: string, cachedContainer?: HTMLElement): {
|
|
67
69
|
portal: React.ReactPortal;
|
|
68
70
|
portalContainer: HTMLElement;
|
|
69
71
|
};
|
package/hotTableClass.d.ts
CHANGED
|
@@ -69,9 +69,17 @@ declare class HotTableClass extends React.Component<HotTableProps, {}> {
|
|
|
69
69
|
*/
|
|
70
70
|
renderersPortalManager: RenderersPortalManager;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Map that stores React portals.
|
|
73
|
+
* @type {Map<string, React.ReactPortal>}
|
|
73
74
|
*/
|
|
74
|
-
|
|
75
|
+
portalCache: Map<string, React.ReactPortal>;
|
|
76
|
+
/**
|
|
77
|
+
* Portal Container Cache
|
|
78
|
+
*
|
|
79
|
+
* @private
|
|
80
|
+
* @type {Map}
|
|
81
|
+
*/
|
|
82
|
+
private portalContainerCache;
|
|
75
83
|
/**
|
|
76
84
|
* The rendered cells cache.
|
|
77
85
|
*
|
|
@@ -113,6 +121,12 @@ declare class HotTableClass extends React.Component<HotTableProps, {}> {
|
|
|
113
121
|
* Prop types to be checked at runtime.
|
|
114
122
|
*/
|
|
115
123
|
static propTypes: object;
|
|
124
|
+
/**
|
|
125
|
+
* Get Portal Container Cache
|
|
126
|
+
*
|
|
127
|
+
* @returns {Map}
|
|
128
|
+
*/
|
|
129
|
+
getPortalContainerCache(): Map<string, HTMLElement>;
|
|
116
130
|
/**
|
|
117
131
|
* Get the rendered table cell cache.
|
|
118
132
|
*
|
|
@@ -147,7 +161,7 @@ declare class HotTableClass extends React.Component<HotTableProps, {}> {
|
|
|
147
161
|
* @param {React.ReactElement} rendererElement React renderer component.
|
|
148
162
|
* @returns {Handsontable.renderers.Base} The Handsontable rendering function.
|
|
149
163
|
*/
|
|
150
|
-
getRendererWrapper(rendererElement: React.ReactElement): typeof Handsontable.renderers.BaseRenderer
|
|
164
|
+
getRendererWrapper(rendererElement: React.ReactElement): typeof Handsontable.renderers.BaseRenderer;
|
|
151
165
|
/**
|
|
152
166
|
* Create a fresh class to be used as an editor, based on the provided editor React element.
|
|
153
167
|
*
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handsontable/react",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.0-next-7ae341f-20240229",
|
|
4
4
|
"description": "Best Data Grid for React with Spreadsheet Look and Feel.",
|
|
5
5
|
"author": "Handsoncode <hello@handsoncode.net> (https://handsoncode.net)",
|
|
6
6
|
"homepage": "https://handsontable.com",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"babel-core": "^7.0.0-bridge.0",
|
|
69
69
|
"cpy-cli": "^3.1.1",
|
|
70
70
|
"cross-env": "^7.0.3",
|
|
71
|
-
"handsontable": "
|
|
71
|
+
"handsontable": "14.2.0-next-7ae341f-20240229",
|
|
72
72
|
"jest": "^25.1.0",
|
|
73
73
|
"prop-types": "^15.7.2",
|
|
74
74
|
"react": "^18.2.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"uglify-js": "^3.4.9"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
|
-
"handsontable": "
|
|
92
|
+
"handsontable": "14.2.0-next-7ae341f-20240229"
|
|
93
93
|
},
|
|
94
94
|
"scripts": {
|
|
95
95
|
"build": "npm run clean && npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:min",
|