@brdgapp/ui 1.10.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.
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { useState } from "react";
5
5
  import { Menu } from "@base-ui/react/menu";
@@ -9,6 +9,92 @@ import { BottomSheet, BottomSheetOption, BottomSheetOptions } from "@brdgapp/ui/
9
9
  import { SearchInput } from "@brdgapp/ui/components/search-input";
10
10
  import { useIsMobile } from "@brdgapp/ui/hooks/use-is-mobile";
11
11
  import { cn } from "@brdgapp/ui/lib/utils";
12
+ /** Two names, then how many more: "London, Berlin +1". `spoken` is the same for screen readers. */
13
+ function summarize(labels) {
14
+ const shown = labels.slice(0, 2).join(", ");
15
+ const more = labels.length - 2;
16
+ return { text: more > 0 ? `${shown} +${more}` : shown, spoken: more > 0 ? `${shown} and ${more} more` : shown };
17
+ }
18
+ /**
19
+ * The picked options, kept with their labels: the app's search results change as people type, and a value
20
+ * picked from an earlier search must still show its name.
21
+ */
22
+ function usePicked(value, options) {
23
+ const [known, setKnown] = useState({});
24
+ const all = { ...known };
25
+ for (const o of options)
26
+ all[o.value] = o;
27
+ const picked = value.map((v) => all[v] ?? { value: v, label: v });
28
+ const remember = (o) => setKnown((k) => ({ ...k, [o.value]: o }));
29
+ return { picked, remember };
30
+ }
31
+ const boxBase = "relative inline-flex size-4 shrink-0 items-center justify-center rounded-[4px] border text-white transition-colors";
32
+ /** A row's tick box, drawn like Checkbox. The row is the option; the box is only its look. */
33
+ function TickBox({ on }) {
34
+ return (_jsx("span", { "aria-hidden": "true", className: cn(boxBase, on ? "border-[var(--primary-solid)] bg-[var(--primary-solid)]" : "border-[var(--text-muted)] bg-[var(--surface-primary)]"), children: on ? _jsx(Check, { className: "size-3", strokeWidth: 3 }) : null }));
35
+ }
36
+ /** Several values to filter by: an optional search field, tick rows, and Reset. Each tick filters at once. */
37
+ function MultiPanel({ value, options, onChange, name, search, searchPlaceholder = "Search", picked, remember, phone = false }) {
38
+ const listId = React.useId();
39
+ const panelRef = React.useRef(null);
40
+ const server = typeof search === "object" ? search : undefined;
41
+ const [own, setOwn] = useState("");
42
+ const query = server ? server.value : own;
43
+ const setQuery = server ? server.onChange : setOwn;
44
+ const [at, setAt] = useState(0);
45
+ const q = query.trim().toLowerCase();
46
+ const min = server ? (server.minLength ?? 2) : 0;
47
+ const short = q.length < min;
48
+ // Before the app has something to search, its list shows what's picked, so it can be unticked.
49
+ const rows = server
50
+ ? short
51
+ ? picked
52
+ : options
53
+ : q
54
+ ? options.filter((o) => o.label.toLowerCase().includes(q) || (o.description?.toLowerCase().includes(q) ?? false))
55
+ : options;
56
+ const cur = at < rows.length ? at : 0;
57
+ const note = short && !picked.length ? `Type at least ${min} letters.` : !short && !server?.loading && !rows.length ? (server?.emptyText ?? "No results.") : null;
58
+ const toggle = (o) => {
59
+ remember(o);
60
+ onChange(value.includes(o.value) ? value.filter((v) => v !== o.value) : [...value, o.value]);
61
+ };
62
+ const keys = (e, typing) => {
63
+ const n = rows.length;
64
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
65
+ e.preventDefault();
66
+ if (n)
67
+ setAt(e.key === "ArrowDown" ? (cur + 1) % n : (cur - 1 + n) % n);
68
+ }
69
+ else if ((e.key === "Enter" || (!typing && e.key === " ")) && rows[cur]) {
70
+ e.preventDefault();
71
+ toggle(rows[cur]);
72
+ }
73
+ };
74
+ const searchField = search ? (_jsx("div", { className: phone ? "px-5 pb-2" : "p-2 pb-1", children: _jsx(SearchInput, { autoFocus: !phone, role: phone ? undefined : "combobox", "aria-expanded": phone ? undefined : "true", "aria-controls": phone ? undefined : listId, "aria-autocomplete": phone ? undefined : "list", "aria-activedescendant": !phone && rows[cur] ? `${listId}-${cur}` : undefined, placeholder: searchPlaceholder, value: query, loading: server?.loading, onChange: (e) => {
75
+ setAt(0);
76
+ setQuery(e.target.value);
77
+ }, onClear: () => setQuery(""), onKeyDown: phone ? undefined : (e) => keys(e, true) }) })) : null;
78
+ const noteLine = note ? (_jsx("p", { role: "status", className: cn("text-[var(--text-muted)]", phone ? "px-5 pb-4 text-14" : "px-3 pt-1 pb-3 text-13"), children: note })) : null;
79
+ // Phones: the sheet's own tick rows (44px, real checkboxes); Reset sits beside the title.
80
+ if (phone) {
81
+ return (_jsxs(_Fragment, { children: [searchField, _jsx(BottomSheetOptions, { multiple: true, children: rows.map((o) => (_jsx(BottomSheetOption, { selected: value.includes(o.value), onSelect: () => toggle(o), children: o.label }, o.value))) }), noteLine] }));
82
+ }
83
+ return (_jsxs("div", { ref: panelRef, "data-slot": "filter-multi", className: "flex flex-col", children: [searchField, _jsx("div", { id: listId, role: "listbox", "aria-multiselectable": "true", "aria-label": name,
84
+ // With no search field, the list itself takes focus and the arrow keys.
85
+ tabIndex: search ? -1 : 0, autoFocus: !search, "aria-activedescendant": !search && rows[cur] ? `${listId}-${cur}` : undefined, onKeyDown: search ? undefined : (e) => keys(e, false), className: "max-h-[280px] overflow-y-auto py-1 outline-none", children: rows.map((o, i) => {
86
+ const on = value.includes(o.value);
87
+ return (_jsxs("div", { id: `${listId}-${i}`, role: "option", "aria-selected": on, "data-slot": "filter-multi-option", "data-highlighted": i === cur || undefined, onMouseDown: (e) => e.preventDefault(), onMouseMove: () => setAt(i), onClick: () => toggle(o), className: "flex w-full cursor-default items-center gap-3 px-3 py-2 text-left text-13 leading-normal text-[var(--text-body)] transition-colors data-[highlighted]:bg-[var(--surface-secondary)]", children: [_jsx(TickBox, { on: on }), o.icon ? _jsx("span", { className: "flex shrink-0", children: o.icon }) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: cn("block truncate", on && "text-[var(--text-primary)]"), children: o.label }), o.description ? _jsx("span", { className: "block truncate text-12 text-[var(--text-muted)]", children: o.description }) : null] })] }, o.value));
88
+ }) }), noteLine, value.length ? (_jsx("div", { className: "border-t border-[var(--border-divider)] p-1", children: _jsx("button", { type: "button", "data-slot": "filter-reset", onClick: () => {
89
+ onChange([]);
90
+ // Reset goes away with nothing picked: focus goes back to the search field, or the list.
91
+ panelRef.current?.querySelector("input, [role=listbox]")?.focus();
92
+ }, className: "w-full rounded-lg px-3 py-2 text-left text-13 font-semibold text-[var(--primary)] outline-none transition-colors hover:bg-[var(--surface-secondary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]", children: "Reset" }) })) : null] }));
93
+ }
94
+ /** Reset beside a phone sheet's title, while something is picked. */
95
+ function SheetReset({ show, onReset }) {
96
+ return show ? (_jsx("button", { type: "button", onClick: onReset, className: "rounded-lg px-2 py-1 text-14 font-semibold text-[var(--primary)] outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]", children: "Reset" })) : null;
97
+ }
12
98
  /** The menu body shared by FilterPill and ColumnFilterMenu. */
