warqadui 0.0.313 → 0.0.314

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/dist/index.js CHANGED
@@ -52041,18 +52041,34 @@ var NumberInput = (0, import_react177.forwardRef)(
52041
52041
  return String(val);
52042
52042
  };
52043
52043
  const renderInput = (inputRef, currentValue, onValueChange, onInputBlur) => {
52044
- const displayVal = editingText !== null ? editingText : formatDisplay(currentValue);
52044
+ const displayVal = formatDisplay(
52045
+ editingText !== null ? editingText : currentValue
52046
+ );
52045
52047
  const handleChange = (e) => {
52046
- const rawVal = e.target.value.replace(/,/g, "").trim();
52048
+ const target = e.target;
52049
+ const rawVal = target.value.replace(/,/g, "").trim();
52050
+ const regex = allowDecimals ? /^-?\d*\.?\d*$/ : /^-?\d*$/;
52051
+ if (rawVal !== "" && rawVal !== "-" && !regex.test(rawVal)) {
52052
+ return;
52053
+ }
52054
+ if (formatSeparators) {
52055
+ const caret = target.selectionStart ?? target.value.length;
52056
+ const charsBefore = target.value.slice(0, caret).replace(/[,\s]/g, "").length;
52057
+ requestAnimationFrame(() => {
52058
+ let pos = 0;
52059
+ let seen = 0;
52060
+ while (pos < target.value.length && seen < charsBefore) {
52061
+ if (target.value[pos] !== ",") seen++;
52062
+ pos++;
52063
+ }
52064
+ target.setSelectionRange(pos, pos);
52065
+ });
52066
+ }
52047
52067
  if (rawVal === "" || rawVal === "-") {
52048
52068
  setEditingText(rawVal);
52049
52069
  onValueChange(void 0, rawVal);
52050
52070
  return;
52051
52071
  }
52052
- const regex = allowDecimals ? /^-?\d*\.?\d*$/ : /^-?\d*$/;
52053
- if (!regex.test(rawVal)) {
52054
- return;
52055
- }
52056
52072
  setEditingText(rawVal);
52057
52073
  const parsed = allowDecimals ? parseFloat(rawVal) : parseInt(rawVal, 10);
52058
52074
  onValueChange(isNaN(parsed) ? void 0 : parsed, rawVal);
package/dist/index.mjs CHANGED
@@ -52267,18 +52267,34 @@ var NumberInput = forwardRef13(
52267
52267
  return String(val);
52268
52268
  };
52269
52269
  const renderInput = (inputRef, currentValue, onValueChange, onInputBlur) => {
52270
- const displayVal = editingText !== null ? editingText : formatDisplay(currentValue);
52270
+ const displayVal = formatDisplay(
52271
+ editingText !== null ? editingText : currentValue
52272
+ );
52271
52273
  const handleChange = (e) => {
52272
- const rawVal = e.target.value.replace(/,/g, "").trim();
52274
+ const target = e.target;
52275
+ const rawVal = target.value.replace(/,/g, "").trim();
52276
+ const regex = allowDecimals ? /^-?\d*\.?\d*$/ : /^-?\d*$/;
52277
+ if (rawVal !== "" && rawVal !== "-" && !regex.test(rawVal)) {
52278
+ return;
52279
+ }
52280
+ if (formatSeparators) {
52281
+ const caret = target.selectionStart ?? target.value.length;
52282
+ const charsBefore = target.value.slice(0, caret).replace(/[,\s]/g, "").length;
52283
+ requestAnimationFrame(() => {
52284
+ let pos = 0;
52285
+ let seen = 0;
52286
+ while (pos < target.value.length && seen < charsBefore) {
52287
+ if (target.value[pos] !== ",") seen++;
52288
+ pos++;
52289
+ }
52290
+ target.setSelectionRange(pos, pos);
52291
+ });
52292
+ }
52273
52293
  if (rawVal === "" || rawVal === "-") {
52274
52294
  setEditingText(rawVal);
52275
52295
  onValueChange(void 0, rawVal);
52276
52296
  return;
52277
52297
  }
52278
- const regex = allowDecimals ? /^-?\d*\.?\d*$/ : /^-?\d*$/;
52279
- if (!regex.test(rawVal)) {
52280
- return;
52281
- }
52282
52298
  setEditingText(rawVal);
52283
52299
  const parsed = allowDecimals ? parseFloat(rawVal) : parseInt(rawVal, 10);
52284
52300
  onValueChange(isNaN(parsed) ? void 0 : parsed, rawVal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warqadui",
3
- "version": "0.0.313",
3
+ "version": "0.0.314",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",