beesoft-components 0.2.26-5 → 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.
@@ -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;
@@ -31768,10 +31794,8 @@ var FormattedInput = function (props, ref) {
31768
31794
  };
31769
31795
  }, []);
31770
31796
  React.useEffect(function () {
31771
- if (formatParser.current) {
31772
- console.log('value', value);
31773
- formatParser.current.inputValuePassed(value);
31774
- }
31797
+ var _a;
31798
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputValuePassed(value);
31775
31799
  }, [value]);
31776
31800
  React.useEffect(function () {
31777
31801
  var _a, _b, _c;
@@ -31827,16 +31851,22 @@ var FormattedInput = function (props, ref) {
31827
31851
  (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
31828
31852
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
31829
31853
  }, [onBlur]);
31854
+ var onMouseUpHandler = React.useCallback(function () {
31855
+ var _a;
31856
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
31857
+ }, []);
31830
31858
  var onKeyDownHandler = React.useCallback(function (event) {
31831
31859
  var _a;
31832
31860
  (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
31833
31861
  }, []);
31834
31862
  var onInputRefCreated = React.useCallback(function (ref) {
31835
- var _a, _b, _c, _d, _e;
31863
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
31836
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);
31837
31866
  inputRef.current = ref;
31838
- (_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.addEventListener('keydown', onKeyDownHandler);
31839
- inputElementRef.current = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement;
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;
31840
31870
  }, []);
31841
31871
  var focus = React.useCallback(function () {
31842
31872
  var _a;
@@ -32790,11 +32820,9 @@ function DateTime(_a) {
32790
32820
  onDateStringChange(formattedText || '');
32791
32821
  };
32792
32822
  var onDateStringChange = function (dateString) {
32793
- console.log("dateString '".concat(dateString, "'"));
32794
32823
  var inputDate = dateSelection !== DateSelectionType.DateRange
32795
32824
  ? parseDate(dateString, loadedLocale.current)
32796
32825
  : parseDateRange(dateString, loadedLocale.current);
32797
- console.log('inputDate', inputDate);
32798
32826
  if (inputDate) {
32799
32827
  if (!Array.isArray(inputDate)) {
32800
32828
  dispatcher({
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;
@@ -31766,10 +31792,8 @@ var FormattedInput = function (props, ref) {
31766
31792
  };
31767
31793
  }, []);
31768
31794
  useEffect(function () {
31769
- if (formatParser.current) {
31770
- console.log('value', value);
31771
- formatParser.current.inputValuePassed(value);
31772
- }
31795
+ var _a;
31796
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputValuePassed(value);
31773
31797
  }, [value]);
31774
31798
  useEffect(function () {
31775
31799
  var _a, _b, _c;
@@ -31825,16 +31849,22 @@ var FormattedInput = function (props, ref) {
31825
31849
  (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
31826
31850
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
31827
31851
  }, [onBlur]);
31852
+ var onMouseUpHandler = useCallback(function () {
31853
+ var _a;
31854
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
31855
+ }, []);
31828
31856
  var onKeyDownHandler = useCallback(function (event) {
31829
31857
  var _a;
31830
31858
  (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
31831
31859
  }, []);
31832
31860
  var onInputRefCreated = useCallback(function (ref) {
31833
- var _a, _b, _c, _d, _e;
31861
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
31834
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);
31835
31864
  inputRef.current = ref;
31836
- (_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.addEventListener('keydown', onKeyDownHandler);
31837
- inputElementRef.current = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement;
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;
31838
31868
  }, []);
31839
31869
  var focus = useCallback(function () {
31840
31870
  var _a;
@@ -32788,11 +32818,9 @@ function DateTime(_a) {
32788
32818
  onDateStringChange(formattedText || '');
32789
32819
  };
32790
32820
  var onDateStringChange = function (dateString) {
32791
- console.log("dateString '".concat(dateString, "'"));
32792
32821
  var inputDate = dateSelection !== DateSelectionType.DateRange
32793
32822
  ? parseDate(dateString, loadedLocale.current)
32794
32823
  : parseDateRange(dateString, loadedLocale.current);
32795
- console.log('inputDate', inputDate);
32796
32824
  if (inputDate) {
32797
32825
  if (!Array.isArray(inputDate)) {
32798
32826
  dispatcher({