@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
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM
|
|
26
26
|
* USE OR INABILITY TO USE THIS SOFTWARE.
|
|
27
27
|
*
|
|
28
|
-
* Version: 12.3.
|
|
28
|
+
* Version: 12.3.2-next-e75de58-20230322 (built at Wed Mar 22 2023 11:55:36 GMT+0000 (Coordinated Universal Time))
|
|
29
29
|
*/
|
|
30
30
|
(function (global, factory) {
|
|
31
31
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('handsontable/base')) :
|
|
@@ -250,48 +250,22 @@ function getOriginalEditorClass(editorElement) {
|
|
|
250
250
|
}
|
|
251
251
|
return editorElement.type.WrappedComponent ? editorElement.type.WrappedComponent : editorElement.type;
|
|
252
252
|
}
|
|
253
|
-
/**
|
|
254
|
-
* Remove editor containers from DOM.
|
|
255
|
-
*
|
|
256
|
-
* @param {Document} [doc] Document to be used.
|
|
257
|
-
* @param {Map} editorCache The editor cache reference.
|
|
258
|
-
*/
|
|
259
|
-
function removeEditorContainers() {
|
|
260
|
-
var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
|
261
|
-
doc.querySelectorAll("[class^=\"".concat(DEFAULT_CLASSNAME, "\"]")).forEach(function (domNode) {
|
|
262
|
-
if (domNode.parentNode) {
|
|
263
|
-
domNode.parentNode.removeChild(domNode);
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
253
|
/**
|
|
268
254
|
* Create an editor portal.
|
|
269
255
|
*
|
|
270
256
|
* @param {Document} [doc] Document to be used.
|
|
271
257
|
* @param {React.ReactElement} editorElement Editor's element.
|
|
272
|
-
* @param {Map} editorCache The editor cache reference.
|
|
273
258
|
* @returns {React.ReactPortal} The portal for the editor.
|
|
274
259
|
*/
|
|
275
260
|
function createEditorPortal() {
|
|
276
261
|
var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
|
277
262
|
var editorElement = arguments.length > 1 ? arguments[1] : undefined;
|
|
278
263
|
if (editorElement === null) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
var editorContainer = doc.createElement('DIV');
|
|
282
|
-
var _getContainerAttribut = getContainerAttributesProps(editorElement.props, false),
|
|
283
|
-
id = _getContainerAttribut.id,
|
|
284
|
-
className = _getContainerAttribut.className,
|
|
285
|
-
style = _getContainerAttribut.style;
|
|
286
|
-
if (id) {
|
|
287
|
-
editorContainer.id = id;
|
|
288
|
-
}
|
|
289
|
-
editorContainer.className = [DEFAULT_CLASSNAME, className].join(' ');
|
|
290
|
-
if (style) {
|
|
291
|
-
Object.assign(editorContainer.style, style);
|
|
264
|
+
return null;
|
|
292
265
|
}
|
|
293
|
-
|
|
294
|
-
|
|
266
|
+
var containerProps = getContainerAttributesProps(editorElement.props, false);
|
|
267
|
+
containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
|
|
268
|
+
return ReactDOM__default["default"].createPortal(React__default["default"].createElement("div", Object.assign({}, containerProps), editorElement), doc.body);
|
|
295
269
|
}
|
|
296
270
|
/**
|
|
297
271
|
* Get an editor element extended with a instance-emitting method.
|
|
@@ -326,12 +300,11 @@ function getExtendedEditorElement(children, editorCache) {
|
|
|
326
300
|
*
|
|
327
301
|
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
328
302
|
* @param {Object} props Props to be passed to the cloned element.
|
|
329
|
-
* @param {Function} callback Callback to be called after the component has been mounted.
|
|
330
303
|
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
331
304
|
* @returns {{portal: React.ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
332
305
|
*/
|
|
333
|
-
function createPortal(rElement, props
|
|
334
|
-
var ownerDocument = arguments.length >
|
|
306
|
+
function createPortal(rElement, props) {
|
|
307
|
+
var ownerDocument = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document;
|
|
335
308
|
if (!ownerDocument) {
|
|
336
309
|
ownerDocument = document;
|
|
337
310
|
}
|
|
@@ -365,23 +338,6 @@ function getContainerAttributesProps(props) {
|
|
|
365
338
|
style: props.style || {}
|
|
366
339
|
};
|
|
367
340
|
}
|
|
368
|
-
/**
|
|
369
|
-
* Add the `UNSAFE_` prefixes to the deprecated lifecycle methods for React >= 16.3.
|
|
370
|
-
*
|
|
371
|
-
* @param {Object} instance Instance to have the methods renamed.
|
|
372
|
-
*/
|
|
373
|
-
function addUnsafePrefixes(instance) {
|
|
374
|
-
var reactSemverArray = React__default["default"].version.split('.').map(function (v) {
|
|
375
|
-
return parseInt(v);
|
|
376
|
-
});
|
|
377
|
-
var shouldPrefix = reactSemverArray[0] >= 16 && reactSemverArray[1] >= 3 || reactSemverArray[0] >= 17;
|
|
378
|
-
if (shouldPrefix) {
|
|
379
|
-
instance.UNSAFE_componentWillUpdate = instance.componentWillUpdate;
|
|
380
|
-
instance.componentWillUpdate = void 0;
|
|
381
|
-
instance.UNSAFE_componentWillMount = instance.componentWillMount;
|
|
382
|
-
instance.componentWillMount = void 0;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
341
|
|
|
386
342
|
var SettingsMapper = /*#__PURE__*/function () {
|
|
387
343
|
function SettingsMapper() {
|
|
@@ -417,48 +373,54 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
417
373
|
return SettingsMapper;
|
|
418
374
|
}();
|
|
419
375
|
|
|
376
|
+
/**
|
|
377
|
+
* Component class used to manage the editor component portals.
|
|
378
|
+
*/
|
|
379
|
+
var EditorsPortalManager = /*#__PURE__*/function (_React$Component) {
|
|
380
|
+
_inherits(EditorsPortalManager, _React$Component);
|
|
381
|
+
var _super = _createSuper(EditorsPortalManager);
|
|
382
|
+
function EditorsPortalManager() {
|
|
383
|
+
var _this;
|
|
384
|
+
_classCallCheck(this, EditorsPortalManager);
|
|
385
|
+
_this = _super.apply(this, arguments);
|
|
386
|
+
_this.state = {
|
|
387
|
+
portals: []
|
|
388
|
+
};
|
|
389
|
+
return _this;
|
|
390
|
+
}
|
|
391
|
+
_createClass(EditorsPortalManager, [{
|
|
392
|
+
key: "render",
|
|
393
|
+
value: function render() {
|
|
394
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, this.state.portals);
|
|
395
|
+
}
|
|
396
|
+
}]);
|
|
397
|
+
return EditorsPortalManager;
|
|
398
|
+
}(React__default["default"].Component);
|
|
399
|
+
|
|
420
400
|
var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
421
401
|
_inherits(HotColumn, _React$Component);
|
|
422
402
|
var _super = _createSuper(HotColumn);
|
|
423
|
-
|
|
424
|
-
* HotColumn class constructor.
|
|
425
|
-
*
|
|
426
|
-
* @param {HotColumnProps} props Component props.
|
|
427
|
-
* @param {*} [context] Component context.
|
|
428
|
-
*/
|
|
429
|
-
function HotColumn(props, context) {
|
|
403
|
+
function HotColumn() {
|
|
430
404
|
var _this;
|
|
431
405
|
_classCallCheck(this, HotColumn);
|
|
432
|
-
_this = _super.
|
|
406
|
+
_this = _super.apply(this, arguments);
|
|
433
407
|
/**
|
|
434
|
-
*
|
|
408
|
+
* Component used to manage the editor portals.
|
|
435
409
|
*
|
|
436
|
-
* @
|
|
437
|
-
* @type {ReactPortal}
|
|
410
|
+
* @type {React.Component}
|
|
438
411
|
*/
|
|
439
|
-
_this.
|
|
440
|
-
addUnsafePrefixes(_assertThisInitialized(_this));
|
|
412
|
+
_this.editorsPortalManager = null;
|
|
441
413
|
return _this;
|
|
442
414
|
}
|
|
443
415
|
/**
|
|
444
|
-
*
|
|
416
|
+
* Set the editors portal manager ref.
|
|
445
417
|
*
|
|
446
|
-
* @
|
|
418
|
+
* @param {React.ReactComponent} pmComponent The PortalManager component.
|
|
447
419
|
*/
|
|
448
420
|
_createClass(HotColumn, [{
|
|
449
|
-
key: "
|
|
450
|
-
value: function
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Set the local editor portal cache property.
|
|
455
|
-
*
|
|
456
|
-
* @param {ReactPortal} portal Local editor portal.
|
|
457
|
-
*/
|
|
458
|
-
}, {
|
|
459
|
-
key: "setLocalEditorPortal",
|
|
460
|
-
value: function setLocalEditorPortal(portal) {
|
|
461
|
-
this.localEditorPortal = portal;
|
|
421
|
+
key: "setEditorsPortalManagerRef",
|
|
422
|
+
value: function setEditorsPortalManagerRef(pmComponent) {
|
|
423
|
+
this.editorsPortalManager = pmComponent;
|
|
462
424
|
}
|
|
463
425
|
/**
|
|
464
426
|
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
@@ -469,7 +431,7 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
469
431
|
key: "getSettingsProps",
|
|
470
432
|
value: function getSettingsProps() {
|
|
471
433
|
var _this2 = this;
|
|
472
|
-
this.internalProps = ['
|
|
434
|
+
this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
|
|
473
435
|
return Object.keys(this.props).filter(function (key) {
|
|
474
436
|
return !_this2.internalProps.includes(key);
|
|
475
437
|
}).reduce(function (obj, key) {
|
|
@@ -505,19 +467,19 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
505
467
|
}
|
|
506
468
|
}
|
|
507
469
|
/**
|
|
508
|
-
*
|
|
470
|
+
* Creates the local editor portal and renders it within the editors portal manager component.
|
|
509
471
|
*
|
|
510
|
-
* @param {
|
|
472
|
+
* @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
|
|
511
473
|
*/
|
|
512
474
|
}, {
|
|
513
|
-
key: "
|
|
514
|
-
value: function
|
|
515
|
-
var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.children;
|
|
475
|
+
key: "renderLocalEditorPortal",
|
|
476
|
+
value: function renderLocalEditorPortal(callback) {
|
|
516
477
|
var editorCache = this.props._getEditorCache();
|
|
517
|
-
var localEditorElement = getExtendedEditorElement(children, editorCache, this.props._columnIndex);
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
478
|
+
var localEditorElement = getExtendedEditorElement(this.props.children, editorCache, this.props._columnIndex);
|
|
479
|
+
var editorPortal = createEditorPortal(this.props._getOwnerDocument(), localEditorElement);
|
|
480
|
+
this.editorsPortalManager.setState({
|
|
481
|
+
portals: [editorPortal]
|
|
482
|
+
}, callback);
|
|
521
483
|
}
|
|
522
484
|
/**
|
|
523
485
|
* Emit the column settings to the parent using a prop passed from the parent.
|
|
@@ -532,30 +494,17 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
532
494
|
------- React lifecycle methods -------
|
|
533
495
|
---------------------------------------
|
|
534
496
|
*/
|
|
535
|
-
/**
|
|
536
|
-
* Logic performed before the mounting of the HotColumn component.
|
|
537
|
-
*/
|
|
538
|
-
}, {
|
|
539
|
-
key: "componentWillMount",
|
|
540
|
-
value: function componentWillMount() {
|
|
541
|
-
this.createLocalEditorPortal();
|
|
542
|
-
}
|
|
543
497
|
/**
|
|
544
498
|
* Logic performed after the mounting of the HotColumn component.
|
|
545
499
|
*/
|
|
546
500
|
}, {
|
|
547
501
|
key: "componentDidMount",
|
|
548
502
|
value: function componentDidMount() {
|
|
549
|
-
this
|
|
550
|
-
this.
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
*/
|
|
555
|
-
}, {
|
|
556
|
-
key: "componentWillUpdate",
|
|
557
|
-
value: function componentWillUpdate(nextProps, nextState, nextContext) {
|
|
558
|
-
this.createLocalEditorPortal(nextProps.children);
|
|
503
|
+
var _this3 = this;
|
|
504
|
+
this.renderLocalEditorPortal(function () {
|
|
505
|
+
_this3.createColumnSettings();
|
|
506
|
+
_this3.emitColumnSettings();
|
|
507
|
+
});
|
|
559
508
|
}
|
|
560
509
|
/**
|
|
561
510
|
* Logic performed after the updating of the HotColumn component.
|
|
@@ -563,8 +512,11 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
563
512
|
}, {
|
|
564
513
|
key: "componentDidUpdate",
|
|
565
514
|
value: function componentDidUpdate() {
|
|
566
|
-
this
|
|
567
|
-
this.
|
|
515
|
+
var _this4 = this;
|
|
516
|
+
this.renderLocalEditorPortal(function () {
|
|
517
|
+
_this4.createColumnSettings();
|
|
518
|
+
_this4.emitColumnSettings();
|
|
519
|
+
});
|
|
568
520
|
}
|
|
569
521
|
/**
|
|
570
522
|
* Render the portals of the editors, if there are any.
|
|
@@ -574,7 +526,9 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
574
526
|
}, {
|
|
575
527
|
key: "render",
|
|
576
528
|
value: function render() {
|
|
577
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
529
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(EditorsPortalManager, {
|
|
530
|
+
ref: this.setEditorsPortalManagerRef.bind(this)
|
|
531
|
+
}));
|
|
578
532
|
}
|
|
579
533
|
}]);
|
|
580
534
|
return HotColumn;
|
|
@@ -583,28 +537,28 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
|
583
537
|
/**
|
|
584
538
|
* Component class used to manage the renderer component portals.
|
|
585
539
|
*/
|
|
586
|
-
var
|
|
587
|
-
_inherits(
|
|
588
|
-
var _super = _createSuper(
|
|
589
|
-
function
|
|
540
|
+
var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
|
|
541
|
+
_inherits(RenderersPortalManager, _React$Component);
|
|
542
|
+
var _super = _createSuper(RenderersPortalManager);
|
|
543
|
+
function RenderersPortalManager() {
|
|
590
544
|
var _this;
|
|
591
|
-
_classCallCheck(this,
|
|
592
|
-
_this = _super.
|
|
545
|
+
_classCallCheck(this, RenderersPortalManager);
|
|
546
|
+
_this = _super.apply(this, arguments);
|
|
593
547
|
_this.state = {
|
|
594
548
|
portals: []
|
|
595
549
|
};
|
|
596
550
|
return _this;
|
|
597
551
|
}
|
|
598
|
-
_createClass(
|
|
552
|
+
_createClass(RenderersPortalManager, [{
|
|
599
553
|
key: "render",
|
|
600
554
|
value: function render() {
|
|
601
555
|
return React__default["default"].createElement(React__default["default"].Fragment, null, this.state.portals);
|
|
602
556
|
}
|
|
603
557
|
}]);
|
|
604
|
-
return
|
|
558
|
+
return RenderersPortalManager;
|
|
605
559
|
}(React__default["default"].Component);
|
|
606
560
|
|
|
607
|
-
var version="12.3.
|
|
561
|
+
var version="12.3.2-next-e75de58-20230322";
|
|
608
562
|
|
|
609
563
|
function createCommonjsModule(fn, module) {
|
|
610
564
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
@@ -972,16 +926,10 @@ var PropTypes = propTypes;
|
|
|
972
926
|
var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
973
927
|
_inherits(HotTable, _React$Component);
|
|
974
928
|
var _super = _createSuper(HotTable);
|
|
975
|
-
|
|
976
|
-
* HotTable class constructor.
|
|
977
|
-
*
|
|
978
|
-
* @param {HotTableProps} props Component props.
|
|
979
|
-
* @param {*} [context] Component context.
|
|
980
|
-
*/
|
|
981
|
-
function HotTable(props, context) {
|
|
929
|
+
function HotTable() {
|
|
982
930
|
var _this;
|
|
983
931
|
_classCallCheck(this, HotTable);
|
|
984
|
-
_this = _super.
|
|
932
|
+
_this = _super.apply(this, arguments);
|
|
985
933
|
/**
|
|
986
934
|
* The `id` of the main Handsontable DOM element.
|
|
987
935
|
*
|
|
@@ -1012,18 +960,17 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1012
960
|
*
|
|
1013
961
|
* @type {React.Component}
|
|
1014
962
|
*/
|
|
1015
|
-
_this.
|
|
963
|
+
_this.renderersPortalManager = null;
|
|
1016
964
|
/**
|
|
1017
|
-
*
|
|
965
|
+
* Component used to manage the editor portals.
|
|
966
|
+
*
|
|
967
|
+
* @type {React.Component}
|
|
1018
968
|
*/
|
|
1019
|
-
_this.
|
|
969
|
+
_this.editorsPortalManager = null;
|
|
1020
970
|
/**
|
|
1021
|
-
*
|
|
1022
|
-
*
|
|
1023
|
-
* @private
|
|
1024
|
-
* @type {React.ReactPortal}
|
|
971
|
+
* Array containing the portals cashed to be rendered in bulk after Handsontable's render cycle.
|
|
1025
972
|
*/
|
|
1026
|
-
_this.
|
|
973
|
+
_this.portalCacheArray = [];
|
|
1027
974
|
/**
|
|
1028
975
|
* The rendered cells cache.
|
|
1029
976
|
*
|
|
@@ -1046,7 +993,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1046
993
|
* @type {Map}
|
|
1047
994
|
*/
|
|
1048
995
|
_this.componentRendererColumns = new Map();
|
|
1049
|
-
addUnsafePrefixes(_assertThisInitialized(_this));
|
|
1050
996
|
return _this;
|
|
1051
997
|
}
|
|
1052
998
|
/**
|
|
@@ -1096,37 +1042,14 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1096
1042
|
value: function getEditorCache() {
|
|
1097
1043
|
return this.editorCache;
|
|
1098
1044
|
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Get the global editor portal property.
|
|
1101
|
-
*
|
|
1102
|
-
* @return {React.ReactPortal} The global editor portal.
|
|
1103
|
-
*/
|
|
1104
|
-
}, {
|
|
1105
|
-
key: "getGlobalEditorPortal",
|
|
1106
|
-
value: function getGlobalEditorPortal() {
|
|
1107
|
-
return this.globalEditorPortal;
|
|
1108
|
-
}
|
|
1109
|
-
/**
|
|
1110
|
-
* Set the private editor portal cache property.
|
|
1111
|
-
*
|
|
1112
|
-
* @param {React.ReactPortal} portal Global editor portal.
|
|
1113
|
-
*/
|
|
1114
|
-
}, {
|
|
1115
|
-
key: "setGlobalEditorPortal",
|
|
1116
|
-
value: function setGlobalEditorPortal(portal) {
|
|
1117
|
-
this.globalEditorPortal = portal;
|
|
1118
|
-
}
|
|
1119
1045
|
/**
|
|
1120
1046
|
* Clear both the editor and the renderer cache.
|
|
1121
1047
|
*/
|
|
1122
1048
|
}, {
|
|
1123
1049
|
key: "clearCache",
|
|
1124
1050
|
value: function clearCache() {
|
|
1125
|
-
var renderedCellCache = this.getRenderedCellCache();
|
|
1126
|
-
this.setGlobalEditorPortal(null);
|
|
1127
|
-
removeEditorContainers(this.getOwnerDocument());
|
|
1128
1051
|
this.getEditorCache().clear();
|
|
1129
|
-
|
|
1052
|
+
this.getRenderedCellCache().clear();
|
|
1130
1053
|
this.componentRendererColumns.clear();
|
|
1131
1054
|
}
|
|
1132
1055
|
/**
|
|
@@ -1173,7 +1096,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1173
1096
|
value: value,
|
|
1174
1097
|
cellProperties: cellProperties,
|
|
1175
1098
|
isRenderer: true
|
|
1176
|
-
},
|
|
1099
|
+
}, TD.ownerDocument),
|
|
1177
1100
|
portal = _createPortal.portal,
|
|
1178
1101
|
portalContainer = _createPortal.portalContainer;
|
|
1179
1102
|
while (TD.firstChild) {
|
|
@@ -1197,11 +1120,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1197
1120
|
}, {
|
|
1198
1121
|
key: "getEditorClass",
|
|
1199
1122
|
value: function getEditorClass(editorElement) {
|
|
1200
|
-
var
|
|
1123
|
+
var _this$getEditorCache$;
|
|
1201
1124
|
var editorColumnScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GLOBAL_EDITOR_SCOPE;
|
|
1202
1125
|
var editorClass = getOriginalEditorClass(editorElement);
|
|
1203
|
-
var
|
|
1204
|
-
var cachedComponent = (_editorCache$get = editorCache.get(editorClass)) === null || _editorCache$get === void 0 ? void 0 : _editorCache$get.get(editorColumnScope);
|
|
1126
|
+
var cachedComponent = (_this$getEditorCache$ = this.getEditorCache().get(editorClass)) === null || _this$getEditorCache$ === void 0 ? void 0 : _this$getEditorCache$.get(editorColumnScope);
|
|
1205
1127
|
return this.makeEditorClass(cachedComponent);
|
|
1206
1128
|
}
|
|
1207
1129
|
/**
|
|
@@ -1265,8 +1187,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1265
1187
|
}, {
|
|
1266
1188
|
key: "getGlobalRendererElement",
|
|
1267
1189
|
value: function getGlobalRendererElement() {
|
|
1268
|
-
|
|
1269
|
-
return getChildElementByType(hotTableSlots, 'hot-renderer');
|
|
1190
|
+
return getChildElementByType(this.props.children, 'hot-renderer');
|
|
1270
1191
|
}
|
|
1271
1192
|
/**
|
|
1272
1193
|
* Get the editor element for the entire HotTable instance.
|
|
@@ -1277,22 +1198,21 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1277
1198
|
}, {
|
|
1278
1199
|
key: "getGlobalEditorElement",
|
|
1279
1200
|
value: function getGlobalEditorElement() {
|
|
1280
|
-
|
|
1281
|
-
return getExtendedEditorElement(children, this.getEditorCache());
|
|
1201
|
+
return getExtendedEditorElement(this.props.children, this.getEditorCache());
|
|
1282
1202
|
}
|
|
1283
1203
|
/**
|
|
1284
|
-
*
|
|
1204
|
+
* Creates the global editor portal and renders it within the editors portal manager component.
|
|
1285
1205
|
*
|
|
1286
|
-
* @param {
|
|
1206
|
+
* @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
|
|
1287
1207
|
*/
|
|
1288
1208
|
}, {
|
|
1289
|
-
key: "
|
|
1290
|
-
value: function
|
|
1291
|
-
var
|
|
1292
|
-
var
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
}
|
|
1209
|
+
key: "renderGlobalEditorPortal",
|
|
1210
|
+
value: function renderGlobalEditorPortal(callback) {
|
|
1211
|
+
var globalEditorElement = this.getGlobalEditorElement();
|
|
1212
|
+
var editorPortal = createEditorPortal(this.getOwnerDocument(), globalEditorElement);
|
|
1213
|
+
this.editorsPortalManager.setState({
|
|
1214
|
+
portals: [editorPortal]
|
|
1215
|
+
}, callback);
|
|
1296
1216
|
}
|
|
1297
1217
|
/**
|
|
1298
1218
|
* Create a new settings object containing the column settings and global editors and renderers.
|
|
@@ -1360,7 +1280,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1360
1280
|
key: "handsontableAfterViewRender",
|
|
1361
1281
|
value: function handsontableAfterViewRender() {
|
|
1362
1282
|
var _this3 = this;
|
|
1363
|
-
this.
|
|
1283
|
+
this.renderersPortalManager.setState(function () {
|
|
1364
1284
|
return Object.assign({}, {
|
|
1365
1285
|
portals: _this3.portalCacheArray
|
|
1366
1286
|
});
|
|
@@ -1381,57 +1301,56 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1381
1301
|
}
|
|
1382
1302
|
}
|
|
1383
1303
|
/**
|
|
1384
|
-
* Set the portal manager ref.
|
|
1304
|
+
* Set the renderers portal manager ref.
|
|
1385
1305
|
*
|
|
1386
1306
|
* @param {React.ReactComponent} pmComponent The PortalManager component.
|
|
1387
1307
|
*/
|
|
1388
1308
|
}, {
|
|
1389
|
-
key: "
|
|
1390
|
-
value: function
|
|
1391
|
-
this.
|
|
1309
|
+
key: "setRenderersPortalManagerRef",
|
|
1310
|
+
value: function setRenderersPortalManagerRef(pmComponent) {
|
|
1311
|
+
this.renderersPortalManager = pmComponent;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Set the editors portal manager ref.
|
|
1315
|
+
*
|
|
1316
|
+
* @param {React.ReactComponent} pmComponent The PortalManager component.
|
|
1317
|
+
*/
|
|
1318
|
+
}, {
|
|
1319
|
+
key: "setEditorsPortalManagerRef",
|
|
1320
|
+
value: function setEditorsPortalManagerRef(pmComponent) {
|
|
1321
|
+
this.editorsPortalManager = pmComponent;
|
|
1392
1322
|
}
|
|
1393
1323
|
/*
|
|
1394
1324
|
---------------------------------------
|
|
1395
1325
|
------- React lifecycle methods -------
|
|
1396
1326
|
---------------------------------------
|
|
1397
1327
|
*/
|
|
1398
|
-
/**
|
|
1399
|
-
* Logic performed before the mounting of the component.
|
|
1400
|
-
*/
|
|
1401
|
-
}, {
|
|
1402
|
-
key: "componentWillMount",
|
|
1403
|
-
value: function componentWillMount() {
|
|
1404
|
-
this.clearCache();
|
|
1405
|
-
this.createGlobalEditorPortal();
|
|
1406
|
-
}
|
|
1407
1328
|
/**
|
|
1408
1329
|
* Initialize Handsontable after the component has mounted.
|
|
1409
1330
|
*/
|
|
1410
1331
|
}, {
|
|
1411
1332
|
key: "componentDidMount",
|
|
1412
1333
|
value: function componentDidMount() {
|
|
1413
|
-
var
|
|
1414
|
-
var newGlobalSettings = this.createNewGlobalSettings();
|
|
1415
|
-
this.hotInstance = new Handsontable__default["default"].Core(this.hotElementRef, newGlobalSettings);
|
|
1416
|
-
this.hotInstance.addHook('beforeViewRender', function (isForced) {
|
|
1417
|
-
hotTableComponent.handsontableBeforeViewRender();
|
|
1418
|
-
});
|
|
1419
|
-
this.hotInstance.addHook('afterViewRender', function () {
|
|
1420
|
-
hotTableComponent.handsontableAfterViewRender();
|
|
1421
|
-
});
|
|
1422
|
-
// `init` missing in Handsontable's type definitions.
|
|
1423
|
-
this.hotInstance.init();
|
|
1424
|
-
this.displayAutoSizeWarning(newGlobalSettings);
|
|
1425
|
-
}
|
|
1426
|
-
/**
|
|
1427
|
-
* Logic performed before the component update.
|
|
1428
|
-
*/
|
|
1429
|
-
}, {
|
|
1430
|
-
key: "componentWillUpdate",
|
|
1431
|
-
value: function componentWillUpdate(nextProps, nextState, nextContext) {
|
|
1334
|
+
var _this4 = this;
|
|
1432
1335
|
this.clearCache();
|
|
1433
|
-
|
|
1434
|
-
|
|
1336
|
+
this.renderGlobalEditorPortal(function () {
|
|
1337
|
+
// In React strict mode the mount/unmount is triggered twice. The `if` prevents
|
|
1338
|
+
// creating two Handsontable instances for the same component in that mode.
|
|
1339
|
+
if (_this4.hotInstance) {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
var newGlobalSettings = _this4.createNewGlobalSettings();
|
|
1343
|
+
_this4.hotInstance = new Handsontable__default["default"].Core(_this4.hotElementRef, newGlobalSettings);
|
|
1344
|
+
_this4.hotInstance.addHook('beforeViewRender', function () {
|
|
1345
|
+
return _this4.handsontableBeforeViewRender();
|
|
1346
|
+
});
|
|
1347
|
+
_this4.hotInstance.addHook('afterViewRender', function () {
|
|
1348
|
+
return _this4.handsontableAfterViewRender();
|
|
1349
|
+
});
|
|
1350
|
+
// `init` missing in Handsontable's type definitions.
|
|
1351
|
+
_this4.hotInstance.init();
|
|
1352
|
+
_this4.displayAutoSizeWarning(newGlobalSettings);
|
|
1353
|
+
});
|
|
1435
1354
|
}
|
|
1436
1355
|
/**
|
|
1437
1356
|
* Logic performed after the component update.
|
|
@@ -1439,9 +1358,13 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1439
1358
|
}, {
|
|
1440
1359
|
key: "componentDidUpdate",
|
|
1441
1360
|
value: function componentDidUpdate() {
|
|
1442
|
-
var
|
|
1443
|
-
this.
|
|
1444
|
-
this.
|
|
1361
|
+
var _this5 = this;
|
|
1362
|
+
this.clearCache();
|
|
1363
|
+
this.renderGlobalEditorPortal(function () {
|
|
1364
|
+
var newGlobalSettings = _this5.createNewGlobalSettings();
|
|
1365
|
+
_this5.updateHot(newGlobalSettings);
|
|
1366
|
+
_this5.displayAutoSizeWarning(newGlobalSettings);
|
|
1367
|
+
});
|
|
1445
1368
|
}
|
|
1446
1369
|
/**
|
|
1447
1370
|
* Destroy the Handsontable instance when the parent component unmounts.
|
|
@@ -1452,7 +1375,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1452
1375
|
if (this.hotInstance) {
|
|
1453
1376
|
this.hotInstance.destroy();
|
|
1454
1377
|
}
|
|
1455
|
-
removeEditorContainers(this.getOwnerDocument());
|
|
1456
1378
|
}
|
|
1457
1379
|
/**
|
|
1458
1380
|
* Render the component.
|
|
@@ -1460,11 +1382,8 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1460
1382
|
}, {
|
|
1461
1383
|
key: "render",
|
|
1462
1384
|
value: function render() {
|
|
1463
|
-
var
|
|
1464
|
-
var
|
|
1465
|
-
id = _getContainerAttribut.id,
|
|
1466
|
-
className = _getContainerAttribut.className,
|
|
1467
|
-
style = _getContainerAttribut.style;
|
|
1385
|
+
var _this6 = this;
|
|
1386
|
+
var containerProps = getContainerAttributesProps(this.props);
|
|
1468
1387
|
var isHotColumn = function isHotColumn(childNode) {
|
|
1469
1388
|
return childNode.type === HotColumn;
|
|
1470
1389
|
};
|
|
@@ -1476,26 +1395,23 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1476
1395
|
// clone the HotColumn nodes and extend them with the callbacks
|
|
1477
1396
|
var childClones = children.map(function (childNode, columnIndex) {
|
|
1478
1397
|
return React__default["default"].cloneElement(childNode, {
|
|
1479
|
-
_componentRendererColumns:
|
|
1480
|
-
_emitColumnSettings:
|
|
1398
|
+
_componentRendererColumns: _this6.componentRendererColumns,
|
|
1399
|
+
_emitColumnSettings: _this6.setHotColumnSettings.bind(_this6),
|
|
1481
1400
|
_columnIndex: columnIndex,
|
|
1482
|
-
_getChildElementByType: getChildElementByType.bind(
|
|
1483
|
-
_getRendererWrapper:
|
|
1484
|
-
_getEditorClass:
|
|
1485
|
-
_getOwnerDocument:
|
|
1486
|
-
_getEditorCache:
|
|
1401
|
+
_getChildElementByType: getChildElementByType.bind(_this6),
|
|
1402
|
+
_getRendererWrapper: _this6.getRendererWrapper.bind(_this6),
|
|
1403
|
+
_getEditorClass: _this6.getEditorClass.bind(_this6),
|
|
1404
|
+
_getOwnerDocument: _this6.getOwnerDocument.bind(_this6),
|
|
1405
|
+
_getEditorCache: _this6.getEditorCache.bind(_this6),
|
|
1487
1406
|
children: childNode.props.children
|
|
1488
1407
|
});
|
|
1489
1408
|
});
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
ref: this.
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
style: style
|
|
1497
|
-
}, childClones), React__default["default"].createElement(PortalManager, {
|
|
1498
|
-
ref: this.setPortalManagerRef.bind(this)
|
|
1409
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", Object.assign({
|
|
1410
|
+
ref: this.setHotElementRef.bind(this)
|
|
1411
|
+
}, containerProps), childClones), React__default["default"].createElement(RenderersPortalManager, {
|
|
1412
|
+
ref: this.setRenderersPortalManagerRef.bind(this)
|
|
1413
|
+
}), React__default["default"].createElement(EditorsPortalManager, {
|
|
1414
|
+
ref: this.setEditorsPortalManagerRef.bind(this)
|
|
1499
1415
|
}));
|
|
1500
1416
|
}
|
|
1501
1417
|
}], [{
|
|
@@ -1518,10 +1434,10 @@ HotTable.propTypes = {
|
|
|
1518
1434
|
var BaseEditorComponent = /*#__PURE__*/function (_React$Component) {
|
|
1519
1435
|
_inherits(BaseEditorComponent, _React$Component);
|
|
1520
1436
|
var _super = _createSuper(BaseEditorComponent);
|
|
1521
|
-
function BaseEditorComponent(
|
|
1437
|
+
function BaseEditorComponent() {
|
|
1522
1438
|
var _this;
|
|
1523
1439
|
_classCallCheck(this, BaseEditorComponent);
|
|
1524
|
-
_this = _super.
|
|
1440
|
+
_this = _super.apply(this, arguments);
|
|
1525
1441
|
_this.name = 'BaseEditorComponent';
|
|
1526
1442
|
_this.instance = null;
|
|
1527
1443
|
_this.row = null;
|
|
@@ -1534,13 +1450,24 @@ var BaseEditorComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1534
1450
|
_this.hotInstance = null;
|
|
1535
1451
|
_this.hotCustomEditorInstance = null;
|
|
1536
1452
|
_this.hot = null;
|
|
1537
|
-
if (props.emitEditorInstance) {
|
|
1538
|
-
props.emitEditorInstance(_assertThisInitialized(_this), props.editorColumnScope);
|
|
1539
|
-
}
|
|
1540
1453
|
return _this;
|
|
1541
1454
|
}
|
|
1542
|
-
// BaseEditor methods:
|
|
1543
1455
|
_createClass(BaseEditorComponent, [{
|
|
1456
|
+
key: "componentDidMount",
|
|
1457
|
+
value: function componentDidMount() {
|
|
1458
|
+
if (this.props.emitEditorInstance) {
|
|
1459
|
+
this.props.emitEditorInstance(this, this.props.editorColumnScope);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
}, {
|
|
1463
|
+
key: "componentDidUpdate",
|
|
1464
|
+
value: function componentDidUpdate() {
|
|
1465
|
+
if (this.props.emitEditorInstance) {
|
|
1466
|
+
this.props.emitEditorInstance(this, this.props.editorColumnScope);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
// BaseEditor methods:
|
|
1470
|
+
}, {
|
|
1544
1471
|
key: "_fireCallbacks",
|
|
1545
1472
|
value: function _fireCallbacks() {
|
|
1546
1473
|
var _Handsontable$editors;
|