@sustaina/shared-ui 1.54.1 → 1.54.2
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.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +175 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1721,6 +1721,14 @@ type InputProps = Omit<InputPrimitiveProps, "size" | "prefix"> & VariantProps<ty
|
|
|
1721
1721
|
validationIcon?: React$1.ReactNode;
|
|
1722
1722
|
validationMessageProps?: React$1.HTMLAttributes<HTMLParagraphElement>;
|
|
1723
1723
|
onValueChange?: (value: string) => void;
|
|
1724
|
+
showPrefixDivider?: boolean;
|
|
1725
|
+
showSuffixDivider?: boolean;
|
|
1726
|
+
prefixWidth?: number | string;
|
|
1727
|
+
suffixWidth?: number | string;
|
|
1728
|
+
prefixMinWidth?: number | string;
|
|
1729
|
+
suffixMinWidth?: number | string;
|
|
1730
|
+
prefixMaxWidth?: number | string;
|
|
1731
|
+
suffixMaxWidth?: number | string;
|
|
1724
1732
|
};
|
|
1725
1733
|
|
|
1726
1734
|
type InputCustomInputProps = Omit<InputProps, "type" | "value" | "defaultValue" | "onValueChange" | "prefix" | "suffix"> & {
|
|
@@ -1735,9 +1743,12 @@ type InputNumberProps = NumericFormatProps<InputProps> & {
|
|
|
1735
1743
|
min?: number;
|
|
1736
1744
|
max?: number;
|
|
1737
1745
|
onStepChange?: (value: number) => void;
|
|
1738
|
-
|
|
1746
|
+
fillDecimalOnBlur?: boolean;
|
|
1747
|
+
truncateDecimalOnBlur?: boolean;
|
|
1748
|
+
maxIntegerDigits?: number;
|
|
1749
|
+
invalid?: boolean;
|
|
1739
1750
|
};
|
|
1740
|
-
declare const InputNumber: ({ customInputProps, showStepper, step, min, max, onStepChange, onValueChange, value, defaultValue, disabled, onBlur, isAllowed: isAllowedProp,
|
|
1751
|
+
declare const InputNumber: ({ customInputProps, showStepper, step, min, max, onStepChange, onValueChange, value, defaultValue, disabled, onBlur, isAllowed: isAllowedProp, fillDecimalOnBlur, truncateDecimalOnBlur, maxIntegerDigits, invalid, decimalScale: decimalScaleProp, fixedDecimalScale: fixedDecimalScaleProp, ...props }: InputNumberProps) => react_jsx_runtime.JSX.Element;
|
|
1741
1752
|
|
|
1742
1753
|
type PermissionAction = "CREATE" | "READ" | "EDIT" | "DELETE" | "NOTIFY" | "CREATE_DRAFT" | "REQUIRE_SITE";
|
|
1743
1754
|
type PermissionString = `${string}.${PermissionAction}`;
|
package/dist/index.d.ts
CHANGED
|
@@ -1721,6 +1721,14 @@ type InputProps = Omit<InputPrimitiveProps, "size" | "prefix"> & VariantProps<ty
|
|
|
1721
1721
|
validationIcon?: React$1.ReactNode;
|
|
1722
1722
|
validationMessageProps?: React$1.HTMLAttributes<HTMLParagraphElement>;
|
|
1723
1723
|
onValueChange?: (value: string) => void;
|
|
1724
|
+
showPrefixDivider?: boolean;
|
|
1725
|
+
showSuffixDivider?: boolean;
|
|
1726
|
+
prefixWidth?: number | string;
|
|
1727
|
+
suffixWidth?: number | string;
|
|
1728
|
+
prefixMinWidth?: number | string;
|
|
1729
|
+
suffixMinWidth?: number | string;
|
|
1730
|
+
prefixMaxWidth?: number | string;
|
|
1731
|
+
suffixMaxWidth?: number | string;
|
|
1724
1732
|
};
|
|
1725
1733
|
|
|
1726
1734
|
type InputCustomInputProps = Omit<InputProps, "type" | "value" | "defaultValue" | "onValueChange" | "prefix" | "suffix"> & {
|
|
@@ -1735,9 +1743,12 @@ type InputNumberProps = NumericFormatProps<InputProps> & {
|
|
|
1735
1743
|
min?: number;
|
|
1736
1744
|
max?: number;
|
|
1737
1745
|
onStepChange?: (value: number) => void;
|
|
1738
|
-
|
|
1746
|
+
fillDecimalOnBlur?: boolean;
|
|
1747
|
+
truncateDecimalOnBlur?: boolean;
|
|
1748
|
+
maxIntegerDigits?: number;
|
|
1749
|
+
invalid?: boolean;
|
|
1739
1750
|
};
|
|
1740
|
-
declare const InputNumber: ({ customInputProps, showStepper, step, min, max, onStepChange, onValueChange, value, defaultValue, disabled, onBlur, isAllowed: isAllowedProp,
|
|
1751
|
+
declare const InputNumber: ({ customInputProps, showStepper, step, min, max, onStepChange, onValueChange, value, defaultValue, disabled, onBlur, isAllowed: isAllowedProp, fillDecimalOnBlur, truncateDecimalOnBlur, maxIntegerDigits, invalid, decimalScale: decimalScaleProp, fixedDecimalScale: fixedDecimalScaleProp, ...props }: InputNumberProps) => react_jsx_runtime.JSX.Element;
|
|
1741
1752
|
|
|
1742
1753
|
type PermissionAction = "CREATE" | "READ" | "EDIT" | "DELETE" | "NOTIFY" | "CREATE_DRAFT" | "REQUIRE_SITE";
|
|
1743
1754
|
type PermissionString = `${string}.${PermissionAction}`;
|
package/dist/index.js
CHANGED
|
@@ -15695,6 +15695,63 @@ var Truncated = ({
|
|
|
15695
15695
|
);
|
|
15696
15696
|
};
|
|
15697
15697
|
var truncated_default = Truncated;
|
|
15698
|
+
|
|
15699
|
+
// src/components/inputNumber/helper.ts
|
|
15700
|
+
var createSourceInfo = (event) => ({
|
|
15701
|
+
event,
|
|
15702
|
+
source: event ? "event" : "prop"
|
|
15703
|
+
});
|
|
15704
|
+
var parseToNumber = (val) => {
|
|
15705
|
+
if (typeof val === "number") return val;
|
|
15706
|
+
if (typeof val === "string" && val !== "") {
|
|
15707
|
+
const parsed = parseFloat(val);
|
|
15708
|
+
if (!isNaN(parsed)) return parsed;
|
|
15709
|
+
}
|
|
15710
|
+
return void 0;
|
|
15711
|
+
};
|
|
15712
|
+
var truncateToFixed = (num, scale) => {
|
|
15713
|
+
if (scale === 0) return Math.trunc(num).toString();
|
|
15714
|
+
const sign = num < 0 ? "-" : "";
|
|
15715
|
+
const abs = Math.abs(num);
|
|
15716
|
+
const str = abs.toString();
|
|
15717
|
+
const dotIndex = str.indexOf(".");
|
|
15718
|
+
let intPart;
|
|
15719
|
+
let fracPart;
|
|
15720
|
+
if (dotIndex === -1) {
|
|
15721
|
+
intPart = str;
|
|
15722
|
+
fracPart = "";
|
|
15723
|
+
} else {
|
|
15724
|
+
intPart = str.slice(0, dotIndex);
|
|
15725
|
+
fracPart = str.slice(dotIndex + 1, dotIndex + 1 + scale);
|
|
15726
|
+
}
|
|
15727
|
+
fracPart = fracPart.padEnd(scale, "0");
|
|
15728
|
+
return `${sign}${intPart}.${fracPart}`;
|
|
15729
|
+
};
|
|
15730
|
+
var truncateStringToFixed = (str, scale) => {
|
|
15731
|
+
const trimmed = str.trim();
|
|
15732
|
+
if (trimmed === "" || trimmed === "-") return "0" + (scale > 0 ? "." + "0".repeat(scale) : "");
|
|
15733
|
+
const negative = trimmed.startsWith("-");
|
|
15734
|
+
const unsigned = negative ? trimmed.slice(1) : trimmed;
|
|
15735
|
+
const dotIndex = unsigned.indexOf(".");
|
|
15736
|
+
let intPart;
|
|
15737
|
+
let fracPart;
|
|
15738
|
+
if (dotIndex === -1) {
|
|
15739
|
+
intPart = unsigned || "0";
|
|
15740
|
+
fracPart = "";
|
|
15741
|
+
} else {
|
|
15742
|
+
intPart = unsigned.slice(0, dotIndex) || "0";
|
|
15743
|
+
fracPart = unsigned.slice(dotIndex + 1, dotIndex + 1 + scale);
|
|
15744
|
+
}
|
|
15745
|
+
if (scale === 0) return (negative ? "-" : "") + intPart;
|
|
15746
|
+
fracPart = fracPart.padEnd(scale, "0");
|
|
15747
|
+
return (negative ? "-" : "") + intPart + "." + fracPart;
|
|
15748
|
+
};
|
|
15749
|
+
var clamp = (value, min, max) => {
|
|
15750
|
+
if (max !== void 0 && value > max) return max;
|
|
15751
|
+
if (min !== void 0 && value < min) return min;
|
|
15752
|
+
return value;
|
|
15753
|
+
};
|
|
15754
|
+
var resolveCssSize = (value) => value !== void 0 ? typeof value === "number" ? `${value}px` : value : void 0;
|
|
15698
15755
|
var InputPrimitive2 = React__namespace.forwardRef(
|
|
15699
15756
|
({ className, type = "text", ...props }, ref) => {
|
|
15700
15757
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -15703,7 +15760,7 @@ var InputPrimitive2 = React__namespace.forwardRef(
|
|
|
15703
15760
|
ref,
|
|
15704
15761
|
type,
|
|
15705
15762
|
className: cn(
|
|
15706
|
-
"placeholder:text-neutral-400 text-neutral-900 flex h-10 w-full min-w-0 items-center rounded-lg border bg-white px-4 text-sm transition-colors outline-none file:inline-flex file:h-7 file:rounded-md file:border-0 file:bg-transparent file:px-2 file:text-sm file:font-medium hover:border-neutral-500 focus-visible:border-neutral-900 focus-visible:ring-0 disabled:cursor-not-allowed disabled:bg-neutral-100 disabled:text-neutral-400 disabled:border-neutral-200 aria-invalid:border-destructive",
|
|
15763
|
+
"placeholder:text-neutral-400 text-neutral-900 flex h-10 w-full min-w-0 items-center rounded-lg border bg-white px-4 text-sm transition-colors outline-none file:inline-flex file:h-7 file:rounded-md file:border-0 file:bg-transparent file:px-2 file:text-sm file:font-medium hover:border-neutral-500 focus-visible:border-neutral-900 focus-visible:ring-0 disabled:cursor-not-allowed disabled:bg-neutral-100 disabled:text-neutral-400 disabled:border-neutral-200 aria-invalid:border-destructive aria-invalid:hover:border-destructive aria-invalid:focus-visible:border-destructive",
|
|
15707
15764
|
className
|
|
15708
15765
|
),
|
|
15709
15766
|
...props
|
|
@@ -15734,6 +15791,26 @@ var inputVariants2 = classVarianceAuthority.cva("", {
|
|
|
15734
15791
|
appearance: "filled"
|
|
15735
15792
|
}
|
|
15736
15793
|
});
|
|
15794
|
+
var wrapperBorderVariants = classVarianceAuthority.cva(
|
|
15795
|
+
"flex items-center overflow-hidden border bg-white transition-colors",
|
|
15796
|
+
{
|
|
15797
|
+
variants: {
|
|
15798
|
+
controlSize: {
|
|
15799
|
+
sm: "h-9 rounded-md text-sm",
|
|
15800
|
+
md: "h-10 rounded-lg text-sm",
|
|
15801
|
+
lg: "h-12 rounded-xl text-base"
|
|
15802
|
+
},
|
|
15803
|
+
appearance: {
|
|
15804
|
+
filled: "border-neutral-200 hover:border-neutral-500 focus-within:border-neutral-900",
|
|
15805
|
+
unfilled: "border-neutral-300 hover:border-neutral-500 focus-within:border-neutral-900"
|
|
15806
|
+
}
|
|
15807
|
+
},
|
|
15808
|
+
defaultVariants: {
|
|
15809
|
+
controlSize: "sm",
|
|
15810
|
+
appearance: "filled"
|
|
15811
|
+
}
|
|
15812
|
+
}
|
|
15813
|
+
);
|
|
15737
15814
|
var Input2 = React__namespace.forwardRef(
|
|
15738
15815
|
({
|
|
15739
15816
|
className,
|
|
@@ -15754,6 +15831,14 @@ var Input2 = React__namespace.forwardRef(
|
|
|
15754
15831
|
validationIcon,
|
|
15755
15832
|
validationMessageProps,
|
|
15756
15833
|
onValueChange,
|
|
15834
|
+
showPrefixDivider,
|
|
15835
|
+
showSuffixDivider,
|
|
15836
|
+
prefixWidth,
|
|
15837
|
+
suffixWidth,
|
|
15838
|
+
prefixMinWidth,
|
|
15839
|
+
suffixMinWidth,
|
|
15840
|
+
prefixMaxWidth,
|
|
15841
|
+
suffixMaxWidth,
|
|
15757
15842
|
type = "text",
|
|
15758
15843
|
...rest
|
|
15759
15844
|
}, ref) => {
|
|
@@ -15777,11 +15862,14 @@ var Input2 = React__namespace.forwardRef(
|
|
|
15777
15862
|
);
|
|
15778
15863
|
const resolvedAriaInvalid = typeof ariaInvalid === "string" ? ariaInvalid : ariaInvalid ? true : void 0;
|
|
15779
15864
|
const describedBy = validationMessage ? [ariaDescribedByProp, messageId].filter(Boolean).join(" ") : ariaDescribedByProp;
|
|
15780
|
-
const
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
);
|
|
15865
|
+
const resolvedPrefixWidth = resolveCssSize(prefixWidth);
|
|
15866
|
+
const resolvedSuffixWidth = resolveCssSize(suffixWidth);
|
|
15867
|
+
const resolvedPrefixMinWidth = resolveCssSize(prefixMinWidth);
|
|
15868
|
+
const resolvedSuffixMinWidth = resolveCssSize(suffixMinWidth);
|
|
15869
|
+
const resolvedPrefixMaxWidth = resolveCssSize(prefixMaxWidth);
|
|
15870
|
+
const resolvedSuffixMaxWidth = resolveCssSize(suffixMaxWidth);
|
|
15871
|
+
const hasPrefixDimension = resolvedPrefixWidth || resolvedPrefixMinWidth || resolvedPrefixMaxWidth;
|
|
15872
|
+
const hasSuffixDimension = resolvedSuffixWidth || resolvedSuffixMinWidth || resolvedSuffixMaxWidth;
|
|
15785
15873
|
const inputElement = /* @__PURE__ */ jsxRuntime.jsx(
|
|
15786
15874
|
InputPrimitive2,
|
|
15787
15875
|
{
|
|
@@ -15790,9 +15878,8 @@ var Input2 = React__namespace.forwardRef(
|
|
|
15790
15878
|
"data-slot": "input",
|
|
15791
15879
|
className: cn(
|
|
15792
15880
|
inputVariants2({ controlSize, fullWidth: isFullWidth, appearance }),
|
|
15793
|
-
|
|
15794
|
-
hasSuffix &&
|
|
15795
|
-
className
|
|
15881
|
+
// Only apply padding offsets in the legacy (non-flex) path
|
|
15882
|
+
!hasPrefix && !hasSuffix && className
|
|
15796
15883
|
),
|
|
15797
15884
|
"aria-invalid": resolvedAriaInvalid,
|
|
15798
15885
|
"aria-describedby": describedBy || void 0,
|
|
@@ -15810,29 +15897,78 @@ var Input2 = React__namespace.forwardRef(
|
|
|
15810
15897
|
addonSuffix,
|
|
15811
15898
|
loading && (loadingIcon ?? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 16, variant: "muted" }))
|
|
15812
15899
|
] });
|
|
15813
|
-
const
|
|
15900
|
+
const flexWrapperClassName = cn(
|
|
15901
|
+
wrapperBorderVariants({ controlSize, appearance }),
|
|
15902
|
+
isFullWidth ? "w-full" : "w-fit",
|
|
15903
|
+
rest.disabled && "bg-sus-secondary-gray-3 border-sus-secondary-gray-5 hover:border-sus-secondary-gray-5",
|
|
15904
|
+
resolvedAriaInvalid && "border-destructive hover:border-destructive focus-within:border-destructive",
|
|
15905
|
+
!validationMessage && wrapperClassName
|
|
15906
|
+
);
|
|
15907
|
+
const divider = /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "addon-divider", className: "self-stretch w-px shrink-0 bg-neutral-200" });
|
|
15908
|
+
const flexInput = /* @__PURE__ */ jsxRuntime.jsx(
|
|
15909
|
+
InputPrimitive2,
|
|
15910
|
+
{
|
|
15911
|
+
ref,
|
|
15912
|
+
type,
|
|
15913
|
+
"data-slot": "input",
|
|
15914
|
+
className: cn(
|
|
15915
|
+
"flex-1 min-w-0 h-full border-0 rounded-none bg-transparent px-3 outline-none ring-0",
|
|
15916
|
+
"placeholder:text-neutral-400 text-neutral-900 text-sm transition-colors",
|
|
15917
|
+
"focus-visible:ring-0 focus-visible:border-0",
|
|
15918
|
+
"disabled:cursor-not-allowed disabled:bg-transparent disabled:text-neutral-400",
|
|
15919
|
+
className
|
|
15920
|
+
),
|
|
15921
|
+
"aria-invalid": resolvedAriaInvalid,
|
|
15922
|
+
"aria-describedby": describedBy || void 0,
|
|
15923
|
+
onChange: handleChange,
|
|
15924
|
+
...inputProps
|
|
15925
|
+
}
|
|
15926
|
+
);
|
|
15927
|
+
const inputWithAffixes = /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-slot": "input-wrapper", className: cn("group/input-wrapper", flexWrapperClassName), children: [
|
|
15814
15928
|
hasPrefix && /* @__PURE__ */ jsxRuntime.jsx(
|
|
15815
15929
|
"span",
|
|
15816
15930
|
{
|
|
15817
15931
|
...prefixRest,
|
|
15932
|
+
"data-slot": "addon-prefix",
|
|
15818
15933
|
className: cn(
|
|
15819
|
-
"
|
|
15934
|
+
"shrink-0 inline-flex items-center px-3 text-sm text-muted-foreground",
|
|
15935
|
+
hasPrefixDimension ? "overflow-hidden" : "whitespace-nowrap",
|
|
15936
|
+
rest.disabled && "text-neutral-400",
|
|
15820
15937
|
!prefixInteractive && "pointer-events-none",
|
|
15821
15938
|
prefixClassName
|
|
15822
15939
|
),
|
|
15940
|
+
style: hasPrefixDimension ? {
|
|
15941
|
+
...resolvedPrefixWidth && { width: resolvedPrefixWidth },
|
|
15942
|
+
...resolvedPrefixMinWidth && { minWidth: resolvedPrefixMinWidth },
|
|
15943
|
+
...resolvedPrefixMaxWidth && { maxWidth: resolvedPrefixMaxWidth },
|
|
15944
|
+
boxSizing: "border-box",
|
|
15945
|
+
...prefixRest?.style
|
|
15946
|
+
} : prefixRest?.style,
|
|
15823
15947
|
children: addonPrefix
|
|
15824
15948
|
}
|
|
15825
15949
|
),
|
|
15826
|
-
|
|
15950
|
+
hasPrefix && showPrefixDivider && divider,
|
|
15951
|
+
flexInput,
|
|
15952
|
+
hasSuffix && showSuffixDivider && divider,
|
|
15827
15953
|
hasSuffix && /* @__PURE__ */ jsxRuntime.jsx(
|
|
15828
15954
|
"span",
|
|
15829
15955
|
{
|
|
15830
15956
|
...suffixRest,
|
|
15957
|
+
"data-slot": "addon-suffix",
|
|
15831
15958
|
className: cn(
|
|
15832
|
-
"
|
|
15959
|
+
"shrink-0 inline-flex items-center gap-2 px-3 text-sm text-muted-foreground",
|
|
15960
|
+
hasSuffixDimension ? "overflow-hidden" : "whitespace-nowrap",
|
|
15961
|
+
rest.disabled && "text-neutral-400",
|
|
15833
15962
|
!suffixInteractive && "pointer-events-none",
|
|
15834
15963
|
suffixClassName
|
|
15835
15964
|
),
|
|
15965
|
+
style: hasSuffixDimension ? {
|
|
15966
|
+
...resolvedSuffixWidth && { width: resolvedSuffixWidth },
|
|
15967
|
+
...resolvedSuffixMinWidth && { minWidth: resolvedSuffixMinWidth },
|
|
15968
|
+
...resolvedSuffixMaxWidth && { maxWidth: resolvedSuffixMaxWidth },
|
|
15969
|
+
boxSizing: "border-box",
|
|
15970
|
+
...suffixRest?.style
|
|
15971
|
+
} : suffixRest?.style,
|
|
15836
15972
|
children: suffixContent
|
|
15837
15973
|
}
|
|
15838
15974
|
)
|
|
@@ -15858,63 +15994,7 @@ var Input2 = React__namespace.forwardRef(
|
|
|
15858
15994
|
}
|
|
15859
15995
|
);
|
|
15860
15996
|
Input2.displayName = "Input";
|
|
15861
|
-
|
|
15862
|
-
// src/components/inputNumber/helper.ts
|
|
15863
|
-
var createSourceInfo = (event) => ({
|
|
15864
|
-
event,
|
|
15865
|
-
source: event ? "event" : "prop"
|
|
15866
|
-
});
|
|
15867
|
-
var parseToNumber = (val) => {
|
|
15868
|
-
if (typeof val === "number") return val;
|
|
15869
|
-
if (typeof val === "string" && val !== "") {
|
|
15870
|
-
const parsed = parseFloat(val);
|
|
15871
|
-
if (!isNaN(parsed)) return parsed;
|
|
15872
|
-
}
|
|
15873
|
-
return void 0;
|
|
15874
|
-
};
|
|
15875
|
-
var truncateToFixed = (num, scale) => {
|
|
15876
|
-
if (scale === 0) return Math.trunc(num).toString();
|
|
15877
|
-
const sign = num < 0 ? "-" : "";
|
|
15878
|
-
const abs = Math.abs(num);
|
|
15879
|
-
const str = abs.toString();
|
|
15880
|
-
const dotIndex = str.indexOf(".");
|
|
15881
|
-
let intPart;
|
|
15882
|
-
let fracPart;
|
|
15883
|
-
if (dotIndex === -1) {
|
|
15884
|
-
intPart = str;
|
|
15885
|
-
fracPart = "";
|
|
15886
|
-
} else {
|
|
15887
|
-
intPart = str.slice(0, dotIndex);
|
|
15888
|
-
fracPart = str.slice(dotIndex + 1, dotIndex + 1 + scale);
|
|
15889
|
-
}
|
|
15890
|
-
fracPart = fracPart.padEnd(scale, "0");
|
|
15891
|
-
return `${sign}${intPart}.${fracPart}`;
|
|
15892
|
-
};
|
|
15893
|
-
var truncateStringToFixed = (str, scale) => {
|
|
15894
|
-
const trimmed = str.trim();
|
|
15895
|
-
if (trimmed === "" || trimmed === "-") return "0" + (scale > 0 ? "." + "0".repeat(scale) : "");
|
|
15896
|
-
const negative = trimmed.startsWith("-");
|
|
15897
|
-
const unsigned = negative ? trimmed.slice(1) : trimmed;
|
|
15898
|
-
const dotIndex = unsigned.indexOf(".");
|
|
15899
|
-
let intPart;
|
|
15900
|
-
let fracPart;
|
|
15901
|
-
if (dotIndex === -1) {
|
|
15902
|
-
intPart = unsigned || "0";
|
|
15903
|
-
fracPart = "";
|
|
15904
|
-
} else {
|
|
15905
|
-
intPart = unsigned.slice(0, dotIndex) || "0";
|
|
15906
|
-
fracPart = unsigned.slice(dotIndex + 1, dotIndex + 1 + scale);
|
|
15907
|
-
}
|
|
15908
|
-
if (scale === 0) return (negative ? "-" : "") + intPart;
|
|
15909
|
-
fracPart = fracPart.padEnd(scale, "0");
|
|
15910
|
-
return (negative ? "-" : "") + intPart + "." + fracPart;
|
|
15911
|
-
};
|
|
15912
|
-
var clamp = (value, min, max) => {
|
|
15913
|
-
if (max !== void 0 && value > max) return max;
|
|
15914
|
-
if (min !== void 0 && value < min) return min;
|
|
15915
|
-
return value;
|
|
15916
|
-
};
|
|
15917
|
-
function useAutoFormatDecimal({
|
|
15997
|
+
function useFillDecimalOnBlur({
|
|
15918
15998
|
enabled,
|
|
15919
15999
|
decimalScale,
|
|
15920
16000
|
value,
|
|
@@ -15991,11 +16071,15 @@ var InputNumber = ({
|
|
|
15991
16071
|
disabled,
|
|
15992
16072
|
onBlur,
|
|
15993
16073
|
isAllowed: isAllowedProp,
|
|
15994
|
-
|
|
16074
|
+
fillDecimalOnBlur = false,
|
|
16075
|
+
truncateDecimalOnBlur = false,
|
|
16076
|
+
maxIntegerDigits,
|
|
16077
|
+
invalid,
|
|
15995
16078
|
decimalScale: decimalScaleProp,
|
|
15996
16079
|
fixedDecimalScale: fixedDecimalScaleProp,
|
|
15997
16080
|
...props
|
|
15998
16081
|
}) => {
|
|
16082
|
+
const blurFormatEnabled = fillDecimalOnBlur || truncateDecimalOnBlur;
|
|
15999
16083
|
const [internalValue, setInternalValue] = React__namespace.useState(
|
|
16000
16084
|
() => parseToNumber(value) ?? parseToNumber(defaultValue)
|
|
16001
16085
|
);
|
|
@@ -16010,12 +16094,24 @@ var InputNumber = ({
|
|
|
16010
16094
|
}
|
|
16011
16095
|
isBlurClampedRef.current = false;
|
|
16012
16096
|
}, [value]);
|
|
16013
|
-
const autoFormat =
|
|
16014
|
-
enabled:
|
|
16097
|
+
const autoFormat = useFillDecimalOnBlur({
|
|
16098
|
+
enabled: blurFormatEnabled,
|
|
16015
16099
|
decimalScale: decimalScaleProp,
|
|
16016
16100
|
value,
|
|
16017
16101
|
defaultValue
|
|
16018
16102
|
});
|
|
16103
|
+
const isAllowed = React__namespace.useMemo(() => {
|
|
16104
|
+
if (maxIntegerDigits === void 0 && !isAllowedProp) return void 0;
|
|
16105
|
+
return (values) => {
|
|
16106
|
+
if (maxIntegerDigits !== void 0) {
|
|
16107
|
+
const raw = values.value;
|
|
16108
|
+
const unsigned = raw.replace(/^-/, "");
|
|
16109
|
+
const intPart = unsigned.split(".")[0].replace(/^0+/, "") || "0";
|
|
16110
|
+
if (intPart.length > maxIntegerDigits) return false;
|
|
16111
|
+
}
|
|
16112
|
+
return isAllowedProp ? isAllowedProp(values) : true;
|
|
16113
|
+
};
|
|
16114
|
+
}, [maxIntegerDigits, isAllowedProp]);
|
|
16019
16115
|
const notifyChange = React__namespace.useCallback(
|
|
16020
16116
|
(newValue, event) => {
|
|
16021
16117
|
internalValueRef.current = newValue;
|
|
@@ -16080,16 +16176,16 @@ var InputNumber = ({
|
|
|
16080
16176
|
);
|
|
16081
16177
|
onStepChange?.(clamped);
|
|
16082
16178
|
}
|
|
16083
|
-
if (
|
|
16179
|
+
if (blurFormatEnabled && autoFormat.blurScale !== void 0) {
|
|
16084
16180
|
const rawStr = wasClamped ? String(clamped) : rawValueRef.current || String(clamped);
|
|
16085
16181
|
autoFormat.onBlur(truncateStringToFixed(rawStr, autoFormat.blurScale));
|
|
16086
16182
|
} else {
|
|
16087
16183
|
autoFormat.resetEditing();
|
|
16088
16184
|
}
|
|
16089
16185
|
},
|
|
16090
|
-
[onBlur,
|
|
16186
|
+
[onBlur, blurFormatEnabled, autoFormat, min, max, onValueChange, onStepChange]
|
|
16091
16187
|
);
|
|
16092
|
-
const effectiveValue = autoFormat.formattedValue !== void 0 ? autoFormat.formattedValue : isBlurClampedRef.current || stepper.changed ||
|
|
16188
|
+
const effectiveValue = autoFormat.formattedValue !== void 0 ? autoFormat.formattedValue : isBlurClampedRef.current || stepper.changed || blurFormatEnabled ? internalValue : value;
|
|
16093
16189
|
const buttonClass = cn(
|
|
16094
16190
|
"flex items-center justify-center h-3 w-5 transition-colors outline-none",
|
|
16095
16191
|
"text-neutral-400 hover:text-neutral-600 active:text-neutral-900",
|
|
@@ -16103,14 +16199,12 @@ var InputNumber = ({
|
|
|
16103
16199
|
defaultValue,
|
|
16104
16200
|
onValueChange: handleValueChange,
|
|
16105
16201
|
onBlur: handleBlur,
|
|
16106
|
-
...
|
|
16107
|
-
|
|
16108
|
-
decimalScale: decimalScaleProp,
|
|
16109
|
-
fixedDecimalScale: fixedDecimalScaleProp
|
|
16110
|
-
},
|
|
16202
|
+
...isAllowed && { isAllowed },
|
|
16203
|
+
...truncateDecimalOnBlur ? {} : fillDecimalOnBlur ? { decimalScale: decimalScaleProp } : { decimalScale: decimalScaleProp, fixedDecimalScale: fixedDecimalScaleProp },
|
|
16111
16204
|
...autoFormat.formattedValue !== void 0 && { valueIsNumericString: true },
|
|
16112
16205
|
...props,
|
|
16113
16206
|
disabled,
|
|
16207
|
+
invalid,
|
|
16114
16208
|
...customInputProps,
|
|
16115
16209
|
addonSuffix: showStepper ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col -space-y-px", children: [
|
|
16116
16210
|
/* @__PURE__ */ jsxRuntime.jsx(
|