@zhin.js/console-ui 1.0.0 → 1.1.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 (95) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +118 -11
  3. package/audit/index.mjs +21 -0
  4. package/audit/layout-audit.mjs +492 -0
  5. package/audit/mount-page.jsx +90 -0
  6. package/audit/plugin-pages.mjs +186 -0
  7. package/dist/components/BrandMark.d.ts +16 -0
  8. package/dist/components/BrandMark.js +21 -0
  9. package/dist/components/InfoHint.js +2 -1
  10. package/dist/components/PageHeader.d.ts +9 -2
  11. package/dist/components/PageHeader.js +6 -3
  12. package/dist/components/PageShell.d.ts +18 -3
  13. package/dist/components/PageShell.js +5 -3
  14. package/dist/components/RefreshControl.d.ts +6 -1
  15. package/dist/components/RefreshControl.js +9 -6
  16. package/dist/components/StatCard.d.ts +19 -5
  17. package/dist/components/StatCard.js +36 -10
  18. package/dist/components/StatusBadge.d.ts +14 -0
  19. package/dist/components/StatusBadge.js +19 -0
  20. package/dist/components/actions.d.ts +53 -0
  21. package/dist/components/actions.js +50 -0
  22. package/dist/components/code.d.ts +11 -0
  23. package/dist/components/code.js +10 -0
  24. package/dist/components/confirm-dialog.js +3 -2
  25. package/dist/components/content-blocks.d.ts +141 -0
  26. package/dist/components/content-blocks.js +77 -0
  27. package/dist/components/empty-illustrations.d.ts +15 -0
  28. package/dist/components/empty-illustrations.js +36 -0
  29. package/dist/components/empty-state.d.ts +23 -3
  30. package/dist/components/empty-state.js +36 -8
  31. package/dist/components/error-alert.js +2 -1
  32. package/dist/components/icon.d.ts +11 -0
  33. package/dist/components/icon.js +8 -0
  34. package/dist/components/layout.d.ts +38 -0
  35. package/dist/components/layout.js +28 -0
  36. package/dist/components/page-chrome.d.ts +12 -0
  37. package/dist/components/page-chrome.js +6 -5
  38. package/dist/components/ui/accordion.js +3 -2
  39. package/dist/components/ui/alert.js +5 -5
  40. package/dist/components/ui/badge.js +10 -9
  41. package/dist/components/ui/button.d.ts +10 -1
  42. package/dist/components/ui/button.js +26 -11
  43. package/dist/components/ui/card.d.ts +6 -0
  44. package/dist/components/ui/card.js +5 -4
  45. package/dist/components/ui/checkbox.js +2 -1
  46. package/dist/components/ui/control-variant.d.ts +10 -0
  47. package/dist/components/ui/control-variant.js +6 -0
  48. package/dist/components/ui/date-field-model.d.ts +39 -0
  49. package/dist/components/ui/date-field-model.js +105 -0
  50. package/dist/components/ui/date-field.d.ts +33 -0
  51. package/dist/components/ui/date-field.js +161 -0
  52. package/dist/components/ui/dialog.js +7 -6
  53. package/dist/components/ui/dropdown-menu.js +6 -5
  54. package/dist/components/ui/input.d.ts +6 -1
  55. package/dist/components/ui/input.js +3 -2
  56. package/dist/components/ui/list-item-button.js +1 -1
  57. package/dist/components/ui/popover.js +1 -1
  58. package/dist/components/ui/radio-group.js +1 -1
  59. package/dist/components/ui/scroll-area.js +1 -1
  60. package/dist/components/ui/searchable-select.d.ts +3 -0
  61. package/dist/components/ui/searchable-select.js +4 -3
  62. package/dist/components/ui/select.d.ts +7 -1
  63. package/dist/components/ui/select.js +7 -5
  64. package/dist/components/ui/sheet.js +4 -3
  65. package/dist/components/ui/skeleton.js +1 -1
  66. package/dist/components/ui/switch.js +1 -1
  67. package/dist/components/ui/table.d.ts +11 -0
  68. package/dist/components/ui/table.js +37 -6
  69. package/dist/components/ui/tabs.js +3 -3
  70. package/dist/components/ui/textarea.d.ts +6 -1
  71. package/dist/components/ui/textarea.js +3 -2
  72. package/dist/components/ui/tooltip.js +1 -1
  73. package/dist/components/use-container-width.d.ts +13 -0
  74. package/dist/components/use-container-width.js +30 -0
  75. package/dist/custom-media.css +13 -0
  76. package/dist/exports.json +41 -1
  77. package/dist/i18n/messages.d.ts +20 -1
  78. package/dist/i18n/messages.js +40 -2
  79. package/dist/index.d.ts +12 -0
  80. package/dist/index.js +11 -0
  81. package/dist/scale.json +643 -0
  82. package/dist/styles.css +1919 -836
  83. package/dist/theme.css +469 -0
  84. package/dist/tokens.css +434 -123
  85. package/dist/version.js +1 -1
  86. package/lint/eslint-plugin.mjs +128 -0
  87. package/lint/stylelint-config.mjs +43 -0
  88. package/lint/stylelint-plugin.mjs +195 -0
  89. package/lint/tailwind-classes.mjs +121 -0
  90. package/package.json +33 -3
  91. package/tokens/color.mjs +104 -0
  92. package/tokens/colors.css +220 -0
  93. package/tokens/generate.mjs +288 -0
  94. package/tokens/scale.mjs +137 -0
  95. package/tokens/tokens.mjs +362 -0
@@ -5,22 +5,23 @@ import * as Radix from "radix-ui";
5
5
  const DialogPrimitive = Radix.Dialog;
6
6
  import { cn } from '../../cn.js';
7
7
  import { X } from "lucide-react";
8
+ import { CONSOLE_ICON_STROKE_WIDTH } from '../icon.js';
8
9
  const Dialog = DialogPrimitive.Root;
9
10
  const DialogTrigger = DialogPrimitive.Trigger;
10
11
  const DialogPortal = DialogPrimitive.Portal;
11
12
  const DialogClose = DialogPrimitive.Close;
12
- const DialogOverlay = forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Overlay, { ref: ref, className: cn("console-dialog-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className), ...props })));
13
+ const DialogOverlay = forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Overlay, { ref: ref, className: cn("console-dialog-overlay", className), ...props })));
13
14
  DialogOverlay.displayName = "DialogOverlay";
