@tristan2828/ui-foundation 4.83.0 → 4.85.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 (43) hide show
  1. package/README.md +1 -1
  2. package/conventions/docs/add-an-entity.md +68 -23
  3. package/conventions/docs/design-language.md +82 -30
  4. package/dist/components/app/entity-form.d.ts +27 -3
  5. package/dist/components/app/entity-form.js +124 -3
  6. package/dist/components/app/form-dialog.js +16 -4
  7. package/dist/components/app/form-leave-guard.d.ts +4 -0
  8. package/dist/components/app/form-leave-guard.js +42 -0
  9. package/dist/components/app/form-section.d.ts +9 -0
  10. package/dist/components/app/form-section.js +15 -0
  11. package/dist/components/app/freshness.d.ts +14 -0
  12. package/dist/components/app/freshness.js +25 -0
  13. package/dist/components/app/list-header.d.ts +44 -0
  14. package/dist/components/app/list-header.js +27 -0
  15. package/dist/components/app/needs-you.d.ts +19 -0
  16. package/dist/components/app/needs-you.js +30 -0
  17. package/dist/components/app/option-select.d.ts +30 -0
  18. package/dist/components/app/option-select.js +21 -0
  19. package/dist/components/app/part-empty.d.ts +20 -0
  20. package/dist/components/app/part-empty.js +17 -0
  21. package/dist/components/app/timeline.d.ts +25 -0
  22. package/dist/components/app/timeline.js +31 -0
  23. package/dist/components/app/value-list.d.ts +14 -0
  24. package/dist/components/app/value-list.js +13 -0
  25. package/dist/components/app/widget-card.d.ts +9 -1
  26. package/dist/components/app/widget-card.js +3 -2
  27. package/dist/components/ui/button.js +1 -1
  28. package/dist/components/ui/combobox.js +1 -1
  29. package/dist/components/ui/field.d.ts +28 -3
  30. package/dist/components/ui/field.js +116 -8
  31. package/dist/components/ui/input-group.js +1 -1
  32. package/dist/components/ui/input.js +1 -1
  33. package/dist/components/ui/select.js +1 -1
  34. package/dist/index.d.ts +11 -0
  35. package/dist/index.js +11 -0
  36. package/dist/lib/field-rows.d.ts +18 -0
  37. package/dist/lib/field-rows.js +53 -0
  38. package/dist/lib/form-errors.d.ts +6 -0
  39. package/dist/lib/form-errors.js +19 -0
  40. package/dist/lib/freshness.d.ts +6 -0
  41. package/dist/lib/freshness.js +37 -0
  42. package/package.json +1 -1
  43. package/styles/index.css +60 -0
