@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.
- package/CHANGELOG.md +64 -0
- package/components/action-menu.d.ts +18 -6
- package/components/action-menu.js +27 -8
- package/components/button.d.ts +6 -1
- package/components/button.js +20 -6
- package/components/column-filter-menu.d.ts +24 -5
- package/components/column-filter-menu.js +27 -5
- package/components/column-sort-button.d.ts +3 -1
- package/components/column-sort-button.js +2 -2
- package/components/copy-field.d.ts +14 -7
- package/components/copy-field.js +25 -22
- package/components/data-table.d.ts +9 -2
- package/components/data-table.js +13 -13
- package/components/date-picker.d.ts +77 -0
- package/components/date-picker.js +367 -0
- package/components/filter-pill.d.ts +60 -5
- 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/network-graph.d.ts +1 -1
- package/components/network-graph.js +13 -5
- package/components/page-header.d.ts +35 -0
- package/components/page-header.js +23 -0
- package/components/select.d.ts +42 -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/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
Every release of `@brdgapp/ui`. Versions follow the rules in README.md → Versions.
|
|
4
4
|
|
|
5
|
+
## 1.12.0
|
|
6
|
+
|
|
7
|
+
2026-11-24. PageHeader, and a table toolbar that sits on the page. Nothing changes for apps already on 1.11.
|
|
8
|
+
|
|
9
|
+
- New: PageHeader (`components/page-header`), the top of every page: `back` ("← Back"), the 22px `title`,
|
|
10
|
+
a `subtitle`, and on the right `action` (the main button) plus at most one `secondaryAction`; on phones
|
|
11
|
+
the buttons go under the title. A page can switch on `media` (an Avatar, or an icon in a blue square), a
|
|
12
|
+
`tag` after the title, and `menu`, a ⋮ ActionMenu for the less-used actions. It replaces apps' own page
|
|
13
|
+
headers (AdminPageHeader, PageHeader, UsersPageShell, hand-made titles from 14 to 30px).
|
|
14
|
+
- New: DataTableToolbar's `onPage`, for a toolbar on the page above a grid of cards or a list that isn't in
|
|
15
|
+
a card: no side space and no divider, so its search lines up with the page's heading. A table in a card
|
|
16
|
+
keeps its toolbar inside the card. It replaces app-directories' PageToolbar.
|
|
17
|
+
- Fix: a state setter passed straight to `onChange` on FilterPill, ColumnFilterMenu or Select with
|
|
18
|
+
`multiple` (`onChange={setPicked}`) could fail to type-check. The values' type now comes from `value` and
|
|
19
|
+
`options` only.
|
|
20
|
+
- Fix: a DataTable with `addColumn` no longer logs a "unique key" warning while an app is in development.
|
|
21
|
+
- Fix: a Button with `render` (a link) draws its `icon`; it used to drop it.
|
|
22
|
+
- Fix: NetworkGraph with more than 16 people shows "+N" in the last outer place, instead of leaving the
|
|
23
|
+
rest out without a word. Its positions are rounded, so a server-drawn page no longer logs a hydration
|
|
24
|
+
warning.
|
|
25
|
+
- New: DataTableToolbar, ColumnFilterMenu and ColumnSortButton take `className`, for layout only, like the
|
|
26
|
+
other components.
|
|
27
|
+
|
|
28
|
+
## 1.11.0
|
|
29
|
+
|
|
30
|
+
2026-11-24. Spinner; DatePicker; search inside Select; picking several values; ticks in ActionMenu; password fields you can show; icons, prefixes and numbers in Input; copy on Button,
|
|
31
|
+
IconButton and CopyField. Nothing changes for apps already on 1.10, except that a password field now has its own show/hide button:
|
|
32
|
+
delete any the app drew beside it.
|
|
33
|
+
|
|
34
|
+
- New: Spinner (`components/spinner`), for work that has nothing to show yet: a sync running, an account
|
|
35
|
+
connecting, a step in progress. Put it beside the words that say what's happening; `label` names it for
|
|
36
|
+
screen readers when it stands alone. Sizes 14, 16 and 24px; it takes the color of the text around it.
|
|
37
|
+
It replaces an app's own `Loader2` with `animate-spin`, except inside a button (use `loading`) and where
|
|
38
|
+
content will appear (use Skeleton).
|
|
39
|
+
- New: an Input with `type="password"` has a show/hide button at its end, named "Show password", with
|
|
40
|
+
the same words in a Tip. `secretName="API key"` makes it "Show API key"; `reveal={false}` leaves it out.
|
|
41
|
+
- New: Input's `leadingIcon` (an icon before the value) and `prefix` (fixed text: "$", "https://"), inside
|
|
42
|
+
the field's box. They replace an icon laid over a field with `pl-10`.
|
|
43
|
+
- New: Input's `format="number"`: a whole number with commas as it's typed; `onValueChange` gets the plain
|
|
44
|
+
number, or `null` when empty. With `prefix="$"` for money. It replaces `type="number"` and apps' own
|
|
45
|
+
currency fields.
|
|
46
|
+
- New: `copy` on Button and IconButton copies text on click. The label says "Copied" with a check for 1.5
|
|
47
|
+
seconds at the same width, screen readers hear it, and a failed copy shows an error toast. `useCopy`
|
|
48
|
+
(`hooks/use-copy`) is the same behavior for a menu row.
|
|
49
|
+
- New: CopyField's `box` (one value with a copy button at its end) and `block` (several lines, Copy in the
|
|
50
|
+
corner), the kinds `link`, `code` and `text`, and `label` for the button's name.
|
|
51
|
+
- New: DatePicker (`components/date-picker`): a date typed ("Mar 4", "3/4/2026", "today") or picked from a
|
|
52
|
+
calendar whose week starts on Monday, with month and year grids to jump far back. `range` takes a start and
|
|
53
|
+
an end in one box. Values are "YYYY-MM-DD" text; `min` and `max` take a date or "today". `Calendar` is the
|
|
54
|
+
calendar alone, for a table cell's popover. It replaces `<input type="date">` and apps' own calendars. The
|
|
55
|
+
package now depends on `react-day-picker` 10.
|
|
56
|
+
- New: Select's `search`, a search field at the top of the list. `true` filters `options` as people type;
|
|
57
|
+
`{ value, onChange, loading, minLength }` means the app searches and passes its results as `options`.
|
|
58
|
+
`searchPlaceholder` and `emptyText` set its words. `onCreate` adds an Add “…” row for a value that isn't
|
|
59
|
+
listed. It replaces apps' own searchable dropdowns (cmdk Command in a Popover, Combobox, SearchableSelect).
|
|
60
|
+
- New: `multiple` on FilterPill and ColumnFilterMenu: tick several values, each tick filters at once, the
|
|
61
|
+
pill names what's on ("Tags: VC, Mutual +1") and Reset clears them. `search` (`true`, or the app's own
|
|
62
|
+
search) for a long list. `multiple` on Select: each choice is a Tag in the field with × to remove it.
|
|
63
|
+
- New: ticks in ActionMenu. An ActionMenuGroup with `value` and `onValueChange` is a pick-one choice (a sort
|
|
64
|
+
order), with a blue check at the picked row's end; choosing closes the menu. A row with `checked` and
|
|
65
|
+
`onCheckedChange` has a tick box and keeps the menu open, for showing and hiding columns.
|
|
66
|
+
- Changed: CopyField shows an error toast when the browser blocks the copy (it used to do nothing).
|
|
67
|
+
- Fix: an ActionMenuItem with `external` shows ↗ and tells screen readers it opens in a new tab.
|
|
68
|
+
|
|
5
69
|
## 1.10.0
|
|
6
70
|
|
|
7
71
|
2026-11-19. Light by default, the top bar's edges, and Lucide's current icon names. Nothing to change in an
|
|
@@ -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 { EllipsisVertical } from "lucide-react";
|
|
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";
|
|
@@ -38,20 +43,34 @@ function ActionMenu({ ariaLabel = "More options", size = "md", width = 248, alig
|
|
|
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
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/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
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
4
4
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
5
5
|
import { useRender } from "@base-ui/react/use-render";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
|
-
import { LoaderCircle } from "lucide-react";
|
|
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,30 @@ 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
|
-
// link. It
|
|
69
|
+
// link. It draws the icon like any button (audit 11.5: it used to be dropped). A link doesn't wait or
|
|
70
|
+
// copy, so `loading` and `copy` don't apply.
|
|
71
|
+
const linkBody = icon ? (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "button-icon", className: "inline-flex shrink-0", "aria-hidden": "true", children: icon }), children] })) : (children);
|
|
67
72
|
const rendered = useRender({
|
|
68
73
|
render: render,
|
|
69
74
|
enabled: render !== undefined,
|
|
70
|
-
props: mergeProps({ className: classes, "data-slot": "button" }, props, { children }),
|
|
75
|
+
props: mergeProps({ className: classes, "data-slot": "button" }, { ...props, onClick }, { children: linkBody }),
|
|
71
76
|
});
|
|
72
77
|
if (rendered)
|
|
73
78
|
return rendered;
|
|
74
|
-
|
|
79
|
+
if (copy !== undefined) {
|
|
80
|
+
const { copied } = copier;
|
|
81
|
+
// A filled button keeps its white check; on the others the check is green.
|
|
82
|
+
const filled = variant === undefined || variant === null || variant === "primary" || variant === "destructive";
|
|
83
|
+
return (_jsxs(ButtonPrimitive, { "data-slot": "button", "data-copied": copied || undefined, className: classes, disabled: disabled || loading, "aria-busy": loading || undefined, ...props, onClick: (e) => {
|
|
84
|
+
void copier.copy(copy);
|
|
85
|
+
onClick?.(e);
|
|
86
|
+
}, 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" : "" })] }));
|
|
87
|
+
}
|
|
88
|
+
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
89
|
}
|
|
76
90
|
const buttonSkeletonHeights = { xs: "h-7", sm: "h-8", md: "h-11 md:h-10", lg: "h-12" };
|
|
77
91
|
/**
|
|
@@ -1,16 +1,35 @@
|
|
|
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
|
+
/** Layout only: `ml-auto`. */
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
type SingleColumnFilterProps<T extends string> = ColumnFilterBase & {
|
|
14
|
+
multiple?: false;
|
|
10
15
|
value: T;
|
|
11
16
|
options: FilterPillOption<T>[];
|
|
12
|
-
onChange: (value: T) => void;
|
|
17
|
+
onChange: (value: NoInfer<T>) => void;
|
|
18
|
+
};
|
|
19
|
+
type MultipleColumnFilterProps<T extends string> = ColumnFilterBase & {
|
|
20
|
+
/** Several values: tick rows, each tick filters at once, Reset clears them. */
|
|
21
|
+
multiple: true;
|
|
22
|
+
/** The picked values; empty means no filter. */
|
|
23
|
+
value: T[];
|
|
24
|
+
/** The values to pick from. No "All" row. */
|
|
25
|
+
options: FilterPillOption<T>[];
|
|
26
|
+
onChange: (value: NoInfer<T>[]) => void;
|
|
27
|
+
/** A search field on top. `true` filters `options`; an object means the app searches. */
|
|
28
|
+
search?: true | FilterPillSearch;
|
|
29
|
+
searchPlaceholder?: string;
|
|
13
30
|
};
|
|
14
|
-
|
|
31
|
+
type ColumnFilterMenuProps<T extends string> = SingleColumnFilterProps<T> | MultipleColumnFilterProps<T>;
|
|
32
|
+
declare function ColumnFilterMenu<T extends string>(props: MultipleColumnFilterProps<T>): React.JSX.Element;
|
|
33
|
+
declare function ColumnFilterMenu<T extends string>(props: SingleColumnFilterProps<T>): React.JSX.Element;
|
|
15
34
|
export { ColumnFilterMenu };
|
|
16
|
-
export type { ColumnFilterMenuProps };
|
|
35
|
+
export type { ColumnFilterMenuProps, MultipleColumnFilterProps, SingleColumnFilterProps };
|
|
@@ -2,29 +2,51 @@
|
|
|
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, className, ...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)]", className);
|
|
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, className, ...rest }) {
|
|
12
34
|
const [open, setOpen] = useState(false);
|
|
13
35
|
const mobile = useIsMobile();
|
|
14
36
|
const active = options.length > 0 && value !== options[0]?.value;
|
|
15
37
|
const activeLabel = options.find((o) => o.value === value)?.label;
|
|
16
38
|
const name = `Filter by ${label.toLowerCase()}${active && activeLabel ? `: ${activeLabel}` : ""}`;
|
|
17
|
-
const triggerClass = cn(columnHeaderButton, active ? "text-[var(--primary)]" : "text-[var(--text-secondary)]");
|
|
39
|
+
const triggerClass = cn(columnHeaderButton, active ? "text-[var(--primary)]" : "text-[var(--text-secondary)]", className);
|
|
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
|
}
|
|
@@ -18,7 +18,9 @@ type ColumnSortButtonProps = ElementProps<HTMLButtonElement> & {
|
|
|
18
18
|
desc: string;
|
|
19
19
|
};
|
|
20
20
|
onClick: () => void;
|
|
21
|
+
/** Layout only: `ml-auto`. */
|
|
22
|
+
className?: string;
|
|
21
23
|
};
|
|
22
|
-
declare function ColumnSortButton({ icon: Icon, label, tooltip, direction, describe, onClick, ...rest }: ColumnSortButtonProps): import("react").JSX.Element;
|
|
24
|
+
declare function ColumnSortButton({ icon: Icon, label, tooltip, direction, describe, onClick, className, ...rest }: ColumnSortButtonProps): import("react").JSX.Element;
|
|
23
25
|
export { ColumnSortButton, columnHeaderButton };
|
|
24
26
|
export type { ColumnSortButtonProps };
|
|
@@ -14,11 +14,11 @@ import { cn } from "@brdgapp/ui/lib/utils";
|
|
|
14
14
|
* it does (⇅, ⌄); the whole thing tints on hover. 24px tall.
|
|
15
15
|
*/
|
|
16
16
|
const columnHeaderButton = "-mx-1.5 inline-flex items-center gap-1.5 rounded px-1.5 py-[3px] text-12 leading-normal font-bold whitespace-nowrap outline-none transition-colors hover:bg-[var(--surface-tertiary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]";
|
|
17
|
-
function ColumnSortButton({ icon: Icon, label, tooltip, direction, describe, onClick, ...rest }) {
|
|
17
|
+
function ColumnSortButton({ icon: Icon, label, tooltip, direction, describe, onClick, className, ...rest }) {
|
|
18
18
|
const state = direction && describe ? `, sorted ${describe[direction]}` : "";
|
|
19
19
|
return (_jsx(Tip, { text: tooltip, children: _jsxs(ButtonPrimitive, { ...rest, "data-slot": "column-sort-button", onClick: (e) => {
|
|
20
20
|
e.stopPropagation();
|
|
21
21
|
onClick();
|
|
22
|
-
}, "aria-label": `Sort by ${label.toLowerCase()}${state}`, className: cn(columnHeaderButton, direction ? "text-[var(--text-primary)]" : "text-[var(--text-secondary)]"), children: [Icon ? _jsx(Icon, { "aria-hidden": "true", className: "size-3.5 text-[var(--text-muted)]" }) : null, label, direction === "desc" ? (_jsx(ArrowDown, { "aria-hidden": "true", className: "size-3 shrink-0 text-[var(--primary)]" })) : direction === "asc" ? (_jsx(ArrowUp, { "aria-hidden": "true", className: "size-3 shrink-0 text-[var(--primary)]" })) : (_jsx(ArrowUpDown, { "aria-hidden": "true", className: "size-3 shrink-0 opacity-40" }))] }) }));
|
|
22
|
+
}, "aria-label": `Sort by ${label.toLowerCase()}${state}`, className: cn(columnHeaderButton, direction ? "text-[var(--text-primary)]" : "text-[var(--text-secondary)]", className), children: [Icon ? _jsx(Icon, { "aria-hidden": "true", className: "size-3.5 text-[var(--text-muted)]" }) : null, label, direction === "desc" ? (_jsx(ArrowDown, { "aria-hidden": "true", className: "size-3 shrink-0 text-[var(--primary)]" })) : direction === "asc" ? (_jsx(ArrowUp, { "aria-hidden": "true", className: "size-3 shrink-0 text-[var(--primary)]" })) : (_jsx(ArrowUpDown, { "aria-hidden": "true", className: "size-3 shrink-0 opacity-40" }))] }) }));
|
|
23
23
|
}
|
|
24
24
|
export { ColumnSortButton, columnHeaderButton };
|
|
@@ -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
|
}
|
|
@@ -74,14 +74,21 @@ declare function DataTable<T>({ columns, rows, rowKey, onRowClick, onRowPrefetch
|
|
|
74
74
|
* The row at the top of a table's card for finding and acting on rows: search on the left; filters, then
|
|
75
75
|
* buttons, on the right. It is not a title: the page's heading names the table. Put it outside DataState,
|
|
76
76
|
* so it stays while the rows load, fail or filter down to nothing.
|
|
77
|
+
* `onPage` (Aman 2026-11-24): the same row on the page, above a grid of cards or a list that isn't in a card
|
|
78
|
+
* (app-directories' PageToolbar). No side space and no line: the page's own margins line it up with the title.
|
|
79
|
+
* A table in a card keeps its toolbar inside the card.
|
|
77
80
|
*/
|
|
78
|
-
declare function DataTableToolbar({ search, filters, actions, ...rest }: ElementProps<HTMLDivElement> & {
|
|
81
|
+
declare function DataTableToolbar({ search, filters, actions, onPage, className, ...rest }: ElementProps<HTMLDivElement> & {
|
|
79
82
|
/** A SearchInput. It is 288px wide, the whole row on a phone. */
|
|
80
83
|
search?: React.ReactNode;
|
|
81
|
-
/** FilterPills, and
|
|
84
|
+
/** FilterPills, and one "Clear all" link (search and every filter) when any is on. */
|
|
82
85
|
filters?: React.ReactNode;
|
|
83
86
|
/** Buttons that act on the table: Export, Add people. Use Button `md`, the search's height. */
|
|
84
87
|
actions?: React.ReactNode;
|
|
88
|
+
/** On the page, above a grid of cards or a list not in a card: no side space, no line under it. */
|
|
89
|
+
onPage?: boolean;
|
|
90
|
+
/** Layout only: `sticky top-0`. */
|
|
91
|
+
className?: string;
|
|
85
92
|
}): React.JSX.Element;
|
|
86
93
|
/**
|
|
87
94
|
* The loading body for a DataTable. Takes the same column list (without `render`), so its widths and
|
package/components/data-table.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createElement as _createElement } from "react";
|
|
3
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
3
|
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
5
4
|
import * as React from "react";
|
|
@@ -57,7 +56,7 @@ function DataTable({ columns, rows, rowKey, onRowClick, onRowPrefetch, rowProps,
|
|
|
57
56
|
const [scrolled, setScrolled] = React.useState(false);
|
|
58
57
|
return (_jsx("div", { "data-slot": "data-table", "data-scrolled": scrolled ? "" : undefined, className: cn("group/table", pinned ? "overflow-auto overscroll-contain" : "overflow-x-auto"), style: pinned ? { maxHeight } : undefined, onScroll: pinFirstColumn ? (e) => setScrolled(e.currentTarget.scrollLeft > 0) : undefined,
|
|
59
58
|
// A scroll area must be reachable by keyboard so it can be scrolled with the arrow keys.
|
|
60
|
-
tabIndex: scrollArea ? 0 : undefined, "aria-label": scrollArea ? props["aria-label"] : undefined, role: scrollArea ? "region" : undefined, children: _jsxs("div", { role: "table", "aria-label": props["aria-label"], style: { minWidth: minTableWidth(columns, Boolean(addColumn)) }, children: [_jsx(HeaderRow, { columns: columns, template: template, pinned: pinned, pinFirst: pinFirstColumn, addColumn: addColumn, addRow: addRow }), _jsxs("div", { role: "rowgroup", children: [rows.map((row) => (
|
|
59
|
+
tabIndex: scrollArea ? 0 : undefined, "aria-label": scrollArea ? props["aria-label"] : undefined, role: scrollArea ? "region" : undefined, children: _jsxs("div", { role: "table", "aria-label": props["aria-label"], style: { minWidth: minTableWidth(columns, Boolean(addColumn)) }, children: [_jsx(HeaderRow, { columns: columns, template: template, pinned: pinned, pinFirst: pinFirstColumn, addColumn: addColumn, addRow: addRow }), _jsxs("div", { role: "rowgroup", children: [rows.map((row) => (_jsxs("div", { ...rowProps?.(row), role: "row", "data-slot": "data-table-row", tabIndex: onRowClick ? 0 : undefined, onClick: onRowClick
|
|
61
60
|
? (e) => {
|
|
62
61
|
// A menu opened from the row (ActionMenu) renders outside it, but React still passes
|
|
63
62
|
// its clicks up to the row. Only clicks inside the row open it.
|
|
@@ -74,23 +73,24 @@ function DataTable({ columns, rows, rowKey, onRowClick, onRowPrefetch, rowProps,
|
|
|
74
73
|
}
|
|
75
74
|
: undefined, onMouseEnter: onRowPrefetch ? () => onRowPrefetch(row) : undefined, onFocus: onRowPrefetch ? () => onRowPrefetch(row) : undefined, className: cn("group/row grid border-b border-[var(--border-divider)] transition-colors last:border-0", onRowClick
|
|
76
75
|
? "cursor-pointer outline-none hover:bg-[var(--surface-tertiary)] focus-visible:bg-[var(--surface-tertiary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-inset"
|
|
77
|
-
: "hover:bg-[var(--surface-secondary)]/40"), style: { gridTemplateColumns: template }
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
: "group-hover/row:bg-[color-mix(in_srgb,var(--surface-secondary)_40%,var(--surface-elevated))]")), children: _jsx("div", { className: "w-full min-w-0", children: c.render(row) }) }, c.key))),
|
|
85
|
-
addColumn ? _jsx("div", { role: "cell" }) : null))), addRow ? (_jsx("div", { role: "row", "data-slot": "data-table-add-row", className: "grid", style: { gridTemplateColumns: template }, children: _jsx("div", { role: "cell", "aria-colspan": count, className: "col-span-full", children: _jsx(ButtonPrimitive, { "data-slot": "data-table-add", onClick: addRow.onClick, className: "flex w-full py-3.5 pl-6 text-left text-13 leading-normal font-semibold text-[var(--text-secondary)] outline-none transition-colors hover:bg-[var(--surface-tertiary)] hover:text-[var(--text-primary)] focus-visible:bg-[var(--surface-tertiary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-inset", children: _jsxs("span", { className: "sticky left-6 flex items-center gap-1.5", children: [_jsx(Plus, { "aria-hidden": "true", className: "size-3.5 text-[var(--text-muted)]" }), addRow.action] }) }) }) })) : null] })] }) }));
|
|
76
|
+
: "hover:bg-[var(--surface-secondary)]/40"), style: { gridTemplateColumns: template }, children: [columns.map((c, i) => (_jsx("div", { role: "cell", className: cn(cellPadding(i, count), "flex min-w-0 items-center py-3.5",
|
|
77
|
+
// The pinned cell is solid and repeats the row's hover and focus, which it would otherwise cover.
|
|
78
|
+
pinFirstColumn &&
|
|
79
|
+
i === 0 &&
|
|
80
|
+
cn(PIN_FIRST, "bg-[var(--surface-elevated)] transition-colors", onRowClick
|
|
81
|
+
? "group-hover/row:bg-[var(--surface-tertiary)] group-focus-visible/row:bg-[var(--surface-tertiary)] group-focus-visible/row:shadow-[inset_2px_0_0_var(--primary),inset_0_2px_0_var(--primary),inset_0_-2px_0_var(--primary)]"
|
|
82
|
+
: "group-hover/row:bg-[color-mix(in_srgb,var(--surface-secondary)_40%,var(--surface-elevated))]")), children: _jsx("div", { className: "w-full min-w-0", children: c.render(row) }) }, c.key))), addColumn ? _jsx("div", { role: "cell" }) : null] }, rowKey(row)))), addRow ? (_jsx("div", { role: "row", "data-slot": "data-table-add-row", className: "grid", style: { gridTemplateColumns: template }, children: _jsx("div", { role: "cell", "aria-colspan": count, className: "col-span-full", children: _jsx(ButtonPrimitive, { "data-slot": "data-table-add", onClick: addRow.onClick, className: "flex w-full py-3.5 pl-6 text-left text-13 leading-normal font-semibold text-[var(--text-secondary)] outline-none transition-colors hover:bg-[var(--surface-tertiary)] hover:text-[var(--text-primary)] focus-visible:bg-[var(--surface-tertiary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-inset", children: _jsxs("span", { className: "sticky left-6 flex items-center gap-1.5", children: [_jsx(Plus, { "aria-hidden": "true", className: "size-3.5 text-[var(--text-muted)]" }), addRow.action] }) }) }) })) : null] })] }) }));
|
|
86
83
|
}
|
|
87
84
|
/**
|
|
88
85
|
* The row at the top of a table's card for finding and acting on rows: search on the left; filters, then
|
|
89
86
|
* buttons, on the right. It is not a title: the page's heading names the table. Put it outside DataState,
|
|
90
87
|
* so it stays while the rows load, fail or filter down to nothing.
|
|
88
|
+
* `onPage` (Aman 2026-11-24): the same row on the page, above a grid of cards or a list that isn't in a card
|
|
89
|
+
* (app-directories' PageToolbar). No side space and no line: the page's own margins line it up with the title.
|
|
90
|
+
* A table in a card keeps its toolbar inside the card.
|
|
91
91
|
*/
|
|
92
|
-
function DataTableToolbar({ search, filters, actions, ...rest }) {
|
|
93
|
-
return (_jsxs("div", { ...rest, "data-slot": "data-table-toolbar", className: "flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-[var(--border-divider)] px-6 py-3", children: [search ? _jsx("div", { className: "w-full md:w-72 [&>*]:w-full", children: search }) : null, filters || actions ? (
|
|
92
|
+
function DataTableToolbar({ search, filters, actions, onPage = false, className, ...rest }) {
|
|
93
|
+
return (_jsxs("div", { ...rest, "data-slot": "data-table-toolbar", "data-on-page": onPage ? "" : undefined, className: cn("flex flex-wrap items-center gap-x-3 gap-y-2", !onPage && "border-b border-[var(--border-divider)] px-6 py-3", className), children: [search ? _jsx("div", { className: "w-full md:w-72 [&>*]:w-full", children: search }) : null, filters || actions ? (
|
|
94
94
|
// Beside a search, filters and actions sit at the right. Without one, filters start at the left
|
|
95
95
|
// (a drawer's row of FilterChips) and actions stay at the right.
|
|
96
96
|
_jsxs("div", { className: cn("flex flex-1 flex-wrap items-center gap-3", search ? "md:justify-end" : ""), children: [filters ? _jsx("div", { className: "flex flex-wrap items-center gap-2", children: filters }) : null, actions ? _jsx("div", { className: cn("flex flex-wrap items-center gap-2", search ? "" : "ml-auto"), children: actions }) : null] })) : null] }));
|