@brdgapp/ui 1.11.0 → 1.12.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/CHANGELOG.md CHANGED
@@ -2,9 +2,32 @@
2
2
 
3
3
  Every release of `@brdgapp/ui`. Versions follow the rules in README.md → Versions.
4
4
 
5
+ ## 1.12.0
6
+
7
+ 2026-11-24. PageHeader, and a table toolbar that sits on the page. Nothing changes for apps already on 1.11.
8
+
9
+ - New: PageHeader (`components/page-header`), the top of every page: `back` ("← Back"), the 22px `title`,
10
+ a `subtitle`, and on the right `action` (the main button) plus at most one `secondaryAction`; on phones
11
+ the buttons go under the title. A page can switch on `media` (an Avatar, or an icon in a blue square), a
12
+ `tag` after the title, and `menu`, a ⋮ ActionMenu for the less-used actions. It replaces apps' own page
13
+ headers (AdminPageHeader, PageHeader, UsersPageShell, hand-made titles from 14 to 30px).
14
+ - New: DataTableToolbar's `onPage`, for a toolbar on the page above a grid of cards or a list that isn't in
15
+ a card: no side space and no divider, so its search lines up with the page's heading. A table in a card
16
+ keeps its toolbar inside the card. It replaces app-directories' PageToolbar.
17
+ - Fix: a state setter passed straight to `onChange` on FilterPill, ColumnFilterMenu or Select with
18
+ `multiple` (`onChange={setPicked}`) could fail to type-check. The values' type now comes from `value` and
19
+ `options` only.
20
+ - Fix: a DataTable with `addColumn` no longer logs a "unique key" warning while an app is in development.
21
+ - Fix: a Button with `render` (a link) draws its `icon`; it used to drop it.
22
+ - Fix: NetworkGraph with more than 16 people shows "+N" in the last outer place, instead of leaving the
23
+ rest out without a word. Its positions are rounded, so a server-drawn page no longer logs a hydration
24
+ warning.
25
+ - New: DataTableToolbar, ColumnFilterMenu and ColumnSortButton take `className`, for layout only, like the
26
+ other components.
27
+
5
28
  ## 1.11.0
6
29
 
7
- 2026-11-20. Spinner; DatePicker; search inside Select; picking several values; ticks in ActionMenu; password fields you can show; icons, prefixes and numbers in Input; copy on Button,
30
+ 2026-11-24. Spinner; DatePicker; search inside Select; picking several values; ticks in ActionMenu; password fields you can show; icons, prefixes and numbers in Input; copy on Button,
8
31
  IconButton and CopyField. Nothing changes for apps already on 1.10, except that a password field now has its own show/hide button:
9
32
  delete any the app drew beside it.
10
33
 
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Button as ButtonPrimitive } from "@base-ui/react/button";
4
4
  import { mergeProps } from "@base-ui/react/merge-props";
5
5
  import { useRender } from "@base-ui/react/use-render";
@@ -66,11 +66,13 @@ function Button({ className, variant, size, fullWidth, icon, loading = false, di
66
66
  const classes = cn(buttonVariants({ variant, size, fullWidth }), className);
67
67
  const copier = useCopy();
68
68
  // With `render` (for example a Next `Link`), the element keeps its own semantics: a link stays a
69
- // link. It owns its content, so `icon` and `loading` don't apply.
69
+ // link. It draws the icon like any button (audit 11.5: it used to be dropped). A link doesn't wait or
70
+ // copy, so `loading` and `copy` don't apply.
71
+ const linkBody = icon ? (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "button-icon", className: "inline-flex shrink-0", "aria-hidden": "true", children: icon }), children] })) : (children);
70
72
  const rendered = useRender({
71
73
  render: render,
72
74
  enabled: render !== undefined,
73
- props: mergeProps({ className: classes, "data-slot": "button" }, { ...props, onClick }, { children }),
75
+ props: mergeProps({ className: classes, "data-slot": "button" }, { ...props, onClick }, { children: linkBody }),
74
76
  });
75
77
  if (rendered)
76
78
  return rendered;
@@ -7,12 +7,14 @@ type ColumnFilterBase = ElementProps<HTMLButtonElement> & {
7
7
  label: string;
8
8
  /** Explains the column. Hidden while the menu is open. */
9
9
  tooltip?: string;
10
+ /** Layout only: `ml-auto`. */
11
+ className?: string;
10
12
  };
11
13
  type SingleColumnFilterProps<T extends string> = ColumnFilterBase & {
12
14
  multiple?: false;
13
15
  value: T;
14
16
  options: FilterPillOption<T>[];
15
- onChange: (value: T) => void;
17
+ onChange: (value: NoInfer<T>) => void;
16
18
  };