14
- const DialogContent = forwardRef(({ className, children, variant = "modal", side = "right", ...props }, ref) => (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { ref: ref, "data-side": variant === "drawer" ? side : undefined, className: cn(variant === "drawer"
15
+ const DialogContent = forwardRef(({ className, children, variant = "modal", side = "right", ...props }, ref) => (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { ref: ref, "data-side": variant === "drawer" ? side : undefined, "data-slot": variant === "drawer" ? "sheet" : "dialog", className: cn(variant === "drawer"
15
16
  ? "console-sheet-content outline-none"
16
- : "fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-2rem)] max-w-lg max-h-[calc(100dvh-2.5rem)] overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border-0 bg-popover text-popover-foreground p-[calc(var(--console-space-card)+0.25rem)] shadow-[var(--console-shadow-lg)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-[var(--console-radius-2xl)] outline-none", className), ...props, children: [children, _jsxs(DialogPrimitive.Close, { className: "console-dialog-close disabled:pointer-events-none", children: [_jsx(X, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: _jsx(ConsoleUiText, { id: "dialog.close" }) })] })] })] })));
17
+ : "console-dialog", className), ...props, children: [children, _jsxs(DialogPrimitive.Close, { className: "console-dialog-close disabled:pointer-events-none", children: [_jsx(X, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-4" }), _jsx("span", { className: "sr-only", children: _jsx(ConsoleUiText, { id: "dialog.close" }) })] })] })] })));
17
18
  DialogContent.displayName = "DialogContent";
18
- const DialogHeader = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col space-y-1.5 pr-8 text-left", className), ...props }));
19
+ const DialogHeader = ({ className, ...props }) => (_jsx("div", { className: cn("console-dialog-header", className), ...props }));
19
20
  DialogHeader.displayName = "DialogHeader";
20
- const DialogFooter = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:justify-end", className), ...props }));
21
+ const DialogFooter = ({ className, ...props }) => (_jsx("div", { className: cn("console-dialog-footer", className), ...props }));
21
22
  DialogFooter.displayName = "DialogFooter";
22
23
  const DialogTitle = forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Title, { ref: ref, className: cn("console-section-title", className), ...props })));
23
24
  DialogTitle.displayName = "DialogTitle";
24
- const DialogDescription = forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Description, { ref: ref, className: cn("text-[length:var(--console-text-body)] text-muted-foreground", className), ...props })));
25
+ const DialogDescription = forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Description, { ref: ref, className: cn("text-body text-muted-foreground", className), ...props })));
25
26
  DialogDescription.displayName = "DialogDescription";
26
27
  export { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, };
@@ -4,21 +4,22 @@ import * as Radix from "radix-ui";
4
4
  const DropdownMenuPrimitive = Radix.DropdownMenu;
5
5
  import { cn } from '../../cn.js';
6
6
  import { Check, Circle } from "lucide-react";
7
+ import { CONSOLE_ICON_STROKE_WIDTH } from '../icon.js';
7
8
  const DropdownMenu = DropdownMenuPrimitive.Root;
8
9
  const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
9
10
  const DropdownMenuGroup = DropdownMenuPrimitive.Group;
10
11
  const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
11
12
  const DropdownMenuSub = DropdownMenuPrimitive.Sub;
12
13
  const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
13
- const DropdownMenuContent = forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn("z-50 min-w-[9.5rem] overflow-hidden rounded-[var(--console-radius-lg)] border-0 bg-popover p-1.5 text-popover-foreground shadow-[var(--console-shadow-lg)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className), ...props }) })));
14
+ const DropdownMenuContent = forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { ref: ref, "data-slot": "popover", sideOffset: sideOffset, className: cn("console-popover min-w-40", className), ...props }) })));
14
15
  DropdownMenuContent.displayName = "DropdownMenuContent";
15
- const DropdownMenuItem = forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Item, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center gap-2 rounded-[var(--console-radius-sm)] px-2 py-1.5 text-[length:var(--console-text-body)] outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", inset && "pl-8", className), ...props })));
16
+ const DropdownMenuItem = forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Item, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center gap-2 px-3 py-1 text-body outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", inset && "pl-8", className), ...props })));
16
17
  DropdownMenuItem.displayName = "DropdownMenuItem";
17
- const DropdownMenuCheckboxItem = forwardRef(({ className, children, checked, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.CheckboxItem, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center rounded-[var(--console-radius-sm)] py-1.5 pl-8 pr-2 text-[length:var(--console-text-body)] outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), checked: checked, ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), children] })));
18
+ const DropdownMenuCheckboxItem = forwardRef(({ className, children, checked, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.CheckboxItem, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center py-1 pl-8 pr-3 text-body outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), checked: checked, ...props, children: [_jsx("span", { className: "absolute left-2 flex size-4 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(Check, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-4" }) }) }), children] })));
18
19
  DropdownMenuCheckboxItem.displayName = "DropdownMenuCheckboxItem";
19
- const DropdownMenuRadioItem = forwardRef(({ className, children, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.RadioItem, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center gap-2 rounded-[var(--console-radius-sm)] py-1.5 pl-8 pr-2 text-[length:var(--console-text-body)] outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", className), ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }), children] })));
20
+ const DropdownMenuRadioItem = forwardRef(({ className, children, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.RadioItem, { ref: ref, className: cn("console-menu-item relative flex cursor-default select-none items-center gap-2 py-1 pl-8 pr-3 text-body outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", className), ...props, children: [_jsx("span", { className: "absolute left-2 flex size-4 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(Circle, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-2 fill-current" }) }) }), children] })));
20
21
  DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem";
21
- const DropdownMenuLabel = forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Label, { ref: ref, className: cn("px-2 py-1.5 text-[length:var(--console-text-body)] font-semibold", inset && "pl-8", className), ...props })));
22
+ const DropdownMenuLabel = forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Label, { ref: ref, className: cn("px-3 py-1 text-label font-strong text-muted-foreground", inset && "pl-8", className), ...props })));
22
23
  DropdownMenuLabel.displayName = "DropdownMenuLabel";
23
24
  const DropdownMenuSeparator = forwardRef(({ className, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Separator, { ref: ref, className: cn("-mx-1 my-1 h-px bg-muted", className), ...props })));
24
25
  DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
