infinity-ui-elements 1.14.18 → 1.14.19

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.js CHANGED
@@ -1964,7 +1964,7 @@ const Counter = React__namespace.forwardRef(({ value, max, size = "medium", colo
1964
1964
  });
1965
1965
  Counter.displayName = "Counter";
1966
1966
 
1967
- const tooltipVariants = classVarianceAuthority.cva("fixed z-[1000] bg-popup-fill-intense text-action-ink-on-primary-normal rounded-medium border border-popup-outline-subtle flex flex-col p-4 rounded-xlarge min-w-[200px] max-w-[300px] transition-opacity duration-200", {
1967
+ const tooltipVariants = classVarianceAuthority.cva("fixed z-50 bg-popup-fill-intense text-action-ink-on-primary-normal rounded-medium border border-popup-outline-subtle flex flex-col p-4 rounded-xlarge min-w-[200px] max-w-[300px] transition-opacity duration-200", {
1968
1968
  variants: {
1969
1969
  isVisible: {
1970
1970
  true: "opacity-100 pointer-events-auto shadow-[0_4px_20px_rgba(0,0,0,0.15)]",
@@ -3174,17 +3174,17 @@ const dropdownVariants = classVarianceAuthority.cva("bg-surface-fill-primary-nor
3174
3174
  size: "medium",
3175
3175
  },
3176
3176
  });
3177
- const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [], customContent, customContentClassName, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, size = "medium", open: controlledOpen, defaultOpen = false, onOpenChange, containerClassName, menuClassName, showChevron = false, emptyIcon, disableFooter = false, showFooter, usePortal = true, ...props }, ref) => {
3177
+ const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [], customContent, customContentClassName, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, size = "medium", open: controlledOpen, defaultOpen = false, onOpenChange, containerClassName, menuClassName, showChevron = false, emptyIcon, disableFooter = false, showFooter, ...props }, ref) => {
3178
3178
  const [uncontrolledOpen, setUncontrolledOpen] = React__namespace.useState(defaultOpen);
3179
3179
  const isOpen = controlledOpen !== undefined ? controlledOpen : uncontrolledOpen;
3180
3180
  const dropdownRef = React__namespace.useRef(null);
3181
3181
  const menuRef = React__namespace.useRef(null);
3182
3182
  const [menuPosition, setMenuPosition] = React__namespace.useState({
3183
- top: 0,
3184
- left: 0,
3185
- width: 0,
3183
+ top: "100%",
3184
+ bottom: "auto",
3185
+ left: "0",
3186
+ right: "auto",
3186
3187
  maxHeight: "400px",
3187
- position: "below",
3188
3188
  });
3189
3189
  // Detect if we're on mobile (< 768px)
3190
3190
  const [isMobile, setIsMobile] = React__namespace.useState(false);
@@ -3238,36 +3238,62 @@ const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [],
3238
3238
  }, [isOpen]);
3239
3239
  // Calculate and adjust dropdown position to keep it within viewport
3240
3240
  React__namespace.useEffect(() => {
3241
- if (!isOpen || !dropdownRef.current)
3241
+ if (!isOpen || !dropdownRef.current || !menuRef.current)
3242
3242
  return;
3243
3243
  const calculatePosition = () => {
3244
3244
  const triggerRect = dropdownRef.current.getBoundingClientRect();
3245
3245
  const menuElement = menuRef.current;
3246
- // Get menu dimensions
3247
- const menuHeight = menuElement?.getBoundingClientRect().height || 400;
3248
- triggerRect.width; // Match trigger width or use size variant
3246
+ // Get menu dimensions (use a temporary measurement if needed)
3247
+ const menuRect = menuElement.getBoundingClientRect();
3248
+ const menuHeight = menuRect.height || 400; // fallback to max-height
3249
+ const menuWidth = menuRect.width;
3249
3250
  const viewportHeight = window.innerHeight;
3251
+ const viewportWidth = window.innerWidth;
3250
3252
  const spaceBelow = viewportHeight - triggerRect.bottom;
3251
3253
  const spaceAbove = triggerRect.top;
3254
+ const spaceRight = viewportWidth - triggerRect.left;
3255
+ const spaceLeft = triggerRect.right;
3252
3256
  const position = {
3253
- top: 0,
3254
- left: triggerRect.left + window.scrollX,
3255
- width: triggerRect.width,
3257
+ top: "auto",
3258
+ bottom: "auto",
3259
+ left: "auto",
3260
+ right: "auto",
3256
3261
  maxHeight: "400px",
3257
- position: "below",
3258
3262
  };
3259
3263
  // Vertical positioning
3260
3264
  if (spaceBelow >= menuHeight || spaceBelow >= spaceAbove) {
3261
3265
  // Position below trigger
3262
- position.top = triggerRect.bottom + window.scrollY + 8; // 8px gap
3266
+ position.top = "100%";
3267
+ position.bottom = "auto";
3263
3268
  position.maxHeight = `${Math.min(400, spaceBelow - 16)}px`;
3264
- position.position = "below";
3265
3269
  }
3266
3270
  else {
3267
3271
  // Position above trigger
3268
- position.top = triggerRect.top + window.scrollY - menuHeight - 8; // 8px gap
3272
+ position.top = "auto";
3273
+ position.bottom = "100%";
3269
3274
  position.maxHeight = `${Math.min(400, spaceAbove - 16)}px`;
3270
- position.position = "above";
3275
+ }
3276
+ // Horizontal positioning
3277
+ if (spaceRight >= menuWidth) {
3278
+ // Align to left edge of trigger
3279
+ position.left = "0";
3280
+ position.right = "auto";
3281
+ }
3282
+ else if (spaceLeft >= menuWidth) {
3283
+ // Align to right edge of trigger
3284
+ position.left = "auto";
3285
+ position.right = "0";
3286
+ }
3287
+ else {
3288
+ // Not enough space on either side, try to center or align based on available space
3289
+ if (triggerRect.left + menuWidth > viewportWidth) {
3290
+ position.left = "auto";
3291
+ position.right = "0";
3292
+ }
3293
+ else {
3294
+ position.left = "0";
3295
+ position.right = "auto";
3296
+ }
3271
3297
  }
3272
3298
  setMenuPosition(position);
3273
3299
  };
@@ -3290,29 +3316,16 @@ const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [],
3290
3316
  };
3291
3317
  // Render dropdown menu content wrapped in BottomSheet for mobile
3292
3318
  const renderDropdownContent = () => (jsxRuntime.jsx(DropdownMenu, { ref: ref, items: items, customContent: customContent, customContentClassName: customContentClassName, sectionHeading: sectionHeading, isLoading: isLoading, isEmpty: isEmpty, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyLinkText: emptyLinkText, onEmptyLinkClick: onEmptyLinkClick, primaryButtonText: primaryButtonText, secondaryButtonText: secondaryButtonText, onPrimaryClick: onPrimaryClick, onSecondaryClick: onSecondaryClick, showChevron: showChevron, emptyIcon: emptyIcon, disableFooter: disableFooter, showFooter: showFooter, onClose: () => handleOpenChange(false), className: className, width: isMobile ? "full" : sizeMap[size], maxHeight: menuPosition.maxHeight, unstyled: isMobile }));
3293
- // Render the dropdown menu for desktop
3294
- const renderDesktopDropdown = () => {
3295
- if (!isOpen)
3296
- return null;
3297
- const dropdownMenu = (jsxRuntime.jsx("div", { ref: menuRef, className: cn("fixed z-[1000]", menuClassName), style: {
3298
- top: `${menuPosition.top}px`,
3299
- left: `${menuPosition.left}px`,
3300
- width: `${menuPosition.width}px`,
3301
- }, children: renderDropdownContent() }));
3302
- // Use portal if enabled, otherwise render inline
3303
- return usePortal && typeof document !== 'undefined'
3304
- ? reactDom.createPortal(dropdownMenu, document.body)
3305
- : (jsxRuntime.jsx("div", { ref: menuRef, className: cn("absolute z-[1000]", menuClassName), style: {
3306
- top: menuPosition.position === "below" ? "100%" : "auto",
3307
- bottom: menuPosition.position === "above" ? "100%" : "auto",
3308
- left: "0",
3309
- marginTop: menuPosition.position === "below" ? "0.5rem" : "0",
3310
- marginBottom: menuPosition.position === "above" ? "0.5rem" : "0",
3311
- }, children: renderDropdownContent() }));
3312
- };
3313
3319
  return (jsxRuntime.jsxs("div", { ref: dropdownRef, className: cn("relative inline-block", containerClassName), ...props, children: [trigger && (jsxRuntime.jsx("div", { onClick: toggleOpen, className: "cursor-pointer", children: trigger })), isMobile ? (jsxRuntime.jsx(BottomSheet, { isOpen: isOpen, onClose: () => handleOpenChange(false), title: sectionHeading, variant: "default", showDragHandle: true, closeOnOverlayClick: true, closeOnEscape: true, closeOnSwipeDown: true, children: renderDropdownContent() })) : (
3314
- /* Desktop: Regular Dropdown Menu with Portal */
3315
- renderDesktopDropdown())] }));
3320
+ /* Desktop: Regular Dropdown Menu */
3321
+ isOpen && (jsxRuntime.jsx("div", { ref: menuRef, className: cn("absolute z-50", menuClassName), style: {
3322
+ top: menuPosition.top,
3323
+ bottom: menuPosition.bottom,
3324
+ left: menuPosition.left,
3325
+ right: menuPosition.right,
3326
+ marginTop: menuPosition.top === "100%" ? "0.5rem" : "0",
3327
+ marginBottom: menuPosition.bottom === "100%" ? "0.5rem" : "0",
3328
+ }, children: renderDropdownContent() })))] }));
3316
3329
  });
