@handsontable/react-wrapper 17.0.0-rc1 → 17.0.0-rc10

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.
@@ -627,6 +627,58 @@ var EditorContextProvider = function EditorContextProvider(_ref) {
627
627
  }
628
628
  }, children);
629
629
  };
630
+ /**
631
+ * Applies editor overlay position/dimensions to an element.
632
+ * @returns true if position was applied, false if editor should close (e.g. cell no longer available).
633
+ */
634
+ function applyEditorPosition(el, editor, hot, td) {
635
+ var _rootWindow$pageXOffs, _rootWindow$pageYOffs;
636
+ var rootWindow = hot.rootWindow || window;
637
+ var pageX = (_rootWindow$pageXOffs = rootWindow.pageXOffset) !== null && _rootWindow$pageXOffs !== void 0 ? _rootWindow$pageXOffs : 0;
638
+ var pageY = (_rootWindow$pageYOffs = rootWindow.pageYOffset) !== null && _rootWindow$pageYOffs !== void 0 ? _rootWindow$pageYOffs : 0;
639
+ var isRtl = typeof hot.isRtl === 'function' && hot.isRtl();
640
+ var position = editor.position;
641
+ var applyTdRect = function applyTdRect(rect) {
642
+ el.style.top = "".concat(pageY + rect.top - 1, "px");
643
+ el.style.width = "".concat(rect.width + 1, "px");
644
+ el.style.height = "".concat(rect.height + 1, "px");
645
+ if (isRtl) {
646
+ el.style.right = "".concat(pageX + rect.right, "px");
647
+ el.style.left = 'auto';
648
+ } else {
649
+ el.style.left = "".concat(pageX + rect.left - 1, "px");
650
+ el.style.right = 'auto';
651
+ }
652
+ };
653
+ if (position === 'portal') {
654
+ var cell = typeof editor.getEditedCell === 'function' ? editor.getEditedCell.call(editor) : null;
655
+ if (!(cell !== null && cell !== void 0 && cell.getBoundingClientRect)) {
656
+ return false;
657
+ }
658
+ applyTdRect(cell.getBoundingClientRect());
659
+ return true;
660
+ }
661
+ var getEditedCellRect = editor.getEditedCellRect;
662
+ var rect = typeof getEditedCellRect === 'function' ? getEditedCellRect.call(editor) : null;
663
+ if (rect) {
664
+ var rootElement = hot.rootElement;
665
+ if (rootElement !== null && rootElement !== void 0 && rootElement.getBoundingClientRect) {
666
+ var rootRect = rootElement.getBoundingClientRect();
667
+ el.style.top = "".concat(pageY + rootRect.top + rect.top, "px");
668
+ el.style.width = "".concat(rect.width, "px");
669
+ el.style.height = "".concat(rect.height, "px");
670
+ if (isRtl) {
671
+ el.style.right = "".concat(pageX + rootRect.right - rect.start, "px");
672
+ el.style.left = 'auto';
673
+ } else {
674
+ el.style.left = "".concat(pageX + rootRect.left + rect.start, "px");
675
+ el.style.right = 'auto';
676
+ }
677
+ return true;
678
+ }
679
+ }
680
+ return false;
681
+ }
630
682
  /**
631
683
  * Hook that allows encapsulating custom behaviours of component-based editor by customizing passed ref with overridden hooks object.
632
684
  *
@@ -700,6 +752,10 @@ function EditorComponent(_ref2) {
700
752
  shortcuts = _ref2.shortcuts;
701
753
  var mainElementRef = React.useRef(null);
702
754
  var currentValue = React.useRef(undefined);
755
+ var _useState5 = React.useState(),
756
+ _useState6 = _slicedToArray(_useState5, 2),
757
+ themeClassName = _useState6[0],
758
+ setThemeClassName = _useState6[1];
703
759
  var _useContext2 = React.useContext(EditorContext),
704
760
  hotCustomEditorInstanceRef = _useContext2.hotCustomEditorInstanceRef;
705
761
  var registerShortcuts = React.useCallback(function () {
@@ -737,26 +793,55 @@ function EditorComponent(_ref2) {
737
793
  var editorContext = shortcutManager.getContext("editor");
738
794
  editorContext.removeShortcutsByGroup(shortcutsGroup);
739
795
  }, [shortcuts]);
796
+ var refreshDimensions = React.useCallback(function () {
797
+ var editor = hotCustomEditorInstanceRef.current;
798
+ var el = mainElementRef.current;
799
+ if (!editor || !el) return;
800
+ var hot = editor.hot;
801
+ if (!hot) return;
802
+ if (typeof editor.isOpened !== 'function' || !editor.isOpened()) return;
803
+ if (!applyEditorPosition(el, editor, hot) && typeof editor.close === 'function') {
804
+ editor.close();
805
+ }
806
+ }, []);
807
+ var unRegisterScrollHooks = React.useCallback(function () {
808
+ var editor = hotCustomEditorInstanceRef.current;
809
+ var hot = editor === null || editor === void 0 ? void 0 : editor.hot;
810
+ if (!hot || typeof hot.removeHook !== 'function') return;
811
+ hot.removeHook('afterScrollHorizontally', refreshDimensions);
812
+ hot.removeHook('afterScrollVertically', refreshDimensions);
813
+ }, [refreshDimensions]);
814
+ var registerScrollHooks = React.useCallback(function () {
815
+ var editor = hotCustomEditorInstanceRef.current;
816
+ var hot = editor === null || editor === void 0 ? void 0 : editor.hot;
817
+ if (!hot || typeof hot.addHook !== 'function') return;
818
+ hot.addHook('afterScrollHorizontally', refreshDimensions);
819
+ hot.addHook('afterScrollVertically', refreshDimensions);
820
+ }, [refreshDimensions]);
740
821
  var _useHotEditor = useHotEditor({
741
822
  onOpen: function onOpen() {
823
+ var _hotCustomEditorInsta11;
742
824
  if (!mainElementRef.current) return;
825
+ var themeName = (_hotCustomEditorInsta11 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta11 === void 0 ? void 0 : _hotCustomEditorInsta11.hot.getCurrentThemeName();
826
+ if (themeName) setThemeClassName(themeName);
743
827
  mainElementRef.current.style.display = 'block';
744
828
  _onOpen === null || _onOpen === void 0 || _onOpen();
829
+ var el = mainElementRef.current;
830
+ var editor = hotCustomEditorInstanceRef.current;
831
+ if (el && editor !== null && editor !== void 0 && editor.hot) {
832
+ applyEditorPosition(el, editor, editor.hot);
833
+ }
745
834
  registerShortcuts();
835
+ registerScrollHooks();
746
836
  },
747
837
  onClose: function onClose() {
748
838
  if (!mainElementRef.current) return;
749
839
  mainElementRef.current.style.display = 'none';
750
840
  _onClose === null || _onClose === void 0 || _onClose();
751
841
  unRegisterShortcuts();
842
+ unRegisterScrollHooks();
752
843
  },
753
844
  onPrepare: function onPrepare(_row, _column, _prop, TD, _originalValue, _cellProperties) {
754
- if (!mainElementRef.current) return;
755
- var tdPosition = TD.getBoundingClientRect();
756
- mainElementRef.current.style.left = "".concat(tdPosition.left + window.pageXOffset - 1, "px");
757
- mainElementRef.current.style.top = "".concat(tdPosition.top + window.pageYOffset - 1, "px");
758
- mainElementRef.current.style.width = "".concat(tdPosition.width + 1, "px");
759
- mainElementRef.current.style.height = "".concat(tdPosition.height + 1, "px");
760
845
  _onPrepare === null || _onPrepare === void 0 || _onPrepare(_row, _column, _prop, TD, _originalValue, _cellProperties);
761
846
  },
762
847
  onFocus: function onFocus() {
@@ -777,13 +862,14 @@ function EditorComponent(_ref2) {
777
862
  };
778
863
  return React__default["default"].createElement("div", {
779
864
  ref: mainElementRef,
865
+ className: themeClassName,
780
866
  style: {
781
867
  display: 'none',
782
868
  position: 'absolute',
783
869
  background: '#fff',
784
870
  border: '0px',
785
871
  padding: '0px',
786
- zIndex: 999
872
+ zIndex: 100
787
873
  },
788
874
  onMouseDown: stopMousedownPropagation
789
875
  }, children({
@@ -870,7 +956,7 @@ var HotColumn = function HotColumn(props) {
870
956
  }, editorPortal);
871
957
  };
872
958
 
873
- var version="17.0.0-rc1";
959
+ var version="17.0.0-rc10";
874
960
 
875
961
  /**
876
962
  * Component used to manage the renderer component portals.
@@ -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: 17.0.0-rc1 (built at Fri Feb 20 2026 12:49:01 GMT+0000 (Coordinated Universal Time))
28
+ * Version: 17.0.0-rc10 (built at Mon Mar 02 2026 11:29:16 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'), require('handsontable/renderers/registry'), require('handsontable/editors/registry')) :
@@ -643,6 +643,58 @@ var EditorContextProvider = function EditorContextProvider(_ref) {
643
643
  }
644
644
  }, children);
645
645
  };
646
+ /**
647
+ * Applies editor overlay position/dimensions to an element.
648
+ * @returns true if position was applied, false if editor should close (e.g. cell no longer available).
649
+ */
650
+ function applyEditorPosition(el, editor, hot, td) {
651
+ var _rootWindow$pageXOffs, _rootWindow$pageYOffs;
652
+ var rootWindow = hot.rootWindow || window;
653
+ var pageX = (_rootWindow$pageXOffs = rootWindow.pageXOffset) !== null && _rootWindow$pageXOffs !== void 0 ? _rootWindow$pageXOffs : 0;
654
+ var pageY = (_rootWindow$pageYOffs = rootWindow.pageYOffset) !== null && _rootWindow$pageYOffs !== void 0 ? _rootWindow$pageYOffs : 0;
655
+ var isRtl = typeof hot.isRtl === 'function' && hot.isRtl();
656
+ var position = editor.position;
657
+ var applyTdRect = function applyTdRect(rect) {
658
+ el.style.top = "".concat(pageY + rect.top - 1, "px");
659
+ el.style.width = "".concat(rect.width + 1, "px");
660
+ el.style.height = "".concat(rect.height + 1, "px");
661
+ if (isRtl) {
662
+ el.style.right = "".concat(pageX + rect.right, "px");
663
+ el.style.left = 'auto';
664
+ } else {
665
+ el.style.left = "".concat(pageX + rect.left - 1, "px");
666
+ el.style.right = 'auto';
667
+ }
668
+ };
669
+ if (position === 'portal') {
670
+ var cell = typeof editor.getEditedCell === 'function' ? editor.getEditedCell.call(editor) : null;
671
+ if (!(cell !== null && cell !== void 0 && cell.getBoundingClientRect)) {
672
+ return false;
673
+ }
674
+ applyTdRect(cell.getBoundingClientRect());
675
+ return true;
676
+ }
677
+ var getEditedCellRect = editor.getEditedCellRect;
678
+ var rect = typeof getEditedCellRect === 'function' ? getEditedCellRect.call(editor) : null;
679
+ if (rect) {
680
+ var rootElement = hot.rootElement;
681
+ if (rootElement !== null && rootElement !== void 0 && rootElement.getBoundingClientRect) {
682
+ var rootRect = rootElement.getBoundingClientRect();
683
+ el.style.top = "".concat(pageY + rootRect.top + rect.top, "px");
684
+ el.style.width = "".concat(rect.width, "px");
685
+ el.style.height = "".concat(rect.height, "px");
686
+ if (isRtl) {
687
+ el.style.right = "".concat(pageX + rootRect.right - rect.start, "px");
688
+ el.style.left = 'auto';
689
+ } else {
690
+ el.style.left = "".concat(pageX + rootRect.left + rect.start, "px");
691
+ el.style.right = 'auto';
692
+ }
693
+ return true;
694
+ }
695
+ }
696
+ return false;
697
+ }
646
698
  /**
647
699
  * Hook that allows encapsulating custom behaviours of component-based editor by customizing passed ref with overridden hooks object.
648
700
  *
@@ -716,6 +768,10 @@ function EditorComponent(_ref2) {
716
768
  shortcuts = _ref2.shortcuts;
717
769
  var mainElementRef = React.useRef(null);
718
770
  var currentValue = React.useRef(undefined);
771
+ var _useState5 = React.useState(),
772
+ _useState6 = _slicedToArray(_useState5, 2),
773
+ themeClassName = _useState6[0],
774
+ setThemeClassName = _useState6[1];
719
775
  var _useContext2 = React.useContext(EditorContext),
720
776
  hotCustomEditorInstanceRef = _useContext2.hotCustomEditorInstanceRef;
721
777
  var registerShortcuts = React.useCallback(function () {
@@ -753,26 +809,55 @@ function EditorComponent(_ref2) {
753
809
  var editorContext = shortcutManager.getContext("editor");
754
810
  editorContext.removeShortcutsByGroup(shortcutsGroup);
755
811
  }, [shortcuts]);
812
+ var refreshDimensions = React.useCallback(function () {
813
+ var editor = hotCustomEditorInstanceRef.current;
814
+ var el = mainElementRef.current;
815
+ if (!editor || !el) return;
816
+ var hot = editor.hot;
817
+ if (!hot) return;
818
+ if (typeof editor.isOpened !== 'function' || !editor.isOpened()) return;
819
+ if (!applyEditorPosition(el, editor, hot) && typeof editor.close === 'function') {
820
+ editor.close();
821
+ }
822
+ }, []);
823
+ var unRegisterScrollHooks = React.useCallback(function () {
824
+ var editor = hotCustomEditorInstanceRef.current;
825
+ var hot = editor === null || editor === void 0 ? void 0 : editor.hot;
826
+ if (!hot || typeof hot.removeHook !== 'function') return;
827
+ hot.removeHook('afterScrollHorizontally', refreshDimensions);
828
+ hot.removeHook('afterScrollVertically', refreshDimensions);
829
+ }, [refreshDimensions]);
830
+ var registerScrollHooks = React.useCallback(function () {
831
+ var editor = hotCustomEditorInstanceRef.current;
832
+ var hot = editor === null || editor === void 0 ? void 0 : editor.hot;
833
+ if (!hot || typeof hot.addHook !== 'function') return;
834
+ hot.addHook('afterScrollHorizontally', refreshDimensions);
835
+ hot.addHook('afterScrollVertically', refreshDimensions);
836
+ }, [refreshDimensions]);
756
837
  var _useHotEditor = useHotEditor({
757
838
  onOpen: function onOpen() {
839
+ var _hotCustomEditorInsta11;
758
840
  if (!mainElementRef.current) return;
841
+ var themeName = (_hotCustomEditorInsta11 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta11 === void 0 ? void 0 : _hotCustomEditorInsta11.hot.getCurrentThemeName();
842
+ if (themeName) setThemeClassName(themeName);
759
843
  mainElementRef.current.style.display = 'block';
760
844
  _onOpen === null || _onOpen === void 0 || _onOpen();
845
+ var el = mainElementRef.current;
846
+ var editor = hotCustomEditorInstanceRef.current;
847
+ if (el && editor !== null && editor !== void 0 && editor.hot) {
848
+ applyEditorPosition(el, editor, editor.hot);
849
+ }
761
850
  registerShortcuts();
851
+ registerScrollHooks();
762
852
  },
763
853
  onClose: function onClose() {
764
854
  if (!mainElementRef.current) return;
765
855
  mainElementRef.current.style.display = 'none';
766
856
  _onClose === null || _onClose === void 0 || _onClose();
767
857
  unRegisterShortcuts();
858
+ unRegisterScrollHooks();
768
859
  },
769
860
  onPrepare: function onPrepare(_row, _column, _prop, TD, _originalValue, _cellProperties) {
770
- if (!mainElementRef.current) return;
771
- var tdPosition = TD.getBoundingClientRect();
772
- mainElementRef.current.style.left = "".concat(tdPosition.left + window.pageXOffset - 1, "px");
773
- mainElementRef.current.style.top = "".concat(tdPosition.top + window.pageYOffset - 1, "px");
774
- mainElementRef.current.style.width = "".concat(tdPosition.width + 1, "px");
775
- mainElementRef.current.style.height = "".concat(tdPosition.height + 1, "px");
776
861
  _onPrepare === null || _onPrepare === void 0 || _onPrepare(_row, _column, _prop, TD, _originalValue, _cellProperties);
777
862
  },
778
863
  onFocus: function onFocus() {
@@ -793,13 +878,14 @@ function EditorComponent(_ref2) {
793
878
  };
794
879
  return React__default["default"].createElement("div", {
795
880
  ref: mainElementRef,
881
+ className: themeClassName,
796
882
  style: {
797
883
  display: 'none',
798
884
  position: 'absolute',
799
885
  background: '#fff',
800
886
  border: '0px',
801
887
  padding: '0px',
802
- zIndex: 999
888
+ zIndex: 100
803
889
  },
804
890
  onMouseDown: stopMousedownPropagation
805
891
  }, children({
@@ -886,7 +972,7 @@ var HotColumn = function HotColumn(props) {
886
972
  }, editorPortal);
887
973
  };
888
974
 
889
- var version="17.0.0-rc1";
975
+ var version="17.0.0-rc10";
890
976
 
891
977
  /**
892
978
  * Component used to manage the renderer component portals.