@@ -1,3 +1,8 @@
1
1
  import type * as React from "react";
2
- declare const Input: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
2
+ import { type ControlVariant } from './control-variant.js';
3
+ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
+ /** `ghost`: no border until hovered or focused, for secondary fields (ADR 0063 D29). */
5
+ variant?: ControlVariant;
6
+ }
7
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
3
8
  export { Input };
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { cn } from '../../cn.js';
4
- const Input = forwardRef(({ className, type, ...props }, ref) => {
5
- return (_jsx("input", { type: type, className: cn("console-control flex h-[var(--console-control-height)] w-full rounded-[var(--console-radius-md)] border-[length:var(--console-border-width)] border-input bg-card hover:border-[hsl(var(--foreground)/0.45)] focus-visible:border-[hsl(var(--primary))] shadow-[var(--console-shadow-xs)] px-3 py-1 text-[length:var(--console-text-body)] transition-colors file:border-0 file:bg-transparent file:text-[length:var(--console-text-body)] file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-60", className), ref: ref, ...props }));
4
+ import { controlVariantClass } from './control-variant.js';
5
+ const Input = forwardRef(({ className, type, variant, ...props }, ref) => {
6
+ return (_jsx("input", { type: type, "data-slot": "input", "data-variant": variant === 'ghost' ? 'ghost' : undefined, className: cn("console-control flex h-control w-full rounded-control border px-3 py-1 text-body transition-colors file:border-0 file:bg-transparent file:text-body file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60", controlVariantClass(variant), className), ref: ref, ...props }));
6
7
  });
7
8
  Input.displayName = "Input";
8
9
  export { Input };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { cn } from '../../cn.js';
4
- const ListItemButton = forwardRef(({ className, type = "button", ...props }, ref) => (_jsx("button", { ref: ref, type: type, className: cn("cursor-pointer text-left max-md:min-h-11 disabled:cursor-not-allowed disabled:opacity-50", "focus-visible:outline focus-visible:outline-[length:var(--console-focus-width)] focus-visible:outline-offset-2 focus-visible:outline-ring", className), ...props })));
4
+ const ListItemButton = forwardRef(({ className, type = "button", ...props }, ref) => (_jsx("button", { ref: ref, type: type, className: cn("cursor-pointer text-left min-h-touch-min disabled:cursor-not-allowed disabled:opacity-50", className), ...props })));
5
5
  ListItemButton.displayName = "ListItemButton";
6
6
  export { ListItemButton };
@@ -5,5 +5,5 @@ import { cn } from '../../cn.js';
5
5
  export const Popover = Primitive.Root;
6
6
  export const PopoverTrigger = Primitive.Trigger;
7
7
  export const PopoverAnchor = Primitive.Anchor;
8
- export const PopoverContent = forwardRef(({ className, align = 'start', sideOffset = 8, ...props }, ref) => _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { ref: ref, align: align, sideOffset: sideOffset, collisionPadding: 12, className: cn('z-50 rounded-[var(--console-radius-lg)] border-[length:var(--console-border-width)] border-[color:var(--console-border-default)] bg-popover p-4 text-popover-foreground shadow-[var(--console-shadow-lg)] outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-1.5 data-[side=top]:slide-in-from-bottom-1.5', className), ...props }) }));
8
+ export const PopoverContent = forwardRef(({ className, align = 'start', sideOffset = 8, ...props }, ref) => _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { ref: ref, "data-slot": "popover", align: align, sideOffset: sideOffset, collisionPadding: 12, className: cn('console-popover console-popover--panel', className), ...props }) }));
9
9
  PopoverContent.displayName = 'PopoverContent';
@@ -5,6 +5,6 @@ import { cn } from '../../cn.js';
5
5
  const RadioGroupPrimitive = Radix.RadioGroup;
6
6
  const RadioGroup = forwardRef(({ className, ...props }, ref) => (_jsx(RadioGroupPrimitive.Root, { className: cn("grid gap-2", className), ...props, ref: ref })));
7
7
  RadioGroup.displayName = "RadioGroup";
8
- const RadioGroupItem = forwardRef(({ className, ...props }, ref) => (_jsx(RadioGroupPrimitive.Item, { ref: ref, className: cn("console-control aspect-square h-4 w-4 shrink-0 rounded-full border border-input bg-card text-primary transition-colors disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary", className), ...props, children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx("span", { className: "h-2 w-2 rounded-full bg-current" }) }) })));
8
+ const RadioGroupItem = forwardRef(({ className, ...props }, ref) => (_jsx(RadioGroupPrimitive.Item, { ref: ref, className: cn("console-control console-touch aspect-square size-4 shrink-0 rounded-full border border-input bg-card text-brand-text transition-colors disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-brand-text", className), ...props, children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx("span", { className: "h-2 w-2 rounded-full bg-current" }) }) })));
9
9
  RadioGroupItem.displayName = "RadioGroupItem";
10
10
  export { RadioGroup, RadioGroupItem };
