@brdgapp/ui 1.9.0 → 1.11.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 +54 -1
- package/README.md +6 -1
- package/components/action-menu.d.ts +18 -6
- package/components/action-menu.js +28 -9
- package/components/app-shell.js +1 -1
- package/components/button.d.ts +6 -1
- package/components/button.js +16 -4
- package/components/column-filter-menu.d.ts +20 -4
- package/components/column-filter-menu.js +26 -4
- package/components/copy-field.d.ts +14 -7
- package/components/copy-field.js +25 -22
- package/components/data-table.d.ts +1 -1
- package/components/data-table.js +2 -2
- package/components/date-picker.d.ts +77 -0
- package/components/date-picker.js +367 -0
- package/components/filter-pill.d.ts +58 -4
- package/components/filter-pill.js +115 -10
- package/components/icon-button.d.ts +7 -1
- package/components/icon-button.js +14 -4
- package/components/input.d.ts +27 -3
- package/components/input.js +96 -3
- package/components/search-input.js +2 -2
- package/components/select.d.ts +41 -6
- package/components/select.js +167 -2
- package/components/spinner.d.ts +19 -0
- package/components/spinner.js +20 -0
- package/hooks/use-copy.d.ts +10 -0
- package/hooks/use-copy.js +27 -0
- package/hooks/use-theme.js +3 -3
- package/lib/theme.d.ts +2 -2
- package/lib/theme.js +7 -7
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
Every release of `@brdgapp/ui`. Versions follow the rules in README.md → Versions.
|
|
4
4
|
|
|
5
|
+
## 1.11.0
|
|
6
|
+
|
|
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,
|
|
8
|
+
IconButton and CopyField. Nothing changes for apps already on 1.10, except that a password field now has its own show/hide button:
|
|
9
|
+
delete any the app drew beside it.
|
|
10
|
+
|
|
11
|
+
- New: Spinner (`components/spinner`), for work that has nothing to show yet: a sync running, an account
|
|
12
|
+
connecting, a step in progress. Put it beside the words that say what's happening; `label` names it for
|
|
13
|
+
screen readers when it stands alone. Sizes 14, 16 and 24px; it takes the color of the text around it.
|
|
14
|
+
It replaces an app's own `Loader2` with `animate-spin`, except inside a button (use `loading`) and where
|
|
15
|
+
content will appear (use Skeleton).
|
|
16
|
+
- New: an Input with `type="password"` has a show/hide button at its end, named "Show password", with
|
|
17
|
+
the same words in a Tip. `secretName="API key"` makes it "Show API key"; `reveal={false}` leaves it out.
|
|
18
|
+
- New: Input's `leadingIcon` (an icon before the value) and `prefix` (fixed text: "$", "https://"), inside
|
|
19
|
+
the field's box. They replace an icon laid over a field with `pl-10`.
|
|
20
|
+
- New: Input's `format="number"`: a whole number with commas as it's typed; `onValueChange` gets the plain
|
|
21
|
+
number, or `null` when empty. With `prefix="$"` for money. It replaces `type="number"` and apps' own
|
|
22
|
+
currency fields.
|
|
23
|
+
- New: `copy` on Button and IconButton copies text on click. The label says "Copied" with a check for 1.5
|
|
24
|
+
seconds at the same width, screen readers hear it, and a failed copy shows an error toast. `useCopy`
|
|
25
|
+
(`hooks/use-copy`) is the same behavior for a menu row.
|
|
26
|
+
- New: CopyField's `box` (one value with a copy button at its end) and `block` (several lines, Copy in the
|
|
27
|
+
corner), the kinds `link`, `code` and `text`, and `label` for the button's name.
|
|
28
|
+
- New: DatePicker (`components/date-picker`): a date typed ("Mar 4", "3/4/2026", "today") or picked from a
|
|
29
|
+
calendar whose week starts on Monday, with month and year grids to jump far back. `range` takes a start and
|
|
30
|
+
an end in one box. Values are "YYYY-MM-DD" text; `min` and `max` take a date or "today". `Calendar` is the
|
|
31
|
+
calendar alone, for a table cell's popover. It replaces `<input type="date">` and apps' own calendars. The
|
|
32
|
+
package now depends on `react-day-picker` 10.
|
|
33
|
+
- New: Select's `search`, a search field at the top of the list. `true` filters `options` as people type;
|
|
34
|
+
`{ value, onChange, loading, minLength }` means the app searches and passes its results as `options`.
|
|
35
|
+
`searchPlaceholder` and `emptyText` set its words. `onCreate` adds an Add “…” row for a value that isn't
|
|
36
|
+
listed. It replaces apps' own searchable dropdowns (cmdk Command in a Popover, Combobox, SearchableSelect).
|
|
37
|
+
- New: `multiple` on FilterPill and ColumnFilterMenu: tick several values, each tick filters at once, the
|
|
38
|
+
pill names what's on ("Tags: VC, Mutual +1") and Reset clears them. `search` (`true`, or the app's own
|
|
39
|
+
search) for a long list. `multiple` on Select: each choice is a Tag in the field with × to remove it.
|
|
40
|
+
- New: ticks in ActionMenu. An ActionMenuGroup with `value` and `onValueChange` is a pick-one choice (a sort
|
|
41
|
+
order), with a blue check at the picked row's end; choosing closes the menu. A row with `checked` and
|
|
42
|
+
`onCheckedChange` has a tick box and keeps the menu open, for showing and hiding columns.
|
|
43
|
+
- Changed: CopyField shows an error toast when the browser blocks the copy (it used to do nothing).
|
|
44
|
+
- Fix: an ActionMenuItem with `external` shows ↗ and tells screen readers it opens in a new tab.
|
|
45
|
+
|
|
46
|
+
## 1.10.0
|
|
47
|
+
|
|
48
|
+
2026-11-19. Light by default, the top bar's edges, and Lucide's current icon names. Nothing to change in an
|
|
49
|
+
app's code.
|
|
50
|
+
|
|
51
|
+
- Changed: someone who hasn't chosen a theme now sees Light, not their device's setting. Light, Dark and
|
|
52
|
+
System are still the three choices in ThemeSwitch, and a saved choice is kept.
|
|
53
|
+
- Fix: AppShell's top bar has the page's edges at every width (16, then 24px from 640px, then 32px from
|
|
54
|
+
1024px), so the logo lines up with the page title between 640 and 768px.
|
|
55
|
+
- Fix: the package draws its spinner and ⋮ with Lucide's current names, `LoaderCircle` and
|
|
56
|
+
`EllipsisVertical`. They look the same.
|
|
57
|
+
|
|
5
58
|
## 1.9.0
|
|
6
59
|
|
|
7
60
|
2026-11-19. Select, and menus open inside dialogs. Nothing changes for apps already on 1.8.
|
|
@@ -32,7 +85,7 @@ Every release of `@brdgapp/ui`. Versions follow the rules in README.md → Versi
|
|
|
32
85
|
|
|
33
86
|
## 1.6.3
|
|
34
87
|
|
|
35
|
-
2026-11-17. AppShell on narrow phones.
|
|
88
|
+
2026-11-17. AppShell on narrow phones. Apps with `nav="top"` pass `logoMark` too.
|
|
36
89
|
|
|
37
90
|
- AppShell: on a phone too narrow for the full logo beside search, the launcher and your account, the top
|
|
38
91
|
bar shows `logoMark` instead, and the right of the bar no longer runs over the logo. Pass `logoMark` with
|
package/README.md
CHANGED
|
@@ -45,7 +45,12 @@ as the family is "Mulish".
|
|
|
45
45
|
If Mulish doesn't load, `<Toaster />` says so in the browser console while you develop, and the handbook's
|
|
46
46
|
`check_code` flags a root layout that doesn't load it.
|
|
47
47
|
|
|
48
|
-
Themes follow `data-theme="light"` or `data-theme="dark"` on `<html>`,
|
|
48
|
+
Themes follow `data-theme="light"` or `data-theme="dark"` on `<html>`, set before the page paints by
|
|
49
|
+
`themeScript`: Light until the person picks Light, Dark or System in ThemeSwitch.
|
|
50
|
+
|
|
51
|
+
The root layout also wraps the app in `<TipProvider>` with one `<Toaster />`, and draws AppShell, which
|
|
52
|
+
brings the skip link, the top bar and the one `<main>`. The whole layout, for Next.js and Vite:
|
|
53
|
+
https://handbook.brdg.app/using-the-system#setup
|
|
49
54
|
|
|
50
55
|
## Use
|
|
51
56
|
|
|
@@ -51,7 +51,13 @@ type ActionMenuItemProps = {
|
|
|
51
51
|
/** Red, for removing or leaving. */
|
|
52
52
|
danger?: boolean;
|
|
53
53
|
disabled?: boolean;
|
|
54
|
-
/**
|
|
54
|
+
/** In a pick-one ActionMenuGroup: what this choice is. The picked row gets a blue check, and the menu closes. */
|
|
55
|
+
value?: string;
|
|
56
|
+
/** Tick several: the row has a tick box, and the menu stays open so a few can be ticked in a row. */
|
|
57
|
+
checked?: boolean;
|
|
58
|
+
/** With `checked`: gets the row's new state. */
|
|
59
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
60
|
+
/** Whether choosing closes the menu. `false` for a row that shows its own result ("Copied"). Ticked rows stay open. */
|
|
55
61
|
closeOnClick?: boolean;
|
|
56
62
|
/**
|
|
57
63
|
* Render the link with your router's link, e.g. `render={<Link href="/settings" />}`.
|
|
@@ -60,13 +66,19 @@ type ActionMenuItemProps = {
|
|
|
60
66
|
render?: React.ReactElement;
|
|
61
67
|
className?: string;
|
|
62
68
|
};
|
|
63
|
-
declare function ActionMenuItem({ icon, children, description, onClick, href, external, danger, disabled, closeOnClick, render, className, }: ActionMenuItemProps): React.JSX.Element;
|
|
69
|
+
declare function ActionMenuItem({ icon, children, description, onClick, href, external, danger, disabled, value, checked, onCheckedChange, closeOnClick, render, className, }: ActionMenuItemProps): React.JSX.Element;
|
|
64
70
|
/** A thin line between groups of rows. */
|
|
65
71
|
declare function ActionMenuSeparator(): React.JSX.Element;
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
type ActionMenuGroupProps = {
|
|
73
|
+
/** The heading over the rows: "Sort by", "Pin column". Announced with the group. */
|
|
68
74
|
label: React.ReactNode;
|
|
75
|
+
/** Pick one: the row with this `value` gets a blue check. `null` when none is picked yet. */
|
|
76
|
+
value?: string | null;
|
|
77
|
+
/** Pick one: gets the `value` of the row chosen. Turns the rows with a `value` into choices. */
|
|
78
|
+
onValueChange?: (value: string) => void;
|
|
69
79
|
children: React.ReactNode;
|
|
70
|
-
}
|
|
80
|
+
};
|
|
81
|
+
/** Rows under a small heading ("Sort by", "Signed in as …"). With `value` and `onValueChange`, the rows are a pick-one choice. */
|
|
82
|
+
declare function ActionMenuGroup({ label, value, onValueChange, children }: ActionMenuGroupProps): React.JSX.Element;
|
|
71
83
|
export { ActionMenu, ActionMenuGroup, ActionMenuItem, ActionMenuSeparator, useActionMenu, ACTION_MENU_ITEM_CLASS };
|
|
72
|
-
export type {
|
|
84
|
+
export type { ActionMenuGroupProps, ActionMenuItemProps, ActionMenuProps };
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
4
4
|
import { Menu } from "@base-ui/react/menu";
|
|
5
|
-
import {
|
|
5
|
+
import { Check, EllipsisVertical, ExternalLink } from "lucide-react";
|
|
6
|
+
import { TickBox } from "@brdgapp/ui/components/filter-pill";
|
|
6
7
|
import { IconButton } from "@brdgapp/ui/components/icon-button";
|
|
7
8
|
import { Tip } from "@brdgapp/ui/components/info-hint";
|
|
8
9
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
@@ -12,6 +13,10 @@ import { cn } from "@brdgapp/ui/lib/utils";
|
|
|
12
13
|
// scroll instead of closing. The danger colour is now a token (Bridge OS hard-coded #E13535).
|
|
13
14
|
// Added from the app survey (2026-11-05): a Tip on the ⋮ with its name, `align="start"` (9 of the apps'
|
|
14
15
|
// 49 menus open from the left), and ActionMenuGroup for a heading over rows (DropdownMenuLabel, 16 uses).
|
|
16
|
+
// Ticks (Aman 2026-11-24, from the survey: pick one in 5 menus, like sort newest/oldest in app-cc, group by
|
|
17
|
+
// in together, pin left/right in Directories; tick several to show and hide columns in raise and Directories):
|
|
18
|
+
// a group with `value` picks one, with a blue check at the row's right end like AccountMenu's workspaces,
|
|
19
|
+
// and closes; a row with `checked` has Checkbox's tick box and keeps the menu open.
|
|
15
20
|
// The one menu-row look. Exported so custom stateful rows can match it.
|
|
16
21
|
const ACTION_MENU_ITEM_CLASS = "flex w-full cursor-default items-center gap-3 px-3.5 py-2.5 max-md:min-h-11 text-left text-13 leading-normal text-[var(--text-body)] outline-none transition-colors " +
|
|
17
22
|
"data-[highlighted]:bg-[var(--surface-secondary)] hover:bg-[var(--surface-secondary)] data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0";
|
|
@@ -36,22 +41,36 @@ function ActionMenu({ ariaLabel = "More options", size = "md", width = 248, alig
|
|
|
36
41
|
const stop = stopPropagation ? (e) => e.stopPropagation() : undefined;
|
|
37
42
|
return (_jsxs(Menu.Root, { open: open, onOpenChange: setOpenAndNotify, children: [renderTrigger ? (_jsx(Menu.Trigger, { render: (props) => renderTrigger(props, { open }) })) : (
|
|
38
43
|
// The same words as the trigger's name, in a Tip, so people who see it and people who hear it get one name.
|
|
39
|
-
_jsx(Tip, { text: ariaLabel, disabled: open, children: _jsx(Menu.Trigger, { render: _jsx(IconButton, { "aria-label": ariaLabel, size: size, className: cn("shrink-0", triggerClassName), children: icon ?? _jsx(
|
|
44
|
+
_jsx(Tip, { text: ariaLabel, disabled: open, children: _jsx(Menu.Trigger, { render: _jsx(IconButton, { "aria-label": ariaLabel, size: size, className: cn("shrink-0", triggerClassName), children: icon ?? _jsx(EllipsisVertical, {}) }), onClick: stop, onPointerDown: stop }) })), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { side: "bottom", align: align, sideOffset: 6, collisionPadding: 8, className: "z-[95]", children: _jsx(Menu.Popup, { "data-slot": "action-menu", style: { width }, className: cn("max-w-[calc(100vw-16px)] rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] py-1 shadow-[var(--shadow-menu)] outline-none", "origin-[var(--transform-origin)] transition-[opacity,scale] duration-200 ease-out data-[ending-style]:duration-150 data-[starting-style]:scale-95 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0", menuClassName), children: _jsx(ActionMenuContext.Provider, { value: ctx, children: typeof children === "function" ? children(close) : children }) }) }) })] }));
|
|
40
45
|
}
|
|
41
|
-
function ActionMenuItem({ icon, children, description, onClick, href, external = false, danger = false, disabled = false,
|
|
46
|
+
function ActionMenuItem({ icon, children, description, onClick, href, external = false, danger = false, disabled = false, value, checked, onCheckedChange, closeOnClick, render, className, }) {
|
|
47
|
+
const pickOne = useContext(PickOneContext) && value !== undefined;
|
|
48
|
+
const tick = !pickOne && checked !== undefined;
|
|
42
49
|
const classes = cn(ACTION_MENU_ITEM_CLASS, danger && ACTION_MENU_ITEM_DANGER_CLASS, description && "items-start", className);
|
|
43
|
-
const body = description ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: "mt-0.5 inline-flex shrink-0", children: icon }), _jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: cn("block text-13 leading-normal font-semibold", !danger && "text-[var(--text-primary)]"), children: children }), _jsx("span", { className: "block text-12 leading-normal text-[var(--text-muted)]", children: description })] })] })) : (_jsxs(_Fragment, { children: [icon ? (_jsx("span", { "aria-hidden": "true", className: "inline-flex shrink-0", children: icon })) : null, children] }));
|
|
50
|
+
const body = description ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: "mt-0.5 inline-flex shrink-0", children: icon }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: cn("block text-13 leading-normal font-semibold", !danger && "text-[var(--text-primary)]"), children: children }), _jsx("span", { className: "block text-12 leading-normal text-[var(--text-muted)]", children: description })] })] })) : (_jsxs(_Fragment, { children: [icon ? (_jsx("span", { "aria-hidden": "true", className: "inline-flex shrink-0", children: icon })) : null, children] }));
|
|
51
|
+
if (pickOne) {
|
|
52
|
+
return (_jsxs(Menu.RadioItem, { "data-slot": "action-menu-item", value: value, onClick: onClick, disabled: disabled, closeOnClick: closeOnClick ?? true, className: classes, children: [body, _jsx(Menu.RadioItemIndicator, { className: cn("ml-auto inline-flex shrink-0", description && "mt-0.5"), children: _jsx(Check, { "aria-hidden": "true", className: "text-[var(--primary)]" }) })] }));
|
|
53
|
+
}
|
|
54
|
+
if (tick) {
|
|
55
|
+
return (_jsxs(Menu.CheckboxItem, { "data-slot": "action-menu-item", checked: checked, onCheckedChange: (on) => onCheckedChange?.(on), onClick: onClick, disabled: disabled, closeOnClick: closeOnClick ?? false, className: classes, children: [_jsx("span", { className: cn("inline-flex shrink-0", description && "mt-0.5"), children: _jsx(TickBox, { on: checked }) }), body] }));
|
|
56
|
+
}
|
|
44
57
|
if (href && !disabled) {
|
|
45
|
-
return (
|
|
58
|
+
return (_jsxs(Menu.LinkItem, { "data-slot": "action-menu-item", href: href, closeOnClick: closeOnClick ?? true, onClick: onClick, className: classes, render: render, ...(external ? { target: "_blank", rel: "noopener noreferrer" } : {}), children: [body, external ? (_jsxs(_Fragment, { children: [_jsx(ExternalLink, { "aria-hidden": "true", className: "ml-auto size-3.5 shrink-0 text-[var(--text-muted)]" }), _jsx("span", { className: "sr-only", children: "(opens in a new tab)" })] })) : null] }));
|
|
46
59
|
}
|
|
47
|
-
return (_jsx(Menu.Item, { "data-slot": "action-menu-item", onClick: onClick, disabled: disabled, closeOnClick: closeOnClick, className: classes, children: body }));
|
|
60
|
+
return (_jsx(Menu.Item, { "data-slot": "action-menu-item", onClick: onClick, disabled: disabled, closeOnClick: closeOnClick ?? true, className: classes, children: body }));
|
|
48
61
|
}
|
|
49
62
|
/** A thin line between groups of rows. */
|
|
50
63
|
function ActionMenuSeparator() {
|
|
51
64
|
return _jsx(Menu.Separator, { "data-slot": "action-menu-separator", className: "my-1 h-px bg-[var(--border-divider)]" });
|
|
52
65
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
// Set by a pick-one group, so its rows know to be choices.
|
|
67
|
+
const PickOneContext = createContext(false);
|
|
68
|
+
/** Rows under a small heading ("Sort by", "Signed in as …"). With `value` and `onValueChange`, the rows are a pick-one choice. */
|
|
69
|
+
function ActionMenuGroup({ label, value, onValueChange, children }) {
|
|
70
|
+
const heading = _jsx(Menu.GroupLabel, { className: "px-3.5 pt-2 pb-1 text-12 leading-normal font-semibold text-[var(--text-muted)]", children: label });
|
|
71
|
+
if (onValueChange) {
|
|
72
|
+
return (_jsxs(Menu.RadioGroup, { "data-slot": "action-menu-group", value: value ?? null, onValueChange: (v) => onValueChange(v), children: [heading, _jsx(PickOneContext.Provider, { value: true, children: children })] }));
|
|
73
|
+
}
|
|
74
|
+
return (_jsxs(Menu.Group, { "data-slot": "action-menu-group", children: [heading, children] }));
|
|
56
75
|
}
|
|
57
76
|
export { ActionMenu, ActionMenuGroup, ActionMenuItem, ActionMenuSeparator, useActionMenu, ACTION_MENU_ITEM_CLASS };
|
package/components/app-shell.js
CHANGED
|
@@ -158,7 +158,7 @@ function AppShell({ logo, logoMark, homeHref = "/", items, nav = "top", breadcru
|
|
|
158
158
|
// The right of the top bar, the same in every app: search, the launcher, your account. Under 640px of bar it
|
|
159
159
|
// keeps its own width, so it never runs over the logo; the logo gives way instead (BarLogo).
|
|
160
160
|
const right = (_jsxs("div", { className: "ml-auto flex min-w-0 flex-1 items-center justify-end gap-3 pl-4 @max-[639px]/bar:flex-none md:gap-4 md:pl-8", children: [search ? _jsx("div", { className: "@container/search flex min-w-9 flex-1 items-center justify-end", children: searchSized }) : null, actions ? _jsx("div", { className: "flex shrink-0 items-center gap-2 md:gap-4", children: actions }) : null, account ? (_jsxs(_Fragment, { children: [actions || search ? _jsx("span", { "aria-hidden": "true", className: "h-6 w-px shrink-0 bg-[var(--border-default)]" }) : null, _jsx("div", { className: "flex shrink-0 items-center", children: account })] })) : null] }));
|
|
161
|
-
const topBar = (_jsx("header", { "data-slot": "app-shell-top-bar", className: "glass-chrome @container/bar sticky top-0 z-50 h-14 shrink-0 border-b border-[var(--glass-border)] bg-[var(--glass-bg)] backdrop-blur-2xl backdrop-saturate-150", children: _jsxs("nav", { "aria-label": "Top bar", className: "flex h-full items-center gap-3 px-4
|
|
161
|
+
const topBar = (_jsx("header", { "data-slot": "app-shell-top-bar", className: "glass-chrome @container/bar sticky top-0 z-50 h-14 shrink-0 border-b border-[var(--glass-border)] bg-[var(--glass-bg)] backdrop-blur-2xl backdrop-saturate-150", children: _jsxs("nav", { "aria-label": "Top bar", className: "flex h-full items-center gap-3 px-4 sm:px-6 md:gap-5 lg:px-8", children: [side ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "-ml-1.5 md:hidden", children: _jsx(IconButton, { size: "sm", "aria-label": "Open menu", "aria-expanded": menuOpen, onClick: () => setMenuOpen(true), children: _jsx(Menu, {}) }) }), _jsx(BarLogo, { logo: logo, mark: logoMark, link: (c) => logoLink(c), className: "flex-1 md:hidden" }), breadcrumbs ? _jsx("div", { className: "hidden min-w-0 shrink md:flex", children: breadcrumbs }) : null] })) : (_jsxs(_Fragment, { children: [_jsx(BarLogo, { logo: logo, mark: logoMark, link: (c) => logoLink(c), className: "shrink-0 max-md:flex-1" }), items.length ? (_jsxs(_Fragment, { children: [divider, _jsx(TopTabs, { items: items, link: link })] })) : null] })), right] }) }));
|
|
162
162
|
return (_jsxs("div", { "data-slot": "app-shell", "data-nav": nav, className: cn("flex min-h-dvh", side ? "flex-row" : "flex-col"), children: [_jsx(SkipLink, {}), side ? (_jsxs("nav", { "aria-label": "Main", "data-slot": "app-shell-side-menu", "data-collapsed": collapsed || undefined, className: cn("sticky top-0 hidden h-dvh shrink-0 flex-col border-r border-[var(--border-divider)] bg-[var(--surface-primary)] transition-[width] duration-200 ease-out motion-reduce:transition-none md:flex", collapsed ? "w-14" : "w-56"), children: [collapsed ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex h-14 shrink-0 items-center justify-center border-b border-[var(--glass-border)] [&_img]:h-4 [&_img]:w-auto [&_svg]:h-4 [&_svg]:w-auto", children: logoMark ? logoLink(logoMark) : null }), _jsx("div", { className: "flex shrink-0 justify-center pt-3", children: toggle })] })) : (_jsxs("div", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-[var(--glass-border)] pr-3 pl-4", children: [logoLink(logo), _jsx("span", { className: "ml-auto", children: toggle })] })), _jsx(SideMenu, { items: items, link: link, collapsed: collapsed, footer: sideFooter })] })) : null, _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [topBar, _jsx("main", { id: "main", tabIndex: -1, className: cn("min-w-0 flex-1 outline-none", side ? "" : "max-md:pb-[calc(56px+env(safe-area-inset-bottom))]"), children: children })] }), !side && items.length ? _jsx(BottomBar, { items: items, link: link }) : null, side ? (_jsx(DialogPrimitive.Root, { open: menuOpen, onOpenChange: setMenuOpen, children: _jsxs(DialogPrimitive.Portal, { children: [_jsx(DialogPrimitive.Backdrop, { className: "fixed inset-0 z-[60] bg-black/30 transition-opacity duration-300 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 md:hidden" }), _jsxs(DialogPrimitive.Popup, { "data-slot": "app-shell-menu-sheet", className: cn("fixed inset-y-0 left-0 z-[60] flex w-72 max-w-[85vw] flex-col bg-[var(--surface-elevated)] shadow-[var(--shadow-drawer)] outline-none md:hidden", "transition-[translate] duration-300 ease-out data-[ending-style]:-translate-x-full data-[starting-style]:-translate-x-full motion-reduce:transition-none"), children: [_jsxs("div", { className: "flex h-14 shrink-0 items-center justify-between gap-3 border-b border-[var(--border-divider)] px-4 pt-[env(safe-area-inset-top)]", children: [_jsx(DialogPrimitive.Title, { className: "sr-only", children: "Menu" }), link({ href: homeHref, onClick: () => setMenuOpen(false), className: "flex items-center rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]", children: logo }), _jsx(DialogPrimitive.Close, { render: _jsx(IconButton, { size: "sm", "aria-label": "Close menu", children: _jsx(X, {}) }) })] }), _jsx(SideMenu, { items: items, link: link, collapsed: false, footer: sideFooter, onNavigate: () => setMenuOpen(false) })] })] }) })) : null] }));
|
|
163
163
|
}
|
|
164
164
|
export { AppShell };
|
package/components/button.d.ts
CHANGED
|
@@ -12,8 +12,13 @@ type ButtonProps = Omit<ButtonPrimitive.Props, "className"> & VariantProps<typeo
|
|
|
12
12
|
icon?: React.ReactNode;
|
|
13
13
|
/** The action is running: shows a spinner, disables the button and sets `aria-busy`. */
|
|
14
14
|
loading?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Text to copy on click: the label becomes "Copied" with a check for 1.5 seconds, the button keeps its
|
|
17
|
+
* width, screen readers hear "Copied", and a failed copy shows an error toast. `onClick` still runs.
|
|
18
|
+
*/
|
|
19
|
+
copy?: string;
|
|
15
20
|
};
|
|
16
|
-
declare function Button({ className, variant, size, fullWidth, icon, loading, disabled, render, children, ...props }: ButtonProps): React.JSX.Element;
|
|
21
|
+
declare function Button({ className, variant, size, fullWidth, icon, loading, disabled, render, children, copy, onClick, ...props }: ButtonProps): React.JSX.Element;
|
|
17
22
|
declare const buttonSkeletonHeights: {
|
|
18
23
|
readonly xs: "h-7";
|
|
19
24
|
readonly sm: "h-8";
|
package/components/button.js
CHANGED
|
@@ -4,11 +4,13 @@ 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";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
|
-
import {
|
|
7
|
+
import { Check, LoaderCircle } from "lucide-react";
|
|
8
|
+
import { useCopy } from "@brdgapp/ui/hooks/use-copy";
|
|
8
9
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
9
10
|
// Started from shadcn's Base UI button (style base-nova), then moved onto Bridge's tokens and API.
|
|
10
11
|
// Look and API match Bridge OS src/components/ui/button.tsx (components.md, 2026-10-29); `asChild`
|
|
11
12
|
// became `render`. Fills use the AA-verified --primary-solid / --danger-solid, never --primary / --error.
|
|
13
|
+
// `copy` (Aman 2026-11-20): about 30 hand-made "Copy … link" buttons in 10 apps; see hooks/use-copy.ts.
|
|
12
14
|
const buttonVariants = cva([
|
|
13
15
|
"group/button inline-flex items-center gap-1.5 whitespace-nowrap font-semibold tracking-[0.4px]",
|
|
14
16
|
"transition-all duration-150 ease-out outline-none select-none",
|
|
@@ -60,18 +62,28 @@ const buttonVariants = cva([
|
|
|
60
62
|
fullWidth: false,
|
|
61
63
|
},
|
|
62
64
|
});
|
|
63
|
-
function Button({ className, variant, size, fullWidth, icon, loading = false, disabled, render, children, ...props }) {
|
|
65
|
+
function Button({ className, variant, size, fullWidth, icon, loading = false, disabled, render, children, copy, onClick, ...props }) {
|
|
64
66
|
const classes = cn(buttonVariants({ variant, size, fullWidth }), className);
|
|
67
|
+
const copier = useCopy();
|
|
65
68
|
// With `render` (for example a Next `Link`), the element keeps its own semantics: a link stays a
|
|
66
69
|
// link. It owns its content, so `icon` and `loading` don't apply.
|
|
67
70
|
const rendered = useRender({
|
|
68
71
|
render: render,
|
|
69
72
|
enabled: render !== undefined,
|
|
70
|
-
props: mergeProps({ className: classes, "data-slot": "button" }, props, { children }),
|
|
73
|
+
props: mergeProps({ className: classes, "data-slot": "button" }, { ...props, onClick }, { children }),
|
|
71
74
|
});
|
|
72
75
|
if (rendered)
|
|
73
76
|
return rendered;
|
|
74
|
-
|
|
77
|
+
if (copy !== undefined) {
|
|
78
|
+
const { copied } = copier;
|
|
79
|
+
// A filled button keeps its white check; on the others the check is green.
|
|
80
|
+
const filled = variant === undefined || variant === null || variant === "primary" || variant === "destructive";
|
|
81
|
+
return (_jsxs(ButtonPrimitive, { "data-slot": "button", "data-copied": copied || undefined, className: classes, disabled: disabled || loading, "aria-busy": loading || undefined, ...props, onClick: (e) => {
|
|
82
|
+
void copier.copy(copy);
|
|
83
|
+
onClick?.(e);
|
|
84
|
+
}, children: [_jsxs("span", { className: "inline-grid", children: [_jsxs("span", { "aria-hidden": copied || undefined, className: cn("col-start-1 row-start-1 inline-flex items-center gap-1.5", copied && "invisible"), children: [loading ? (_jsx(LoaderCircle, { "data-slot": "button-spinner", className: "animate-spin", "aria-hidden": "true" })) : icon ? (_jsx("span", { "data-slot": "button-icon", className: "inline-flex shrink-0", "aria-hidden": "true", children: icon })) : null, children] }), _jsxs("span", { "aria-hidden": "true", className: cn("col-start-1 row-start-1 inline-flex items-center justify-center gap-1.5", !copied && "invisible"), children: [_jsx(Check, { className: filled ? undefined : "text-[var(--success-text)]" }), "Copied"] })] }), _jsx("span", { className: "sr-only", "aria-live": "polite", children: copied ? "Copied" : "" })] }));
|
|
85
|
+
}
|
|
86
|
+
return (_jsxs(ButtonPrimitive, { "data-slot": "button", className: classes, disabled: disabled || loading, "aria-busy": loading || undefined, onClick: onClick, ...props, children: [loading ? (_jsx(LoaderCircle, { "data-slot": "button-spinner", className: "animate-spin", "aria-hidden": "true" })) : icon ? (_jsx("span", { "data-slot": "button-icon", className: "inline-flex shrink-0", "aria-hidden": "true", children: icon })) : null, children] }));
|
|
75
87
|
}
|
|
76
88
|
const buttonSkeletonHeights = { xs: "h-7", sm: "h-8", md: "h-11 md:h-10", lg: "h-12" };
|
|
77
89
|
/**
|
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
import { type LucideIcon } from "lucide-react";
|
|
2
|
-
import { type FilterPillOption } from "@brdgapp/ui/components/filter-pill";
|
|
2
|
+
import { type FilterPillOption, type FilterPillSearch } from "@brdgapp/ui/components/filter-pill";
|
|
3
3
|
import { type ElementProps } from "@brdgapp/ui/lib/utils";
|
|
4
|
-
type
|
|
4
|
+
type ColumnFilterBase = ElementProps<HTMLButtonElement> & {
|
|
5
5
|
/** The column's icon component. Optional: leave it out for a header with only a name. */
|
|
6
6
|
icon?: LucideIcon;
|
|
7
7
|
label: string;
|
|
8
8
|
/** Explains the column. Hidden while the menu is open. */
|
|
9
9
|
tooltip?: string;
|
|
10
|
+
};
|
|
11
|
+
type SingleColumnFilterProps<T extends string> = ColumnFilterBase & {
|
|
12
|
+
multiple?: false;
|
|
10
13
|
value: T;
|
|
11
14
|
options: FilterPillOption<T>[];
|
|
12
15
|
onChange: (value: T) => void;
|
|
13
16
|
};
|
|
14
|
-
|
|
17
|
+
type MultipleColumnFilterProps<T extends string> = ColumnFilterBase & {
|
|
18
|
+
/** Several values: tick rows, each tick filters at once, Reset clears them. */
|
|
19
|
+
multiple: true;
|
|
20
|
+
/** The picked values; empty means no filter. */
|
|
21
|
+
value: T[];
|
|
22
|
+
/** The values to pick from. No "All" row. */
|
|
23
|
+
options: FilterPillOption<T>[];
|
|
24
|
+
onChange: (value: T[]) => void;
|
|
25
|
+
/** A search field on top. `true` filters `options`; an object means the app searches. */
|
|
26
|
+
search?: true | FilterPillSearch;
|
|
27
|
+
searchPlaceholder?: string;
|
|
28
|
+
};
|
|
29
|
+
type ColumnFilterMenuProps<T extends string> = SingleColumnFilterProps<T> | MultipleColumnFilterProps<T>;
|
|
30
|
+
declare function ColumnFilterMenu<T extends string>(props: ColumnFilterMenuProps<T>): import("react").JSX.Element;
|
|
15
31
|
export { ColumnFilterMenu };
|
|
16
|
-
export type { ColumnFilterMenuProps };
|
|
32
|
+
export type { ColumnFilterMenuProps, MultipleColumnFilterProps, SingleColumnFilterProps };
|
|
@@ -2,13 +2,35 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { Menu } from "@base-ui/react/menu";
|
|
5
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
5
6
|
import { ChevronDown } from "lucide-react";
|
|
6
|
-
import {
|
|
7
|
+
import { BottomSheet } from "@brdgapp/ui/components/bottom-sheet";
|
|
8
|
+
import { FilterMenuPopup, FilterSheet, MultiPanel, SheetReset, summarize, usePicked } from "@brdgapp/ui/components/filter-pill";
|
|
7
9
|
import { useIsMobile } from "@brdgapp/ui/hooks/use-is-mobile";
|
|
8
10
|
import { Tip } from "@brdgapp/ui/components/info-hint";
|
|
9
11
|
import { columnHeaderButton } from "@brdgapp/ui/components/column-sort-button";
|
|
10
12
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
11
|
-
function ColumnFilterMenu(
|
|
13
|
+
function ColumnFilterMenu(props) {
|
|
14
|
+
return props.multiple ? _jsx(MultipleColumnFilter, { ...props }) : _jsx(SingleColumnFilter, { ...props });
|
|
15
|
+
}
|
|
16
|
+
function MultipleColumnFilter({ multiple, icon: Icon, label, tooltip, value, options, onChange, search, searchPlaceholder, ...rest }) {
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const mobile = useIsMobile();
|
|
19
|
+
const { picked, remember } = usePicked(value, options);
|
|
20
|
+
const active = value.length > 0;
|
|
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)]");
|
|
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
|
+
const panel = (phone) => (_jsx(MultiPanel, { value: value, options: options, onChange: onChange, name: label, search: search, searchPlaceholder: searchPlaceholder, picked: picked, remember: remember, phone: phone }));
|
|
25
|
+
if (mobile) {
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { ...rest, type: "button", "data-slot": "column-filter-menu", "data-multiple": multiple ? "" : undefined, "aria-haspopup": "dialog", "aria-label": name, className: triggerClass, onClick: (e) => {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
setOpen(true);
|
|
29
|
+
}, children: inner }), _jsx(BottomSheet, { open: open, onClose: () => setOpen(false), title: label, action: _jsx(SheetReset, { show: active, onReset: () => onChange([]) }), children: panel(true) })] }));
|
|
30
|
+
}
|
|
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
|
+
}
|
|
33
|
+
function SingleColumnFilter({ multiple, icon: Icon, label, tooltip, value, options, onChange, ...rest }) {
|
|
12
34
|
const [open, setOpen] = useState(false);
|
|
13
35
|
const mobile = useIsMobile();
|
|
14
36
|
const active = options.length > 0 && value !== options[0]?.value;
|
|
@@ -18,13 +40,13 @@ function ColumnFilterMenu({ icon: Icon, label, tooltip, value, options, onChange
|
|
|
18
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") })] }));
|
|
19
41
|
// Phones: a bottom sheet instead of a menu. No tooltip: touch has no hover.
|
|
20
42
|
if (mobile) {
|
|
21
|
-
return (_jsxs(_Fragment, { children: [_jsx("button", { ...rest, type: "button", "data-slot": "column-filter-menu", "aria-haspopup": "dialog", "aria-label": name, className: triggerClass, onClick: (e) => {
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { ...rest, type: "button", "data-slot": "column-filter-menu", "data-multiple": multiple ? "" : undefined, "aria-haspopup": "dialog", "aria-label": name, className: triggerClass, onClick: (e) => {
|
|
22
44
|
// A header often sits in a clickable row; keep the click here.
|
|
23
45
|
e.stopPropagation();
|
|
24
46
|
setOpen(true);
|
|
25
47
|
}, children: inner }), _jsx(FilterSheet, { open: open, onClose: () => setOpen(false), title: label, value: value, options: options, onChange: onChange })] }));
|
|
26
48
|
}
|
|
27
|
-
return (_jsxs(Menu.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Tip, { text: tooltip, disabled: open, children: _jsx(Menu.Trigger, { ...rest, "data-slot": "column-filter-menu", "aria-label": name,
|
|
49
|
+
return (_jsxs(Menu.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Tip, { text: tooltip, disabled: open, children: _jsx(Menu.Trigger, { ...rest, "data-slot": "column-filter-menu", "data-multiple": multiple ? "" : undefined, "aria-label": name,
|
|
28
50
|
// A header often sits in a clickable row; keep the click here.
|
|
29
51
|
onClick: (e) => e.stopPropagation(), className: triggerClass, children: inner }) }), _jsx(FilterMenuPopup, { value: value, options: options, onChange: onChange, width: 220, align: "start" })] }));
|
|
30
52
|
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { type ElementProps } from "@brdgapp/ui/lib/utils";
|
|
2
|
-
type
|
|
2
|
+
type CopyFieldKind = "email" | "phone" | "link" | "code" | "text";
|
|
3
|
+
type CopyFieldProps = Omit<ElementProps<HTMLButtonElement>, "children"> & {
|
|
3
4
|
value: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/** What the value is. `code` (keys, commands, snippets) and `link` are set in a fixed-width font in `box` and `block`. */
|
|
6
|
+
kind: CopyFieldKind;
|
|
7
|
+
/**
|
|
8
|
+
* `row`: a full-width contact row with a Copy hint on hover. `inline`: a compact meta item.
|
|
9
|
+
* `box`: one line in a grey box with a copy button at the end. `block`: several lines, with Copy in the corner.
|
|
10
|
+
*/
|
|
11
|
+
variant?: "row" | "inline" | "box" | "block";
|
|
12
|
+
/** What's copied, for the button's name: "server URL" makes it "Copy server URL". Defaults to the kind. */
|
|
13
|
+
label?: string;
|
|
7
14
|
/** Inline only: the stronger body colour, for a prominent identity line. */
|
|
8
15
|
strong?: boolean;
|
|
9
16
|
/** Inline only: text size. */
|
|
10
17
|
size?: 12 | 14;
|
|
11
|
-
/**
|
|
18
|
+
/** Row and inline: show the kind's icon. */
|
|
12
19
|
showIcon?: boolean;
|
|
13
20
|
className?: string;
|
|
14
21
|
};
|
|
15
|
-
declare function CopyField({ value, kind, variant, strong, size, showIcon, className, ...rest }: CopyFieldProps): import("react").JSX.Element;
|
|
22
|
+
declare function CopyField({ value, kind, variant, label, strong, size, showIcon, className, ...rest }: CopyFieldProps): import("react").JSX.Element;
|
|
16
23
|
export { CopyField };
|
|
17
|
-
export type { CopyFieldProps };
|
|
24
|
+
export type { CopyFieldKind, CopyFieldProps };
|
package/components/copy-field.js
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
3
|
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
5
|
-
import { Check, Copy, Mail, Phone } from "lucide-react";
|
|
4
|
+
import { Check, Copy, Link2, Mail, Phone, SquareCode } from "lucide-react";
|
|
5
|
+
import { Button } from "@brdgapp/ui/components/button";
|
|
6
|
+
import { IconButton } from "@brdgapp/ui/components/icon-button";
|
|
7
|
+
import { useCopy } from "@brdgapp/ui/hooks/use-copy";
|
|
6
8
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return ()
|
|
14
|
-
}, [copied]);
|
|
15
|
-
async function copy() {
|
|
16
|
-
try {
|
|
17
|
-
await navigator.clipboard.writeText(value);
|
|
18
|
-
setCopied(true);
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
// Clipboard blocked (permissions or an insecure page): nothing to undo.
|
|
22
|
-
}
|
|
9
|
+
const ICON = { email: Mail, phone: Phone, link: Link2, code: SquareCode, text: Copy };
|
|
10
|
+
const NOUN = { email: "email", phone: "phone number", link: "link", code: "code", text: "text" };
|
|
11
|
+
function CopyField({ value, kind, variant = "row", label, strong = false, size = 12, showIcon = true, className, ...rest }) {
|
|
12
|
+
const name = `Copy ${label ?? NOUN[kind]}`;
|
|
13
|
+
const fixed = kind === "code" || kind === "link";
|
|
14
|
+
if (variant === "box") {
|
|
15
|
+
return (_jsxs("div", { "data-slot": "copy-field", className: cn("flex h-11 min-w-0 items-center gap-2 rounded-lg border border-[var(--border-default)] bg-[var(--surface-secondary)] pr-1.5 pl-3.5 md:h-10", className), children: [_jsx("span", { className: cn("min-w-0 flex-1 truncate select-all text-[var(--text-primary)]", fixed ? "font-mono text-13" : "text-14"), children: value }), _jsx(IconButton, { ...rest, size: "sm", copy: value, "aria-label": name })] }));
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
if (variant === "block") {
|
|
18
|
+
// The button has its own column, so long code scrolls beside it, never under it.
|
|
19
|
+
return (_jsxs("div", { "data-slot": "copy-field", className: cn("flex min-w-0 items-start gap-2 rounded-lg border border-[var(--border-default)] bg-[var(--surface-secondary)]", className), children: [_jsx("pre", { className: cn("min-w-0 flex-1 py-3.5 pl-4 text-[var(--text-primary)]", kind === "code"
|
|
20
|
+
? "overflow-x-auto font-mono text-13 leading-[1.7] whitespace-pre"
|
|
21
|
+
: "font-sans text-14 leading-[1.625] break-words whitespace-pre-wrap"), children: value }), _jsx(Button, { ...rest, variant: "secondary", size: "xs", icon: _jsx(Copy, {}), copy: value, "aria-label": name, className: "mt-2.5 mr-2.5 shrink-0", children: "Copy" })] }));
|
|
22
|
+
}
|
|
23
|
+
return _jsx(CopyRow, { value: value, kind: kind, variant: variant, name: name, strong: strong, size: size, showIcon: showIcon, className: className, ...rest });
|
|
24
|
+
}
|
|
25
|
+
// The contact row and the inline meta item: the whole value is the button.
|
|
26
|
+
function CopyRow({ value, kind, variant, name, strong, size, showIcon, className, ...rest }) {
|
|
27
|
+
const { copied, copy } = useCopy();
|
|
28
|
+
const Icon = ICON[kind];
|
|
26
29
|
const announcement = (_jsx("span", { className: "sr-only", "aria-live": "polite", children: copied ? "Copied" : "" }));
|
|
27
30
|
if (variant === "inline") {
|
|
28
|
-
return (_jsxs(ButtonPrimitive, { ...rest, "data-slot": "copy-field", onClick: copy, "aria-label": `${
|
|
31
|
+
return (_jsxs(ButtonPrimitive, { ...rest, "data-slot": "copy-field", onClick: () => void copy(value), "aria-label": `${name}: ${value}`, className: cn(
|
|
29
32
|
// An outline with a 2px gap, so the ring clears the text without moving it (as on HoverCard).
|
|
30
33
|
"inline-flex min-w-0 items-center gap-1.5 rounded-sm outline-none transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solid focus-visible:outline-[var(--primary)]", size === 14 ? "text-14 leading-[1.625]" : "text-12 leading-[1.625]", strong
|
|
31
34
|
? "text-[var(--text-body)] hover:text-[var(--text-primary)]"
|
|
32
35
|
: "text-[var(--text-muted)] hover:text-[var(--text-secondary)]", className), children: [copied ? (_jsx(Check, { "aria-hidden": "true", className: "size-3.5 shrink-0 text-[var(--success)]" })) : showIcon ? (_jsx(Icon, { "aria-hidden": "true", className: "size-3.5 shrink-0" })) : null, _jsx("span", { className: "truncate", children: copied ? "Copied" : value }), announcement] }));
|
|
33
36
|
}
|
|
34
|
-
return (_jsxs(ButtonPrimitive, { ...rest, "data-slot": "copy-field", onClick: copy, "aria-label": `${
|
|
37
|
+
return (_jsxs(ButtonPrimitive, { ...rest, "data-slot": "copy-field", onClick: () => void copy(value), "aria-label": `${name}: ${value}`, className: cn("group flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left outline-none transition-colors", "hover:bg-[var(--surface-secondary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]", className), children: [_jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0 text-[var(--text-disabled)]" }), _jsx("span", { className: "min-w-0 flex-1 truncate text-13 leading-[1.625] text-[var(--text-body)] group-hover:text-[var(--text-primary)]", children: value }), _jsxs("span", { "aria-hidden": "true", className: cn("inline-flex shrink-0 items-center gap-1 text-12 leading-[1.625] font-semibold transition-opacity", copied
|
|
35
38
|
? "text-[var(--success-text)] opacity-100"
|
|
36
39
|
: "text-[var(--text-muted)] [@media(hover:hover)]:opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"), children: [copied ? _jsx(Check, { className: "size-3.5" }) : _jsx(Copy, { className: "size-3.5" }), copied ? "Copied" : "Copy"] }), announcement] }));
|
|
37
40
|
}
|
|
@@ -78,7 +78,7 @@ declare function DataTable<T>({ columns, rows, rowKey, onRowClick, onRowPrefetch
|
|
|
78
78
|
declare function DataTableToolbar({ search, filters, actions, ...rest }: ElementProps<HTMLDivElement> & {
|
|
79
79
|
/** A SearchInput. It is 288px wide, the whole row on a phone. */
|
|
80
80
|
search?: React.ReactNode;
|
|
81
|
-
/** FilterPills, and
|
|
81
|
+
/** FilterPills, and one "Clear all" link (search and every filter) when any is on. */
|
|
82
82
|
filters?: React.ReactNode;
|
|
83
83
|
/** Buttons that act on the table: Export, Add people. Use Button `md`, the search's height. */
|
|
84
84
|
actions?: React.ReactNode;
|
package/components/data-table.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createElement as _createElement } from "react";
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import { ChevronLeft, ChevronRight,
|
|
6
|
+
import { ChevronLeft, ChevronRight, LoaderCircle, Plus } from "lucide-react";
|
|
7
7
|
import { IconButton } from "@brdgapp/ui/components/icon-button";
|
|
8
8
|
import { Tip } from "@brdgapp/ui/components/info-hint";
|
|
9
9
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
@@ -131,6 +131,6 @@ function DataTablePagination({ page, pageSize, totalCount, loading = false, onPa
|
|
|
131
131
|
if (totalPages <= 1)
|
|
132
132
|
return null;
|
|
133
133
|
const n = (v) => v.toLocaleString("en-US");
|
|
134
|
-
return (_jsxs("nav", { "data-slot": "data-table-pagination", "aria-label": "Pages", className: "flex items-center justify-between gap-4 px-6 py-3", children: [_jsxs("p", { className: "shrink-0 text-12 leading-normal tabular-nums text-[var(--text-muted)]", children: [n((page - 1) * pageSize + 1), "\u2013", n(Math.min(page * pageSize, totalCount)), " of ", n(totalCount)] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(ButtonPrimitive, { onClick: () => onPageChange(page - 1), disabled: page === 1 || loading, "aria-label": "Previous page", className: pagerButton, children: _jsx(ChevronLeft, { "aria-hidden": "true", className: "size-3.5" }) }), pageList(page, totalPages).map((p, i) => p === "…" ? (_jsx("span", { "aria-hidden": "true", className: "flex size-7 items-center justify-center text-12 text-[var(--text-muted)]", children: "\u2026" }, `gap-${i}`)) : (_jsx(ButtonPrimitive, { onClick: () => onPageChange(p), disabled: loading, "aria-label": `Page ${p}`, "aria-current": p === page ? "page" : undefined, className: cn(pagerButton, "w-auto min-w-7 px-1.5 text-12 font-semibold tabular-nums disabled:opacity-100", p === page && "bg-[var(--primary-solid)] text-white hover:bg-[var(--primary-solid)] hover:text-white"), children: loading && p === page ? _jsx(
|
|
134
|
+
return (_jsxs("nav", { "data-slot": "data-table-pagination", "aria-label": "Pages", className: "flex items-center justify-between gap-4 px-6 py-3", children: [_jsxs("p", { className: "shrink-0 text-12 leading-normal tabular-nums text-[var(--text-muted)]", children: [n((page - 1) * pageSize + 1), "\u2013", n(Math.min(page * pageSize, totalCount)), " of ", n(totalCount)] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(ButtonPrimitive, { onClick: () => onPageChange(page - 1), disabled: page === 1 || loading, "aria-label": "Previous page", className: pagerButton, children: _jsx(ChevronLeft, { "aria-hidden": "true", className: "size-3.5" }) }), pageList(page, totalPages).map((p, i) => p === "…" ? (_jsx("span", { "aria-hidden": "true", className: "flex size-7 items-center justify-center text-12 text-[var(--text-muted)]", children: "\u2026" }, `gap-${i}`)) : (_jsx(ButtonPrimitive, { onClick: () => onPageChange(p), disabled: loading, "aria-label": `Page ${p}`, "aria-current": p === page ? "page" : undefined, className: cn(pagerButton, "w-auto min-w-7 px-1.5 text-12 font-semibold tabular-nums disabled:opacity-100", p === page && "bg-[var(--primary-solid)] text-white hover:bg-[var(--primary-solid)] hover:text-white"), children: loading && p === page ? _jsx(LoaderCircle, { "aria-hidden": "true", className: "mx-auto size-3 animate-spin" }) : p }, p))), _jsx(ButtonPrimitive, { onClick: () => onPageChange(page + 1), disabled: page === totalPages || loading, "aria-label": "Next page", className: pagerButton, children: _jsx(ChevronRight, { "aria-hidden": "true", className: "size-3.5" }) })] })] }));
|
|
135
135
|
}
|
|
136
136
|
export { DataTable, DataTableHeader, DataTableSkeleton, DataTablePagination, DataTableToolbar };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** A date as "YYYY-MM-DD", the way the browser's date field and a database write it. */
|
|
3
|
+
type DateString = string;
|
|
4
|
+
/** A from–to range. Either end is `null` until it's picked. */
|
|
5
|
+
type DateRangeValue = {
|
|
6
|
+
start: DateString | null;
|
|
7
|
+
end: DateString | null;
|
|
8
|
+
};
|
|
9
|
+
/** A limit: "YYYY-MM-DD", or "today". */
|
|
10
|
+
type DateLimit = DateString | "today";
|
|
11
|
+
type CalendarSingleProps = {
|
|
12
|
+
range?: false;
|
|
13
|
+
/** The picked day, "YYYY-MM-DD". */
|
|
14
|
+
value?: DateString | null;
|
|
15
|
+
/** Called with the day that was picked. */
|
|
16
|
+
onValueChange?: (value: DateString) => void;
|
|
17
|
+
};
|
|
18
|
+
type CalendarRangeProps = {
|
|
19
|
+
/** Pick a start day, then an end day. */
|
|
20
|
+
range: true;
|
|
21
|
+
value?: DateRangeValue;
|
|
22
|
+
/** Called after each pick: first `{ start, end: null }`, then both. */
|
|
23
|
+
onValueChange?: (value: DateRangeValue) => void;
|
|
24
|
+
};
|
|
25
|
+
type CalendarProps = (CalendarSingleProps | CalendarRangeProps) & {
|
|
26
|
+
/** The earliest day that can be picked: "YYYY-MM-DD" or "today". */
|
|
27
|
+
min?: DateLimit;
|
|
28
|
+
/** The latest day that can be picked: "YYYY-MM-DD" or "today" (no future dates). */
|
|
29
|
+
max?: DateLimit;
|
|
30
|
+
/** Focus the picked day (or today) when it appears, as it does when DatePicker opens it. */
|
|
31
|
+
autoFocus?: boolean;
|
|
32
|
+
/** Layout only. */
|
|
33
|
+
className?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The calendar on its own, for a place that has no field: a table cell's popover. In a form, use
|
|
37
|
+
* DatePicker, which opens this from its calendar button. Weeks start on Monday.
|
|
38
|
+
*/
|
|
39
|
+
declare function Calendar(props: CalendarProps): React.JSX.Element;
|
|
40
|
+
type FieldBits = {
|
|
41
|
+
/** The earliest date allowed: "YYYY-MM-DD" or "today". Earlier days are greyed out, and a typed one is an error. */
|
|
42
|
+
min?: DateLimit;
|
|
43
|
+
/** The latest date allowed: "YYYY-MM-DD" or "today" (no future dates). */
|
|
44
|
+
max?: DateLimit;
|
|
45
|
+
/** Can't be typed in or opened. */
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/** Sends the value with a form as "YYYY-MM-DD". A range sends two: `name` + "Start" and `name` + "End". */
|
|
48
|
+
name?: string;
|
|
49
|
+
/** Only outside a Field. Inside one, the FieldLabel names it. */
|
|
50
|
+
"aria-label"?: string;
|
|
51
|
+
/** Layout only: `max-w-60`. */
|
|
52
|
+
className?: string;
|
|
53
|
+
};
|
|
54
|
+
type SingleDatePickerProps = FieldBits & {
|
|
55
|
+
range?: false;
|
|
56
|
+
/** The date, "YYYY-MM-DD", or `null` for none. */
|
|
57
|
+
value?: DateString | null;
|
|
58
|
+
defaultValue?: DateString | null;
|
|
59
|
+
/** Called with "YYYY-MM-DD" once a date is picked or typed (when the field is left or Enter is pressed), or `null` when it's emptied or can't be read. */
|
|
60
|
+
onValueChange?: (value: DateString | null) => void;
|
|
61
|
+
};
|
|
62
|
+
type RangeDatePickerProps = FieldBits & {
|
|
63
|
+
/** A from–to range: two dates in one box, one calendar. */
|
|
64
|
+
range: true;
|
|
65
|
+
value?: DateRangeValue;
|
|
66
|
+
defaultValue?: DateRangeValue;
|
|
67
|
+
/** Called with `{ start, end }`, each "YYYY-MM-DD" or `null`. */
|
|
68
|
+
onValueChange?: (value: DateRangeValue) => void;
|
|
69
|
+
};
|
|
70
|
+
type DatePickerProps = SingleDatePickerProps | RangeDatePickerProps;
|
|
71
|
+
/**
|
|
72
|
+
* A date field: type a date ("Mar 4", "3/4/2026", "today") or pick it from the calendar button at its
|
|
73
|
+
* end. `range` makes it a from–to pair in one box. Put it in a Field with a FieldLabel.
|
|
74
|
+
*/
|
|
75
|
+
declare function DatePicker(props: DatePickerProps): React.JSX.Element;
|
|
76
|
+
export { Calendar, DatePicker };
|
|
77
|
+
export type { CalendarProps, DateLimit, DatePickerProps, DateRangeValue, DateString, RangeDatePickerProps, SingleDatePickerProps };
|