@particle-academy/react-fancy 4.3.0 → 4.4.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.cjs CHANGED
@@ -2396,6 +2396,8 @@ var Button = react.forwardRef(
2396
2396
  loading = false,
2397
2397
  disabled,
2398
2398
  href,
2399
+ responsive,
2400
+ labelClassName,
2399
2401
  ...props
2400
2402
  }, ref) => {
2401
2403
  const isCircle = variant === "circle";
@@ -2507,7 +2509,10 @@ var Button = react.forwardRef(
2507
2509
  const trailingAlert = renderAlertIcon(true);
2508
2510
  if (trailingAlert) trailingElements.push(trailingAlert);
2509
2511
  const classes = cn(
2510
- "inline-flex items-center justify-center font-medium transition-all duration-200",
2512
+ // `text-left` overrides the UA <button> center default so a wrapped,
2513
+ // width-constrained multi-word label stacks left-aligned. Overridable —
2514
+ // twMerge lets a `text-center` / `text-right` in `className` win.
2515
+ "inline-flex items-center justify-center text-left font-medium transition-all duration-200",
2511
2516
  "focus:outline-none focus:ring-2 focus:ring-offset-1",
2512
2517
  "disabled:opacity-50 disabled:cursor-not-allowed",
2513
2518
  isCircle ? "rounded-full" : "rounded-lg",
@@ -2529,7 +2534,22 @@ var Button = react.forwardRef(
2529
2534
  }
2530
2535
  ) : icon ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: icon, size: iconSizeMap[size] }) : children }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2531
2536
  leadingElements,
2532
- children != null && /* @__PURE__ */ jsxRuntime.jsx("span", { children }),
2537
+ children != null && /* @__PURE__ */ jsxRuntime.jsx(
2538
+ "span",
2539
+ {
2540
+ "data-react-fancy-button-label": "",
2541
+ className: cn(
2542
+ // min-w-0 lets the label shrink + wrap inside the flex row instead
2543
+ // of overflowing and shoving the icon out of place.
2544
+ "min-w-0",
2545
+ // `responsive` collapses to icon-only when squeezed, while keeping
2546
+ // the label readable to screen readers.
2547
+ responsive && "sr-only sm:not-sr-only",
2548
+ labelClassName
2549
+ ),
2550
+ children
2551
+ }
2552
+ ),
2533
2553
  trailingElements
2534
2554
  ] });
2535
2555
  const safeHref = sanitizeHref(href);