@@ -7,7 +7,7 @@ const ScrollArea = forwardRef(({ className, children, ...props }, ref) => (_jsxs
7
7
  ScrollArea.displayName = "ScrollArea";
8
8
  const ScrollBar = forwardRef(({ className, orientation: orientationProp, ...props }, ref) => {
9
9
  const orientation = (orientationProp ?? "vertical");
10
- return (_jsx(ScrollAreaPrimitive.Scrollbar, { ref: ref, orientation: orientation, className: cn("flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]", className), ...props, children: _jsx(ScrollAreaPrimitive.Thumb, { className: "relative flex-1 rounded-full bg-border" }) }));
10
+ return (_jsx(ScrollAreaPrimitive.Scrollbar, { ref: ref, orientation: orientation, className: cn("flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-px", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-px", className), ...props, children: _jsx(ScrollAreaPrimitive.Thumb, { className: "relative flex-1 rounded-full bg-border" }) }));
11
11
  });
12
12
  ScrollBar.displayName = "ScrollBar";
13
13
  export { ScrollArea, ScrollBar };
@@ -1,4 +1,5 @@
1
1
  import type * as React from 'react';
2
+ import type { ControlVariant } from './control-variant.js';
2
3
  import { type SearchableSelectOption } from './searchable-select-model.js';
3
4
  export type { SearchableSelectOption };
4
5
  export interface SearchableSelectFieldProps {
@@ -14,6 +15,8 @@ export interface SearchableSelectFieldProps {
14
15
  searchPlaceholder?: string;
15
16
  /** Shown when nothing matches the search. */
16
17
  emptyText?: string;
18
+ /** `ghost`: no border until hovered, focused or open, for secondary fields (ADR 0063 D29). */
19
+ variant?: ControlVariant;
17
20
  }
18
21
  /**
19
22
  * A select for long lists: a popover with a search box and grouped options (combobox / listbox
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useEffect, useId, useMemo, useRef, useState } from 'react';
3
3
  import { Check, ChevronDown, Search } from 'lucide-react';
4
+ import { CONSOLE_ICON_STROKE_WIDTH } from '../icon.js';
4
5
  import { cn } from '../../cn.js';
5
6
  import { useConsoleUiI18n } from '../../i18n/index.js';
6
7
  import { Popover, PopoverContent, PopoverTrigger } from './popover.js';
@@ -10,7 +11,7 @@ import { groupSelectOptions, navigableValues } from './searchable-select-model.j
10
11
  * pattern). Same controlled contract as SelectField (`options` / `value` / `onValueChange`), plus
11
12
  * `group`, `description` and `keywords` per option. ↑ / ↓ move, Enter picks, Esc closes.
12
13
  */
13
- export const SearchableSelectField = forwardRef(({ options, value, onValueChange, disabled, className, id, searchPlaceholder, emptyText, ...aria }, ref) => {
14
+ export const SearchableSelectField = forwardRef(({ options, value, onValueChange, disabled, className, id, searchPlaceholder, emptyText, variant, ...aria }, ref) => {
14
15
  const i18n = useConsoleUiI18n();
15
16
  const listId = useId();
16
17
  const [open, setOpen] = useState(false);
@@ -74,10 +75,10 @@ export const SearchableSelectField = forwardRef(({ options, value, onValueChange
74
75
  }
75
76
  };
76
77
  const optionId = (optionValue) => `${listId}-${order.indexOf(optionValue)}`;
77
- return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { ref: ref, type: "button", id: id, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listId : undefined, disabled: disabled, className: cn('console-control console-searchable-select-trigger', className), ...aria, children: [_jsx("span", { className: "console-searchable-select-value", children: selected ? selected.label : value }), _jsx(ChevronDown, { "aria-hidden": "true", className: "console-searchable-select-chevron" })] }) }), _jsxs(PopoverContent, { className: "console-searchable-select-popover", sideOffset: 4, onOpenAutoFocus: event => event.preventDefault(), children: [_jsxs("div", { className: "console-searchable-select-search", children: [_jsx(Search, { "aria-hidden": "true" }), _jsx("input", { autoFocus: true, value: query, onChange: event => setQuery(event.target.value), onKeyDown: onKeyDown, placeholder: searchPlaceholder ?? i18n.t('select.searchPlaceholder'), "aria-label": searchPlaceholder ?? i18n.t('select.searchPlaceholder'), "aria-controls": listId, "aria-activedescendant": active !== null && order.includes(active) ? optionId(active) : undefined, "aria-autocomplete": "list", role: "combobox", "aria-expanded": "true" })] }), _jsx("div", { ref: listRef, id: listId, role: "listbox", "aria-label": aria['aria-label'], className: "console-searchable-select-list", children: grouped.length ? grouped.map(entry => {
78
+ return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { ref: ref, type: "button", id: id, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listId : undefined, disabled: disabled, "data-slot": "input", "data-variant": variant === 'ghost' ? 'ghost' : undefined, className: cn('console-control console-searchable-select-trigger', className), ...aria, children: [_jsx("span", { className: "console-searchable-select-value", children: selected ? selected.label : value }), _jsx(ChevronDown, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, "aria-hidden": "true", className: "console-searchable-select-chevron" })] }) }), _jsxs(PopoverContent, { className: "console-searchable-select-popover", sideOffset: 4, onOpenAutoFocus: event => event.preventDefault(), children: [_jsxs("div", { className: "console-searchable-select-search", children: [_jsx(Search, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, "aria-hidden": "true" }), _jsx("input", { autoFocus: true, value: query, onChange: event => setQuery(event.target.value), onKeyDown: onKeyDown, placeholder: searchPlaceholder ?? i18n.t('select.searchPlaceholder'), "aria-label": searchPlaceholder ?? i18n.t('select.searchPlaceholder'), "aria-controls": listId, "aria-activedescendant": active !== null && order.includes(active) ? optionId(active) : undefined, "aria-autocomplete": "list", role: "combobox", "aria-expanded": "true" })] }), _jsx("div", { ref: listRef, id: listId, role: "listbox", "aria-label": aria['aria-label'], className: "console-searchable-select-list", children: grouped.length ? grouped.map(entry => {
78
79
  const items = entry.options.map(option => (_jsxs("div", { id: option.disabled ? undefined : optionId(option.value), role: "option", "data-value": option.value, "aria-selected": option.value === value, "aria-disabled": option.disabled || undefined, className: cn('console-searchable-select-option', option.value === active && 'is-active', option.value === value && 'is-selected'), onMouseMove: () => { if (!option.disabled && active !== option.value)
79
80
  setActive(option.value); }, onMouseDown: event => event.preventDefault(), onClick: () => { if (!option.disabled)
80
- pick(option.value); }, title: typeof option.label === 'string' ? option.label : undefined, children: [_jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "console-searchable-select-label", children: option.label }), option.description ? _jsx("span", { className: "console-searchable-select-description", children: option.description }) : null] }), option.value === value ? _jsx(Check, { "aria-hidden": "true", className: "console-searchable-select-check" }) : null] }, option.value)));
81
+ pick(option.value); }, title: typeof option.label === 'string' ? option.label : undefined, children: [_jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "console-searchable-select-label", children: option.label }), option.description ? _jsx("span", { className: "console-searchable-select-description", children: option.description }) : null] }), option.value === value ? _jsx(Check, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, "aria-hidden": "true", className: "console-searchable-select-check" }) : null] }, option.value)));
81
82
  return entry.group === null ? _jsx("div", { role: "group", children: items }, "__top") : (_jsxs("div", { role: "group", "aria-label": entry.group, className: "console-searchable-select-group", children: [_jsxs("div", { className: "console-searchable-select-group-label", "aria-hidden": "true", children: [entry.group, _jsx("span", { children: entry.options.length })] }), items] }, entry.group));
82
83
  }) : _jsx("p", { className: "console-searchable-select-empty", children: emptyText ?? i18n.t('select.noMatch') }) })] })] }));
