@graftwork/ui 1.1.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/components/accordion.d.ts +21 -0
  3. package/dist/components/accordion.js +17 -0
  4. package/dist/components/alert-dialog.d.ts +10 -0
  5. package/dist/components/alert-dialog.js +32 -0
  6. package/dist/components/alert.d.ts +11 -0
  7. package/dist/components/alert.js +13 -0
  8. package/dist/components/avatar.d.ts +26 -0
  9. package/dist/components/avatar.js +33 -0
  10. package/dist/components/badge.d.ts +10 -0
  11. package/dist/components/badge.js +27 -0
  12. package/dist/components/breadcrumb.d.ts +15 -0
  13. package/dist/components/breadcrumb.js +11 -0
  14. package/dist/components/button.js +3 -3
  15. package/dist/components/card.js +1 -1
  16. package/dist/components/checkbox.d.ts +22 -0
  17. package/dist/components/checkbox.js +29 -0
  18. package/dist/components/collapsible.d.ts +15 -0
  19. package/dist/components/collapsible.js +13 -0
  20. package/dist/components/combobox.d.ts +19 -0
  21. package/dist/components/combobox.js +14 -0
  22. package/dist/components/dialog.d.ts +36 -0
  23. package/dist/components/dialog.js +67 -0
  24. package/dist/components/dropdown-menu.d.ts +27 -0
  25. package/dist/components/dropdown-menu.js +49 -0
  26. package/dist/components/empty.d.ts +12 -0
  27. package/dist/components/empty.js +6 -0
  28. package/dist/components/field.js +3 -1
  29. package/dist/components/input-group.d.ts +16 -0
  30. package/dist/components/input-group.js +14 -0
  31. package/dist/components/kbd.d.ts +4 -0
  32. package/dist/components/kbd.js +6 -0
  33. package/dist/components/label.d.ts +4 -0
  34. package/dist/components/label.js +7 -0
  35. package/dist/components/pagination.d.ts +19 -0
  36. package/dist/components/pagination.js +32 -0
  37. package/dist/components/popover.d.ts +13 -0
  38. package/dist/components/popover.js +28 -0
  39. package/dist/components/progress.d.ts +9 -0
  40. package/dist/components/progress.js +8 -0
  41. package/dist/components/radio-group.d.ts +18 -0
  42. package/dist/components/radio-group.js +12 -0
  43. package/dist/components/select.js +2 -2
  44. package/dist/components/separator.d.ts +5 -0
  45. package/dist/components/separator.js +6 -0
  46. package/dist/components/sheet.d.ts +20 -0
  47. package/dist/components/sheet.js +38 -0
  48. package/dist/components/skeleton.d.ts +2 -0
  49. package/dist/components/skeleton.js +14 -0
  50. package/dist/components/slider.d.ts +12 -0
  51. package/dist/components/slider.js +8 -0
  52. package/dist/components/spinner.d.ts +14 -0
  53. package/dist/components/spinner.js +15 -0
  54. package/dist/components/switch.d.ts +8 -0
  55. package/dist/components/switch.js +8 -0
  56. package/dist/components/table.js +1 -1
  57. package/dist/components/tabs.d.ts +17 -0
  58. package/dist/components/tabs.js +18 -0
  59. package/dist/components/textarea.d.ts +16 -0
  60. package/dist/components/textarea.js +8 -0
  61. package/dist/components/toast.d.ts +24 -0
  62. package/dist/components/toast.js +28 -0
  63. package/dist/components/toggle.d.ts +14 -0
  64. package/dist/components/toggle.js +37 -0
  65. package/dist/components/tooltip.d.ts +6 -0
  66. package/dist/components/tooltip.js +24 -0
  67. package/dist/index.d.ts +30 -0
  68. package/dist/index.js +30 -0
  69. package/dist/lib/utils.d.ts +1 -1
  70. package/dist/lib/utils.js +6 -1
  71. package/dist/styles.css +11 -1
  72. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @graftwork/ui
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#25](https://github.com/graftwork-studio/design-system/pull/25) [`33b8015`](https://github.com/graftwork-studio/design-system/commit/33b80153bfad7861453ded91710a7d8d542ae477) Thanks [@david-kenny](https://github.com/david-kenny)! - Controls now use the 14px body size by default.
8
+
9
+ - Button and Toggle text is 12px at `sm`, 14px at `md` and 16px at `lg` (was 14, 16 and 18).
10
+ - Input, Textarea, InputGroup and Combobox are 14px from the `md` breakpoint (768px) up, and 16px below it so iPhone Safari doesn't zoom in when they're tapped.
11
+ - The Select trigger, Select and Combobox options, DropdownMenu items, Accordion triggers and Tabs are 14px everywhere.
12
+ - Pagination links keep 14px text at the small button height.
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [[`33b8015`](https://github.com/graftwork-studio/design-system/commit/33b80153bfad7861453ded91710a7d8d542ae477)]:
17
+ - @graftwork/tokens@1.3.0
18
+
19
+ ## 1.2.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [#22](https://github.com/graftwork-studio/design-system/pull/22) [`0c0b6dc`](https://github.com/graftwork-studio/design-system/commit/0c0b6dcb927a3948d9565f30dbf34cf800010e3a) Thanks [@david-kenny](https://github.com/david-kenny)! - Body text is now 14px (0.875rem at the browser default). A new `font.size.body` token (`--gw-font-size-body`, Tailwind `text-body`) is applied to `body`, and Card and Table use it for their content. The `html` root stays at `100%`, so rem still follows the user's font setting, and `font.size.md` stays at 1rem for inputs, Select and Button so iOS Safari doesn't zoom in on focus.
24
+
25
+ - [#23](https://github.com/graftwork-studio/design-system/pull/23) [`cc952a7`](https://github.com/graftwork-studio/design-system/commit/cc952a705279e6ad295dde8f9c791132e1750c6f) Thanks [@david-kenny](https://github.com/david-kenny)! - Add 30 components from shadcn/ui, built on React Aria and styled with our tokens: Accordion, Alert, AlertDialog, Avatar, Badge, Breadcrumb, Checkbox, Collapsible, Combobox, Dialog, DropdownMenu, Empty, InputGroup, Kbd, Label, Pagination, Popover, Progress, RadioGroup, Separator, Sheet, Skeleton, Slider, Spinner, Switch, Tabs, Textarea, Toast, Toggle and Tooltip.
26
+
27
+ Toast uses React Aria's Toast (still marked unstable upstream) rather than Sonner: render `<Toaster />` once and call `toast({ title })`.
28
+
29
+ Tokens: new `color.overlay.scrim` (Tailwind `bg-overlay-scrim/60`) for the layer behind modals. Stylesheet: new `focus-ring-drawn` utility, which draws the focus ring on a part that shows its parent's focus.
30
+
31
+ - [#22](https://github.com/graftwork-studio/design-system/pull/22) [`0c0b6dc`](https://github.com/graftwork-studio/design-system/commit/0c0b6dcb927a3948d9565f30dbf34cf800010e3a) Thanks [@david-kenny](https://github.com/david-kenny)! - Switch the sans font from Noto Sans to Geist. `font.family.sans` is now `"Geist Variable", Geist, system-ui, sans-serif`, and `@graftwork/ui` loads it from `@fontsource-variable/geist` in place of `@fontsource-variable/noto-sans`.
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [[`0c0b6dc`](https://github.com/graftwork-studio/design-system/commit/0c0b6dcb927a3948d9565f30dbf34cf800010e3a), [`cc952a7`](https://github.com/graftwork-studio/design-system/commit/cc952a705279e6ad295dde8f9c791132e1750c6f), [`0c0b6dc`](https://github.com/graftwork-studio/design-system/commit/0c0b6dcb927a3948d9565f30dbf34cf800010e3a)]:
36
+ - @graftwork/tokens@1.2.0
37
+
3
38
  ## 1.1.1
4
39
 
5
40
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ import type * as React from "react";
2
+ import { type DisclosureGroupProps, type DisclosurePanelProps, type DisclosureProps } from "react-aria-components";
3
+ export type AccordionProps = Omit<DisclosureGroupProps, "className" | "style"> & {
4
+ className?: string;
5
+ };
6
+ export declare function Accordion({ className, ...props }: AccordionProps): React.JSX.Element;
7
+ export type AccordionItemProps = Omit<DisclosureProps, "className" | "style"> & {
8
+ className?: string;
9
+ };
10
+ export declare function AccordionItem({ className, ...props }: AccordionItemProps): React.JSX.Element;
11
+ export type AccordionTriggerProps = {
12
+ children: React.ReactNode;
13
+ /** Heading level, so the sections fit the page outline. Defaults to 3. */
14
+ level?: 2 | 3 | 4 | 5 | 6;
15
+ className?: string;
16
+ };
17
+ export declare function AccordionTrigger({ children, level, className }: AccordionTriggerProps): React.JSX.Element;
18
+ export type AccordionContentProps = Omit<DisclosurePanelProps, "className" | "style"> & {
19
+ className?: string;
20
+ };
21
+ export declare function AccordionContent({ className, children, ...props }: AccordionContentProps): React.JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ChevronDownIcon } from "lucide-react";
4
+ import { Button as ButtonPrimitive, Disclosure, DisclosureGroup, DisclosurePanel, Heading, } from "react-aria-components";
5
+ import { cn } from "../lib/utils.js";
6
+ export function Accordion({ className, ...props }) {
7
+ return (_jsx(DisclosureGroup, { "data-slot": "accordion", className: cn("flex w-full flex-col divide-y divide-border-default border-y border-border-default", className), ...props }));
8
+ }
9
+ export function AccordionItem({ className, ...props }) {
10
+ return _jsx(Disclosure, { "data-slot": "accordion-item", className: cn("group/accordion", className), ...props });
11
+ }
12
+ export function AccordionTrigger({ children, level = 3, className }) {
13
+ return (_jsx(Heading, { level: level, className: "flex", children: _jsxs(ButtonPrimitive, { slot: "trigger", "data-slot": "accordion-trigger", className: cn("focus-ring flex min-h-target-min flex-1 cursor-pointer items-center justify-between gap-4 py-3 text-start text-body font-medium text-text-default", "hover:underline data-disabled:cursor-not-allowed data-disabled:opacity-50", className), children: [children, _jsx(ChevronDownIcon, { "aria-hidden": true, className: "size-4 shrink-0 text-icon-default transition-transform duration-(--gw-motion-duration-fast) group-data-expanded/accordion:rotate-180" })] }) }));
14
+ }
15
+ export function AccordionContent({ className, children, ...props }) {
16
+ return (_jsx(DisclosurePanel, { "data-slot": "accordion-content", ...props, children: _jsx("div", { className: cn("pb-4 text-body text-text-default", className), children: children }) }));
17
+ }
@@ -0,0 +1,10 @@
1
+ import type * as React from "react";
2
+ import type { DialogTriggerProps } from "react-aria-components";
3
+ import { type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, type DialogTitleProps } from "./dialog.js";
4
+ export declare function AlertDialog(props: DialogTriggerProps): React.JSX.Element;
5
+ export type AlertDialogContentProps = Omit<DialogContentProps, "role" | "showCloseButton" | "isDismissable">;
6
+ export declare function AlertDialogContent({ size, ...props }: AlertDialogContentProps): React.JSX.Element;
7
+ export declare function AlertDialogHeader(props: React.ComponentProps<typeof DialogHeader>): React.JSX.Element;
8
+ export declare function AlertDialogTitle(props: DialogTitleProps): React.JSX.Element;
9
+ export declare function AlertDialogDescription(props: React.ComponentProps<typeof DialogDescription>): React.JSX.Element;
10
+ export declare function AlertDialogFooter(props: React.ComponentProps<typeof DialogFooter>): React.JSX.Element;
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "./dialog.js";
4
+ /*
5
+ * Adapted from shadcn/ui (aria-nova). Copyright (c) 2023 shadcn. MIT licence.
6
+ *
7
+ * Figma contract: AlertDialog, AlertDialogContent { size: sm | md | lg }, AlertDialogHeader,
8
+ * AlertDialogTitle, AlertDialogDescription, AlertDialogFooter
9
+ *
10
+ * For a decision the user must make, like confirming a deletion. It uses
11
+ * role="alertdialog", can't be dismissed by clicking outside, and has no close
12
+ * button: the footer's buttons are the only way out (Escape still cancels).
13
+ * Put a Button with slot="close" in the footer for Cancel.
14
+ */
15
+ export function AlertDialog(props) {
16
+ return _jsx(Dialog, { ...props });
17
+ }
18
+ export function AlertDialogContent({ size = "sm", ...props }) {
19
+ return _jsx(DialogContent, { role: "alertdialog", size: size, showCloseButton: false, isDismissable: false, ...props });
20
+ }
21
+ export function AlertDialogHeader(props) {
22
+ return _jsx(DialogHeader, { "data-slot": "alert-dialog-header", className: "pe-0", ...props });
23
+ }
24
+ export function AlertDialogTitle(props) {
25
+ return _jsx(DialogTitle, { "data-slot": "alert-dialog-title", ...props });
26
+ }
27
+ export function AlertDialogDescription(props) {
28
+ return _jsx(DialogDescription, { "data-slot": "alert-dialog-description", ...props });
29
+ }
30
+ export function AlertDialogFooter(props) {
31
+ return _jsx(DialogFooter, { "data-slot": "alert-dialog-footer", ...props });
32
+ }
@@ -0,0 +1,11 @@
1
+ import type * as React from "react";
2
+ export type AlertVariant = "info" | "success" | "warning" | "error";
3
+ export type AlertProps = Omit<React.ComponentProps<"div">, "title"> & {
4
+ /** Sets the colour and icon. Defaults to info. */
5
+ variant?: AlertVariant;
6
+ /** Short summary in bold. */
7
+ title?: React.ReactNode;
8
+ /** A Button or link shown at the end, e.g. "Upgrade". */
9
+ action?: React.ReactNode;
10
+ };
11
+ export declare function Alert({ variant, title, action, className, children, ...props }: AlertProps): React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CircleAlertIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon } from "lucide-react";
3
+ import { cn } from "../lib/utils.js";
4
+ const variants = {
5
+ info: { box: "border-border-status-info bg-status-info-bg", icon: InfoIcon, text: "text-text-info" },
6
+ success: { box: "border-border-status-success bg-status-success-bg", icon: CircleCheckIcon, text: "text-text-success" },
7
+ warning: { box: "border-border-status-warning bg-status-warning-bg", icon: TriangleAlertIcon, text: "text-text-warning" },
8
+ error: { box: "border-border-status-error bg-status-error-bg", icon: CircleAlertIcon, text: "text-text-error" },
9
+ };
10
+ export function Alert({ variant = "info", title, action, className, children, ...props }) {
11
+ const { box, icon: Icon, text } = variants[variant];
12
+ return (_jsxs("div", { "data-slot": "alert", "data-variant": variant, className: cn("flex flex-wrap items-start gap-3 rounded-md border px-4 py-3 text-body", box, className), ...props, children: [_jsx(Icon, { "aria-hidden": true, className: cn("mt-0.5 size-5 shrink-0", text) }), _jsxs("div", { className: "flex min-w-0 flex-1 basis-48 flex-col gap-1", children: [title ? _jsx("p", { className: cn("font-semibold", text), children: title }) : null, children ? _jsx("div", { className: "text-text-default", children: children }) : null] }), action ? _jsx("div", { className: "flex shrink-0 items-center gap-2", children: action }) : null] }));
13
+ }
@@ -0,0 +1,26 @@
1
+ import * as React from "react";
2
+ declare const sizes: {
3
+ readonly sm: "size-8 text-xs";
4
+ readonly md: "size-10 text-sm";
5
+ readonly lg: "size-12 text-md";
6
+ };
7
+ export type AvatarProps = {
8
+ /** The person's name. Used for the alt text and the initials. */
9
+ name: string;
10
+ /** Photo URL. Falls back to initials if missing or broken. */
11
+ src?: string;
12
+ /** Defaults to md. */
13
+ size?: keyof typeof sizes;
14
+ /** Hide from assistive tech because the name is shown alongside. */
15
+ decorative?: boolean;
16
+ className?: string;
17
+ };
18
+ export declare function initials(name: string): string;
19
+ export declare function Avatar({ name, src, size, decorative, className }: AvatarProps): React.JSX.Element;
20
+ export type AvatarGroupProps = React.ComponentProps<"div"> & {
21
+ /** Avatars beyond this number are summarised as "+N". */
22
+ max?: number;
23
+ };
24
+ /** Overlapping avatars, e.g. the people on a project. */
25
+ export declare function AvatarGroup({ max, className, children, ...props }: AvatarGroupProps): React.JSX.Element;
26
+ export {};
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../lib/utils.js";
5
+ /*
6
+ * Adapted from shadcn/ui (aria-nova). Copyright (c) 2023 shadcn. MIT licence.
7
+ *
8
+ * Figma contract: Avatar { name; src; size: sm | md | lg }
9
+ *
10
+ * A person's photo, or their initials when there's no photo or it fails to
11
+ * load. The name is the accessible text. If the name is already written next
12
+ * to the avatar, pass decorative so it isn't read twice.
13
+ */
14
+ const sizes = { sm: "size-8 text-xs", md: "size-10 text-sm", lg: "size-12 text-md" };
15
+ export function initials(name) {
16
+ const parts = name.trim().split(/\s+/).filter(Boolean);
17
+ const first = parts[0]?.[0] ?? "";
18
+ const last = parts.length > 1 ? (parts[parts.length - 1]?.[0] ?? "") : "";
19
+ return (first + last).toUpperCase();
20
+ }
21
+ export function Avatar({ name, src, size = "md", decorative = false, className }) {
22
+ // Remember which src failed, so a new src gets a fresh try.
23
+ const [failedSrc, setFailedSrc] = React.useState();
24
+ const showImage = src && failedSrc !== src;
25
+ return (_jsx("span", { "data-slot": "avatar", role: decorative ? undefined : "img", "aria-label": decorative ? undefined : name, "aria-hidden": decorative || undefined, className: cn("relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-surface-subtle font-medium text-text-default select-none", sizes[size], className), children: showImage ? (_jsx("img", { src: src, alt: "", className: "size-full object-cover", onError: () => setFailedSrc(src) })) : (_jsx("span", { "aria-hidden": true, children: initials(name) })) }));
26
+ }
27
+ /** Overlapping avatars, e.g. the people on a project. */
28
+ export function AvatarGroup({ max, className, children, ...props }) {
29
+ const items = React.Children.toArray(children);
30
+ const shown = max ? items.slice(0, max) : items;
31
+ const extra = items.length - shown.length;
32
+ return (_jsxs("div", { "data-slot": "avatar-group", className: cn("flex items-center -space-x-2 [&>*]:ring-2 [&>*]:ring-surface-default", className), ...props, children: [shown, extra > 0 ? (_jsx("span", { role: "img", "aria-label": `${extra} more`, className: "relative inline-flex size-10 shrink-0 items-center justify-center rounded-full bg-surface-subtle text-sm font-medium text-text-default", children: _jsxs("span", { "aria-hidden": true, children: ["+", extra] }) })) : null] }));
33
+ }
@@ -0,0 +1,10 @@
1
+ import type * as React from "react";
2
+ export declare const badgeVariants: (props?: ({
3
+ variant?: "info" | "success" | "warning" | "error" | "neutral" | "outline" | null | undefined;
4
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
5
+ export type BadgeVariant = "neutral" | "info" | "success" | "warning" | "error" | "outline";
6
+ export type BadgeProps = React.ComponentProps<"span"> & {
7
+ /** Defaults to neutral. */
8
+ variant?: BadgeVariant;
9
+ };
10
+ export declare function Badge({ variant, className, ...props }: BadgeProps): React.JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cva } from "class-variance-authority";
3
+ import { cn } from "../lib/utils.js";
4
+ /*
5
+ * Adapted from shadcn/ui (aria-nova). Copyright (c) 2023 shadcn. MIT licence.
6
+ *
7
+ * Figma contract: Badge { variant: neutral | info | success | warning | error | outline }
8
+ *
9
+ * A short label for a status or category. The words carry the meaning, so
10
+ * "Live" and "Draft" read the same in any colour.
11
+ */
12
+ export const badgeVariants = cva("inline-flex w-fit shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-sm font-medium whitespace-nowrap [&_svg]:size-3.5 [&_svg]:shrink-0", {
13
+ variants: {
14
+ variant: {
15
+ neutral: "border-transparent bg-surface-subtle text-text-default",
16
+ info: "border-transparent bg-status-info-bg text-text-info",
17
+ success: "border-transparent bg-status-success-bg text-text-success",
18
+ warning: "border-transparent bg-status-warning-bg text-text-warning",
19
+ error: "border-transparent bg-status-error-bg text-text-error",
20
+ outline: "border-border-input bg-transparent text-text-default",
21
+ },
22
+ },
23
+ defaultVariants: { variant: "neutral" },
24
+ });
25
+ export function Badge({ variant = "neutral", className, ...props }) {
26
+ return _jsx("span", { "data-slot": "badge", "data-variant": variant, className: cn(badgeVariants({ variant }), className), ...props });
27
+ }
@@ -0,0 +1,15 @@
1
+ import type * as React from "react";
2
+ import { type BreadcrumbProps as BreadcrumbPrimitiveProps, type BreadcrumbsProps, type LinkProps } from "react-aria-components";
3
+ export type BreadcrumbProps<T extends object> = Omit<BreadcrumbsProps<T>, "className" | "style"> & {
4
+ /** Names the navigation landmark. Defaults to "Breadcrumb". */
5
+ "aria-label"?: string;
6
+ className?: string;
7
+ };
8
+ export declare function Breadcrumb<T extends object>({ "aria-label": label, className, ...props }: BreadcrumbProps<T>): React.JSX.Element;
9
+ export type BreadcrumbItemProps = Omit<BreadcrumbPrimitiveProps, "className" | "style" | "children"> & {
10
+ /** Where the crumb links to. Leave it out on the current page. */
11
+ href?: LinkProps["href"];
12
+ children: React.ReactNode;
13
+ className?: string;
14
+ };
15
+ export declare function BreadcrumbItem({ href, children, className, ...props }: BreadcrumbItemProps): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ChevronRightIcon } from "lucide-react";
4
+ import { Breadcrumb as BreadcrumbPrimitive, Breadcrumbs, Link, } from "react-aria-components";
5
+ import { cn } from "../lib/utils.js";
6
+ export function Breadcrumb({ "aria-label": label = "Breadcrumb", className, ...props }) {
7
+ return (_jsx("nav", { "aria-label": label, "data-slot": "breadcrumb", children: _jsx(Breadcrumbs, { className: cn("flex flex-wrap items-center gap-1 text-body text-text-secondary", className), ...props }) }));
8
+ }
9
+ export function BreadcrumbItem({ href, children, className, ...props }) {
10
+ return (_jsxs(BreadcrumbPrimitive, { "data-slot": "breadcrumb-item", className: cn("group/crumb flex items-center gap-1", className), ...props, children: [_jsx(Link, { href: href, className: cn("focus-ring rounded-sm py-1", "data-[current]:font-medium data-[current]:text-text-default data-[current]:no-underline", "not-data-[current]:text-text-link not-data-[current]:underline not-data-[current]:underline-offset-[0.15em]", "not-data-[current]:hover:decoration-2"), children: children }), _jsx(ChevronRightIcon, { "aria-hidden": true, className: "size-4 text-icon-default group-last/crumb:hidden" })] }));
11
+ }
@@ -23,9 +23,9 @@ export const buttonVariants = cva([
23
23
  destructive: "bg-action-destructive-bg text-text-on-destructive hover:bg-action-destructive-bg-hover data-pressed:bg-action-destructive-bg-hover",
24
24
  },
25
25
  size: {
26
- sm: "h-8 px-3 text-sm [&_svg]:size-4",
27
- md: "h-10 px-4 text-md [&_svg]:size-4",
28
- lg: "h-11 px-6 text-lg [&_svg]:size-5",
26
+ sm: "h-8 px-3 text-xs [&_svg]:size-4",
27
+ md: "h-10 px-4 text-body [&_svg]:size-4",
28
+ lg: "h-11 px-6 text-md [&_svg]:size-5",
29
29
  },
30
30
  },
31
31
  defaultVariants: { variant: "primary", size: "md" },
@@ -6,7 +6,7 @@ import { cn } from "../lib/utils.js";
6
6
  * Figma contract: Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter
7
7
  */
8
8
  export function Card({ className, ...props }) {
9
- return (_jsx("div", { "data-slot": "card", className: cn("flex flex-col gap-4 rounded-lg border border-border-default bg-surface-raised py-6 text-md text-text-default", className), ...props }));
9
+ return (_jsx("div", { "data-slot": "card", className: cn("flex flex-col gap-4 rounded-lg border border-border-default bg-surface-raised py-6 text-body text-text-default", className), ...props }));
10
10
  }
11
11
  export function CardHeader({ className, ...props }) {
12
12
  return _jsx("div", { "data-slot": "card-header", className: cn("flex flex-col gap-1 px-6", className), ...props });
@@ -0,0 +1,22 @@
1
+ import type * as React from "react";
2
+ import { type CheckboxGroupProps as CheckboxGroupPrimitiveProps, type CheckboxProps as CheckboxPrimitiveProps } from "react-aria-components";
3
+ /** The row a checkbox, radio or switch sits in. The whole row is the label, so the hit area is the full row. */
4
+ export declare const selectionRow: string;
5
+ /** The box or circle itself. Focus is shown on the indicator, which is what the keyboard user is operating. */
6
+ export declare const selectionIndicator: string;
7
+ export type CheckboxProps = Omit<CheckboxPrimitiveProps, "className" | "style" | "children"> & {
8
+ /** Visible label. */
9
+ children: React.ReactNode;
10
+ className?: string;
11
+ };
12
+ export declare function Checkbox({ className, children, ...props }: CheckboxProps): React.JSX.Element;
13
+ export type CheckboxGroupProps = Omit<CheckboxGroupPrimitiveProps, "className" | "style" | "children"> & {
14
+ /** Visible label for the group. */
15
+ label: string;
16
+ description?: string;
17
+ errorMessage?: string;
18
+ className?: string;
19
+ /** Checkbox elements. */
20
+ children: React.ReactNode;
21
+ };
22
+ export declare function CheckboxGroup({ label, description, errorMessage, className, children, ...props }: CheckboxGroupProps): React.JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { CheckIcon, MinusIcon } from "lucide-react";
4
+ import { Checkbox as CheckboxPrimitive, CheckboxGroup as CheckboxGroupPrimitive, composeRenderProps, } from "react-aria-components";
5
+ import { cn } from "../lib/utils.js";
6
+ import { FieldDescription, FieldErrorText, FieldLabel } from "./field.js";
7
+ /*
8
+ * Adapted from shadcn/ui (aria-nova). Copyright (c) 2023 shadcn. MIT licence.
9
+ *
10
+ * Figma contract: Checkbox { label (children); isSelected; isIndeterminate; isInvalid; isDisabled }
11
+ * CheckboxGroup { label; description; errorMessage; isInvalid; isDisabled; isRequired }
12
+ */
13
+ /** The row a checkbox, radio or switch sits in. The whole row is the label, so the hit area is the full row. */
14
+ export const selectionRow = [
15
+ "group/selection flex min-h-target-min cursor-pointer items-center gap-3 text-body text-text-default",
16
+ "data-disabled:cursor-not-allowed data-disabled:opacity-50",
17
+ ].join(" ");
18
+ /** The box or circle itself. Focus is shown on the indicator, which is what the keyboard user is operating. */
19
+ export const selectionIndicator = [
20
+ "flex shrink-0 items-center justify-center border-2 border-border-input bg-surface-default text-text-on-primary",
21
+ "transition-colors duration-(--gw-motion-duration-fast)",
22
+ "group-data-focus-visible/selection:focus-ring-drawn group-data-invalid/selection:border-border-input-invalid",
23
+ ].join(" ");
24
+ export function Checkbox({ className, children, ...props }) {
25
+ return (_jsx(CheckboxPrimitive, { "data-slot": "checkbox", className: cn(selectionRow, className), ...props, children: composeRenderProps(children, (label, { isSelected, isIndeterminate }) => (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "checkbox-indicator", className: cn(selectionIndicator, "size-5 rounded-sm", "group-data-selected/selection:border-action-primary-bg group-data-selected/selection:bg-action-primary-bg", "group-data-indeterminate/selection:border-action-primary-bg group-data-indeterminate/selection:bg-action-primary-bg"), children: isIndeterminate ? (_jsx(MinusIcon, { "aria-hidden": true, className: "size-4", strokeWidth: 3 })) : isSelected ? (_jsx(CheckIcon, { "aria-hidden": true, className: "size-4", strokeWidth: 3 })) : null }), _jsx("span", { children: label })] }))) }));
26
+ }
27
+ export function CheckboxGroup({ label, description, errorMessage, className, children, ...props }) {
28
+ return (_jsxs(CheckboxGroupPrimitive, { "data-slot": "checkbox-group", className: cn("flex flex-col gap-1", className), ...props, children: [_jsxs(FieldLabel, { elementType: "span", children: [label, props.isRequired ? _jsx("span", { className: "text-text-secondary", children: " (required)" }) : null] }), description ? _jsx(FieldDescription, { children: description }) : null, _jsx("div", { className: "flex flex-col", children: children }), _jsx(FieldErrorText, { children: errorMessage })] }));
29
+ }
@@ -0,0 +1,15 @@
1
+ import type * as React from "react";
2
+ import { type ButtonProps, type DisclosurePanelProps, type DisclosureProps } from "react-aria-components";
3
+ export type CollapsibleProps = Omit<DisclosureProps, "className" | "style"> & {
4
+ className?: string;
5
+ };
6
+ export declare function Collapsible({ className, ...props }: CollapsibleProps): React.JSX.Element;
7
+ export type CollapsibleTriggerProps = Omit<ButtonProps, "slot" | "style" | "className"> & {
8
+ className?: string;
9
+ };
10
+ export declare function CollapsibleTrigger({ className, ...props }: CollapsibleTriggerProps): React.JSX.Element;
11
+ export type CollapsibleContentProps = Omit<DisclosurePanelProps, "className" | "style"> & {
12
+ className?: string;
13
+ children?: React.ReactNode;
14
+ };
15
+ export declare function CollapsibleContent({ className, ...props }: CollapsibleContentProps): React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Button as ButtonPrimitive, Disclosure, DisclosurePanel, } from "react-aria-components";
4
+ import { cn } from "../lib/utils.js";
5
+ export function Collapsible({ className, ...props }) {
6
+ return _jsx(Disclosure, { "data-slot": "collapsible", className: cn("group/collapsible flex flex-col gap-2", className), ...props });
7
+ }
8
+ export function CollapsibleTrigger({ className, ...props }) {
9
+ return (_jsx(ButtonPrimitive, { slot: "trigger", "data-slot": "collapsible-trigger", className: cn("focus-ring hit-area inline-flex cursor-pointer items-center gap-2 rounded-md", className), ...props }));
10
+ }
11
+ export function CollapsibleContent({ className, ...props }) {
12
+ return _jsx(DisclosurePanel, { "data-slot": "collapsible-content", className: className, ...props });
13
+ }
@@ -0,0 +1,19 @@
1
+ import type * as React from "react";
2
+ import { type ComboBoxProps as ComboBoxPrimitiveProps, type ListBoxItemProps } from "react-aria-components";
3
+ export type ComboboxProps<T extends object> = Omit<ComboBoxPrimitiveProps<T>, "className" | "style" | "children"> & {
4
+ /** Visible label. Required. */
5
+ label: string;
6
+ description?: string;
7
+ errorMessage?: string;
8
+ placeholder?: string;
9
+ /** Shown in the list when nothing matches what was typed. Defaults to "No results". */
10
+ emptyMessage?: string;
11
+ className?: string;
12
+ /** ComboboxItem elements, or a render function when `items` is given. */
13
+ children: React.ReactNode | ((item: T) => React.ReactNode);
14
+ };
15
+ export declare function Combobox<T extends object>({ label, description, errorMessage, placeholder, emptyMessage, className, children, ...props }: ComboboxProps<T>): React.JSX.Element;
16
+ export type ComboboxItemProps = Omit<ListBoxItemProps, "className" | "style"> & {
17
+ className?: string;
18
+ };
19
+ export declare function ComboboxItem({ className, children, ...props }: ComboboxItemProps): React.JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { CheckIcon, ChevronDownIcon } from "lucide-react";
4
+ import { Button as ButtonPrimitive, ComboBox as ComboBoxPrimitive, composeRenderProps, Group, Input as InputPrimitive, ListBox, ListBoxItem, Popover, } from "react-aria-components";
5
+ import { cn } from "../lib/utils.js";
6
+ import { FieldDescription, FieldErrorText, FieldLabel, fieldControl } from "./field.js";
7
+ export function Combobox({ label, description, errorMessage, placeholder, emptyMessage = "No results", className, children, ...props }) {
8
+ return (_jsxs(ComboBoxPrimitive, { "data-slot": "combobox", className: cn("group/combobox flex flex-col gap-1", className), ...props, children: [_jsxs(FieldLabel, { children: [label, props.isRequired ? _jsx("span", { className: "text-text-secondary", children: " (required)" }) : null] }), description ? _jsx(FieldDescription, { children: description }) : null, _jsxs(Group, { "data-slot": "combobox-control", isDisabled: props.isDisabled, className: cn(fieldControl, "focus-ring-within flex items-center gap-1 pe-0", "group-data-invalid/combobox:border-2 group-data-invalid/combobox:border-border-input-invalid", "group-data-disabled/combobox:cursor-not-allowed group-data-disabled/combobox:opacity-50"), children: [_jsx(InputPrimitive, { "data-slot": "combobox-input", placeholder: placeholder,
9
+ // eslint-disable-next-line graftwork/no-outline-removal -- the wrapping Group draws the ring (focus-ring-within).
10
+ className: "min-h-target-min min-w-0 flex-1 bg-transparent outline-none placeholder:text-text-placeholder disabled:cursor-not-allowed" }), _jsx(ButtonPrimitive, { "data-slot": "combobox-trigger", className: "focus-ring flex size-target-min shrink-0 cursor-pointer items-center justify-center rounded-md hover:bg-action-ghost-bg-hover data-disabled:cursor-not-allowed", children: _jsx(ChevronDownIcon, { "aria-hidden": true, className: "size-4 text-icon-default" }) })] }), _jsx(FieldErrorText, { children: errorMessage }), _jsx(Popover, { "data-slot": "combobox-popover", offset: 4, className: cn("w-(--trigger-width) min-w-40 overflow-auto rounded-md border border-border-default bg-surface-overlay shadow-md", "transition-opacity duration-(--gw-motion-duration-fade) data-entering:opacity-0 data-exiting:opacity-0"), children: _jsx(ListBox, { "data-slot": "combobox-list", renderEmptyState: () => _jsx("p", { className: "px-3 py-2 text-sm text-text-secondary", children: emptyMessage }), className: "focus-ring max-h-72 p-1", children: children }) })] }));
11
+ }
12
+ export function ComboboxItem({ className, children, ...props }) {
13
+ return (_jsx(ListBoxItem, { "data-slot": "combobox-item", textValue: typeof children === "string" ? children : props.textValue, className: cn("flex min-h-target-min cursor-pointer items-center justify-between gap-2 rounded-sm px-3 text-body text-text-default outline-none", "data-focused:bg-action-ghost-bg-hover data-focus-visible:outline-2 data-focus-visible:outline-solid data-focus-visible:-outline-offset-2 data-focus-visible:outline-focus-ring", "data-disabled:cursor-not-allowed data-disabled:opacity-50", className), ...props, children: composeRenderProps(children, (content, { isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: "truncate", children: content }), isSelected ? _jsx(CheckIcon, { "aria-hidden": true, className: "size-4 shrink-0 text-icon-brand" }) : null] }))) }));
14
+ }
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import { type DialogProps as DialogPrimitiveProps, type DialogTriggerProps, Heading, type ModalOverlayProps } from "react-aria-components";
3
+ /** Wraps the trigger (any Button) and the DialogContent. Control it with isOpen and onOpenChange. */
4
+ export declare function Dialog(props: DialogTriggerProps): React.JSX.Element;
5
+ /** The dimmed layer behind a modal. Shared by Dialog, AlertDialog and Sheet. */
6
+ export declare const modalOverlay: string;
7
+ declare const sizes: {
8
+ readonly sm: "max-w-sm";
9
+ readonly md: "max-w-lg";
10
+ readonly lg: "max-w-2xl";
11
+ };
12
+ export type DialogContentProps = Omit<ModalOverlayProps, "className" | "style" | "children"> & {
13
+ /** Maximum width. Defaults to md. */
14
+ size?: keyof typeof sizes;
15
+ /** Show a close button in the corner. Defaults to true. */
16
+ showCloseButton?: boolean;
17
+ /** Use role="alertdialog". Set by AlertDialogContent. */
18
+ role?: DialogPrimitiveProps["role"];
19
+ className?: string;
20
+ children: DialogPrimitiveProps["children"];
21
+ };
22
+ export declare function DialogContent({ size, showCloseButton, role, className, children, isDismissable, ...props }: DialogContentProps): React.JSX.Element;
23
+ /** Lets DialogDescription register itself as the dialog's description. Used by Sheet too. */
24
+ export declare function useDialogDescription(): {
25
+ descriptionId: string | undefined;
26
+ Provider: React.Provider<((id: string | undefined) => void) | null>;
27
+ setDescriptionId: React.Dispatch<React.SetStateAction<string | undefined>>;
28
+ };
29
+ export declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
30
+ export type DialogTitleProps = Omit<React.ComponentProps<typeof Heading>, "slot">;
31
+ /** The dialog's accessible name. Every dialog needs one. */
32
+ export declare function DialogTitle({ className, level, ...props }: DialogTitleProps): React.JSX.Element;
33
+ export declare function DialogDescription({ className, id, ...props }: React.ComponentProps<"p">): React.JSX.Element;
34
+ export declare function DialogBody({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
35
+ export declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
36
+ export {};
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { XIcon } from "lucide-react";
4
+ import * as React from "react";
5
+ import { Button as ButtonPrimitive, Dialog as DialogPrimitive, DialogTrigger, Heading, Modal, ModalOverlay, } from "react-aria-components";
6
+ import { cn } from "../lib/utils.js";
7
+ /*
8
+ * Adapted from shadcn/ui (aria-nova). Copyright (c) 2023 shadcn. MIT licence.
9
+ *
10
+ * Figma contract: Dialog, DialogContent { size: sm | md | lg; showCloseButton }, DialogHeader,
11
+ * DialogTitle, DialogDescription, DialogBody, DialogFooter
12
+ *
13
+ * <Dialog>
14
+ * <Button>Rename</Button>
15
+ * <DialogContent>
16
+ * <DialogHeader><DialogTitle>Rename project</DialogTitle></DialogHeader>
17
+ * …
18
+ * <DialogFooter><Button slot="close" variant="secondary">Cancel</Button>…</DialogFooter>
19
+ * </DialogContent>
20
+ * </Dialog>
21
+ *
22
+ * Focus moves into the dialog, stays there, and returns to the trigger on close.
23
+ */
24
+ /** Wraps the trigger (any Button) and the DialogContent. Control it with isOpen and onOpenChange. */
25
+ export function Dialog(props) {
26
+ return _jsx(DialogTrigger, { ...props });
27
+ }
28
+ /** The dimmed layer behind a modal. Shared by Dialog, AlertDialog and Sheet. */
29
+ export const modalOverlay = cn("fixed inset-0 z-50 flex min-h-dvh w-full items-center justify-center bg-overlay-scrim/60 p-4", "transition-opacity duration-(--gw-motion-duration-fade) data-entering:opacity-0 data-exiting:opacity-0");
30
+ const sizes = { sm: "max-w-sm", md: "max-w-lg", lg: "max-w-2xl" };
31
+ /*
32
+ * React Aria names the dialog from its title but doesn't link a description, so
33
+ * DialogDescription registers its id here and DialogContent sets aria-describedby.
34
+ */
35
+ const DescriptionContext = React.createContext(null);
36
+ export function DialogContent({ size = "md", showCloseButton = true, role, className, children, isDismissable = true, ...props }) {
37
+ const [descriptionId, setDescriptionId] = React.useState();
38
+ return (_jsx(ModalOverlay, { "data-slot": "dialog-overlay", isDismissable: isDismissable, className: modalOverlay, ...props, children: _jsx(Modal, { "data-slot": "dialog-modal", className: cn("w-full rounded-lg border border-border-default bg-surface-overlay text-body text-text-default shadow-lg", "max-h-[calc(100dvh-2rem)] overflow-y-auto", sizes[size]), children: _jsx(DialogPrimitive, { "data-slot": "dialog", role: role, "aria-describedby": descriptionId, className: cn("focus-ring relative flex flex-col gap-4 p-6", className), children: (renderProps) => (_jsxs(DescriptionContext.Provider, { value: setDescriptionId, children: [typeof children === "function" ? children(renderProps) : children, showCloseButton ? (_jsx(ButtonPrimitive, { slot: "close", "aria-label": "Close", "data-slot": "dialog-close", className: "focus-ring hit-area absolute top-4 right-4 flex size-8 cursor-pointer items-center justify-center rounded-md text-icon-default hover:bg-action-ghost-bg-hover", children: _jsx(XIcon, { "aria-hidden": true, className: "size-4" }) })) : null] })) }) }) }));
39
+ }
40
+ /** Lets DialogDescription register itself as the dialog's description. Used by Sheet too. */
41
+ export function useDialogDescription() {
42
+ const [descriptionId, setDescriptionId] = React.useState();
43
+ return { descriptionId, Provider: DescriptionContext.Provider, setDescriptionId };
44
+ }
45
+ export function DialogHeader({ className, ...props }) {
46
+ return _jsx("div", { "data-slot": "dialog-header", className: cn("flex flex-col gap-1 pe-8", className), ...props });
47
+ }
48
+ /** The dialog's accessible name. Every dialog needs one. */
49
+ export function DialogTitle({ className, level = 2, ...props }) {
50
+ return (_jsx(Heading, { slot: "title", level: level, "data-slot": "dialog-title", className: cn("text-xl leading-heading font-semibold text-text-default", className), ...props }));
51
+ }
52
+ export function DialogDescription({ className, id, ...props }) {
53
+ const generated = React.useId();
54
+ const descriptionId = id ?? generated;
55
+ const register = React.useContext(DescriptionContext);
56
+ React.useLayoutEffect(() => {
57
+ register?.(descriptionId);
58
+ return () => register?.(undefined);
59
+ }, [register, descriptionId]);
60
+ return (_jsx("p", { "data-slot": "dialog-description", id: descriptionId, className: cn("text-sm text-text-secondary", className), ...props }));
61
+ }
62
+ export function DialogBody({ className, ...props }) {
63
+ return _jsx("div", { "data-slot": "dialog-body", className: cn("flex flex-col gap-4", className), ...props });
64
+ }
65
+ export function DialogFooter({ className, ...props }) {
66
+ return (_jsx("div", { "data-slot": "dialog-footer", className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className), ...props }));
67
+ }
@@ -0,0 +1,27 @@
1
+ import type * as React from "react";
2
+ import { type MenuItemProps, type MenuProps, type MenuSectionProps, type MenuTriggerProps, type PopoverProps, type SubmenuTriggerProps } from "react-aria-components";
3
+ export declare function DropdownMenu(props: MenuTriggerProps): React.JSX.Element;
4
+ export type DropdownMenuContentProps<T extends object> = Omit<MenuProps<T>, "className" | "style"> & {
5
+ placement?: PopoverProps["placement"];
6
+ className?: string;
7
+ };
8
+ export declare function DropdownMenuContent<T extends object>({ placement, className, ...props }: DropdownMenuContentProps<T>): React.JSX.Element;
9
+ export type DropdownMenuItemProps<T extends object> = Omit<MenuItemProps<T>, "className" | "style"> & {
10
+ /** destructive colours the label, for actions like Delete. Defaults to default. */
11
+ variant?: "default" | "destructive";
12
+ /** Keyboard shortcut shown on the right, e.g. "⌘D". It's a hint; wire the shortcut up yourself. */
13
+ shortcut?: string;
14
+ className?: string;
15
+ };
16
+ export declare function DropdownMenuItem<T extends object>({ variant, shortcut, className, children, ...props }: DropdownMenuItemProps<T>): React.JSX.Element;
17
+ export type DropdownMenuSectionProps<T extends object> = Omit<MenuSectionProps<T>, "className" | "style"> & {
18
+ /** Visible heading for the group. */
19
+ title?: string;
20
+ className?: string;
21
+ };
22
+ export declare function DropdownMenuSection<T extends object>({ title, className, children, ...props }: DropdownMenuSectionProps<T>): React.JSX.Element;
23
+ export declare function DropdownMenuSeparator({ className }: {
24
+ className?: string;
25
+ }): React.JSX.Element;
26
+ /** A nested menu: a DropdownMenuItem followed by a DropdownMenuContent. */
27
+ export declare function DropdownMenuSub(props: SubmenuTriggerProps): React.JSX.Element;