infinity-ui-elements 1.6.15 → 1.7.0

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
@@ -2543,6 +2543,64 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
2543
2543
  });
2544
2544
  SearchableDropdown.displayName = "SearchableDropdown";
2545
2545
 
2546
+ const variantDefaults = {
2547
+ rect: { height: 16, className: "w-full rounded-large" },
2548
+ text: { height: 12, className: "w-full rounded-large" },
2549
+ title: { height: 20, className: "w-full rounded-large" },
2550
+ circle: { height: 40, className: "rounded-full aspect-square" },
2551
+ };
2552
+ const roundedClassNames = {
2553
+ none: "rounded-none",
2554
+ small: "rounded-small",
2555
+ medium: "rounded-medium",
2556
+ large: "rounded-large",
2557
+ full: "rounded-full",
2558
+ };
2559
+ const animationClassNames = {
2560
+ pulse: "animate-skeleton",
2561
+ none: undefined,
2562
+ };
2563
+ const normalizeCssValue = (value) => {
2564
+ if (value === undefined || value === null) {
2565
+ return undefined;
2566
+ }
2567
+ return typeof value === "number" ? `${value}px` : value;
2568
+ };
2569
+ const getLineWidths = (count, provided) => {
2570
+ if (provided && provided.length) {
2571
+ return Array.from({ length: count }, (_, index) => normalizeCssValue(provided[index] ?? provided[provided.length - 1]));
2572
+ }
2573
+ if (count === 1) {
2574
+ return ["100%"];
2575
+ }
2576
+ return Array.from({ length: count }, (_, index) => index === count - 1 ? "60%" : "100%");
2577
+ };
2578
+ const Skeleton = React__namespace.forwardRef(({ className, containerClassName, containerStyle, variant = "rect", animation = "pulse", lines = 1, lineWidths, lineGap = "0.5rem", width, height, rounded = "large", style, ...props }, ref) => {
2579
+ const resolvedLines = Math.max(1, lines);
2580
+ const baseVariant = variantDefaults[variant];
2581
+ const resolvedHeight = normalizeCssValue(height) ?? normalizeCssValue(baseVariant.height);
2582
+ const resolvedWidth = normalizeCssValue(width) ??
2583
+ (variant === "circle" ? resolvedHeight : undefined);
2584
+ const skeletonClasses = cn("block bg-surface-fill-neutral-subtle", animationClassNames[animation], variant !== "circle" && roundedClassNames[rounded], baseVariant.className, className);
2585
+ if ((variant === "text" || variant === "title") && resolvedLines > 1) {
2586
+ const widths = getLineWidths(resolvedLines, lineWidths);
2587
+ return (jsxRuntime.jsx("div", { ref: ref, className: cn("flex w-full flex-col", containerClassName, animation === "pulse" ? "animate-none" : undefined), style: {
2588
+ gap: normalizeCssValue(lineGap) ?? "0.5rem",
2589
+ ...containerStyle,
2590
+ }, "aria-live": "polite", "aria-busy": "true", ...props, children: widths.map((lineWidth, index) => (jsxRuntime.jsx("span", { className: skeletonClasses, style: {
2591
+ height: resolvedHeight,
2592
+ width: lineWidth ?? resolvedWidth ?? "100%",
2593
+ ...style,
2594
+ }, "aria-hidden": "true" }, `skeleton-line-${index}`))) }));
2595
+ }
2596
+ return (jsxRuntime.jsx("div", { ref: ref, className: skeletonClasses, style: {
2597
+ height: resolvedHeight,
2598
+ width: resolvedWidth ?? style?.width,
2599
+ ...style,
2600
+ }, "aria-live": "polite", "aria-busy": "true", ...props }));
2601
+ });
2602
+ Skeleton.displayName = "Skeleton";
2603
+
2546
2604
  const switchVariants = classVarianceAuthority.cva("relative inline-flex items-center shrink-0 cursor-pointer rounded-full transition-all duration-200", {
2547
2605
  variants: {
2548
2606
  size: {
@@ -3158,6 +3216,7 @@ exports.Pagination = Pagination;
3158
3216
  exports.Radio = Radio;
3159
3217
  exports.SearchableDropdown = SearchableDropdown;
3160
3218
  exports.Select = Select;
3219
+ exports.Skeleton = Skeleton;
3161
3220
  exports.SlotCell = SlotCell;
3162
3221
  exports.SpacerCell = SpacerCell;
3163
3222
  exports.Switch = Switch;