83
84
  });
@@ -1,9 +1,15 @@
1
1
  import type * as React from "react";
2
2
  import * as Radix from "radix-ui";
3
+ declare const SelectPrimitive: typeof Radix.Select;
4
+ import { type ControlVariant } from './control-variant.js';
3
5
  declare const Select: React.FC<Radix.Select.SelectProps>;
4
6
  declare const SelectGroup: React.ForwardRefExoticComponent<Radix.Select.SelectGroupProps & React.RefAttributes<HTMLDivElement>>;
5
7
  declare const SelectValue: React.ForwardRefExoticComponent<Radix.Select.SelectValueProps & React.RefAttributes<HTMLSpanElement>>;
6
- declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<Radix.Select.SelectTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
8
+ export interface SelectTriggerProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> {
9
+ /** `ghost`: no border until hovered, focused or open, for secondary fields (ADR 0063 D29). */
10
+ variant?: ControlVariant;
11
+ }
12
+ declare const SelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
7
13
  declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<Radix.Select.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
8
14
  declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<Radix.Select.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
15
  declare const SelectContent: React.ForwardRefExoticComponent<Omit<Radix.Select.SelectContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -4,22 +4,24 @@ import * as Radix from "radix-ui";
4
4
  const SelectPrimitive = Radix.Select;
5
5
  import { cn } from '../../cn.js';
6
6
  import { Check, ChevronDown, ChevronUp } from "lucide-react";
7
+ import { CONSOLE_ICON_STROKE_WIDTH } from '../icon.js';
8
+ import { controlVariantClass } from './control-variant.js';
7
9
  const Select = SelectPrimitive.Root;
8
10
  const SelectGroup = SelectPrimitive.Group;
9
11
  const SelectValue = SelectPrimitive.Value;
10
- const SelectTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn("console-control flex h-[var(--console-control-height)] w-full items-center justify-between whitespace-nowrap rounded-[var(--console-radius-md)] border-[length:var(--console-border-width)] border-input bg-card hover:border-[hsl(var(--foreground)/0.45)] focus-visible:border-[hsl(var(--primary))] shadow-[var(--console-shadow-xs)] px-3 py-2 text-[length:var(--console-text-body)] ring-offset-background placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-60 [&>span]:line-clamp-1", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })] })));
12
+ const SelectTrigger = forwardRef(({ className, children, variant, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, "data-slot": "input", "data-variant": variant === 'ghost' ? 'ghost' : undefined, className: cn("console-control flex h-control w-full items-center justify-between gap-2 whitespace-nowrap rounded-control border px-3 text-body transition-colors placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60 [&>span]:line-clamp-1", controlVariantClass(variant), className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-4 shrink-0 opacity-50" }) })] })));
11
13
  SelectTrigger.displayName = "SelectTrigger";
12
- const SelectScrollUpButton = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(ChevronUp, { className: "h-4 w-4" }) })));
14
+ const SelectScrollUpButton = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(ChevronUp, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-4" }) })));
13
15
  SelectScrollUpButton.displayName = "SelectScrollUpButton";
14
- const SelectScrollDownButton = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(ChevronDown, { className: "h-4 w-4" }) })));
16
+ const SelectScrollDownButton = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(ChevronDown, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-4" }) })));
15
17
  SelectScrollDownButton.displayName = "SelectScrollDownButton";
16
18
  const SelectContent = forwardRef(({ className, children, position: positionProp, ...props }, ref) => {
17
19
  const position = (positionProp ?? "popper");
18
- return (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, className: cn("relative z-50 max-h-[min(24rem,var(--radix-select-content-available-height,calc(100dvh-1rem)))] min-w-[8rem] max-w-[calc(100vw-1rem)] overflow-hidden rounded-[var(--console-radius-lg)] border-[length:var(--console-border-width)] border-border bg-popover text-popover-foreground shadow-[var(--console-shadow-md)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", position === "popper" &&
20
+ return (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, "data-slot": "popover", className: cn("console-popover relative flex max-h-[min(24rem,var(--radix-select-content-available-height,calc(100dvh-1rem)))] min-w-32 max-w-[calc(100vw-1rem)] flex-col p-0", position === "popper" &&
19
21
  "w-[var(--radix-select-trigger-width)]", className), position: position, collisionPadding: 8, sideOffset: 4, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: cn("min-h-0 w-full min-w-0 overflow-y-auto overscroll-contain p-1"), children: children }), _jsx(SelectScrollDownButton, {})] }) }));
20
22
  });
21
23
  SelectContent.displayName = "SelectContent";
