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.esm.js
CHANGED
|
@@ -992,6 +992,68 @@ const Alert = React.forwardRef(({ className, emphasis = "subtle", intent = "info
|
|
|
992
992
|
});
|
|
993
993
|
Alert.displayName = "Alert";
|
|
994
994
|
|
|
995
|
+
/**
|
|
996
|
+
* Amount component that displays formatted currency amounts with decimal numbers in superscript.
|
|
997
|
+
*
|
|
998
|
+
* @example
|
|
999
|
+
* ```tsx
|
|
1000
|
+
* <Amount value={1234.56} currency="USD" />
|
|
1001
|
+
* // Renders: USD 1,234.<sup>56</sup>
|
|
1002
|
+
*
|
|
1003
|
+
* <Amount value={5000} currency="INR" />
|
|
1004
|
+
* // Renders: INR 5,000.<sup>00</sup>
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
const Amount = React.forwardRef(({ value, currency, locale = "en-US", minimumFractionDigits = 2, maximumFractionDigits = 2, showCurrency = true, className, ...props }, ref) => {
|
|
1008
|
+
// Parse the formatted amount into parts
|
|
1009
|
+
const parts = React.useMemo(() => {
|
|
1010
|
+
// Always format as a number (not currency style) to get number formatting
|
|
1011
|
+
const formatter = new Intl.NumberFormat(locale, {
|
|
1012
|
+
minimumFractionDigits,
|
|
1013
|
+
maximumFractionDigits,
|
|
1014
|
+
});
|
|
1015
|
+
// Use formatToParts to get structured parts
|
|
1016
|
+
const formattedParts = formatter.formatToParts(value);
|
|
1017
|
+
let integerPart = "";
|
|
1018
|
+
let decimalPart = "";
|
|
1019
|
+
let decimalSeparator = ".";
|
|
1020
|
+
formattedParts.forEach((part) => {
|
|
1021
|
+
switch (part.type) {
|
|
1022
|
+
case "integer":
|
|
1023
|
+
integerPart += part.value;
|
|
1024
|
+
break;
|
|
1025
|
+
case "decimal":
|
|
1026
|
+
decimalSeparator = part.value;
|
|
1027
|
+
break;
|
|
1028
|
+
case "fraction":
|
|
1029
|
+
decimalPart = part.value;
|
|
1030
|
+
break;
|
|
1031
|
+
case "group":
|
|
1032
|
+
integerPart += part.value;
|
|
1033
|
+
break;
|
|
1034
|
+
}
|
|
1035
|
+
});
|
|
1036
|
+
// Use currency code as prefix if provided and showCurrency is true
|
|
1037
|
+
const currencyPrefix = currency && showCurrency ? `${currency} ` : "";
|
|
1038
|
+
return {
|
|
1039
|
+
currency: currencyPrefix,
|
|
1040
|
+
integer: integerPart,
|
|
1041
|
+
decimal: decimalPart,
|
|
1042
|
+
decimalSeparator: decimalSeparator,
|
|
1043
|
+
hasDecimal: decimalPart.length > 0,
|
|
1044
|
+
};
|
|
1045
|
+
}, [
|
|
1046
|
+
value,
|
|
1047
|
+
currency,
|
|
1048
|
+
locale,
|
|
1049
|
+
minimumFractionDigits,
|
|
1050
|
+
maximumFractionDigits,
|
|
1051
|
+
showCurrency,
|
|
1052
|
+
]);
|
|
1053
|
+
return (jsxs("span", { ref: ref, className: cn("inline-flex items-baseline", className), ...props, children: [parts.currency && jsx("span", { children: parts.currency }), jsx("span", { className: "ml-[0.2em]", children: parts.integer }), parts.hasDecimal && (jsxs(Fragment, { children: [jsx("span", { className: "mx-[0.05em]", children: parts.decimalSeparator }), jsx("sup", { className: "text-[0.75em] leading-none", children: parts.decimal })] }))] }));
|
|
1054
|
+
});
|
|
1055
|
+
Amount.displayName = "Amount";
|
|
1056
|
+
|
|
995
1057
|
// Helper function to get the text utility class name
|
|
996
1058
|
function getTextClassName(variant = "body", size = "medium", weight = "regular", color = "default") {
|
|
997
1059
|
// Build the base class name
|
|
@@ -3061,7 +3123,7 @@ const textFieldVariants = cva("relative flex items-center gap-2 border rounded-l
|
|
|
3061
3123
|
isDisabled: false,
|
|
3062
3124
|
},
|
|
3063
3125
|
});
|
|
3064
|
-
const TextField = React.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) => {
|
|
3126
|
+
const TextField = React.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) => {
|
|
3065
3127
|
const [internalValue, setInternalValue] = React.useState("");
|
|
3066
3128
|
const inputValue = value !== undefined ? value : internalValue;
|
|
3067
3129
|
const hasValue = inputValue && String(inputValue).length > 0;
|
|
@@ -3108,7 +3170,7 @@ const TextField = React.forwardRef(({ label, helperText, errorText, successText,
|
|
|
3108
3170
|
size,
|
|
3109
3171
|
validationState: currentValidationState,
|
|
3110
3172
|
isDisabled,
|
|
3111
|
-
}), className), children: [prefix && (jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
|
|
3173
|
+
}), isLoading && "text-field-loading", className), children: [prefix && (jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
|
|
3112
3174
|
? "text-surface-ink-neutral-disabled"
|
|
3113
3175
|
: currentValidationState === "positive"
|
|
3114
3176
|
? "text-feedback-ink-positive-intense"
|
|
@@ -3945,5 +4007,5 @@ const TextArea = React.forwardRef(({ label, helperText, errorText, successText,
|
|
|
3945
4007
|
});
|
|
3946
4008
|
TextArea.displayName = "TextArea";
|
|
3947
4009
|
|
|
3948
|
-
export { Alert, Avatar, AvatarCell, Badge, Button, ButtonGroup, Checkbox, Counter, DatePicker, Divider, Dropdown, DropdownMenu, FormFooter, FormHeader, Icon, IconButton, IconCell, Link, ListItem, Modal, NumberCell, Pagination, Radio, SearchableDropdown, Select, Skeleton, SlotCell, SpacerCell, Switch, TabItem, Table, TableDetailPanel, Tabs, Text, TextArea, TextField, Tooltip, alertVariants, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, checkboxVariants, cn, counterVariants, datePickerVariants, dropdownVariants, getAvailableIcons, hasIcon, iconButtonVariants, iconRegistry, linkVariants, listItemVariants, paginationVariants, radioVariants, selectVariants, switchVariants, tableCellVariants, tableHeaderVariants, tableVariants, textAreaVariants, textFieldVariants, tooltipVariants };
|
|
4010
|
+
export { Alert, Amount, Avatar, AvatarCell, Badge, Button, ButtonGroup, Checkbox, Counter, DatePicker, Divider, Dropdown, DropdownMenu, FormFooter, FormHeader, Icon, IconButton, IconCell, Link, ListItem, Modal, NumberCell, Pagination, Radio, SearchableDropdown, Select, Skeleton, SlotCell, SpacerCell, Switch, TabItem, Table, TableDetailPanel, Tabs, Text, TextArea, TextField, Tooltip, alertVariants, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, checkboxVariants, cn, counterVariants, datePickerVariants, dropdownVariants, getAvailableIcons, hasIcon, iconButtonVariants, iconRegistry, linkVariants, listItemVariants, paginationVariants, radioVariants, selectVariants, switchVariants, tableCellVariants, tableHeaderVariants, tableVariants, textAreaVariants, textFieldVariants, tooltipVariants };
|
|
3949
4011
|
//# sourceMappingURL=index.esm.js.map
|