3317
3330
  Dropdown.displayName = "Dropdown";
3318
3331
 
@@ -3836,7 +3849,7 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
3836
3849
  const displaySuffix = suffix ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [suffix, chevronIcon] })) : (chevronIcon);
3837
3850
  // Render dropdown menu content
3838
3851
  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 }));
3839
- 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-[1000] left-0 right-0", dropdownPlacement === "bottom"
3852
+ 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"
3840
3853
  ? "top-full mt-1"
3841
3854
  : "bottom-full mb-1"), children: renderDropdownContent() })))] }));
3842
3855
  });
@@ -4994,7 +5007,7 @@ const SelectTextField = React__namespace.forwardRef(({ textValue: controlledText
4994
5007
  ? "text-feedback-ink-positive-intense"
4995
5008
  : currentValidationState === "negative"
4996
5009
  ? "text-feedback-ink-negative-subtle"
4997
- : "text-surface-ink-neutral-muted", isSelectOpen && "transform rotate-180") })] }), isSelectOpen && !effectiveSelectDisabled && (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-[1000]", position === "prefix" ? "left-[-12px]" : "right-[-12px]", dropdownPlacement === "bottom"
5010
+ : "text-surface-ink-neutral-muted", isSelectOpen && "transform rotate-180") })] }), isSelectOpen && !effectiveSelectDisabled && (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"
4998
5011
  ? "top-[30px] mt-1"
4999
5012
  : "bottom-full mb-1"), children: renderDropdownContent() })))] }));
