@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,9 +1,13 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
+ import { Combobox } from "@base-ui/react/combobox";
4
5
  import { Select as SelectPrimitive } from "@base-ui/react/select";
5
- import { Check, ChevronDown } from "lucide-react";
6
+ import { Check, ChevronDown, Plus, X } from "lucide-react";
6
7
  import { BottomSheet, BottomSheetOption, BottomSheetOptions } from "@brdgapp/ui/components/bottom-sheet";
8
+ import { TickBox, usePicked } from "@brdgapp/ui/components/filter-pill";
9
+ import { SearchInput } from "@brdgapp/ui/components/search-input";
10
+ import { Tag } from "@brdgapp/ui/components/tag";
7
11
  import { useIsMobile } from "@brdgapp/ui/hooks/use-is-mobile";
8
12
  import { cn } from "@brdgapp/ui/lib/utils";
9
13
  // The same box as Input: 40px (44 on phones), 8px corners, the field border, blue focus, red when invalid.
@@ -11,7 +15,12 @@ const triggerClasses = cn("flex h-11 md:h-10 w-full min-w-0 items-center justify
11
15
  function OptionBody({ option, phone = false }) {
12
16
  return (_jsxs("span", { className: "flex min-w-0 items-center gap-3", children: [option.icon ? _jsx("span", { className: "flex shrink-0 text-[var(--text-muted)] [&_svg]:size-4", children: option.icon }) : null, _jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block truncate", children: option.label }), option.description ? _jsx("span", { className: cn("block truncate font-normal text-[var(--text-muted)]", phone ? "text-13" : "text-12"), children: option.description }) : null] })] }));
13
17
  }
14
- function Select({ value, onChange, options, placeholder = "Choose", disabled = false, name, className, ...props }) {
18
+ function Select(props) {
19
+ if (props.multiple)
20
+ return _jsx(MultipleSelect, { ...props });
21
+ return props.search || props.onCreate ? _jsx(SearchSelect, { ...props }) : _jsx(PlainSelect, { ...props });
22
+ }
23
+ function PlainSelect({ value, onChange, options, placeholder = "Choose", disabled = false, name, className, ...props }) {
15
24
  const mobile = useIsMobile();
16
25
  const [sheet, setSheet] = React.useState(false);
17
26
  const [listOpen, setListOpen] = React.useState(false);
@@ -41,4 +50,160 @@ function Select({ value, onChange, options, placeholder = "Choose", disabled = f
41
50
  setSheet(false);
42
51
  }, children: _jsx(OptionBody, { option: option, phone: true }) }, option.value))) }) })) : null] }));
43
52
  }
