@brdgapp/ui 1.2.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  Every release of `@brdgapp/ui`. Versions follow the rules in README.md → Versions.
4
4
 
5
+ ## 1.4.0
6
+
7
+ 2026-11-12. Three new components. Nothing changes for apps already on 1.3, so they can update without changes.
8
+
9
+ - New: GlobalSearch (`components/global-search`), the ⌘K search for every app. `GlobalSearchTrigger` is the
10
+ search field in the top bar and owns ⌘K (Ctrl+K). `GlobalSearch` shows each kind of thing in its own list,
11
+ two side by side and a third on a row below, with recents or suggestions before anything is typed. ↑ ↓ move
12
+ through the results, as in shadcn's Command. Bridge OS's search overlay, and shadcn's CommandDialog in raise
13
+ and app-portfolio, become this.
14
+ - New: Popover (`components/popover`), a panel that opens from a button: 320px, or `wide` 460px, with an
15
+ optional heading and one link beside it. On a phone it opens as a BottomSheet. For the account menu and the
16
+ app launcher.
17
+ - New: AppLauncher (`components/app-launcher`), the 9-dot button in the top bar that opens every Bridge app in
18
+ one grid. Each app passes in the `apps` it loads from Bridge's app list; icons can be the database's SVG markup.
19
+ - BottomSheet: `action`, one link or small button beside the title.
20
+
21
+ ## 1.3.0
22
+
23
+ 2026-11-12. Six additions Bridge OS asked for, each found in other apps too. Nothing changes for apps already on
24
+ 1.2, so they can update without changes.
25
+
26
+ - SearchInput: `loading` shows a small spinner in the clear button's place while results come from the server,
27
+ and screen readers hear "Searching".
28
+ - DataState: `DataStateEmpty` and `DataStateError` can be used on their own, for a page that already knows its
29
+ answer (a not-found page) and from a server component.
30
+ - Card: `external` opens an `href` card in a new tab, and screen readers hear "Opens in a new tab".
31
+ - Dialog: `cancelLabel={null}` leaves out Cancel, for a notice people only acknowledge ("Got it").
32
+ - Skeleton: `width` for a width worked out in code (`120`, `"60%"`).
33
+ - BrandMark: the X logo (`brand="x"`), always one color like Apple's.
34
+
5
35
  ## 1.2.1
6
36
 
7
37
  2026-11-10. A small addition that changes nothing an app relies on.
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+ type AppLauncherApp = {
3
+ /** Unique: "intros", "raise". */
4
+ id: string;
5
+ /** The app's name, without a version: "Intros", "Raise". */
6
+ name: string;
7
+ /** Where it opens: "https://raise.brdg.app". */
8
+ href: string;
9
+ /** A Lucide icon, or the SVG markup the database stores (`icon_svg`). Drawn in Royal either way. */
10
+ icon: React.ReactNode | string;
11
+ /** Still in beta: a small flask on the icon. */
12
+ beta?: boolean;
13
+ };
14
+ type AppLauncherProps = {
15
+ /** The apps to show, in order. Leave out the app it's in and anything not ready yet. */
16
+ apps: AppLauncherApp[];
17
+ /** A page listing every app with more detail: a "See more" link in the heading. */
18
+ moreHref?: string;
19
+ };
20
+ declare function AppLauncher({ apps, moreHref }: AppLauncherProps): React.JSX.Element;
21
+ export { AppLauncher };
22
+ export type { AppLauncherApp, AppLauncherProps };
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { FlaskConical } from "lucide-react";
5
+ import { Button } from "@brdgapp/ui/components/button";
6
+ import { IconButton } from "@brdgapp/ui/components/icon-button";
7
+ import { Popover } from "@brdgapp/ui/components/popover";
8
+ import { cn } from "@brdgapp/ui/lib/utils";
9
+ function AppIcon({ icon }) {
10
+ // Markup from the database: only an <svg>, drawn with currentColor.
11
+ if (typeof icon === "string") {
12
+ return icon.trimStart().startsWith("<svg") ? (_jsx("span", { "aria-hidden": "true", className: "flex size-[18px] [&>svg]:size-full", dangerouslySetInnerHTML: { __html: icon } })) : null;
13
+ }
14
+ return (_jsx("span", { "aria-hidden": "true", className: "flex [&>svg]:size-[18px]", children: icon }));
15
+ }
16
+ function AppLauncher({ apps, moreHref }) {
17
+ const [open, setOpen] = React.useState(false);
18
+ return (_jsx(Popover, { open: open, onOpenChange: setOpen, title: "All apps", size: "wide", align: "end", action: moreHref ? (_jsx(Button, { variant: "link", size: "xs", render: _jsx("a", { href: moreHref, onClick: () => setOpen(false) }), children: "See more" })) : undefined, trigger: _jsx(IconButton, { size: "sm", "aria-label": "Open app launcher", "data-slot": "app-launcher-trigger", children: _jsx("svg", { viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: [1, 6, 11].flatMap((y) => [1, 6, 11].map((x) => _jsx("rect", { x: x, y: y, width: "4", height: "4", rx: "1" }, `${x}-${y}`))) }) }), children: _jsx("ul", { "data-slot": "app-launcher", className: "-m-2 grid grid-cols-3 gap-2", children: apps.map((app) => (_jsx("li", { children: _jsxs("a", { href: app.href, onClick: () => setOpen(false), className: cn("flex flex-col items-center gap-2 rounded-xl p-3 text-center transition-colors outline-none", "hover:bg-[var(--surface-secondary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]"), children: [_jsxs("span", { className: "relative flex size-10 shrink-0 items-center justify-center rounded-xl bg-[var(--info-bg)] text-[var(--primary)]", children: [_jsx(AppIcon, { icon: app.icon }), app.beta ? (_jsx("span", { className: "absolute -right-1 -bottom-1 flex size-4 items-center justify-center rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--purple)]", children: _jsx(FlaskConical, { "aria-hidden": "true", className: "size-2.5 text-white" }) })) : null] }), _jsxs("span", { className: "line-clamp-2 text-12 leading-tight font-semibold text-[var(--text-primary)]", children: [app.name, app.beta ? _jsx("span", { className: "sr-only", children: ", beta" }) : null] })] }) }, app.id))) }) }));
19
+ }
20
+ export { AppLauncher };
@@ -11,8 +11,10 @@ type BottomSheetProps = {
11
11
  primaryAction?: DialogAction;
12
12
  /** The footer button that closes without applying. Default "Cancel". Shown with `primaryAction`. */
13
13
  cancelLabel?: string;
14
+ /** One link or small button beside the title, like a Popover's "See all" on a phone. */
15
+ action?: React.ReactNode;
14
16
  };
15
- declare function BottomSheet({ open, onClose, title, children, primaryAction, cancelLabel }: BottomSheetProps): React.JSX.Element;
17
+ declare function BottomSheet({ open, onClose, title, children, primaryAction, cancelLabel, action }: BottomSheetProps): React.JSX.Element;
16
18
  /**
17
19
  * The options in a sheet. One choice (default): a list where ↑ and ↓ move and Enter picks; Tab enters at the
18
20
  * chosen row. `multiple`: a checkbox per row, ticked and unticked until Apply.
@@ -11,7 +11,7 @@ const SheetContext = React.createContext({ titleId: "" });
11
11
  const CLOSE_AT = 1 / 3;
12
12
  /** Or how fast, in px per ms: a quick flick closes it from anywhere. */
13
13
  const FLICK = 0.5;
