@particle-academy/react-fancy 4.4.0 → 4.4.2

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
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, HTMLAttributes, ComponentType, CSSProperties, ReactElement, RefObject } from 'react';
2
+ import { ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, TdHTMLAttributes, HTMLAttributes, ComponentType, CSSProperties, ReactElement, RefObject } from 'react';
3
3
  import { ClassValue } from 'clsx';
4
4
 
5
5
  type Size = "xs" | "sm" | "md" | "lg" | "xl";
@@ -626,9 +626,13 @@ interface TableRowTrayProps {
626
626
  children: ReactNode;
627
627
  className?: string;
628
628
  }
629
- interface TableCellProps {
630
- children: ReactNode;
631
- className?: string;
629
+ /**
630
+ * Extends the native cell attributes so `colSpan`/`rowSpan` (full-span
631
+ * empty-state rows, trays) plus `onClick`, `style`, `scope`, `data-*`, etc. are
632
+ * forwarded onto the underlying `<td>`/`<th>` instead of silently dropped.
633
+ */
634
+ interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {
635
+ /** Render a `<th>` header cell instead of a `<td>`. */
632
636
  header?: boolean;
633
637
  }
634
638
  interface TableColumnProps {
@@ -656,7 +660,7 @@ declare function TableBody({ children, className }: TableBodyProps): react.JSX.E
656
660
 
657
661
  declare function TableRow({ children, className, onClick, tray, trayTriggerPosition, expanded: controlledExpanded, defaultExpanded, onExpandedChange, }: TableRowProps): react.JSX.Element;
658
662
 
659
- declare function TableCell({ children, className, header }: TableCellProps): react.JSX.Element;
663
+ declare function TableCell({ children, className, header, ...rest }: TableCellProps): react.JSX.Element;
660
664
 
661
665
  declare function TableColumn({ label, sortKey, className }: TableColumnProps): react.JSX.Element;
662
666
 
@@ -1292,7 +1296,7 @@ interface ModalContextValue {
1292
1296
  open: boolean;
1293
1297
  close: () => void;
1294
1298
  }
1295
- interface ModalProps {
1299
+ interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
1296
1300
  children: ReactNode;
1297
1301
  open: boolean;
1298
1302
  onClose: () => void;
@@ -1327,7 +1331,7 @@ declare namespace ModalFooter {
1327
1331
  var displayName: string;
1328
1332
  }
1329
1333
 
1330
- declare function ModalRoot({ children, open, onClose, size, className, }: ModalProps): react.JSX.Element | null;
1334
+ declare function ModalRoot({ children, open, onClose, size, className, ...rest }: ModalProps): react.JSX.Element | null;
1331
1335
  declare const Modal: typeof ModalRoot & {
1332
1336
  Header: typeof ModalHeader;
1333
1337
  Body: typeof ModalBody;
@@ -1455,7 +1459,7 @@ interface TabsListProps {
1455
1459
  children: ReactNode;
1456
1460
  className?: string;
1457
1461
  }
1458
- interface TabsTabProps {
1462
+ interface TabsTabProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value"> {
1459
1463
  children: ReactNode;
1460
1464
  value: string;
1461
1465
  disabled?: boolean;
@@ -1476,7 +1480,7 @@ declare namespace TabsList {
1476
1480
  var displayName: string;
1477
1481
  }
1478
1482
 
1479
- declare function TabsTab({ children, value, disabled, className, }: TabsTabProps): react.JSX.Element;
1483
+ declare function TabsTab({ children, value, disabled, className, onClick, ...rest }: TabsTabProps): react.JSX.Element;
1480
1484
  declare namespace TabsTab {
1481
1485
  var displayName: string;
1482
1486
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, HTMLAttributes, ComponentType, CSSProperties, ReactElement, RefObject } from 'react';
2
+ import { ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, TdHTMLAttributes, HTMLAttributes, ComponentType, CSSProperties, ReactElement, RefObject } from 'react';
3
3
  import { ClassValue } from 'clsx';
4
4
 
5
5
  type Size = "xs" | "sm" | "md" | "lg" | "xl";
@@ -626,9 +626,13 @@ interface TableRowTrayProps {
626
626
  children: ReactNode;
627
627
  className?: string;
628
628
  }
629
- interface TableCellProps {
630
- children: ReactNode;
631
- className?: string;
629
+ /**
630
+ * Extends the native cell attributes so `colSpan`/`rowSpan` (full-span
631
+ * empty-state rows, trays) plus `onClick`, `style`, `scope`, `data-*`, etc. are
632
+ * forwarded onto the underlying `<td>`/`<th>` instead of silently dropped.
633
+ */
634
+ interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {
635
+ /** Render a `<th>` header cell instead of a `<td>`. */
632
636
  header?: boolean;
633
637
  }
634
638
  interface TableColumnProps {
@@ -656,7 +660,7 @@ declare function TableBody({ children, className }: TableBodyProps): react.JSX.E
656
660
 
657
661
  declare function TableRow({ children, className, onClick, tray, trayTriggerPosition, expanded: controlledExpanded, defaultExpanded, onExpandedChange, }: TableRowProps): react.JSX.Element;
658
662
 
659
- declare function TableCell({ children, className, header }: TableCellProps): react.JSX.Element;
663
+ declare function TableCell({ children, className, header, ...rest }: TableCellProps): react.JSX.Element;
660
664
 
661
665
  declare function TableColumn({ label, sortKey, className }: TableColumnProps): react.JSX.Element;
662
666
 
@@ -1292,7 +1296,7 @@ interface ModalContextValue {
1292
1296
  open: boolean;
1293
1297
  close: () => void;
1294
1298
  }
1295
- interface ModalProps {
1299
+ interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
1296
1300
  children: ReactNode;
1297
1301
  open: boolean;
1298
1302
  onClose: () => void;
@@ -1327,7 +1331,7 @@ declare namespace ModalFooter {
1327
1331
  var displayName: string;
1328
1332
  }
1329
1333
 
1330
- declare function ModalRoot({ children, open, onClose, size, className, }: ModalProps): react.JSX.Element | null;
1334
+ declare function ModalRoot({ children, open, onClose, size, className, ...rest }: ModalProps): react.JSX.Element | null;
1331
1335
  declare const Modal: typeof ModalRoot & {
1332
1336
  Header: typeof ModalHeader;
1333
1337
  Body: typeof ModalBody;
@@ -1455,7 +1459,7 @@ interface TabsListProps {
1455
1459
  children: ReactNode;
1456
1460
  className?: string;
1457
1461
  }
1458
- interface TabsTabProps {
1462
+ interface TabsTabProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value"> {
1459
1463
  children: ReactNode;
1460
1464
  value: string;
1461
1465
  disabled?: boolean;
@@ -1476,7 +1480,7 @@ declare namespace TabsList {
1476
1480
  var displayName: string;
1477
1481
  }
1478
1482
 
1479
- declare function TabsTab({ children, value, disabled, className, }: TabsTabProps): react.JSX.Element;
1483
+ declare function TabsTab({ children, value, disabled, className, onClick, ...rest }: TabsTabProps): react.JSX.Element;
1480
1484
  declare namespace TabsTab {
1481
1485
  var displayName: string;
1482
1486
  }
package/dist/index.js CHANGED
@@ -2518,9 +2518,14 @@ var Button = forwardRef(
2518
2518
  {
2519
2519
  "data-react-fancy-button-label": "",
2520
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",
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",
2524
2529
  // `responsive` collapses to icon-only when squeezed, while keeping
2525
2530
  // the label readable to screen readers.
2526
2531
  responsive && "sr-only sm:not-sr-only",
@@ -5498,7 +5503,7 @@ function TableRow({
5498
5503
  hasTray && expanded && /* @__PURE__ */ jsx("tr", { className: "bg-zinc-50/50 dark:bg-zinc-800/30", children: /* @__PURE__ */ jsx("td", { colSpan: 999, children: tray }) })
5499
5504
  ] });
5500
5505
  }
5501
- function TableCell({ children, className, header }) {
5506
+ function TableCell({ children, className, header, ...rest }) {
5502
5507
  const Tag = header ? "th" : "td";
5503
5508
  return /* @__PURE__ */ jsx(
5504
5509
  Tag,
@@ -5509,6 +5514,7 @@ function TableCell({ children, className, header }) {
5509
5514
  header && "text-left font-medium text-zinc-500 dark:text-zinc-400",
5510
5515
  className
5511
5516
  ),
5517
+ ...rest,
5512
5518
  children
5513
5519
  }
5514
5520
  );
@@ -7904,7 +7910,8 @@ function ModalRoot({
7904
7910
  open,
7905
7911
  onClose,
7906
7912
  size = "md",
7907
- className
7913
+ className,
7914
+ ...rest
7908
7915
  }) {
7909
7916
  const panelRef = useRef(null);
7910
7917
  const close = useCallback(() => onClose(), [onClose]);
@@ -7945,6 +7952,7 @@ function ModalRoot({
7945
7952
  "data-react-fancy-modal": "",
7946
7953
  role: "dialog",
7947
7954
  "aria-modal": "true",
7955
+ ...rest,
7948
7956
  className: cn(
7949
7957
  "relative flex w-full flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900",
7950
7958
  SIZE_MAP[size],
@@ -8312,7 +8320,9 @@ function TabsTab({
8312
8320
  children,
8313
8321
  value,
8314
8322
  disabled = false,
8315
- className
8323
+ className,
8324
+ onClick,
8325
+ ...rest
8316
8326
  }) {
8317
8327
  const { activeTab, setActiveTab, variant } = useTabs();
8318
8328
  const isActive = activeTab === value;
@@ -8325,7 +8335,11 @@ function TabsTab({
8325
8335
  disabled,
8326
8336
  "aria-selected": isActive,
8327
8337
  tabIndex: isActive ? 0 : -1,
8328
- onClick: () => !disabled && setActiveTab(value),
8338
+ onClick: (e) => {
8339
+ if (!disabled) setActiveTab(value);
8340
+ onClick?.(e);
8341
+ },
8342
+ ...rest,
8329
8343
  className: cn(
8330
8344
  "text-sm font-medium transition-colors",
8331
8345
  disabled && "cursor-not-allowed opacity-50",
@@ -12893,13 +12907,14 @@ function PromptInput({
12893
12907
  {
12894
12908
  variant: "ghost",
12895
12909
  size: "sm",
12910
+ className: "shrink-0",
12896
12911
  onClick: () => {
12897
12912
  },
12898
12913
  children: "\u{1F4CE} attach"
12899
12914
  }
12900
12915
  ) }),
12901
- /* @__PURE__ */ jsxs("div", { className: "ml-2 flex items-center gap-1.5", children: [
12902
- /* @__PURE__ */ jsx("div", { className: "h-1.5 w-24 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700", children: /* @__PURE__ */ jsx(
12916
+ /* @__PURE__ */ jsxs("div", { className: "ml-2 flex min-w-0 items-center gap-1.5 overflow-hidden", children: [
12917
+ /* @__PURE__ */ jsx("div", { className: "h-1.5 w-24 shrink overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700", children: /* @__PURE__ */ jsx(
12903
12918
  "div",
12904
12919
  {
12905
12920
  className: "h-full rounded-full transition-all",
@@ -12912,7 +12927,7 @@ function PromptInput({
12912
12927
  fmtTokens(budgetTokens)
12913
12928
  ] })
12914
12929
  ] }),
12915
- /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
12930
+ /* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
12916
12931
  showHint && /* @__PURE__ */ jsxs("span", { className: "hidden text-[10px] text-zinc-500 sm:inline", children: [
12917
12932
  /* @__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" }),
12918
12933
  " ",
@@ -12922,7 +12937,7 @@ function PromptInput({
12922
12937
  " ",
12923
12938
  "to send"
12924
12939
  ] }),
12925
- /* @__PURE__ */ jsx(Button, { color: "violet", size: "sm", onClick: submit, children: "send \u2192" })
12940
+ /* @__PURE__ */ jsx(Button, { color: "violet", size: "sm", className: "shrink-0", onClick: submit, children: "send \u2192" })
12926
12941
  ] })
12927
12942
  ] })
12928
12943
  ]