infinity-ui-elements 1.8.10 → 1.8.12
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/SearchableDropdown/SearchableDropdown.d.ts +5 -0
- package/dist/components/SearchableDropdown/SearchableDropdown.d.ts.map +1 -1
- package/dist/components/SearchableDropdown/SearchableDropdown.stories.d.ts +1 -0
- package/dist/components/SearchableDropdown/SearchableDropdown.stories.d.ts.map +1 -1
- 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 +80 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +80 -11
- 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"
|
|
@@ -3152,7 +3214,7 @@ const defaultFilter = (item, query) => {
|
|
|
3152
3214
|
return (item.label.toLowerCase().includes(searchQuery) ||
|
|
3153
3215
|
(item.description?.toLowerCase().includes(searchQuery) ?? false));
|
|
3154
3216
|
};
|
|
3155
|
-
const SearchableDropdown = React__namespace.forwardRef(({ className, items = [], sectionHeading, isLoading = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText, secondaryButtonText, onPrimaryClick, onSecondaryClick, dropdownWidth = "full", showChevron = false, emptyIcon, disableFooter = false, footerLayout = "horizontal", onSearchChange, onItemSelect, filterFunction = defaultFilter, searchValue: controlledSearchValue, defaultSearchValue = "", dropdownClassName, minSearchLength = 0, showOnFocus = true, showAddNew = false, containerClassName, ...textFieldProps }, ref) => {
|
|
3217
|
+
const SearchableDropdown = React__namespace.forwardRef(({ className, items = [], sectionHeading, isLoading = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText, secondaryButtonText, onPrimaryClick, onSecondaryClick, dropdownWidth = "full", showChevron = false, emptyIcon, disableFooter = false, footerLayout = "horizontal", onSearchChange, onItemSelect, filterFunction = defaultFilter, searchValue: controlledSearchValue, defaultSearchValue = "", dropdownClassName, minSearchLength = 0, showOnFocus = true, showAddNew = false, onAddNew, containerClassName, ...textFieldProps }, ref) => {
|
|
3156
3218
|
const [uncontrolledSearchValue, setUncontrolledSearchValue] = React__namespace.useState(defaultSearchValue);
|
|
3157
3219
|
const [isOpen, setIsOpen] = React__namespace.useState(false);
|
|
3158
3220
|
const [focusedIndex, setFocusedIndex] = React__namespace.useState(-1);
|
|
@@ -3219,16 +3281,21 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
|
|
|
3219
3281
|
}
|
|
3220
3282
|
const addNewItem = {
|
|
3221
3283
|
value: searchValue,
|
|
3222
|
-
label: `+ Add ${searchValue}`,
|
|
3284
|
+
label: `+ Add "${searchValue}"`,
|
|
3223
3285
|
variant: "primary",
|
|
3224
3286
|
onClick: () => {
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3287
|
+
if (onAddNew) {
|
|
3288
|
+
onAddNew(searchValue);
|
|
3289
|
+
}
|
|
3290
|
+
else {
|
|
3291
|
+
const newItem = {
|
|
3292
|
+
value: searchValue,
|
|
3293
|
+
label: searchValue,
|
|
3294
|
+
};
|
|
3295
|
+
onItemSelect?.(newItem);
|
|
3296
|
+
if (controlledSearchValue === undefined) {
|
|
3297
|
+
setUncontrolledSearchValue(searchValue);
|
|
3298
|
+
}
|
|
3232
3299
|
}
|
|
3233
3300
|
setIsOpen(false);
|
|
3234
3301
|
inputRef.current?.focus();
|
|
@@ -3240,6 +3307,7 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
|
|
|
3240
3307
|
searchValue,
|
|
3241
3308
|
filteredItems,
|
|
3242
3309
|
onItemSelect,
|
|
3310
|
+
onAddNew,
|
|
3243
3311
|
controlledSearchValue,
|
|
3244
3312
|
]);
|
|
3245
3313
|
// Reset focused index when items change
|
|
@@ -3967,6 +4035,7 @@ const TextArea = React__namespace.forwardRef(({ label, helperText, errorText, su
|
|
|
3967
4035
|
TextArea.displayName = "TextArea";
|
|
3968
4036
|
|
|
3969
4037
|
exports.Alert = Alert;
|
|
4038
|
+
exports.Amount = Amount;
|
|
3970
4039
|
exports.Avatar = Avatar;
|
|
3971
4040
|
exports.AvatarCell = AvatarCell;
|
|
3972
4041
|
exports.Badge = Badge;
|