@dmsi/wedgekit-react 0.0.1248 → 0.0.1249
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/{chunk-MOBFZ672.js → chunk-3DJWSTPS.js} +1 -1
- package/dist/{chunk-EA6Y4HXQ.js → chunk-4FUZDLWX.js} +1 -1
- package/dist/{chunk-PABII472.js → chunk-H5SHC4XZ.js} +40 -33
- package/dist/{chunk-PBJ2MEHM.js → chunk-QW4AJ5FK.js} +1 -1
- package/dist/{chunk-5UPADXVU.js → chunk-WSZ3ET5G.js} +4 -4
- package/dist/components/CalendarRange.cjs +40 -33
- package/dist/components/CalendarRange.js +5 -5
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +40 -33
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +5 -5
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +40 -33
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +5 -5
- package/dist/components/DataGrid/PinnedColumns.cjs +40 -33
- package/dist/components/DataGrid/PinnedColumns.js +5 -5
- package/dist/components/DataGrid/TableBody/LoadingCell.cjs +40 -33
- package/dist/components/DataGrid/TableBody/LoadingCell.js +5 -5
- package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +40 -33
- package/dist/components/DataGrid/TableBody/TableBodyRow.js +5 -5
- package/dist/components/DataGrid/TableBody/index.cjs +40 -33
- package/dist/components/DataGrid/TableBody/index.js +5 -5
- package/dist/components/DataGrid/index.cjs +40 -33
- package/dist/components/DataGrid/index.js +5 -5
- package/dist/components/DataGrid/utils.cjs +40 -33
- package/dist/components/DataGrid/utils.js +5 -5
- package/dist/components/DataGridCell.cjs +40 -33
- package/dist/components/DataGridCell.js +3 -3
- package/dist/components/DateInput.cjs +40 -33
- package/dist/components/DateInput.js +5 -5
- package/dist/components/DateRangeInput.cjs +40 -33
- package/dist/components/DateRangeInput.js +5 -5
- package/dist/components/FilterGroup.cjs +40 -33
- package/dist/components/FilterGroup.js +2 -2
- package/dist/components/Input.cjs +40 -33
- package/dist/components/Input.js +1 -1
- package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +40 -33
- package/dist/components/MobileDataGrid/ColumnSelector/index.js +5 -5
- package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +40 -33
- package/dist/components/MobileDataGrid/MobileDataGridHeader.js +5 -5
- package/dist/components/MobileDataGrid/index.cjs +40 -33
- package/dist/components/MobileDataGrid/index.js +5 -5
- package/dist/components/Password.cjs +40 -33
- package/dist/components/Password.js +1 -1
- package/dist/components/Search.cjs +40 -33
- package/dist/components/Search.js +2 -2
- package/dist/components/Select.cjs +40 -33
- package/dist/components/Select.js +2 -2
- package/dist/components/Stepper.cjs +40 -33
- package/dist/components/Stepper.js +1 -1
- package/dist/components/Time.cjs +40 -33
- package/dist/components/Time.js +1 -1
- package/dist/components/index.cjs +40 -33
- package/dist/components/index.js +5 -5
- package/package.json +1 -1
|
@@ -376,6 +376,14 @@ Paragraph.displayName = "Paragraph";
|
|
|
376
376
|
|
|
377
377
|
// src/components/Input.tsx
|
|
378
378
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
379
|
+
function hasEquivalentNumericValue(currentValue, nextValue) {
|
|
380
|
+
if (!currentValue || !nextValue) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
const currentNumericValue = Number(currentValue.replace(/,/g, ""));
|
|
384
|
+
const nextNumericValue = Number(nextValue.replace(/,/g, ""));
|
|
385
|
+
return !Number.isNaN(currentNumericValue) && !Number.isNaN(nextNumericValue) && currentNumericValue === nextNumericValue;
|
|
386
|
+
}
|
|
379
387
|
var InputBase = (_a) => {
|
|
380
388
|
var _b = _a, {
|
|
381
389
|
id,
|
|
@@ -598,28 +606,33 @@ var Input = (_a) => {
|
|
|
598
606
|
const [internalValue, setInternalValue] = (0, import_react.useState)("");
|
|
599
607
|
const [displayValue, setDisplayValue] = (0, import_react.useState)("");
|
|
600
608
|
const [isFocused, setIsFocused] = (0, import_react.useState)(false);
|
|
609
|
+
const internalValueRef = (0, import_react.useRef)("");
|
|
610
|
+
const setInputValues = (nextInternalValue, nextDisplayValue) => {
|
|
611
|
+
internalValueRef.current = nextInternalValue;
|
|
612
|
+
setInternalValue(nextInternalValue);
|
|
613
|
+
setDisplayValue(nextDisplayValue);
|
|
614
|
+
};
|
|
601
615
|
(0, import_react.useEffect)(() => {
|
|
602
616
|
var _a2;
|
|
603
617
|
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
604
618
|
const shouldUseThousandsFormatting = variant === "currency" || variant === "uom" && currencyFormat;
|
|
605
619
|
if (!stringValue) {
|
|
606
|
-
|
|
607
|
-
setDisplayValue("");
|
|
620
|
+
setInputValues("", "");
|
|
608
621
|
return;
|
|
609
622
|
}
|
|
610
623
|
if (!shouldUseThousandsFormatting) {
|
|
611
|
-
|
|
612
|
-
|
|
624
|
+
setInputValues(stringValue, stringValue);
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (isFocused && hasEquivalentNumericValue(internalValueRef.current, stringValue)) {
|
|
613
628
|
return;
|
|
614
629
|
}
|
|
615
|
-
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
616
630
|
if (formatOnBlur && isFocused) {
|
|
617
|
-
|
|
618
|
-
setDisplayValue(stringValue);
|
|
631
|
+
setInputValues(stringValue, stringValue);
|
|
619
632
|
return;
|
|
620
633
|
}
|
|
621
|
-
|
|
622
|
-
|
|
634
|
+
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
635
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
623
636
|
}, [propValue, variant, currencyFormat, decimals, formatOnBlur, isFocused]);
|
|
624
637
|
const getInputProps = () => {
|
|
625
638
|
var _a2;
|
|
@@ -641,6 +654,7 @@ var Input = (_a) => {
|
|
|
641
654
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
642
655
|
align: "right",
|
|
643
656
|
type: "text",
|
|
657
|
+
inputMode: "decimal",
|
|
644
658
|
value: displayValue
|
|
645
659
|
});
|
|
646
660
|
case "percentage":
|
|
@@ -648,6 +662,7 @@ var Input = (_a) => {
|
|
|
648
662
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
649
663
|
type: currencyFormat ? "text" : "number",
|
|
650
664
|
align: "right",
|
|
665
|
+
inputMode: currencyFormat ? "decimal" : void 0,
|
|
651
666
|
value: currencyFormat ? displayValue : propValue
|
|
652
667
|
});
|
|
653
668
|
default:
|
|
@@ -694,8 +709,7 @@ var Input = (_a) => {
|
|
|
694
709
|
}
|
|
695
710
|
};
|
|
696
711
|
const handleSearchReset = () => {
|
|
697
|
-
|
|
698
|
-
setDisplayValue("");
|
|
712
|
+
setInputValues("", "");
|
|
699
713
|
if (onChange) {
|
|
700
714
|
const syntheticEvent = {
|
|
701
715
|
target: { value: "" }
|
|
@@ -712,8 +726,7 @@ var Input = (_a) => {
|
|
|
712
726
|
if (variant === "currency") {
|
|
713
727
|
const raw = rawValue.replace(/,/g, "");
|
|
714
728
|
if (raw === "") {
|
|
715
|
-
|
|
716
|
-
setDisplayValue("");
|
|
729
|
+
setInputValues("", "");
|
|
717
730
|
if (onChange) {
|
|
718
731
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
719
732
|
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
@@ -734,8 +747,8 @@ var Input = (_a) => {
|
|
|
734
747
|
clamped.toString(),
|
|
735
748
|
currentDecimals
|
|
736
749
|
);
|
|
737
|
-
|
|
738
|
-
|
|
750
|
+
setInputValues(
|
|
751
|
+
formattedClamped,
|
|
739
752
|
formatOnBlur ? formattedClamped : formatCurrencyDisplay(formattedClamped)
|
|
740
753
|
);
|
|
741
754
|
if (onChange) {
|
|
@@ -746,8 +759,7 @@ var Input = (_a) => {
|
|
|
746
759
|
}
|
|
747
760
|
return;
|
|
748
761
|
}
|
|
749
|
-
|
|
750
|
-
setDisplayValue(formatOnBlur ? raw : formatCurrencyDisplay(raw));
|
|
762
|
+
setInputValues(raw, formatOnBlur ? raw : formatCurrencyDisplay(raw));
|
|
751
763
|
if (!isNaN(asNumber) && onChange) {
|
|
752
764
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
753
765
|
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
@@ -759,8 +771,7 @@ var Input = (_a) => {
|
|
|
759
771
|
if (variant === "uom" && currencyFormat) {
|
|
760
772
|
const raw = rawValue.replace(/,/g, "");
|
|
761
773
|
if (raw === "") {
|
|
762
|
-
|
|
763
|
-
setDisplayValue("");
|
|
774
|
+
setInputValues("", "");
|
|
764
775
|
if (onChange) {
|
|
765
776
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
766
777
|
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
@@ -781,8 +792,10 @@ var Input = (_a) => {
|
|
|
781
792
|
clamped.toString(),
|
|
782
793
|
currentDecimals
|
|
783
794
|
);
|
|
784
|
-
|
|
785
|
-
|
|
795
|
+
setInputValues(
|
|
796
|
+
formattedClamped,
|
|
797
|
+
formatCurrencyDisplay(formattedClamped)
|
|
798
|
+
);
|
|
786
799
|
if (onChange) {
|
|
787
800
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
788
801
|
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
@@ -791,8 +804,7 @@ var Input = (_a) => {
|
|
|
791
804
|
}
|
|
792
805
|
return;
|
|
793
806
|
}
|
|
794
|
-
|
|
795
|
-
setDisplayValue(formatCurrencyDisplay(raw));
|
|
807
|
+
setInputValues(raw, formatCurrencyDisplay(raw));
|
|
796
808
|
if (!isNaN(asNumber) && onChange) {
|
|
797
809
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
798
810
|
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
@@ -809,8 +821,7 @@ var Input = (_a) => {
|
|
|
809
821
|
clamped.toString(),
|
|
810
822
|
decimals != null ? decimals : 0
|
|
811
823
|
);
|
|
812
|
-
|
|
813
|
-
setDisplayValue(formattedClamped);
|
|
824
|
+
setInputValues(formattedClamped, formattedClamped);
|
|
814
825
|
if (typeof onChange === "function") {
|
|
815
826
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
816
827
|
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
@@ -819,15 +830,13 @@ var Input = (_a) => {
|
|
|
819
830
|
}
|
|
820
831
|
return;
|
|
821
832
|
}
|
|
822
|
-
|
|
823
|
-
setDisplayValue(rawValue);
|
|
833
|
+
setInputValues(rawValue, rawValue);
|
|
824
834
|
if (typeof onChange === "function") {
|
|
825
835
|
onChange(e);
|
|
826
836
|
}
|
|
827
837
|
return;
|
|
828
838
|
}
|
|
829
|
-
|
|
830
|
-
setDisplayValue(rawValue);
|
|
839
|
+
setInputValues(rawValue, rawValue);
|
|
831
840
|
if (typeof onChange === "function") {
|
|
832
841
|
onChange(e);
|
|
833
842
|
}
|
|
@@ -840,8 +849,7 @@ var Input = (_a) => {
|
|
|
840
849
|
}
|
|
841
850
|
if (variant === "currency") {
|
|
842
851
|
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
843
|
-
|
|
844
|
-
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
852
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
845
853
|
const asNumber = Number(formatted);
|
|
846
854
|
if (!isNaN(asNumber) && onChange) {
|
|
847
855
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
@@ -852,8 +860,7 @@ var Input = (_a) => {
|
|
|
852
860
|
} else if (variant === "uom") {
|
|
853
861
|
if (currencyFormat) {
|
|
854
862
|
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
855
|
-
|
|
856
|
-
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
863
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
857
864
|
const asNumber = Number(formatted);
|
|
858
865
|
if (!isNaN(asNumber) && onChange) {
|
|
859
866
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Search
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-3DJWSTPS.js";
|
|
5
|
+
import "../chunk-H5SHC4XZ.js";
|
|
6
6
|
import "../chunk-4UGMSWWA.js";
|
|
7
7
|
import "../chunk-5UH6QUFB.js";
|
|
8
8
|
import "../chunk-7MBRCM3M.js";
|
|
@@ -376,6 +376,14 @@ Paragraph.displayName = "Paragraph";
|
|
|
376
376
|
|
|
377
377
|
// src/components/Input.tsx
|
|
378
378
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
379
|
+
function hasEquivalentNumericValue(currentValue, nextValue) {
|
|
380
|
+
if (!currentValue || !nextValue) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
const currentNumericValue = Number(currentValue.replace(/,/g, ""));
|
|
384
|
+
const nextNumericValue = Number(nextValue.replace(/,/g, ""));
|
|
385
|
+
return !Number.isNaN(currentNumericValue) && !Number.isNaN(nextNumericValue) && currentNumericValue === nextNumericValue;
|
|
386
|
+
}
|
|
379
387
|
var InputBase = (_a) => {
|
|
380
388
|
var _b = _a, {
|
|
381
389
|
id,
|
|
@@ -598,28 +606,33 @@ var Input = (_a) => {
|
|
|
598
606
|
const [internalValue, setInternalValue] = (0, import_react.useState)("");
|
|
599
607
|
const [displayValue, setDisplayValue] = (0, import_react.useState)("");
|
|
600
608
|
const [isFocused, setIsFocused] = (0, import_react.useState)(false);
|
|
609
|
+
const internalValueRef = (0, import_react.useRef)("");
|
|
610
|
+
const setInputValues = (nextInternalValue, nextDisplayValue) => {
|
|
611
|
+
internalValueRef.current = nextInternalValue;
|
|
612
|
+
setInternalValue(nextInternalValue);
|
|
613
|
+
setDisplayValue(nextDisplayValue);
|
|
614
|
+
};
|
|
601
615
|
(0, import_react.useEffect)(() => {
|
|
602
616
|
var _a2;
|
|
603
617
|
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
604
618
|
const shouldUseThousandsFormatting = variant === "currency" || variant === "uom" && currencyFormat;
|
|
605
619
|
if (!stringValue) {
|
|
606
|
-
|
|
607
|
-
setDisplayValue("");
|
|
620
|
+
setInputValues("", "");
|
|
608
621
|
return;
|
|
609
622
|
}
|
|
610
623
|
if (!shouldUseThousandsFormatting) {
|
|
611
|
-
|
|
612
|
-
|
|
624
|
+
setInputValues(stringValue, stringValue);
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (isFocused && hasEquivalentNumericValue(internalValueRef.current, stringValue)) {
|
|
613
628
|
return;
|
|
614
629
|
}
|
|
615
|
-
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
616
630
|
if (formatOnBlur && isFocused) {
|
|
617
|
-
|
|
618
|
-
setDisplayValue(stringValue);
|
|
631
|
+
setInputValues(stringValue, stringValue);
|
|
619
632
|
return;
|
|
620
633
|
}
|
|
621
|
-
|
|
622
|
-
|
|
634
|
+
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
635
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
623
636
|
}, [propValue, variant, currencyFormat, decimals, formatOnBlur, isFocused]);
|
|
624
637
|
const getInputProps = () => {
|
|
625
638
|
var _a2;
|
|
@@ -641,6 +654,7 @@ var Input = (_a) => {
|
|
|
641
654
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
642
655
|
align: "right",
|
|
643
656
|
type: "text",
|
|
657
|
+
inputMode: "decimal",
|
|
644
658
|
value: displayValue
|
|
645
659
|
});
|
|
646
660
|
case "percentage":
|
|
@@ -648,6 +662,7 @@ var Input = (_a) => {
|
|
|
648
662
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
649
663
|
type: currencyFormat ? "text" : "number",
|
|
650
664
|
align: "right",
|
|
665
|
+
inputMode: currencyFormat ? "decimal" : void 0,
|
|
651
666
|
value: currencyFormat ? displayValue : propValue
|
|
652
667
|
});
|
|
653
668
|
default:
|
|
@@ -694,8 +709,7 @@ var Input = (_a) => {
|
|
|
694
709
|
}
|
|
695
710
|
};
|
|
696
711
|
const handleSearchReset = () => {
|
|
697
|
-
|
|
698
|
-
setDisplayValue("");
|
|
712
|
+
setInputValues("", "");
|
|
699
713
|
if (onChange) {
|
|
700
714
|
const syntheticEvent = {
|
|
701
715
|
target: { value: "" }
|
|
@@ -712,8 +726,7 @@ var Input = (_a) => {
|
|
|
712
726
|
if (variant === "currency") {
|
|
713
727
|
const raw = rawValue.replace(/,/g, "");
|
|
714
728
|
if (raw === "") {
|
|
715
|
-
|
|
716
|
-
setDisplayValue("");
|
|
729
|
+
setInputValues("", "");
|
|
717
730
|
if (onChange) {
|
|
718
731
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
719
732
|
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
@@ -734,8 +747,8 @@ var Input = (_a) => {
|
|
|
734
747
|
clamped.toString(),
|
|
735
748
|
currentDecimals
|
|
736
749
|
);
|
|
737
|
-
|
|
738
|
-
|
|
750
|
+
setInputValues(
|
|
751
|
+
formattedClamped,
|
|
739
752
|
formatOnBlur ? formattedClamped : formatCurrencyDisplay(formattedClamped)
|
|
740
753
|
);
|
|
741
754
|
if (onChange) {
|
|
@@ -746,8 +759,7 @@ var Input = (_a) => {
|
|
|
746
759
|
}
|
|
747
760
|
return;
|
|
748
761
|
}
|
|
749
|
-
|
|
750
|
-
setDisplayValue(formatOnBlur ? raw : formatCurrencyDisplay(raw));
|
|
762
|
+
setInputValues(raw, formatOnBlur ? raw : formatCurrencyDisplay(raw));
|
|
751
763
|
if (!isNaN(asNumber) && onChange) {
|
|
752
764
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
753
765
|
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
@@ -759,8 +771,7 @@ var Input = (_a) => {
|
|
|
759
771
|
if (variant === "uom" && currencyFormat) {
|
|
760
772
|
const raw = rawValue.replace(/,/g, "");
|
|
761
773
|
if (raw === "") {
|
|
762
|
-
|
|
763
|
-
setDisplayValue("");
|
|
774
|
+
setInputValues("", "");
|
|
764
775
|
if (onChange) {
|
|
765
776
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
766
777
|
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
@@ -781,8 +792,10 @@ var Input = (_a) => {
|
|
|
781
792
|
clamped.toString(),
|
|
782
793
|
currentDecimals
|
|
783
794
|
);
|
|
784
|
-
|
|
785
|
-
|
|
795
|
+
setInputValues(
|
|
796
|
+
formattedClamped,
|
|
797
|
+
formatCurrencyDisplay(formattedClamped)
|
|
798
|
+
);
|
|
786
799
|
if (onChange) {
|
|
787
800
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
788
801
|
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
@@ -791,8 +804,7 @@ var Input = (_a) => {
|
|
|
791
804
|
}
|
|
792
805
|
return;
|
|
793
806
|
}
|
|
794
|
-
|
|
795
|
-
setDisplayValue(formatCurrencyDisplay(raw));
|
|
807
|
+
setInputValues(raw, formatCurrencyDisplay(raw));
|
|
796
808
|
if (!isNaN(asNumber) && onChange) {
|
|
797
809
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
798
810
|
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
@@ -809,8 +821,7 @@ var Input = (_a) => {
|
|
|
809
821
|
clamped.toString(),
|
|
810
822
|
decimals != null ? decimals : 0
|
|
811
823
|
);
|
|
812
|
-
|
|
813
|
-
setDisplayValue(formattedClamped);
|
|
824
|
+
setInputValues(formattedClamped, formattedClamped);
|
|
814
825
|
if (typeof onChange === "function") {
|
|
815
826
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
816
827
|
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
@@ -819,15 +830,13 @@ var Input = (_a) => {
|
|
|
819
830
|
}
|
|
820
831
|
return;
|
|
821
832
|
}
|
|
822
|
-
|
|
823
|
-
setDisplayValue(rawValue);
|
|
833
|
+
setInputValues(rawValue, rawValue);
|
|
824
834
|
if (typeof onChange === "function") {
|
|
825
835
|
onChange(e);
|
|
826
836
|
}
|
|
827
837
|
return;
|
|
828
838
|
}
|
|
829
|
-
|
|
830
|
-
setDisplayValue(rawValue);
|
|
839
|
+
setInputValues(rawValue, rawValue);
|
|
831
840
|
if (typeof onChange === "function") {
|
|
832
841
|
onChange(e);
|
|
833
842
|
}
|
|
@@ -840,8 +849,7 @@ var Input = (_a) => {
|
|
|
840
849
|
}
|
|
841
850
|
if (variant === "currency") {
|
|
842
851
|
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
843
|
-
|
|
844
|
-
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
852
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
845
853
|
const asNumber = Number(formatted);
|
|
846
854
|
if (!isNaN(asNumber) && onChange) {
|
|
847
855
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
@@ -852,8 +860,7 @@ var Input = (_a) => {
|
|
|
852
860
|
} else if (variant === "uom") {
|
|
853
861
|
if (currencyFormat) {
|
|
854
862
|
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
855
|
-
|
|
856
|
-
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
863
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
857
864
|
const asNumber = Number(formatted);
|
|
858
865
|
if (!isNaN(asNumber) && onChange) {
|
|
859
866
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Select
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-4FUZDLWX.js";
|
|
5
|
+
import "../chunk-H5SHC4XZ.js";
|
|
6
6
|
import "../chunk-4UGMSWWA.js";
|
|
7
7
|
import "../chunk-5UH6QUFB.js";
|
|
8
8
|
import "../chunk-7MBRCM3M.js";
|
|
@@ -571,6 +571,14 @@ Paragraph.displayName = "Paragraph";
|
|
|
571
571
|
|
|
572
572
|
// src/components/Input.tsx
|
|
573
573
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
574
|
+
function hasEquivalentNumericValue(currentValue, nextValue) {
|
|
575
|
+
if (!currentValue || !nextValue) {
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
const currentNumericValue = Number(currentValue.replace(/,/g, ""));
|
|
579
|
+
const nextNumericValue = Number(nextValue.replace(/,/g, ""));
|
|
580
|
+
return !Number.isNaN(currentNumericValue) && !Number.isNaN(nextNumericValue) && currentNumericValue === nextNumericValue;
|
|
581
|
+
}
|
|
574
582
|
var InputBase = (_a) => {
|
|
575
583
|
var _b = _a, {
|
|
576
584
|
id,
|
|
@@ -793,28 +801,33 @@ var Input = (_a) => {
|
|
|
793
801
|
const [internalValue, setInternalValue] = (0, import_react.useState)("");
|
|
794
802
|
const [displayValue, setDisplayValue] = (0, import_react.useState)("");
|
|
795
803
|
const [isFocused, setIsFocused] = (0, import_react.useState)(false);
|
|
804
|
+
const internalValueRef = (0, import_react.useRef)("");
|
|
805
|
+
const setInputValues = (nextInternalValue, nextDisplayValue) => {
|
|
806
|
+
internalValueRef.current = nextInternalValue;
|
|
807
|
+
setInternalValue(nextInternalValue);
|
|
808
|
+
setDisplayValue(nextDisplayValue);
|
|
809
|
+
};
|
|
796
810
|
(0, import_react.useEffect)(() => {
|
|
797
811
|
var _a2;
|
|
798
812
|
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
799
813
|
const shouldUseThousandsFormatting = variant === "currency" || variant === "uom" && currencyFormat;
|
|
800
814
|
if (!stringValue) {
|
|
801
|
-
|
|
802
|
-
setDisplayValue("");
|
|
815
|
+
setInputValues("", "");
|
|
803
816
|
return;
|
|
804
817
|
}
|
|
805
818
|
if (!shouldUseThousandsFormatting) {
|
|
806
|
-
|
|
807
|
-
|
|
819
|
+
setInputValues(stringValue, stringValue);
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (isFocused && hasEquivalentNumericValue(internalValueRef.current, stringValue)) {
|
|
808
823
|
return;
|
|
809
824
|
}
|
|
810
|
-
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
811
825
|
if (formatOnBlur && isFocused) {
|
|
812
|
-
|
|
813
|
-
setDisplayValue(stringValue);
|
|
826
|
+
setInputValues(stringValue, stringValue);
|
|
814
827
|
return;
|
|
815
828
|
}
|
|
816
|
-
|
|
817
|
-
|
|
829
|
+
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
830
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
818
831
|
}, [propValue, variant, currencyFormat, decimals, formatOnBlur, isFocused]);
|
|
819
832
|
const getInputProps = () => {
|
|
820
833
|
var _a2;
|
|
@@ -836,6 +849,7 @@ var Input = (_a) => {
|
|
|
836
849
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
837
850
|
align: "right",
|
|
838
851
|
type: "text",
|
|
852
|
+
inputMode: "decimal",
|
|
839
853
|
value: displayValue
|
|
840
854
|
});
|
|
841
855
|
case "percentage":
|
|
@@ -843,6 +857,7 @@ var Input = (_a) => {
|
|
|
843
857
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
844
858
|
type: currencyFormat ? "text" : "number",
|
|
845
859
|
align: "right",
|
|
860
|
+
inputMode: currencyFormat ? "decimal" : void 0,
|
|
846
861
|
value: currencyFormat ? displayValue : propValue
|
|
847
862
|
});
|
|
848
863
|
default:
|
|
@@ -889,8 +904,7 @@ var Input = (_a) => {
|
|
|
889
904
|
}
|
|
890
905
|
};
|
|
891
906
|
const handleSearchReset = () => {
|
|
892
|
-
|
|
893
|
-
setDisplayValue("");
|
|
907
|
+
setInputValues("", "");
|
|
894
908
|
if (onChange) {
|
|
895
909
|
const syntheticEvent = {
|
|
896
910
|
target: { value: "" }
|
|
@@ -907,8 +921,7 @@ var Input = (_a) => {
|
|
|
907
921
|
if (variant === "currency") {
|
|
908
922
|
const raw = rawValue.replace(/,/g, "");
|
|
909
923
|
if (raw === "") {
|
|
910
|
-
|
|
911
|
-
setDisplayValue("");
|
|
924
|
+
setInputValues("", "");
|
|
912
925
|
if (onChange) {
|
|
913
926
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
914
927
|
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
@@ -929,8 +942,8 @@ var Input = (_a) => {
|
|
|
929
942
|
clamped.toString(),
|
|
930
943
|
currentDecimals
|
|
931
944
|
);
|
|
932
|
-
|
|
933
|
-
|
|
945
|
+
setInputValues(
|
|
946
|
+
formattedClamped,
|
|
934
947
|
formatOnBlur ? formattedClamped : formatCurrencyDisplay(formattedClamped)
|
|
935
948
|
);
|
|
936
949
|
if (onChange) {
|
|
@@ -941,8 +954,7 @@ var Input = (_a) => {
|
|
|
941
954
|
}
|
|
942
955
|
return;
|
|
943
956
|
}
|
|
944
|
-
|
|
945
|
-
setDisplayValue(formatOnBlur ? raw : formatCurrencyDisplay(raw));
|
|
957
|
+
setInputValues(raw, formatOnBlur ? raw : formatCurrencyDisplay(raw));
|
|
946
958
|
if (!isNaN(asNumber) && onChange) {
|
|
947
959
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
948
960
|
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
@@ -954,8 +966,7 @@ var Input = (_a) => {
|
|
|
954
966
|
if (variant === "uom" && currencyFormat) {
|
|
955
967
|
const raw = rawValue.replace(/,/g, "");
|
|
956
968
|
if (raw === "") {
|
|
957
|
-
|
|
958
|
-
setDisplayValue("");
|
|
969
|
+
setInputValues("", "");
|
|
959
970
|
if (onChange) {
|
|
960
971
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
961
972
|
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
@@ -976,8 +987,10 @@ var Input = (_a) => {
|
|
|
976
987
|
clamped.toString(),
|
|
977
988
|
currentDecimals
|
|
978
989
|
);
|
|
979
|
-
|
|
980
|
-
|
|
990
|
+
setInputValues(
|
|
991
|
+
formattedClamped,
|
|
992
|
+
formatCurrencyDisplay(formattedClamped)
|
|
993
|
+
);
|
|
981
994
|
if (onChange) {
|
|
982
995
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
983
996
|
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
@@ -986,8 +999,7 @@ var Input = (_a) => {
|
|
|
986
999
|
}
|
|
987
1000
|
return;
|
|
988
1001
|
}
|
|
989
|
-
|
|
990
|
-
setDisplayValue(formatCurrencyDisplay(raw));
|
|
1002
|
+
setInputValues(raw, formatCurrencyDisplay(raw));
|
|
991
1003
|
if (!isNaN(asNumber) && onChange) {
|
|
992
1004
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
993
1005
|
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
@@ -1004,8 +1016,7 @@ var Input = (_a) => {
|
|
|
1004
1016
|
clamped.toString(),
|
|
1005
1017
|
decimals != null ? decimals : 0
|
|
1006
1018
|
);
|
|
1007
|
-
|
|
1008
|
-
setDisplayValue(formattedClamped);
|
|
1019
|
+
setInputValues(formattedClamped, formattedClamped);
|
|
1009
1020
|
if (typeof onChange === "function") {
|
|
1010
1021
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
1011
1022
|
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
@@ -1014,15 +1025,13 @@ var Input = (_a) => {
|
|
|
1014
1025
|
}
|
|
1015
1026
|
return;
|
|
1016
1027
|
}
|
|
1017
|
-
|
|
1018
|
-
setDisplayValue(rawValue);
|
|
1028
|
+
setInputValues(rawValue, rawValue);
|
|
1019
1029
|
if (typeof onChange === "function") {
|
|
1020
1030
|
onChange(e);
|
|
1021
1031
|
}
|
|
1022
1032
|
return;
|
|
1023
1033
|
}
|
|
1024
|
-
|
|
1025
|
-
setDisplayValue(rawValue);
|
|
1034
|
+
setInputValues(rawValue, rawValue);
|
|
1026
1035
|
if (typeof onChange === "function") {
|
|
1027
1036
|
onChange(e);
|
|
1028
1037
|
}
|
|
@@ -1035,8 +1044,7 @@ var Input = (_a) => {
|
|
|
1035
1044
|
}
|
|
1036
1045
|
if (variant === "currency") {
|
|
1037
1046
|
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
1038
|
-
|
|
1039
|
-
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
1047
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
1040
1048
|
const asNumber = Number(formatted);
|
|
1041
1049
|
if (!isNaN(asNumber) && onChange) {
|
|
1042
1050
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
@@ -1047,8 +1055,7 @@ var Input = (_a) => {
|
|
|
1047
1055
|
} else if (variant === "uom") {
|
|
1048
1056
|
if (currencyFormat) {
|
|
1049
1057
|
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
1050
|
-
|
|
1051
|
-
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
1058
|
+
setInputValues(formatted, formatCurrencyDisplay(formatted));
|
|
1052
1059
|
const asNumber = Number(formatted);
|
|
1053
1060
|
if (!isNaN(asNumber) && onChange) {
|
|
1054
1061
|
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|