22
- const SelectItem = forwardRef(({ className, children, value, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, value: value, className: cn("console-menu-item relative flex w-full min-w-0 cursor-default select-none items-center rounded-[var(--console-radius-sm)] py-1.5 pl-2.5 pr-8 text-[length:var(--console-text-body)] leading-normal outline-none focus:bg-accent focus:text-accent-foreground data-[state=checked]:bg-primary/5 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span:last-child]:min-w-0 [&>span:last-child]:truncate", className), ...props, children: [_jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center text-primary", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
24
+ const SelectItem = forwardRef(({ className, children, value, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, value: value, className: cn("console-menu-item relative flex w-full min-w-0 cursor-default select-none items-center py-1 pl-3 pr-8 text-body leading-normal outline-none focus:bg-accent focus:text-accent-foreground data-[state=checked]:bg-brand-tint data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span:last-child]:min-w-0 [&>span:last-child]:truncate", className), ...props, children: [_jsx("span", { className: "absolute right-2 flex size-4 items-center justify-center text-brand-text", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Check, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-4" }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
23
25
  SelectItem.displayName = "SelectItem";
24
26
  const SelectSeparator = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn("-mx-1 my-1 h-px bg-muted", className), ...props })));
25
27
  SelectSeparator.displayName = "SelectSeparator";
@@ -4,14 +4,15 @@ import { forwardRef } from "react";
4
4
  import * as Radix from "radix-ui";
5
5
  import { cn } from '../../cn.js';
6
6
  import { X } from "lucide-react";
7
+ import { CONSOLE_ICON_STROKE_WIDTH } from '../icon.js';
7
8
  const SheetPrimitive = Radix.Dialog;
8
9
  const Sheet = SheetPrimitive.Root;
9
10
  const SheetTrigger = SheetPrimitive.Trigger;
10
11
  const SheetPortal = SheetPrimitive.Portal;
11
12
  const SheetClose = SheetPrimitive.Close;
12
- const SheetOverlay = forwardRef(({ className, ...props }, ref) => (_jsx(SheetPrimitive.Overlay, { ref: ref, className: cn("console-sheet-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className), ...props })));
13
+ const SheetOverlay = forwardRef(({ className, ...props }, ref) => (_jsx(SheetPrimitive.Overlay, { ref: ref, className: cn("console-sheet-overlay", className), ...props })));
13
14
  SheetOverlay.displayName = "SheetOverlay";
14
- const SheetContent = forwardRef(({ side = "right", className, children, ...props }, ref) => (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { ref: ref, "data-side": side, className: cn("console-sheet-content outline-none", className), ...props, children: [children, _jsxs(SheetPrimitive.Close, { className: "console-dialog-close disabled:pointer-events-none", children: [_jsx(X, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: _jsx(ConsoleUiText, { id: "dialog.close" }) })] })] })] })));
15
+ const SheetContent = forwardRef(({ side = "right", className, children, ...props }, ref) => (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { ref: ref, "data-side": side, "data-slot": "sheet", className: cn("console-sheet-content outline-none", className), ...props, children: [children, _jsxs(SheetPrimitive.Close, { className: "console-dialog-close disabled:pointer-events-none", children: [_jsx(X, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "size-4" }), _jsx("span", { className: "sr-only", children: _jsx(ConsoleUiText, { id: "dialog.close" }) })] })] })] })));
15
16
  SheetContent.displayName = "SheetContent";
16
17
  const SheetHeader = ({ className, ...props }) => (_jsx("div", { className: cn("console-sheet-header", className), ...props }));
17
18
  SheetHeader.displayName = "SheetHeader";
@@ -21,6 +22,6 @@ const SheetFooter = ({ className, ...props }) => (_jsx("div", { className: cn("c
21
22
  SheetFooter.displayName = "SheetFooter";
22
23
  const SheetTitle = forwardRef(({ className, ...props }, ref) => (_jsx(SheetPrimitive.Title, { ref: ref, className: cn("console-section-title", className), ...props })));
23
24
  SheetTitle.displayName = "SheetTitle";
24
- const SheetDescription = forwardRef(({ className, ...props }, ref) => (_jsx(SheetPrimitive.Description, { ref: ref, className: cn("text-[length:var(--console-text-body)] text-muted-foreground", className), ...props })));
25
+ const SheetDescription = forwardRef(({ className, ...props }, ref) => (_jsx(SheetPrimitive.Description, { ref: ref, className: cn("text-body text-muted-foreground", className), ...props })));
25
26
  SheetDescription.displayName = "SheetDescription";
26
27
  export { Sheet, SheetPortal, SheetOverlay, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetBody, SheetFooter, SheetTitle, SheetDescription, };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn } from '../../cn.js';
3
3
  function Skeleton({ className, ...props }) {
4
- return (_jsx("div", { className: cn("console-skeleton rounded-md", className), ...props }));
4
+ return (_jsx("div", { className: cn("console-skeleton rounded-control", className), ...props }));
5
5
  }
6
6
  export { Skeleton };
@@ -3,6 +3,6 @@ import { forwardRef } from "react";
3
3
  import * as Radix from "radix-ui";
4
4
  const SwitchPrimitive = Radix.Switch;
5
5
  import { cn } from '../../cn.js';
6
- const Switch = forwardRef(({ className, ...props }, ref) => (_jsx(SwitchPrimitive.Root, { className: cn("console-control peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input", className), ...props, ref: ref, children: _jsx(SwitchPrimitive.Thumb, { className: cn("pointer-events-none block h-4 w-4 rounded-full bg-background transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0") }) })));
6
+ const Switch = forwardRef(({ className, ...props }, ref) => (_jsx(SwitchPrimitive.Root, { className: cn("console-control console-touch peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent px-px transition-colors disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-brand-text data-[state=unchecked]:bg-input", className), ...props, ref: ref, children: _jsx(SwitchPrimitive.Thumb, { className: cn("pointer-events-none block size-4 rounded-full bg-background transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0") }) })));
7
7
  Switch.displayName = "Switch";
8
8
  export { Switch };
@@ -1,6 +1,10 @@
1
1
  import type * as React from "react";
2
+ /** Copies the column headers into `data-label` of every body cell that has no label of its own. */
3
+ export declare function syncTableCellLabels(table: HTMLTableElement): void;
2
4
  declare const Table: React.ForwardRefExoticComponent<React.TableHTMLAttributes<HTMLTableElement> & {
3
5
  containerClassName?: string;
6
+ /** `compact` uses the compact control height for controls inside cells (2rem on wide screens). */
7
+ density?: "default" | "compact";
4
8
  } & React.RefAttributes<HTMLTableElement>>;
5
9
  declare const TableHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & {
6
10
  sticky?: boolean;
@@ -9,8 +13,15 @@ declare const TableBody: React.ForwardRefExoticComponent<React.HTMLAttributes<HT
9
13
  declare const TableRow: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableRowElement> & React.RefAttributes<HTMLTableRowElement>>;
10
14
  declare const TableHead: React.ForwardRefExoticComponent<React.ThHTMLAttributes<HTMLTableCellElement> & {
11
15
  numeric?: boolean;
16
+ /** `secondary` cells are hidden when the table turns into cards (narrow containers). */
17
+ priority?: "primary" | "secondary";
12
18
  } & React.RefAttributes<HTMLTableCellElement>>;
13
19
  declare const TableCell: React.ForwardRefExoticComponent<React.TdHTMLAttributes<HTMLTableCellElement> & {
14
20
  numeric?: boolean;
21
+ /** `secondary` cells are hidden when the table turns into cards (narrow containers). */
22
+ priority?: "primary" | "secondary";
23
+ } & {
24
+ /** Label shown in card mode; defaults to the column header. */
25
+ label?: string;
15
26
  } & React.RefAttributes<HTMLTableCellElement>>;
16
27
  export { Table, TableHeader, TableBody, TableRow, TableHead, TableCell };
@@ -1,16 +1,47 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
2
+ import { forwardRef, useCallback, useEffect, useRef } from "react";
3
3
  import { cn } from '../../cn.js';
4
- const Table = forwardRef(({ className, containerClassName, ...props }, ref) => (_jsx("div", { className: cn("w-full max-w-full overflow-x-auto", containerClassName), children: _jsx("table", { ref: ref, className: cn("w-full border-collapse text-[length:var(--console-text-body-sm)]", className), ...props }) })));
4
+ /** Copies the column headers into `data-label` of every body cell that has no label of its own. */
5
+ export function syncTableCellLabels(table) {
6
+ const headers = [...table.querySelectorAll(":scope > thead > tr:last-child > th")]
7
+ .map((cell) => cell.textContent?.trim() ?? "");
8
+ if (!headers.length)
9
+ return;
10
+ for (const row of table.querySelectorAll(":scope > tbody > tr")) {
11
+ let column = 0;
12
+ for (const cell of row.cells) {
13
+ const label = headers[column];
14
+ if (label && (!cell.hasAttribute("data-label") || cell.dataset.labelAuto === "true")) {
15
+ cell.dataset.label = label;
16
+ cell.dataset.labelAuto = "true";
17
+ }
18
+ column += cell.colSpan || 1;
19
+ }
20
+ }
21
+ }
22
+ const Table = forwardRef(({ className, containerClassName, density = "default", ...props }, ref) => {
23
+ const own = useRef(null);
24
+ const setRef = useCallback((node) => {
25
+ own.current = node;
26
+ if (typeof ref === "function")
27
+ ref(node);
28
+ else if (ref)
29
+ ref.current = node;
30
+ }, [ref]);
31
+ // Runs after every render of the table, so rows added later get their labels too.
32
+ useEffect(() => { if (own.current)
33
+ syncTableCellLabels(own.current); });
34
+ return (_jsx("div", { className: cn("console-table console-cq", containerClassName), "data-slot": "table", "data-density": density, children: _jsx("div", { className: "console-table-scroll", children: _jsx("table", { ref: setRef, className: className, ...props }) }) }));
35
+ });
5
36
  Table.displayName = "Table";
6
- const TableHeader = forwardRef(({ className, sticky, ...props }, ref) => (_jsx("thead", { ref: ref, className: cn(sticky && "sticky top-0 z-10 backdrop-blur-sm", className), ...props })));
37
+ const TableHeader = forwardRef(({ className, sticky, ...props }, ref) => (_jsx("thead", { ref: ref, className: cn(sticky && "sticky top-0 z-10 bg-card", className), ...props })));
7
38
  TableHeader.displayName = "TableHeader";
8
39
  const TableBody = forwardRef(({ className, ...props }, ref) => (_jsx("tbody", { ref: ref, className: className, ...props })));
9
40
  TableBody.displayName = "TableBody";
10
- const TableRow = forwardRef(({ className, ...props }, ref) => (_jsx("tr", { ref: ref, className: cn("border-b border-border/70 transition-colors last:border-0 hover:bg-[var(--console-surface-hover)]", className), ...props })));
41
+ const TableRow = forwardRef(({ className, ...props }, ref) => (_jsx("tr", { ref: ref, className: className, ...props })));
11
42
  TableRow.displayName = "TableRow";
12
- const TableHead = forwardRef(({ className, numeric, scope = "col", ...props }, ref) => (_jsx("th", { ref: ref, scope: scope, className: cn("whitespace-nowrap border-b border-border bg-transparent px-3 py-2.5 align-middle text-[length:var(--console-text-label)] font-medium text-muted-foreground", numeric ? "text-right tabular-nums" : "text-left", className), ...props })));
43
+ const TableHead = forwardRef(({ className, numeric, priority, scope = "col", ...props }, ref) => (_jsx("th", { ref: ref, scope: scope, "data-numeric": numeric ? "" : undefined, "data-priority": priority, className: className, ...props })));
13
44
  TableHead.displayName = "TableHead";
14
- const TableCell = forwardRef(({ className, numeric, ...props }, ref) => (_jsx("td", { ref: ref, className: cn("px-3 py-2 align-middle", numeric && "text-right tabular-nums", className), ...props })));
45
+ const TableCell = forwardRef(({ className, numeric, priority, label, ...props }, ref) => (_jsx("td", { ref: ref, "data-numeric": numeric ? "" : undefined, "data-priority": priority, "data-label": label, className: className, ...props })));
15
46
  TableCell.displayName = "TableCell";
16
47
  export { Table, TableHeader, TableBody, TableRow, TableHead, TableCell };
@@ -4,10 +4,10 @@ import * as Radix from "radix-ui";
4
4
  const TabsPrimitive = Radix.Tabs;
5
5
  import { cn } from '../../cn.js';
6
6
  const Tabs = TabsPrimitive.Root;
7
- const TabsList = forwardRef(({ className, ...props }, ref) => (_jsx(TabsPrimitive.List, { ref: ref, className: cn("inline-flex h-[var(--console-control-height-lg)] items-center justify-center gap-0.5 rounded-[var(--console-radius-lg)] bg-[hsl(var(--foreground)/0.055)] p-1 text-muted-foreground", className), ...props })));
7
+ const TabsList = forwardRef(({ className, ...props }, ref) => (_jsx(TabsPrimitive.List, { ref: ref, className: cn("inline-flex max-w-full items-center justify-start gap-1 overflow-x-auto rounded-control bg-foreground/6 p-1 text-muted-foreground", className), ...props })));
8
8
  TabsList.displayName = "TabsList";
9
- const TabsTrigger = forwardRef(({ className, value, ...props }, ref) => (_jsx(TabsPrimitive.Trigger, { ref: ref, value: value, className: cn("inline-flex items-center justify-center whitespace-nowrap rounded-[var(--console-radius-md)] h-full px-3 py-1 text-[length:var(--console-text-body)] font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:text-foreground data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:shadow-[var(--console-shadow-sm)]", className), ...props })));
9
+ const TabsTrigger = forwardRef(({ className, value, ...props }, ref) => (_jsx(TabsPrimitive.Trigger, { ref: ref, value: value, className: cn("console-tabs-trigger inline-flex min-h-control-compact items-center justify-center whitespace-nowrap rounded-segment px-3 text-body font-medium transition-colors disabled:pointer-events-none disabled:opacity-50 hover:text-foreground data-[state=active]:bg-card data-[state=active]:text-foreground", className), ...props })));
10
10
  TabsTrigger.displayName = "TabsTrigger";
11
- const TabsContent = forwardRef(({ className, value, ...props }, ref) => (_jsx(TabsPrimitive.Content, { ref: ref, value: value, className: cn("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", className), ...props })));
11
+ const TabsContent = forwardRef(({ className, value, ...props }, ref) => (_jsx(TabsPrimitive.Content, { ref: ref, value: value, className: cn("mt-3", className), ...props })));
12
12
  TabsContent.displayName = "TabsContent";
13
13
  export { Tabs, TabsList, TabsTrigger, TabsContent };
@@ -1,3 +1,8 @@
1
1
  import type * as React from "react";
2
- declare const Textarea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLTextAreaElement>>;
2
+ import { type ControlVariant } from './control-variant.js';
3
+ export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
4
+ /** `ghost`: no border until hovered or focused, for secondary fields (ADR 0063 D29). */
5
+ variant?: ControlVariant;
6
+ }
7
+ declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
3
8
  export { Textarea };
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { cn } from '../../cn.js';
4
- const Textarea = forwardRef(({ className, ...props }, ref) => {
5
- return (_jsx("textarea", { className: cn("console-control flex min-h-[88px] w-full rounded-[var(--console-radius-md)] border-[length:var(--console-border-width)] border-input bg-card hover:border-[hsl(var(--foreground)/0.45)] focus-visible:border-[hsl(var(--primary))] shadow-[var(--console-shadow-xs)] px-3 py-2 leading-relaxed text-[length:var(--console-text-body)] placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-60", className), ref: ref, ...props }));
4
+ import { controlVariantClass } from './control-variant.js';
5
+ const Textarea = forwardRef(({ className, variant, ...props }, ref) => {
6
+ return (_jsx("textarea", { "data-slot": "input", "data-variant": variant === 'ghost' ? 'ghost' : undefined, className: cn("console-control flex min-h-20 w-full rounded-control border px-3 py-2 leading-relaxed text-body transition-colors placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60", controlVariantClass(variant), className), ref: ref, ...props }));
6
7
  });
7
8
  Textarea.displayName = "Textarea";
8
9
  export { Textarea };
@@ -6,6 +6,6 @@ import { cn } from '../../cn.js';
6
6
  const TooltipProvider = TooltipPrimitive.Provider;
7
7
  const Tooltip = TooltipPrimitive.Root;
8
8
  const TooltipTrigger = TooltipPrimitive.Trigger;
9
- const TooltipContent = forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(TooltipPrimitive.Portal, { children: _jsx(TooltipPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn("z-50 overflow-hidden rounded-md bg-foreground px-2.5 py-1.5 text-xs font-medium text-background shadow-console-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className), ...props }) })));
9
+ const TooltipContent = forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(TooltipPrimitive.Portal, { children: _jsx(TooltipPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn("z-50 overflow-hidden rounded-popover-item bg-foreground px-2 py-1 text-label font-medium text-background shadow-popover", className), ...props }) })));
10
10
  TooltipContent.displayName = "TooltipContent";
11
11
  export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1,13 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * Whether the element is at least `rem` wide (ADR 0063 D18: components follow the width of their
4
+ * own container, not the viewport). `undefined` until measured (and during server rendering).
5
+ */
6
+ export declare function useContainerAtLeast(ref: RefObject<HTMLElement | null>, rem: number): boolean | undefined;
7
+ /** Breakpoints of the size scale in rem (tokens/tokens.mjs `breakpoints`). */
8
+ export declare const CONSOLE_BREAKPOINTS_REM: Readonly<{
9
+ readonly sm: 40;
10
+ readonly md: 48;
11
+ readonly lg: 64;
12
+ readonly xl: 90;
13
+ }>;
@@ -0,0 +1,30 @@
1
+ import { useEffect, useState } from 'react';
2
+ /** Root font size in px (rem breakpoints are compared against element widths in px). */
3
+ function remInPx() {
4
+ if (typeof document === 'undefined')
5
+ return 16;
6
+ const size = Number.parseFloat(getComputedStyle(document.documentElement).fontSize);
7
+ return Number.isFinite(size) && size > 0 ? size : 16;
8
+ }
9
+ /**
10
+ * Whether the element is at least `rem` wide (ADR 0063 D18: components follow the width of their
11
+ * own container, not the viewport). `undefined` until measured (and during server rendering).
12
+ */
13
+ export function useContainerAtLeast(ref, rem) {
14
+ const [wide, setWide] = useState(undefined);
15
+ useEffect(() => {
16
+ const element = ref.current;
17
+ if (!element)
18
+ return;
19
+ const measure = () => setWide(element.getBoundingClientRect().width >= rem * remInPx());
20
+ measure();
21
+ if (typeof ResizeObserver === 'undefined')
22
+ return;
23
+ const observer = new ResizeObserver(measure);
24
+ observer.observe(element);
25
+ return () => observer.disconnect();
26
+ }, [ref, rem]);
27
+ return wide;
28
+ }
29
+ /** Breakpoints of the size scale in rem (tokens/tokens.mjs `breakpoints`). */
30
+ export const CONSOLE_BREAKPOINTS_REM = Object.freeze({ sm: 40, md: 48, lg: 64, xl: 90 });
@@ -0,0 +1,13 @@
1
+ /*
2
+ * GENERATED by @zhin.js/console-ui tokens/generate.mjs from tokens/tokens.mjs — do not edit.
3
+ * Breakpoints for the global shell (D16): `@media (--console-sm)`. Needs postcss-custom-media (or Lightning CSS drafts.customMedia).
4
+ */
5
+
6
+ @custom-media --console-sm (min-width: 40rem);
7
+ @custom-media --console-below-sm (width < 40rem);
8
+ @custom-media --console-md (min-width: 48rem);
9
+ @custom-media --console-below-md (width < 48rem);
10
+ @custom-media --console-lg (min-width: 64rem);
11
+ @custom-media --console-below-lg (width < 64rem);
12
+ @custom-media --console-xl (min-width: 90rem);
13
+ @custom-media --console-below-xl (width < 90rem);