infinity-ui-elements 1.9.19 → 1.9.21
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/Avatar/Avatar.d.ts +4 -0
- package/dist/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/components/SearchableDropdown/SearchableDropdown.d.ts.map +1 -1
- package/dist/components/SearchableDropdown/SearchableDropdown.stories.d.ts +1 -1
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/SelectTextField/SelectTextField.d.ts.map +1 -1
- package/dist/index.esm.js +71 -39
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +71 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1100,33 +1100,6 @@ const Amount = React__namespace.forwardRef(({ value, currency, locale = "en-US",
|
|
|
1100
1100
|
});
|
|
1101
1101
|
Amount.displayName = "Amount";
|
|
1102
1102
|
|
|
1103
|
-
// Helper function to get the text utility class name
|
|
1104
|
-
function getTextClassName(variant = "body", size = "medium", weight = "regular", color = "default") {
|
|
1105
|
-
// Build the base class name
|
|
1106
|
-
let baseClass = `text-${variant}`;
|
|
1107
|
-
// Add size
|
|
1108
|
-
if (size) {
|
|
1109
|
-
baseClass += `-${size}`;
|
|
1110
|
-
}
|
|
1111
|
-
// Add weight
|
|
1112
|
-
if (weight) {
|
|
1113
|
-
baseClass += `-${weight}`;
|
|
1114
|
-
}
|
|
1115
|
-
// Add color class separately
|
|
1116
|
-
const colorClass = `text-color-${color}`;
|
|
1117
|
-
return `${baseClass} ${colorClass}`;
|
|
1118
|
-
}
|
|
1119
|
-
const Text = React__namespace.forwardRef(({ className, variant = "body", size = "medium", weight = "regular", color = "default", as = "p", children, ...props }, ref) => {
|
|
1120
|
-
const Component = as;
|
|
1121
|
-
const textClass = getTextClassName(variant, size, weight, color);
|
|
1122
|
-
return React__namespace.createElement(Component, {
|
|
1123
|
-
className: cn(textClass, className),
|
|
1124
|
-
ref,
|
|
1125
|
-
...props,
|
|
1126
|
-
}, children);
|
|
1127
|
-
});
|
|
1128
|
-
Text.displayName = "Text";
|
|
1129
|
-
|
|
1130
1103
|
const inverseColorClasses = {
|
|
1131
1104
|
a1: "bg-avatar-fill-a1-on-bg text-avatar-fill-a1-bg",
|
|
1132
1105
|
a2: "bg-avatar-fill-a2-on-bg text-avatar-fill-a2-bg",
|
|
@@ -1174,7 +1147,7 @@ const statusVariants = classVarianceAuthority.cva("absolute flex items-center ju
|
|
|
1174
1147
|
statusColor: "notice",
|
|
1175
1148
|
},
|
|
1176
1149
|
});
|
|
1177
|
-
const Avatar = React__namespace.forwardRef(({ className, appearance = "default", color, size, children, src, alt, showStatus = false, statusColor = "notice", statusIcon, label, trailingComponent, containerClassName, ...props }, ref) => {
|
|
1150
|
+
const Avatar = React__namespace.forwardRef(({ className, appearance = "default", color, size, children, src, alt, showStatus = false, statusColor = "notice", statusIcon, label, trailingComponent, containerClassName, labelClassName, ...props }, ref) => {
|
|
1178
1151
|
const [imageError, setImageError] = React__namespace.useState(false);
|
|
1179
1152
|
const handleImageError = () => {
|
|
1180
1153
|
setImageError(true);
|
|
@@ -1189,14 +1162,14 @@ const Avatar = React__namespace.forwardRef(({ className, appearance = "default",
|
|
|
1189
1162
|
return "h-4 w-4";
|
|
1190
1163
|
}
|
|
1191
1164
|
};
|
|
1192
|
-
const
|
|
1165
|
+
const getTextClass = () => {
|
|
1193
1166
|
switch (size) {
|
|
1194
1167
|
case "small":
|
|
1195
|
-
return "small";
|
|
1168
|
+
return "text-body-small-medium text-color-default";
|
|
1196
1169
|
case "medium":
|
|
1197
|
-
return "medium";
|
|
1170
|
+
return "text-body-medium-medium text-color-default";
|
|
1198
1171
|
default:
|
|
1199
|
-
return "medium";
|
|
1172
|
+
return "text-body-medium-medium text-color-default";
|
|
1200
1173
|
}
|
|
1201
1174
|
};
|
|
1202
1175
|
const resolvedColor = color ?? "a1";
|
|
@@ -1208,7 +1181,7 @@ const Avatar = React__namespace.forwardRef(({ className, appearance = "default",
|
|
|
1208
1181
|
return jsxRuntime.jsx("div", { ref: ref, children: avatarElement });
|
|
1209
1182
|
}
|
|
1210
1183
|
// Otherwise, return avatar with label and/or trailing component
|
|
1211
|
-
return (jsxRuntime.jsxs("div", { ref: ref, className: cn("inline-flex items-center gap-3", containerClassName), children: [avatarElement, label &&
|
|
1184
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn("inline-flex items-center gap-3", containerClassName), children: [avatarElement, label && jsxRuntime.jsx("p", { className: cn(getTextClass(), labelClassName), children: label }), trailingComponent && (jsxRuntime.jsx("span", { className: "ml-auto", children: trailingComponent }))] }));
|
|
1212
1185
|
});
|
|
1213
1186
|
Avatar.displayName = "Avatar";
|
|
1214
1187
|
|
|
@@ -1338,6 +1311,33 @@ const Badge = React__namespace.forwardRef(({ className, variant, size, color, sh
|
|
|
1338
1311
|
});
|
|
1339
1312
|
Badge.displayName = "Badge";
|
|
1340
1313
|
|
|
1314
|
+
// Helper function to get the text utility class name
|
|
1315
|
+
function getTextClassName(variant = "body", size = "medium", weight = "regular", color = "default") {
|
|
1316
|
+
// Build the base class name
|
|
1317
|
+
let baseClass = `text-${variant}`;
|
|
1318
|
+
// Add size
|
|
1319
|
+
if (size) {
|
|
1320
|
+
baseClass += `-${size}`;
|
|
1321
|
+
}
|
|
1322
|
+
// Add weight
|
|
1323
|
+
if (weight) {
|
|
1324
|
+
baseClass += `-${weight}`;
|
|
1325
|
+
}
|
|
1326
|
+
// Add color class separately
|
|
1327
|
+
const colorClass = `text-color-${color}`;
|
|
1328
|
+
return `${baseClass} ${colorClass}`;
|
|
1329
|
+
}
|
|
1330
|
+
const Text = React__namespace.forwardRef(({ className, variant = "body", size = "medium", weight = "regular", color = "default", as = "p", children, ...props }, ref) => {
|
|
1331
|
+
const Component = as;
|
|
1332
|
+
const textClass = getTextClassName(variant, size, weight, color);
|
|
1333
|
+
return React__namespace.createElement(Component, {
|
|
1334
|
+
className: cn(textClass, className),
|
|
1335
|
+
ref,
|
|
1336
|
+
...props,
|
|
1337
|
+
}, children);
|
|
1338
|
+
});
|
|
1339
|
+
Text.displayName = "Text";
|
|
1340
|
+
|
|
1341
1341
|
const dividerVariants = classVarianceAuthority.cva("", {
|
|
1342
1342
|
variants: {
|
|
1343
1343
|
orientation: {
|
|
@@ -3498,10 +3498,22 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
|
|
|
3498
3498
|
const [uncontrolledValue, setUncontrolledValue] = React__namespace.useState(defaultValue);
|
|
3499
3499
|
const [isOpen, setIsOpen] = React__namespace.useState(false);
|
|
3500
3500
|
const [dropdownPlacement, setDropdownPlacement] = React__namespace.useState("bottom");
|
|
3501
|
+
const [isMobile, setIsMobile] = React__namespace.useState(false);
|
|
3501
3502
|
const containerRef = React__namespace.useRef(null);
|
|
3502
3503
|
const dropdownContainerRef = React__namespace.useRef(null);
|
|
3503
3504
|
const inputRef = React__namespace.useRef(null);
|
|
3504
3505
|
React__namespace.useImperativeHandle(ref, () => inputRef.current);
|
|
3506
|
+
// Detect if we're on mobile (< 768px)
|
|
3507
|
+
React__namespace.useEffect(() => {
|
|
3508
|
+
const checkMobile = () => {
|
|
3509
|
+
setIsMobile(window.innerWidth < 768);
|
|
3510
|
+
};
|
|
3511
|
+
// Check on mount
|
|
3512
|
+
checkMobile();
|
|
3513
|
+
// Add resize listener
|
|
3514
|
+
window.addEventListener('resize', checkMobile);
|
|
3515
|
+
return () => window.removeEventListener('resize', checkMobile);
|
|
3516
|
+
}, []);
|
|
3505
3517
|
const value = controlledValue !== undefined ? controlledValue : uncontrolledValue;
|
|
3506
3518
|
// Find the selected option
|
|
3507
3519
|
const selectedOption = options.find((opt) => opt.value === value);
|
|
@@ -3658,9 +3670,11 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
|
|
|
3658
3670
|
// Build the suffix: include both the optional suffix and the chevron icon
|
|
3659
3671
|
const chevronIcon = (jsxRuntime.jsx(Icon, { name: isOpen ? "chevronUp" : "chevronDown", size: 16, className: "shrink-0 transition-colors" }));
|
|
3660
3672
|
const displaySuffix = suffix ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [suffix, chevronIcon] })) : (chevronIcon);
|
|
3661
|
-
|
|
3673
|
+
// Render dropdown menu content
|
|
3674
|
+
const renderDropdownContent = () => (jsxRuntime.jsx(DropdownMenu, { items: menuItems, sectionHeading: sectionHeading, isEmpty: options.length === 0, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyIcon: emptyIcon, disableFooter: true, onClose: () => handleOpenChange(false), className: menuClassName, width: isMobile ? "full" : widthStyle, unstyled: isMobile }));
|
|
3675
|
+
return (jsxRuntime.jsxs("div", { ref: containerRef, className: "relative w-full", children: [jsxRuntime.jsx(TextField, { ref: inputRef, label: label, helperText: helperText, errorText: errorText, successText: successText, validationState: validationState, isDisabled: isDisabled, isRequired: isRequired, isOptional: isOptional, isLoading: isLoading, size: size, prefix: displayPrefix, suffix: displaySuffix, showClearButton: showClearButton && hasValue && !isLoading, onClear: handleClear, placeholder: placeholder, value: displayValue, readOnly: true, containerClassName: cn("w-full", containerClassName), labelClassName: labelClassName, className: cn("cursor-pointer", triggerClassName, className), inputClassName: "cursor-pointer", infoHeading: infoHeading, infoDescription: infoDescription, LinkComponent: LinkComponent, linkText: linkText, linkHref: linkHref, onLinkClick: onLinkClick, onClick: toggleOpen, onKeyDown: handleKeyDown, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": isOpen, ...props }), isOpen && !isDisabled && !isLoading && (isMobile ? (jsxRuntime.jsx(BottomSheet, { isOpen: isOpen, onClose: () => handleOpenChange(false), title: sectionHeading || label, variant: "default", showDragHandle: true, closeOnOverlayClick: true, closeOnEscape: true, closeOnSwipeDown: true, children: renderDropdownContent() })) : (jsxRuntime.jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50 left-0 right-0", dropdownPlacement === "bottom"
|
|
3662
3676
|
? "top-full mt-1"
|
|
3663
|
-
: "bottom-full mb-1"), children:
|
|
3677
|
+
: "bottom-full mb-1"), children: renderDropdownContent() })))] }));
|
|
3664
3678
|
});
|
|
3665
3679
|
Select.displayName = "Select";
|
|
3666
3680
|
|
|
@@ -4373,14 +4387,18 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
|
|
|
4373
4387
|
? true
|
|
4374
4388
|
: false, footerLayout: footerLayout, onClose: () => setIsOpen(false), focusedIndex: focusedIndex, className: dropdownClassName, width: isMobile ? "full" : (dropdownWidth === "full" ? "full" : "auto"), unstyled: isMobile }));
|
|
4375
4389
|
// Mobile: BottomSheet, Desktop: Regular Dropdown
|
|
4376
|
-
const dropdownMenu = showDropdown && (isMobile ? (jsxRuntime.
|
|
4390
|
+
const dropdownMenu = showDropdown && (isMobile ? (jsxRuntime.jsxs(BottomSheet, { isOpen: isOpen, onClose: () => setIsOpen(false), title: sectionHeading, variant: "default", showDragHandle: true, closeOnOverlayClick: true, closeOnEscape: true, closeOnSwipeDown: true, children: [jsxRuntime.jsx("div", { className: "mb-4", children: jsxRuntime.jsx(TextField, { value: searchValue, onChange: handleSearchChange, onKeyDown: handleKeyDown, containerClassName: "mb-0", placeholder: textFieldProps.placeholder || "Search...", autoFocus: true, ...textFieldProps }) }), renderDropdownContent()] })) : (jsxRuntime.jsx("div", { ref: menuRef, style: {
|
|
4377
4391
|
position: "absolute",
|
|
4378
4392
|
top: `${position.top + 8}px`,
|
|
4379
4393
|
left: `${position.left}px`,
|
|
4380
4394
|
width: dropdownWidth === "full" ? `${position.width}px` : "auto",
|
|
4381
4395
|
zIndex: isInsideModal ? 10001 : 9999,
|
|
4382
4396
|
}, children: renderDropdownContent() })));
|
|
4383
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.
|
|
4397
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { ref: dropdownRef, className: cn("relative", containerClassName), children: [!isMobile && (jsxRuntime.jsx(TextField, { ref: inputRef, value: searchValue, onChange: handleSearchChange, onFocus: handleFocus, onKeyDown: handleKeyDown, containerClassName: "mb-0", ...textFieldProps })), isMobile && (jsxRuntime.jsx(TextField, { ref: inputRef, value: searchValue, onFocus: () => {
|
|
4398
|
+
if (showOnFocus && searchValue.length >= minSearchLength) {
|
|
4399
|
+
setIsOpen(true);
|
|
4400
|
+
}
|
|
4401
|
+
}, onClick: () => setIsOpen(true), readOnly: true, containerClassName: "mb-0", ...textFieldProps }))] }), typeof document !== "undefined" &&
|
|
4384
4402
|
dropdownMenu &&
|
|
4385
4403
|
reactDom.createPortal(dropdownMenu, document.body)] }));
|
|
4386
4404
|
});
|
|
@@ -4558,9 +4576,21 @@ const SelectTextField = React__namespace.forwardRef(({ textValue: controlledText
|
|
|
4558
4576
|
const [uncontrolledSelectValue, setUncontrolledSelectValue] = React__namespace.useState(defaultSelectValue);
|
|
4559
4577
|
const [isSelectOpen, setIsSelectOpen] = React__namespace.useState(false);
|
|
4560
4578
|
const [dropdownPlacement, setDropdownPlacement] = React__namespace.useState("bottom");
|
|
4579
|
+
const [isMobile, setIsMobile] = React__namespace.useState(false);
|
|
4561
4580
|
const selectRef = React__namespace.useRef(null);
|
|
4562
4581
|
const dropdownContainerRef = React__namespace.useRef(null);
|
|
4563
4582
|
const componentRef = React__namespace.useRef(null);
|
|
4583
|
+
// Detect if we're on mobile (< 768px)
|
|
4584
|
+
React__namespace.useEffect(() => {
|
|
4585
|
+
const checkMobile = () => {
|
|
4586
|
+
setIsMobile(window.innerWidth < 768);
|
|
4587
|
+
};
|
|
4588
|
+
// Check on mount
|
|
4589
|
+
checkMobile();
|
|
4590
|
+
// Add resize listener
|
|
4591
|
+
window.addEventListener('resize', checkMobile);
|
|
4592
|
+
return () => window.removeEventListener('resize', checkMobile);
|
|
4593
|
+
}, []);
|
|
4564
4594
|
const textValue = controlledTextValue !== undefined
|
|
4565
4595
|
? controlledTextValue
|
|
4566
4596
|
: uncontrolledTextValue;
|
|
@@ -4708,6 +4738,8 @@ const SelectTextField = React__namespace.forwardRef(({ textValue: controlledText
|
|
|
4708
4738
|
gap: "gap-3",
|
|
4709
4739
|
},
|
|
4710
4740
|
};
|
|
4741
|
+
// Render dropdown menu content
|
|
4742
|
+
const renderDropdownContent = () => (jsxRuntime.jsx(DropdownMenu, { items: menuItems, sectionHeading: selectSectionHeading, isEmpty: selectOptions.length === 0, emptyTitle: selectEmptyTitle, emptyDescription: selectEmptyDescription, emptyIcon: selectEmptyIcon, disableFooter: true, onClose: () => handleSelectOpenChange(false), className: selectMenuClassName, width: isMobile ? "full" : widthStyle, unstyled: isMobile }));
|
|
4711
4743
|
// Create the select component (prefix or suffix)
|
|
4712
4744
|
const selectComponent = (jsxRuntime.jsxs("div", { className: cn("relative flex items-stretch h-full"), children: [jsxRuntime.jsxs("div", { ref: selectRef, className: cn(selectTriggerVariants({
|
|
4713
4745
|
size,
|
|
@@ -4725,9 +4757,9 @@ const SelectTextField = React__namespace.forwardRef(({ textValue: controlledText
|
|
|
4725
4757
|
? "text-feedback-ink-positive-intense"
|
|
4726
4758
|
: currentValidationState === "negative"
|
|
4727
4759
|
? "text-feedback-ink-negative-subtle"
|
|
4728
|
-
: "text-surface-ink-neutral-muted", isSelectOpen && "transform rotate-180") })] }), isSelectOpen && !isDisabled && (jsxRuntime.jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50", position === "prefix" ? "left-[-12px]" : "right-[-12px]", dropdownPlacement === "bottom"
|
|
4760
|
+
: "text-surface-ink-neutral-muted", isSelectOpen && "transform rotate-180") })] }), isSelectOpen && !isDisabled && (isMobile ? (jsxRuntime.jsx(BottomSheet, { isOpen: isSelectOpen, onClose: () => handleSelectOpenChange(false), title: selectSectionHeading || label, variant: "default", showDragHandle: true, closeOnOverlayClick: true, closeOnEscape: true, closeOnSwipeDown: true, children: renderDropdownContent() })) : (jsxRuntime.jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50", position === "prefix" ? "left-[-12px]" : "right-[-12px]", dropdownPlacement === "bottom"
|
|
4729
4761
|
? "top-[30px] mt-1"
|
|
4730
|
-
: "bottom-full mb-1"), children:
|
|
4762
|
+
: "bottom-full mb-1"), children: renderDropdownContent() })))] }));
|
|
4731
4763
|
return (jsxRuntime.jsxs("div", { ref: componentRef, className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), children: [label && (jsxRuntime.jsx(FormHeader, { label: label, size: size, isRequired: isRequired, isOptional: isOptional, infoHeading: textFieldProps.infoHeading, infoDescription: textFieldProps.infoDescription, LinkComponent: textFieldProps.LinkComponent, linkText: textFieldProps.linkText, linkHref: textFieldProps.linkHref, onLinkClick: textFieldProps.onLinkClick, htmlFor: textFieldProps.id, className: "mb-2", labelClassName: labelClassName })), jsxRuntime.jsx(TextField, { ref: ref, value: textValue, onChange: handleTextChange, ...(position === "prefix"
|
|
4732
4764
|
? { prefix: selectComponent }
|
|
4733
4765
|
: { suffix: selectComponent }), size: size, validationState: currentValidationState, isDisabled: isDisabled, isRequired: isRequired, isOptional: isOptional, containerClassName: "gap-0", className: className, inputClassName: inputClassName, ...textFieldProps }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
|