@@ -0,0 +1,44 @@
1
+ import { type To } from 'react-router';
2
+ import type { IconComponent } from './icon-component.js';
3
+ export type ListHeaderLink = {
4
+ label: string;
5
+ to: To;
6
+ icon?: IconComponent;
7
+ };
8
+ export type ListHeaderAction = {
9
+ label: string;
10
+ onSelect: () => void;
11
+ icon?: IconComponent;
12
+ };
13
+ export type ListHeaderProps = {
14
+ /** The list's name: the page's h1. */
15
+ title: string;
16
+ /** How many records there are, beside the title in the muted tone. Left out while loading. */
17
+ count?: number;
18
+ /** Related screens (Board, Change log). One stays a button; two or more fold into ⋯. */
19
+ links?: readonly ListHeaderLink[];
20
+ /** The New button: a link to the new-record page, or a function that opens its dialog. */
21
+ newAction?: {
22
+ label: string;
23
+ to: To;
24
+ onClick?: never;
25
+ } | {
26
+ label: string;
27
+ onClick: () => void;
28
+ to?: never;
29
+ };
30
+ /** The page's other actions (Export, Import), in ⋯ after the folded links. */
31
+ more?: readonly ListHeaderAction[];
32
+ /**
33
+ * Soft-deleted records, for a list that has them: "Show deleted" in ⋯,
34
+ * and the notice while it is on. `noun` completes "Showing deleted
35
+ * <noun>" (default "records").
36
+ */
37
+ deleted?: {
38
+ shown: boolean;
39
+ onShownChange: (shown: boolean) => void;
40
+ noun?: string;
41
+ };
42
+ className?: string;
43
+ };
44
+ export declare function ListHeader({ title, count, links, newAction, more, deleted, className }: ListHeaderProps): import("react").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A list page's header (list standard L12): the title with its count,
3
+ // the New button alone beside it, and everything else behind one ⋯ menu.
4
+ // The related screens (Board, Change log) stay out as buttons while
5
+ // there's one; two or more fold into the menu with the page's other
6
+ // extras, so the row is the same on a list with no siblings and one with
7
+ // four. "Show deleted" is the menu's last item, and while it's on a notice
8
+ // says so with "Back to the list", so the ⋯ menu and the notice are one
9
+ // component and a list can't show deleted records without saying so.
10
+ //
11
+ // Holds no state: the app keeps `shown` (usually a URL filter). `links`
12
+ // are routes, `more` are the app's own actions. The ⋯ button has an
13
+ // accessible name and is left out when the menu would be empty.
14
+ import { EllipsisIcon, PlusIcon, Trash2Icon } from 'lucide-react';
15
+ import { Link } from 'react-router';
16
+ import { cn } from 'cn';
17
+ import { Notice } from './notice.js';
18
+ import { Button } from '../ui/button.js';
19
+ import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
20
+ export function ListHeader({ title, count, links = [], newAction, more = [], deleted, className }) {
21
+ // One link is a button of its own; two or more go in the menu.
22
+ const outLink = links.length === 1 ? links[0] : undefined;
23
+ const menuLinks = links.length > 1 ? links : [];
24
+ const hasMenu = menuLinks.length > 0 || more.length > 0 || deleted !== undefined;
25
+ return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show deleted"] }))] })] })), newAction &&
26
+ (newAction.to !== undefined ? (_jsxs(Button, { size: "sm", nativeButton: false, render: _jsx(Link, { to: newAction.to }), children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })) : (_jsxs(Button, { size: "sm", onClick: newAction.onClick, children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })))] })] }), _jsx("div", { role: "status", "data-slot": "list-header-notice", className: "not-empty:mt-3", children: deleted?.shown && (_jsxs(Notice, { tone: "info", icon: Trash2Icon, action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => deleted.onShownChange(false), children: "Back to the list" }), children: ["Showing deleted ", deleted.noun ?? 'records', "."] })) })] }));
27
+ }
@@ -0,0 +1,19 @@
1
+ import { type To } from 'react-router';
2
+ export type NeedsYouTone = 'warning' | 'destructive';
3
+ export type NeedsYouItem = {
4
+ /** What waits: a short sentence ("1 document is overdue"). The whole line is the link. */
5
+ text: string;
6
+ /** Where to fix it. */
7
+ to: To;
8
+ /** `warning` (the default), or `destructive` for what's overdue. */
9
+ tone?: NeedsYouTone;
10
+ };
11
+ export type NeedsYouProps = {
12
+ items: readonly NeedsYouItem[];
13
+ /** The heading. Defaults to "Needs you". */
14
+ title?: string;
15
+ /** The heading's level: 2 under the page's h1 (the default). */
16
+ headingLevel?: 2 | 3 | 4;
17
+ className?: string;
18
+ };
19
+ export declare function NeedsYou({ items, title, headingLevel, className }: NeedsYouProps): import("react").JSX.Element | null;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // What waits on you (overview standard O2): one list at the top of an
3
+ // overview, in the warning tone, each line a link to where it's fixed
4
+ // ("Balances are three months old", "2 deals at their target"). It
5
+ // collects what each part already says about itself, so the page's first
6
+ // answer is "what do I do", not a scan of every tile.
7
+ //
8
+ // Nothing at all when `items` is empty: no heading, no empty box. A
9
+ // region named by its heading, so it is in the page's outline and a
10
+ // screen reader can jump to it. The wash is the tone at 10% (20% in dark)
11
+ // with foreground text and the `*-text` icon, as a Notice draws it; a
12
+ // line may take another tone (`destructive` for an overdue one).
13
+ import { ChevronRightIcon, CircleAlertIcon, TriangleAlertIcon } from 'lucide-react';
14
+ import { useId } from 'react';
15
+ import { Link } from 'react-router';
16
+ import { cn } from 'cn';
17
+ const LINE = {
18
+ warning: { icon: 'text-warning-text', Icon: TriangleAlertIcon },
19
+ destructive: { icon: 'text-destructive-text', Icon: CircleAlertIcon },
20
+ };
21
+ export function NeedsYou({ items, title = 'Needs you', headingLevel = 2, className }) {
22
+ const headingId = useId();
23
+ if (items.length === 0)
24
+ return null;
25
+ const Heading = `h${headingLevel}`;
26
+ return (_jsxs("section", { "aria-labelledby": headingId, "data-slot": "needs-you", className: cn('flex flex-col gap-1 rounded-lg border border-warning-text/30 bg-warning/10 px-4 py-3 text-foreground dark:bg-warning/20', className), children: [_jsx(Heading, { id: headingId, className: "type-label font-semibold text-foreground", children: title }), _jsx("ul", { className: "flex flex-col", children: items.map((item, index) => {
27
+ const { icon, Icon } = LINE[item.tone ?? 'warning'];
28
+ return (_jsx("li", { "data-tone": item.tone ?? 'warning', children: _jsxs(Link, { to: item.to, className: "group/line -mx-1 flex min-h-8 items-center gap-2 rounded-sm px-1 py-1 type-body text-foreground outline-none focus-visible:ring-3 focus-visible:ring-ring/50 max-sm:min-h-11", children: [_jsx(Icon, { "aria-hidden": "true", className: cn('size-4 shrink-0', icon) }), _jsx("span", { className: "min-w-0 flex-1 underline-offset-4 group-hover/line:underline", children: item.text }), _jsx(ChevronRightIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground" })] }) }, `${index}-${item.text}`));
29
+ }) })] }));
30
+ }
@@ -0,0 +1,30 @@
1
+ import type { ReactNode } from 'react';
2
+ export type OptionSelectOption<T> = {
3
+ value: T;
4
+ label: string;
5
+ };
6
+ export type OptionSelectProps<T extends string | number> = {
7
+ id?: string;
8
+ /** Every option, in the order the list shows them. */
9
+ options: readonly OptionSelectOption<T>[];
10
+ value: T | null;
11
+ onValueChange: (value: T | null) => void;
12
+ /** How an option reads on the trigger and in the list (a badge). Defaults to its label. */
13
+ render?: (value: T, label: string) => ReactNode;
14
+ /** No "Not set" option: one of the list must be picked. */
15
+ required?: boolean;
16
+ /** The "Not set" option's words. */
17
+ emptyLabel?: string;
18
+ /** The trigger's words while nothing is picked (a required one). */
19
+ placeholder?: string;
20
+ invalid?: boolean;
21
+ disabled?: boolean;
22
+ defaultOpen?: boolean;
23
+ onOpenChange?: (open: boolean) => void;
24
+ modal?: boolean;
25
+ className?: string;
26
+ 'aria-label'?: string;
27
+ 'aria-labelledby'?: string;
28
+ 'aria-describedby'?: string;
29
+ };
30
+ export declare function OptionSelect<T extends string | number>({ id, options, value, onValueChange, render, required, emptyLabel, placeholder, invalid, disabled, defaultOpen, onOpenChange, modal, className, ...aria }: OptionSelectProps<T>): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from 'cn';
3
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select.js';
4
+ const NONE = '__none__';
5
+ export function OptionSelect({ id, options, value, onValueChange, render, required = false, emptyLabel = 'Not set', placeholder = 'Pick one', invalid = false, disabled, defaultOpen, onOpenChange, modal, className, ...aria }) {
6
+ const shown = (option) => (render ? render(option.value, option.label) : option.label);
7
+ const at = value == null ? -1 : options.findIndex((option) => option.value === value);
8
+ const key = at === -1 ? (required ? null : NONE) : String(at);
9
+ return (_jsxs(Select, { value: key, onValueChange: (next) => {
10
+ if (next === null)
11
+ return;
12
+ onValueChange(next === NONE ? null : (options[Number(next)]?.value ?? null));
13
+ }, disabled: disabled, defaultOpen: defaultOpen, onOpenChange: onOpenChange, modal: modal, children: [_jsx(SelectTrigger, { id: id, "aria-invalid": invalid || undefined, className: cn('w-full', className), ...aria, children: _jsx(SelectValue, { placeholder: placeholder, children: (picked) => {
14
+ if (picked === null)
15
+ return placeholder;
16
+ if (picked === NONE)
17
+ return _jsx("span", { className: "text-muted-foreground", children: emptyLabel });
18
+ const option = options[Number(picked)];
19
+ return option ? shown(option) : placeholder;
20
+ } }) }), _jsxs(SelectContent, { children: [!required && _jsx(SelectItem, { value: NONE, children: emptyLabel }), options.map((option, index) => (_jsx(SelectItem, { value: String(index), children: shown(option) }, String(option.value))))] })] }));
21
+ }
@@ -0,0 +1,20 @@
1
+ import { type To } from 'react-router';
2
+ export type PartEmptyAction = {
3
+ label: string;
4
+ to: To;
5
+ onClick?: never;
6
+ } | {
7
+ label: string;
8
+ onClick: () => void;
9
+ to?: never;
10
+ };
11
+ export type PartEmptyState = {
12
+ /** What it says. Defaults to "Nothing here yet". */
13
+ text?: string;
14
+ /** The one way to start: a link to where the first one is added, or a button that opens it. */
15
+ action?: PartEmptyAction;
16
+ };
17
+ export type PartEmptyProps = PartEmptyState & {
18
+ className?: string;
19
+ };
20
+ export declare function PartEmpty({ text, action, className }: PartEmptyProps): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A part with nothing in it yet (overview standard O5): the card stays,
3
+ // with "Nothing here yet" and one way to start ("Add the first line"), as
4
+ // an empty list does. The foundation's Empty at card size: no big
5
+ // illustration, a dashed border, the message and one outline button.
6
+ //
7
+ // `WidgetCard`'s `empty` prop draws this in its body in place of the
8
+ // plain `emptyMessage` line; an overview part uses the same component for
9
+ // its own `empty`. The button is a link (`to`) or a plain button
10
+ // (`onClick`).
11
+ import { Link } from 'react-router';
12
+ import { cn } from 'cn';
13
+ import { Button } from '../ui/button.js';
14
+ import { Empty, EmptyContent, EmptyDescription, EmptyHeader } from '../ui/empty.js';
15
+ export function PartEmpty({ text = 'Nothing here yet', action, className }) {
16
+ return (_jsxs(Empty, { "data-slot": "part-empty", "data-state": "empty", className: cn('gap-3 border p-4', className), children: [_jsx(EmptyHeader, { children: _jsx(EmptyDescription, { children: text }) }), action && (_jsx(EmptyContent, { children: action.to !== undefined ? (_jsx(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: action.to }), children: action.label })) : (_jsx(Button, { size: "sm", variant: "outline", onClick: action.onClick, children: action.label })) }))] }));
17
+ }
@@ -0,0 +1,25 @@
1
+ import { type ReactNode } from 'react';
2
+ export type TimelineItem = {
3
+ /** Unique in the list; a stored id when there is one. */
4
+ id: string;
5
+ /** The date as shown ("Nov 2", "Nov 2, 2025"): short, one line. */
6
+ date: string;
7
+ /** The date for machines ('2026-11-02'), on the <time> element. */
8
+ dateTime?: string;
9
+ /** What sort of entry: "Visit", "Call", "Note". A muted line under the body. */
10
+ kind?: string;
11
+ body: ReactNode;
12
+ /** The entry's own control, at its end (an edit button, a ⋯ menu). */
13
+ edit?: ReactNode;
14
+ };
15
+ export type TimelineProps = {
16
+ items: readonly TimelineItem[];
17
+ /** How many show before "Show all N". Defaults to 5. */
18
+ initial?: number;
19
+ /** The list's name for screen readers ("Changes"). */
20
+ label: string;
21
+ /** What an empty timeline says. Defaults to "Nothing yet". */
22
+ emptyText?: string;
23
+ className?: string;
24
+ };
25
+ export declare function Timeline({ items, initial, label, emptyText, className }: TimelineProps): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A record's dated history (record standard R7): updates, changes, a
3
+ // care log. Dates line up in a tabular column on the left, a dot and a
4
+ // thin line between, the entry on the right, so it reads as a history
5
+ // instead of a stack of paragraphs. The newest `initial` (5) show, then
6
+ // "Show all N": a long history stays short and the entries after it stay
7
+ // where they were.
8
+ //
9
+ // Items are given newest first, as the app sorts them. An entry has its
10
+ // date (`date`, already formatted; `dateTime` the machine-readable day
11
+ // for the <time>), an optional `kind` ("Visit", "Note") as a muted line
12
+ // under the body, the `body` (text, or markup such as <Markdown inline>),
13
+ // and `edit`: the entry's own control (an edit button, a menu), at its
14
+ // end. Under 24rem of the timeline's own width (a phone, a narrow
15
+ // dialog) the date moves above its entry and the column goes.
16
+ //
17
+ // It owns the empty state: "Nothing yet" (`emptyText`), never a blank.
18
+ import { useId, useState } from 'react';
19
+ import { cn } from 'cn';
20
+ import { Button } from '../ui/button.js';
21
+ export function Timeline({ items, initial = 5, label, emptyText = 'Nothing yet', className }) {
22
+ const [all, setAll] = useState(false);
23
+ const listId = useId();
24
+ if (items.length === 0) {
25
+ return (_jsx("p", { "data-slot": "timeline", "data-state": "empty", className: cn('type-body text-muted-foreground', className), children: emptyText }));
26
+ }
27
+ const limit = Math.max(1, initial);
28
+ const folds = items.length > limit;
29
+ const shown = folds && !all ? items.slice(0, limit) : items;
30
+ return (_jsxs("div", { "data-slot": "timeline", className: cn('@container flex min-w-0 flex-col gap-2', className), children: [_jsx("ol", { id: listId, "aria-label": label, className: "flex flex-col", children: shown.map((item, index) => (_jsxs("li", { "data-slot": "timeline-item", className: "grid grid-cols-[5.5rem_1rem_minmax(0,1fr)] gap-x-2 @max-[24rem]:grid-cols-[1rem_minmax(0,1fr)]", children: [_jsx("div", { className: "col-start-1 row-start-1 pt-px text-right type-caption tabular-nums text-muted-foreground @max-[24rem]:col-start-2 @max-[24rem]:text-left", children: item.dateTime ? _jsx("time", { dateTime: item.dateTime, children: item.date }) : item.date }), _jsxs("div", { "aria-hidden": "true", className: "col-start-2 row-start-1 flex flex-col items-center @max-[24rem]:col-start-1 @max-[24rem]:row-span-2", children: [_jsx("span", { className: "mt-1.5 size-2 shrink-0 rounded-full bg-primary" }), index < shown.length - 1 && _jsx("span", { className: "w-px flex-1 bg-border" })] }), _jsxs("div", { className: "col-start-3 row-start-1 flex min-w-0 items-start gap-2 pb-3 @max-[24rem]:col-start-2 @max-[24rem]:row-start-2", children: [_jsxs("div", { className: "min-w-0 flex-1 type-body text-foreground", children: [_jsx("div", { className: "break-words", children: item.body }), item.kind && _jsx("div", { className: "type-caption text-muted-foreground", children: item.kind })] }), item.edit && _jsx("div", { className: "shrink-0", children: item.edit })] })] }, item.id))) }), folds && (_jsx(Button, { variant: "link", size: "sm", "aria-expanded": all, "aria-controls": listId, onClick: () => setAll(!all), className: "self-start", children: all ? 'Show fewer' : `Show all ${items.length}` }))] }));
31
+ }
@@ -0,0 +1,14 @@
1
+ import type { ReactNode } from 'react';
2
+ export type ValueListItem = {
3
+ /** Plain text: the chip's text, the tooltip's line and the screen reader's. Unique in the list. */
4
+ label: string;
5
+ /** The app's own mark for the value (an icon, a swatch), drawn in place of the chip. */
6
+ node?: ReactNode;
7
+ };
8
+ export type ValueListProps = {
9
+ items: readonly ValueListItem[];
10
+ /** How many show before "+N". Defaults to 2. */
11
+ max?: number;
12
+ className?: string;
13
+ };
14
+ export declare function ValueList({ items, max, className }: ValueListProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from 'cn';
3
+ import { Badge } from '../ui/badge.js';
4
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip.js';
5
+ export function ValueList({ items, max = 2, className }) {
6
+ if (items.length === 0) {
7
+ return (_jsxs("span", { "data-slot": "value-list", "data-state": "empty", className: cn('text-muted-foreground', className), children: [_jsx("span", { "aria-hidden": "true", children: "\u2014" }), _jsx("span", { className: "sr-only", children: "None" })] }));
8
+ }
9
+ const shown = items.slice(0, Math.max(0, max));
10
+ const folded = items.slice(shown.length);
11
+ const names = folded.map((item) => item.label).join(', ');
12
+ return (_jsxs("span", { "data-slot": "value-list", className: cn('inline-flex items-center gap-1 whitespace-nowrap', className), children: [shown.map((item) => (_jsx("span", { "data-slot": "value-list-item", className: "inline-flex shrink-0 items-center", children: item.node ?? _jsx(Badge, { children: item.label }) }, item.label))), folded.length > 0 && (_jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsxs(TooltipTrigger, { render: _jsx("button", { type: "button", "data-slot": "value-list-more", "aria-label": `${folded.length} more: ${names}`, className: "rounded-sm px-1 type-caption tabular-nums text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50" }), children: ["+", folded.length] }), _jsx(TooltipContent, { children: names })] }) }))] }));
13
+ }
@@ -2,6 +2,7 @@ import { type ReactNode } from 'react';
2
2
  import { type To } from 'react-router';