17
19
  type MultipleColumnFilterProps<T extends string> = ColumnFilterBase & {
18
20
  /** Several values: tick rows, each tick filters at once, Reset clears them. */
@@ -21,12 +23,13 @@ type MultipleColumnFilterProps<T extends string> = ColumnFilterBase & {
21
23
  value: T[];
22
24
  /** The values to pick from. No "All" row. */
23
25
  options: FilterPillOption<T>[];
24
- onChange: (value: T[]) => void;
26
+ onChange: (value: NoInfer<T>[]) => void;
25
27
  /** A search field on top. `true` filters `options`; an object means the app searches. */
26
28
  search?: true | FilterPillSearch;
27
29
  searchPlaceholder?: string;
28
30
  };
29
31
  type ColumnFilterMenuProps<T extends string> = SingleColumnFilterProps<T> | MultipleColumnFilterProps<T>;
30
- declare function ColumnFilterMenu<T extends string>(props: ColumnFilterMenuProps<T>): import("react").JSX.Element;
32
+ declare function ColumnFilterMenu<T extends string>(props: MultipleColumnFilterProps<T>): React.JSX.Element;
33
+ declare function ColumnFilterMenu<T extends string>(props: SingleColumnFilterProps<T>): React.JSX.Element;
31
34
  export { ColumnFilterMenu };
32
35
  export type { ColumnFilterMenuProps, MultipleColumnFilterProps, SingleColumnFilterProps };
@@ -13,13 +13,13 @@ import { cn } from "@brdgapp/ui/lib/utils";
13
13
  function ColumnFilterMenu(props) {
14
14
  return props.multiple ? _jsx(MultipleColumnFilter, { ...props }) : _jsx(SingleColumnFilter, { ...props });
15
15
  }
16
- function MultipleColumnFilter({ multiple, icon: Icon, label, tooltip, value, options, onChange, search, searchPlaceholder, ...rest }) {
16
+ function MultipleColumnFilter({ multiple, icon: Icon, label, tooltip, value, options, onChange, search, searchPlaceholder, className, ...rest }) {
17
17
  const [open, setOpen] = useState(false);
18
18
  const mobile = useIsMobile();
19
19
  const { picked, remember } = usePicked(value, options);
20
20
  const active = value.length > 0;
21
21
  const name = `Filter by ${label.toLowerCase()}${active ? `: ${summarize(picked.map((o) => o.label)).spoken}` : ""}`;
22
- const triggerClass = cn(columnHeaderButton, active ? "text-[var(--primary)]" : "text-[var(--text-secondary)]");
22
+ const triggerClass = cn(columnHeaderButton, active ? "text-[var(--primary)]" : "text-[var(--text-secondary)]", className);
23
23
  const inner = (_jsxs(_Fragment, { children: [Icon ? _jsx(Icon, { "aria-hidden": "true", className: cn("size-3.5", active ? "text-[var(--primary)]" : "text-[var(--text-muted)]") }) : null, label, active ? _jsx("span", { "aria-hidden": "true", className: "size-1.5 rounded-full bg-[var(--primary)]" }) : null, _jsx(ChevronDown, { "aria-hidden": "true", className: cn("size-3.5 text-[var(--text-muted)] transition-transform", open && "rotate-180") })] }));
24
24
  const panel = (phone) => (_jsx(MultiPanel, { value: value, options: options, onChange: onChange, name: label, search: search, searchPlaceholder: searchPlaceholder, picked: picked, remember: remember, phone: phone }));
25
25
  if (mobile) {
@@ -30,13 +30,13 @@ function MultipleColumnFilter({ multiple, icon: Icon, label, tooltip, value, opt
30
30
  }
31
31
  return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Tip, { text: tooltip, disabled: open, children: _jsx(PopoverPrimitive.Trigger, { ...rest, "data-slot": "column-filter-menu", "data-multiple": multiple ? "" : undefined, "aria-label": name, onClick: (e) => e.stopPropagation(), className: triggerClass, children: inner }) }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Positioner, { side: "bottom", align: "start", sideOffset: 6, collisionPadding: 8, className: "z-[95]", children: _jsx(PopoverPrimitive.Popup, { "data-slot": "filter-menu", "aria-label": `Filter by ${label.toLowerCase()}`, className: "w-[260px] max-w-[calc(100vw-16px)] rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] shadow-[var(--shadow-menu)] outline-none transition-opacity duration-200 ease-out data-[ending-style]:duration-150 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0", children: panel(false) }) }) })] }));
32
32
  }
