@dmsi/wedgekit-react 0.0.1009 → 0.0.1011
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-FHXCCVOG.js → chunk-72WLEGGU.js} +1 -1
- package/dist/{chunk-5NRKL5CJ.js → chunk-FFCSDPXR.js} +1 -1
- package/dist/{chunk-FZ2TEKOE.js → chunk-IEKZBWVL.js} +1 -1
- package/dist/{chunk-7T5RGDCN.js → chunk-NEMOTB6U.js} +75 -13
- package/dist/{chunk-RLJU65SD.js → chunk-PJQHRERH.js} +4 -4
- package/dist/components/CalendarRange.cjs +75 -13
- package/dist/components/CalendarRange.js +5 -5
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +75 -13
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +5 -5
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +75 -13
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +5 -5
- package/dist/components/DataGrid/PinnedColumns.cjs +75 -13
- package/dist/components/DataGrid/PinnedColumns.js +5 -5
- package/dist/components/DataGrid/TableBody/LoadingCell.cjs +75 -13
- package/dist/components/DataGrid/TableBody/LoadingCell.js +5 -5
- package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +75 -13
- package/dist/components/DataGrid/TableBody/TableBodyRow.js +5 -5
- package/dist/components/DataGrid/TableBody/index.cjs +75 -13
- package/dist/components/DataGrid/TableBody/index.js +5 -5
- package/dist/components/DataGrid/index.cjs +75 -13
- package/dist/components/DataGrid/index.js +5 -5
- package/dist/components/DataGrid/utils.cjs +75 -13
- package/dist/components/DataGrid/utils.js +5 -5
- package/dist/components/DataGridCell.cjs +75 -13
- package/dist/components/DataGridCell.js +3 -3
- package/dist/components/DateInput.cjs +75 -13
- package/dist/components/DateInput.js +5 -5
- package/dist/components/DateRangeInput.cjs +75 -13
- package/dist/components/DateRangeInput.js +5 -5
- package/dist/components/FilterGroup.cjs +75 -13
- package/dist/components/FilterGroup.js +2 -2
- package/dist/components/Input.cjs +75 -13
- package/dist/components/Input.js +1 -1
- package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +75 -13
- package/dist/components/MobileDataGrid/ColumnSelector/index.js +5 -5
- package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +75 -13
- package/dist/components/MobileDataGrid/MobileDataGridHeader.js +5 -5
- package/dist/components/MobileDataGrid/index.cjs +75 -13
- package/dist/components/MobileDataGrid/index.js +5 -5
- package/dist/components/Password.cjs +75 -13
- package/dist/components/Password.js +1 -1
- package/dist/components/Search.cjs +75 -13
- package/dist/components/Search.js +2 -2
- package/dist/components/Select.cjs +75 -13
- package/dist/components/Select.js +2 -2
- package/dist/components/Stepper.cjs +75 -13
- package/dist/components/Stepper.js +1 -1
- package/dist/components/Time.cjs +75 -13
- package/dist/components/Time.js +1 -1
- package/dist/components/index.cjs +75 -13
- package/dist/components/index.js +5 -5
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MobileDataGrid
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-PJQHRERH.js";
|
|
4
4
|
import "../../chunk-2UNLVJU5.js";
|
|
5
5
|
import "../../chunk-POZD6R3P.js";
|
|
6
6
|
import "../../chunk-M7INAUAJ.js";
|
|
@@ -21,7 +21,7 @@ import "../../chunk-7IPESTQS.js";
|
|
|
21
21
|
import "../../chunk-Z2HPSFEQ.js";
|
|
22
22
|
import "../../chunk-AT4AWD6B.js";
|
|
23
23
|
import "../../chunk-EWGHVZL5.js";
|
|
24
|
-
import "../../chunk-
|
|
24
|
+
import "../../chunk-IEKZBWVL.js";
|
|
25
25
|
import "../../chunk-I57U5THY.js";
|
|
26
26
|
import "../../chunk-KBIEWFQS.js";
|
|
27
27
|
import "../../chunk-NSZTJ5R4.js";
|
|
@@ -38,12 +38,12 @@ import "../../chunk-3IAXYRUR.js";
|
|
|
38
38
|
import "../../chunk-SJZNVG4N.js";
|
|
39
39
|
import "../../chunk-75USUR3I.js";
|
|
40
40
|
import "../../chunk-BWPNXY7T.js";
|
|
41
|
-
import "../../chunk-
|
|
41
|
+
import "../../chunk-FFCSDPXR.js";
|
|
42
42
|
import "../../chunk-OM7QLLI2.js";
|
|
43
43
|
import "../../chunk-PE3EZP56.js";
|
|
44
44
|
import "../../chunk-X3NDEFVA.js";
|
|
45
|
-
import "../../chunk-
|
|
46
|
-
import "../../chunk-
|
|
45
|
+
import "../../chunk-72WLEGGU.js";
|
|
46
|
+
import "../../chunk-NEMOTB6U.js";
|
|
47
47
|
import "../../chunk-HXGJVYGQ.js";
|
|
48
48
|
import "../../chunk-WVUIIBRR.js";
|
|
49
49
|
import "../../chunk-M7WHWZ2J.js";
|
|
@@ -570,6 +570,7 @@ var Input = (_a) => {
|
|
|
570
570
|
variant = "default",
|
|
571
571
|
decimals,
|
|
572
572
|
uom,
|
|
573
|
+
currencyFormat = false,
|
|
573
574
|
removeSearchIcon,
|
|
574
575
|
value: propValue,
|
|
575
576
|
onChange,
|
|
@@ -582,6 +583,7 @@ var Input = (_a) => {
|
|
|
582
583
|
"variant",
|
|
583
584
|
"decimals",
|
|
584
585
|
"uom",
|
|
586
|
+
"currencyFormat",
|
|
585
587
|
"removeSearchIcon",
|
|
586
588
|
"value",
|
|
587
589
|
"onChange",
|
|
@@ -596,22 +598,21 @@ var Input = (_a) => {
|
|
|
596
598
|
(0, import_react.useEffect)(() => {
|
|
597
599
|
var _a2;
|
|
598
600
|
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
var _a2;
|
|
604
|
-
if (variant !== "currency") {
|
|
601
|
+
const shouldUseThousandsFormatting = variant === "currency" || variant === "uom" && currencyFormat;
|
|
602
|
+
if (!stringValue) {
|
|
603
|
+
setInternalValue("");
|
|
604
|
+
setDisplayValue("");
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
if (!shouldUseThousandsFormatting) {
|
|
608
|
+
setInternalValue(stringValue);
|
|
609
|
+
setDisplayValue(stringValue);
|
|
609
610
|
return;
|
|
610
611
|
}
|
|
611
612
|
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
612
613
|
setInternalValue(formatted);
|
|
613
614
|
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
614
|
-
}, []);
|
|
615
|
+
}, [propValue, variant, currencyFormat, decimals]);
|
|
615
616
|
const getInputProps = () => {
|
|
616
617
|
var _a2;
|
|
617
618
|
const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
@@ -637,8 +638,9 @@ var Input = (_a) => {
|
|
|
637
638
|
case "percentage":
|
|
638
639
|
case "uom":
|
|
639
640
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
640
|
-
type: "number",
|
|
641
|
-
align: "right"
|
|
641
|
+
type: currencyFormat ? "text" : "number",
|
|
642
|
+
align: "right",
|
|
643
|
+
value: currencyFormat ? displayValue : propValue
|
|
642
644
|
});
|
|
643
645
|
default:
|
|
644
646
|
return baseProps;
|
|
@@ -651,6 +653,8 @@ var Input = (_a) => {
|
|
|
651
653
|
return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "search" }) }) : null;
|
|
652
654
|
case "currency":
|
|
653
655
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "attach_money" }) });
|
|
656
|
+
case "uom":
|
|
657
|
+
return currencyFormat ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "attach_money" }) }) : null;
|
|
654
658
|
default:
|
|
655
659
|
return null;
|
|
656
660
|
}
|
|
@@ -742,6 +746,51 @@ var Input = (_a) => {
|
|
|
742
746
|
}
|
|
743
747
|
return;
|
|
744
748
|
}
|
|
749
|
+
if (variant === "uom" && currencyFormat) {
|
|
750
|
+
const raw = rawValue.replace(/,/g, "");
|
|
751
|
+
if (raw === "") {
|
|
752
|
+
setInternalValue("");
|
|
753
|
+
setDisplayValue("");
|
|
754
|
+
if (onChange) {
|
|
755
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
756
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
757
|
+
});
|
|
758
|
+
onChange(syntheticEvent);
|
|
759
|
+
}
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
const regex = /^\d*\.?\d*$/;
|
|
763
|
+
if (!regex.test(raw)) return;
|
|
764
|
+
const parts = raw.split(".");
|
|
765
|
+
const currentDecimals = decimals != null ? decimals : 2;
|
|
766
|
+
if (parts.length === 2 && parts[1].length > currentDecimals) return;
|
|
767
|
+
const asNumber = Number(raw);
|
|
768
|
+
if (!isNaN(asNumber) && maxNumber != null && asNumber > maxNumber) {
|
|
769
|
+
const clamped = maxNumber;
|
|
770
|
+
const formattedClamped = formatDecimalValue(
|
|
771
|
+
clamped.toString(),
|
|
772
|
+
currentDecimals
|
|
773
|
+
);
|
|
774
|
+
setInternalValue(formattedClamped);
|
|
775
|
+
setDisplayValue(formatCurrencyDisplay(formattedClamped));
|
|
776
|
+
if (onChange) {
|
|
777
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
778
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
779
|
+
});
|
|
780
|
+
onChange(syntheticEvent);
|
|
781
|
+
}
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
setInternalValue(raw);
|
|
785
|
+
setDisplayValue(formatCurrencyDisplay(raw));
|
|
786
|
+
if (!isNaN(asNumber) && onChange) {
|
|
787
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
788
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
789
|
+
});
|
|
790
|
+
onChange(syntheticEvent);
|
|
791
|
+
}
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
745
794
|
if (variant === "uom" && e.target.type === "number") {
|
|
746
795
|
const numeric = Number(rawValue);
|
|
747
796
|
if (!isNaN(numeric) && maxNumber != null && numeric > maxNumber) {
|
|
@@ -790,8 +839,21 @@ var Input = (_a) => {
|
|
|
790
839
|
onChange(syntheticEvent);
|
|
791
840
|
}
|
|
792
841
|
} else if (variant === "uom") {
|
|
793
|
-
|
|
794
|
-
|
|
842
|
+
if (currencyFormat) {
|
|
843
|
+
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
844
|
+
setInternalValue(formatted);
|
|
845
|
+
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
846
|
+
const asNumber = Number(formatted);
|
|
847
|
+
if (!isNaN(asNumber) && onChange) {
|
|
848
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
849
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
850
|
+
});
|
|
851
|
+
onChange(syntheticEvent);
|
|
852
|
+
}
|
|
853
|
+
} else {
|
|
854
|
+
const formattedValue = formatDecimalValue(e.target.value, decimals);
|
|
855
|
+
e.target.value = formattedValue;
|
|
856
|
+
}
|
|
795
857
|
}
|
|
796
858
|
onBlur == null ? void 0 : onBlur(e);
|
|
797
859
|
};
|
|
@@ -570,6 +570,7 @@ var Input = (_a) => {
|
|
|
570
570
|
variant = "default",
|
|
571
571
|
decimals,
|
|
572
572
|
uom,
|
|
573
|
+
currencyFormat = false,
|
|
573
574
|
removeSearchIcon,
|
|
574
575
|
value: propValue,
|
|
575
576
|
onChange,
|
|
@@ -582,6 +583,7 @@ var Input = (_a) => {
|
|
|
582
583
|
"variant",
|
|
583
584
|
"decimals",
|
|
584
585
|
"uom",
|
|
586
|
+
"currencyFormat",
|
|
585
587
|
"removeSearchIcon",
|
|
586
588
|
"value",
|
|
587
589
|
"onChange",
|
|
@@ -596,22 +598,21 @@ var Input = (_a) => {
|
|
|
596
598
|
(0, import_react.useEffect)(() => {
|
|
597
599
|
var _a2;
|
|
598
600
|
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
var _a2;
|
|
604
|
-
if (variant !== "currency") {
|
|
601
|
+
const shouldUseThousandsFormatting = variant === "currency" || variant === "uom" && currencyFormat;
|
|
602
|
+
if (!stringValue) {
|
|
603
|
+
setInternalValue("");
|
|
604
|
+
setDisplayValue("");
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
if (!shouldUseThousandsFormatting) {
|
|
608
|
+
setInternalValue(stringValue);
|
|
609
|
+
setDisplayValue(stringValue);
|
|
609
610
|
return;
|
|
610
611
|
}
|
|
611
612
|
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
612
613
|
setInternalValue(formatted);
|
|
613
614
|
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
614
|
-
}, []);
|
|
615
|
+
}, [propValue, variant, currencyFormat, decimals]);
|
|
615
616
|
const getInputProps = () => {
|
|
616
617
|
var _a2;
|
|
617
618
|
const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
@@ -637,8 +638,9 @@ var Input = (_a) => {
|
|
|
637
638
|
case "percentage":
|
|
638
639
|
case "uom":
|
|
639
640
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
640
|
-
type: "number",
|
|
641
|
-
align: "right"
|
|
641
|
+
type: currencyFormat ? "text" : "number",
|
|
642
|
+
align: "right",
|
|
643
|
+
value: currencyFormat ? displayValue : propValue
|
|
642
644
|
});
|
|
643
645
|
default:
|
|
644
646
|
return baseProps;
|
|
@@ -651,6 +653,8 @@ var Input = (_a) => {
|
|
|
651
653
|
return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "search" }) }) : null;
|
|
652
654
|
case "currency":
|
|
653
655
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "attach_money" }) });
|
|
656
|
+
case "uom":
|
|
657
|
+
return currencyFormat ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "attach_money" }) }) : null;
|
|
654
658
|
default:
|
|
655
659
|
return null;
|
|
656
660
|
}
|
|
@@ -742,6 +746,51 @@ var Input = (_a) => {
|
|
|
742
746
|
}
|
|
743
747
|
return;
|
|
744
748
|
}
|
|
749
|
+
if (variant === "uom" && currencyFormat) {
|
|
750
|
+
const raw = rawValue.replace(/,/g, "");
|
|
751
|
+
if (raw === "") {
|
|
752
|
+
setInternalValue("");
|
|
753
|
+
setDisplayValue("");
|
|
754
|
+
if (onChange) {
|
|
755
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
756
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
757
|
+
});
|
|
758
|
+
onChange(syntheticEvent);
|
|
759
|
+
}
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
const regex = /^\d*\.?\d*$/;
|
|
763
|
+
if (!regex.test(raw)) return;
|
|
764
|
+
const parts = raw.split(".");
|
|
765
|
+
const currentDecimals = decimals != null ? decimals : 2;
|
|
766
|
+
if (parts.length === 2 && parts[1].length > currentDecimals) return;
|
|
767
|
+
const asNumber = Number(raw);
|
|
768
|
+
if (!isNaN(asNumber) && maxNumber != null && asNumber > maxNumber) {
|
|
769
|
+
const clamped = maxNumber;
|
|
770
|
+
const formattedClamped = formatDecimalValue(
|
|
771
|
+
clamped.toString(),
|
|
772
|
+
currentDecimals
|
|
773
|
+
);
|
|
774
|
+
setInternalValue(formattedClamped);
|
|
775
|
+
setDisplayValue(formatCurrencyDisplay(formattedClamped));
|
|
776
|
+
if (onChange) {
|
|
777
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
778
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
779
|
+
});
|
|
780
|
+
onChange(syntheticEvent);
|
|
781
|
+
}
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
setInternalValue(raw);
|
|
785
|
+
setDisplayValue(formatCurrencyDisplay(raw));
|
|
786
|
+
if (!isNaN(asNumber) && onChange) {
|
|
787
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
788
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
789
|
+
});
|
|
790
|
+
onChange(syntheticEvent);
|
|
791
|
+
}
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
745
794
|
if (variant === "uom" && e.target.type === "number") {
|
|
746
795
|
const numeric = Number(rawValue);
|
|
747
796
|
if (!isNaN(numeric) && maxNumber != null && numeric > maxNumber) {
|
|
@@ -790,8 +839,21 @@ var Input = (_a) => {
|
|
|
790
839
|
onChange(syntheticEvent);
|
|
791
840
|
}
|
|
792
841
|
} else if (variant === "uom") {
|
|
793
|
-
|
|
794
|
-
|
|
842
|
+
if (currencyFormat) {
|
|
843
|
+
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
844
|
+
setInternalValue(formatted);
|
|
845
|
+
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
846
|
+
const asNumber = Number(formatted);
|
|
847
|
+
if (!isNaN(asNumber) && onChange) {
|
|
848
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
849
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
850
|
+
});
|
|
851
|
+
onChange(syntheticEvent);
|
|
852
|
+
}
|
|
853
|
+
} else {
|
|
854
|
+
const formattedValue = formatDecimalValue(e.target.value, decimals);
|
|
855
|
+
e.target.value = formattedValue;
|
|
856
|
+
}
|
|
795
857
|
}
|
|
796
858
|
onBlur == null ? void 0 : onBlur(e);
|
|
797
859
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Search
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-72WLEGGU.js";
|
|
5
|
+
import "../chunk-NEMOTB6U.js";
|
|
6
6
|
import "../chunk-HXGJVYGQ.js";
|
|
7
7
|
import "../chunk-5UH6QUFB.js";
|
|
8
8
|
import "../chunk-WMPWWFUJ.js";
|
|
@@ -570,6 +570,7 @@ var Input = (_a) => {
|
|
|
570
570
|
variant = "default",
|
|
571
571
|
decimals,
|
|
572
572
|
uom,
|
|
573
|
+
currencyFormat = false,
|
|
573
574
|
removeSearchIcon,
|
|
574
575
|
value: propValue,
|
|
575
576
|
onChange,
|
|
@@ -582,6 +583,7 @@ var Input = (_a) => {
|
|
|
582
583
|
"variant",
|
|
583
584
|
"decimals",
|
|
584
585
|
"uom",
|
|
586
|
+
"currencyFormat",
|
|
585
587
|
"removeSearchIcon",
|
|
586
588
|
"value",
|
|
587
589
|
"onChange",
|
|
@@ -596,22 +598,21 @@ var Input = (_a) => {
|
|
|
596
598
|
(0, import_react.useEffect)(() => {
|
|
597
599
|
var _a2;
|
|
598
600
|
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
var _a2;
|
|
604
|
-
if (variant !== "currency") {
|
|
601
|
+
const shouldUseThousandsFormatting = variant === "currency" || variant === "uom" && currencyFormat;
|
|
602
|
+
if (!stringValue) {
|
|
603
|
+
setInternalValue("");
|
|
604
|
+
setDisplayValue("");
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
if (!shouldUseThousandsFormatting) {
|
|
608
|
+
setInternalValue(stringValue);
|
|
609
|
+
setDisplayValue(stringValue);
|
|
609
610
|
return;
|
|
610
611
|
}
|
|
611
612
|
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
612
613
|
setInternalValue(formatted);
|
|
613
614
|
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
614
|
-
}, []);
|
|
615
|
+
}, [propValue, variant, currencyFormat, decimals]);
|
|
615
616
|
const getInputProps = () => {
|
|
616
617
|
var _a2;
|
|
617
618
|
const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
@@ -637,8 +638,9 @@ var Input = (_a) => {
|
|
|
637
638
|
case "percentage":
|
|
638
639
|
case "uom":
|
|
639
640
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
640
|
-
type: "number",
|
|
641
|
-
align: "right"
|
|
641
|
+
type: currencyFormat ? "text" : "number",
|
|
642
|
+
align: "right",
|
|
643
|
+
value: currencyFormat ? displayValue : propValue
|
|
642
644
|
});
|
|
643
645
|
default:
|
|
644
646
|
return baseProps;
|
|
@@ -651,6 +653,8 @@ var Input = (_a) => {
|
|
|
651
653
|
return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "search" }) }) : null;
|
|
652
654
|
case "currency":
|
|
653
655
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "attach_money" }) });
|
|
656
|
+
case "uom":
|
|
657
|
+
return currencyFormat ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "attach_money" }) }) : null;
|
|
654
658
|
default:
|
|
655
659
|
return null;
|
|
656
660
|
}
|
|
@@ -742,6 +746,51 @@ var Input = (_a) => {
|
|
|
742
746
|
}
|
|
743
747
|
return;
|
|
744
748
|
}
|
|
749
|
+
if (variant === "uom" && currencyFormat) {
|
|
750
|
+
const raw = rawValue.replace(/,/g, "");
|
|
751
|
+
if (raw === "") {
|
|
752
|
+
setInternalValue("");
|
|
753
|
+
setDisplayValue("");
|
|
754
|
+
if (onChange) {
|
|
755
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
756
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
757
|
+
});
|
|
758
|
+
onChange(syntheticEvent);
|
|
759
|
+
}
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
const regex = /^\d*\.?\d*$/;
|
|
763
|
+
if (!regex.test(raw)) return;
|
|
764
|
+
const parts = raw.split(".");
|
|
765
|
+
const currentDecimals = decimals != null ? decimals : 2;
|
|
766
|
+
if (parts.length === 2 && parts[1].length > currentDecimals) return;
|
|
767
|
+
const asNumber = Number(raw);
|
|
768
|
+
if (!isNaN(asNumber) && maxNumber != null && asNumber > maxNumber) {
|
|
769
|
+
const clamped = maxNumber;
|
|
770
|
+
const formattedClamped = formatDecimalValue(
|
|
771
|
+
clamped.toString(),
|
|
772
|
+
currentDecimals
|
|
773
|
+
);
|
|
774
|
+
setInternalValue(formattedClamped);
|
|
775
|
+
setDisplayValue(formatCurrencyDisplay(formattedClamped));
|
|
776
|
+
if (onChange) {
|
|
777
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
778
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
779
|
+
});
|
|
780
|
+
onChange(syntheticEvent);
|
|
781
|
+
}
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
setInternalValue(raw);
|
|
785
|
+
setDisplayValue(formatCurrencyDisplay(raw));
|
|
786
|
+
if (!isNaN(asNumber) && onChange) {
|
|
787
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
788
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
789
|
+
});
|
|
790
|
+
onChange(syntheticEvent);
|
|
791
|
+
}
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
745
794
|
if (variant === "uom" && e.target.type === "number") {
|
|
746
795
|
const numeric = Number(rawValue);
|
|
747
796
|
if (!isNaN(numeric) && maxNumber != null && numeric > maxNumber) {
|
|
@@ -790,8 +839,21 @@ var Input = (_a) => {
|
|
|
790
839
|
onChange(syntheticEvent);
|
|
791
840
|
}
|
|
792
841
|
} else if (variant === "uom") {
|
|
793
|
-
|
|
794
|
-
|
|
842
|
+
if (currencyFormat) {
|
|
843
|
+
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
844
|
+
setInternalValue(formatted);
|
|
845
|
+
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
846
|
+
const asNumber = Number(formatted);
|
|
847
|
+
if (!isNaN(asNumber) && onChange) {
|
|
848
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
849
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
850
|
+
});
|
|
851
|
+
onChange(syntheticEvent);
|
|
852
|
+
}
|
|
853
|
+
} else {
|
|
854
|
+
const formattedValue = formatDecimalValue(e.target.value, decimals);
|
|
855
|
+
e.target.value = formattedValue;
|
|
856
|
+
}
|
|
795
857
|
}
|
|
796
858
|
onBlur == null ? void 0 : onBlur(e);
|
|
797
859
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Select
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-IEKZBWVL.js";
|
|
5
|
+
import "../chunk-NEMOTB6U.js";
|
|
6
6
|
import "../chunk-HXGJVYGQ.js";
|
|
7
7
|
import "../chunk-5UH6QUFB.js";
|
|
8
8
|
import "../chunk-WMPWWFUJ.js";
|
|
@@ -765,6 +765,7 @@ var Input = (_a) => {
|
|
|
765
765
|
variant = "default",
|
|
766
766
|
decimals,
|
|
767
767
|
uom,
|
|
768
|
+
currencyFormat = false,
|
|
768
769
|
removeSearchIcon,
|
|
769
770
|
value: propValue,
|
|
770
771
|
onChange,
|
|
@@ -777,6 +778,7 @@ var Input = (_a) => {
|
|
|
777
778
|
"variant",
|
|
778
779
|
"decimals",
|
|
779
780
|
"uom",
|
|
781
|
+
"currencyFormat",
|
|
780
782
|
"removeSearchIcon",
|
|
781
783
|
"value",
|
|
782
784
|
"onChange",
|
|
@@ -791,22 +793,21 @@ var Input = (_a) => {
|
|
|
791
793
|
(0, import_react.useEffect)(() => {
|
|
792
794
|
var _a2;
|
|
793
795
|
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
var _a2;
|
|
799
|
-
if (variant !== "currency") {
|
|
796
|
+
const shouldUseThousandsFormatting = variant === "currency" || variant === "uom" && currencyFormat;
|
|
797
|
+
if (!stringValue) {
|
|
798
|
+
setInternalValue("");
|
|
799
|
+
setDisplayValue("");
|
|
800
800
|
return;
|
|
801
801
|
}
|
|
802
|
-
|
|
803
|
-
|
|
802
|
+
if (!shouldUseThousandsFormatting) {
|
|
803
|
+
setInternalValue(stringValue);
|
|
804
|
+
setDisplayValue(stringValue);
|
|
804
805
|
return;
|
|
805
806
|
}
|
|
806
807
|
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
807
808
|
setInternalValue(formatted);
|
|
808
809
|
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
809
|
-
}, []);
|
|
810
|
+
}, [propValue, variant, currencyFormat, decimals]);
|
|
810
811
|
const getInputProps = () => {
|
|
811
812
|
var _a2;
|
|
812
813
|
const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
@@ -832,8 +833,9 @@ var Input = (_a) => {
|
|
|
832
833
|
case "percentage":
|
|
833
834
|
case "uom":
|
|
834
835
|
return __spreadProps(__spreadValues({}, baseProps), {
|
|
835
|
-
type: "number",
|
|
836
|
-
align: "right"
|
|
836
|
+
type: currencyFormat ? "text" : "number",
|
|
837
|
+
align: "right",
|
|
838
|
+
value: currencyFormat ? displayValue : propValue
|
|
837
839
|
});
|
|
838
840
|
default:
|
|
839
841
|
return baseProps;
|
|
@@ -846,6 +848,8 @@ var Input = (_a) => {
|
|
|
846
848
|
return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "search" }) }) : null;
|
|
847
849
|
case "currency":
|
|
848
850
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "attach_money" }) });
|
|
851
|
+
case "uom":
|
|
852
|
+
return currencyFormat ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "attach_money" }) }) : null;
|
|
849
853
|
default:
|
|
850
854
|
return null;
|
|
851
855
|
}
|
|
@@ -937,6 +941,51 @@ var Input = (_a) => {
|
|
|
937
941
|
}
|
|
938
942
|
return;
|
|
939
943
|
}
|
|
944
|
+
if (variant === "uom" && currencyFormat) {
|
|
945
|
+
const raw = rawValue.replace(/,/g, "");
|
|
946
|
+
if (raw === "") {
|
|
947
|
+
setInternalValue("");
|
|
948
|
+
setDisplayValue("");
|
|
949
|
+
if (onChange) {
|
|
950
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
951
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
952
|
+
});
|
|
953
|
+
onChange(syntheticEvent);
|
|
954
|
+
}
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
const regex = /^\d*\.?\d*$/;
|
|
958
|
+
if (!regex.test(raw)) return;
|
|
959
|
+
const parts = raw.split(".");
|
|
960
|
+
const currentDecimals = decimals != null ? decimals : 2;
|
|
961
|
+
if (parts.length === 2 && parts[1].length > currentDecimals) return;
|
|
962
|
+
const asNumber = Number(raw);
|
|
963
|
+
if (!isNaN(asNumber) && maxNumber != null && asNumber > maxNumber) {
|
|
964
|
+
const clamped = maxNumber;
|
|
965
|
+
const formattedClamped = formatDecimalValue(
|
|
966
|
+
clamped.toString(),
|
|
967
|
+
currentDecimals
|
|
968
|
+
);
|
|
969
|
+
setInternalValue(formattedClamped);
|
|
970
|
+
setDisplayValue(formatCurrencyDisplay(formattedClamped));
|
|
971
|
+
if (onChange) {
|
|
972
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
973
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: clamped.toString() })
|
|
974
|
+
});
|
|
975
|
+
onChange(syntheticEvent);
|
|
976
|
+
}
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
setInternalValue(raw);
|
|
980
|
+
setDisplayValue(formatCurrencyDisplay(raw));
|
|
981
|
+
if (!isNaN(asNumber) && onChange) {
|
|
982
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
983
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
984
|
+
});
|
|
985
|
+
onChange(syntheticEvent);
|
|
986
|
+
}
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
940
989
|
if (variant === "uom" && e.target.type === "number") {
|
|
941
990
|
const numeric = Number(rawValue);
|
|
942
991
|
if (!isNaN(numeric) && maxNumber != null && numeric > maxNumber) {
|
|
@@ -985,8 +1034,21 @@ var Input = (_a) => {
|
|
|
985
1034
|
onChange(syntheticEvent);
|
|
986
1035
|
}
|
|
987
1036
|
} else if (variant === "uom") {
|
|
988
|
-
|
|
989
|
-
|
|
1037
|
+
if (currencyFormat) {
|
|
1038
|
+
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
1039
|
+
setInternalValue(formatted);
|
|
1040
|
+
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
1041
|
+
const asNumber = Number(formatted);
|
|
1042
|
+
if (!isNaN(asNumber) && onChange) {
|
|
1043
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
1044
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
1045
|
+
});
|
|
1046
|
+
onChange(syntheticEvent);
|
|
1047
|
+
}
|
|
1048
|
+
} else {
|
|
1049
|
+
const formattedValue = formatDecimalValue(e.target.value, decimals);
|
|
1050
|
+
e.target.value = formattedValue;
|
|
1051
|
+
}
|
|
990
1052
|
}
|
|
991
1053
|
onBlur == null ? void 0 : onBlur(e);
|
|
992
1054
|
};
|