@particle-academy/react-fancy 4.2.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 +22 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/styles.css +43 -22
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -59,6 +59,16 @@ interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "col
|
|
|
59
59
|
disabled?: boolean;
|
|
60
60
|
/** Render as anchor tag */
|
|
61
61
|
href?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Collapse to icon-only when squeezed — injects the minimal Tailwind classes
|
|
64
|
+
* (`sr-only sm:not-sr-only`) onto the label so it stays screen-reader
|
|
65
|
+
* accessible but visually hidden on small screens. The label is also directly
|
|
66
|
+
* targetable via `data-react-fancy-button-label` for a custom breakpoint, e.g.
|
|
67
|
+
* `className="[&_[data-react-fancy-button-label]]:hidden md:[&_[data-react-fancy-button-label]]:inline"`.
|
|
68
|
+
*/
|
|
69
|
+
responsive?: boolean;
|
|
70
|
+
/** Extra classes for the label wrapper — alignment, responsive hiding, etc. */
|
|
71
|
+
labelClassName?: string;
|
|
62
72
|
}
|
|
63
73
|
/**
|
|
64
74
|
* @deprecated Renamed to {@link ButtonProps}. `ActionProps` remains as an alias
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,16 @@ interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "col
|
|
|
59
59
|
disabled?: boolean;
|
|
60
60
|
/** Render as anchor tag */
|
|
61
61
|
href?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Collapse to icon-only when squeezed — injects the minimal Tailwind classes
|
|
64
|
+
* (`sr-only sm:not-sr-only`) onto the label so it stays screen-reader
|
|
65
|
+
* accessible but visually hidden on small screens. The label is also directly
|
|
66
|
+
* targetable via `data-react-fancy-button-label` for a custom breakpoint, e.g.
|
|
67
|
+
* `className="[&_[data-react-fancy-button-label]]:hidden md:[&_[data-react-fancy-button-label]]:inline"`.
|
|
68
|
+
*/
|
|
69
|
+
responsive?: boolean;
|
|
70
|
+
/** Extra classes for the label wrapper — alignment, responsive hiding, etc. */
|
|
71
|
+
labelClassName?: string;
|
|
62
72
|
}
|
|
63
73
|
/**
|
|
64
74
|
* @deprecated Renamed to {@link ButtonProps}. `ActionProps` remains as an alias
|
package/dist/index.js
CHANGED
|
@@ -2375,6 +2375,8 @@ var Button = forwardRef(
|
|
|
2375
2375
|
loading = false,
|
|
2376
2376
|
disabled,
|
|
2377
2377
|
href,
|
|
2378
|
+
responsive,
|
|
2379
|
+
labelClassName,
|
|
2378
2380
|
...props
|
|
2379
2381
|
}, ref) => {
|
|
2380
2382
|
const isCircle = variant === "circle";
|
|
@@ -2486,7 +2488,10 @@ var Button = forwardRef(
|
|
|
2486
2488
|
const trailingAlert = renderAlertIcon(true);
|
|
2487
2489
|
if (trailingAlert) trailingElements.push(trailingAlert);
|
|
2488
2490
|
const classes = cn(
|
|
2489
|
-
|
|
2491
|
+
// `text-left` overrides the UA <button> center default so a wrapped,
|
|
2492
|
+
// width-constrained multi-word label stacks left-aligned. Overridable —
|
|
2493
|
+
// twMerge lets a `text-center` / `text-right` in `className` win.
|
|
2494
|
+
"inline-flex items-center justify-center text-left font-medium transition-all duration-200",
|
|
2490
2495
|
"focus:outline-none focus:ring-2 focus:ring-offset-1",
|
|
2491
2496
|
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
2492
2497
|
isCircle ? "rounded-full" : "rounded-lg",
|
|
@@ -2508,7 +2513,22 @@ var Button = forwardRef(
|
|
|
2508
2513
|
}
|
|
2509
2514
|
) : icon ? /* @__PURE__ */ jsx(Icon, { name: icon, size: iconSizeMap[size] }) : children }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2510
2515
|
leadingElements,
|
|
2511
|
-
children != null && /* @__PURE__ */ jsx(
|
|
2516
|
+
children != null && /* @__PURE__ */ jsx(
|
|
2517
|
+
"span",
|
|
2518
|
+
{
|
|
2519
|
+
"data-react-fancy-button-label": "",
|
|
2520
|
+
className: cn(
|
|
2521
|
+
// min-w-0 lets the label shrink + wrap inside the flex row instead
|
|
2522
|
+
// of overflowing and shoving the icon out of place.
|
|
2523
|
+
"min-w-0",
|
|
2524
|
+
// `responsive` collapses to icon-only when squeezed, while keeping
|
|
2525
|
+
// the label readable to screen readers.
|
|
2526
|
+
responsive && "sr-only sm:not-sr-only",
|
|
2527
|
+
labelClassName
|
|
2528
|
+
),
|
|
2529
|
+
children
|
|
2530
|
+
}
|
|
2531
|
+
),
|
|
2512
2532
|
trailingElements
|
|
2513
2533
|
] });
|
|
2514
2534
|
const safeHref = sanitizeHref(href);
|