@handsontable/react 12.3.1 → 12.3.2-next-e75de58-20230322
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/baseEditorComponent.d.ts +7 -2
- package/commonjs/react-handsontable.js +169 -242
- package/dist/react-handsontable.js +170 -243
- 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/editorsPortalManager.d.ts +12 -0
- package/es/react-handsontable.mjs +169 -242
- package/helpers.d.ts +6 -22
- package/hotColumn.d.ts +10 -32
- package/hotTable.d.ts +18 -40
- package/package.json +9 -9
- package/renderersPortalManager.d.ts +12 -0
- package/portalManager.d.ts +0 -10
|
@@ -213,48 +213,22 @@ function getOriginalEditorClass(editorElement) {
|
|
|
213
213
|
}
|
|
214
214
|
return editorElement.type.WrappedComponent ? editorElement.type.WrappedComponent : editorElement.type;
|
|
215
215
|
}
|
|
216
|
-
/**
|
|
217
|
-
* Remove editor containers from DOM.
|
|
218
|
-
*
|
|
219
|
-
* @param {Document} [doc] Document to be used.
|
|
220
|
-
* @param {Map} editorCache The editor cache reference.
|
|
221
|
-
*/
|
|
222
|
-
function removeEditorContainers() {
|
|
223
|
-
var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
|
224
|
-
doc.querySelectorAll("[class^=\"".concat(DEFAULT_CLASSNAME, "\"]")).forEach(function (domNode) {
|
|
225
|
-
if (domNode.parentNode) {
|
|
226
|
-
domNode.parentNode.removeChild(domNode);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
216
|
/**
|
|
231
217
|
* Create an editor portal.
|
|
232
218
|
*
|
|
233
219
|
* @param {Document} [doc] Document to be used.
|
|
234
220
|
* @param {React.ReactElement} editorElement Editor's element.
|
|
235
|
-
* @param {Map} editorCache The editor cache reference.
|
|
236
221
|
* @returns {React.ReactPortal} The portal for the editor.
|
|
237
222
|
*/
|
|
238
223
|
function createEditorPortal() {
|
|
239
224
|
var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
|
240
225
|
var editorElement = arguments.length > 1 ? arguments[1] : undefined;
|
|
241
226
|
if (editorElement === null) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
var editorContainer = doc.createElement('DIV');
|
|
245
|
-
var _getContainerAttribut = getContainerAttributesProps(editorElement.props, false),
|
|
246
|
-
id = _getContainerAttribut.id,
|
|
247
|
-
className = _getContainerAttribut.className,
|
|
248
|
-
style = _getContainerAttribut.style;
|
|
249
|
-
if (id) {
|
|
250
|
-
editorContainer.id = id;
|
|
251
|
-
}
|
|
252
|
-
editorContainer.className = [DEFAULT_CLASSNAME, className].join(' ');
|
|
253
|
-
if (style) {
|
|
254
|
-
Object.assign(editorContainer.style, style);
|
|
227
|
+
return null;
|
|
255
228
|
}
|
|
256
|
-
|
|
257
|
-
|
|
229
|
+
var containerProps = getContainerAttributesProps(editorElement.props, false);
|
|
230
|
+
containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
|
|
231
|
+
return ReactDOM.createPortal(React.createElement("div", Object.assign({}, containerProps), editorElement), doc.body);
|
|
258
232
|
}
|
|
259
233
|
/**
|
|
260
234
|
* Get an editor element extended with a instance-emitting method.
|
|
@@ -289,12 +263,11 @@ function getExtendedEditorElement(children, editorCache) {
|
|
|
289
263
|
*
|
|
290
264
|
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
291
265
|
* @param {Object} props Props to be passed to the cloned element.
|
|
292
|
-
* @param {Function} callback Callback to be called after the component has been mounted.
|
|
293
266
|
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
294
267
|
* @returns {{portal: React.ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
295
268
|
*/
|
|
296
|
-
function createPortal(rElement, props
|
|
297
|
-
var ownerDocument = arguments.length >
|
|
269
|
+
function createPortal(rElement, props) {
|
|
270
|
+
var ownerDocument = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document;
|
|
298
271
|
if (!ownerDocument) {
|
|
299
272
|
ownerDocument = document;
|
|
300
273
|
}
|
|
@@ -328,23 +301,6 @@ function getContainerAttributesProps(props) {
|
|
|
328
301
|
style: props.style || {}
|
|
329
302
|
};
|
|
330
303
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Add the `UNSAFE_` prefixes to the deprecated lifecycle methods for React >= 16.3.
|
|
333
|
-
*
|
|
334
|
-
* @param {Object} instance Instance to have the methods renamed.
|
|
335
|
-
*/
|
|
336
|
-
function addUnsafePrefixes(instance) {
|
|
337
|
-
var reactSemverArray = React.version.split('.').map(function (v) {
|
|
338
|
-
return parseInt(v);
|
|
339
|
-
});
|
|
340
|
-
var shouldPrefix = reactSemverArray[0] >= 16 && reactSemverArray[1] >= 3 || reactSemverArray[0] >= 17;
|
|
341
|
-
if (shouldPrefix) {
|
|
342
|
-
instance.UNSAFE_componentWillUpdate = instance.componentWillUpdate;
|
|
343
|
-
instance.componentWillUpdate = void 0;
|
|
344
|
-
instance.UNSAFE_componentWillMount = instance.componentWillMount;
|
|
345
|
-
instance.componentWillMount = void 0;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
304
|
|
|
349
305
|
var SettingsMapper = /*#__PURE__*/function () {
|
|
350
306
|
function SettingsMapper() {
|
|
@@ -380,48 +336,54 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
380
336
|
return SettingsMapper;
|
|
381
337
|
}();
|
|
382
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Component class used to manage the editor component portals.
|
|
341
|
+
*/
|
|
342
|
+
var EditorsPortalManager = /*#__PURE__*/function (_React$Component) {
|
|
343
|
+
_inherits(EditorsPortalManager, _React$Component);
|
|
344
|
+
var _super = _createSuper(EditorsPortalManager);
|
|
345
|
+
function EditorsPortalManager() {
|
|
346
|
+
var _this;
|
|
347
|
+
_classCallCheck(this, EditorsPortalManager);
|
|
348
|
+
_this = _super.apply(this, arguments);
|
|
349
|
+
_this.state = {
|
|
350
|
+
portals: []
|
|
351
|
+
};
|
|
352
|
+
return _this;
|
|
353
|
+
}
|
|
354
|
+
_createClass(EditorsPortalManager, [{
|
|
355
|
+
key: "render",
|
|
356
|
+
value: function render() {
|
|
357
|
+
return React.createElement(React.Fragment, null, this.state.portals);
|
|
358
|
+
}
|
|
359
|
+
}]);
|
|
360
|
+
return EditorsPortalManager;
|
|
361
|
+
}(React.Component);
|
|
362
|
+
|
|
383
363
|
var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
384
364
|
_inherits(HotColumn, _React$Component);
|
|
385
365
|
var _super = _createSuper(HotColumn);
|
|
386
|
-
|
|
387
|
-
* HotColumn class constructor.
|
|
388
|
-
*
|
|
389
|
-
* @param {HotColumnProps} props Component props.
|
|
390
|
-
* @param {*} [context] Component context.
|
|
391
|
-
*/
|
|
392
|
-
function HotColumn(props, context) {
|
|
366
|
+
function HotColumn() {
|
|
393
367
|
var _this;
|
|
394
368
|
_classCallCheck(this, HotColumn);
|
|
395
|
-
_this = _super.
|
|
369
|
+
_this = _super.apply(this, arguments);
|
|
396
370
|
/**
|
|
397
|
-
*
|
|
371
|
+
* Component used to manage the editor portals.
|
|
398
372
|
*
|
|
399
|
-
* @
|
|
400
|
-
* @type {ReactPortal}
|
|
373
|
+
* @type {React.Component}
|
|
401
374
|
*/
|
|
402
|
-
_this.
|
|
403
|
-
addUnsafePrefixes(_assertThisInitialized(_this));
|
|
375
|
+
_this.editorsPortalManager = null;
|
|
404
376
|
return _this;
|
|
405
377
|
}
|
|
406
378
|
/**
|
|
407
|
-
*
|
|
379
|
+
* Set the editors portal manager ref.
|
|
408
380
|
*
|
|
409
|
-
* @
|
|
381
|
+
* @param {React.ReactComponent} pmComponent The PortalManager component.
|
|
410
382
|
*/
|
|
411
383
|
_createClass(HotColumn, [{
|
|
412
|
-
key: "
|
|
413
|
-
value: function
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Set the local editor portal cache property.
|
|
418
|
-
*
|
|
419
|
-
* @param {ReactPortal} portal Local editor portal.
|
|
420
|
-
*/
|
|
421
|
-
}, {
|
|
422
|
-
key: "setLocalEditorPortal",
|
|
423
|
-
value: function setLocalEditorPortal(portal) {
|
|
424
|
-
this.localEditorPortal = portal;
|
|
384
|
+
key: "setEditorsPortalManagerRef",
|
|
385
|
+
value: function setEditorsPortalManagerRef(pmComponent) {
|
|
386
|
+
this.editorsPortalManager = pmComponent;
|
|
425
387
|
}
|
|
426
388
|
/**
|
|
427
389
|
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
@@ -432,7 +394,7 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
432
394
|
key: "getSettingsProps",
|
|
433
395
|
value: function getSettingsProps() {
|
|
434
396
|
var _this2 = this;
|
|
435
|
-
this.internalProps = ['
|
|
397
|
+
this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
|
|
436
398
|
return Object.keys(this.props).filter(function (key) {
|
|
437
399
|
return !_this2.internalProps.includes(key);
|
|
438
400
|
}).reduce(function (obj, key) {
|
|
@@ -468,19 +430,19 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
468
430
|
}
|
|
469
431
|
}
|
|
470
432
|
/**
|
|
471
|
-
*
|
|
433
|
+
* Creates the local editor portal and renders it within the editors portal manager component.
|
|
472
434
|
*
|
|
473
|
-
* @param {
|
|
435
|
+
* @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
|
|
474
436
|
*/
|
|
475
437
|
}, {
|
|
476
|
-
key: "
|
|
477
|
-
value: function
|
|
478
|
-
var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.children;
|
|
438
|
+
key: "renderLocalEditorPortal",
|
|
439
|
+
value: function renderLocalEditorPortal(callback) {
|
|
479
440
|
var editorCache = this.props._getEditorCache();
|
|
480
|
-
var localEditorElement = getExtendedEditorElement(children, editorCache, this.props._columnIndex);
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
441
|
+
var localEditorElement = getExtendedEditorElement(this.props.children, editorCache, this.props._columnIndex);
|
|
442
|
+
var editorPortal = createEditorPortal(this.props._getOwnerDocument(), localEditorElement);
|
|
443
|
+
this.editorsPortalManager.setState({
|
|
444
|
+
portals: [editorPortal]
|
|
445
|
+
}, callback);
|
|
484
446
|
}
|
|
485
447
|
/**
|
|
486
448
|
* Emit the column settings to the parent using a prop passed from the parent.
|
|
@@ -495,30 +457,17 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
495
457
|
------- React lifecycle methods -------
|
|
496
458
|
---------------------------------------
|
|
497
459
|
*/
|
|
498
|
-
/**
|
|
499
|
-
* Logic performed before the mounting of the HotColumn component.
|
|
500
|
-
*/
|
|
501
|
-
}, {
|
|
502
|
-
key: "componentWillMount",
|
|
503
|
-
value: function componentWillMount() {
|
|
504
|
-
this.createLocalEditorPortal();
|
|
505
|
-
}
|
|
506
460
|
/**
|
|
507
461
|
* Logic performed after the mounting of the HotColumn component.
|
|
508
462
|
*/
|
|
509
463
|
}, {
|
|
510
464
|
key: "componentDidMount",
|
|
511
465
|
value: function componentDidMount() {
|
|
512
|
-
this
|
|
513
|
-
this.
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
*/
|
|
518
|
-
}, {
|
|
519
|
-
key: "componentWillUpdate",
|
|
520
|
-
value: function componentWillUpdate(nextProps, nextState, nextContext) {
|
|
521
|
-
this.createLocalEditorPortal(nextProps.children);
|
|
466
|
+
var _this3 = this;
|
|
467
|
+
this.renderLocalEditorPortal(function () {
|
|
468
|
+
_this3.createColumnSettings();
|
|
469
|
+
_this3.emitColumnSettings();
|
|
470
|
+
});
|
|
522
471
|
}
|
|
523
472
|
/**
|
|
524
473
|
* Logic performed after the updating of the HotColumn component.
|
|
@@ -526,8 +475,11 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
526
475
|
}, {
|
|
527
476
|
key: "componentDidUpdate",
|
|
528
477
|
value: function componentDidUpdate() {
|
|
529
|
-
this
|
|
530
|
-
this.
|
|
478
|
+
var _this4 = this;
|
|
479
|
+
this.renderLocalEditorPortal(function () {
|
|
480
|
+
_this4.createColumnSettings();
|
|
481
|
+
_this4.emitColumnSettings();
|
|
482
|
+
});
|
|
531
483
|
}
|
|
532
484
|
/**
|
|
533
485
|
* Render the portals of the editors, if there are any.
|
|
@@ -537,7 +489,9 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
537
489
|
}, {
|
|
538
490
|
key: "render",
|
|
539
491
|
value: function render() {
|
|
540
|
-
return React.createElement(React.Fragment, null,
|
|
492
|
+
return React.createElement(React.Fragment, null, React.createElement(EditorsPortalManager, {
|
|
493
|
+
ref: this.setEditorsPortalManagerRef.bind(this)
|
|
494
|
+
}));
|
|
541
495
|
}
|
|
542
496
|
}]);
|
|
543
497
|
return HotColumn;
|
|
@@ -546,28 +500,28 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
546
500
|
/**
|
|
547
501
|
* Component class used to manage the renderer component portals.
|
|
548
502
|
*/
|
|
549
|
-
var
|
|
550
|
-
_inherits(
|
|
551
|
-
var _super = _createSuper(
|
|
552
|
-
function
|
|
503
|
+
var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
|
|
504
|
+
_inherits(RenderersPortalManager, _React$Component);
|
|
505
|
+
var _super = _createSuper(RenderersPortalManager);
|
|
506
|
+
function RenderersPortalManager() {
|
|
553
507
|
var _this;
|
|
554
|
-
_classCallCheck(this,
|
|
555
|
-
_this = _super.
|
|
508
|
+
_classCallCheck(this, RenderersPortalManager);
|
|
509
|
+
_this = _super.apply(this, arguments);
|
|
556
510
|
_this.state = {
|
|
557
511
|
portals: []
|
|
558
512
|
};
|
|
559
513
|
return _this;
|
|
560
514
|
}
|
|
561
|
-
_createClass(
|
|
515
|
+
_createClass(RenderersPortalManager, [{
|
|
562
516
|
key: "render",
|
|
563
517
|
value: function render() {
|
|
564
518
|
return React.createElement(React.Fragment, null, this.state.portals);
|
|
565
519
|
}
|
|
566
520
|
}]);
|
|
567
|
-
return
|
|
521
|
+
return RenderersPortalManager;
|
|
568
522
|
}(React.Component);
|
|
569
523
|
|
|
570
|
-
var version="12.3.
|
|
524
|
+
var version="12.3.2-next-e75de58-20230322";
|
|
571
525
|
|
|
572
526
|
function createCommonjsModule(fn, module) {
|
|
573
527
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
@@ -1713,16 +1667,10 @@ var PropTypes = propTypes;
|
|
|
1713
1667
|
var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
1714
1668
|
_inherits(HotTable, _React$Component);
|
|
1715
1669
|
var _super = _createSuper(HotTable);
|
|
1716
|
-
|
|
1717
|
-
* HotTable class constructor.
|
|
1718
|
-
*
|
|
1719
|
-
* @param {HotTableProps} props Component props.
|
|
1720
|
-
* @param {*} [context] Component context.
|
|
1721
|
-
*/
|
|
1722
|
-
function HotTable(props, context) {
|
|
1670
|
+
function HotTable() {
|
|
1723
1671
|
var _this;
|
|
1724
1672
|
_classCallCheck(this, HotTable);
|
|
1725
|
-
_this = _super.
|
|
1673
|
+
_this = _super.apply(this, arguments);
|
|
1726
1674
|
/**
|
|
1727
1675
|
* The `id` of the main Handsontable DOM element.
|
|
1728
1676
|
*
|
|
@@ -1753,18 +1701,17 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1753
1701
|
*
|
|
1754
1702
|
* @type {React.Component}
|
|
1755
1703
|
*/
|
|
1756
|
-
_this.
|
|
1704
|
+
_this.renderersPortalManager = null;
|
|
1757
1705
|
/**
|
|
1758
|
-
*
|
|
1706
|
+
* Component used to manage the editor portals.
|
|
1707
|
+
*
|
|
1708
|
+
* @type {React.Component}
|
|
1759
1709
|
*/
|
|
1760
|
-
_this.
|
|
1710
|
+
_this.editorsPortalManager = null;
|
|
1761
1711
|
/**
|
|
1762
|
-
*
|
|
1763
|
-
*
|
|
1764
|
-
* @private
|
|
1765
|
-
* @type {React.ReactPortal}
|
|
1712
|
+
* Array containing the portals cashed to be rendered in bulk after Handsontable's render cycle.
|
|
1766
1713
|
*/
|
|
1767
|
-
_this.
|
|
1714
|
+
_this.portalCacheArray = [];
|
|
1768
1715
|
/**
|
|
1769
1716
|
* The rendered cells cache.
|
|
1770
1717
|
*
|
|
@@ -1787,7 +1734,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1787
1734
|
* @type {Map}
|
|
1788
1735
|
*/
|
|
1789
1736
|
_this.componentRendererColumns = new Map();
|
|
1790
|
-
addUnsafePrefixes(_assertThisInitialized(_this));
|
|
1791
1737
|
return _this;
|
|
1792
1738
|
}
|
|
1793
1739
|
/**
|
|
@@ -1837,37 +1783,14 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1837
1783
|
value: function getEditorCache() {
|
|
1838
1784
|
return this.editorCache;
|
|
1839
1785
|
}
|
|
1840
|
-
/**
|
|
1841
|
-
* Get the global editor portal property.
|
|
1842
|
-
*
|
|
1843
|
-
* @return {React.ReactPortal} The global editor portal.
|
|
1844
|
-
*/
|
|
1845
|
-
}, {
|
|
1846
|
-
key: "getGlobalEditorPortal",
|
|
1847
|
-
value: function getGlobalEditorPortal() {
|
|
1848
|
-
return this.globalEditorPortal;
|
|
1849
|
-
}
|
|
1850
|
-
/**
|
|
1851
|
-
* Set the private editor portal cache property.
|
|
1852
|
-
*
|
|
1853
|
-
* @param {React.ReactPortal} portal Global editor portal.
|
|
1854
|
-
*/
|
|
1855
|
-
}, {
|
|
1856
|
-
key: "setGlobalEditorPortal",
|
|
1857
|
-
value: function setGlobalEditorPortal(portal) {
|
|
1858
|
-
this.globalEditorPortal = portal;
|
|
1859
|
-
}
|
|
1860
1786
|
/**
|
|
1861
1787
|
* Clear both the editor and the renderer cache.
|
|
1862
1788
|
*/
|
|
1863
1789
|
}, {
|
|
1864
1790
|
key: "clearCache",
|
|
1865
1791
|
value: function clearCache() {
|
|
1866
|
-
var renderedCellCache = this.getRenderedCellCache();
|
|
1867
|
-
this.setGlobalEditorPortal(null);
|
|
1868
|
-
removeEditorContainers(this.getOwnerDocument());
|
|
1869
1792
|
this.getEditorCache().clear();
|
|
1870
|
-
|
|
1793
|
+
this.getRenderedCellCache().clear();
|
|
1871
1794
|
this.componentRendererColumns.clear();
|
|
1872
1795
|
}
|
|
1873
1796
|
/**
|
|
@@ -1914,7 +1837,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1914
1837
|
value: value,
|
|
1915
1838
|
cellProperties: cellProperties,
|
|
1916
1839
|
isRenderer: true
|
|
1917
|
-
},
|
|
1840
|
+
}, TD.ownerDocument),
|
|
1918
1841
|
portal = _createPortal.portal,
|
|
1919
1842
|
portalContainer = _createPortal.portalContainer;
|
|
1920
1843
|
while (TD.firstChild) {
|
|
@@ -1938,11 +1861,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1938
1861
|
}, {
|
|
1939
1862
|
key: "getEditorClass",
|
|
1940
1863
|
value: function getEditorClass(editorElement) {
|
|
1941
|
-
var
|
|
1864
|
+
var _this$getEditorCache$;
|
|
1942
1865
|
var editorColumnScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GLOBAL_EDITOR_SCOPE;
|
|
1943
1866
|
var editorClass = getOriginalEditorClass(editorElement);
|
|
1944
|
-
var
|
|
1945
|
-
var cachedComponent = (_editorCache$get = editorCache.get(editorClass)) === null || _editorCache$get === void 0 ? void 0 : _editorCache$get.get(editorColumnScope);
|
|
1867
|
+
var cachedComponent = (_this$getEditorCache$ = this.getEditorCache().get(editorClass)) === null || _this$getEditorCache$ === void 0 ? void 0 : _this$getEditorCache$.get(editorColumnScope);
|
|
1946
1868
|
return this.makeEditorClass(cachedComponent);
|
|
1947
1869
|
}
|
|
1948
1870
|
/**
|
|
@@ -2006,8 +1928,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
2006
1928
|
}, {
|
|
2007
1929
|
key: "getGlobalRendererElement",
|
|
2008
1930
|
value: function getGlobalRendererElement() {
|
|
2009
|
-
|
|
2010
|
-
return getChildElementByType(hotTableSlots, 'hot-renderer');
|
|
1931
|
+
return getChildElementByType(this.props.children, 'hot-renderer');
|
|
2011
1932
|
}
|
|
2012
1933
|
/**
|
|
2013
1934
|
* Get the editor element for the entire HotTable instance.
|
|
@@ -2018,22 +1939,21 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
2018
1939
|
}, {
|
|
2019
1940
|
key: "getGlobalEditorElement",
|
|
2020
1941
|
value: function getGlobalEditorElement() {
|
|
2021
|
-
|
|
2022
|
-
return getExtendedEditorElement(children, this.getEditorCache());
|
|
1942
|
+
return getExtendedEditorElement(this.props.children, this.getEditorCache());
|
|
2023
1943
|
}
|
|
2024
1944
|
/**
|
|
2025
|
-
*
|
|
1945
|
+
* Creates the global editor portal and renders it within the editors portal manager component.
|
|
2026
1946
|
*
|
|
2027
|
-
* @param {
|
|
1947
|
+
* @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
|
|
2028
1948
|
*/
|
|
2029
1949
|
}, {
|
|
2030
|
-
key: "
|
|
2031
|
-
value: function
|
|
2032
|
-
var
|
|
2033
|
-
var
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
}
|
|
1950
|
+
key: "renderGlobalEditorPortal",
|
|
1951
|
+
value: function renderGlobalEditorPortal(callback) {
|
|
1952
|
+
var globalEditorElement = this.getGlobalEditorElement();
|
|
1953
|
+
var editorPortal = createEditorPortal(this.getOwnerDocument(), globalEditorElement);
|
|
1954
|
+
this.editorsPortalManager.setState({
|
|
1955
|
+
portals: [editorPortal]
|
|
1956
|
+
}, callback);
|
|
2037
1957
|
}
|
|
2038
1958
|
/**
|
|
2039
1959
|
* Create a new settings object containing the column settings and global editors and renderers.
|
|
@@ -2101,7 +2021,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
2101
2021
|
key: "handsontableAfterViewRender",
|
|
2102
2022
|
value: function handsontableAfterViewRender() {
|
|
2103
2023
|
var _this3 = this;
|
|
2104
|
-
this.
|
|
2024
|
+
this.renderersPortalManager.setState(function () {
|
|
2105
2025
|
return Object.assign({}, {
|
|
2106
2026
|
portals: _this3.portalCacheArray
|
|
2107
2027
|
});
|
|
@@ -2122,57 +2042,56 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
2122
2042
|
}
|
|
2123
2043
|
}
|
|
2124
2044
|
/**
|
|
2125
|
-
* Set the portal manager ref.
|
|
2045
|
+
* Set the renderers portal manager ref.
|
|
2126
2046
|
*
|
|
2127
2047
|
* @param {React.ReactComponent} pmComponent The PortalManager component.
|
|
2128
2048
|
*/
|
|
2129
2049
|
}, {
|
|
2130
|
-
key: "
|
|
2131
|
-
value: function
|
|
2132
|
-
this.
|
|
2050
|
+
key: "setRenderersPortalManagerRef",
|
|
2051
|
+
value: function setRenderersPortalManagerRef(pmComponent) {
|
|
2052
|
+
this.renderersPortalManager = pmComponent;
|
|
2053
|
+
}
|
|
2054
|
+
/**
|
|
2055
|
+
* Set the editors portal manager ref.
|
|
2056
|
+
*
|
|
2057
|
+
* @param {React.ReactComponent} pmComponent The PortalManager component.
|
|
2058
|
+
*/
|
|
2059
|
+
}, {
|
|
2060
|
+
key: "setEditorsPortalManagerRef",
|
|
2061
|
+
value: function setEditorsPortalManagerRef(pmComponent) {
|
|
2062
|
+
this.editorsPortalManager = pmComponent;
|
|
2133
2063
|
}
|
|
2134
2064
|
/*
|
|
2135
2065
|
---------------------------------------
|
|
2136
2066
|
------- React lifecycle methods -------
|
|
2137
2067
|
---------------------------------------
|
|
2138
2068
|
*/
|
|
2139
|
-
/**
|
|
2140
|
-
* Logic performed before the mounting of the component.
|
|
2141
|
-
*/
|
|
2142
|
-
}, {
|
|
2143
|
-
key: "componentWillMount",
|
|
2144
|
-
value: function componentWillMount() {
|
|
2145
|
-
this.clearCache();
|
|
2146
|
-
this.createGlobalEditorPortal();
|
|
2147
|
-
}
|
|
2148
2069
|
/**
|
|
2149
2070
|
* Initialize Handsontable after the component has mounted.
|
|
2150
2071
|
*/
|
|
2151
2072
|
}, {
|
|
2152
2073
|
key: "componentDidMount",
|
|
2153
2074
|
value: function componentDidMount() {
|
|
2154
|
-
var
|
|
2155
|
-
var newGlobalSettings = this.createNewGlobalSettings();
|
|
2156
|
-
this.hotInstance = new Handsontable.Core(this.hotElementRef, newGlobalSettings);
|
|
2157
|
-
this.hotInstance.addHook('beforeViewRender', function (isForced) {
|
|
2158
|
-
hotTableComponent.handsontableBeforeViewRender();
|
|
2159
|
-
});
|
|
2160
|
-
this.hotInstance.addHook('afterViewRender', function () {
|
|
2161
|
-
hotTableComponent.handsontableAfterViewRender();
|
|
2162
|
-
});
|
|
2163
|
-
// `init` missing in Handsontable's type definitions.
|
|
2164
|
-
this.hotInstance.init();
|
|
2165
|
-
this.displayAutoSizeWarning(newGlobalSettings);
|
|
2166
|
-
}
|
|
2167
|
-
/**
|
|
2168
|
-
* Logic performed before the component update.
|
|
2169
|
-
*/
|
|
2170
|
-
}, {
|
|
2171
|
-
key: "componentWillUpdate",
|
|
2172
|
-
value: function componentWillUpdate(nextProps, nextState, nextContext) {
|
|
2075
|
+
var _this4 = this;
|
|
2173
2076
|
this.clearCache();
|
|
2174
|
-
|
|
2175
|
-
|
|
2077
|
+
this.renderGlobalEditorPortal(function () {
|
|
2078
|
+
// In React strict mode the mount/unmount is triggered twice. The `if` prevents
|
|
2079
|
+
// creating two Handsontable instances for the same component in that mode.
|
|
2080
|
+
if (_this4.hotInstance) {
|
|
2081
|
+
return;
|
|
2082
|
+
}
|
|
2083
|
+
var newGlobalSettings = _this4.createNewGlobalSettings();
|
|
2084
|
+
_this4.hotInstance = new Handsontable.Core(_this4.hotElementRef, newGlobalSettings);
|
|
2085
|
+
_this4.hotInstance.addHook('beforeViewRender', function () {
|
|
2086
|
+
return _this4.handsontableBeforeViewRender();
|
|
2087
|
+
});
|
|
2088
|
+
_this4.hotInstance.addHook('afterViewRender', function () {
|
|
2089
|
+
return _this4.handsontableAfterViewRender();
|
|
2090
|
+
});
|
|
2091
|
+
// `init` missing in Handsontable's type definitions.
|
|
2092
|
+
_this4.hotInstance.init();
|
|
2093
|
+
_this4.displayAutoSizeWarning(newGlobalSettings);
|
|
2094
|
+
});
|
|
2176
2095
|
}
|
|
2177
2096
|
/**
|
|
2178
2097
|
* Logic performed after the component update.
|
|
@@ -2180,9 +2099,13 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
2180
2099
|
}, {
|
|
2181
2100
|
key: "componentDidUpdate",
|
|
2182
2101
|
value: function componentDidUpdate() {
|
|
2183
|
-
var
|
|
2184
|
-
this.
|
|
2185
|
-
this.
|
|
2102
|
+
var _this5 = this;
|
|
2103
|
+
this.clearCache();
|
|
2104
|
+
this.renderGlobalEditorPortal(function () {
|
|
2105
|
+
var newGlobalSettings = _this5.createNewGlobalSettings();
|
|
2106
|
+
_this5.updateHot(newGlobalSettings);
|
|
2107
|
+
_this5.displayAutoSizeWarning(newGlobalSettings);
|
|
2108
|
+
});
|
|
2186
2109
|
}
|
|
2187
2110
|
/**
|
|
2188
2111
|
* Destroy the Handsontable instance when the parent component unmounts.
|
|
@@ -2193,7 +2116,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
2193
2116
|
if (this.hotInstance) {
|
|
2194
2117
|
this.hotInstance.destroy();
|
|
2195
2118
|
}
|
|
2196
|
-
removeEditorContainers(this.getOwnerDocument());
|
|
2197
2119
|
}
|
|
2198
2120
|
/**
|
|
2199
2121
|
* Render the component.
|
|
@@ -2201,11 +2123,8 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
2201
2123
|
}, {
|
|
2202
2124
|
key: "render",
|
|
2203
2125
|
value: function render() {
|
|
2204
|
-
var
|
|
2205
|
-
var
|
|
2206
|
-
id = _getContainerAttribut.id,
|
|
2207
|
-
className = _getContainerAttribut.className,
|
|
2208
|
-
style = _getContainerAttribut.style;
|
|
2126
|
+
var _this6 = this;
|
|
2127
|
+
var containerProps = getContainerAttributesProps(this.props);
|
|
2209
2128
|
var isHotColumn = function isHotColumn(childNode) {
|
|
2210
2129
|
return childNode.type === HotColumn;
|
|
2211
2130
|
};
|
|
@@ -2217,26 +2136,23 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
2217
2136
|
// clone the HotColumn nodes and extend them with the callbacks
|
|
2218
2137
|
var childClones = children.map(function (childNode, columnIndex) {
|
|
2219
2138
|
return React.cloneElement(childNode, {
|
|
2220
|
-
_componentRendererColumns:
|
|
2221
|
-
_emitColumnSettings:
|
|
2139
|
+
_componentRendererColumns: _this6.componentRendererColumns,
|
|
2140
|
+
_emitColumnSettings: _this6.setHotColumnSettings.bind(_this6),
|
|
2222
2141
|
_columnIndex: columnIndex,
|
|
2223
|
-
_getChildElementByType: getChildElementByType.bind(
|
|
2224
|
-
_getRendererWrapper:
|
|
2225
|
-
_getEditorClass:
|
|
2226
|
-
_getOwnerDocument:
|
|
2227
|
-
_getEditorCache:
|
|
2142
|
+
_getChildElementByType: getChildElementByType.bind(_this6),
|
|
2143
|
+
_getRendererWrapper: _this6.getRendererWrapper.bind(_this6),
|
|
2144
|
+
_getEditorClass: _this6.getEditorClass.bind(_this6),
|
|
2145
|
+
_getOwnerDocument: _this6.getOwnerDocument.bind(_this6),
|
|
2146
|
+
_getEditorCache: _this6.getEditorCache.bind(_this6),
|
|
2228
2147
|
children: childNode.props.children
|
|
2229
2148
|
});
|
|
2230
2149
|
});
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
ref: this.
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
style: style
|
|
2238
|
-
}, childClones), React.createElement(PortalManager, {
|
|
2239
|
-
ref: this.setPortalManagerRef.bind(this)
|
|
2150
|
+
return React.createElement(React.Fragment, null, React.createElement("div", Object.assign({
|
|
2151
|
+
ref: this.setHotElementRef.bind(this)
|
|
2152
|
+
}, containerProps), childClones), React.createElement(RenderersPortalManager, {
|
|
2153
|
+
ref: this.setRenderersPortalManagerRef.bind(this)
|
|
2154
|
+
}), React.createElement(EditorsPortalManager, {
|
|
2155
|
+
ref: this.setEditorsPortalManagerRef.bind(this)
|
|
2240
2156
|
}));
|
|
2241
2157
|
}
|
|
2242
2158
|
}], [{
|
|
@@ -2259,10 +2175,10 @@ HotTable.propTypes = {
|
|
|
2259
2175
|
var BaseEditorComponent = /*#__PURE__*/function (_React$Component) {
|
|
2260
2176
|
_inherits(BaseEditorComponent, _React$Component);
|
|
2261
2177
|
var _super = _createSuper(BaseEditorComponent);
|
|
2262
|
-
function BaseEditorComponent(
|
|
2178
|
+
function BaseEditorComponent() {
|
|
2263
2179
|
var _this;
|
|
2264
2180
|
_classCallCheck(this, BaseEditorComponent);
|
|
2265
|
-
_this = _super.
|
|
2181
|
+
_this = _super.apply(this, arguments);
|
|
2266
2182
|
_this.name = 'BaseEditorComponent';
|
|
2267
2183
|
_this.instance = null;
|
|
2268
2184
|
_this.row = null;
|
|
@@ -2275,13 +2191,24 @@ var BaseEditorComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
2275
2191
|
_this.hotInstance = null;
|
|
2276
2192
|
_this.hotCustomEditorInstance = null;
|
|
2277
2193
|
_this.hot = null;
|
|
2278
|
-
if (props.emitEditorInstance) {
|
|
2279
|
-
props.emitEditorInstance(_assertThisInitialized(_this), props.editorColumnScope);
|
|
2280
|
-
}
|
|
2281
2194
|
return _this;
|
|
2282
2195
|
}
|
|
2283
|
-
// BaseEditor methods:
|
|
2284
2196
|
_createClass(BaseEditorComponent, [{
|
|
2197
|
+
key: "componentDidMount",
|
|
2198
|
+
value: function componentDidMount() {
|
|
2199
|
+
if (this.props.emitEditorInstance) {
|
|
2200
|
+
this.props.emitEditorInstance(this, this.props.editorColumnScope);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
}, {
|
|
2204
|
+
key: "componentDidUpdate",
|
|
2205
|
+
value: function componentDidUpdate() {
|
|
2206
|
+
if (this.props.emitEditorInstance) {
|
|
2207
|
+
this.props.emitEditorInstance(this, this.props.editorColumnScope);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
// BaseEditor methods:
|
|
2211
|
+
}, {
|
|
2285
2212
|
key: "_fireCallbacks",
|
|
2286
2213
|
value: function _fireCallbacks() {
|
|
2287
2214
|
var _Handsontable$editors;
|