@handsontable/react-wrapper 16.2.0 → 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.
- package/README.md +1 -13
- package/commonjs/react-handsontable.js +196 -1
- package/dist/react-handsontable.js +197 -2
- 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 +195 -2
- package/hotEditor.d.ts +41 -1
- package/index.d.ts +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -67,15 +67,6 @@ Below is the installation guide for the React functional component.
|
|
|
67
67
|
npm install handsontable @handsontable/react-wrapper
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
### Import CSS files
|
|
71
|
-
|
|
72
|
-
```jsx
|
|
73
|
-
// Base CSS rules
|
|
74
|
-
import 'handsontable/styles/handsontable.min.css';
|
|
75
|
-
// Main theme variables
|
|
76
|
-
import 'handsontable/styles/ht-theme-main.min.css';
|
|
77
|
-
```
|
|
78
|
-
|
|
79
70
|
### Register Handsontable's modules
|
|
80
71
|
|
|
81
72
|
```jsx
|
|
@@ -97,15 +88,12 @@ To set Handsontable's [configuration options](https://handsontable.com/docs/reac
|
|
|
97
88
|
```jsx
|
|
98
89
|
import { HotTable, HotColumn } from '@handsontable/react-wrapper';
|
|
99
90
|
import { registerAllModules } from 'handsontable/registry';
|
|
100
|
-
import 'handsontable/styles/handsontable.min.css';
|
|
101
|
-
import 'handsontable/styles/ht-theme-main.min.css';
|
|
102
91
|
|
|
103
92
|
registerAllModules();
|
|
104
93
|
|
|
105
94
|
const ExampleComponent = () => {
|
|
106
95
|
return (
|
|
107
96
|
<HotTable
|
|
108
|
-
theme="ht-theme-main-dark-auto"
|
|
109
97
|
data={[
|
|
110
98
|
{ company: 'Tagcat', country: 'United Kingdom', rating: 4.4 },
|
|
111
99
|
{ company: 'Zoomzone', country: 'Japan', rating: 4.5 },
|
|
@@ -138,7 +126,7 @@ const ExampleComponent = () => {
|
|
|
138
126
|
- [Website](https://handsontable.com)
|
|
139
127
|
- [Demo](https://handsontable.com/demo)
|
|
140
128
|
- [Documentation](https://handsontable.com/docs/react-data-grid)
|
|
141
|
-
- [npm](https://www.npmjs.com/package/@handsontable/react)
|
|
129
|
+
- [npm](https://www.npmjs.com/package/@handsontable/react-wrapper)
|
|
142
130
|
- [CDN](https://www.jsdelivr.com/package/npm/@handsontable/react-wrapper)
|
|
143
131
|
- [Forum](https://forum.handsontable.com/)
|
|
144
132
|
- [Blog](https://handsontable.com/blog)
|
|
@@ -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
|
*
|
|
@@ -689,6 +741,147 @@ function useHotEditor(overriddenHooks, deps) {
|
|
|
689
741
|
};
|
|
690
742
|
}, [rerenderTrigger, hotCustomEditorInstanceRef, deferredValue]);
|
|
691
743
|
}
|
|
744
|
+
function EditorComponent(_ref2) {
|
|
745
|
+
var _onPrepare = _ref2.onPrepare,
|
|
746
|
+
_onClose = _ref2.onClose,
|
|
747
|
+
_onOpen = _ref2.onOpen,
|
|
748
|
+
_onFocus = _ref2.onFocus,
|
|
749
|
+
children = _ref2.children,
|
|
750
|
+
_ref2$shortcutsGroup = _ref2.shortcutsGroup,
|
|
751
|
+
shortcutsGroup = _ref2$shortcutsGroup === void 0 ? "custom-editor" : _ref2$shortcutsGroup,
|
|
752
|
+
shortcuts = _ref2.shortcuts;
|
|
753
|
+
var mainElementRef = React.useRef(null);
|
|
754
|
+
var currentValue = React.useRef(undefined);
|
|
755
|
+
var _useState5 = React.useState(),
|
|
756
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
757
|
+
themeClassName = _useState6[0],
|
|
758
|
+
setThemeClassName = _useState6[1];
|
|
759
|
+
var _useContext2 = React.useContext(EditorContext),
|
|
760
|
+
hotCustomEditorInstanceRef = _useContext2.hotCustomEditorInstanceRef;
|
|
761
|
+
var registerShortcuts = React.useCallback(function () {
|
|
762
|
+
var _hotCustomEditorInsta8, _hotCustomEditorInsta9, _hotCustomEditorInsta0;
|
|
763
|
+
if (!((_hotCustomEditorInsta8 = hotCustomEditorInstanceRef.current) !== null && _hotCustomEditorInsta8 !== void 0 && _hotCustomEditorInsta8.hot)) return;
|
|
764
|
+
(_hotCustomEditorInsta9 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta9 === void 0 || (_hotCustomEditorInsta9 = _hotCustomEditorInsta9.hot) === null || _hotCustomEditorInsta9 === void 0 || _hotCustomEditorInsta9.getShortcutManager().setActiveContextName("editor");
|
|
765
|
+
var shortcutManager = (_hotCustomEditorInsta0 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta0 === void 0 || (_hotCustomEditorInsta0 = _hotCustomEditorInsta0.hot) === null || _hotCustomEditorInsta0 === void 0 ? void 0 : _hotCustomEditorInsta0.getShortcutManager();
|
|
766
|
+
var editorContext = shortcutManager.getContext('editor');
|
|
767
|
+
var contextConfig = {
|
|
768
|
+
group: shortcutsGroup
|
|
769
|
+
};
|
|
770
|
+
if (shortcuts) {
|
|
771
|
+
editorContext === null || editorContext === void 0 || editorContext.addShortcuts(shortcuts.map(function (shortcut) {
|
|
772
|
+
return _objectSpread2(_objectSpread2({}, shortcut), {}, {
|
|
773
|
+
group: shortcut.group || shortcutsGroup,
|
|
774
|
+
relativeToGroup: shortcut.relativeToGroup || 'editorManager.handlingEditor',
|
|
775
|
+
position: shortcut.position || 'before',
|
|
776
|
+
callback: function callback(event) {
|
|
777
|
+
return shortcut.callback({
|
|
778
|
+
value: currentValue.current,
|
|
779
|
+
setValue: setValue,
|
|
780
|
+
finishEditing: finishEditing
|
|
781
|
+
}, event);
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
}),
|
|
785
|
+
//@ts-ignore
|
|
786
|
+
contextConfig);
|
|
787
|
+
}
|
|
788
|
+
}, [shortcuts]);
|
|
789
|
+
var unRegisterShortcuts = React.useCallback(function () {
|
|
790
|
+
var _hotCustomEditorInsta1, _hotCustomEditorInsta10;
|
|
791
|
+
if (!((_hotCustomEditorInsta1 = hotCustomEditorInstanceRef.current) !== null && _hotCustomEditorInsta1 !== void 0 && _hotCustomEditorInsta1.hot)) return;
|
|
792
|
+
var shortcutManager = (_hotCustomEditorInsta10 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta10 === void 0 || (_hotCustomEditorInsta10 = _hotCustomEditorInsta10.hot) === null || _hotCustomEditorInsta10 === void 0 ? void 0 : _hotCustomEditorInsta10.getShortcutManager();
|
|
793
|
+
var editorContext = shortcutManager.getContext("editor");
|
|
794
|
+
editorContext.removeShortcutsByGroup(shortcutsGroup);
|
|
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]);
|
|
821
|
+
var _useHotEditor = useHotEditor({
|
|
822
|
+
onOpen: function onOpen() {
|
|
823
|
+
var _hotCustomEditorInsta11;
|
|
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);
|
|
827
|
+
mainElementRef.current.style.display = 'block';
|
|
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
|
+
}
|
|
834
|
+
registerShortcuts();
|
|
835
|
+
registerScrollHooks();
|
|
836
|
+
},
|
|
837
|
+
onClose: function onClose() {
|
|
838
|
+
if (!mainElementRef.current) return;
|
|
839
|
+
mainElementRef.current.style.display = 'none';
|
|
840
|
+
_onClose === null || _onClose === void 0 || _onClose();
|
|
841
|
+
unRegisterShortcuts();
|
|
842
|
+
unRegisterScrollHooks();
|
|
843
|
+
},
|
|
844
|
+
onPrepare: function onPrepare(_row, _column, _prop, TD, _originalValue, _cellProperties) {
|
|
845
|
+
_onPrepare === null || _onPrepare === void 0 || _onPrepare(_row, _column, _prop, TD, _originalValue, _cellProperties);
|
|
846
|
+
},
|
|
847
|
+
onFocus: function onFocus() {
|
|
848
|
+
_onFocus === null || _onFocus === void 0 || _onFocus();
|
|
849
|
+
}
|
|
850
|
+
}),
|
|
851
|
+
value = _useHotEditor.value,
|
|
852
|
+
setValue = _useHotEditor.setValue,
|
|
853
|
+
finishEditing = _useHotEditor.finishEditing,
|
|
854
|
+
isOpen = _useHotEditor.isOpen,
|
|
855
|
+
col = _useHotEditor.col,
|
|
856
|
+
row = _useHotEditor.row;
|
|
857
|
+
React.useEffect(function () {
|
|
858
|
+
currentValue.current = value;
|
|
859
|
+
}, [value]);
|
|
860
|
+
var stopMousedownPropagation = function stopMousedownPropagation(e) {
|
|
861
|
+
e.stopPropagation();
|
|
862
|
+
};
|
|
863
|
+
return React__default["default"].createElement("div", {
|
|
864
|
+
ref: mainElementRef,
|
|
865
|
+
className: themeClassName,
|
|
866
|
+
style: {
|
|
867
|
+
display: 'none',
|
|
868
|
+
position: 'absolute',
|
|
869
|
+
background: '#fff',
|
|
870
|
+
border: '0px',
|
|
871
|
+
padding: '0px',
|
|
872
|
+
zIndex: 100
|
|
873
|
+
},
|
|
874
|
+
onMouseDown: stopMousedownPropagation
|
|
875
|
+
}, children({
|
|
876
|
+
value: value,
|
|
877
|
+
setValue: setValue,
|
|
878
|
+
finishEditing: finishEditing,
|
|
879
|
+
mainElementRef: mainElementRef,
|
|
880
|
+
isOpen: isOpen,
|
|
881
|
+
col: col,
|
|
882
|
+
row: row
|
|
883
|
+
}));
|
|
884
|
+
}
|
|
692
885
|
|
|
693
886
|
var isHotColumn = function isHotColumn(childNode) {
|
|
694
887
|
return childNode.type === HotColumn;
|
|
@@ -763,7 +956,7 @@ var HotColumn = function HotColumn(props) {
|
|
|
763
956
|
}, editorPortal);
|
|
764
957
|
};
|
|
765
958
|
|
|
766
|
-
var version="
|
|
959
|
+
var version="17.0.0-rc10";
|
|
767
960
|
|
|
768
961
|
/**
|
|
769
962
|
* Component used to manage the renderer component portals.
|
|
@@ -2134,6 +2327,8 @@ var HotTable = React.forwardRef(function (_ref, ref) {
|
|
|
2134
2327
|
*/
|
|
2135
2328
|
HotTable.version = version;
|
|
2136
2329
|
|
|
2330
|
+
exports.EditorComponent = EditorComponent;
|
|
2331
|
+
exports.EditorContext = EditorContext;
|
|
2137
2332
|
exports.HotColumn = HotColumn;
|
|
2138
2333
|
exports.HotTable = HotTable;
|
|
2139
2334
|
exports["default"] = HotTable;
|
|
@@ -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:
|
|
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
|
*
|
|
@@ -705,6 +757,147 @@ function useHotEditor(overriddenHooks, deps) {
|
|
|
705
757
|
};
|
|
706
758
|
}, [rerenderTrigger, hotCustomEditorInstanceRef, deferredValue]);
|
|
707
759
|
}
|
|
760
|
+
function EditorComponent(_ref2) {
|
|
761
|
+
var _onPrepare = _ref2.onPrepare,
|
|
762
|
+
_onClose = _ref2.onClose,
|
|
763
|
+
_onOpen = _ref2.onOpen,
|
|
764
|
+
_onFocus = _ref2.onFocus,
|
|
765
|
+
children = _ref2.children,
|
|
766
|
+
_ref2$shortcutsGroup = _ref2.shortcutsGroup,
|
|
767
|
+
shortcutsGroup = _ref2$shortcutsGroup === void 0 ? "custom-editor" : _ref2$shortcutsGroup,
|
|
768
|
+
shortcuts = _ref2.shortcuts;
|
|
769
|
+
var mainElementRef = React.useRef(null);
|
|
770
|
+
var currentValue = React.useRef(undefined);
|
|
771
|
+
var _useState5 = React.useState(),
|
|
772
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
773
|
+
themeClassName = _useState6[0],
|
|
774
|
+
setThemeClassName = _useState6[1];
|
|
775
|
+
var _useContext2 = React.useContext(EditorContext),
|
|
776
|
+
hotCustomEditorInstanceRef = _useContext2.hotCustomEditorInstanceRef;
|
|
777
|
+
var registerShortcuts = React.useCallback(function () {
|
|
778
|
+
var _hotCustomEditorInsta8, _hotCustomEditorInsta9, _hotCustomEditorInsta0;
|
|
779
|
+
if (!((_hotCustomEditorInsta8 = hotCustomEditorInstanceRef.current) !== null && _hotCustomEditorInsta8 !== void 0 && _hotCustomEditorInsta8.hot)) return;
|
|
780
|
+
(_hotCustomEditorInsta9 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta9 === void 0 || (_hotCustomEditorInsta9 = _hotCustomEditorInsta9.hot) === null || _hotCustomEditorInsta9 === void 0 || _hotCustomEditorInsta9.getShortcutManager().setActiveContextName("editor");
|
|
781
|
+
var shortcutManager = (_hotCustomEditorInsta0 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta0 === void 0 || (_hotCustomEditorInsta0 = _hotCustomEditorInsta0.hot) === null || _hotCustomEditorInsta0 === void 0 ? void 0 : _hotCustomEditorInsta0.getShortcutManager();
|
|
782
|
+
var editorContext = shortcutManager.getContext('editor');
|
|
783
|
+
var contextConfig = {
|
|
784
|
+
group: shortcutsGroup
|
|
785
|
+
};
|
|
786
|
+
if (shortcuts) {
|
|
787
|
+
editorContext === null || editorContext === void 0 || editorContext.addShortcuts(shortcuts.map(function (shortcut) {
|
|
788
|
+
return _objectSpread2(_objectSpread2({}, shortcut), {}, {
|
|
789
|
+
group: shortcut.group || shortcutsGroup,
|
|
790
|
+
relativeToGroup: shortcut.relativeToGroup || 'editorManager.handlingEditor',
|
|
791
|
+
position: shortcut.position || 'before',
|
|
792
|
+
callback: function callback(event) {
|
|
793
|
+
return shortcut.callback({
|
|
794
|
+
value: currentValue.current,
|
|
795
|
+
setValue: setValue,
|
|
796
|
+
finishEditing: finishEditing
|
|
797
|
+
}, event);
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
}),
|
|
801
|
+
//@ts-ignore
|
|
802
|
+
contextConfig);
|
|
803
|
+
}
|
|
804
|
+
}, [shortcuts]);
|
|
805
|
+
var unRegisterShortcuts = React.useCallback(function () {
|
|
806
|
+
var _hotCustomEditorInsta1, _hotCustomEditorInsta10;
|
|
807
|
+
if (!((_hotCustomEditorInsta1 = hotCustomEditorInstanceRef.current) !== null && _hotCustomEditorInsta1 !== void 0 && _hotCustomEditorInsta1.hot)) return;
|
|
808
|
+
var shortcutManager = (_hotCustomEditorInsta10 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta10 === void 0 || (_hotCustomEditorInsta10 = _hotCustomEditorInsta10.hot) === null || _hotCustomEditorInsta10 === void 0 ? void 0 : _hotCustomEditorInsta10.getShortcutManager();
|
|
809
|
+
var editorContext = shortcutManager.getContext("editor");
|
|
810
|
+
editorContext.removeShortcutsByGroup(shortcutsGroup);
|
|
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]);
|
|
837
|
+
var _useHotEditor = useHotEditor({
|
|
838
|
+
onOpen: function onOpen() {
|
|
839
|
+
var _hotCustomEditorInsta11;
|
|
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);
|
|
843
|
+
mainElementRef.current.style.display = 'block';
|
|
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
|
+
}
|
|
850
|
+
registerShortcuts();
|
|
851
|
+
registerScrollHooks();
|
|
852
|
+
},
|
|
853
|
+
onClose: function onClose() {
|
|
854
|
+
if (!mainElementRef.current) return;
|
|
855
|
+
mainElementRef.current.style.display = 'none';
|
|
856
|
+
_onClose === null || _onClose === void 0 || _onClose();
|
|
857
|
+
unRegisterShortcuts();
|
|
858
|
+
unRegisterScrollHooks();
|
|
859
|
+
},
|
|
860
|
+
onPrepare: function onPrepare(_row, _column, _prop, TD, _originalValue, _cellProperties) {
|
|
861
|
+
_onPrepare === null || _onPrepare === void 0 || _onPrepare(_row, _column, _prop, TD, _originalValue, _cellProperties);
|
|
862
|
+
},
|
|
863
|
+
onFocus: function onFocus() {
|
|
864
|
+
_onFocus === null || _onFocus === void 0 || _onFocus();
|
|
865
|
+
}
|
|
866
|
+
}),
|
|
867
|
+
value = _useHotEditor.value,
|
|
868
|
+
setValue = _useHotEditor.setValue,
|
|
869
|
+
finishEditing = _useHotEditor.finishEditing,
|
|
870
|
+
isOpen = _useHotEditor.isOpen,
|
|
871
|
+
col = _useHotEditor.col,
|
|
872
|
+
row = _useHotEditor.row;
|
|
873
|
+
React.useEffect(function () {
|
|
874
|
+
currentValue.current = value;
|
|
875
|
+
}, [value]);
|
|
876
|
+
var stopMousedownPropagation = function stopMousedownPropagation(e) {
|
|
877
|
+
e.stopPropagation();
|
|
878
|
+
};
|
|
879
|
+
return React__default["default"].createElement("div", {
|
|
880
|
+
ref: mainElementRef,
|
|
881
|
+
className: themeClassName,
|
|
882
|
+
style: {
|
|
883
|
+
display: 'none',
|
|
884
|
+
position: 'absolute',
|
|
885
|
+
background: '#fff',
|
|
886
|
+
border: '0px',
|
|
887
|
+
padding: '0px',
|
|
888
|
+
zIndex: 100
|
|
889
|
+
},
|
|
890
|
+
onMouseDown: stopMousedownPropagation
|
|
891
|
+
}, children({
|
|
892
|
+
value: value,
|
|
893
|
+
setValue: setValue,
|
|
894
|
+
finishEditing: finishEditing,
|
|
895
|
+
mainElementRef: mainElementRef,
|
|
896
|
+
isOpen: isOpen,
|
|
897
|
+
col: col,
|
|
898
|
+
row: row
|
|
899
|
+
}));
|
|
900
|
+
}
|
|
708
901
|
|
|
709
902
|
var isHotColumn = function isHotColumn(childNode) {
|
|
710
903
|
return childNode.type === HotColumn;
|
|
@@ -779,7 +972,7 @@ var HotColumn = function HotColumn(props) {
|
|
|
779
972
|
}, editorPortal);
|
|
780
973
|
};
|
|
781
974
|
|
|
782
|
-
var version="
|
|
975
|
+
var version="17.0.0-rc10";
|
|
783
976
|
|
|
784
977
|
/**
|
|
785
978
|
* Component used to manage the renderer component portals.
|
|
@@ -1123,6 +1316,8 @@ var HotTable = React.forwardRef(function (_ref, ref) {
|
|
|
1123
1316
|
*/
|
|
1124
1317
|
HotTable.version = version;
|
|
1125
1318
|
|
|
1319
|
+
exports.EditorComponent = EditorComponent;
|
|
1320
|
+
exports.EditorContext = EditorContext;
|
|
1126
1321
|
exports.HotColumn = HotColumn;
|
|
1127
1322
|
exports.HotTable = HotTable;
|
|
1128
1323
|
exports["default"] = HotTable;
|