@dmsi/wedgekit-react 0.0.537 → 0.0.539

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.
Files changed (57) hide show
  1. package/dist/{chunk-UV53RKAQ.js → chunk-BKBJOF4J.js} +1 -1
  2. package/dist/{chunk-U6W5E3XW.js → chunk-I5BV7UPG.js} +1 -1
  3. package/dist/{chunk-PMNNRB6S.js → chunk-NWTVBVBC.js} +44 -2
  4. package/dist/{chunk-UFGH5V7K.js → chunk-RB7F6QWD.js} +4 -4
  5. package/dist/{chunk-YHFOOBE2.js → chunk-Y3EFHKAG.js} +1 -1
  6. package/dist/components/CalendarRange.cjs +44 -2
  7. package/dist/components/CalendarRange.js +6 -6
  8. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +44 -2
  9. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +6 -6
  10. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +44 -2
  11. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +6 -6
  12. package/dist/components/DataGrid/PinnedColumns.cjs +44 -2
  13. package/dist/components/DataGrid/PinnedColumns.js +6 -6
  14. package/dist/components/DataGrid/TableBody/LoadingCell.cjs +44 -2
  15. package/dist/components/DataGrid/TableBody/LoadingCell.js +6 -6
  16. package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +44 -2
  17. package/dist/components/DataGrid/TableBody/TableBodyRow.js +6 -6
  18. package/dist/components/DataGrid/TableBody/index.cjs +44 -2
  19. package/dist/components/DataGrid/TableBody/index.js +6 -6
  20. package/dist/components/DataGrid/index.cjs +44 -2
  21. package/dist/components/DataGrid/index.js +6 -6
  22. package/dist/components/DataGrid/utils.cjs +44 -2
  23. package/dist/components/DataGrid/utils.js +6 -6
  24. package/dist/components/DataGridCell.cjs +44 -2
  25. package/dist/components/DataGridCell.js +3 -3
  26. package/dist/components/DateInput.cjs +44 -2
  27. package/dist/components/DateInput.js +6 -6
  28. package/dist/components/DateRangeInput.cjs +44 -2
  29. package/dist/components/DateRangeInput.js +6 -6
  30. package/dist/components/FilterGroup.cjs +44 -2
  31. package/dist/components/FilterGroup.js +2 -2
  32. package/dist/components/Input.cjs +44 -2
  33. package/dist/components/Input.js +1 -1
  34. package/dist/components/MobileDataGrid/ColumnList.js +1 -1
  35. package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +44 -2
  36. package/dist/components/MobileDataGrid/ColumnSelector/index.js +6 -6
  37. package/dist/components/MobileDataGrid/MobileDataGridCard/index.js +1 -1
  38. package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +44 -2
  39. package/dist/components/MobileDataGrid/MobileDataGridHeader.js +6 -6
  40. package/dist/components/MobileDataGrid/RowDetailModalProvider/ModalContent.js +1 -1
  41. package/dist/components/MobileDataGrid/RowDetailModalProvider/index.js +1 -1
  42. package/dist/components/MobileDataGrid/index.cjs +44 -2
  43. package/dist/components/MobileDataGrid/index.js +6 -6
  44. package/dist/components/Password.cjs +44 -2
  45. package/dist/components/Password.js +1 -1
  46. package/dist/components/Search.cjs +44 -2
  47. package/dist/components/Search.js +2 -2
  48. package/dist/components/Select.cjs +44 -2
  49. package/dist/components/Select.js +2 -2
  50. package/dist/components/Stepper.cjs +44 -2
  51. package/dist/components/Stepper.js +1 -1
  52. package/dist/components/Time.cjs +44 -2
  53. package/dist/components/Time.js +1 -1
  54. package/dist/components/index.cjs +44 -2
  55. package/dist/components/index.js +6 -6
  56. package/package.json +1 -1
  57. package/src/components/Input.tsx +62 -4