33
- function SingleColumnFilter({ multiple, icon: Icon, label, tooltip, value, options, onChange, ...rest }) {
33
+ function SingleColumnFilter({ multiple, icon: Icon, label, tooltip, value, options, onChange, className, ...rest }) {
34
34
  const [open, setOpen] = useState(false);
35
35
  const mobile = useIsMobile();
36
36
  const active = options.length > 0 && value !== options[0]?.value;
37
37
  const activeLabel = options.find((o) => o.value === value)?.label;
38
38
  const name = `Filter by ${label.toLowerCase()}${active && activeLabel ? `: ${activeLabel}` : ""}`;
39
- const triggerClass = cn(columnHeaderButton, active ? "text-[var(--primary)]" : "text-[var(--text-secondary)]");
39
+ const triggerClass = cn(columnHeaderButton, active ? "text-[var(--primary)]" : "text-[var(--text-secondary)]", className);
40
40
  const inner = (_jsxs(_Fragment, { children: [Icon ? _jsx(Icon, { "aria-hidden": "true", className: cn("size-3.5", active ? "text-[var(--primary)]" : "text-[var(--text-muted)]") }) : null, label, active ? _jsx("span", { "aria-hidden": "true", className: "size-1.5 rounded-full bg-[var(--primary)]" }) : null, _jsx(ChevronDown, { "aria-hidden": "true", className: cn("size-3.5 text-[var(--text-muted)] transition-transform", open && "rotate-180") })] }));
41
41
  // Phones: a bottom sheet instead of a menu. No tooltip: touch has no hover.
42
42
  if (mobile) {
@@ -18,7 +18,9 @@ type ColumnSortButtonProps = ElementProps<HTMLButtonElement> & {
18
18
  desc: string;
19
19
  };
20
20
  onClick: () => void;
21
+ /** Layout only: `ml-auto`. */
22
+ className?: string;
21
23
  };
22
- declare function ColumnSortButton({ icon: Icon, label, tooltip, direction, describe, onClick, ...rest }: ColumnSortButtonProps): import("react").JSX.Element;
24
+ declare function ColumnSortButton({ icon: Icon, label, tooltip, direction, describe, onClick, className, ...rest }: ColumnSortButtonProps): import("react").JSX.Element;
23
25
  export { ColumnSortButton, columnHeaderButton };
24
26
  export type { ColumnSortButtonProps };
@@ -14,11 +14,11 @@ import { cn } from "@brdgapp/ui/lib/utils";
14
14
  * it does (⇅, ⌄); the whole thing tints on hover. 24px tall.
15
15
  */
16
16
  const columnHeaderButton = "-mx-1.5 inline-flex items-center gap-1.5 rounded px-1.5 py-[3px] text-12 leading-normal font-bold whitespace-nowrap outline-none transition-colors hover:bg-[var(--surface-tertiary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]";
17
- function ColumnSortButton({ icon: Icon, label, tooltip, direction, describe, onClick, ...rest }) {
17
+ function ColumnSortButton({ icon: Icon, label, tooltip, direction, describe, onClick, className, ...rest }) {
18
18
  const state = direction && describe ? `, sorted ${describe[direction]}` : "";
19
19
  return (_jsx(Tip, { text: tooltip, children: _jsxs(ButtonPrimitive, { ...rest, "data-slot": "column-sort-button", onClick: (e) => {
20
20
  e.stopPropagation();
21
21
  onClick();
22
- }, "aria-label": `Sort by ${label.toLowerCase()}${state}`, className: cn(columnHeaderButton, direction ? "text-[var(--text-primary)]" : "text-[var(--text-secondary)]"), children: [Icon ? _jsx(Icon, { "aria-hidden": "true", className: "size-3.5 text-[var(--text-muted)]" }) : null, label, direction === "desc" ? (_jsx(ArrowDown, { "aria-hidden": "true", className: "size-3 shrink-0 text-[var(--primary)]" })) : direction === "asc" ? (_jsx(ArrowUp, { "aria-hidden": "true", className: "size-3 shrink-0 text-[var(--primary)]" })) : (_jsx(ArrowUpDown, { "aria-hidden": "true", className: "size-3 shrink-0 opacity-40" }))] }) }));
22
+ }, "aria-label": `Sort by ${label.toLowerCase()}${state}`, className: cn(columnHeaderButton, direction ? "text-[var(--text-primary)]" : "text-[var(--text-secondary)]", className), children: [Icon ? _jsx(Icon, { "aria-hidden": "true", className: "size-3.5 text-[var(--text-muted)]" }) : null, label, direction === "desc" ? (_jsx(ArrowDown, { "aria-hidden": "true", className: "size-3 shrink-0 text-[var(--primary)]" })) : direction === "asc" ? (_jsx(ArrowUp, { "aria-hidden": "true", className: "size-3 shrink-0 text-[var(--primary)]" })) : (_jsx(ArrowUpDown, { "aria-hidden": "true", className: "size-3 shrink-0 opacity-40" }))] }) }));
23
23
  }
24
24
  export { ColumnSortButton, columnHeaderButton };