3
3
  import type { AppError } from '../../api/contracts.js';
4
4
  import type { IconComponent } from './icon-component.js';
5
+ import { type PartEmptyState } from './part-empty.js';
5
6
  export interface WidgetCardProps {
6
7
  title: string;
7
8
  /**
@@ -32,6 +33,13 @@ export interface WidgetCardProps {
32
33
  isEmpty: boolean;
33
34
  /** The empty state's one line: "Nothing waiting". */
34
35
  emptyMessage: string;
36
+ /**
37
+ * A card with nothing yet that offers a way to start (overview standard
38
+ * O5): `{ text, action }` draws "Nothing here yet" and one button, the
39
+ * foundation's Empty at card size (PartEmpty), in place of the plain
40
+ * `emptyMessage` line. `text` defaults to "Nothing here yet".
41
+ */
42
+ empty?: PartEmptyState;
35
43
  /** How many rows the loading skeleton shows: the number the widget usually holds. */
36
44
  skeletonRows?: number;
37
45
  /** A button at the header's end that folds the card to its header, and opens it again. */
@@ -64,7 +72,7 @@ export type WidgetCardLink = {
64
72
  label: string;
65
73
  to?: never;
66
74
  };
67
- export declare function WidgetCard({ id, title, icon: Icon, headingLevel, link, isLoading, error, onRetry, isEmpty, emptyMessage, skeletonRows, collapsible, defaultCollapsed, storageKey, summary, emptySummary, children, className, }: WidgetCardProps): import("react").JSX.Element;
75
+ export declare function WidgetCard({ id, title, icon: Icon, headingLevel, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows, collapsible, defaultCollapsed, storageKey, summary, emptySummary, children, className, }: WidgetCardProps): import("react").JSX.Element;
68
76
  export interface WidgetCardGroupProps {
69
77
  /**
70
78
  * One card open at a time: `true` always, `"mobile"` only below the
@@ -59,6 +59,7 @@ import { Link } from 'react-router';
59
59
  import { ChevronDownIcon, ExternalLinkIcon } from 'lucide-react';
60
60
  import { cn } from 'cn';
61
61
  import { ErrorState } from './error-state.js';
62
+ import { PartEmpty } from './part-empty.js';
62
63
  import { Button } from '../ui/button.js';
63
64
  import { Card, CardContent, CardHeader } from '../ui/card.js';
64
65
  import { Skeleton } from '../ui/skeleton.js';
@@ -66,7 +67,7 @@ import { useIsMobile } from '../../hooks/use-mobile.js';
66
67
  import { useRememberedFlag } from '../../hooks/use-remembered-flag.js';
67
68
  const HEADER_LINK_CLASS = 'shrink-0 rounded-sm type-label text-foreground underline underline-offset-4 outline-none ' +
68
69
  'hover:decoration-2 focus-visible:ring-3 focus-visible:ring-ring/50';
69
- export function WidgetCard({ id, title, icon: Icon, headingLevel = 2, link, isLoading, error, onRetry, isEmpty, emptyMessage, skeletonRows = 3, collapsible = false, defaultCollapsed = false, storageKey, summary, emptySummary, children, className, }) {
70
+ export function WidgetCard({ id, title, icon: Icon, headingLevel = 2, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows = 3, collapsible = false, defaultCollapsed = false, storageKey, summary, emptySummary, children, className, }) {
70
71
  const headingId = useId();
71
72
  const contentId = useId();
72
73
  const summaryId = useId();
@@ -93,7 +94,7 @@ export function WidgetCard({ id, title, icon: Icon, headingLevel = 2, link, isLo
93
94
  return (_jsx("section", { id: id, "aria-labelledby": headingId, "data-slot": "widget-card", "data-state": state, "data-collapsed": collapsed || undefined, className: cn('min-w-0 self-start', className), children: _jsxs(Card, { className: cn('glow-edge density-compact:[--card-spacing:--spacing(3)]', collapsed && 'pb-0'), children: [_jsxs(CardHeader, { onClick: onHeaderClick, className: cn('flex items-center justify-between gap-3', inAccordion && 'cursor-pointer select-none', collapsed && 'border-b-0'), children: [_jsxs(Heading, { id: headingId, className: "flex min-w-0 items-center gap-2 type-section-title text-foreground", children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground" }), _jsx("span", { className: "truncate", children: title })] }), (link || foldable || summaryShown) && (_jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [summaryShown && (_jsx("span", { id: summaryId, "data-slot": "widget-card-summary", className: "mr-2 flex items-center", children: _jsx(WidgetCardSummary, { state: state, summary: summary, emptySummary: emptySummary }) })), link?.href !== undefined ? (_jsxs("a", { href: link.href, target: "_blank", rel: "noreferrer", "aria-describedby": headingId, className: cn(HEADER_LINK_CLASS, 'inline-flex items-center gap-1'), children: [link.label, _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3 shrink-0 text-muted-foreground" }), _jsx("span", { className: "sr-only", children: " (opens in a new tab)" })] })) : (link && (_jsx(Link, { to: link.to, "aria-describedby": headingId, className: HEADER_LINK_CLASS, children: link.label }))), foldable && (_jsx(Button, { variant: "ghost", size: "icon-sm", "aria-labelledby": headingId, "aria-describedby": summaryShown ? summaryId : undefined, "aria-expanded": !collapsed, "aria-controls": contentId, onClick: toggle,
94
95
  // The button's own open look (a filled background) would
95
96
  // read as pressed: the chevron says it.
96
- className: "-my-1 -mr-1.5 aria-expanded:not-hover:bg-transparent", children: _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('transition-transform', collapsed && '-rotate-90') }) }))] }))] }), _jsx(CardContent, { id: contentId, hidden: collapsed, "aria-busy": state === 'loading' || undefined, children: error ? (_jsx(ErrorState, { error: error, onRetry: onRetry, size: "compact" })) : state === 'loading' ? (_jsx(WidgetListSkeleton, { rows: skeletonRows })) : state === 'empty' ? (_jsx("p", { "data-state": "empty", className: "py-2 type-body text-muted-foreground", children: emptyMessage })) : (children) })] }) }));
97
+ className: "-my-1 -mr-1.5 aria-expanded:not-hover:bg-transparent", children: _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('transition-transform', collapsed && '-rotate-90') }) }))] }))] }), _jsx(CardContent, { id: contentId, hidden: collapsed, "aria-busy": state === 'loading' || undefined, children: error ? (_jsx(ErrorState, { error: error, onRetry: onRetry, size: "compact" })) : state === 'loading' ? (_jsx(WidgetListSkeleton, { rows: skeletonRows })) : state === 'empty' ? (empty ? (_jsx(PartEmpty, { ...empty })) : (_jsx("p", { "data-state": "empty", className: "py-2 type-body text-muted-foreground", children: emptyMessage }))) : (children) })] }) }));
97
98
  }
98
99
  // A folded card's one value, by state. Loading's skeleton is about one
99
100
  // number wide; an error's dash says "Couldn't load" to a screen reader,
@@ -13,7 +13,7 @@ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justi
13
13
  link: "text-link underline-offset-4 hover:underline",
14
14
  },
15
15
  size: {
16
- default: "h-9 gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
16
+ default: "h-[var(--control-height,--spacing(9))] gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
17
17
  xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
18
18
  sm: "h-8 gap-1 rounded-[min(var(--radius-md),12px)] px-3 text-(length:--control-text-sm) in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
19
19
  lg: "h-10 gap-1.5 px-5 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",
@@ -44,7 +44,7 @@ function ComboboxSeparator({ className, ...props }) {
44
44
  return (_jsx(ComboboxPrimitive.Separator, { "data-slot": "combobox-separator", className: cn("-mx-1 my-1 h-px bg-border", className), ...props }));
45
45
  }
46
46
  function ComboboxChips({ className, ...props }) {
47
- return (_jsx(ComboboxPrimitive.Chips, { "data-slot": "combobox-chips", className: cn("flex min-h-9 flex-wrap items-center gap-1 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40", className), ...props }));
47
+ return (_jsx(ComboboxPrimitive.Chips, { "data-slot": "combobox-chips", className: cn("flex min-h-[var(--control-height,--spacing(9))] flex-wrap items-center gap-1 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40", className), ...props }));
48
48
  }
49
49
  function ComboboxChip({ className, children, showRemove = true, ...props }) {
50
50
  return (_jsxs(ComboboxPrimitive.Chip, { "data-slot": "combobox-chip", className: cn("flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0", className), ...props, children: [children, showRemove && (_jsx(ComboboxPrimitive.ChipRemove
@@ -1,16 +1,41 @@
1
1
  import { type VariantProps } from "class-variance-authority";
2
2
  import { Label } from "./label.js";
3
+ import { type FieldKind, type FieldSize } from "../../lib/field-rows.js";
3
4
  declare function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">): import("react").JSX.Element;
4
5
  declare function FieldLegend({ className, variant, ...props }: React.ComponentProps<"legend"> & {
5
6
  variant?: "legend" | "label";
6
7
  }): import("react").JSX.Element;
7
- declare function FieldGroup({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
8
+ declare function FieldGroup({ className, ref, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
8
9
  declare const fieldVariants: (props?: ({
9
10
  orientation?: "horizontal" | "vertical" | "responsive" | null | undefined;
10
11
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
- declare function Field({ className, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>): import("react").JSX.Element;
12
+ declare function Field({ className, orientation, size, solo, kind, ...props }: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants> & {
13
+ /**
14
+ * How much it holds, so FieldGroup can put short fields side by side:
15
+ * `s` a number or a short code, `m` a date, a status, a choice of two
16
+ * to four or a rating, `l` a name or a pick of a record, `full` (the
17
+ * default) long text, a list or anything that needs the row.
18
+ */
19
+ size?: FieldSize;
20
+ /** Keep this short field on a row of its own, where a pairing would read wrong. */
21
+ solo?: boolean;
22
+ /**
23
+ * A date or a number: two of a kind stay side by side on a phone.
24
+ * Found by itself for a date or number `<input>`; say it for a
25
+ * control of your own (DateField's button).
26
+ */
27
+ kind?: FieldKind;
28
+ }): import("react").JSX.Element;
12
29
  declare function FieldContent({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
13
- declare function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>): import("react").JSX.Element;
30
+ declare function FieldLabel({ className, required, children, ...props }: React.ComponentProps<typeof Label> & {
31
+ /**
32
+ * A field that must be filled: an asterisk after the words, and
33
+ * `aria-required` on the control `htmlFor` names where its role takes
34
+ * it (a box, a select, a combobox; not a date picker's button). Nothing
35
+ * marks an optional one (no "(optional)").
36
+ */
37
+ required?: boolean;
38
+ }): import("react").JSX.Element;
14
39
  declare function FieldTitle({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
15
40
  declare function FieldDescription({ className, ...props }: React.ComponentProps<"p">): import("react").JSX.Element;
16
41
  declare function FieldSeparator({ children, className, ...props }: React.ComponentProps<"div"> & {
@@ -1,22 +1,106 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from "react";
2
+ import { useLayoutEffect, useMemo, useRef } from "react";
3
3
  import { cva } from "class-variance-authority";
4
4
  import { cn } from "cn";
5
5
  import { Label } from "./label.js";
6
6
  import { Separator } from "./separator.js";
7
+ import { fieldRows } from "../../lib/field-rows.js";
8
+ // The foundation's additions to shadcn's Field (4.85, the form standard):
9
+ //
10
+ // - FieldGroup lays its fields out itself: consecutive short fields
11
+ // (`<Field size="s" | "m" | "l">`) share a row, up to three, each as
12
+ // wide as its size; `<Field solo>` keeps a short one alone
13
+ // (lib/field-rows.ts has the rule). Below 48rem each takes its own row
14
+ // but two dates or two numbers. The rows are worked out from the DOM, so
15
+ // a Field inside the app's own component still counts.
16
+ // - Compact: 14px between fields and 32px controls (40px under 48rem or
17
+ // on a touch screen), from `--control-height`, which FieldGroup sets
18
+ // and the inputs, selects and buttons read (styles/index.css).
19
+ // - `<FieldLabel required>`: an asterisk in the destructive text tone,
20
+ // hidden from screen readers, and `aria-required` on the control it
21
+ // names, which says it instead.
7
22
  function FieldSet({ className, ...props }) {
8
23
  return (_jsx("fieldset", { "data-slot": "field-set", className: cn("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", className), ...props }));
9
24
  }
10
25
  function FieldLegend({ className, variant = "legend", ...props }) {
11
26
  return (_jsx("legend", { "data-slot": "field-legend", "data-variant": variant, className: cn("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base", className), ...props }));
12
27
  }
13
- function FieldGroup({ className, ...props }) {
14
- return (_jsx("div", { "data-slot": "field-group", className: cn("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4", className), ...props }));
28
+ // What a Field holds, when it doesn't say (`kind`): a date or a number
29
+ // box keeps its partner on a phone.
30
+ const DATE_CONTROL = "input[type=date]";
31
+ const NUMBER_CONTROL = "input[type=number], input[inputmode=numeric], input[inputmode=decimal]";
32
+ function kindOf(field) {
33
+ const said = field.dataset.kind;
34
+ if (said === "date" || said === "number")
35
+ return said;
36
+ if (field.querySelector(DATE_CONTROL))
37
+ return "date";
38
+ if (field.querySelector(NUMBER_CONTROL))
39
+ return "number";
40
+ return null;
41
+ }
42
+ const SIZES = new Set(["s", "m", "l", "full"]);
43
+ /** Puts each of the group's own fields in its row (lib/field-rows.ts). */
44
+ function layOut(group) {
45
+ const children = Array.from(group.children);
46
+ const items = children.map((child) => {
47
+ const isField = child.dataset.slot === "field";
48
+ const size = isField ? child.dataset.size : undefined;
49
+ return {
50
+ size: (size && SIZES.has(size) ? size : "full"),
51
+ solo: child.dataset.solo !== undefined,
52
+ kind: isField ? kindOf(child) : null,
53
+ };
54
+ });
55
+ fieldRows(items).forEach((place, at) => {
56
+ const child = children[at];
57
+ if (place.share === null) {
58
+ child.style.removeProperty("--field-share");
59
+ child.style.removeProperty("--field-gaps");
60
+ delete child.dataset.fieldRow;
61
+ delete child.dataset.phonePair;
62
+ return;
63
+ }
64
+ child.style.setProperty("--field-share", String(place.share));
65
+ child.style.setProperty("--field-gaps", String(place.gaps));
66
+ child.dataset.fieldRow = "";
67
+ if (place.phonePair)
68
+ child.dataset.phonePair = "";
69
+ else
70
+ delete child.dataset.phonePair;
71
+ });
72
+ }
73
+ function FieldGroup({ className, ref, ...props }) {
74
+ const own = useRef(null);
75
+ useLayoutEffect(() => {
76
+ const group = own.current;
77
+ if (!group)
78
+ return;
79
+ layOut(group);
80
+ // Fields come and go (a conditional field, an error line), and a
81
+ // field's size can change: lay it out again. Only what layOut reads
82
+ // is watched, so its own writes don't wake it.
83
+ const observer = new MutationObserver(() => layOut(group));
84
+ observer.observe(group, {
85
+ childList: true,
86
+ subtree: true,
87
+ attributes: true,
88
+ attributeFilter: ["data-size", "data-solo", "data-kind", "type", "inputmode"],
89
+ });
90
+ return () => observer.disconnect();
91
+ }, []);
92
+ return (_jsx("div", { ref: (node) => {
93
+ own.current = node;
94
+ if (typeof ref === "function")
95
+ return ref(node);
96
+ if (ref)
97
+ ref.current = node;
98
+ }, "data-slot": "field-group", className: cn("group/field-group @container/field-group flex w-full flex-wrap gap-x-3 gap-y-3.5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-y-3.5 has-[>[data-slot=form-section]]:gap-y-6", className), ...props }));
15
99
  }
16
100
  const fieldVariants = cva("group/field flex w-full gap-2 data-[invalid=true]:text-destructive-text", {
17
101
  variants: {
18
102
  orientation: {
19
- vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
103
+ vertical: "flex-col gap-1.5 *:w-full [&>.sr-only]:w-auto",
20
104
  horizontal: "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
21
105
  responsive: "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
22
106
  },
@@ -25,14 +109,38 @@ const fieldVariants = cva("group/field flex w-full gap-2 data-[invalid=true]:tex
25
109
  orientation: "vertical",
26
110
  },
27
111
  });
28
- function Field({ className, orientation = "vertical", ...props }) {
29
- return (_jsx("div", { role: "group", "data-slot": "field", "data-orientation": orientation, className: cn(fieldVariants({ orientation }), className), ...props }));
112
+ function Field({ className, orientation = "vertical", size, solo = false, kind, ...props }) {
113
+ return (_jsx("div", { role: "group", "data-slot": "field", "data-orientation": orientation, "data-size": size, "data-solo": solo ? "" : undefined, "data-kind": kind, className: cn(fieldVariants({ orientation }), className), ...props }));
30
114
  }
31
115
  function FieldContent({ className, ...props }) {
32
116
  return (_jsx("div", { "data-slot": "field-content", className: cn("group/field-content flex flex-1 flex-col gap-0.5 leading-snug", className), ...props }));
33
117
  }
34
- function FieldLabel({ className, ...props }) {
35
- return (_jsx(Label, { "data-slot": "field-label", className: cn("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col", className), ...props }));
118
+ const REQUIRABLE_ROLES = new Set(["combobox", "textbox", "listbox", "radiogroup", "spinbutton", "searchbox", "gridcell", "tree", "treegrid", "checkbox", "switch"]);
119
+ /** Whether `aria-required` is allowed on it: a form control, or a role that takes it. */
120
+ function takesRequired(control) {
121
+ const role = control.getAttribute("role");
122
+ if (role)
123
+ return REQUIRABLE_ROLES.has(role);
124
+ if (control instanceof HTMLTextAreaElement || control instanceof HTMLSelectElement)
125
+ return true;
126
+ if (control instanceof HTMLInputElement)
127
+ return !["button", "submit", "reset", "image", "hidden"].includes(control.type);
128
+ return false;
129
+ }
130
+ function FieldLabel({ className, required = false, children, ...props }) {
131
+ const { htmlFor } = props;
132
+ useLayoutEffect(() => {
133
+ if (!required || !htmlFor)
134
+ return;
135
+ const control = document.getElementById(htmlFor);
136
+ // Only where the control's role takes it (ARIA): a box, a list or a
137
+ // group of choices, not a button (a date picker's trigger).
138
+ if (!control || !takesRequired(control))
139
+ return;
140
+ control.setAttribute("aria-required", "true");
141
+ return () => control.removeAttribute("aria-required");
142
+ }, [required, htmlFor]);
143
+ return (_jsxs(Label, { "data-slot": "field-label", "data-required": required ? "" : undefined, className: cn("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col", className), ...props, children: [children, required && (_jsx("span", { "aria-hidden": "true", "data-slot": "field-required", className: "-ml-1.5 text-destructive-text", children: "*" }))] }));
36
144
  }
37
145
  function FieldTitle({ className, ...props }) {
38
146
  return (_jsx("div", { "data-slot": "field-label", className: cn("flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50", className), ...props }));