@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.
- package/CHANGELOG.md +45 -0
- package/README.md +118 -11
- package/audit/index.mjs +21 -0
- package/audit/layout-audit.mjs +492 -0
- package/audit/mount-page.jsx +90 -0
- package/audit/plugin-pages.mjs +186 -0
- package/dist/components/BrandMark.d.ts +16 -0
- package/dist/components/BrandMark.js +21 -0
- package/dist/components/InfoHint.js +2 -1
- package/dist/components/PageHeader.d.ts +9 -2
- package/dist/components/PageHeader.js +6 -3
- package/dist/components/PageShell.d.ts +18 -3
- package/dist/components/PageShell.js +5 -3
- package/dist/components/RefreshControl.d.ts +6 -1
- package/dist/components/RefreshControl.js +9 -6
- package/dist/components/StatCard.d.ts +19 -5
- package/dist/components/StatCard.js +36 -10
- package/dist/components/StatusBadge.d.ts +14 -0
- package/dist/components/StatusBadge.js +19 -0
- package/dist/components/actions.d.ts +53 -0
- package/dist/components/actions.js +50 -0
- package/dist/components/code.d.ts +11 -0
- package/dist/components/code.js +10 -0
- package/dist/components/confirm-dialog.js +3 -2
- package/dist/components/content-blocks.d.ts +141 -0
- package/dist/components/content-blocks.js +77 -0
- package/dist/components/empty-illustrations.d.ts +15 -0
- package/dist/components/empty-illustrations.js +36 -0
- package/dist/components/empty-state.d.ts +23 -3
- package/dist/components/empty-state.js +36 -8
- package/dist/components/error-alert.js +2 -1
- package/dist/components/icon.d.ts +11 -0
- package/dist/components/icon.js +8 -0
- package/dist/components/layout.d.ts +38 -0
- package/dist/components/layout.js +28 -0
- package/dist/components/page-chrome.d.ts +12 -0
- package/dist/components/page-chrome.js +6 -5
- package/dist/components/ui/accordion.js +3 -2
- package/dist/components/ui/alert.js +5 -5
- package/dist/components/ui/badge.js +10 -9
- package/dist/components/ui/button.d.ts +10 -1
- package/dist/components/ui/button.js +26 -11
- package/dist/components/ui/card.d.ts +6 -0
- package/dist/components/ui/card.js +5 -4
- package/dist/components/ui/checkbox.js +2 -1
- package/dist/components/ui/control-variant.d.ts +10 -0
- package/dist/components/ui/control-variant.js +6 -0
- package/dist/components/ui/date-field-model.d.ts +39 -0
- package/dist/components/ui/date-field-model.js +105 -0
- package/dist/components/ui/date-field.d.ts +33 -0
- package/dist/components/ui/date-field.js +161 -0
- package/dist/components/ui/dialog.js +7 -6
- package/dist/components/ui/dropdown-menu.js +6 -5
- package/dist/components/ui/input.d.ts +6 -1
- package/dist/components/ui/input.js +3 -2
- package/dist/components/ui/list-item-button.js +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/scroll-area.js +1 -1
- package/dist/components/ui/searchable-select.d.ts +3 -0
- package/dist/components/ui/searchable-select.js +4 -3
- package/dist/components/ui/select.d.ts +7 -1
- package/dist/components/ui/select.js +7 -5
- package/dist/components/ui/sheet.js +4 -3
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/table.d.ts +11 -0
- package/dist/components/ui/table.js +37 -6
- package/dist/components/ui/tabs.js +3 -3
- package/dist/components/ui/textarea.d.ts +6 -1
- package/dist/components/ui/textarea.js +3 -2
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/use-container-width.d.ts +13 -0
- package/dist/components/use-container-width.js +30 -0
- package/dist/custom-media.css +13 -0
- package/dist/exports.json +41 -1
- package/dist/i18n/messages.d.ts +20 -1
- package/dist/i18n/messages.js +40 -2
- package/dist/index.d.ts +12 -0
- package/dist/index.js +11 -0
- package/dist/scale.json +643 -0
- package/dist/styles.css +1919 -836
- package/dist/theme.css +469 -0
- package/dist/tokens.css +434 -123
- package/dist/version.js +1 -1
- package/lint/eslint-plugin.mjs +128 -0
- package/lint/stylelint-config.mjs +43 -0
- package/lint/stylelint-plugin.mjs +195 -0
- package/lint/tailwind-classes.mjs +121 -0
- package/package.json +33 -3
- package/tokens/color.mjs +104 -0
- package/tokens/colors.css +220 -0
- package/tokens/generate.mjs +288 -0
- package/tokens/scale.mjs +137 -0
- 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
|
|
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
|
-
: "
|
|
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("
|
|
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("
|
|
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-
|
|
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("
|
|
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
|
|
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
|
|
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
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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
|
|
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('
|
|
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
|
|
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-
|
|
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
|
-
|
|
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-
|
|
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: "
|
|
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: "
|
|
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
|
|
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
|
|
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
|
|
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: "
|
|
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-
|
|
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-
|
|
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
|
|
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
|
-
|
|
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
|
|
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:
|
|
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,
|
|
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,
|
|
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
|
|
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-
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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-
|
|
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);
|