@@ -74,14 +74,21 @@ declare function DataTable<T>({ columns, rows, rowKey, onRowClick, onRowPrefetch
74
74
  * The row at the top of a table's card for finding and acting on rows: search on the left; filters, then
75
75
  * buttons, on the right. It is not a title: the page's heading names the table. Put it outside DataState,
76
76
  * so it stays while the rows load, fail or filter down to nothing.
77
+ * `onPage` (Aman 2026-11-24): the same row on the page, above a grid of cards or a list that isn't in a card
78
+ * (app-directories' PageToolbar). No side space and no line: the page's own margins line it up with the title.
79
+ * A table in a card keeps its toolbar inside the card.
77
80
  */
78
- declare function DataTableToolbar({ search, filters, actions, ...rest }: ElementProps<HTMLDivElement> & {
81
+ declare function DataTableToolbar({ search, filters, actions, onPage, className, ...rest }: ElementProps<HTMLDivElement> & {
79
82
  /** A SearchInput. It is 288px wide, the whole row on a phone. */
80
83
  search?: React.ReactNode;
81
84
  /** FilterPills, and one "Clear all" link (search and every filter) when any is on. */
82
85
  filters?: React.ReactNode;
83
86
  /** Buttons that act on the table: Export, Add people. Use Button `md`, the search's height. */
84
87
  actions?: React.ReactNode;
88
+ /** On the page, above a grid of cards or a list not in a card: no side space, no line under it. */
89
+ onPage?: boolean;
90
+ /** Layout only: `sticky top-0`. */
91
+ className?: string;
85
92
  }): React.JSX.Element;
86
93
  /**
87
94
  * The loading body for a DataTable. Takes the same column list (without `render`), so its widths and
@@ -1,5 +1,4 @@
1
1
  "use client";
2
- import { createElement as _createElement } from "react";
3
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
3
  import { Button as ButtonPrimitive } from "@base-ui/react/button";
5
4
  import * as React from "react";
@@ -57,7 +56,7 @@ function DataTable({ columns, rows, rowKey, onRowClick, onRowPrefetch, rowProps,
57
56
  const [scrolled, setScrolled] = React.useState(false);
58
57
  return (_jsx("div", { "data-slot": "data-table", "data-scrolled": scrolled ? "" : undefined, className: cn("group/table", pinned ? "overflow-auto overscroll-contain" : "overflow-x-auto"), style: pinned ? { maxHeight } : undefined, onScroll: pinFirstColumn ? (e) => setScrolled(e.currentTarget.scrollLeft > 0) : undefined,
59
58
  // A scroll area must be reachable by keyboard so it can be scrolled with the arrow keys.
60
- tabIndex: scrollArea ? 0 : undefined, "aria-label": scrollArea ? props["aria-label"] : undefined, role: scrollArea ? "region" : undefined, children: _jsxs("div", { role: "table", "aria-label": props["aria-label"], style: { minWidth: minTableWidth(columns, Boolean(addColumn)) }, children: [_jsx(HeaderRow, { columns: columns, template: template, pinned: pinned, pinFirst: pinFirstColumn, addColumn: addColumn, addRow: addRow }), _jsxs("div", { role: "rowgroup", children: [rows.map((row) => (_createElement("div", { ...rowProps?.(row), key: rowKey(row), role: "row", "data-slot": "data-table-row", tabIndex: onRowClick ? 0 : undefined, onClick: onRowClick
59
+ tabIndex: scrollArea ? 0 : undefined, "aria-label": scrollArea ? props["aria-label"] : undefined, role: scrollArea ? "region" : undefined, children: _jsxs("div", { role: "table", "aria-label": props["aria-label"], style: { minWidth: minTableWidth(columns, Boolean(addColumn)) }, children: [_jsx(HeaderRow, { columns: columns, template: template, pinned: pinned, pinFirst: pinFirstColumn, addColumn: addColumn, addRow: addRow }), _jsxs("div", { role: "rowgroup", children: [rows.map((row) => (_jsxs("div", { ...rowProps?.(row), role: "row", "data-slot": "data-table-row", tabIndex: onRowClick ? 0 : undefined, onClick: onRowClick
61
60
  ? (e) => {
62
61
  // A menu opened from the row (ActionMenu) renders outside it, but React still passes
63
62
  // its clicks up to the row. Only clicks inside the row open it.
@@ -74,23 +73,24 @@ function DataTable({ columns, rows, rowKey, onRowClick, onRowPrefetch, rowProps,
74
73
  }
75
74
  : undefined, onMouseEnter: onRowPrefetch ? () => onRowPrefetch(row) : undefined, onFocus: onRowPrefetch ? () => onRowPrefetch(row) : undefined, className: cn("group/row grid border-b border-[var(--border-divider)] transition-colors last:border-0", onRowClick
76
75
  ? "cursor-pointer outline-none hover:bg-[var(--surface-tertiary)] focus-visible:bg-[var(--surface-tertiary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-inset"
77
- : "hover:bg-[var(--surface-secondary)]/40"), style: { gridTemplateColumns: template } },
78
- columns.map((c, i) => (_jsx("div", { role: "cell", className: cn(cellPadding(i, count), "flex min-w-0 items-center py-3.5",
79
- // The pinned cell is solid and repeats the row's hover and focus, which it would otherwise cover.
80
- pinFirstColumn &&
81
- i === 0 &&
82
- cn(PIN_FIRST, "bg-[var(--surface-elevated)] transition-colors", onRowClick
83
- ? "group-hover/row:bg-[var(--surface-tertiary)] group-focus-visible/row:bg-[var(--surface-tertiary)] group-focus-visible/row:shadow-[inset_2px_0_0_var(--primary),inset_0_2px_0_var(--primary),inset_0_-2px_0_var(--primary)]"
84
- : "group-hover/row:bg-[color-mix(in_srgb,var(--surface-secondary)_40%,var(--surface-elevated))]")), children: _jsx("div", { className: "w-full min-w-0", children: c.render(row) }) }, c.key))),
85
- addColumn ? _jsx("div", { role: "cell" }) : null))), addRow ? (_jsx("div", { role: "row", "data-slot": "data-table-add-row", className: "grid", style: { gridTemplateColumns: template }, children: _jsx("div", { role: "cell", "aria-colspan": count, className: "col-span-full", children: _jsx(ButtonPrimitive, { "data-slot": "data-table-add", onClick: addRow.onClick, className: "flex w-full py-3.5 pl-6 text-left text-13 leading-normal font-semibold text-[var(--text-secondary)] outline-none transition-colors hover:bg-[var(--surface-tertiary)] hover:text-[var(--text-primary)] focus-visible:bg-[var(--surface-tertiary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-inset", children: _jsxs("span", { className: "sticky left-6 flex items-center gap-1.5", children: [_jsx(Plus, { "aria-hidden": "true", className: "size-3.5 text-[var(--text-muted)]" }), addRow.action] }) }) }) })) : null] })] }) }));
76
+ : "hover:bg-[var(--surface-secondary)]/40"), style: { gridTemplateColumns: template }, children: [columns.map((c, i) => (_jsx("div", { role: "cell", className: cn(cellPadding(i, count), "flex min-w-0 items-center py-3.5",
77
+ // The pinned cell is solid and repeats the row's hover and focus, which it would otherwise cover.
78
+ pinFirstColumn &&
79
+ i === 0 &&
80
+ cn(PIN_FIRST, "bg-[var(--surface-elevated)] transition-colors", onRowClick
81
+ ? "group-hover/row:bg-[var(--surface-tertiary)] group-focus-visible/row:bg-[var(--surface-tertiary)] group-focus-visible/row:shadow-[inset_2px_0_0_var(--primary),inset_0_2px_0_var(--primary),inset_0_-2px_0_var(--primary)]"
82
+ : "group-hover/row:bg-[color-mix(in_srgb,var(--surface-secondary)_40%,var(--surface-elevated))]")), children: _jsx("div", { className: "w-full min-w-0", children: c.render(row) }) }, c.key))), addColumn ? _jsx("div", { role: "cell" }) : null] }, rowKey(row)))), addRow ? (_jsx("div", { role: "row", "data-slot": "data-table-add-row", className: "grid", style: { gridTemplateColumns: template }, children: _jsx("div", { role: "cell", "aria-colspan": count, className: "col-span-full", children: _jsx(ButtonPrimitive, { "data-slot": "data-table-add", onClick: addRow.onClick, className: "flex w-full py-3.5 pl-6 text-left text-13 leading-normal font-semibold text-[var(--text-secondary)] outline-none transition-colors hover:bg-[var(--surface-tertiary)] hover:text-[var(--text-primary)] focus-visible:bg-[var(--surface-tertiary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-inset", children: _jsxs("span", { className: "sticky left-6 flex items-center gap-1.5", children: [_jsx(Plus, { "aria-hidden": "true", className: "size-3.5 text-[var(--text-muted)]" }), addRow.action] }) }) }) })) : null] })] }) }));
86
83
  }
87
84
  /**
88
85
  * The row at the top of a table's card for finding and acting on rows: search on the left; filters, then
89
86
  * buttons, on the right. It is not a title: the page's heading names the table. Put it outside DataState,
90
87
  * so it stays while the rows load, fail or filter down to nothing.
88
+ * `onPage` (Aman 2026-11-24): the same row on the page, above a grid of cards or a list that isn't in a card
89
+ * (app-directories' PageToolbar). No side space and no line: the page's own margins line it up with the title.
90
+ * A table in a card keeps its toolbar inside the card.
91
91
  */
92
- function DataTableToolbar({ search, filters, actions, ...rest }) {
93
- return (_jsxs("div", { ...rest, "data-slot": "data-table-toolbar", className: "flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-[var(--border-divider)] px-6 py-3", children: [search ? _jsx("div", { className: "w-full md:w-72 [&>*]:w-full", children: search }) : null, filters || actions ? (
92
+ function DataTableToolbar({ search, filters, actions, onPage = false, className, ...rest }) {
93
+ return (_jsxs("div", { ...rest, "data-slot": "data-table-toolbar", "data-on-page": onPage ? "" : undefined, className: cn("flex flex-wrap items-center gap-x-3 gap-y-2", !onPage && "border-b border-[var(--border-divider)] px-6 py-3", className), children: [search ? _jsx("div", { className: "w-full md:w-72 [&>*]:w-full", children: search }) : null, filters || actions ? (
94
94
  // Beside a search, filters and actions sit at the right. Without one, filters start at the left
95
95
  // (a drawer's row of FilterChips) and actions stay at the right.
96
96
  _jsxs("div", { className: cn("flex flex-1 flex-wrap items-center gap-3", search ? "md:justify-end" : ""), children: [filters ? _jsx("div", { className: "flex flex-wrap items-center gap-2", children: filters }) : null, actions ? _jsx("div", { className: cn("flex flex-wrap items-center gap-2", search ? "" : "ml-auto"), children: actions }) : null] })) : null] }));
@@ -79,7 +79,7 @@ type SingleFilterPillProps<T extends string> = ElementProps<HTMLButtonElement> &
79
79
  value: T;
80
80
  /** The first option is the resting "All" state. */
81
81
  options: FilterPillOption<T>[];
82
- onChange: (value: T) => void;
82
+ onChange: (value: NoInfer<T>) => void;
83
83
  /** What is being filtered: "Degree", "Status". Read as "Degree: 1st". */
84
84
  ariaLabel?: string;
85
85
  /**
@@ -96,7 +96,7 @@ type MultipleFilterPillProps<T extends string> = ElementProps<HTMLButtonElement>
96
96
  value: T[];
97
97
  /** The values to pick from. No "All" row: an empty pick is all. */
98
98
  options: FilterPillOption<T>[];
99
- onChange: (value: T[]) => void;
99
+ onChange: (value: NoInfer<T>[]) => void;
100
100
  /** What's filtered: "Location". The resting label, then "Location: London, Berlin +1". */
101
101
  ariaLabel: string;
102
102
  /** A search field on top. `true` filters `options`; an object means the app searches and `options` are its results. */
@@ -106,6 +106,7 @@ type MultipleFilterPillProps<T extends string> = ElementProps<HTMLButtonElement>
106
106
  className?: string;
107
107
  };
108
108
  type FilterPillProps<T extends string> = SingleFilterPillProps<T> | MultipleFilterPillProps<T>;
109
- declare function FilterPill<T extends string>(props: FilterPillProps<T>): React.JSX.Element;
109
+ declare function FilterPill<T extends string>(props: MultipleFilterPillProps<T>): React.JSX.Element;
110
+ declare function FilterPill<T extends string>(props: SingleFilterPillProps<T>): React.JSX.Element;
110
111
  export { FilterPill, FilterMenuPopup, FilterSheet, MultiPanel, SheetReset, summarize, TickBox, usePicked };
111
112
  export type { FilterPillOption, FilterPillProps, FilterPillSearch, MultipleFilterPillProps, SingleFilterPillProps };
@@ -26,7 +26,7 @@ declare const SIZES: {
26
26
  };
27
27
  };
28
28
  type NetworkGraphProps = {
29
- /** The people around the middle. The first 6 sit close; up to 10 more sit further out. */
29
+ /** The people around the middle. The first 6 sit close; up to 10 more sit further out. Past 16, the last outer place says "+N" for the people not drawn. */
30
30
  people: Person[];
31
31
  /** Who is in the middle. Leave it off for "You". */
32
32
  center?: Person;
@@ -6,19 +6,27 @@ const SIZES = {
6
6
  md: { width: "w-[280px]", center: "xl", inner: "lg", outer: "md", you: "size-12 text-13" },
7
7
  lg: { width: "w-[360px]", center: "2xl", inner: "xl", outer: "lg", you: "size-16 text-16" },
8
8
  };
9
+ // The "+N" bubble is the size of an outer face.
10
+ const MORE = { sm: "size-6 text-[10px]", md: "size-8 text-12", lg: "size-10 text-14" };
9
11
  const INNER = 6;
10
12
  const OUTER = 10;
11
13
  function place(i, count, radius, offset) {
12
14
  const a = offset + (i / count) * Math.PI * 2 - Math.PI / 2;
13
- return { x: 50 + radius * Math.cos(a), y: 50 + radius * Math.sin(a) };
15
+ // Rounded, so the server and the browser draw the same numbers (their last digits can differ).
16
+ const r = (v) => Math.round(v * 1000) / 1000;
17
+ return { x: r(50 + radius * Math.cos(a)), y: r(50 + radius * Math.sin(a)) };
14
18
  }
15
19
  /** A network: you (or someone) in the middle, people around, a line to each. */
16
20
  function NetworkGraph({ people, center, highlight = [], size = "md", animate = true, label, className }) {
17
21
  const s = SIZES[size];
18
22
  const inner = people.slice(0, INNER);
19
- const outer = people.slice(INNER, INNER + OUTER);
23
+ // More than fit: the last outer place counts the rest, so nobody is left out without a word (audit 11.5).
24
+ const over = people.length > INNER + OUTER;
25
+ const outer = people.slice(INNER, INNER + OUTER - (over ? 1 : 0));
26
+ const more = over ? people.length - INNER - outer.length : 0;
27
+ const outerCount = outer.length + (more ? 1 : 0);
20
28
  const innerAt = inner.map((_, i) => place(i, inner.length, 30, 0));
21
- const outerAt = outer.map((_, i) => place(i, outer.length, 45, Math.PI / outer.length));
29
+ const outerAt = Array.from({ length: outerCount }, (_, i) => place(i, outerCount, 45, Math.PI / outerCount));
22
30
  const lit = new Set(highlight);
23
31
  // Outer people hang off the nearest close-in person, so the picture reads as friends of friends.
24
32
  const nearest = (p) => innerAt.reduce((best, q, i) => (Math.hypot(q.x - p.x, q.y - p.y) < Math.hypot(innerAt[best].x - p.x, innerAt[best].y - p.y) ? i : best), 0);
@@ -27,11 +35,11 @@ function NetworkGraph({ people, center, highlight = [], size = "md", animate = t
27
35
  const fade = animate ? "motion-safe:animate-fade-in [animation-fill-mode:both]" : "";
28
36
  const lines = [
29
37
  ...innerAt.map((p, i) => ({ from: { x: 50, y: 50 }, to: p, on: lit.has(inner[i].name), n: i })),
30
- ...(innerAt.length ? outerAt.map((p, i) => ({ from: innerAt[nearest(p)], to: p, on: lit.has(outer[i].name), n: inner.length + i })) : []),
38
+ ...(innerAt.length ? outerAt.map((p, i) => ({ from: innerAt[nearest(p)], to: p, on: i < outer.length && lit.has(outer[i].name), n: inner.length + i })) : []),
31
39
  ];
32
40
  return (_jsxs("div", { "data-slot": "network-graph", role: label ? "img" : undefined, "aria-label": label, "aria-hidden": label ? undefined : true,
33
41
  // A set width (not w-full), so it keeps its size inside a parent that shrinks to fit; max-w-full lets it
34
42
  // shrink on a narrow screen.
35
- className: cn("relative aspect-square max-w-full shrink-0", s.width, className), children: [_jsx("svg", { viewBox: "0 0 100 100", className: "absolute inset-0 size-full", "aria-hidden": "true", children: lines.map((l, i) => (_jsx("line", { x1: l.from.x, y1: l.from.y, x2: l.to.x, y2: l.to.y, vectorEffect: "non-scaling-stroke", strokeWidth: l.on ? 1.5 : 1, strokeDasharray: l.on ? undefined : "3 3", className: cn(l.on ? "stroke-[var(--primary)]" : "stroke-[var(--text-disabled)]", fade), style: step(l.n) }, i))) }), _jsxs("div", { "aria-hidden": "true", className: "contents", children: [[...inner.map((p, i) => ({ p, at: innerAt[i], ring: "inner", n: i })), ...outer.map((p, i) => ({ p, at: outerAt[i], ring: "outer", n: inner.length + i }))].map(({ p, at, ring, n }) => (_jsx("span", { className: cn("absolute -translate-x-1/2 -translate-y-1/2", enter), style: { left: `${at.x}%`, top: `${at.y}%`, ...step(n + 1) }, children: _jsx(Avatar, { name: p.name, src: p.src, size: ring === "inner" ? s.inner : s.outer, className: cn(lit.has(p.name) && "outline-2 outline-offset-2 outline-[var(--primary)] outline-solid") }) }, `${p.name}-${n}`))), _jsx("span", { className: cn("absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2", enter), children: center ? (_jsx(Avatar, { name: center.name, src: center.src, size: s.center })) : (_jsx("span", { className: cn("flex items-center justify-center rounded-full bg-[var(--primary-solid)] font-bold text-white", s.you), children: "You" })) })] })] }));
43
+ className: cn("relative aspect-square max-w-full shrink-0", s.width, className), children: [_jsx("svg", { viewBox: "0 0 100 100", className: "absolute inset-0 size-full", "aria-hidden": "true", children: lines.map((l, i) => (_jsx("line", { x1: l.from.x, y1: l.from.y, x2: l.to.x, y2: l.to.y, vectorEffect: "non-scaling-stroke", strokeWidth: l.on ? 1.5 : 1, strokeDasharray: l.on ? undefined : "3 3", className: cn(l.on ? "stroke-[var(--primary)]" : "stroke-[var(--text-disabled)]", fade), style: step(l.n) }, i))) }), _jsxs("div", { "aria-hidden": "true", className: "contents", children: [[...inner.map((p, i) => ({ p, at: innerAt[i], ring: "inner", n: i })), ...outer.map((p, i) => ({ p, at: outerAt[i], ring: "outer", n: inner.length + i }))].map(({ p, at, ring, n }) => (_jsx("span", { className: cn("absolute -translate-x-1/2 -translate-y-1/2", enter), style: { left: `${at.x}%`, top: `${at.y}%`, ...step(n + 1) }, children: _jsx(Avatar, { name: p.name, src: p.src, size: ring === "inner" ? s.inner : s.outer, className: cn(lit.has(p.name) && "outline-2 outline-offset-2 outline-[var(--primary)] outline-solid") }) }, `${p.name}-${n}`))), more ? (_jsxs("span", { "data-slot": "network-graph-more", className: cn("absolute flex -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-[var(--border-default)] bg-[var(--surface-secondary)] font-semibold tabular-nums text-[var(--text-secondary)]", MORE[s.outer], enter), style: { left: `${outerAt[outer.length].x}%`, top: `${outerAt[outer.length].y}%`, ...step(inner.length + outer.length + 1) }, children: ["+", more] })) : null, _jsx("span", { className: cn("absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2", enter), children: center ? (_jsx(Avatar, { name: center.name, src: center.src, size: s.center })) : (_jsx("span", { className: cn("flex items-center justify-center rounded-full bg-[var(--primary-solid)] font-bold text-white", s.you), children: "You" })) })] })] }));
36
44
  }
37
45
  export { NetworkGraph };
@@ -0,0 +1,35 @@
1
+ import type * as React from "react";
2
+ type PageHeaderBack = {
3
+ /** The words after the arrow. "Back" unless the place is worth naming: "Back to lists". */
4
+ label?: string;
5
+ /** Where it goes. Without `href` or `onClick`, it goes back in the browser's history. */
6
+ href?: string;
7
+ onClick?: () => void;
8
+ /** Your router's link, e.g. `render={<Link href="/lists" />}`. Without it, `href` is a plain `<a>`. */
9
+ render?: React.ReactElement;
10
+ };
11
+ type PageHeaderProps = {
12
+ /** The page's one `<h1>`: what this page is. "Climate founders", "Lanternfield Capital". */
13
+ title: React.ReactNode;
14
+ /** One line under the title: what the page is for, or a count ("128 members"). */
15
+ subtitle?: React.ReactNode;
16
+ /** "← Back" above the title, for a page reached from a list. `true` goes back in history. */
17
+ back?: true | PageHeaderBack;
18
+ /** Before the title: an Avatar `size="xl"` (a person, or an organization with its logo as `src`), or a Lucide icon, drawn in a 48px blue square. */
19
+ media?: React.ReactNode;
20
+ /** After the title: one Tag, such as "Private" or "Manager". */
21
+ tag?: React.ReactNode;
22
+ /** The page's main button: one primary Button (`md`). */
23
+ action?: React.ReactNode;
24
+ /** One other button, before the main one: a secondary Button (`md`). */
25
+ secondaryAction?: React.ReactNode;
26
+ /** ActionMenuItems for the less-used actions (Rename, Delete). They go in a ⋮ menu after the buttons. */
27
+ menu?: React.ReactNode;
28
+ /** Names the ⋮ menu. "More actions" unless the page has a better name: "Actions for Climate founders". */
29
+ menuLabel?: string;
30
+ /** Layout only: `mb-6`. */
31
+ className?: string;
32
+ };
33
+ declare function PageHeader({ title, subtitle, back, media, tag, action, secondaryAction, menu, menuLabel, className }: PageHeaderProps): React.JSX.Element;
34
+ export { PageHeader };
35
+ export type { PageHeaderBack, PageHeaderProps };
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { isValidElement, cloneElement } from "react";
4
+ import { ArrowLeft } from "lucide-react";
5
+ import { ActionMenu } from "@brdgapp/ui/components/action-menu";
6
+ import { cn } from "@brdgapp/ui/lib/utils";
7
+ const BACK_CLASS = "mb-6 inline-flex w-fit items-center gap-1.5 rounded-sm text-13 leading-normal font-semibold text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--text-primary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40";
8
+ function BackLink({ back }) {
9
+ const { label = "Back", href, onClick, render } = back === true ? {} : back;
10
+ const body = (_jsxs(_Fragment, { children: [_jsx(ArrowLeft, { "aria-hidden": "true", className: "size-3.5" }), label] }));
11
+ if (render && isValidElement(render)) {
12
+ return cloneElement(render, { className: BACK_CLASS, onClick, children: body });
13
+ }
14
+ if (href) {
15
+ return (_jsx("a", { href: href, onClick: onClick, className: BACK_CLASS, children: body }));
16
+ }
17
+ return (_jsx("button", { type: "button", onClick: onClick ?? (() => window.history.back()), className: BACK_CLASS, children: body }));
18
+ }
19
+ function PageHeader({ title, subtitle, back, media, tag, action, secondaryAction, menu, menuLabel = "More actions", className }) {
20
+ const buttons = action || secondaryAction || menu;
21
+ return (_jsxs("header", { "data-slot": "page-header", className: cn("flex flex-col", className), children: [back ? _jsx(BackLink, { back: back }) : null, _jsxs("div", { className: "flex flex-wrap items-start justify-between gap-x-6 gap-y-4", children: [_jsxs("div", { className: "flex min-w-0 flex-[1_1_16rem] items-center gap-3", children: [media ? (_jsx("span", { "data-slot": "page-header-media", className: "flex shrink-0 items-center justify-center has-[>svg]:size-12 has-[>svg]:rounded-xl has-[>svg]:bg-[var(--info-bg)] [&>svg]:size-6 [&>svg]:text-[var(--primary)]", children: media })) : null, _jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [_jsx("h1", { className: "min-w-0 text-22 leading-tight font-bold tracking-tight break-words text-[var(--text-primary)]", children: title }), tag] }), subtitle ? _jsx("p", { className: "mt-1 text-14 leading-normal text-[var(--text-body)]", children: subtitle }) : null] })] }), buttons ? (_jsxs("div", { "data-slot": "page-header-actions", className: "flex shrink-0 flex-wrap items-center gap-2", children: [secondaryAction, action, menu ? _jsx(ActionMenu, { ariaLabel: menuLabel, children: menu }) : null] })) : null] })] }));
22
+ }
23
+ export { PageHeader };
@@ -47,16 +47,17 @@ type SingleSelectProps<T extends string> = SelectBase<T> & {
47
47
  multiple?: false;
48
48
  /** The chosen option, or `null` for none yet (the placeholder shows). */
49
49
  value: T | null;
50
- onChange: (value: T) => void;
50
+ onChange: (value: NoInfer<T>) => void;
51
51
  };
52
52
  type MultipleSelectProps<T extends string> = SelectBase<T> & {
53
53
  /** Several values: each shows as a Tag in the field with × to remove it; the list stays open while ticking. */
54
54
  multiple: true;
55
55
  /** The chosen values; empty shows the placeholder. */
56
56
  value: T[];
57
- onChange: (value: T[]) => void;
57
+ onChange: (value: NoInfer<T>[]) => void;
58
58
  };
59
59
  type SelectProps<T extends string> = SingleSelectProps<T> | MultipleSelectProps<T>;
60
- declare function Select<T extends string>(props: SelectProps<T>): React.JSX.Element;
60
+ declare function Select<T extends string>(props: MultipleSelectProps<T>): React.JSX.Element;
61
+ declare function Select<T extends string>(props: SingleSelectProps<T>): React.JSX.Element;
61
62
  export { Select };
62
63
  export type { MultipleSelectProps, SelectOption, SelectProps, SelectSearch, SingleSelectProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brdgapp/ui",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Bridge's shared components, tokens and styles. Documented at handbook.brdg.app.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://handbook.brdg.app",