@particle-academy/react-fancy 4.3.0 → 4.4.1

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.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
- "inline-flex items-center justify-center font-medium transition-all duration-200",
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,27 @@ 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("span", { children }),
2516
+ children != null && /* @__PURE__ */ jsx(
2517
+ "span",
2518
+ {
2519
+ "data-react-fancy-button-label": "",
2520
+ className: cn(
2521
+ // A button label must stay on one line. When a host flex layout
2522
+ // squeezes the button, `whitespace-nowrap` keeps the label and any
2523
+ // trailing icon/arrow together instead of wrapping and stacking the
2524
+ // icon below it (the classic "send" over "→" break). `min-w-0` keeps
2525
+ // the span shrinkable so `truncate`/ellipsis still works; multi-line
2526
+ // wrapping is opt-in via `labelClassName` ("whitespace-normal") or
2527
+ // the `responsive` prop.
2528
+ "min-w-0 whitespace-nowrap",
2529
+ // `responsive` collapses to icon-only when squeezed, while keeping
2530
+ // the label readable to screen readers.
2531
+ responsive && "sr-only sm:not-sr-only",
2532
+ labelClassName
2533
+ ),
2534
+ children
2535
+ }
2536
+ ),
2512
2537
  trailingElements
2513
2538
  ] });
2514
2539
  const safeHref = sanitizeHref(href);
@@ -12873,13 +12898,14 @@ function PromptInput({
12873
12898
  {
12874
12899
  variant: "ghost",
12875
12900
  size: "sm",
12901
+ className: "shrink-0",
12876
12902
  onClick: () => {
12877
12903
  },
12878
12904
  children: "\u{1F4CE} attach"
12879
12905
  }
12880
12906
  ) }),
12881
- /* @__PURE__ */ jsxs("div", { className: "ml-2 flex items-center gap-1.5", children: [
12882
- /* @__PURE__ */ jsx("div", { className: "h-1.5 w-24 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700", children: /* @__PURE__ */ jsx(
12907
+ /* @__PURE__ */ jsxs("div", { className: "ml-2 flex min-w-0 items-center gap-1.5 overflow-hidden", children: [
12908
+ /* @__PURE__ */ jsx("div", { className: "h-1.5 w-24 shrink overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700", children: /* @__PURE__ */ jsx(
12883
12909
  "div",
12884
12910
  {
12885
12911
  className: "h-full rounded-full transition-all",
@@ -12892,7 +12918,7 @@ function PromptInput({
12892
12918
  fmtTokens(budgetTokens)
12893
12919
  ] })
12894
12920
  ] }),
12895
- /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
12921
+ /* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
12896
12922
  showHint && /* @__PURE__ */ jsxs("span", { className: "hidden text-[10px] text-zinc-500 sm:inline", children: [
12897
12923
  /* @__PURE__ */ jsx("kbd", { className: "rounded border border-zinc-300 bg-zinc-50 px-1 py-0.5 font-mono text-[9px] text-zinc-700 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300", children: "\u2318" }),
12898
12924
  " ",
@@ -12902,7 +12928,7 @@ function PromptInput({
12902
12928
  " ",
12903
12929
  "to send"
12904
12930
  ] }),
12905
- /* @__PURE__ */ jsx(Button, { color: "violet", size: "sm", onClick: submit, children: "send \u2192" })
12931
+ /* @__PURE__ */ jsx(Button, { color: "violet", size: "sm", className: "shrink-0", onClick: submit, children: "send \u2192" })
12906
12932
  ] })
12907
12933
  ] })
12908
12934
  ]