14
- function BottomSheet({ open, onClose, title, children, primaryAction, cancelLabel = "Cancel" }) {
14
+ function BottomSheet({ open, onClose, title, children, primaryAction, cancelLabel = "Cancel", action }) {
15
15
  const titleId = React.useId();
16
16
  const popup = React.useRef(null);
17
17
  const start = React.useRef(null);
@@ -47,7 +47,7 @@ function BottomSheet({ open, onClose, title, children, primaryAction, cancelLabe
47
47
  }, onPointerMove: (e) => {
48
48
  if (start.current)
49
49
  setDrag(Math.max(0, e.clientY - start.current.y));
50
- }, onPointerUp: (e) => endDrag(e.clientY), onPointerCancel: (e) => endDrag(e.clientY), children: [_jsx("div", { "aria-hidden": "true", className: "mx-auto mt-2 h-1 w-10 rounded-full bg-[var(--border-hover)]" }), _jsx(DialogPrimitive.Title, { id: titleId, className: "px-5 pt-3 pb-2 text-16 font-bold tracking-tight text-[var(--text-primary)]", children: title })] }), _jsx("div", { "data-slot": "bottom-sheet-body", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: _jsx(SheetContext.Provider, { value: { titleId }, children: children }) }), primaryAction ? (_jsxs("footer", { "data-slot": "bottom-sheet-footer", className: "flex shrink-0 gap-2 border-t border-[var(--border-divider)] px-5 pt-3 pb-[max(12px,env(safe-area-inset-bottom))]", children: [_jsx(Button, { variant: "secondary", size: "md", onClick: onClose, className: "flex-1", children: cancelLabel }), _jsx(Button, { size: "md", disabled: primaryAction.disabled, icon: primaryAction.icon, onClick: primaryAction.onClick, className: "flex-1", children: primaryAction.label })] })) : null] })] }) }));
50
+ }, onPointerUp: (e) => endDrag(e.clientY), onPointerCancel: (e) => endDrag(e.clientY), children: [_jsx("div", { "aria-hidden": "true", className: "mx-auto mt-2 h-1 w-10 rounded-full bg-[var(--border-hover)]" }), _jsxs("div", { className: "flex items-center gap-3 px-5 pt-3 pb-2", children: [_jsx(DialogPrimitive.Title, { id: titleId, className: "min-w-0 flex-1 text-16 font-bold tracking-tight text-[var(--text-primary)]", children: title }), action ? (_jsx("div", { className: "shrink-0", onPointerDown: (e) => e.stopPropagation(), children: action })) : null] })] }), _jsx("div", { "data-slot": "bottom-sheet-body", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: _jsx(SheetContext.Provider, { value: { titleId }, children: children }) }), primaryAction ? (_jsxs("footer", { "data-slot": "bottom-sheet-footer", className: "flex shrink-0 gap-2 border-t border-[var(--border-divider)] px-5 pt-3 pb-[max(12px,env(safe-area-inset-bottom))]", children: [_jsx(Button, { variant: "secondary", size: "md", onClick: onClose, className: "flex-1", children: cancelLabel }), _jsx(Button, { size: "md", disabled: primaryAction.disabled, icon: primaryAction.icon, onClick: primaryAction.onClick, className: "flex-1", children: primaryAction.label })] })) : null] })] }) }));
51
51
  }
52
52
  const OptionsContext = React.createContext({ multiple: false, tabStop: 0, index: 0 });
53
53
  /**
@@ -1,4 +1,4 @@
1
- export type Brand = "linkedin" | "google" | "microsoft" | "apple" | "whatsapp" | "telegram" | "chrome";
1
+ export type Brand = "linkedin" | "x" | "google" | "microsoft" | "apple" | "whatsapp" | "telegram" | "chrome";
2
2
  declare const NAME: Record<Brand, string>;
3
3
  type BrandMarkProps = {
4
4
  brand: Brand;
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from "@brdgapp/ui/lib/utils";
3
3
  /** Brands whose own rules allow a one-color version. Google, Microsoft and Chrome are always in color. */
