beesoft-components 0.2.26-6 → 0.3.0-0
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/build/index.cjs.js +35 -3
- package/build/index.js +35 -3
- package/build/index.min.js +3 -3
- package/build/index.min.js.gz +0 -0
- package/build/types/src/components/form/input/formatted-input/parser/format-navigator.d.ts +1 -0
- package/build/types/src/components/form/input/formatted-input/parser/format-parser.d.ts +1 -0
- package/package.json +1 -1
package/build/index.cjs.js
CHANGED
|
@@ -30566,6 +30566,29 @@ var FormatNavigator = (function () {
|
|
|
30566
30566
|
this.setPartIndexByCursorPosition();
|
|
30567
30567
|
}
|
|
30568
30568
|
};
|
|
30569
|
+
FormatNavigator.prototype.findCursorPosition = function () {
|
|
30570
|
+
var _a, _b;
|
|
30571
|
+
var range = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
30572
|
+
if (this.inputElement && range) {
|
|
30573
|
+
var treeWalker = document.createTreeWalker(this.inputElement, NodeFilter.SHOW_TEXT, function (node) {
|
|
30574
|
+
var nodeRange = document.createRange();
|
|
30575
|
+
nodeRange.selectNodeContents(node);
|
|
30576
|
+
return nodeRange.compareBoundaryPoints(Range.END_TO_END, range) < 1
|
|
30577
|
+
? NodeFilter.FILTER_ACCEPT
|
|
30578
|
+
: NodeFilter.FILTER_REJECT;
|
|
30579
|
+
});
|
|
30580
|
+
var cursorPosition = 0;
|
|
30581
|
+
while (treeWalker.nextNode()) {
|
|
30582
|
+
cursorPosition += ((_b = treeWalker.currentNode.textContent) === null || _b === void 0 ? void 0 : _b.length) || 0;
|
|
30583
|
+
}
|
|
30584
|
+
if (range.startContainer.nodeType === Node.TEXT_NODE) {
|
|
30585
|
+
cursorPosition += range.startOffset;
|
|
30586
|
+
}
|
|
30587
|
+
var lastDataSlot = this.inputSlotCollection.getLastSlotWithData();
|
|
30588
|
+
var maximumLength = lastDataSlot.startPosition + lastDataSlot.partText.length;
|
|
30589
|
+
this.setCursorSelection(cursorPosition > maximumLength ? maximumLength : cursorPosition);
|
|
30590
|
+
}
|
|
30591
|
+
};
|
|
30569
30592
|
FormatNavigator.prototype.isAtLastPart = function () {
|
|
30570
30593
|
return this.currentPartIndex === this.formatPartList.length - 1;
|
|
30571
30594
|
};
|
|
@@ -31205,6 +31228,9 @@ var FormatParser = (function () {
|
|
|
31205
31228
|
FormatParser.prototype.registerFormatChangeEvent = function (onFormatChange) {
|
|
31206
31229
|
this.onFormatChange = onFormatChange;
|
|
31207
31230
|
};
|
|
31231
|
+
FormatParser.prototype.mouseUpHandler = function () {
|
|
31232
|
+
this.formatNavigator.findCursorPosition();
|
|
31233
|
+
};
|
|
31208
31234
|
FormatParser.prototype.keyDownHandler = function (event) {
|
|
31209
31235
|
if (event.key === 'Tab') {
|
|
31210
31236
|
return;
|
|
@@ -31825,16 +31851,22 @@ var FormattedInput = function (props, ref) {
|
|
|
31825
31851
|
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
|
|
31826
31852
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
31827
31853
|
}, [onBlur]);
|
|
31854
|
+
var onMouseUpHandler = React.useCallback(function () {
|
|
31855
|
+
var _a;
|
|
31856
|
+
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
|
|
31857
|
+
}, []);
|
|
31828
31858
|
var onKeyDownHandler = React.useCallback(function (event) {
|
|
31829
31859
|
var _a;
|
|
31830
31860
|
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
|
|
31831
31861
|
}, []);
|
|
31832
31862
|
var onInputRefCreated = React.useCallback(function (ref) {
|
|
31833
|
-
var _a, _b, _c, _d, _e;
|
|
31863
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
31834
31864
|
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.inputElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', onKeyDownHandler);
|
|
31865
|
+
(_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseup', onMouseUpHandler);
|
|
31835
31866
|
inputRef.current = ref;
|
|
31836
|
-
(
|
|
31837
|
-
|
|
31867
|
+
(_f = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement) === null || _f === void 0 ? void 0 : _f.addEventListener('keydown', onKeyDownHandler);
|
|
31868
|
+
(_h = (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.inputElement) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseup', onMouseUpHandler);
|
|
31869
|
+
inputElementRef.current = (_j = inputRef.current) === null || _j === void 0 ? void 0 : _j.inputElement;
|
|
31838
31870
|
}, []);
|
|
31839
31871
|
var focus = React.useCallback(function () {
|
|
31840
31872
|
var _a;
|
package/build/index.js
CHANGED
|
@@ -30564,6 +30564,29 @@ var FormatNavigator = (function () {
|
|
|
30564
30564
|
this.setPartIndexByCursorPosition();
|
|
30565
30565
|
}
|
|
30566
30566
|
};
|
|
30567
|
+
FormatNavigator.prototype.findCursorPosition = function () {
|
|
30568
|
+
var _a, _b;
|
|
30569
|
+
var range = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
30570
|
+
if (this.inputElement && range) {
|
|
30571
|
+
var treeWalker = document.createTreeWalker(this.inputElement, NodeFilter.SHOW_TEXT, function (node) {
|
|
30572
|
+
var nodeRange = document.createRange();
|
|
30573
|
+
nodeRange.selectNodeContents(node);
|
|
30574
|
+
return nodeRange.compareBoundaryPoints(Range.END_TO_END, range) < 1
|
|
30575
|
+
? NodeFilter.FILTER_ACCEPT
|
|
30576
|
+
: NodeFilter.FILTER_REJECT;
|
|
30577
|
+
});
|
|
30578
|
+
var cursorPosition = 0;
|
|
30579
|
+
while (treeWalker.nextNode()) {
|
|
30580
|
+
cursorPosition += ((_b = treeWalker.currentNode.textContent) === null || _b === void 0 ? void 0 : _b.length) || 0;
|
|
30581
|
+
}
|
|
30582
|
+
if (range.startContainer.nodeType === Node.TEXT_NODE) {
|
|
30583
|
+
cursorPosition += range.startOffset;
|
|
30584
|
+
}
|
|
30585
|
+
var lastDataSlot = this.inputSlotCollection.getLastSlotWithData();
|
|
30586
|
+
var maximumLength = lastDataSlot.startPosition + lastDataSlot.partText.length;
|
|
30587
|
+
this.setCursorSelection(cursorPosition > maximumLength ? maximumLength : cursorPosition);
|
|
30588
|
+
}
|
|
30589
|
+
};
|
|
30567
30590
|
FormatNavigator.prototype.isAtLastPart = function () {
|
|
30568
30591
|
return this.currentPartIndex === this.formatPartList.length - 1;
|
|
30569
30592
|
};
|
|
@@ -31203,6 +31226,9 @@ var FormatParser = (function () {
|
|
|
31203
31226
|
FormatParser.prototype.registerFormatChangeEvent = function (onFormatChange) {
|
|
31204
31227
|
this.onFormatChange = onFormatChange;
|
|
31205
31228
|
};
|
|
31229
|
+
FormatParser.prototype.mouseUpHandler = function () {
|
|
31230
|
+
this.formatNavigator.findCursorPosition();
|
|
31231
|
+
};
|
|
31206
31232
|
FormatParser.prototype.keyDownHandler = function (event) {
|
|
31207
31233
|
if (event.key === 'Tab') {
|
|
31208
31234
|
return;
|
|
@@ -31823,16 +31849,22 @@ var FormattedInput = function (props, ref) {
|
|
|
31823
31849
|
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
|
|
31824
31850
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
31825
31851
|
}, [onBlur]);
|
|
31852
|
+
var onMouseUpHandler = useCallback(function () {
|
|
31853
|
+
var _a;
|
|
31854
|
+
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
|
|
31855
|
+
}, []);
|
|
31826
31856
|
var onKeyDownHandler = useCallback(function (event) {
|
|
31827
31857
|
var _a;
|
|
31828
31858
|
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
|
|
31829
31859
|
}, []);
|
|
31830
31860
|
var onInputRefCreated = useCallback(function (ref) {
|
|
31831
|
-
var _a, _b, _c, _d, _e;
|
|
31861
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
31832
31862
|
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.inputElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', onKeyDownHandler);
|
|
31863
|
+
(_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseup', onMouseUpHandler);
|
|
31833
31864
|
inputRef.current = ref;
|
|
31834
|
-
(
|
|
31835
|
-
|
|
31865
|
+
(_f = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement) === null || _f === void 0 ? void 0 : _f.addEventListener('keydown', onKeyDownHandler);
|
|
31866
|
+
(_h = (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.inputElement) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseup', onMouseUpHandler);
|
|
31867
|
+
inputElementRef.current = (_j = inputRef.current) === null || _j === void 0 ? void 0 : _j.inputElement;
|
|
31836
31868
|
}, []);
|
|
31837
31869
|
var focus = useCallback(function () {
|
|
31838
31870
|
var _a;
|