53
+ const CREATE = "\u0000create";
54
+ const optionRow = "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-[selected]:font-semibold data-[selected]:text-[var(--text-primary)] data-[highlighted]:bg-[var(--surface-secondary)]";
55
+ const matches = (o, q) => {
56
+ const t = q.toLowerCase();
57
+ return o.label.toLowerCase().includes(t) || (o.description?.toLowerCase().includes(t) ?? false);
58
+ };
59
+ /** The label of the field this Select sits in (FieldLabel), for the phone sheet's title. */
60
+ function labelOf(el) {
61
+ const ids = el?.getAttribute("aria-labelledby")?.split(" ") ?? [];
62
+ return ids.map((id) => document.getElementById(id)?.textContent?.trim()).find(Boolean);
63
+ }
64
+ function SearchSelect({ value, onChange, options, placeholder = "Choose", disabled = false, name, className, search, searchPlaceholder = "Search", emptyText = "No results.", onCreate, ...props }) {
65
+ const mobile = useIsMobile();
66
+ const server = typeof search === "object" ? search : undefined;
67
+ const [ownQuery, setOwnQuery] = React.useState("");
68
+ const query = server ? server.value : ownQuery;
69
+ const setQuery = server ? server.onChange : setOwnQuery;
70
+ const [open, setOpen] = React.useState(false);
71
+ const [title, setTitle] = React.useState("");
72
+ const trigger = React.useRef(null);
73
+ // The app's results change as people type, so the chosen option is kept here for its label.
74
+ const [picked, setPicked] = React.useState();
75
+ const chosen = options.find((o) => o.value === value) ?? (picked && picked.value === value ? picked : undefined);
76
+ const q = query.trim();
77
+ const min = server ? (server.minLength ?? 2) : 0;
78
+ const short = q.length < min;
79
+ const found = server ? (short ? [] : options) : q ? options.filter((o) => matches(o, q)) : options;
80
+ const exact = options.some((o) => o.label.trim().toLowerCase() === q.toLowerCase());
81
+ const addRow = onCreate && q && !exact ? { value: CREATE, label: `Add “${q}”`, create: q } : null;
82
+ const rows = addRow ? [...found, addRow] : found;
83
+ const note = short ? `Type at least ${min} letters.` : !server?.loading && !rows.length ? emptyText : null;
84
+ const close = () => {
85
+ setOpen(false);
86
+ setQuery("");
87
+ };
88
+ const pick = (row) => {
89
+ if (row.create !== undefined)
90
+ onCreate?.(row.create);
91
+ else {
92
+ setPicked(row);
93
+ onChange(row.value);
94
+ }
95
+ close();
96
+ };
97
+ const triggerInner = (_jsxs(_Fragment, { children: [_jsx("span", { className: cn("min-w-0 truncate", !chosen && "text-[var(--text-muted)]"), children: chosen ? chosen.label : placeholder }), _jsx(ChevronDown, { "aria-hidden": "true", className: cn("size-4 shrink-0 text-[var(--text-muted)] transition-transform", open && "rotate-180") })] }));
98
+ // Phones: the search field and the options in a bottom sheet, 44px rows.
99
+ if (mobile) {
100
+ return (_jsxs(_Fragment, { children: [_jsx(Combobox.Root, { items: rows, value: chosen ?? null, itemToStringValue: (r) => r.value, isItemEqualToValue: (a, b) => a.value === b.value, inputValue: query, open: false, disabled: disabled, name: name, children: _jsx(Combobox.Trigger, { ref: trigger, "data-slot": "select", "aria-haspopup": "dialog", "aria-label": props["aria-label"], className: cn(triggerClasses, className), onClick: () => {
101
+ setTitle(labelOf(trigger.current) || props["aria-label"] || placeholder);
102
+ setOpen(true);
103
+ }, children: triggerInner }) }), _jsxs(BottomSheet, { open: open, onClose: close, title: title, children: [_jsx("div", { className: "px-5 pb-2", children: _jsx(SearchInput, { placeholder: searchPlaceholder, value: query, loading: server?.loading, onChange: (e) => setQuery(e.target.value), onClear: () => setQuery("") }) }), _jsx(BottomSheetOptions, { children: rows.map((row) => (_jsx(BottomSheetOption, { selected: row.value === value, onSelect: () => pick(row), children: row.create !== undefined ? _jsx(AddBody, { label: row.label, phone: true }) : _jsx(OptionBody, { option: row, phone: true }) }, row.value))) }), note ? (_jsx("p", { role: "status", className: "px-5 pb-4 text-14 text-[var(--text-muted)]", children: note })) : null] })] }));
104
+ }
105
+ return (_jsxs(Combobox.Root, { items: rows, value: chosen ?? null, filter: null,
106
+ // The first match is highlighted as people type, so Enter picks it (or adds what was typed).
107
+ autoHighlight: true, itemToStringLabel: (r) => r.label, itemToStringValue: (r) => r.value, isItemEqualToValue: (a, b) => a.value === b.value, inputValue: query, onInputValueChange: (next, details) => {
108
+ // Picking an option would write its label into the field; the field is for searching only.
109
+ if (details.reason !== "item-press")
110
+ setQuery(next);
111
+ }, onValueChange: (row) => {
112
+ if (row)
113
+ pick(row);
114
+ }, open: open, onOpenChange: (next) => {
115
+ if (!next)
116
+ return close();
117
+ // The list is named by the field's label, read when it opens.
118
+ setTitle(labelOf(trigger.current) || props["aria-label"] || placeholder);
119
+ setOpen(true);
120
+ }, disabled: disabled, name: name, children: [_jsx(Combobox.Trigger, { ref: trigger, "data-slot": "select", "aria-label": props["aria-label"], className: cn(triggerClasses, className), children: triggerInner }), _jsx(Combobox.Portal, { children: _jsx(Combobox.Positioner, { side: "bottom", align: "start", sideOffset: 6, collisionPadding: 8, className: "z-[95]", children: _jsxs(Combobox.Popup, { "data-slot": "select-menu", "aria-label": title || props["aria-label"] || placeholder, className: "flex max-h-[min(380px,var(--available-height))] w-[max(var(--anchor-width),280px)] max-w-[calc(100vw-16px)] flex-col 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("div", { className: "shrink-0 p-2 pb-1", children: _jsx(Combobox.Input, { render: _jsx(SearchInput, { placeholder: searchPlaceholder, loading: server?.loading, onClear: () => setQuery("") }) }) }), _jsx(Combobox.List, { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain pb-1 empty:hidden", children: (row) => (_jsx(Combobox.Item, { value: row, "data-slot": "select-option", className: optionRow, children: row.create !== undefined ? (_jsx(AddBody, { label: row.label })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "min-w-0", children: _jsx(OptionBody, { option: row }) }), _jsx(Combobox.ItemIndicator, { className: "inline-flex shrink-0", children: _jsx(Check, { "aria-hidden": "true", className: "size-4 text-[var(--primary)]" }) })] })) }, row.value)) }), note ? (_jsx("p", { role: "status", className: "px-3 pt-1 pb-3 text-13 text-[var(--text-muted)]", children: note })) : null] }) }) })] }));
121
+ }
122
+ // The field for several values: a box holding a Tag per choice and the trigger, which fills the rest. The
123
+ // trigger is the control (FieldLabel names it); each Tag's × is its own button, never inside the trigger.
124
+ const tagsBox = cn("flex min-h-11 md:min-h-10 w-full min-w-0 flex-wrap items-center gap-1.5 rounded-lg border border-[var(--border-field)] bg-[var(--surface-primary)] py-1.5 pr-3.5 pl-2", "transition-colors duration-150 ease-out hover:border-[var(--text-muted)]", "has-[[data-slot=select]:focus-visible]:border-[var(--primary)] has-[[data-slot=select]:focus-visible]:ring-2 has-[[data-slot=select]:focus-visible]:ring-[var(--primary)]/20", "has-[[data-popup-open]]:border-[var(--primary)]", "has-[[data-invalid]]:border-[var(--error)] has-[[data-invalid]]:hover:border-[var(--error)] has-[[aria-invalid=true]]:border-[var(--error)]", "has-[[data-invalid]:focus-visible]:ring-[var(--error)]/20", "has-[[data-disabled]]:cursor-not-allowed has-[[data-disabled]]:opacity-50");
125
+ const tagsTrigger = "flex min-h-7 min-w-20 flex-1 items-center justify-between gap-2 pl-1.5 text-left text-16 md:text-14 text-[var(--text-primary)] outline-none data-[disabled]:cursor-not-allowed";
126
+ function MultipleSelect({ value, onChange, options, placeholder = "Choose", disabled = false, name, className, search, searchPlaceholder = "Search", emptyText = "No results.", onCreate, ...props }) {
127
+ const mobile = useIsMobile();
128
+ const searching = Boolean(search || onCreate);
129
+ const server = typeof search === "object" ? search : undefined;
130
+ const [ownQuery, setOwnQuery] = React.useState("");
131
+ const query = server ? server.value : ownQuery;
132
+ const setQuery = server ? server.onChange : setOwnQuery;
133
+ const [open, setOpen] = React.useState(false);
134
+ const [title, setTitle] = React.useState("");
135
+ const trigger = React.useRef(null);
136
+ // The list lines up with the whole box, not only the trigger beside the Tags.
137
+ const boxRef = React.useRef(null);
138
+ const { picked, remember } = usePicked(value, options);
139
+ const q = query.trim();
140
+ const min = server ? (server.minLength ?? 2) : 0;
141
+ const short = q.length < min;
142
+ // Before the app has something to search, the list shows what's chosen, so it can be unticked.
143
+ const found = server ? (short ? picked : options) : q ? options.filter((o) => matches(o, q)) : options;
144
+ const exact = options.some((o) => o.label.trim().toLowerCase() === q.toLowerCase());
145
+ const addRow = onCreate && q && !exact ? { value: CREATE, label: `Add “${q}”`, create: q } : null;
146
+ const rows = addRow ? [...found, addRow] : found;
147
+ const note = short && !picked.length ? `Type at least ${min} letters.` : !short && !server?.loading && !rows.length ? emptyText : null;
148
+ const toggle = (row) => {
149
+ if (row.create !== undefined) {
150
+ onCreate?.(row.create);
151
+ setQuery("");
152
+ return;
153
+ }
154
+ remember(row);
155
+ const v = row.value;
156
+ onChange(value.includes(v) ? value.filter((x) => x !== v) : [...value, v]);
157
+ };
158
+ const openList = (next) => {
159
+ if (!next) {
160
+ setOpen(false);
161
+ setQuery("");
162
+ return;
163
+ }
164
+ setTitle(labelOf(trigger.current) || props["aria-label"] || placeholder);
165
+ setOpen(true);
166
+ };
167
+ const tags = picked.map((o) => (_jsxs(Tag, { size: "sm", className: "max-w-full", children: [_jsx("span", { className: "truncate", children: o.label }), _jsx("button", { type: "button", "aria-label": `Remove ${o.label}`, disabled: disabled, onClick: () => {
168
+ onChange(value.filter((x) => x !== o.value));
169
+ // The Tag and its × go away: focus stays in the field.
170
+ trigger.current?.focus();
171
+ }, className: "-mr-1 ml-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full text-[var(--text-muted)] outline-none transition-colors hover:bg-[var(--surface-tertiary)] hover:text-[var(--text-primary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]", children: _jsx(X, { "aria-hidden": "true", className: "size-3" }) })] }, o.value)));
172
+ const triggerInner = (_jsxs(_Fragment, { children: [_jsx("span", { className: cn("min-w-0 truncate", "text-[var(--text-muted)]"), children: value.length ? "" : placeholder }), _jsx(ChevronDown, { "aria-hidden": "true", className: cn("size-4 shrink-0 text-[var(--text-muted)] transition-transform", open && "rotate-180") })] }));
173
+ // A press on the box's empty space opens the list, as on the field itself.
174
+ const box = (control) => (_jsxs("div", { ref: boxRef, "data-slot": "select-tags", className: cn(tagsBox, className), onPointerDown: (e) => {
175
+ if (e.target === e.currentTarget && !disabled) {
176
+ e.preventDefault();
177
+ trigger.current?.focus();
178
+ if (mobile)
179
+ openList(true);
180
+ else
181
+ trigger.current?.click();
182
+ }
183
+ }, children: [tags, control] }));
184
+ const row = (r) => r.create !== undefined ? (_jsx(AddBody, { label: r.label })) : (_jsxs("span", { className: "flex min-w-0 items-center gap-3", children: [_jsx(TickBox, { on: value.includes(r.value) }), _jsx(OptionBody, { option: r })] }));
185
+ const popupClass = "flex max-h-[min(380px,var(--available-height))] min-w-[var(--anchor-width)] w-[max(var(--anchor-width),280px)] max-w-[calc(100vw-16px)] flex-col 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";
186
+ // Phones: tick rows in a bottom sheet (with the search field on top when there is one).
187
+ if (mobile) {
188
+ return (_jsxs(_Fragment, { children: [box(_jsx(SelectPrimitive.Root, { multiple: true, value: value, items: options.map((o) => ({ value: o.value, label: o.label })), open: false, disabled: disabled, name: name, children: _jsx(SelectPrimitive.Trigger, { ref: trigger, "data-slot": "select", "aria-haspopup": "dialog", "aria-label": props["aria-label"], className: tagsTrigger, onClick: () => openList(true), children: triggerInner }) })), _jsxs(BottomSheet, { open: open, onClose: () => openList(false), title: title, children: [searching ? (_jsx("div", { className: "px-5 pb-2", children: _jsx(SearchInput, { placeholder: searchPlaceholder, value: query, loading: server?.loading, onChange: (e) => setQuery(e.target.value), onClear: () => setQuery("") }) })) : null, _jsx(BottomSheetOptions, { multiple: true, children: rows.map((r) => (_jsx(BottomSheetOption, { selected: value.includes(r.value), onSelect: () => toggle(r), children: r.create !== undefined ? _jsx(AddBody, { label: r.label, phone: true }) : _jsx(OptionBody, { option: r, phone: true }) }, r.value))) }), note ? (_jsx("p", { role: "status", className: "px-5 pb-4 text-14 text-[var(--text-muted)]", children: note })) : null] })] }));
189
+ }
190
+ if (!searching) {
191
+ return box(_jsxs(SelectPrimitive.Root, { multiple: true, value: value, onValueChange: (v) => onChange((v ?? [])), items: options.map((o) => ({ value: o.value, label: o.label })), disabled: disabled, name: name, open: open, onOpenChange: openList, children: [_jsx(SelectPrimitive.Trigger, { ref: trigger, "data-slot": "select", "aria-label": props["aria-label"], className: tagsTrigger, children: triggerInner }), _jsx(SelectPrimitive.Portal, { children: _jsx(SelectPrimitive.Positioner, { anchor: boxRef, side: "bottom", align: "start", sideOffset: 6, collisionPadding: 8, alignItemWithTrigger: false, className: "z-[95]", children: _jsx(SelectPrimitive.Popup, { "data-slot": "select-menu", className: cn(popupClass, "overflow-y-auto py-1"), children: _jsx(SelectPrimitive.List, { children: options.map((o) => (_jsx(SelectPrimitive.Item, { value: o.value, label: o.label, "data-slot": "select-option", className: optionRow, children: row(o) }, o.value))) }) }) }) })] }));
192
+ }
193
+ return box(_jsxs(Combobox.Root, { multiple: true, items: rows, value: picked, filter: null, autoHighlight: true, itemToStringLabel: (r) => r.label, itemToStringValue: (r) => r.value, isItemEqualToValue: (a, b) => a.value === b.value, inputValue: query, onInputValueChange: (next, details) => {
194
+ if (details.reason !== "item-press")
195
+ setQuery(next);
196
+ }, onValueChange: (next) => {
197
+ // Base UI hands back the whole new list; find the one row that was pressed.
198
+ const added = next.find((r) => !value.includes(r.value));
199
+ if (added)
200
+ return toggle(added);
201
+ const removed = picked.find((p) => !next.some((r) => r.value === p.value));
202
+ if (removed)
203
+ toggle(removed);
204
+ }, open: open, onOpenChange: openList, disabled: disabled, name: name, children: [_jsx(Combobox.Trigger, { ref: trigger, "data-slot": "select", "aria-label": props["aria-label"], className: tagsTrigger, children: triggerInner }), _jsx(Combobox.Portal, { children: _jsx(Combobox.Positioner, { anchor: boxRef, side: "bottom", align: "start", sideOffset: 6, collisionPadding: 8, className: "z-[95]", children: _jsxs(Combobox.Popup, { "data-slot": "select-menu", "aria-label": title || props["aria-label"] || placeholder, className: popupClass, children: [_jsx("div", { className: "shrink-0 p-2 pb-1", children: _jsx(Combobox.Input, { render: _jsx(SearchInput, { placeholder: searchPlaceholder, loading: server?.loading, onClear: () => setQuery("") }) }) }), _jsx(Combobox.List, { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain pb-1 empty:hidden", children: (r) => (_jsx(Combobox.Item, { value: r, "data-slot": "select-option", className: optionRow, children: row(r) }, r.value)) }), note ? (_jsx("p", { role: "status", className: "px-3 pt-1 pb-3 text-13 text-[var(--text-muted)]", children: note })) : null] }) }) })] }));
205
+ }
206
+ function AddBody({ label, phone = false }) {
207
+ return (_jsxs("span", { className: cn("flex min-w-0 items-center gap-3 font-semibold text-[var(--primary)]", phone && "text-14"), children: [_jsx(Plus, { "aria-hidden": "true", className: "size-4 shrink-0" }), _jsx("span", { className: "truncate", children: label })] }));
208
+ }
44
209
  export { Select };
@@ -0,0 +1,19 @@
1
+ declare const SIZE: {
2
+ readonly sm: "size-3.5";
3
+ readonly md: "size-4";
4
+ readonly lg: "size-6";
5
+ };
6
+ type SpinnerProps = {
7
+ /** 14, 16 (the default) or 24px. Match the text beside it: 14 by 12–13px text, 16 by 14px, 24 on its own. */
8
+ size?: keyof typeof SIZE;
9
+ /**
10
+ * What's working, said to screen readers when nothing beside the spinner says it: "Signing you in".
11
+ * Leave it out when words beside it already say what's happening ("Syncing 120 of 480…").
12
+ */
13
+ label?: string;
14
+ /** Layout only: `mx-auto`, `shrink-0`. */
15
+ className?: string;
16
+ };
17
+ declare function Spinner({ size, label, className }: SpinnerProps): import("react").JSX.Element;
18
+ export { Spinner };
19
+ export type { SpinnerProps };
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { LoaderCircle } from "lucide-react";
3
+ import { cn } from "@brdgapp/ui/lib/utils";
4
+ // Something working whose result has no shape yet: a sync running, signing you in. The same drawing as
5
+ // the spinner inside Button, IconButton, SearchInput and DataTable's pager (LoaderCircle, turning), which
6
+ // size theirs from the control.
7
+ // Survey of all 12 app repos (2026-11-19): about 380 hand-made spinners in 11 apps, all Lucide's
8
+ // Loader2 with `animate-spin` (raise 59 files, app-cc 41, app-directories 34, app-portfolio 31, together 19,
9
+ // bridge-jobs 17, app-perks-v2 13, Bridge OS 10, bridge-signup 8, app-intercom 6, chat 1; the mobile app
10
+ // uses its platform's). Sizes: 16px about 210 times, 14px about 50, 32px 22, 20px 21, 12px 18, 24px 14.
11
+ // About 97 sit beside a button's words (they become Button `loading`) and about 26 are big spinners where
12
+ // a page or card loads (they become skeletons). Approved: Aman 2026-11-19 (audit decision 5).
13
+ // Sizes on the icon scale (Iconography): 14, 16, 24. It takes the color of the text around it, and keeps
14
+ // turning with reduced motion turned on (globals.css leaves `animate-spin` alone): a still spinner reads
15
+ // as stuck.
16
+ const SIZE = { sm: "size-3.5", md: "size-4", lg: "size-6" };
17
+ function Spinner({ size = "md", label, className }) {
18
+ return (_jsxs("span", { "data-slot": "spinner", role: label ? "status" : undefined, "aria-hidden": label ? undefined : true, className: cn("inline-flex shrink-0", className), children: [_jsx(LoaderCircle, { "aria-hidden": "true", className: cn("animate-spin", SIZE[size]) }), label ? _jsx("span", { className: "sr-only", children: label }) : null] }));
19
+ }
20
+ export { Spinner };
@@ -0,0 +1,10 @@
1
+ type UseCopyOptions = {
2
+ /** The error toast when the browser blocks the copy. Default: "Couldn't copy. Try again." */
3
+ failed?: string;
4
+ };
5
+ declare function useCopy({ failed }?: UseCopyOptions): {
6
+ copied: boolean;
7
+ copy: (text: string) => Promise<boolean>;
8
+ };
9
+ export { useCopy };
10
+ export type { UseCopyOptions };
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ import { toast } from "@brdgapp/ui/components/toast";
4
+ function useCopy({ failed = "Couldn't copy. Try again." } = {}) {
5
+ const [copied, setCopied] = useState(false);
6
+ useEffect(() => {
7
+ if (!copied)
8
+ return;
9
+ const timer = setTimeout(() => setCopied(false), 1500);
10
+ return () => clearTimeout(timer);
11
+ }, [copied]);
12
+ /** Copies `text`. Resolves to `true` once it's on the clipboard, `false` (after the error toast) if not. */
13
+ async function copy(text) {
14
+ try {
15
+ await navigator.clipboard.writeText(text);
16
+ setCopied(true);
17
+ return true;
18
+ }
19
+ catch {
20
+ // Blocked: no permission, or an insecure (http) page. Nothing was copied, so never "Copied".
21
+ toast.error(failed);
22
+ return false;
23
+ }
24
+ }
25
+ return { copied, copy };
26
+ }
27
+ export { useCopy };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brdgapp/ui",
3
- "version": "1.10.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",
@@ -34,13 +34,14 @@
34
34
  "class-variance-authority": "^0.7.1",
35
35
  "clsx": "^2.1.1",
36
36
  "lucide-react": "^1.6.0",
37
+ "react-day-picker": "^10.0.2",
37
38
  "tailwind-merge": "^3.7.0"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "react": ">=19",
41
42
  "react-dom": ">=19",
42
- "tailwindcss": ">=4",
43
- "recharts": ">=3.8"
43
+ "recharts": ">=3.8",
44
+ "tailwindcss": ">=4"
44
45
  },
45
46
  "peerDependenciesMeta": {
46
47
  "recharts": {