4
- const CAN_BE_MONO = new Set(["linkedin", "whatsapp", "telegram", "apple"]);
4
+ const CAN_BE_MONO = new Set(["linkedin", "x", "whatsapp", "telegram", "apple"]);
5
5
  const NAME = {
6
6
  linkedin: "LinkedIn",
7
+ x: "X",
7
8
  google: "Google",
8
9
  microsoft: "Microsoft",
9
10
  apple: "Apple",
@@ -12,6 +13,7 @@ const NAME = {
12
13
  chrome: "Chrome",
13
14
  };
14
15
  const LINKEDIN = "M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z";
16
+ const X_LOGO = "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.744l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z";
15
17
  const APPLE = "M16.365 1.43c0 1.14-.415 2.205-1.19 3.03-.81.87-2.145 1.54-3.28 1.45-.145-1.09.42-2.24 1.17-3.02.81-.85 2.205-1.47 3.3-1.46zM20.7 17.39c-.52 1.2-.77 1.73-1.44 2.79-.94 1.45-2.26 3.26-3.9 3.28-1.46.02-1.84-.95-3.82-.94-1.99.01-2.4.96-3.86.94-1.64-.02-2.89-1.65-3.83-3.1C1.88 17.42.5 12.84 2.4 9.64c.95-1.6 2.45-2.61 4.14-2.61 1.54 0 2.51.99 3.79.99 1.24 0 2-.99 3.8-.99 1.52 0 3.13.83 4.07 2.26-3.58 1.97-3 7.1.5 8.1z";
16
18
  const WHATSAPP_RING = "M360,0C161.18,0,0,161.18,0,360c0,65.41,17.45,126.75,47.94,179.61L0,720l187.02-44.21c51.34,28.18,110.28,44.21,172.98,44.21,198.82,0,360-161.18,360-360S558.82,0,360,0ZM360,655.52c-60.17,0-116.13-17.98-162.82-48.87l-110.49,28.14,30.99-105.61c-33.53-47.93-53.2-106.26-53.2-169.19,0-163.21,132.31-295.52,295.52-295.52s295.52,132.31,295.52,295.52-132.31,295.52-295.52,295.52Z";
17
19
  const WHATSAPP_PHONE = "M444.35,407.52l87.1,41.06c4,1.88,6.56,5.94,6.2,10.34-.94,11.46-5.54,34.43-26.13,55.02-58.12,58.12-162.49-7.64-166.74-10.18-25.67-13.79-50.06-32.24-73.19-55.36-23.12-23.12-41.58-47.52-55.37-73.19-2.55-4.24-68.31-108.61-10.18-166.74,20.59-20.59,43.56-25.19,55.02-26.13,4.41-.36,8.46,2.2,10.34,6.2l41.07,87.1c1.94,4.12,1.09,9.02-2.13,12.24l-30.61,30.61c-6.62,6.62-8.56,16.93-4,25.11,11.17,20.03,26.19,39.32,43.59,57.07,17.75,17.4,37.04,32.43,57.07,43.59,8.18,4.56,18.48,2.62,25.11-4l30.61-30.61c3.22-3.22,8.12-4.08,12.24-2.13Z";
@@ -21,6 +23,9 @@ function Drawing({ brand, mono }) {
21
23
  switch (brand) {
22
24
  case "linkedin":
23
25
  return (_jsxs("svg", { viewBox: "0 0 24 24", children: [mono ? null : _jsx("rect", { x: "2", y: "2", width: "20", height: "20", fill: "#fff" }), _jsx("path", { d: LINKEDIN, fill: mono ? "currentColor" : "#0A66C2" })] }));
26
+ case "x":
27
+ // X's mark is one color, like Apple's: it follows the text, black on light and white on dark.
28
+ return (_jsx("svg", { viewBox: "0 0 24 24", children: _jsx("path", { d: X_LOGO, fill: "currentColor" }) }));
24
29
  case "google":
25
30
  return (_jsxs("svg", { viewBox: "0 0 48 48", children: [_jsx("path", { fill: "#FFC107", d: "M43.611 20.083H42V20H24v8h11.303c-1.649 4.657-6.08 8-11.303 8-6.627 0-12-5.373-12-12s5.373-12 12-12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 12.955 4 4 12.955 4 24s8.955 20 20 20 20-8.955 20-20c0-1.341-.138-2.65-.389-3.917z" }), _jsx("path", { fill: "#FF3D00", d: "M6.306 14.691l6.571 4.819C14.655 15.108 18.961 12 24 12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 16.318 4 9.656 8.337 6.306 14.691z" }), _jsx("path", { fill: "#4CAF50", d: "M24 44c5.166 0 9.86-1.977 13.409-5.192l-6.19-5.238C29.211 35.091 26.715 36 24 36c-5.202 0-9.619-3.317-11.283-7.946l-6.522 5.025C9.505 39.556 16.227 44 24 44z" }), _jsx("path", { fill: "#1976D2", d: "M43.611 20.083H42V20H24v8h11.303c-.792 2.237-2.231 4.166-4.087 5.571.001-.001.002-.001.003-.002l6.19 5.238C36.971 39.205 44 34 44 24c0-1.341-.138-2.65-.389-3.917z" })] }));
26
31
  case "microsoft":
@@ -12,6 +12,8 @@ type CardProps = VariantProps<typeof cardVariants> & {
12
12
  href?: string;
13
13
  /** Your router's link (Next `Link`) for `href`. A plain `<a>` by default. */
14
14
  linkAs?: React.ElementType;
15
+ /** With `href`: opens in a new tab, for another site or another Bridge app. Screen readers hear "opens in a new tab". */
16
+ external?: boolean;
15
17
  /** The whole card picks this item, usually to open it in a pane. It tints on hover. */
16
18
  onSelect?: () => void;
17
19
  /** The picked card: blue border and tint. Use with `onSelect`. */
@@ -24,7 +26,7 @@ type CardProps = VariantProps<typeof cardVariants> & {
24
26
  className?: string;
25
27
  children?: React.ReactNode;
26
28
  };
27
- declare function Card({ size, flush, bare, href, linkAs: LinkComponent, onSelect, selected, disabled, label, className, children, }: CardProps): React.JSX.Element;
29
+ declare function Card({ size, flush, bare, href, linkAs: LinkComponent, external, onSelect, selected, disabled, label, className, children, }: CardProps): React.JSX.Element;
28
30
  declare const ICON_COLOR: {
29
31
  readonly blue: "bg-[var(--primary)]/8 text-[var(--primary)]";
30
32
  readonly green: "bg-[var(--success)]/8 text-[var(--success-text)]";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { cva } from "class-variance-authority";
5
5
  import { InfoHint } from "@brdgapp/ui/components/info-hint";
@@ -19,6 +19,8 @@ import { cn } from "@brdgapp/ui/lib/utils";
19
19
  // work as usual. So no screen writes stopPropagation (the apps do, over 300 times).
20
20
  // - Hover by job (Aman): links rise 2px with a soft shadow (Elevation); selectable cards tint, since a
21
21
  // list of rising cards jumps about.
22
+ // - `external` (2026-11-12, asked for by Bridge OS; new-tab card links in 10 of the 12 apps): `href` opens in a
23
+ // new tab, with the same name as ActionMenu's. The card still rises on hover like any link card.
22
24
  // - `selected`: a blue border and a light blue tint, what app-cc, app-intercom and app-portfolio already
23
25
  // use; announced with aria-current.
24
26
  // - No colored edge bars or strips (Aman): status goes in a Tag in the header, word and color together.
@@ -35,13 +37,14 @@ const cardVariants = cva("relative block text-[var(--text-body)]", {
35
37
  defaultVariants: { size: "lg" },
36
38
  });
37
39
  const CardContext = React.createContext(null);
38
- function Card({ size, flush = false, bare = false, href, linkAs: LinkComponent = "a", onSelect, selected = false, disabled = false, label, className, children, }) {
40
+ function Card({ size, flush = false, bare = false, href, linkAs: LinkComponent = "a", external = false, onSelect, selected = false, disabled = false, label, className, children, }) {
39
41
  const titleId = React.useId();
40
42
  const clickable = href ? "link" : onSelect ? "select" : undefined;
41
43
  const nameProps = label ? { "aria-label": label } : { "aria-labelledby": titleId };
44
+ const newTabId = `${titleId}-new-tab`;
42
45
  let cover = null;
43
46
  if (clickable === "link" && !disabled) {
44
- cover = _jsx(LinkComponent, { "data-card-cover": "", href: href, "aria-current": selected ? "page" : undefined, ...nameProps });
47
+ cover = (_jsxs(_Fragment, { children: [_jsx(LinkComponent, { "data-card-cover": "", href: href, "aria-current": selected ? "page" : undefined, ...nameProps, ...(external ? { target: "_blank", rel: "noopener noreferrer", "aria-describedby": newTabId } : {}) }), external ? (_jsx("span", { id: newTabId, hidden: true, children: "Opens in a new tab" })) : null] }));
45
48
  }
46
49
  else if (clickable) {
47
50
  cover = (_jsx("button", { type: "button", "data-card-cover": "", disabled: disabled, onClick: onSelect, "aria-current": selected ? "true" : undefined, ...nameProps }));
@@ -40,5 +40,16 @@ type DataStateProps<T> = {
40
40
  * because its data is missing, and loading never takes over the whole page.
41
41
  */
42
42
  declare function DataState<T>({ status, data, skeleton, isEmpty, empty, errorSubject, onRetry, children, className, }: DataStateProps<T>): React.JSX.Element;
43
- export { DataState };
43
+ /**
44
+ * The empty body on its own, for a page that already knows it has nothing to show: a not-found page, or a
45
+ * server component (DataState's `children` is a function, which can't be passed from the server). Inside a
46
+ * data region, use DataState's `empty` instead.
47
+ */
48
+ declare function DataStateEmpty({ icon, illustration, illustrationSize, title, description, action }: EmptyContent): React.JSX.Element;
49
+ /** The error body on its own, for a page that already knows its data failed. On the server, leave out `onRetry`. */
50
+ declare function DataStateError({ subject, onRetry }: {
51
+ subject: string;
52
+ onRetry?: () => void;
53
+ }): React.JSX.Element;
54
+ export { DataState, DataStateEmpty, DataStateError };
44
55
  export type { DataStateProps, DataStatus, EmptyContent };
@@ -16,10 +16,16 @@ function DataState({ status, data, skeleton, isEmpty = defaultIsEmpty, empty, er
16
16
  const state = status !== "success" ? status : data === undefined || isEmpty(data) ? "empty" : "ready";
17
17
  return (_jsxs("div", { "data-slot": "data-state", "data-state": state, "aria-busy": state === "loading" || undefined, "aria-live": "polite", className: cn("min-w-0", className), children: [state === "loading" ? skeleton : null, state === "error" ? _jsx(DataStateError, { subject: errorSubject, onRetry: onRetry }) : null, state === "empty" ? _jsx(DataStateEmpty, { ...empty }) : null, state === "ready" ? children(data) : null] }));
18
18
  }
19
+ /**
20
+ * The empty body on its own, for a page that already knows it has nothing to show: a not-found page, or a
21
+ * server component (DataState's `children` is a function, which can't be passed from the server). Inside a
22
+ * data region, use DataState's `empty` instead.
23
+ */
19
24
  function DataStateEmpty({ icon, illustration, illustrationSize = "md", title, description, action }) {
20
25
  return (_jsxs("div", { "data-slot": "data-state-empty", className: "flex flex-col items-center gap-4 px-6 py-10 text-center", children: [illustration ? (_jsx(Illustration, { name: illustration, size: illustrationSize })) : icon ? (_jsx("span", { "aria-hidden": "true", className: "flex size-12 items-center justify-center rounded-full bg-[var(--surface-secondary)] text-[var(--text-disabled)] [&_svg]:size-6", children: icon })) : null, _jsxs("div", { children: [_jsx("p", { className: "text-16 font-bold tracking-tight text-[var(--text-primary)]", children: title }), description ? (_jsx("p", { className: "mx-auto mt-1 max-w-xs text-13 leading-relaxed text-[var(--text-body)]", children: description })) : null] }), action] }));
21
26
  }
27
+ /** The error body on its own, for a page that already knows its data failed. On the server, leave out `onRetry`. */
22
28
  function DataStateError({ subject, onRetry }) {
23
29
  return (_jsxs("div", { "data-slot": "data-state-error", role: "alert", className: "flex flex-col items-center gap-3 px-6 py-10 text-center", children: [_jsx("span", { "aria-hidden": "true", className: "flex size-12 items-center justify-center rounded-full bg-[var(--error-bg)] text-[var(--danger-text)] [&_svg]:size-6", children: _jsx(AlertCircle, {}) }), _jsxs("p", { className: "text-16 font-bold tracking-tight text-[var(--text-primary)]", children: ["Couldn\u2019t load ", subject] }), onRetry ? (_jsx(Button, { variant: "link", size: "sm", onClick: onRetry, children: "Try again" })) : (_jsx("p", { className: "text-13 leading-[1.625] text-[var(--text-body)]", children: "Try again shortly." }))] }));
24
30
  }
25
- export { DataState };
31
+ export { DataState, DataStateEmpty, DataStateError };
@@ -23,8 +23,11 @@ type DialogProps = {
23
23
  children: React.ReactNode;
24
24
  /** The main button, bottom right. Spins while `busy`. */
25
25
  primaryAction?: DialogAction;
26
- /** The button that closes without saving, beside the main one. Default "Cancel". */
27
- cancelLabel?: string;
26
+ /**
27
+ * The button that closes without saving, beside the main one. Default "Cancel". `null` leaves it out, for a
28
+ * notice people only acknowledge: `primaryAction={{ label: "Got it", onClick: onClose }} cancelLabel={null}`.
29
+ */
30
+ cancelLabel?: string | null;
28
31
  /** A red action, like Remove, alone at the bottom left. Ask with a ConfirmDialog before doing it. */
29
32
  dangerAction?: DialogAction;
30
33
  /**
@@ -29,6 +29,6 @@ function Dialog({ open, onClose, title, description, children, primaryAction, ca
29
29
  // Computer: a box in the middle.
30
30
  "md:top-1/2 md:left-1/2 md:max-h-[calc(100dvh-32px)] md:w-[calc(100vw-32px)] md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-2xl md:border md:border-[var(--border-default)] md:shadow-[var(--shadow-dialog)]", "md:transition-[opacity,scale] md:duration-300 md:ease-out md:data-[ending-style]:duration-200 md:data-[starting-style]:scale-95 md:data-[starting-style]:opacity-0 md:data-[ending-style]:opacity-0", WIDTHS[size], className), children: [_jsxs("header", { "data-slot": "dialog-header", className: "flex shrink-0 items-start gap-3 px-6 pt-6 pb-4 max-md:border-b max-md:border-[var(--border-divider)] max-md:px-5 max-md:pt-[max(16px,env(safe-area-inset-top))]", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx(DialogPrimitive.Title, { className: "text-18 font-bold tracking-tight text-[var(--text-primary)]", children: title }), description ? (_jsx(DialogPrimitive.Description, { className: "mt-1 text-13 leading-normal text-[var(--text-body)]", children: description })) : null] }), _jsx(DialogPrimitive.Close, { disabled: busy, render: _jsx(IconButton, { "aria-label": "Close", size: "sm", className: "-mt-1 -mr-2", children: _jsx(X, {}) }) })] }), _jsx("div", { ref: body, "data-slot": "dialog-body", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 pb-2 max-md:px-5 max-md:pt-5", children: children }), primaryAction || dangerAction || footer ? (_jsxs("footer", { "data-slot": "dialog-footer", className: "flex shrink-0 flex-wrap items-center justify-end gap-2 px-6 pt-4 pb-6 max-md:border-t max-md:border-[var(--border-divider)] max-md:px-5 max-md:pb-[max(16px,env(safe-area-inset-bottom))]", children: [dangerAction ? (_jsx(Button, { variant: "danger-ghost", size: "md", icon: dangerAction.icon, disabled: busy || dangerAction.disabled, onClick: dangerAction.onClick,
31
31
  // Phone: its own row above Cancel and the main button, so the three never squeeze into one.
32
- className: "mr-auto max-md:mr-0 max-md:w-full", children: dangerAction.label })) : null, primaryAction ? (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "secondary", size: "md", disabled: busy, onClick: onClose, className: "max-md:flex-1", children: cancelLabel }), _jsx(Button, { size: "md", loading: busy, disabled: primaryAction.disabled, icon: primaryAction.icon, onClick: primaryAction.onClick, className: "max-md:flex-1", children: primaryAction.label })] })) : null, footer] })) : null] })] }) }));
32
+ className: "mr-auto max-md:mr-0 max-md:w-full", children: dangerAction.label })) : null, primaryAction ? (_jsxs(_Fragment, { children: [cancelLabel !== null ? (_jsx(Button, { variant: "secondary", size: "md", disabled: busy, onClick: onClose, className: "max-md:flex-1", children: cancelLabel })) : null, _jsx(Button, { size: "md", loading: busy, disabled: primaryAction.disabled, icon: primaryAction.icon, onClick: primaryAction.onClick, className: "max-md:flex-1", children: primaryAction.label })] })) : null, footer] })) : null] })] }) }));
33
33
  }
34
34
  export { Dialog };
@@ -0,0 +1,73 @@
1
+ import * as React from "react";
2
+ type GlobalSearchItem = {
3
+ /** Unique within its list. */
4
+ id: string;
5
+ /** The name: a person, an organization, a list. */
6
+ title: string;
7
+ /** One line under it: role and company, people you know there. */
8
+ description?: string;
9
+ /** An Avatar, a logo or a favicon, up to 40px. */
10
+ leading?: React.ReactNode;
11
+ /** Open it. Add it to the app's recents here. The search closes itself afterwards. */
12
+ onSelect: () => void;
13
+ };
14
+ type GlobalSearchGroup = {
15
+ /** Unique: "people", "orgs". */
16
+ id: string;
17
+ /** Plural, as the chip and heading say it: "People", "Organizations". */
18
+ label: string;
19
+ /** Matches for the query. Shown once two characters are typed. */
20
+ results: GlobalSearchItem[];
21
+ /** What the person opened lately, newest first. Shown before anything is typed. */
22
+ recent: GlobalSearchItem[];
23
+ /** Shown before anything is typed when `recent` is empty, so the list is never blank: the people you know best, your top organizations. */
24
+ suggested: GlobalSearchItem[];
25
+ /** The list being shown is still loading: skeleton rows in its place. */
26
+ loading?: boolean;
27
+ /** The search for this list failed: an error with Try again in its place. */
28
+ failed?: boolean;
29
+ /** Try the failed search again. */
30
+ onRetry?: () => void;
31
+ /** How many match in all, when more can load. Shown in the heading when this list is shown alone. */
32
+ total?: number;
33
+ /** Load the next page of results: a Load more link under them. */
34
+ onLoadMore?: () => void;
35
+ /** The next page is loading: Load more spins. */
36
+ loadingMore?: boolean;
37
+ /** Take one item out of `recent`: a ✕ on the row, and Shift+Delete. */
38
+ onRemoveRecent?: (id: string) => void;
39
+ /** Empty `recent`: a Clear button in the heading. */
40
+ onClearRecent?: () => void;
41
+ /** One thing to try when nothing matches: "Try a different name, company, or spelling." */
42
+ noResultsHint?: string;
43
+ /** A filter for these results, like a FilterPill for 1st or 2nd degree. Shown in the heading while searching. */
44
+ filter?: React.ReactNode;
45
+ };
46
+ type GlobalSearchProps = {
47
+ open: boolean;
48
+ /** Called on Esc, ✕, the backdrop, and after a row is opened. */
49
+ onClose: () => void;
50
+ /** The text typed. You own it, so you can debounce the search. */
51
+ query: string;
52
+ onQueryChange: (query: string) => void;
53
+ /** Names every list it searches: "Search people and organizations". */
54
+ placeholder: string;
55
+ /** One per kind of thing, in the order they should appear. */
56
+ groups: GlobalSearchGroup[];
57
+ };
58
+ declare function GlobalSearch({ open, onClose, query, onQueryChange, placeholder, groups }: GlobalSearchProps): React.JSX.Element;
59
+ type GlobalSearchTriggerProps = {
60
+ /** Open the search. ⌘K (Ctrl+K off a Mac) calls it too, from anywhere in the app. */
61
+ onOpen: () => void;
62
+ /** What it searches: "Search your network". Shown in the field, and read out on phones where only the icon shows. */
63
+ label: string;
64
+ /** Layout only: the width at each screen size. */
65
+ className?: string;
66
+ };
67
+ /**
68
+ * The search field in the top bar that opens GlobalSearch, from Bridge OS's NetworkSearchBar: a slim pill
69
+ * with ⌘K on computers, a round search button on phones. It owns the ⌘K shortcut, so put one in each app.
70
+ */
71
+ declare function GlobalSearchTrigger({ onOpen, label, className }: GlobalSearchTriggerProps): React.JSX.Element;
72
+ export { GlobalSearch, GlobalSearchTrigger };
73
+ export type { GlobalSearchGroup, GlobalSearchItem, GlobalSearchProps, GlobalSearchTriggerProps };
@@ -0,0 +1,202 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
5
+ import { ChevronRight, Search, X } from "lucide-react";
6
+ import { Button } from "@brdgapp/ui/components/button";
7
+ import { DataStateEmpty, DataStateError } from "@brdgapp/ui/components/data-state";
8
+ import { FilterChip } from "@brdgapp/ui/components/filter-chip";
9
+ import { IconButton } from "@brdgapp/ui/components/icon-button";
10
+ import { Skeleton } from "@brdgapp/ui/components/skeleton";
11
+ import { cn } from "@brdgapp/ui/lib/utils";
12
+ // The ⌘K search, one for every app (Aman, 2026-11-12). The look is Bridge OS's network-search-overlay: the
13
+ // tall input row, All / People / Organizations chips, and the lists side by side under small uppercase
14
+ // headings. Decisions:
15
+ // - ⌘K (Ctrl+K off a Mac) only opens search. No commands, no "go to" actions.
16
+ // - The lists sit in columns, two to a row. A third goes on its own full-width row below; a fourth joins it.
17
+ // - The box fits what's in it: one list is 560px wide, two or more 1040px; it grows with the rows up to 80%
18
+ // of the screen, then scrolls. On a phone it fills the screen, like every full-screen panel.
19
+ // - It's never empty. Before anything is typed each list shows what you opened recently, or suggestions
20
+ // when there's nothing recent yet.
21
+ // - Moving through it works like shadcn's Command (cmdk): focus stays in the input, ↑ ↓ move through every
22
+ // row in reading order (down the first column, then the next), Home and End jump, Enter opens, and the
23
+ // pointer moves the highlight too.
24
+ // Unlike the Bridge OS overlay, it's a real dialog (Base UI): screen readers are told, and Tab stays inside.
25
+ /** Searching starts at two characters, the same in every app. */
26
+ const MIN_QUERY = 2;
27
+ const SKELETON_ROWS = 5;
28
+ function shownFor(group, searching) {
29
+ if (searching)
30
+ return { kind: "results", items: group.results };
31
+ if (group.recent.length > 0)
32
+ return { kind: "recent", items: group.recent };
33
+ return { kind: "suggested", items: group.suggested };
34
+ }
35
+ function headingFor(group, kind) {
36
+ if (kind === "results")
37
+ return group.label;
38
+ const name = group.label.toLowerCase();
39
+ return kind === "recent" ? `Recent ${name}` : `Suggested ${name}`;
40
+ }
41
+ const domId = (s) => s.replace(/[^a-zA-Z0-9_-]/g, "_");
42
+ function GlobalSearch({ open, onClose, query, onQueryChange, placeholder, groups }) {
43
+ const baseId = React.useId();
44
+ const inputRef = React.useRef(null);
45
+ const [view, setView] = React.useState("all");
46
+ // The highlighted row, remembered with the rows it was picked from: when the rows change it goes back to
47
+ // the first one, as cmdk does.
48
+ const [picked, setPicked] = React.useState(null);
49
+ const searching = query.trim().length >= MIN_QUERY;
50
+ // A chip for a list that's gone falls back to All.
51
+ const visible = view === "all" ? groups : groups.filter((g) => g.id === view);
52
+ const shownGroups = visible.length > 0 ? visible : groups;
53
+ // Every row in reading order: down the first list, then the next. ↑ ↓ follow this, as cmdk does.
54
+ const rows = shownGroups.flatMap((g) => {
55
+ const shown = shownFor(g, searching);
56
+ if (g.loading || (shown.kind === "results" && g.failed))
57
+ return [];
58
+ return shown.items.map((item) => ({ key: `${g.id}\u0000${item.id}`, group: g, item, kind: shown.kind }));
59
+ });
60
+ const rowKeys = rows.map((r) => r.key).join("\u0001");
61
+ const active = (picked?.rows === rowKeys ? rows.find((r) => r.key === picked.key) : undefined) ?? rows[0];
62
+ const setActiveKey = (key) => setPicked({ key, rows: rowKeys });
63
+ const optionId = (key) => `${baseId}-opt-${domId(key)}`;
64
+ // Each time it closes it goes back to All, ready for the next time.
65
+ const close = () => {
66
+ setView("all");
67
+ onClose();
68
+ };
69
+ React.useEffect(() => {
70
+ if (!active)
71
+ return;
72
+ document.getElementById(optionId(active.key))?.scrollIntoView({ block: "nearest" });
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ }, [active?.key]);
75
+ if (process.env.NODE_ENV !== "production") {
76
+ for (const g of groups) {
77
+ if (!g.loading && g.recent.length === 0 && g.suggested.length === 0) {
78
+ console.warn(`GlobalSearch: "${g.label}" has nothing recent and no suggestions. Give it suggestions, so the search is never empty.`);
79
+ }
80
+ }
81
+ }
82
+ const choose = (item) => {
83
+ item.onSelect();
84
+ close();
85
+ };
86
+ const move = (to) => {
87
+ const next = rows[Math.max(0, Math.min(rows.length - 1, to))];
88
+ if (next)
89
+ setActiveKey(next.key);
90
+ };
91
+ const onKeyDown = (e) => {
92
+ const at = active ? rows.indexOf(active) : -1;
93
+ const ctrl = e.ctrlKey && !e.metaKey && !e.altKey;
94
+ if (e.key === "ArrowDown" || (ctrl && (e.key === "n" || e.key === "j"))) {
95
+ e.preventDefault();
96
+ move(at + 1);
97
+ }
98
+ else if (e.key === "ArrowUp" || (ctrl && (e.key === "p" || e.key === "k"))) {
99
+ e.preventDefault();
100
+ move(at - 1);
101
+ }
102
+ else if (e.key === "Home" && rows.length > 0) {
103
+ e.preventDefault();
104
+ move(0);
105
+ }
106
+ else if (e.key === "End" && rows.length > 0) {
107
+ e.preventDefault();
108
+ move(rows.length - 1);
109
+ }
110
+ else if (e.key === "Enter" && active && !e.nativeEvent.isComposing) {
111
+ e.preventDefault();
112
+ choose(active.item);
113
+ }
114
+ else if ((e.key === "Delete" || e.key === "Backspace") && e.shiftKey && active?.kind === "recent" && active.group.onRemoveRecent) {
115
+ e.preventDefault();
116
+ active.group.onRemoveRecent(active.item.id);
117
+ }
118
+ };
119
+ const columns = groups.length > 1 ? 2 : 1;
120
+ const announce = searching && shownGroups.every((g) => !g.loading)
121
+ ? shownGroups.map((g) => `${g.label}: ${g.failed ? "couldn't load" : g.results.length}`).join(". ")
122
+ : "";
123
+ return (_jsx(DialogPrimitive.Root, { open: open, onOpenChange: (next) => !next && close(), children: _jsxs(DialogPrimitive.Portal, { children: [_jsx(DialogPrimitive.Backdrop, { className: "fixed inset-0 z-[90] bg-black/40 backdrop-blur-sm transition-opacity duration-150 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0" }), _jsxs(DialogPrimitive.Popup, { "data-slot": "global-search", initialFocus: inputRef, "aria-label": placeholder, className: cn("fixed z-[90] flex flex-col overflow-hidden bg-[var(--surface-elevated)] outline-none",
124
+ // Phone: the whole screen.
125
+ "max-md:inset-0",
126
+ // Computer: near the top, as wide as its lists need, as tall as its rows up to 80% of the screen.
127
+ "md:top-[10vh] md:left-1/2 md:max-h-[min(80vh,720px)] md:w-[calc(100vw-32px)] md:-translate-x-1/2 md:rounded-2xl md:border md:border-[var(--border-default)] md:shadow-[var(--shadow-dialog)]", columns === 2 ? "md:max-w-[1040px]" : "md:max-w-[560px]", "transition-[opacity,scale,translate] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)] data-[starting-style]:opacity-0 data-[ending-style]:opacity-0 md:data-[starting-style]:scale-[0.98] md:data-[ending-style]:scale-[0.98] motion-reduce:transition-none"), children: [_jsxs("div", { "data-slot": "global-search-input", className: "relative shrink-0 border-b border-[var(--border-divider)] max-md:pt-[env(safe-area-inset-top)]", children: [_jsx(Search, { "aria-hidden": "true", className: "pointer-events-none absolute bottom-[19px] left-5 size-[18px] text-[var(--text-muted)]" }), _jsx("input", { ref: inputRef, type: "text", role: "combobox", "aria-expanded": "true", "aria-autocomplete": "list", "aria-controls": shownGroups.map((g) => `${baseId}-list-${domId(g.id)}`).join(" "), "aria-activedescendant": active ? optionId(active.key) : undefined, "aria-label": placeholder, autoComplete: "off", spellCheck: false, value: query, placeholder: placeholder, onChange: (e) => onQueryChange(e.target.value), onKeyDown: onKeyDown, className: "h-14 w-full bg-transparent pr-24 pl-[52px] text-16 text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:outline-none" }), _jsxs("div", { className: "absolute right-4 bottom-[18px] flex items-center gap-2", children: [query ? (_jsx(IconButton, { size: "xs", "aria-label": "Clear search", onClick: () => {
128
+ onQueryChange("");
129
+ inputRef.current?.focus();
130
+ }, children: _jsx(X, {}) })) : null, _jsx("kbd", { className: "hidden h-5 items-center rounded border border-[var(--border-default)] bg-[var(--surface-secondary)] px-1.5 text-11 font-semibold text-[var(--text-muted)] md:inline-flex", children: "Esc" }), _jsx(DialogPrimitive.Close, { render: _jsx(Button, { variant: "ghost", size: "sm", className: "md:hidden", children: "Cancel" }) })] })] }), groups.length > 1 ? (_jsxs("div", { "data-slot": "global-search-chips", className: "flex shrink-0 items-center gap-1.5 overflow-x-auto border-b border-[var(--border-divider)] px-4 py-2.5", children: [_jsx(FilterChip, { active: view === "all", onClick: () => setView("all"), children: "All" }), groups.map((g) => (_jsx(FilterChip, { active: view === g.id, onClick: () => setView(view === g.id ? "all" : g.id), children: g.label }, g.id)))] })) : null, _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: _jsx("div", { className: cn("grid", shownGroups.length > 1 && "md:grid-cols-2"), children: shownGroups.map((g, i) => {
131
+ const shown = shownFor(g, searching);
132
+ const twoUp = shownGroups.length > 1;
133
+ const spans = twoUp && i === shownGroups.length - 1 && i % 2 === 0;
134
+ return (_jsx(GroupColumn, { group: g, shown: shown, query: query.trim(), alone: shownGroups.length === 1, listId: `${baseId}-list-${domId(g.id)}`, headingId: `${baseId}-heading-${domId(g.id)}`, optionId: (item) => optionId(`${g.id}\u0000${item.id}`), activeId: active?.group.id === g.id ? active.item.id : null, onHover: (item) => setActiveKey(`${g.id}\u0000${item.id}`), onChoose: choose, className: cn(i > 0 && "border-t border-[var(--border-divider)]", twoUp && i === 1 && "md:border-t-0 md:border-l", twoUp && i > 1 && i % 2 === 1 && !spans && "md:border-l", spans && "md:col-span-2") }, g.id));
135
+ }) }) }), _jsx("span", { role: "status", className: "sr-only", children: announce })] })] }) }));
136
+ }
137
+ function GroupColumn({ group, shown, query, alone, listId, headingId, optionId, activeId, onHover, onChoose, className }) {
138
+ const searching = shown.kind === "results";
139
+ const meta = alone && searching && !group.loading && group.total != null && group.total > 0 ? `${group.total.toLocaleString("en-US")} found` : null;
140
+ const action = searching ? group.filter : shown.kind === "recent" && group.onClearRecent ? (_jsx(Button, { variant: "ghost", size: "xs", onClick: group.onClearRecent, children: "Clear" })) : null;
141
+ let body;
142
+ if (group.loading) {
143
+ body = (_jsx("div", { "aria-hidden": "true", children: Array.from({ length: SKELETON_ROWS }, (_, i) => (_jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [_jsx(Skeleton, { shape: "circle", className: "size-10 shrink-0" }), _jsxs("div", { className: "flex-1 space-y-2", children: [_jsx(Skeleton, { className: "h-3 w-1/3" }), _jsx(Skeleton, { className: "h-2.5 w-1/2" })] })] }, i))) }));
144
+ }
145
+ else if (searching && group.failed) {
146
+ body = _jsx(DataStateError, { subject: group.label.toLowerCase(), onRetry: group.onRetry });
147
+ }
148
+ else if (searching && shown.items.length === 0) {
149
+ body = (_jsx(DataStateEmpty, { illustration: "search", illustrationSize: "sm", title: `No ${group.label.toLowerCase()} match “${query}”`, description: group.noResultsHint }));
150
+ }
151
+ else if (shown.items.length === 0) {
152
+ // Only when an app gave no suggestions (it's warned in development).
153
+ body = _jsxs("p", { className: "px-4 py-6 text-13 text-[var(--text-muted)]", children: ["Type to search ", group.label.toLowerCase(), "."] });
154
+ }
155
+ else {
156
+ body = (_jsxs("div", { id: listId, role: "listbox", "aria-labelledby": headingId, children: [shown.items.map((item) => (_jsx(SearchRow, { id: optionId(item), item: item, active: activeId === item.id, onHover: () => onHover(item), onChoose: () => onChoose(item), onRemove: shown.kind === "recent" && group.onRemoveRecent ? () => group.onRemoveRecent?.(item.id) : undefined }, item.id))), searching && group.onLoadMore ? (_jsx("div", { role: "presentation", className: "flex justify-center px-4 py-3", children: _jsx(Button, { variant: "link", loading: group.loadingMore, onClick: group.onLoadMore, children: group.loadingMore ? "Loading…" : "Load more" }) })) : null] }));
157
+ }
158
+ return (_jsxs("section", { "data-slot": "global-search-group", "aria-labelledby": headingId, className: cn("min-w-0", className), children: [_jsxs("div", { className: "sticky top-0 z-[1] flex h-10 items-center justify-between gap-3 bg-[var(--surface-elevated)] px-4", children: [_jsxs("div", { className: "flex min-w-0 items-baseline gap-2", children: [_jsx("h2", { id: headingId, className: "text-11 font-bold tracking-[0.55px] text-[var(--text-muted)] uppercase", children: headingFor(group, shown.kind) }), meta ? _jsx("span", { className: "truncate text-11 text-[var(--text-muted)]", children: meta }) : null] }), action] }), body] }));
159
+ }
160
+ function SearchRow({ id, item, active, onHover, onChoose, onRemove }) {
161
+ return (_jsxs("div", { id: id, role: "option", "aria-selected": active, "data-slot": "global-search-row", "data-active": active || undefined, onPointerMove: () => !active && onHover(),
162
+ // Keep focus in the input, so typing carries on after a click.
163
+ onMouseDown: (e) => e.preventDefault(), onClick: onChoose, className: "group/row relative flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors data-[active]:bg-[var(--surface-secondary)]", children: [item.leading ? _jsx("span", { className: "flex size-10 shrink-0 items-center justify-center", children: item.leading }) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate text-14 font-bold tracking-tight text-[var(--text-primary)]", children: item.title }), item.description ? _jsx("span", { className: "mt-0.5 block truncate text-12 text-[var(--text-muted)]", children: item.description }) : null] }), onRemove ? (_jsx(IconButton, { size: "xs", tabIndex: -1, "aria-label": `Remove ${item.title} from recents`, onMouseDown: (e) => e.preventDefault(), onClick: (e) => {
164
+ e.stopPropagation();
165
+ onRemove();
166
+ }, className: "opacity-0 group-hover/row:opacity-100 group-data-[active]/row:opacity-100", children: _jsx(X, {}) })) : null, _jsx(ChevronRight, { "aria-hidden": "true", className: "size-4 shrink-0 text-[var(--text-disabled)]" })] }));
167
+ }
168
+ /** Triggers on the page, oldest first. */
169
+ const MOUNTED = [];
170
+ const noSubscribe = () => () => { };
171
+ const isApple = () => /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
172
+ /**
173
+ * The search field in the top bar that opens GlobalSearch, from Bridge OS's NetworkSearchBar: a slim pill
174
+ * with ⌘K on computers, a round search button on phones. It owns the ⌘K shortcut, so put one in each app.
175
+ */
176
+ function GlobalSearchTrigger({ onOpen, label, className }) {
177
+ const mac = React.useSyncExternalStore(noSubscribe, isApple, () => true);
178
+ const openRef = React.useRef(onOpen);
179
+ React.useEffect(() => {
180
+ openRef.current = onOpen;
181
+ });
182
+ React.useEffect(() => {
183
+ const me = Symbol();
184
+ MOUNTED.push(me);
185
+ const onKey = (e) => {
186
+ // With more than one on a page (a docs page), only the first answers ⌘K.
187
+ if (MOUNTED[0] !== me || e.defaultPrevented)
188
+ return;
189
+ if ((e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === "k") {
190
+ e.preventDefault();
191
+ openRef.current();
192
+ }
193
+ };
194
+ document.addEventListener("keydown", onKey);
195
+ return () => {
196
+ document.removeEventListener("keydown", onKey);
197
+ MOUNTED.splice(MOUNTED.indexOf(me), 1);
198
+ };
199
+ }, []);
200
+ return (_jsxs("button", { type: "button", "data-slot": "global-search-trigger", onClick: onOpen, "aria-label": label, "aria-haspopup": "dialog", "aria-keyshortcuts": mac ? "Meta+K" : "Control+K", className: cn("flex h-9 shrink-0 items-center gap-2 rounded-full border border-[var(--border-hover)] bg-[var(--surface-secondary)] text-[var(--text-muted)] transition-colors outline-none", "hover:border-[var(--primary)] hover:text-[var(--text-body)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]", "w-9 justify-center sm:w-[340px] sm:justify-start sm:px-3.5 lg:w-[440px] xl:w-[520px]", className), children: [_jsx(Search, { "aria-hidden": "true", className: "size-4 shrink-0" }), _jsx("span", { className: "hidden flex-1 truncate text-left text-13 sm:block", children: label }), _jsx("kbd", { "aria-hidden": "true", className: "hidden h-5 shrink-0 items-center rounded border border-[var(--border-default)] bg-[var(--surface-primary)] px-1.5 text-11 font-semibold text-[var(--text-muted)] sm:inline-flex", children: mac ? "⌘K" : "Ctrl K" })] }));
201
+ }
202
+ export { GlobalSearch, GlobalSearchTrigger };
@@ -0,0 +1,27 @@
1
+ import * as React from "react";
2
+ declare const WIDTHS: {
3
+ readonly default: "w-80";
4
+ readonly wide: "w-[460px]";
5
+ };
6
+ type PopoverProps = {
7
+ /** The button that opens it: an IconButton, a Button or an Avatar button. One element. */
8
+ trigger: React.ReactElement<React.HTMLAttributes<HTMLElement>>;
9
+ /** Names the panel: "All apps", "Your account". The heading on a computer, and the sheet's title on a phone. */
10
+ title: string;
11
+ /** Leave the heading row out on a computer, when the content says what it is (the account menu starts with your name). The phone sheet still shows the title. */
12
+ hideTitle?: boolean;
13
+ /** One link or small button beside the title: "See more". */
14
+ action?: React.ReactNode;
15
+ /** `default` 320px; `wide` 460px, for a grid like the app launcher. Phones use the whole width either way. */
16
+ size?: keyof typeof WIDTHS;
17
+ /** Which edge of the trigger it lines up with. `end` for a button at the right of the top bar. */
18
+ align?: "start" | "center" | "end";
19
+ /** Control it, to close it when a link inside is clicked. Leave both out and it opens and closes itself. */
20
+ open?: boolean;
21
+ onOpenChange?: (open: boolean) => void;
22
+ /** What's inside. */
23
+ children: React.ReactNode;
24
+ };
25
+ declare function Popover({ trigger, title, hideTitle, action, size, align, open: openProp, onOpenChange, children }: PopoverProps): React.JSX.Element;
26
+ export { Popover };
27
+ export type { PopoverProps };
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
5
+ import { BottomSheet } from "@brdgapp/ui/components/bottom-sheet";
6
+ import { useIsMobile } from "@brdgapp/ui/hooks/use-is-mobile";
7
+ import { cn } from "@brdgapp/ui/lib/utils";
8
+ // A panel that opens from a button and holds anything: the account menu, the app launcher, a small form.
9
+ // Asked for by Bridge OS, whose account menu and app launcher were built on a Radix DropdownMenu, which
10
+ // tells screen readers "menu" and then holds tiles and buttons a menu can't move through. About 85 files
11
+ // in six apps build a popover of their own (raise 24, app-portfolio 24, app-cc 18).
12
+ //
13
+ // Decisions (Aman, 2026-11-12):
14
+ // - Two widths: 320px by default (the account menu; the apps' most common is 256–320px) and `wide`
15
+ // 460px (the app launcher).
16
+ // - An optional heading row: the title, with one link or button beside it ("See more").
17
+ // - On a phone (below 768px) it slides up from the bottom as a BottomSheet, like every other sheet.
18
+ // For a list of actions use ActionMenu; for a preview on hover, HoverCard; for a hint, InfoHint.
19
+ // The surface is the menus': --surface-elevated, a border, --shadow-menu, 12px corners, z-[80].
20
+ const WIDTHS = { default: "w-80", wide: "w-[460px]" };
21
+ function Popover({ trigger, title, hideTitle = false, action, size = "default", align = "start", open: openProp, onOpenChange, children }) {
22
+ const mobile = useIsMobile();
23
+ const [ownOpen, setOwnOpen] = React.useState(false);
24
+ const open = openProp ?? ownOpen;
25
+ const setOpen = (next) => {
26
+ if (openProp === undefined)
27
+ setOwnOpen(next);
28
+ onOpenChange?.(next);
29
+ };
30
+ // Phones: the trigger opens a sheet from the bottom, with the same content.
31
+ if (mobile) {
32
+ const props = trigger.props;
33
+ return (_jsxs(_Fragment, { children: [React.cloneElement(trigger, {
34
+ "aria-haspopup": "dialog",
35
+ "aria-expanded": open,
36
+ onClick: (e) => {
37
+ props.onClick?.(e);
38
+ if (!e.defaultPrevented)
39
+ setOpen(true);
40
+ },
41
+ }), _jsx(BottomSheet, { open: open, onClose: () => setOpen(false), title: title, action: action, children: _jsx("div", { "data-slot": "popover-body", className: "px-5 pt-1 pb-3", children: children }) })] }));
42
+ }
43
+ return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Trigger, { render: trigger }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Positioner, { side: "bottom", align: align, sideOffset: 8, collisionPadding: 12, className: "z-[80]", children: _jsxs(PopoverPrimitive.Popup, { "data-slot": "popover", "aria-label": hideTitle ? title : undefined, className: cn("flex max-h-[min(70vh,var(--available-height))] max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] flex-col overflow-hidden rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] shadow-[var(--shadow-menu)] outline-none", "transition-[opacity,scale] duration-200 ease-out data-[ending-style]:duration-150 motion-reduce:transition-none", "data-[starting-style]:scale-95 data-[starting-style]:opacity-0 data-[ending-style]:scale-95 data-[ending-style]:opacity-0", WIDTHS[size]), children: [hideTitle ? null : (_jsxs("div", { "data-slot": "popover-header", className: "flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--border-divider)] px-4", children: [_jsx(PopoverPrimitive.Title, { className: "min-w-0 truncate text-14 font-bold tracking-[-0.01em] text-[var(--text-primary)]", children: title }), action] })), _jsx("div", { "data-slot": "popover-body", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain p-4", children: children })] }) }) })] }));
44
+ }
45
+ export { Popover };
@@ -2,7 +2,9 @@ import * as React from "react";
2
2
  type SearchInputProps = Omit<React.ComponentProps<"input">, "type"> & {
3
3
  /** Clears the field. The clear button shows only when there is a value. */
4
4
  onClear?: () => void;
5
+ /** Results are on their way from the server: a spinner shows in the clear button's place. */
6
+ loading?: boolean;
5
7
  };
6
- declare function SearchInput({ className, value, onClear, onKeyDown, disabled, ref, ...props }: SearchInputProps): React.JSX.Element;
8
+ declare function SearchInput({ className, value, onClear, loading, onKeyDown, disabled, ref, ...props }: SearchInputProps): React.JSX.Element;
7
9
  export { SearchInput };
8
10
  export type { SearchInputProps };
@@ -2,11 +2,11 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { Input as InputPrimitive } from "@base-ui/react/input";
5
- import { Search, X } from "lucide-react";
5
+ import { Loader2, Search, X } from "lucide-react";
6
6
  import { IconButton } from "@brdgapp/ui/components/icon-button";
7
7
  import { cn } from "@brdgapp/ui/lib/utils";
8
8
  // `className` goes on the wrapper, not the input, so a width limit keeps the clear button inside the pill.
9
- function SearchInput({ className, value, onClear, onKeyDown, disabled, ref, ...props }) {
9
+ function SearchInput({ className, value, onClear, loading = false, onKeyDown, disabled, ref, ...props }) {
10
10
  const inner = React.useRef(null);
11
11
  const hasValue = value !== undefined && String(value).length > 0;
12
12
  const canClear = hasValue && !!onClear && !disabled;
@@ -17,7 +17,7 @@ function SearchInput({ className, value, onClear, onKeyDown, disabled, ref, ...p
17
17
  else if (ref)
18
18
  ref.current = el;
19
19
  };
20
- return (_jsxs("div", { "data-slot": "search-input", className: cn("group relative", className), children: [_jsx(Search, { "aria-hidden": "true", className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-[var(--text-disabled)] transition-colors group-focus-within:text-[var(--primary)] group-has-[input:disabled]:opacity-50" }), _jsx(InputPrimitive, { "data-slot": "search-input-field", type: "search", ref: setRefs, value: value, disabled: disabled, onKeyDown: (e) => {
20
+ return (_jsxs("div", { "data-slot": "search-input", className: cn("group relative", className), children: [_jsx(Search, { "aria-hidden": "true", className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-[var(--text-disabled)] transition-colors group-focus-within:text-[var(--primary)] group-has-[input:disabled]:opacity-50" }), _jsx(InputPrimitive, { "data-slot": "search-input-field", type: "search", ref: setRefs, value: value, disabled: disabled, "aria-busy": loading || undefined, onKeyDown: (e) => {
21
21
  onKeyDown?.(e);
22
22
  if (e.key === "Escape" && canClear && !e.defaultPrevented) {
23
23
  // Keep the Esc for the field: a dialog around it shouldn't close too.
@@ -27,7 +27,7 @@ function SearchInput({ className, value, onClear, onKeyDown, disabled, ref, ...p
27
27
  }
28
28
  }, className: cn("h-11 md:h-10 w-full rounded-full border border-[var(--border-field)] bg-[var(--surface-secondary)] py-2 pr-10 pl-10", "text-16 md:text-14 text-[var(--text-primary)] placeholder:text-[var(--text-muted)]", "transition-all duration-150 ease-out outline-none hover:border-[var(--text-muted)]", "focus:border-[var(--primary)] focus:bg-[var(--surface-primary)] focus:ring-2 focus:ring-[var(--primary)]/20", "disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-[var(--border-field)]",
29
29
  // Hide the browser's own clear button; this component draws its own.
30
- "[&::-webkit-search-cancel-button]:appearance-none"), ...props }), canClear ? (_jsx(IconButton, { "aria-label": "Clear search", size: "sm", onClick: () => {
30
+ "[&::-webkit-search-cancel-button]:appearance-none"), ...props }), loading ? (_jsxs("span", { className: "pointer-events-none absolute top-1/2 right-3.5 -translate-y-1/2 text-[var(--text-muted)]", children: [_jsx(Loader2, { "data-slot": "search-input-spinner", "aria-hidden": "true", className: "size-4 animate-spin" }), _jsx("span", { role: "status", className: "sr-only", children: "Searching" })] })) : canClear ? (_jsx(IconButton, { "aria-label": "Clear search", size: "sm", onClick: () => {
31
31
  onClear?.();
32
32
  inner.current?.focus();
33
33
  }, className: "absolute top-1/2 right-1.5 -translate-y-1/2", children: _jsx(X, {}) })) : null] }));
@@ -6,7 +6,12 @@ declare const skeletonVariants: (props?: ({
6
6
  type SkeletonProps = VariantProps<typeof skeletonVariants> & {
7
7
  /** Size and position only: `w-1/2`, `size-8`, `h-24`. The look comes from `shape`. */
8
8
  className?: string;
9
+ /**
10
+ * A width worked out in code: px as a number (`120`), or any CSS width as text (`"60%"`). For a fixed width,
11
+ * use a class (`w-24`).
12
+ */
13
+ width?: number | string;
9
14
  };
10
- declare function Skeleton({ shape, className }: SkeletonProps): React.JSX.Element;
15
+ declare function Skeleton({ shape, className, width }: SkeletonProps): React.JSX.Element;
11
16
  export { Skeleton, skeletonVariants };
12
17
  export type { SkeletonProps };
@@ -17,7 +17,7 @@ const skeletonVariants = cva("block animate-pulse bg-[var(--skeleton)]", {
17
17
  },
18
18
  defaultVariants: { shape: "line" },
19
19
  });
20
- function Skeleton({ shape, className }) {
21
- return _jsx("span", { "data-slot": "skeleton", "aria-hidden": "true", className: cn(skeletonVariants({ shape }), className) });
20
+ function Skeleton({ shape, className, width }) {
21
+ return (_jsx("span", { "data-slot": "skeleton", "aria-hidden": "true", className: cn(skeletonVariants({ shape }), className), style: width !== undefined ? { width } : undefined }));
22
22
  }
23
23
  export { Skeleton, skeletonVariants };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brdgapp/ui",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "Bridge's shared components, tokens and styles. Documented at handbook.brdg.app.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://handbook.brdg.app",