13
99
  function FilterMenuPopup({ value, options, onChange, width, align, }) {
14
100
  return (_jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { side: "bottom", align: align, sideOffset: 6, collisionPadding: 8, className: "z-[95]", children: _jsx(Menu.Popup, { "data-slot": "filter-menu", style: { minWidth: width }, className: "max-h-[320px] overflow-y-auto rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] py-1 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: _jsx(Menu.RadioGroup, { value: value, onValueChange: (v) => onChange(v), children: options.map((option) => (_jsxs(Menu.RadioItem, { value: option.value, closeOnClick: true, "data-slot": "filter-menu-option", className: "group flex w-full cursor-default items-center justify-between gap-3 px-3 py-2 text-left text-13 leading-normal text-[var(--text-body)] outline-none transition-colors data-[checked]:font-semibold data-[checked]:text-[var(--text-primary)] data-[highlighted]:bg-[var(--surface-secondary)] hover:bg-[var(--surface-secondary)]", children: [_jsx("span", { className: "truncate", children: option.label }), _jsx(Menu.RadioItemIndicator, { className: "inline-flex shrink-0", children: _jsx(Check, { "aria-hidden": "true", className: "size-4 text-[var(--primary)]" }) })] }, option.value))) }) }) }) }));
@@ -53,16 +139,35 @@ function SearchPanel({ value, options, search, onPick, phone = false, }) {
53
139
  return (_jsxs("div", { id: `${listId}-${i}`, role: "option", "aria-selected": selected, "data-slot": "filter-search-option", "data-highlighted": i === cur || undefined, onMouseDown: (e) => e.preventDefault(), onMouseMove: () => setAt(i), onClick: () => onPick(option), className: cn("flex w-full cursor-default items-center gap-3 text-left leading-normal transition-colors data-[highlighted]:bg-[var(--surface-secondary)]", phone ? "min-h-11 px-5 py-2 text-14" : "px-3 py-2 text-13", selected ? "font-semibold text-[var(--text-primary)]" : "text-[var(--text-body)]"), children: [option.icon ? _jsx("span", { className: "flex shrink-0", children: option.icon }) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate", children: option.label }), option.description ? _jsx("span", { className: "block truncate text-12 font-normal text-[var(--text-muted)]", children: option.description }) : null] }), selected ? _jsx(Check, { "aria-hidden": "true", className: "size-4 shrink-0 text-[var(--primary)]" }) : null] }, option.value));
54
140
  }) }), note ? _jsx("p", { role: "status", className: cn("text-[var(--text-muted)]", phone ? "px-5 pb-4 text-14" : "px-3 pt-1 pb-3 text-13"), children: note }) : null] }));
55
141
  }
56
- function FilterPill({ value, options, onChange, ariaLabel = "Filter", search, className, ...rest }) {
142
+ function FilterPill(props) {
143
+ return props.multiple ? _jsx(MultipleFilterPill, { ...props }) : _jsx(SingleFilterPill, { ...props });
144
+ }
145
+ const pillClass = (active, className) => cn("inline-flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-13 leading-normal font-semibold outline-none transition-colors duration-150", "focus-visible:ring-2 focus-visible:ring-[var(--primary)]", active
146
+ ? "border-[var(--text-muted)] bg-[var(--surface-tertiary)] text-[var(--text-primary)] hover:border-[var(--text-secondary)]"
147
+ : "border-[var(--text-disabled)] bg-transparent text-[var(--text-secondary)] hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]", className);
148
+ function MultipleFilterPill({ multiple, value, options, onChange, ariaLabel, search, searchPlaceholder, className, ...rest }) {
149
+ const [open, setOpen] = useState(false);
150
+ const mobile = useIsMobile();
151
+ const { picked, remember } = usePicked(value, options);
152
+ const active = value.length > 0;
153
+ const sum = summarize(picked.map((o) => o.label));
154
+ const label = active ? `${ariaLabel}: ${sum.text}` : ariaLabel;
155
+ const name = active ? `${ariaLabel}: ${sum.spoken}` : ariaLabel;
156
+ const inner = (_jsxs(_Fragment, { children: [_jsx("span", { className: "max-w-[260px] truncate", children: label }), _jsx(ChevronDown, { "aria-hidden": "true", className: cn("size-3.5 shrink-0 text-[var(--text-muted)] transition-transform", open && "rotate-180") })] }));
157
+ const panel = (phone) => (_jsx(MultiPanel, { value: value, options: options, onChange: onChange, name: ariaLabel, search: search, searchPlaceholder: searchPlaceholder, picked: picked, remember: remember, phone: phone }));
158
+ if (mobile) {
159
+ return (_jsxs(_Fragment, { children: [_jsx("button", { ...rest, type: "button", "data-slot": "filter-pill", "data-multiple": multiple ? "" : undefined, "aria-haspopup": "dialog", "aria-label": name, className: pillClass(active, className), onClick: () => setOpen(true), children: inner }), _jsx(BottomSheet, { open: open, onClose: () => setOpen(false), title: ariaLabel, action: _jsx(SheetReset, { show: active, onReset: () => onChange([]) }), children: panel(true) })] }));
160
+ }
161
+ return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Trigger, { ...rest, "data-slot": "filter-pill", "data-multiple": multiple ? "" : undefined, "aria-label": name, className: pillClass(active, className), children: inner }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Positioner, { side: "bottom", align: "end", sideOffset: 6, collisionPadding: 8, className: "z-[95]", children: _jsx(PopoverPrimitive.Popup, { "data-slot": "filter-menu", "aria-label": ariaLabel, className: "w-[280px] 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) }) }) })] }));
162
+ }
163
+ function SingleFilterPill({ multiple, value, options, onChange, ariaLabel = "Filter", search, className, ...rest }) {
57
164
  const [open, setOpen] = useState(false);
58
165
  const mobile = useIsMobile();
59
166
  const active = value !== options[0]?.value;
60
167
  // The search variant's results change as people type, so the chosen label is kept here.
61
168
  const [picked, setPicked] = useState();
62
169
  const label = options.find((o) => o.value === value)?.label ?? (active ? picked : undefined) ?? options[0]?.label ?? "";
63
- const triggerClass = cn("inline-flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-13 leading-normal font-semibold outline-none transition-colors duration-150", "focus-visible:ring-2 focus-visible:ring-[var(--primary)]", active
64
- ? "border-[var(--text-muted)] bg-[var(--surface-tertiary)] text-[var(--text-primary)] hover:border-[var(--text-secondary)]"
65
- : "border-[var(--text-disabled)] bg-transparent text-[var(--text-secondary)] hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]", className);
170
+ const triggerClass = pillClass(active, className);
66
171
  const inner = (_jsxs(_Fragment, { children: [label, _jsx(ChevronDown, { "aria-hidden": "true", className: cn("size-3.5 text-[var(--text-muted)] transition-transform", open && "rotate-180") })] }));
67
172
  if (search) {
68
173
  const pick = (option) => {
@@ -72,14 +177,14 @@ function FilterPill({ value, options, onChange, ariaLabel = "Filter", search, cl
72
177
  setOpen(false);
73
178
  };
74
179
  if (mobile) {
75
- return (_jsxs(_Fragment, { children: [_jsx("button", { ...rest, type: "button", "data-slot": "filter-pill", "aria-haspopup": "dialog", "aria-label": `${ariaLabel}: ${label}`, className: triggerClass, onClick: () => setOpen(true), children: inner }), _jsx(BottomSheet, { open: open, onClose: () => setOpen(false), title: ariaLabel, children: _jsx(SearchPanel, { value: value, options: options, search: search, onPick: pick, phone: true }) })] }));
180
+ return (_jsxs(_Fragment, { children: [_jsx("button", { ...rest, type: "button", "data-slot": "filter-pill", "data-multiple": multiple ? "" : undefined, "aria-haspopup": "dialog", "aria-label": `${ariaLabel}: ${label}`, className: triggerClass, onClick: () => setOpen(true), children: inner }), _jsx(BottomSheet, { open: open, onClose: () => setOpen(false), title: ariaLabel, children: _jsx(SearchPanel, { value: value, options: options, search: search, onPick: pick, phone: true }) })] }));
76
181
  }
77
- return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Trigger, { ...rest, "data-slot": "filter-pill", "aria-label": `${ariaLabel}: ${label}`, className: triggerClass, children: inner }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Positioner, { side: "bottom", align: "end", sideOffset: 6, collisionPadding: 8, className: "z-[95]", children: _jsx(PopoverPrimitive.Popup, { "data-slot": "filter-menu", "aria-label": ariaLabel, className: "w-[300px] 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: _jsx(SearchPanel, { value: value, options: options, search: search, onPick: pick }) }) }) })] }));
182
+ return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Trigger, { ...rest, "data-slot": "filter-pill", "data-multiple": multiple ? "" : undefined, "aria-label": `${ariaLabel}: ${label}`, className: triggerClass, children: inner }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Positioner, { side: "bottom", align: "end", sideOffset: 6, collisionPadding: 8, className: "z-[95]", children: _jsx(PopoverPrimitive.Popup, { "data-slot": "filter-menu", "aria-label": ariaLabel, className: "w-[300px] 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: _jsx(SearchPanel, { value: value, options: options, search: search, onPick: pick }) }) }) })] }));
78
183
  }
79
184
  // Phones: the choices slide up from the bottom, near the thumb, in 44px rows.
80
185
  if (mobile) {
81
- return (_jsxs(_Fragment, { children: [_jsx("button", { ...rest, type: "button", "data-slot": "filter-pill", "aria-haspopup": "dialog", "aria-label": `${ariaLabel}: ${label}`, className: triggerClass, onClick: () => setOpen(true), children: inner }), _jsx(FilterSheet, { open: open, onClose: () => setOpen(false), title: ariaLabel, value: value, options: options, onChange: onChange })] }));
186
+ return (_jsxs(_Fragment, { children: [_jsx("button", { ...rest, type: "button", "data-slot": "filter-pill", "data-multiple": multiple ? "" : undefined, "aria-haspopup": "dialog", "aria-label": `${ariaLabel}: ${label}`, className: triggerClass, onClick: () => setOpen(true), children: inner }), _jsx(FilterSheet, { open: open, onClose: () => setOpen(false), title: ariaLabel, value: value, options: options, onChange: onChange })] }));
82
187
  }
83
- return (_jsxs(Menu.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Menu.Trigger, { ...rest, "data-slot": "filter-pill", "aria-label": `${ariaLabel}: ${label}`, className: triggerClass, children: inner }), _jsx(FilterMenuPopup, { value: value, options: options, onChange: onChange, width: 200, align: "end" })] }));
188
+ return (_jsxs(Menu.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Menu.Trigger, { ...rest, "data-slot": "filter-pill", "data-multiple": multiple ? "" : undefined, "aria-label": `${ariaLabel}: ${label}`, className: triggerClass, children: inner }), _jsx(FilterMenuPopup, { value: value, options: options, onChange: onChange, width: 200, align: "end" })] }));
84
189
  }
85
- export { FilterPill, FilterMenuPopup, FilterSheet };
190
+ export { FilterPill, FilterMenuPopup, FilterSheet, MultiPanel, SheetReset, summarize, TickBox, usePicked };
@@ -9,8 +9,14 @@ type IconButtonProps = Omit<ButtonPrimitive.Props, "className" | "aria-label"> &
9
9
  "aria-label": string;
10
10
  /** The action is running: shows a spinner, disables the button, sets `aria-busy`. */
11
11
  loading?: boolean;
12
+ /**
13
+ * Text to copy on click. The icon (Copy, unless you pass another) becomes a green check for 1.5 seconds,
14
+ * the name becomes "Copied" and is announced, and a failed copy shows an error toast. Name what's
15
+ * copied: `aria-label="Copy server URL"`. `onClick` still runs.
16
+ */
17
+ copy?: string;
12
18
  className?: string;
13
19
  };
14
- declare function IconButton({ className, variant, size, loading, disabled, children, ...props }: IconButtonProps): import("react").JSX.Element;
20
+ declare function IconButton({ className, variant, size, loading, disabled, children, copy, onClick, "aria-label": label, ...props }: IconButtonProps): import("react").JSX.Element;
15
21
  export { IconButton, iconButtonVariants };
16
22
  export type { IconButtonProps };
@@ -1,13 +1,15 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Button as ButtonPrimitive } from "@base-ui/react/button";
4
4
  import { cva } from "class-variance-authority";
5
- import { LoaderCircle } from "lucide-react";
5
+ import { Check, Copy, LoaderCircle } from "lucide-react";
6
+ import { useCopy } from "@brdgapp/ui/hooks/use-copy";
6
7
  import { cn } from "@brdgapp/ui/lib/utils";
7
8
  // The one icon-only button: close, kebab, back, copy, sync. Always round. Ported from Bridge OS
8
9
  // src/components/ui/icon-button.tsx onto Base UI Button. All sizes meet the 24px minimum target.
9
10
  // 2026-11-06 (Aman): `outline`, Button `secondary`'s edge and fill on a circle; `xs`, 24px (the apps draw
10
11
  // 24px icon buttons by hand 73 times).
12
+ // `copy` (Aman 2026-11-20): the copy icon beside a value, hand-made in 8 apps; see hooks/use-copy.ts.
11
13
  const iconButtonVariants = cva([
12
14
  "inline-grid shrink-0 place-items-center rounded-full border border-transparent",
13
15
  "transition-colors duration-150 ease-out outline-none",
@@ -31,7 +33,15 @@ const iconButtonVariants = cva([
31
33
  },
32
34
  defaultVariants: { variant: "default", size: "md" },
33
35
  });
34
- function IconButton({ className, variant, size, loading = false, disabled, children, ...props }) {
35
- return (_jsx(ButtonPrimitive, { "data-slot": "icon-button", className: cn(iconButtonVariants({ variant, size }), className), disabled: disabled || loading, "aria-busy": loading || undefined, ...props, children: _jsx("span", { "aria-hidden": "true", className: "inline-grid place-items-center", children: loading ? _jsx(LoaderCircle, { className: "animate-spin" }) : children }) }));
36
+ function IconButton({ className, variant, size, loading = false, disabled, children, copy, onClick, "aria-label": label, ...props }) {
37
+ const copier = useCopy();
38
+ const copying = copy !== undefined;
39
+ const copied = copying && copier.copied;
40
+ return (_jsxs(ButtonPrimitive, { "data-slot": "icon-button", "data-copied": copied || undefined, className: cn(iconButtonVariants({ variant, size }), className), disabled: disabled || loading, "aria-busy": loading || undefined, "aria-label": copied ? "Copied" : label, ...props, onClick: copying
41
+ ? (e) => {
42
+ void copier.copy(copy);
43
+ onClick?.(e);
44
+ }
45
+ : onClick, children: [_jsx("span", { "aria-hidden": "true", className: "inline-grid place-items-center", children: loading ? (_jsx(LoaderCircle, { className: "animate-spin" })) : copied ? (_jsx(Check, { className: "text-[var(--success-text)]" })) : copying ? ((children ?? _jsx(Copy, {}))) : (children) }), copying ? (_jsx("span", { className: "sr-only", "aria-live": "polite", children: copied ? "Copied" : "" })) : null] }));
36
46
  }
37
47
  export { IconButton, iconButtonVariants };
@@ -1,9 +1,33 @@
1
1
  import type * as React from "react";
2
2
  import { Input as InputPrimitive } from "@base-ui/react/input";
3
- type InputProps = Omit<InputPrimitive.Props, "className"> & {
3
+ type BaseProps = Omit<InputPrimitive.Props, "className" | "prefix" | "value" | "defaultValue" | "onValueChange"> & {
4
4
  /** Layout only: `max-w-sm`, `flex-1`. */
5
5
  className?: string;
6
+ /** With `type="password"`: the show/hide button at the field's end. On by default; `false` leaves it out. */
7
+ reveal?: boolean;
8
+ /** What the hidden value is, for the button's name: "password" (the default) or, say, "API key". */
9
+ secretName?: string;
10
+ /** A Lucide icon before the value, saying what kind of value it is: `<Key />` for an API key. */
11
+ leadingIcon?: React.ReactNode;
12
+ /** Text before the value that isn't typed: "$", "https://", "linkedin.com/in/". Say the unit in the label too. */
13
+ prefix?: string;
6
14
  };
7
- declare function Input({ className, type, ...props }: InputProps): React.JSX.Element;
15
+ type TextInputProps = BaseProps & {
16
+ format?: undefined;
17
+ value?: InputPrimitive.Props["value"];
18
+ defaultValue?: InputPrimitive.Props["defaultValue"];
19
+ onValueChange?: InputPrimitive.Props["onValueChange"];
20
+ };
21
+ type NumberInputProps = BaseProps & {
22
+ /** A whole number, with commas as it's typed ("2,500,000"). Pair it with `prefix="$"` for an amount. */
23
+ format: "number";
24
+ /** The number shown, or `null` for an empty field. */
25
+ value?: number | null;
26
+ defaultValue?: number | null;
27
+ /** The plain number as it's typed (`2500000`), or `null` when the field is emptied. */
28
+ onValueChange?: (value: number | null) => void;
29
+ };
30
+ type InputProps = TextInputProps | NumberInputProps;
31
+ declare function Input(props: InputProps): React.JSX.Element;
8
32
  export { Input };
9
- export type { InputProps };
33
+ export type { InputProps, NumberInputProps };
@@ -1,6 +1,10 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useLayoutEffect, useRef, useState } from "react";
3
4
  import { Input as InputPrimitive } from "@base-ui/react/input";
5
+ import { Eye, EyeOff } from "lucide-react";
6
+ import { IconButton } from "@brdgapp/ui/components/icon-button";
7
+ import { Tip } from "@brdgapp/ui/components/info-hint";
4
8
  import { cn } from "@brdgapp/ui/lib/utils";
5
9
  // A one-line text field. Started from shadcn's Base UI input, then put on Bridge's look: Bridge OS's own
6
10
  // Input (src/components/ui/input.tsx) and Add a network use a 40px white box with 14px text, 16px on phones
@@ -8,8 +12,97 @@ import { cn } from "@brdgapp/ui/lib/utils";
8
12
  // 2026-11-03 over Edit contact's 36px grey box). Same height as SearchInput, so they line up.
9
13
  // Inside a Field, the label, help text and error are tied to it automatically.
10
14
  // The placeholder uses --text-muted, not --text-disabled as in Bridge OS: disabled grey is 2:1 on white.
15
+ // A password field (`type="password"`) has a show/hide button at its end (Aman 2026-11-19, audit decision 5).
16
+ // Survey (2026-11-19): about 22 password and secret fields in 10 apps, hand-made eye buttons in together (5
17
+ // files, API keys too), raise (3) and bridge-jobs (1), mostly with no name for screen readers. One button
18
+ // for every secret: "Show password", or "Show API key" with `secretName`. The value stays as typed.
11
19
  const inputClasses = cn("h-11 md:h-10 w-full min-w-0 rounded-lg border border-[var(--border-field)] bg-[var(--surface-primary)] px-3.5", "text-16 md:text-14 text-[var(--text-primary)] placeholder:text-[var(--text-muted)]", "transition-colors duration-150 ease-out outline-none", "hover:border-[var(--text-muted)]", "focus-visible:border-[var(--primary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]/20", "aria-invalid:border-[var(--error)] aria-invalid:hover:border-[var(--error)] aria-invalid:focus-visible:border-[var(--error)] aria-invalid:focus-visible:ring-[var(--error)]/20", "data-[invalid]:border-[var(--error)] data-[invalid]:hover:border-[var(--error)] data-[invalid]:focus-visible:border-[var(--error)] data-[invalid]:focus-visible:ring-[var(--error)]/20", "disabled:cursor-not-allowed disabled:opacity-50");
12
- function Input({ className, type = "text", ...props }) {
13
- return _jsx(InputPrimitive, { "data-slot": "input", type: type, className: cn(inputClasses, className), ...props });
20
+ // With an icon, a prefix or the show/hide button, the box is drawn around them and the field together, so
21
+ // any prefix ("$", "https://") fits without guessed padding. The same look and states, read from the field
22
+ // inside it (`has-[…]`).
23
+ const boxClasses = cn("flex h-11 md:h-10 w-full min-w-0 items-center gap-2 rounded-lg border border-[var(--border-field)] bg-[var(--surface-primary)] px-3.5", "transition-colors duration-150 ease-out hover:border-[var(--text-muted)]", "has-[:focus-visible]:border-[var(--primary)] has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-[var(--primary)]/20", "has-[[aria-invalid=true]]:border-[var(--error)] has-[[data-invalid]]:border-[var(--error)]", "has-[[aria-invalid=true]]:hover:border-[var(--error)] has-[[data-invalid]]:hover:border-[var(--error)]", "has-[[aria-invalid=true]:focus-visible]:border-[var(--error)] has-[[data-invalid]:focus-visible]:border-[var(--error)]", "has-[[aria-invalid=true]:focus-visible]:ring-[var(--error)]/20 has-[[data-invalid]:focus-visible]:ring-[var(--error)]/20", "has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50");
24
+ const fieldInBox = cn("h-full w-full min-w-0 flex-1 bg-transparent outline-none", "text-16 md:text-14 text-[var(--text-primary)] placeholder:text-[var(--text-muted)]", "disabled:cursor-not-allowed");
25
+ function Input(props) {
26
+ return props.format === "number" ? _jsx(NumberInput, { ...props }) : _jsx(TextInput, { ...props });
27
+ }
28
+ // Whole numbers only, left-aligned, US dollars when there's a currency (Aman, 2026-11-19): every app's money
29
+ // field today is a whole amount with "$" before it (app-portfolio's CurrencyAmountInput, raise's check sizes,
30
+ // bridge-jobs' salary, Bridge OS's outcome value), and none shows cents. Up to 15 digits, so the number stays exact.
31
+ const groupDigits = (digits) => (digits ? Number(digits).toLocaleString("en-US") : "");
32
+ function NumberInput({ format, value, defaultValue, onValueChange, onChange, ...props }) {
33
+ const toDigits = (n) => (n == null ? "" : String(Math.trunc(Math.abs(n))));
34
+ const [text, setText] = useState(() => groupDigits(toDigits(value !== undefined ? value : defaultValue)));
35
+ // A new value from outside (a reset, a loaded record) replaces what's shown; the number being typed doesn't.
36
+ // Adjusted while rendering, not in an effect, so there's no second render with the old text.
37
+ const [lastValue, setLastValue] = useState(value);
38
+ if (value !== lastValue) {
39
+ setLastValue(value);
40
+ if (value !== undefined && text.replace(/\D/g, "") !== toDigits(value))
41
+ setText(groupDigits(toDigits(value)));
42
+ }
43
+ // Where the cursor goes once the commas have moved, put back after React has written the new text.
44
+ const pending = useRef(null);
45
+ useLayoutEffect(() => {
46
+ const c = pending.current;
47
+ if (c && document.activeElement === c.el)
48
+ c.el.setSelectionRange(c.at, c.at);
49
+ pending.current = null;
50
+ }, [text]);
51
+ if (format !== "number")
52
+ return null;
53
+ return (_jsx(TextInput, { ...props, type: "text", inputMode: "numeric", numeric: true, value: text, onChange: (e) => {
54
+ const el = e.target;
55
+ let raw = el.value;
56
+ let caret = el.selectionStart ?? raw.length;
57
+ // Deleting a comma deletes the digit beside it, as people expect; otherwise the key would seem dead.
58
+ const kind = e.nativeEvent.inputType;
59
+ if (raw.replace(/\D/g, "") === text.replace(/\D/g, "") && raw.length < text.length) {
60
+ if (kind === "deleteContentBackward" && caret > 0) {
61
+ raw = raw.slice(0, caret - 1) + raw.slice(caret);
62
+ caret -= 1;
63
+ }
64
+ else if (kind === "deleteContentForward")
65
+ raw = raw.slice(0, caret) + raw.slice(caret + 1);
66
+ }
67
+ // Keep the cursor beside the same digit once the commas move, and before a comma, not after it.
68
+ const digitsAfter = raw.slice(caret).replace(/\D/g, "").length;
69
+ const digits = raw.replace(/\D/g, "").replace(/^0+(?=\d)/, "").slice(0, 15);
70
+ const next = groupDigits(digits);
71
+ let at = next.length;
72
+ for (let seen = 0; at > 0 && seen < digitsAfter;)
73
+ if (/\d/.test(next[--at]))
74
+ seen++;
75
+ if (next[at - 1] === ",")
76
+ at -= 1;
77
+ pending.current = { el, at };
78
+ if (next === text) {
79
+ // Nothing to rewrite (a letter was dropped): the field still puts its old text back, so wait for that.
80
+ setTimeout(() => {
81
+ if (document.activeElement === el)
82
+ el.setSelectionRange(at, at);
83
+ });
84
+ }
85
+ setText(next);
86
+ onChange?.(e);
87
+ onValueChange?.(digits ? Number(digits) : null);
88
+ } }));
89
+ }
90
+ function TextInput({ className, type = "text", reveal = true, secretName = "password", leadingIcon, prefix, disabled, numeric = false, ...props }) {
91
+ const [shown, setShown] = useState(false);
92
+ const field = useRef(null);
93
+ const password = type === "password" && reveal;
94
+ if (!password && !leadingIcon && !prefix) {
95
+ return _jsx(InputPrimitive, { "data-slot": "input", type: type, disabled: disabled, className: cn(inputClasses, numeric && "tabular-nums", className), ...props });
96
+ }
97
+ const forced = props["data-force-state"];
98
+ const name = `${shown ? "Hide" : "Show"} ${secretName}`;
99
+ return (_jsxs("span", { "data-slot": "input-box", "data-force-state": forced, className: cn(boxClasses, className),
100
+ // A press on the icon or the prefix goes to the field, as on the field itself.
101
+ onPointerDown: (e) => {
102
+ if (e.target === e.currentTarget || !e.target.closest("button, input")) {
103
+ e.preventDefault();
104
+ field.current?.focus();
105
+ }
106
+ }, children: [leadingIcon ? _jsx("span", { "aria-hidden": "true", className: "flex shrink-0 text-[var(--text-muted)] [&_svg]:size-4", children: leadingIcon }) : null, prefix ? _jsx("span", { "aria-hidden": "true", className: "-mr-1 shrink-0 text-16 text-[var(--text-muted)] md:text-14", children: prefix }) : null, _jsx(InputPrimitive, { ref: field, "data-slot": "input", type: password && shown ? "text" : type, disabled: disabled, ...(password ? { spellCheck: false, autoCapitalize: "off" } : {}), className: cn(fieldInBox, numeric && "tabular-nums"), ...props }), password ? (_jsx("span", { className: "-mr-2 flex shrink-0", children: _jsx(Tip, { text: name, children: _jsx(IconButton, { type: "button", size: "sm", "aria-label": name, disabled: disabled, onClick: () => setShown((v) => !v), children: shown ? _jsx(EyeOff, {}) : _jsx(Eye, {}) }) }) })) : null] }));
14
107
  }
15
108
  export { Input };
@@ -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 };
@@ -7,10 +7,17 @@ type SelectOption<T extends string> = {
7
7
  /** A Lucide icon or small Avatar before the label. */
8
8
  icon?: React.ReactNode;
9
9
  };
10
- type SelectProps<T extends string> = {
11
- /** The chosen option, or `null` for none yet (the placeholder shows). */
12
- value: T | null;
13
- onChange: (value: T) => void;
10
+ /** Results from the server as people type, for lists too long to load: people, locations, every VC. */
11
+ type SelectSearch = {
12
+ /** What's typed. */
13
+ value: string;
14
+ onChange: (value: string) => void;
15
+ /** Results are on their way: a spinner shows in the search field. */
16
+ loading?: boolean;
17
+ /** Letters needed before the app searches. Default 2; under it the list says "Type at least 2 letters." */
18
+ minLength?: number;
19
+ };
20
+ type SelectBase<T extends string> = {
14
21
  options: SelectOption<T>[];
15
22
  /** Shown, muted, until something is chosen: "Choose a type". */
16
23
  placeholder?: string;
@@ -21,7 +28,36 @@ type SelectProps<T extends string> = {
21
28
  "aria-label"?: string;
22
29
  /** Layout only: `max-w-xs`. */
23
30
  className?: string;
31
+ /**
32
+ * A search field at the top of the list. `true` filters `options` as people type (by label and
33
+ * description). An object means the app searches: `options` are its results for what's typed.
34
+ */
35
+ search?: boolean | SelectSearch;
36
+ /** The search field's placeholder: "Search contacts". Default "Search". */
37
+ searchPlaceholder?: string;
38
+ /** What the list says when nothing matches. Default "No results." */
39
+ emptyText?: string;
40
+ /**
41
+ * Adds an "Add “…”" row when what's typed matches no option, and is called with the typed text. The app
42
+ * adds it (to the list, or saves it) and sets `value`. Turns on the search field.
43
+ */
44
+ onCreate?: (text: string) => void;
45
+ };
46
+ type SingleSelectProps<T extends string> = SelectBase<T> & {
47
+ multiple?: false;
48
+ /** The chosen option, or `null` for none yet (the placeholder shows). */
49
+ value: T | null;
50
+ onChange: (value: NoInfer<T>) => void;
51
+ };
52
+ type MultipleSelectProps<T extends string> = SelectBase<T> & {
53
+ /** Several values: each shows as a Tag in the field with × to remove it; the list stays open while ticking. */
54
+ multiple: true;
55
+ /** The chosen values; empty shows the placeholder. */
56
+ value: T[];
57
+ onChange: (value: NoInfer<T>[]) => void;
24
58
  };
25
- declare function Select<T extends string>({ value, onChange, options, placeholder, disabled, name, className, ...props }: SelectProps<T>): React.JSX.Element;
59
+ type SelectProps<T extends string> = SingleSelectProps<T> | MultipleSelectProps<T>;
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;
26
62
  export { Select };
27
- export type { SelectOption, SelectProps };
63
+ export type { MultipleSelectProps, SelectOption, SelectProps, SelectSearch, SingleSelectProps };