osl-base-extended 17.3.1 → 17.4.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.
@@ -1627,7 +1627,7 @@ class Oslinput {
1627
1627
  event.preventDefault();
1628
1628
  return;
1629
1629
  }
1630
- if (key === '.' && (this.decimalPortion === 0 || String(this.model ?? '').includes('.'))) {
1630
+ if (key === '.' && (this.decimalPortion === 0 || this.valueOutsideSelection(event.target).includes('.'))) {
1631
1631
  event.preventDefault();
1632
1632
  return;
1633
1633
  }
@@ -1681,7 +1681,14 @@ class Oslinput {
1681
1681
  allowNegativeAt(input) {
1682
1682
  if (!this.allowNegative)
1683
1683
  return false;
1684
- return (input.selectionStart ?? 0) === 0 && !input.value.includes('-');
1684
+ return (input.selectionStart ?? 0) === 0 && !this.valueOutsideSelection(input).includes('-');
1685
+ }
1686
+ /** The input's value minus the currently selected text (which the next keystroke replaces). */
1687
+ valueOutsideSelection(input) {
1688
+ const val = input.value;
1689
+ const selStart = input.selectionStart ?? val.length;
1690
+ const selEnd = input.selectionEnd ?? selStart;
1691
+ return val.slice(0, selStart) + val.slice(selEnd);
1685
1692
  }
1686
1693
  isKeyAllowedByMask(key) {
1687
1694
  const maskSlots = new Set();