@brdgapp/ui 1.2.1 → 1.3.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 +14 -0
- package/components/brand-mark.d.ts +1 -1
- package/components/brand-mark.js +6 -1
- package/components/card.d.ts +3 -1
- package/components/card.js +6 -3
- package/components/data-state.d.ts +12 -1
- package/components/data-state.js +7 -1
- package/components/dialog.d.ts +5 -2
- package/components/dialog.js +1 -1
- package/components/search-input.d.ts +3 -1
- package/components/search-input.js +4 -4
- package/components/skeleton.d.ts +6 -1
- package/components/skeleton.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Every release of `@brdgapp/ui`. Versions follow the rules in README.md → Versions.
|
|
4
4
|
|
|
5
|
+
## 1.3.0
|
|
6
|
+
|
|
7
|
+
2026-11-12. Six additions Bridge OS asked for, each found in other apps too. Nothing changes for apps already on
|
|
8
|
+
1.2, so they can update without changes.
|
|
9
|
+
|
|
10
|
+
- SearchInput: `loading` shows a small spinner in the clear button's place while results come from the server,
|
|
11
|
+
and screen readers hear "Searching".
|
|
12
|
+
- DataState: `DataStateEmpty` and `DataStateError` can be used on their own, for a page that already knows its
|
|
13
|
+
answer (a not-found page) and from a server component.
|
|
14
|
+
- Card: `external` opens an `href` card in a new tab, and screen readers hear "Opens in a new tab".
|
|
15
|
+
- Dialog: `cancelLabel={null}` leaves out Cancel, for a notice people only acknowledge ("Got it").
|
|
16
|
+
- Skeleton: `width` for a width worked out in code (`120`, `"60%"`).
|
|
17
|
+
- BrandMark: the X logo (`brand="x"`), always one color like Apple's.
|
|
18
|
+
|
|
5
19
|
## 1.2.1
|
|
6
20
|
|
|
7
21
|
2026-11-10. A small addition that changes nothing an app relies on.
|
|
@@ -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;
|
package/components/brand-mark.js
CHANGED
|
@@ -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":
|
package/components/card.d.ts
CHANGED
|
@@ -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)]";
|
package/components/card.js
CHANGED
|
@@ -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
|
-
|
|
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 };
|
package/components/data-state.js
CHANGED
|
@@ -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 };
|
package/components/dialog.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
27
|
-
|
|
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
|
/**
|
package/components/dialog.js
CHANGED
|
@@ -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 };
|
|
@@ -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] }));
|
package/components/skeleton.d.ts
CHANGED
|
@@ -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 };
|
package/components/skeleton.js
CHANGED
|
@@ -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