@@ -1895,7 +1895,7 @@ var Input = (_a) => {
1895
1895
  const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
1896
1896
  setInternalValue(formatted);
1897
1897
  setDisplayValue(formatCurrencyDisplay(formatted));
1898
- }, [variant, propValue, decimals]);
1898
+ }, []);
1899
1899
  const getInputProps = () => {
1900
1900
  var _a2;
1901
1901
  const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
@@ -1980,6 +1980,7 @@ var Input = (_a) => {
1980
1980
  };
1981
1981
  const handleChange = (e) => {
1982
1982
  const rawValue = e.target.value;
1983
+ const maxNumber = props.max != null ? Number(String(props.max).replace(/,/g, "")) : void 0;
1983
1984
  if (variant === "currency") {
1984
1985
  const raw = rawValue.replace(/,/g, "");
1985
1986
  if (raw === "") {
@@ -1998,9 +1999,25 @@ var Input = (_a) => {
1998
1999
  const parts = raw.split(".");
1999
2000
  const currentDecimals = decimals != null ? decimals : 2;
2000
2001
  if (parts.length === 2 && parts[1].length > currentDecimals) return;
2002
+ const asNumber = Number(raw);
2003
+ if (!isNaN(asNumber) && maxNumber != null && asNumber > maxNumber) {
2004
+ const clamped = maxNumber;
2005
+ const formattedClamped = formatDecimalValue(
2006
+ clamped.toString(),
2007
+ currentDecimals
2008
+ );
2009
+ setInternalValue(formattedClamped);
2010
+ setDisplayValue(formatCurrencyDisplay(formattedClamped));
2011
+ if (onChange) {
2012
+ const syntheticEvent = __spreadProps(__spreadValues({}, e), {
2013
+ target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
2014
+ });
2015
+ onChange(syntheticEvent);
2016
+ }
2017
+ return;
2018
+ }
2001
2019
  setInternalValue(raw);
2002
2020
  setDisplayValue(formatCurrencyDisplay(raw));
2003
- const asNumber = Number(raw);
2004
2021
  if (!isNaN(asNumber) && onChange) {
2005
2022
  const syntheticEvent = __spreadProps(__spreadValues({}, e), {
2006
2023
  target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
@@ -2009,6 +2026,31 @@ var Input = (_a) => {
2009
2026
  }
2010
2027
  return;
2011
2028
  }
2029
+ if ((variant === "percentage" || variant === "uom") && e.target.type === "number") {
2030
+ const numeric = Number(rawValue);
2031
+ if (!isNaN(numeric) && maxNumber != null && numeric > maxNumber) {
2032
+ const clamped = maxNumber;
2033
+ const formattedClamped = formatDecimalValue(
2034
+ clamped.toString(),
2035
+ decimals != null ? decimals : 0
2036
+ );
2037
+ setInternalValue(formattedClamped);
2038
+ setDisplayValue(formattedClamped);
2039
+ if (typeof onChange === "function") {
2040
+ const syntheticEvent = __spreadProps(__spreadValues({}, e), {
2041
+ target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
2042
+ });
2043
+ onChange(syntheticEvent);
2044
+ }
2045
+ return;
2046
+ }
2047
+ setInternalValue(rawValue);
2048
+ setDisplayValue(rawValue);
2049
+ if (typeof onChange === "function") {
2050
+ onChange(e);
2051
+ }
2052
+ return;
2053
+ }
2012
2054
  setInternalValue(rawValue);
2013
2055
  setDisplayValue(rawValue);
2014
2056
  if (typeof onChange === "function") {
@@ -2,7 +2,7 @@ import {
2
2
  DataGrid,
3
3
  DateInput,
4
4
  MobileDataGrid
5
- } from "../chunk-UFGH5V7K.js";
5
+ } from "../chunk-RB7F6QWD.js";
6
6
  import "../chunk-M7INAUAJ.js";
7
7
  import "../chunk-ZIPJMN2E.js";
8
8
  import "../chunk-FJFZBIRG.js";
@@ -20,8 +20,8 @@ import "../chunk-3X3Y4TMS.js";
20
20
  import "../chunk-4DXOA7NZ.js";
21
21
  import "../chunk-5BRIDIUA.js";
22
22
  import "../chunk-5IFPG6TS.js";
23
- import "../chunk-AJ5M6MVX.js";
24
23
  import "../chunk-M4FM3B3R.js";
24
+ import "../chunk-AJ5M6MVX.js";
25
25
  import "../chunk-AT4AWD6B.js";
26
26
  import "../chunk-EWGHVZL5.js";
27
27
  import {
@@ -41,7 +41,7 @@ import {
41
41
  } from "../chunk-MDB26F6T.js";
42
42
  import {
43
43
  Select
44
- } from "../chunk-U6W5E3XW.js";
44
+ } from "../chunk-I5BV7UPG.js";
45
45
  import "../chunk-JADOJNBI.js";
46
46
  import "../chunk-4RJKB7LC.js";
47
47
  import "../chunk-WVVEOCEH.js";
@@ -58,7 +58,7 @@ import {
58
58
  DataGridCell,
59
59
  DragAlongCell,
60
60
  DraggableCellHeader
61
- } from "../chunk-YHFOOBE2.js";
61
+ } from "../chunk-Y3EFHKAG.js";
62
62
  import {
63
63
  Menu
64
64
  } from "../chunk-HGLOO52X.js";
@@ -68,10 +68,10 @@ import {
68
68
  } from "../chunk-EZ4KZYKG.js";
69
69
  import {
70
70
  Search
71
- } from "../chunk-UV53RKAQ.js";
71
+ } from "../chunk-BKBJOF4J.js";
72
72
  import {
73
73
  Input
74
- } from "../chunk-PMNNRB6S.js";
74
+ } from "../chunk-NWTVBVBC.js";
75
75
  import {
76
76
  Label
77
77
  } from "../chunk-HXGJVYGQ.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.537",
4
+ "version": "0.0.539",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
@@ -285,7 +285,9 @@ export const Input = ({
285
285
 
286
286
  setInternalValue(formatted);
287
287
  setDisplayValue(formatCurrencyDisplay(formatted));
288
- }, [variant, propValue, decimals]);
288
+ // Intentionally not adding dependencies to avoid formatting on every change
289
+ // eslint-disable-next-line react-hooks/exhaustive-deps
290
+ }, []);
289
291
 
290
292
  const getInputProps = () => {
291
293
  const baseProps = {
@@ -409,6 +411,10 @@ export const Input = ({
409
411
 
410
412
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
411
413
  const rawValue = e.target.value;
414
+ const maxNumber =
415
+ props.max != null
416
+ ? Number(String(props.max).replace(/,/g, ""))
417
+ : undefined;
412
418
 
413
419
  if (variant === "currency") {
414
420
  const raw = rawValue.replace(/,/g, ""); // Remove commas for processing
@@ -420,7 +426,7 @@ export const Input = ({
420
426
  const syntheticEvent = {
421
427
  ...e,
422
428
  target: { ...e.target, value: "" },
423
- };
429
+ } as React.ChangeEvent<HTMLInputElement>;
424
430
  onChange(syntheticEvent);
425
431
  }
426
432
  return;
@@ -433,20 +439,72 @@ export const Input = ({
433
439
  const currentDecimals = decimals ?? 2;
434
440
  if (parts.length === 2 && parts[1].length > currentDecimals) return;
435
441
 
442
+ const asNumber = Number(raw);
443
+ if (!isNaN(asNumber) && maxNumber != null && asNumber > maxNumber) {
444
+ // Clamp to max
445
+ const clamped = maxNumber;
446
+ const formattedClamped = formatDecimalValue(
447
+ clamped.toString(),
448
+ currentDecimals,
449
+ );
450
+ setInternalValue(formattedClamped);
451
+ setDisplayValue(formatCurrencyDisplay(formattedClamped));
452
+ if (onChange) {
453
+ const syntheticEvent = {
454
+ ...e,
455
+ target: { ...e.target, value: clamped.toString() },
456
+ } as React.ChangeEvent<HTMLInputElement>;
457
+ onChange(syntheticEvent);
458
+ }
459
+ return;
460
+ }
461
+
436
462
  setInternalValue(raw);
437
463
  setDisplayValue(formatCurrencyDisplay(raw));
438
464
 
439
- const asNumber = Number(raw);
440
465
  if (!isNaN(asNumber) && onChange) {
441
466
  const syntheticEvent = {
442
467
  ...e,
443
468
  target: { ...e.target, value: asNumber.toString() },
444
- };
469
+ } as React.ChangeEvent<HTMLInputElement>;
445
470
  onChange(syntheticEvent);
446
471
  }
447
472
  return;
448
473
  }
449
474
 
475
+ // Handle numeric variants (percentage / uom) wrt max prop
476
+ if (
477
+ (variant === "percentage" || variant === "uom") &&
478
+ e.target.type === "number"
479
+ ) {
480
+ const numeric = Number(rawValue);
481
+ if (!isNaN(numeric) && maxNumber != null && numeric > maxNumber) {
482
+ const clamped = maxNumber;
483
+ const formattedClamped = formatDecimalValue(
484
+ clamped.toString(),
485
+ decimals ?? 0,
486
+ );
487
+ setInternalValue(formattedClamped);
488
+ setDisplayValue(formattedClamped);
489
+
490
+ if (typeof onChange === "function") {
491
+ const syntheticEvent = {
492
+ ...e,
493
+ target: { ...e.target, value: clamped.toString() },
494
+ } as React.ChangeEvent<HTMLInputElement>;
495
+ onChange(syntheticEvent);
496
+ }
497
+ return;
498
+ }
499
+
500
+ setInternalValue(rawValue);
501
+ setDisplayValue(rawValue);
502
+ if (typeof onChange === "function") {
503
+ onChange(e);
504
+ }
505
+ return;
506
+ }
507
+
450
508
  // Default behavior for other variants
451
509
  setInternalValue(rawValue);
452
510
  setDisplayValue(rawValue);