infinity-ui-elements 1.8.10 → 1.8.11
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/components/Amount/Amount.d.ts +46 -0
- package/dist/components/Amount/Amount.d.ts.map +1 -0
- package/dist/components/Amount/Amount.stories.d.ts +16 -0
- package/dist/components/Amount/Amount.stories.d.ts.map +1 -0
- package/dist/components/Amount/index.d.ts +2 -0
- package/dist/components/Amount/index.d.ts.map +1 -0
- package/dist/components/TextField/TextField.d.ts +1 -0
- package/dist/components/TextField/TextField.d.ts.map +1 -1
- package/dist/components/TextField/TextField.stories.d.ts +1 -0
- package/dist/components/TextField/TextField.stories.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +65 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +65 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1013,6 +1013,68 @@ const Alert = React__namespace.forwardRef(({ className, emphasis = "subtle", int
|
|
|
1013
1013
|
});
|
|
1014
1014
|
Alert.displayName = "Alert";
|
|
1015
1015
|
|
|
1016
|
+
/**
|
|
1017
|
+
* Amount component that displays formatted currency amounts with decimal numbers in superscript.
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* ```tsx
|
|
1021
|
+
* <Amount value={1234.56} currency="USD" />
|
|
1022
|
+
* // Renders: USD 1,234.<sup>56</sup>
|
|
1023
|
+
*
|
|
1024
|
+
* <Amount value={5000} currency="INR" />
|
|
1025
|
+
* // Renders: INR 5,000.<sup>00</sup>
|
|
1026
|
+
* ```
|
|
1027
|
+
*/
|
|
1028
|
+
const Amount = React__namespace.forwardRef(({ value, currency, locale = "en-US", minimumFractionDigits = 2, maximumFractionDigits = 2, showCurrency = true, className, ...props }, ref) => {
|
|
1029
|
+
// Parse the formatted amount into parts
|
|
1030
|
+
const parts = React__namespace.useMemo(() => {
|
|
1031
|
+
// Always format as a number (not currency style) to get number formatting
|
|
1032
|
+
const formatter = new Intl.NumberFormat(locale, {
|
|
1033
|
+
minimumFractionDigits,
|
|
1034
|
+
maximumFractionDigits,
|
|
1035
|
+
});
|
|
1036
|
+
// Use formatToParts to get structured parts
|
|
1037
|
+
const formattedParts = formatter.formatToParts(value);
|
|
1038
|
+
let integerPart = "";
|
|
1039
|
+
let decimalPart = "";
|
|
1040
|
+
let decimalSeparator = ".";
|
|
1041
|
+
formattedParts.forEach((part) => {
|
|
1042
|
+
switch (part.type) {
|
|
1043
|
+
case "integer":
|
|
1044
|
+
integerPart += part.value;
|
|
1045
|
+
break;
|
|
1046
|
+
case "decimal":
|
|
1047
|
+
decimalSeparator = part.value;
|
|
1048
|
+
break;
|
|
1049
|
+
case "fraction":
|
|
1050
|
+
decimalPart = part.value;
|
|
1051
|
+
break;
|
|
1052
|
+
case "group":
|
|
1053
|
+
integerPart += part.value;
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
// Use currency code as prefix if provided and showCurrency is true
|
|
1058
|
+
const currencyPrefix = currency && showCurrency ? `${currency} ` : "";
|
|
1059
|
+
return {
|
|
1060
|
+
currency: currencyPrefix,
|
|
1061
|
+
integer: integerPart,
|
|
1062
|
+
decimal: decimalPart,
|
|
1063
|
+
decimalSeparator: decimalSeparator,
|
|
1064
|
+
hasDecimal: decimalPart.length > 0,
|
|
1065
|
+
};
|
|
1066
|
+
}, [
|
|
1067
|
+
value,
|
|
1068
|
+
currency,
|
|
1069
|
+
locale,
|
|
1070
|
+
minimumFractionDigits,
|
|
1071
|
+
maximumFractionDigits,
|
|
1072
|
+
showCurrency,
|
|
1073
|
+
]);
|
|
1074
|
+
return (jsxRuntime.jsxs("span", { ref: ref, className: cn("inline-flex items-baseline", className), ...props, children: [parts.currency && jsxRuntime.jsx("span", { children: parts.currency }), jsxRuntime.jsx("span", { className: "ml-[0.2em]", children: parts.integer }), parts.hasDecimal && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: "mx-[0.05em]", children: parts.decimalSeparator }), jsxRuntime.jsx("sup", { className: "text-[0.75em] leading-none", children: parts.decimal })] }))] }));
|
|
1075
|
+
});
|
|
1076
|
+
Amount.displayName = "Amount";
|
|
1077
|
+
|
|
1016
1078
|
// Helper function to get the text utility class name
|
|
1017
1079
|
function getTextClassName(variant = "body", size = "medium", weight = "regular", color = "default") {
|
|
1018
1080
|
// Build the base class name
|
|
@@ -3082,7 +3144,7 @@ const textFieldVariants = classVarianceAuthority.cva("relative flex items-center
|
|
|
3082
3144
|
isDisabled: false,
|
|
3083
3145
|
},
|
|
3084
3146
|
});
|
|
3085
|
-
const TextField = React__namespace.forwardRef(({ label, helperText, errorText, successText, size = "medium", validationState = "none", isDisabled = false, isRequired = false, isOptional = false, prefix, suffix, showClearButton = false, infoDescription, infoHeading, LinkComponent, linkText, linkHref, onLinkClick, onClear, containerClassName, labelClassName, inputClassName, className, value, onChange, ...props }, ref) => {
|
|
3147
|
+
const TextField = React__namespace.forwardRef(({ label, helperText, errorText, successText, size = "medium", validationState = "none", isDisabled = false, isLoading = false, isRequired = false, isOptional = false, prefix, suffix, showClearButton = false, infoDescription, infoHeading, LinkComponent, linkText, linkHref, onLinkClick, onClear, containerClassName, labelClassName, inputClassName, className, value, onChange, ...props }, ref) => {
|
|
3086
3148
|
const [internalValue, setInternalValue] = React__namespace.useState("");
|
|
3087
3149
|
const inputValue = value !== undefined ? value : internalValue;
|
|
3088
3150
|
const hasValue = inputValue && String(inputValue).length > 0;
|
|
@@ -3129,7 +3191,7 @@ const TextField = React__namespace.forwardRef(({ label, helperText, errorText, s
|
|
|
3129
3191
|
size,
|
|
3130
3192
|
validationState: currentValidationState,
|
|
3131
3193
|
isDisabled,
|
|
3132
|
-
}), className), children: [prefix && (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
|
|
3194
|
+
}), isLoading && "text-field-loading", className), children: [prefix && (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
|
|
3133
3195
|
? "text-surface-ink-neutral-disabled"
|
|
3134
3196
|
: currentValidationState === "positive"
|
|
3135
3197
|
? "text-feedback-ink-positive-intense"
|
|
@@ -3967,6 +4029,7 @@ const TextArea = React__namespace.forwardRef(({ label, helperText, errorText, su
|
|
|
3967
4029
|
TextArea.displayName = "TextArea";
|
|
3968
4030
|
|
|
3969
4031
|
exports.Alert = Alert;
|
|
4032
|
+
exports.Amount = Amount;
|
|
3970
4033
|
exports.Avatar = Avatar;
|
|
3971
4034
|
exports.AvatarCell = AvatarCell;
|
|
3972
4035
|
exports.Badge = Badge;
|