beesoft-components 0.2.26-6 → 0.3.0-1

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.
@@ -30376,9 +30376,7 @@ function OverlayPanel(_a) {
30376
30376
  var onEntered = function () {
30377
30377
  if (!panelRef.current)
30378
30378
  return;
30379
- if (shown) {
30380
- shown();
30381
- }
30379
+ shown === null || shown === void 0 ? void 0 : shown();
30382
30380
  var otherElements = undefined;
30383
30381
  if (!shouldTargetCloseOverlay && finalTarget.current) {
30384
30382
  otherElements = [finalTarget.current];
@@ -30403,14 +30401,12 @@ function OverlayPanel(_a) {
30403
30401
  };
30404
30402
  var onExited = function () {
30405
30403
  setZIndex(-1);
30406
- if (hidden) {
30407
- hidden();
30408
- }
30404
+ hidden === null || hidden === void 0 ? void 0 : hidden();
30409
30405
  };
30410
30406
  var onMarkupCreated = function (element) {
30411
30407
  var _a, _b;
30412
30408
  panelRef.current = element;
30413
- markupCreated && markupCreated(element);
30409
+ markupCreated === null || markupCreated === void 0 ? void 0 : markupCreated(element);
30414
30410
  if (finalTarget.current) {
30415
30411
  var position = DomHandler.positionElementToTarget(panelRef.current, finalTarget.current, elementAlignment, targetPosition);
30416
30412
  panelDimensions.current = __assign(__assign({}, position), { width: finalTarget.current.offsetWidth });
@@ -30566,6 +30562,29 @@ var FormatNavigator = (function () {
30566
30562
  this.setPartIndexByCursorPosition();
30567
30563
  }
30568
30564
  };
30565
+ FormatNavigator.prototype.findCursorPosition = function () {
30566
+ var _a, _b;
30567
+ var range = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
30568
+ if (this.inputElement && range) {
30569
+ var treeWalker = document.createTreeWalker(this.inputElement, NodeFilter.SHOW_TEXT, function (node) {
30570
+ var nodeRange = document.createRange();
30571
+ nodeRange.selectNodeContents(node);
30572
+ return nodeRange.compareBoundaryPoints(Range.END_TO_END, range) < 1
30573
+ ? NodeFilter.FILTER_ACCEPT
30574
+ : NodeFilter.FILTER_REJECT;
30575
+ });
30576
+ var cursorPosition = 0;
30577
+ while (treeWalker.nextNode()) {
30578
+ cursorPosition += ((_b = treeWalker.currentNode.textContent) === null || _b === void 0 ? void 0 : _b.length) || 0;
30579
+ }
30580
+ if (range.startContainer.nodeType === Node.TEXT_NODE) {
30581
+ cursorPosition += range.startOffset;
30582
+ }
30583
+ var lastDataSlot = this.inputSlotCollection.getLastSlotWithData();
30584
+ var maximumLength = lastDataSlot.startPosition + lastDataSlot.partText.length;
30585
+ this.setCursorSelection(cursorPosition > maximumLength ? maximumLength : cursorPosition);
30586
+ }
30587
+ };
30569
30588
  FormatNavigator.prototype.isAtLastPart = function () {
30570
30589
  return this.currentPartIndex === this.formatPartList.length - 1;
30571
30590
  };
@@ -31192,8 +31211,13 @@ var FormatParser = (function () {
31192
31211
  FormatParser.prototype.inputValuePassed = function (inputValue) {
31193
31212
  var _this = this;
31194
31213
  this.inputValue = inputValue;
31195
- if (this.inputElementSet && this.inputValue.length > 0) {
31196
- this.inputRuleProcessor.processInputValue(inputValue);
31214
+ if (this.inputElementSet) {
31215
+ if (this.inputValue.length > 0) {
31216
+ this.inputRuleProcessor.processInputValue(inputValue);
31217
+ }
31218
+ else {
31219
+ this.inputSlotCollection.clearAllSlots();
31220
+ }
31197
31221
  setTimeout(function () {
31198
31222
  _this.formatRenderer.render();
31199
31223
  if (_this.isInputFocused) {
@@ -31205,6 +31229,9 @@ var FormatParser = (function () {
31205
31229
  FormatParser.prototype.registerFormatChangeEvent = function (onFormatChange) {
31206
31230
  this.onFormatChange = onFormatChange;
31207
31231
  };
31232
+ FormatParser.prototype.mouseUpHandler = function () {
31233
+ this.formatNavigator.findCursorPosition();
31234
+ };
31208
31235
  FormatParser.prototype.keyDownHandler = function (event) {
31209
31236
  if (event.key === 'Tab') {
31210
31237
  return;
@@ -31825,16 +31852,22 @@ var FormattedInput = function (props, ref) {
31825
31852
  (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
31826
31853
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
31827
31854
  }, [onBlur]);
31855
+ var onMouseUpHandler = React.useCallback(function () {
31856
+ var _a;
31857
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
31858
+ }, []);
31828
31859
  var onKeyDownHandler = React.useCallback(function (event) {
31829
31860
  var _a;
31830
31861
  (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
31831
31862
  }, []);
31832
31863
  var onInputRefCreated = React.useCallback(function (ref) {
31833
- var _a, _b, _c, _d, _e;
31864
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
31834
31865
  (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.inputElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', onKeyDownHandler);
31866
+ (_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseup', onMouseUpHandler);
31835
31867
  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;
31868
+ (_f = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement) === null || _f === void 0 ? void 0 : _f.addEventListener('keydown', onKeyDownHandler);
31869
+ (_h = (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.inputElement) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseup', onMouseUpHandler);
31870
+ inputElementRef.current = (_j = inputRef.current) === null || _j === void 0 ? void 0 : _j.inputElement;
31838
31871
  }, []);
31839
31872
  var focus = React.useCallback(function () {
31840
31873
  var _a;
package/build/index.js CHANGED
@@ -30374,9 +30374,7 @@ function OverlayPanel(_a) {
30374
30374
  var onEntered = function () {
30375
30375
  if (!panelRef.current)
30376
30376
  return;
30377
- if (shown) {
30378
- shown();
30379
- }
30377
+ shown === null || shown === void 0 ? void 0 : shown();
30380
30378
  var otherElements = undefined;
30381
30379
  if (!shouldTargetCloseOverlay && finalTarget.current) {
30382
30380
  otherElements = [finalTarget.current];
@@ -30401,14 +30399,12 @@ function OverlayPanel(_a) {
30401
30399
  };
30402
30400
  var onExited = function () {
30403
30401
  setZIndex(-1);
30404
- if (hidden) {
30405
- hidden();
30406
- }
30402
+ hidden === null || hidden === void 0 ? void 0 : hidden();
30407
30403
  };
30408
30404
  var onMarkupCreated = function (element) {
30409
30405
  var _a, _b;
30410
30406
  panelRef.current = element;
30411
- markupCreated && markupCreated(element);
30407
+ markupCreated === null || markupCreated === void 0 ? void 0 : markupCreated(element);
30412
30408
  if (finalTarget.current) {
30413
30409
  var position = DomHandler.positionElementToTarget(panelRef.current, finalTarget.current, elementAlignment, targetPosition);
30414
30410
  panelDimensions.current = __assign(__assign({}, position), { width: finalTarget.current.offsetWidth });
@@ -30564,6 +30560,29 @@ var FormatNavigator = (function () {
30564
30560
  this.setPartIndexByCursorPosition();
30565
30561
  }
30566
30562
  };
30563
+ FormatNavigator.prototype.findCursorPosition = function () {
30564
+ var _a, _b;
30565
+ var range = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
30566
+ if (this.inputElement && range) {
30567
+ var treeWalker = document.createTreeWalker(this.inputElement, NodeFilter.SHOW_TEXT, function (node) {
30568
+ var nodeRange = document.createRange();
30569
+ nodeRange.selectNodeContents(node);
30570
+ return nodeRange.compareBoundaryPoints(Range.END_TO_END, range) < 1
30571
+ ? NodeFilter.FILTER_ACCEPT
30572
+ : NodeFilter.FILTER_REJECT;
30573
+ });
30574
+ var cursorPosition = 0;
30575
+ while (treeWalker.nextNode()) {
30576
+ cursorPosition += ((_b = treeWalker.currentNode.textContent) === null || _b === void 0 ? void 0 : _b.length) || 0;
30577
+ }
30578
+ if (range.startContainer.nodeType === Node.TEXT_NODE) {
30579
+ cursorPosition += range.startOffset;
30580
+ }
30581
+ var lastDataSlot = this.inputSlotCollection.getLastSlotWithData();
30582
+ var maximumLength = lastDataSlot.startPosition + lastDataSlot.partText.length;
30583
+ this.setCursorSelection(cursorPosition > maximumLength ? maximumLength : cursorPosition);
30584
+ }
30585
+ };
30567
30586
  FormatNavigator.prototype.isAtLastPart = function () {
30568
30587
  return this.currentPartIndex === this.formatPartList.length - 1;
30569
30588
  };
@@ -31190,8 +31209,13 @@ var FormatParser = (function () {
31190
31209
  FormatParser.prototype.inputValuePassed = function (inputValue) {
31191
31210
  var _this = this;
31192
31211
  this.inputValue = inputValue;
31193
- if (this.inputElementSet && this.inputValue.length > 0) {
31194
- this.inputRuleProcessor.processInputValue(inputValue);
31212
+ if (this.inputElementSet) {
31213
+ if (this.inputValue.length > 0) {
31214
+ this.inputRuleProcessor.processInputValue(inputValue);
31215
+ }
31216
+ else {
31217
+ this.inputSlotCollection.clearAllSlots();
31218
+ }
31195
31219
  setTimeout(function () {
31196
31220
  _this.formatRenderer.render();
31197
31221
  if (_this.isInputFocused) {
@@ -31203,6 +31227,9 @@ var FormatParser = (function () {
31203
31227
  FormatParser.prototype.registerFormatChangeEvent = function (onFormatChange) {
31204
31228
  this.onFormatChange = onFormatChange;
31205
31229
  };
31230
+ FormatParser.prototype.mouseUpHandler = function () {
31231
+ this.formatNavigator.findCursorPosition();
31232
+ };
31206
31233
  FormatParser.prototype.keyDownHandler = function (event) {
31207
31234
  if (event.key === 'Tab') {
31208
31235
  return;
@@ -31823,16 +31850,22 @@ var FormattedInput = function (props, ref) {
31823
31850
  (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
31824
31851
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
31825
31852
  }, [onBlur]);
31853
+ var onMouseUpHandler = useCallback(function () {
31854
+ var _a;
31855
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
31856
+ }, []);
31826
31857
  var onKeyDownHandler = useCallback(function (event) {
31827
31858
  var _a;
31828
31859
  (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
31829
31860
  }, []);
31830
31861
  var onInputRefCreated = useCallback(function (ref) {
31831
- var _a, _b, _c, _d, _e;
31862
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
31832
31863
  (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.inputElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', onKeyDownHandler);
31864
+ (_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseup', onMouseUpHandler);
31833
31865
  inputRef.current = ref;
31834
- (_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.addEventListener('keydown', onKeyDownHandler);
31835
- inputElementRef.current = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement;
31866
+ (_f = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement) === null || _f === void 0 ? void 0 : _f.addEventListener('keydown', onKeyDownHandler);
31867
+ (_h = (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.inputElement) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseup', onMouseUpHandler);
31868
+ inputElementRef.current = (_j = inputRef.current) === null || _j === void 0 ? void 0 : _j.inputElement;
31836
31869
  }, []);
31837
31870
  var focus = useCallback(function () {
31838
31871
  var _a;