5000
5013
  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"
@@ -5275,13 +5288,13 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
5275
5288
  large: 48,
5276
5289
  auto: 56,
5277
5290
  }[size] ?? 40;
5278
- return (jsxRuntime.jsx("thead", { className: cn(showHeaderBackground ? "bg-surface-fill-neutral-moderate" : "bg-white", stickyHeader && "sticky top-0 z-[100]"), children: headerGroups.map((headerGroup, groupIndex) => {
5291
+ return (jsxRuntime.jsx("thead", { className: cn(showHeaderBackground ? "bg-surface-fill-neutral-moderate" : "bg-white", stickyHeader && "sticky top-0 z-10"), children: headerGroups.map((headerGroup, groupIndex) => {
5279
5292
  const stickyTop = stickyHeader ? groupIndex * headerHeight : undefined;
5280
- return (jsxRuntime.jsxs("tr", { children: [enableRowSelection && enableSelectAll && (jsxRuntime.jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground && "bg-surface-fill-neutral-moderate", stickyHeader && "sticky z-[101]", "w-10 rounded-tl-xlarge rounded-bl-xlarge", headerClassName), style: { top: stickyTop }, children: jsxRuntime.jsx(Checkbox, { checked: isAllRowsSelected, isIndeterminate: isSomeRowsSelected, onChange: onToggleAllRows, "aria-label": "Select all rows" }) })), headerGroup.headers.map((header, index) => {
5293
+ return (jsxRuntime.jsxs("tr", { children: [enableRowSelection && enableSelectAll && (jsxRuntime.jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground && "bg-surface-fill-neutral-moderate", stickyHeader && "sticky z-20", "w-10 rounded-tl-xlarge rounded-bl-xlarge", headerClassName), style: { top: stickyTop }, children: jsxRuntime.jsx(Checkbox, { checked: isAllRowsSelected, isIndeterminate: isSomeRowsSelected, onChange: onToggleAllRows, "aria-label": "Select all rows" }) })), headerGroup.headers.map((header, index) => {
5281
5294
  const isFirstColumn = index === 0;
5282
5295
  const isLastColumn = index === headerGroup.headers.length - 1;
5283
5296
  return (jsxRuntime.jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground &&
5284
- "bg-surface-fill-neutral-moderate border-none", stickyHeader && "sticky z-[101]", !enableRowSelection && index === 0 && "rounded-tl-xlarge ", isLastColumn && "rounded-tr-xlarge", header.column.columnDef.meta?.headerClassName, headerClassName), style: {
5297
+ "bg-surface-fill-neutral-moderate border-none", stickyHeader && "sticky z-20", !enableRowSelection && index === 0 && "rounded-tl-xlarge ", isLastColumn && "rounded-tr-xlarge", header.column.columnDef.meta?.headerClassName, headerClassName), style: {
5285
5298
  ...getColumnStyle(header.column.id, {
5286
5299
  width: header.getSize(),
5287
5300
  minWidth: header.column.columnDef.minSize,