@nadicodeai/ui 12.1.205 → 12.1.207
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/AGENTS.md +10 -0
- package/dist/components/account-menu.d.ts.map +1 -1
- package/dist/components/account-menu.js +7 -5
- package/dist/components/action-menu.d.ts +119 -23
- package/dist/components/action-menu.d.ts.map +1 -1
- package/dist/components/action-menu.js +52 -24
- package/dist/components/catalog-entry.d.ts +3 -2
- package/dist/components/catalog-entry.d.ts.map +1 -1
- package/dist/components/collection-page.d.ts +6 -3
- package/dist/components/collection-page.d.ts.map +1 -1
- package/dist/components/collection-page.js +4 -3
- package/dist/components/confirm-dialog.d.ts +37 -10
- package/dist/components/confirm-dialog.d.ts.map +1 -1
- package/dist/components/confirm-dialog.js +63 -11
- package/dist/components/data-table.d.ts +2 -2
- package/dist/components/data-table.d.ts.map +1 -1
- package/dist/components/data-table.js +7 -2
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/message-notice.js +1 -1
- package/dist/components/notice-banner.d.ts +1 -1
- package/dist/components/notice-banner.js +1 -1
- package/dist/components/object-page.d.ts +4 -1
- package/dist/components/object-page.d.ts.map +1 -1
- package/dist/components/object-page.js +3 -2
- package/dist/components/overview-page.d.ts +4 -1
- package/dist/components/overview-page.d.ts.map +1 -1
- package/dist/components/overview-page.js +3 -2
- package/dist/components/page-actions.d.ts +12 -61
- package/dist/components/page-actions.d.ts.map +1 -1
- package/dist/components/page-actions.js +27 -35
- package/dist/components/record-commands.d.ts +71 -0
- package/dist/components/record-commands.d.ts.map +1 -0
- package/dist/components/record-commands.js +92 -0
- package/dist/components/record-list.d.ts +32 -64
- package/dist/components/record-list.d.ts.map +1 -1
- package/dist/components/record-list.js +53 -61
- package/dist/components/record-sheet.d.ts +3 -3
- package/dist/components/record-sheet.d.ts.map +1 -1
- package/dist/components/settings-page.d.ts +5 -2
- package/dist/components/settings-page.d.ts.map +1 -1
- package/dist/components/settings-page.js +4 -3
- package/dist/internal/catalog-list.d.ts.map +1 -1
- package/dist/internal/catalog-list.js +2 -4
- package/dist/internal/command-runner.d.ts +13 -0
- package/dist/internal/command-runner.d.ts.map +1 -0
- package/dist/internal/command-runner.js +67 -0
- package/dist/internal/page-command-button.d.ts +83 -0
- package/dist/internal/page-command-button.d.ts.map +1 -0
- package/dist/internal/page-command-button.js +47 -0
- package/dist/internal/record-menu-items.d.ts +7 -5
- package/dist/internal/record-menu-items.d.ts.map +1 -1
- package/dist/internal/record-menu-items.js +1 -9
- package/dist/showcase/samples.d.ts +9 -2
- package/dist/showcase/samples.d.ts.map +1 -1
- package/dist/showcase/samples.js +15 -1
- package/dist/showcase/specimens/actions.d.ts +2 -0
- package/dist/showcase/specimens/actions.d.ts.map +1 -1
- package/dist/showcase/specimens/actions.js +4 -1
- package/dist/showcase/specimens/compositions.d.ts.map +1 -1
- package/dist/showcase/specimens/compositions.js +17 -14
- package/dist/showcase/specimens/index.d.ts +2 -0
- package/dist/showcase/specimens/index.d.ts.map +1 -1
- package/dist/showcase/specimens/menus.d.ts.map +1 -1
- package/dist/showcase/specimens/menus.js +4 -3
- package/dist/showcase/usage.generated.d.ts +1 -1
- package/dist/showcase/usage.generated.d.ts.map +1 -1
- package/dist/showcase/usage.generated.js +51 -29
- package/package.json +2 -2
package/AGENTS.md
CHANGED
|
@@ -25,6 +25,16 @@ that draws it for all of them, never in `DESIGN.md`
|
|
|
25
25
|
server actions, runtime adapters, permissions and copy. Apps change a
|
|
26
26
|
component's appearance only through its typed variants and slots; a new
|
|
27
27
|
appearance is added here.
|
|
28
|
+
- **Pages.** Every product page renders a composition from this package whose
|
|
29
|
+
slots are fixed, and lint rules keep the pages there; a written rule that left
|
|
30
|
+
the assembly to each page let the pages drift.
|
|
31
|
+
- **Elements.** An app whose pages must reach an element through a shared
|
|
32
|
+
component sets `jsxImportSource` to `#jsx`, a module of its own that types the
|
|
33
|
+
intrinsic elements without it, so a raw `<table>` or `<h1>` on a page is a
|
|
34
|
+
type error in the editor and the typecheck; a file that owns one opts back in
|
|
35
|
+
with `/** @jsxImportSource react */`. It is a type and not a lint check per
|
|
36
|
+
element, which an agent met only after writing the element, and declaration
|
|
37
|
+
merging cannot remove an element from React's own list.
|
|
28
38
|
- **Source.** Components stay flat under `src/components/`; reviewed registry
|
|
29
39
|
source sits in `src/internal/` and is not a public namespace. Base UI is the
|
|
30
40
|
primitive base: no Radix or vaul, and `cmdk` only for the stock Command. A
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-menu.d.ts","sourceRoot":"","sources":["../../src/components/account-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"account-menu.d.ts","sourceRoot":"","sources":["../../src/components/account-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAkB5D,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAIjE,2FAA2F;AAC3F,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAA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E,iBAAiB,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,+CAA+C;IAC/C,KAAK,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACvC,2EAA2E;IAC3E,eAAe,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAChD,gEAAgE;IAChE,QAAQ,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACzC,OAAO,EAAE,kBAAkB,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;IACnC,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;IAC3C,iFAAiF;IACjF,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC,CAAC;AAKF;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAe,EACf,OAAoB,EACpB,QAAsB,EACtB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,eAA6B,EAC7B,YAAY,EACZ,WAAmB,EACnB,QAAQ,EACR,IAAY,EACZ,OAAO,EACP,KAAK,GACN,EAAE,gBAAgB,+BAgHlB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Ellipsis, LogOut, Settings, UserRound } from "lucide-react";
|
|
4
|
+
import { useCommandRunner } from "../internal/command-runner.js";
|
|
4
5
|
import { Avatar, AvatarFallback, AvatarImage } from "./avatar.js";
|
|
5
6
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "./dropdown-menu.js";
|
|
6
7
|
import { FieldError } from "./field.js";
|
|
@@ -33,11 +34,12 @@ const NO_COMMANDS = [];
|
|
|
33
34
|
*/
|
|
34
35
|
export function AccountMenu({ align = "start", choices = NO_CHOICES, commands = NO_COMMANDS, identity, label, language, leadingCommands = NO_COMMANDS, onOpenChange, pictureOnly = false, settings, side = "top", signOut, theme, }) {
|
|
35
36
|
const name = `${label}: ${identity.name}`;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const { arm, dialog } = useCommandRunner();
|
|
38
|
+
const commandRows = (rows) => rows.map(arm).map(({ value, ...command }) => (_jsx(AccountMenuRow, { "aria-label": command.accessibleName, disabled: command.locked === true || command.disabledReason !== undefined, icon: command.icon, reason: command.locked ? command.reason : command.disabledReason, value: value, ...menuItemAction(command), children: command.label }, command.label)));
|
|
39
|
+
return (_jsxs(_Fragment, { children: [_jsxs(DropdownMenu, { onOpenChange: onOpenChange, children: [_jsx(DropdownMenuTrigger, { "aria-label": name, className: cn("group/account flex min-h-9 min-w-0 items-center rounded-full outline-none focus-visible:nc-focus-outline focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50", pictureOnly ? "justify-center" : "w-full pr-2 pl-2.5"), disabled: signOut.pending, children: _jsx(AccountMenuIdentity, { identity: identity, pictureOnly: pictureOnly }) }), _jsxs(DropdownMenuContent, { align: align, "aria-label": name, className: "w-72 max-w-[calc(100vw-2rem)] p-1.5", density: "comfortable", side: side, sideOffset: 6, children: [_jsxs(DropdownMenuGroup, { className: "flex min-w-0 items-center gap-2 py-1.5 pl-2", "data-slot": "account-menu-header", children: [_jsxs("span", { className: "grid min-w-0 flex-1 gap-0.5 text-left", children: [_jsx("span", { className: "truncate text-sm font-medium text-foreground", children: identity.name }), identity.notice ? _jsx("span", { className: "text-xs", children: identity.notice }) : null, identity.lines?.map((line, index) => (_jsx("span", { className: "truncate text-xs text-muted-foreground", children: line }, index)))] }), settings ? (_jsx(DropdownMenuItem, { "aria-label": settings.label, className: "text-muted-foreground", iconOnly: true, ...menuItemAction(settings), children: _jsx(Settings, { "aria-hidden": "true" }) })) : null] }), _jsx(DropdownMenuSeparator, { className: "-mx-1.5 my-1.5" }), _jsxs(DropdownMenuGroup, { children: [commandRows(leadingCommands), _jsx(ThemeModeMenu, { ...theme }), language ? _jsx(MenuChoiceRow, { ...language }) : null, choices.map((choice) => (_jsx(AccountMenuChoiceRow, { choice: choice }, choice.label))), settings ? (_jsx(AccountMenuRow, { icon: _jsx(Settings, {}), ...menuItemAction(settings), children: settings.label })) : null, commandRows(commands), _jsx(AccountMenuRow, { "aria-busy": signOut.pending || undefined, closeOnClick: signOut.confirms === true, disabled: signOut.pending, icon: _jsx(LogOut, {}), onClick: () => {
|
|
40
|
+
if (!signOut.pending)
|
|
41
|
+
signOut.onSignOut();
|
|
42
|
+
}, children: _jsx(PendingLabel, { pending: signOut.pending, pendingLabel: signOut.pendingLabel, children: signOut.label }) }), signOut.pending ? (_jsx("span", { className: "sr-only", role: "status", children: signOut.pendingLabel })) : null, signOut.failure ? (_jsxs(FieldError, { className: "mx-2 mb-1 wrap-break-word", "data-message-code": signOut.failure.code, children: [_jsx("span", { className: "block font-medium", children: signOut.failure.title }), bodyBeyondTitle(signOut.failure) ? (_jsx("span", { className: "block", children: bodyBeyondTitle(signOut.failure) })) : null] })) : null] })] })] }), dialog] }));
|
|
41
43
|
}
|
|
42
44
|
function AccountMenuRow({ children, icon, reason, value, ...props }) {
|
|
43
45
|
return (_jsxs(DropdownMenuItem, { ...props, className: "min-h-9 gap-3 px-2 py-1.5 group-data-[density=comfortable]/menu:px-2 group-data-[density=comfortable]/menu:py-1.5 [@media(hover:hover)_and_(pointer:fine)]:min-h-9", children: [_jsxs("span", { className: "grid min-w-0 flex-1 gap-0.5", children: [_jsx("span", { className: "truncate", children: children }), reason ? _jsx("span", { className: "text-xs text-muted-foreground", children: reason }) : null] }), value === undefined ? null : " ", value === undefined ? null : (_jsx(DropdownMenuShortcut, { className: "ml-0", children: value })), _jsx("span", { "aria-hidden": "true", className: "flex shrink-0 items-center text-muted-foreground", children: icon })] }));
|
|
@@ -1,30 +1,100 @@
|
|
|
1
|
-
import type { ComponentProps, ReactElement } from "react";
|
|
1
|
+
import type { ComponentProps, ReactElement, ReactNode } from "react";
|
|
2
2
|
import { DropdownMenuContent, type DropdownMenuCommandState } from "./dropdown-menu.js";
|
|
3
3
|
import type { PageCommandAction, PendingWord } from "./page-actions.js";
|
|
4
|
+
import type { ResolvedMessage } from "./product-message.js";
|
|
5
|
+
/** Geist's cap: "Cap a Menu around 10 items." (https://vercel.com/geist/menu) */
|
|
6
|
+
export declare const MAX_COMMANDS = 10;
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
+
* What a command that runs through a composition returns: nothing once it is done, or the
|
|
9
|
+
* catalogue's message for why it did not happen, which the composition shows where the person
|
|
10
|
+
* asked (in the confirmation it keeps open, or in a toast). It never throws a failure it can word.
|
|
8
11
|
*/
|
|
9
|
-
export type
|
|
12
|
+
export type CommandResult = ResolvedMessage | null | undefined | void;
|
|
13
|
+
export type CommandRun = () => CommandResult | Promise<CommandResult>;
|
|
14
|
+
/**
|
|
15
|
+
* What a command that asks first runs: its confirmation stays open and busy until the promise
|
|
16
|
+
* settles, then closes on `null` or shows the returned message, so it always answers.
|
|
17
|
+
*/
|
|
18
|
+
export type ConfirmedRun = () => Promise<ResolvedMessage | null>;
|
|
19
|
+
/**
|
|
20
|
+
* The confirmation a command opens before it runs: Geist's destructive-action modal. `title` is a
|
|
21
|
+
* statement naming the verb and the record ("Remove pec@acme.it"), `confirmLabel` the verb and
|
|
22
|
+
* the noun ("Remove mailbox"), and the dismissal is always the catalogue's "Cancel".
|
|
23
|
+
*/
|
|
24
|
+
export type CommandConfirmation = {
|
|
25
|
+
title: string;
|
|
26
|
+
/** The consequence, naming the record. */
|
|
27
|
+
description: ReactNode;
|
|
28
|
+
confirmLabel: string;
|
|
29
|
+
/** What cannot be undone, ending in "cannot be undone"; left out when the action can be reversed. */
|
|
30
|
+
irreversible?: string | undefined;
|
|
31
|
+
/** The record's name typed before the confirm enables: only to delete an Agent, a workspace or a company. */
|
|
32
|
+
verify?: {
|
|
33
|
+
phrase: string;
|
|
34
|
+
prompt: string;
|
|
35
|
+
} | undefined;
|
|
36
|
+
};
|
|
37
|
+
/** A reversible destructive command runs at once and says so in a toast whose one action is Undo. */
|
|
38
|
+
export type CommandUndo = {
|
|
39
|
+
/** "Message deleted", with its Undo action, from the catalogue. */
|
|
40
|
+
message: ResolvedMessage;
|
|
41
|
+
};
|
|
42
|
+
type RunsThroughComposition = {
|
|
43
|
+
onClick: CommandRun;
|
|
44
|
+
link?: never;
|
|
45
|
+
render?: never;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* What a command does when chosen. A destructive one carries exactly one of `confirm` (the
|
|
49
|
+
* composition drawing it asks first, keeps the confirmation open while it runs and shows its
|
|
50
|
+
* failure there) or `undo` (it runs at once and the toast offers Undo), so a destructive command
|
|
51
|
+
* without either does not compile; either way its `onClick` returns its failure, never throws it.
|
|
52
|
+
*/
|
|
53
|
+
type CommandConsequence = (PageCommandAction & {
|
|
54
|
+
destructive?: false | undefined;
|
|
55
|
+
confirm?: never;
|
|
56
|
+
undo?: never;
|
|
57
|
+
}) | {
|
|
58
|
+
onClick: ConfirmedRun;
|
|
59
|
+
link?: never;
|
|
60
|
+
render?: never;
|
|
61
|
+
destructive?: boolean | undefined;
|
|
62
|
+
confirm: CommandConfirmation;
|
|
63
|
+
undo?: never;
|
|
64
|
+
} | (RunsThroughComposition & {
|
|
65
|
+
destructive: true;
|
|
66
|
+
undo: CommandUndo;
|
|
67
|
+
confirm?: never;
|
|
68
|
+
});
|
|
69
|
+
type MenuCommandFace = PendingWord & {
|
|
10
70
|
label: string;
|
|
11
71
|
icon: ReactElement;
|
|
12
72
|
/** Read instead of the label when the label alone does not name the target: "Let Sofia use Gmail". */
|
|
13
73
|
accessibleName?: string | undefined;
|
|
14
|
-
/** Drawn last, after the divider, in the error colour. */
|
|
15
|
-
destructive?: boolean | undefined;
|
|
16
74
|
/** The value it acts on, in mono under its label: the address Copy address copies. */
|
|
17
75
|
detail?: string | undefined;
|
|
18
76
|
} & DropdownMenuCommandState;
|
|
77
|
+
/**
|
|
78
|
+
* One command a composition draws: its icon first, then its label. It is runnable, or it cannot
|
|
79
|
+
* run now and says why (`disabledReason`), or the person may not run it (`locked`, with its
|
|
80
|
+
* `reason`), or it is running (`pending`, which always comes with its `pendingLabel`, the label's
|
|
81
|
+
* -ing form: "Removing mailbox"). A destructive one is drawn last, after a divider, in the error
|
|
82
|
+
* colour, and carries its `confirm` or `undo`.
|
|
83
|
+
*/
|
|
84
|
+
export type MenuCommand = MenuCommandFace & CommandConsequence;
|
|
85
|
+
/** Two commands or more: a three-dots menu never opens onto one (owner, 2026-11-06). */
|
|
86
|
+
export type MenuCommands = readonly [MenuCommand, MenuCommand, ...MenuCommand[]];
|
|
19
87
|
/** A record's menu: whose it is, and what can be done to it. */
|
|
20
88
|
export type RecordMenu = {
|
|
21
89
|
/** The trigger's accessible name, from the catalogue: "More for pec@acme.it". */
|
|
22
90
|
label: string;
|
|
23
91
|
/** The record the menu acts on, its first line: "pec@acme.it". */
|
|
24
92
|
record: string;
|
|
25
|
-
commands:
|
|
93
|
+
commands: MenuCommands;
|
|
26
94
|
};
|
|
27
95
|
export type ActionMenuProps = RecordMenu & {
|
|
96
|
+
/** `row`: the 32 px trigger of a record's row or card, beside its 32 px buttons; `page`: the title row's, at the control height. */
|
|
97
|
+
size: "row" | "page";
|
|
28
98
|
triggerId?: string | undefined;
|
|
29
99
|
/** Controlled, for a host that stays visible while the menu is open (a message's hover bar). */
|
|
30
100
|
open?: boolean | undefined;
|
|
@@ -35,31 +105,57 @@ export type ActionMenuProps = RecordMenu & {
|
|
|
35
105
|
/** Where focus goes when the menu closes, when not its trigger: Edit hands it to a composer. */
|
|
36
106
|
finalFocus?: ComponentProps<typeof DropdownMenuContent>["finalFocus"];
|
|
37
107
|
};
|
|
108
|
+
/** Throws in development and tests past Geist's cap, so a list of commands is cut where it is written. */
|
|
109
|
+
export declare function refuseTooManyCommands(name: string, count: number): void;
|
|
38
110
|
/**
|
|
39
|
-
* A record's three dots: the menu of
|
|
111
|
+
* A record's three dots: the menu of the commands that do not stand as buttons, headed by the record's name.
|
|
40
112
|
*
|
|
41
113
|
* @family Menus
|
|
42
|
-
* @when "An overflow menu triggered by a three-dot icon that reveals additional actions in a dropdown." (https://vercel.com/geist/dots-menu)
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
46
|
-
*
|
|
114
|
+
* @when "An overflow menu triggered by a three-dot icon that reveals additional actions in a dropdown." (https://vercel.com/geist/dots-menu)
|
|
115
|
+
* "Use Menu for a discoverable trigger that opens a list of actions on a single resource (a dots menu on a row, a dropdown on a primary entity)." (https://vercel.com/geist/menu)
|
|
116
|
+
* Ours: the three dots of a record or of a page. Only `RecordList`, `RecordCommands` and the page compositions draw it, from the commands a product passes them; a product never renders it, which `nadicodeai/page-composition` refuses (nadicode decision).
|
|
117
|
+
* @instead "For right-click or long-press on a row, use `ContextMenu`. For global commands behind `⌘K`, use `CommandMenu`." (https://vercel.com/geist/menu)
|
|
118
|
+
* Ours: a record's commands are given to `RecordList` (in a list) or `RecordCommands` (one record outside a list), and a page's to its composition's `actions`; each decides what stands as a button and what goes in these dots. Finding across everything is `CommandDialog`; a value to choose is a `Select` (nadicode decision).
|
|
119
|
+
* @behaviour "Open on click, not hover; hover-open menus collide with screen readers and trackpad scrolls." (https://vercel.com/geist/menu)
|
|
120
|
+
* "Position auto-flips based on window bounds; don’t hardcode a side that clips on narrow viewports." (https://vercel.com/geist/menu)
|
|
121
|
+
* "Close on item activation, Escape, and outside-click. Don’t auto-close on a hover-out." (https://vercel.com/geist/menu)
|
|
122
|
+
* "Use `MenuItemLocked` for permission-gated actions so the lock icon and disabled state explain why the row is inert." (https://vercel.com/geist/menu)
|
|
123
|
+
* Ours: that is `locked` with its required `reason`: the row stays, inert, with a lock at its end and the reason under its label (nadicode decision).
|
|
124
|
+
* "Cap a Menu around 10 items. Past that, group with `MenuSection` or move secondary actions to a settings page." (https://vercel.com/geist/menu)
|
|
125
|
+
* Ours: it holds two commands or more, so a menu of one does not compile (owner, 2026-11-06), and more than ten throws in development and tests (nadicode decision). The menu is at most 288 px wide and the record's name heading it is one line, cut with an ellipsis and whole in its tooltip (nadicode decision). The trigger is a ghost icon button, 32 px on a row and at the control height (36 px) on a title row, named for its record, last after any button, keeping its fill while open (nadicode decision). The menu opens 10 px under the trigger, aligned to its end: the record's name, the commands with their icons first and the value one acts on in mono under it, then the destructive ones after a divider in the error colour (nadicode decision). A command that cannot run now takes `disabledReason`: it stays, 36 px like the rest, its text muted, never dimmed, with why in a line under its label; a destructive one is muted, not red; a running one takes `pending` and `pendingLabel` (nadicode decision). A destructive command opens its confirmation from here, or runs and offers its Undo, as `MenuCommand` requires (nadicode decision).
|
|
126
|
+
* @words "Item children are Title Case `Verb + Noun` (`Rename Project`, `Duplicate Deployment`). Bare verbs like `Rename` or `Edit` are wrong outside obvious single-object context." (https://vercel.com/geist/menu)
|
|
127
|
+
* "End an item with `…` only when activating it opens a follow-up dialog (`Rename…`, `Transfer to Team…`)." (https://vercel.com/geist/menu)
|
|
128
|
+
* "Group destructive items at the bottom, separated by a divider, and keep the destructive copy as `Verb + Noun` (`Delete Project`, never bare `Delete`)." (https://vercel.com/geist/menu)
|
|
129
|
+
* Ours: sentence case, "Remove mailbox", not Title Case; the trigger reads "More for {record}" and the header is the record's name; rows wrap, never truncate (nadicode decision).
|
|
130
|
+
* @access "Typeahead jumps to the next item whose label starts with the typed character; keep the visible label first so typeahead matches what the user sees." (https://vercel.com/geist/menu)
|
|
131
|
+
* "Return focus to the trigger on close so keyboard users keep their place in the row." (https://vercel.com/geist/menu)
|
|
132
|
+
* Ours: the trigger is a ghost icon button named by `label`, `aria-expanded` while open; `role="menu"`, items `menuitem` in a group named by `record`; every command requires its `icon`, which is hidden; the value a command acts on and its reason are the item's description (nadicode decision).
|
|
47
133
|
*/
|
|
48
|
-
export declare function ActionMenu({ label, record, commands, triggerId, open, onOpenChange, modal, side, finalFocus, }: ActionMenuProps): import("react").JSX.Element
|
|
49
|
-
/** The same commands on a right-click, Shift+F10 or the Menu key of the record's row. */
|
|
50
|
-
export type ActionContextMenuProps = RecordMenu & {
|
|
134
|
+
export declare function ActionMenu({ label, record, commands, size, triggerId, open, onOpenChange, modal, side, finalFocus, }: ActionMenuProps): import("react").JSX.Element;
|
|
135
|
+
/** The same commands on a right-click, Shift+F10 or the Menu key of the record's row: every one of them. */
|
|
136
|
+
export type ActionContextMenuProps = Omit<RecordMenu, "commands"> & {
|
|
137
|
+
commands: readonly MenuCommand[];
|
|
51
138
|
/** The record's row, which keeps its own element and opens the menu. */
|
|
52
139
|
children: ReactElement;
|
|
53
140
|
};
|
|
54
141
|
/**
|
|
55
|
-
* A record's menu opened from its row by a right-click: the mirror of its
|
|
142
|
+
* A record's menu opened from its row by a right-click: the mirror of its visible commands.
|
|
56
143
|
*
|
|
57
144
|
* @family Menus
|
|
58
|
-
* @when "ContextMenu must never be the only entry point for an action. Mirror every item in a visible `Menu` trigger or row button so mouse-only and keyboard-only users have parity." (https://vercel.com/geist/context-menu)
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
145
|
+
* @when "ContextMenu must never be the only entry point for an action. Mirror every item in a visible `Menu` trigger or row button so mouse-only and keyboard-only users have parity." (https://vercel.com/geist/context-menu)
|
|
146
|
+
* Ours: drawn by `DataTable`'s entity rows and by `RecordContextMenu`, with every command the record's visible buttons and three dots hold; a product never renders it, which `nadicodeai/page-composition` refuses (nadicode decision).
|
|
147
|
+
* @instead "For a global command palette, use `CommandMenu`; for a dropdown opened from a visible trigger, use `Menu`." (https://vercel.com/geist/context-menu)
|
|
148
|
+
* Ours: a product gives a card's right-click to `RecordContextMenu`, with the same commands it gives `RecordCommands` (nadicode decision).
|
|
149
|
+
* @behaviour "Bind to right-click on desktop and long-press on touch. Suppress the native browser menu only on the trigger area, not the whole page." (https://vercel.com/geist/context-menu)
|
|
150
|
+
* "Position the menu at the pointer; if it would overflow the viewport, flip horizontally then vertically before clipping." (https://vercel.com/geist/context-menu)
|
|
151
|
+
* "Close on activation, Escape, and outside-click. Don’t close on hover-out." (https://vercel.com/geist/context-menu)
|
|
152
|
+
* Ours: every command of the record, in the order of its buttons and dots, with the dropdown's surface and rows, destructive last after a divider, a destructive one opening its confirmation; with no command the row renders alone and keeps its element (nadicode decision).
|
|
153
|
+
* @words "Items follow the same rules as `Menu`: Title Case `Verb + Noun` (`Open in New Tab`, `Copy URL`, `Delete Deployment`). Bare verbs are wrong." (https://vercel.com/geist/context-menu)
|
|
154
|
+
* Ours: sentence case, "Copy address"; a command reached two ways reads the same both ways (nadicode decision).
|
|
155
|
+
* @access "Trigger the keyboard menu key (`Shift+F10` on Windows/Linux, the menu key, or platform equivalent) to open the same menu without right-click." (https://vercel.com/geist/context-menu)
|
|
156
|
+
* "Up/Down arrows move focus, Enter/Space activates, Escape closes and returns focus to the row." (https://vercel.com/geist/context-menu)
|
|
157
|
+
* Ours: the menu is named by `label`, which is required (nadicode decision).
|
|
63
158
|
*/
|
|
64
159
|
export declare function ActionContextMenu({ label, record, commands, children }: ActionContextMenuProps): import("react").JSX.Element;
|
|
160
|
+
export {};
|
|
65
161
|
//# sourceMappingURL=action-menu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-menu.d.ts","sourceRoot":"","sources":["../../src/components/action-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,YA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
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { EllipsisIcon } from "lucide-react";
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
5
|
import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from "./context-menu.js";
|
|
6
6
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, } from "./dropdown-menu.js";
|
|
7
|
+
import { useCommandRunner } from "../internal/command-runner.js";
|
|
7
8
|
import { RecordMenuItems } from "../internal/record-menu-items.js";
|
|
8
|
-
|
|
9
|
+
/** Geist's cap: "Cap a Menu around 10 items." (https://vercel.com/geist/menu) */
|
|
10
|
+
export const MAX_COMMANDS = 10;
|
|
11
|
+
/** Throws in development and tests past Geist's cap, so a list of commands is cut where it is written. */
|
|
12
|
+
export function refuseTooManyCommands(name, count) {
|
|
13
|
+
if (typeof process === "undefined" || process.env.NODE_ENV === "production")
|
|
14
|
+
return;
|
|
15
|
+
if (count > MAX_COMMANDS) {
|
|
16
|
+
throw new Error(`${name} has ${count} commands; a record holds ${MAX_COMMANDS} at most. Move the rest to the record's page.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
9
19
|
/**
|
|
10
|
-
* A record's three dots: the menu of
|
|
20
|
+
* A record's three dots: the menu of the commands that do not stand as buttons, headed by the record's name.
|
|
11
21
|
*
|
|
12
22
|
* @family Menus
|
|
13
|
-
* @when "An overflow menu triggered by a three-dot icon that reveals additional actions in a dropdown." (https://vercel.com/geist/dots-menu)
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
23
|
+
* @when "An overflow menu triggered by a three-dot icon that reveals additional actions in a dropdown." (https://vercel.com/geist/dots-menu)
|
|
24
|
+
* "Use Menu for a discoverable trigger that opens a list of actions on a single resource (a dots menu on a row, a dropdown on a primary entity)." (https://vercel.com/geist/menu)
|
|
25
|
+
* Ours: the three dots of a record or of a page. Only `RecordList`, `RecordCommands` and the page compositions draw it, from the commands a product passes them; a product never renders it, which `nadicodeai/page-composition` refuses (nadicode decision).
|
|
26
|
+
* @instead "For right-click or long-press on a row, use `ContextMenu`. For global commands behind `⌘K`, use `CommandMenu`." (https://vercel.com/geist/menu)
|
|
27
|
+
* Ours: a record's commands are given to `RecordList` (in a list) or `RecordCommands` (one record outside a list), and a page's to its composition's `actions`; each decides what stands as a button and what goes in these dots. Finding across everything is `CommandDialog`; a value to choose is a `Select` (nadicode decision).
|
|
28
|
+
* @behaviour "Open on click, not hover; hover-open menus collide with screen readers and trackpad scrolls." (https://vercel.com/geist/menu)
|
|
29
|
+
* "Position auto-flips based on window bounds; don’t hardcode a side that clips on narrow viewports." (https://vercel.com/geist/menu)
|
|
30
|
+
* "Close on item activation, Escape, and outside-click. Don’t auto-close on a hover-out." (https://vercel.com/geist/menu)
|
|
31
|
+
* "Use `MenuItemLocked` for permission-gated actions so the lock icon and disabled state explain why the row is inert." (https://vercel.com/geist/menu)
|
|
32
|
+
* Ours: that is `locked` with its required `reason`: the row stays, inert, with a lock at its end and the reason under its label (nadicode decision).
|
|
33
|
+
* "Cap a Menu around 10 items. Past that, group with `MenuSection` or move secondary actions to a settings page." (https://vercel.com/geist/menu)
|
|
34
|
+
* Ours: it holds two commands or more, so a menu of one does not compile (owner, 2026-11-06), and more than ten throws in development and tests (nadicode decision). The menu is at most 288 px wide and the record's name heading it is one line, cut with an ellipsis and whole in its tooltip (nadicode decision). The trigger is a ghost icon button, 32 px on a row and at the control height (36 px) on a title row, named for its record, last after any button, keeping its fill while open (nadicode decision). The menu opens 10 px under the trigger, aligned to its end: the record's name, the commands with their icons first and the value one acts on in mono under it, then the destructive ones after a divider in the error colour (nadicode decision). A command that cannot run now takes `disabledReason`: it stays, 36 px like the rest, its text muted, never dimmed, with why in a line under its label; a destructive one is muted, not red; a running one takes `pending` and `pendingLabel` (nadicode decision). A destructive command opens its confirmation from here, or runs and offers its Undo, as `MenuCommand` requires (nadicode decision).
|
|
35
|
+
* @words "Item children are Title Case `Verb + Noun` (`Rename Project`, `Duplicate Deployment`). Bare verbs like `Rename` or `Edit` are wrong outside obvious single-object context." (https://vercel.com/geist/menu)
|
|
36
|
+
* "End an item with `…` only when activating it opens a follow-up dialog (`Rename…`, `Transfer to Team…`)." (https://vercel.com/geist/menu)
|
|
37
|
+
* "Group destructive items at the bottom, separated by a divider, and keep the destructive copy as `Verb + Noun` (`Delete Project`, never bare `Delete`)." (https://vercel.com/geist/menu)
|
|
38
|
+
* Ours: sentence case, "Remove mailbox", not Title Case; the trigger reads "More for {record}" and the header is the record's name; rows wrap, never truncate (nadicode decision).
|
|
39
|
+
* @access "Typeahead jumps to the next item whose label starts with the typed character; keep the visible label first so typeahead matches what the user sees." (https://vercel.com/geist/menu)
|
|
40
|
+
* "Return focus to the trigger on close so keyboard users keep their place in the row." (https://vercel.com/geist/menu)
|
|
41
|
+
* Ours: the trigger is a ghost icon button named by `label`, `aria-expanded` while open; `role="menu"`, items `menuitem` in a group named by `record`; every command requires its `icon`, which is hidden; the value a command acts on and its reason are the item's description (nadicode decision).
|
|
18
42
|
*/
|
|
19
|
-
export function ActionMenu({ label, record, commands, triggerId, open, onOpenChange, modal, side = "bottom", finalFocus, }) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
console.warn(`ActionMenu "${label}" has ${commands.length} commands; a menu holds ${MAX_COMMANDS} at most. Move the rest to the record's page.`);
|
|
24
|
-
}
|
|
25
|
-
if (commands.length === 0)
|
|
26
|
-
return null;
|
|
27
|
-
return (_jsxs(DropdownMenu, { modal: modal, onOpenChange: onOpenChange ? (next) => onOpenChange(next) : undefined, open: open, children: [_jsx(DropdownMenuTrigger, { id: triggerId, render: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": label }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsx(DropdownMenuContent, { align: "end", className: "max-w-72", finalFocus: finalFocus, side: side, children: _jsx(RecordMenuItems, { commands: commands, record: record }) })] }));
|
|
43
|
+
export function ActionMenu({ label, record, commands, size, triggerId, open, onOpenChange, modal, side = "bottom", finalFocus, }) {
|
|
44
|
+
refuseTooManyCommands(`ActionMenu "${label}"`, commands.length);
|
|
45
|
+
const { arm, dialog } = useCommandRunner();
|
|
46
|
+
return (_jsxs(_Fragment, { children: [_jsxs(DropdownMenu, { modal: modal, onOpenChange: onOpenChange ? (next) => onOpenChange(next) : undefined, open: open, children: [_jsx(DropdownMenuTrigger, { id: triggerId, render: _jsx(Button, { "aria-label": label, size: size === "row" ? "icon-sm" : "icon", variant: "ghost" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsx(DropdownMenuContent, { align: "end", className: "max-w-72", finalFocus: finalFocus, side: side, children: _jsx(RecordMenuItems, { commands: commands.map(arm), record: record }) })] }), dialog] }));
|
|
28
47
|
}
|
|
29
48
|
/**
|
|
30
|
-
* A record's menu opened from its row by a right-click: the mirror of its
|
|
49
|
+
* A record's menu opened from its row by a right-click: the mirror of its visible commands.
|
|
31
50
|
*
|
|
32
51
|
* @family Menus
|
|
33
|
-
* @when "ContextMenu must never be the only entry point for an action. Mirror every item in a visible `Menu` trigger or row button so mouse-only and keyboard-only users have parity." (https://vercel.com/geist/context-menu)
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
52
|
+
* @when "ContextMenu must never be the only entry point for an action. Mirror every item in a visible `Menu` trigger or row button so mouse-only and keyboard-only users have parity." (https://vercel.com/geist/context-menu)
|
|
53
|
+
* Ours: drawn by `DataTable`'s entity rows and by `RecordContextMenu`, with every command the record's visible buttons and three dots hold; a product never renders it, which `nadicodeai/page-composition` refuses (nadicode decision).
|
|
54
|
+
* @instead "For a global command palette, use `CommandMenu`; for a dropdown opened from a visible trigger, use `Menu`." (https://vercel.com/geist/context-menu)
|
|
55
|
+
* Ours: a product gives a card's right-click to `RecordContextMenu`, with the same commands it gives `RecordCommands` (nadicode decision).
|
|
56
|
+
* @behaviour "Bind to right-click on desktop and long-press on touch. Suppress the native browser menu only on the trigger area, not the whole page." (https://vercel.com/geist/context-menu)
|
|
57
|
+
* "Position the menu at the pointer; if it would overflow the viewport, flip horizontally then vertically before clipping." (https://vercel.com/geist/context-menu)
|
|
58
|
+
* "Close on activation, Escape, and outside-click. Don’t close on hover-out." (https://vercel.com/geist/context-menu)
|
|
59
|
+
* Ours: every command of the record, in the order of its buttons and dots, with the dropdown's surface and rows, destructive last after a divider, a destructive one opening its confirmation; with no command the row renders alone and keeps its element (nadicode decision).
|
|
60
|
+
* @words "Items follow the same rules as `Menu`: Title Case `Verb + Noun` (`Open in New Tab`, `Copy URL`, `Delete Deployment`). Bare verbs are wrong." (https://vercel.com/geist/context-menu)
|
|
61
|
+
* Ours: sentence case, "Copy address"; a command reached two ways reads the same both ways (nadicode decision).
|
|
62
|
+
* @access "Trigger the keyboard menu key (`Shift+F10` on Windows/Linux, the menu key, or platform equivalent) to open the same menu without right-click." (https://vercel.com/geist/context-menu)
|
|
63
|
+
* "Up/Down arrows move focus, Enter/Space activates, Escape closes and returns focus to the row." (https://vercel.com/geist/context-menu)
|
|
64
|
+
* Ours: the menu is named by `label`, which is required (nadicode decision).
|
|
38
65
|
*/
|
|
39
66
|
export function ActionContextMenu({ label, record, commands, children }) {
|
|
67
|
+
const { arm, dialog } = useCommandRunner();
|
|
40
68
|
const none = commands.length === 0;
|
|
41
69
|
// The row stays one element whether or not it has commands, so a menu that appears or goes
|
|
42
70
|
// never remounts the row; with none the browser keeps its own menu and the row its selection.
|
|
43
|
-
return (_jsxs(ContextMenu, { disabled: none, children: [_jsx(ContextMenuTrigger, { className: none ? "select-auto" : undefined, render: children }), none ? null : (_jsx(ContextMenuContent, { "aria-label": label, className: "max-w-72", children: _jsx(RecordMenuItems, { commands: commands, record: record }) }))] }));
|
|
71
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ContextMenu, { disabled: none, children: [_jsx(ContextMenuTrigger, { className: none ? "select-auto" : undefined, render: children }), none ? null : (_jsx(ContextMenuContent, { "aria-label": label, className: "max-w-72", children: _jsx(RecordMenuItems, { commands: commands.map(arm), record: record }) }))] }), dialog] }));
|
|
44
72
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type LucideIcon } from "lucide-react";
|
|
2
2
|
import type { ComponentProps, ReactNode } from "react";
|
|
3
|
-
import type {
|
|
3
|
+
import type { RowCommand } from "./record-commands.js";
|
|
4
4
|
import type { IdentityMarkProps } from "./identity-mark.js";
|
|
5
5
|
import type { PageCommand } from "./page-actions.js";
|
|
6
6
|
import type { RowMessage } from "../internal/row-message.js";
|
|
@@ -43,9 +43,10 @@ export type CatalogEntryProps = {
|
|
|
43
43
|
/** One categorical fact, a Tag: the audience, the owner. */
|
|
44
44
|
fact?: ReactNode;
|
|
45
45
|
add?: CatalogEntryAdd;
|
|
46
|
+
/** The entry's commands, drawn as `RecordCommands` draws one record's, and its three dots' name. */
|
|
46
47
|
menu?: {
|
|
47
48
|
label: string;
|
|
48
|
-
commands: readonly
|
|
49
|
+
commands: readonly RowCommand[];
|
|
49
50
|
};
|
|
50
51
|
/** The add failed or cannot run: its message in the description's place. */
|
|
51
52
|
state?: RowMessage | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-entry.d.ts","sourceRoot":"","sources":["../../src/components/catalog-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAaL,KAAK,UAAU,EAiBhB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"catalog-entry.d.ts","sourceRoot":"","sources":["../../src/components/catalog-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAaL,KAAK,UAAU,EAiBhB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EA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CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACvC,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { type CollectionSearchProps } from "./collection-search.js";
|
|
|
5
5
|
import { type CollectionSortProps } from "./collection-sort.js";
|
|
6
6
|
import type { EmptyStateKind } from "./empty-state.js";
|
|
7
7
|
import { type PageActionsProps } from "./page-actions.js";
|
|
8
|
+
import { type NoticeBannerProps } from "./notice-banner.js";
|
|
8
9
|
import { type RecordListWithout } from "./record-list.js";
|
|
9
10
|
import { type CollectionRail } from "../internal/collection-rail.js";
|
|
10
11
|
export type { RowMessage } from "./record-list.js";
|
|
@@ -18,13 +19,15 @@ type CollectionTitle = {
|
|
|
18
19
|
title?: undefined;
|
|
19
20
|
description?: never;
|
|
20
21
|
};
|
|
21
|
-
export type CollectionPageProps<TRecord extends RowData
|
|
22
|
+
export type CollectionPageProps<TRecord extends RowData> = RecordListWithout<TRecord, "heading" | "noMatch" | "layout"> & CollectionTitle & {
|
|
22
23
|
/** The title row: secondary, primary, then the three dots. The primary stays here whether the collection is empty or not. */
|
|
23
24
|
actions?: Omit<PageActionsProps, "period">;
|
|
24
25
|
/** The page's sibling collections, under the title row: `TabsNav variant="line"`. */
|
|
25
26
|
tabs?: ReactElement;
|
|
26
27
|
/** Actionable conditions above the toolbar, independent of sibling navigation. */
|
|
27
28
|
attention?: ReactNode;
|
|
29
|
+
/** A condition of the collection's own owner that the page fixes, under the title: one `NoticeBanner`. */
|
|
30
|
+
notice?: NoticeBannerProps;
|
|
28
31
|
search?: CollectionSearchProps;
|
|
29
32
|
filters?: CollectionFiltersProps;
|
|
30
33
|
sort?: CollectionSortProps;
|
|
@@ -52,11 +55,11 @@ export type CollectionPageProps<TRecord extends RowData, TCommand extends string
|
|
|
52
55
|
* Ours: Customers and Partners use the full-width list, with actionable attention above the toolbar when present. Business summaries belong on Dashboard and Analytics. A rail remains available for context that belongs to the collection itself, such as the selected Library hub.
|
|
53
56
|
* @instead “For tabular data with sortable columns and shared row shape, use `Table` instead.” (https://vercel.com/geist/entity)
|
|
54
57
|
* Ours: records compared across columns, read by their headings, are a `DataTable` under the page's own title and toolbar. A list inside another page's section is a `RecordList` with its `heading`.
|
|
55
|
-
* @behaviour The page supplies its records and their commands as data, never its own toolbar, table, rows or menus. Title or none, as Vercel decides it: a page that is one plain list of things a person makes, whose concept needs no sentence, such as Vercel's Domains, Storage, Projects and AI Gateway's API Keys, has no title row, and its actions (its create buttons) end its search row, after the filters. A page that needs its one sentence, or whose commands do something other than create, such as Environment Variables, Members, Integrations and Deployments, keeps its title row with the sentence and every action on it. The product says which a page is (`PageActionsHostProvider`'s `titled`, or this composition's own `title`), never what the page shows at the moment, so an issue appearing above the list never moves the actions. With a `rail`, the toolbar spans the page and under it stand two columns from 1280 px: the rail, 300 px, then the records' card, its top level with the rail's first title and named by the page's title alone, never a second heading, and the records' rows are `RecordList`'s `line` rows; below 1280 px the records come first and the rail follows them. Each rail card has its title above it at 16 px, an optional 44 px muted summary row with its one outline button at its end (a button never stands in a row of its own, so a card with an `action` has a `summary`), then its items: a figure is one 36 px row, its title and its number at the trailing edge; a record is its 24 px mark, a title over a muted line that wraps to a second before it is cut, and a figure or a status at its end, the whole item opening its record; a card with no items draws its `empty` inside it as one 44 px row like an item. While the rail's read is in flight a card's `items` are undefined and it holds its place with three placeholder lines, so the two columns stand from the first frame; a rail whose read `failed` is one card saying so, and the records beside it stay. Under the title sits only the `description`, when the collection's kind needs explaining; otherwise nothing. The page's title names the collection once, and the records' card never adds a header that only describes it. The title row
|
|
58
|
+
* @behaviour The page supplies its records and their commands as data, never its own toolbar, table, rows or menus. Title or none, as Vercel decides it: a page that is one plain list of things a person makes, whose concept needs no sentence, such as Vercel's Domains, Storage, Projects and AI Gateway's API Keys, has no title row, and its actions (its create buttons) end its search row, after the filters. A page that needs its one sentence, or whose commands do something other than create, such as Environment Variables, Members, Integrations and Deployments, keeps its title row with the sentence and every action on it. The product says which a page is (`PageActionsHostProvider`'s `titled`, or this composition's own `title`), never what the page shows at the moment, so an issue appearing above the list never moves the actions. With a `rail`, the toolbar spans the page and under it stand two columns from 1280 px: the rail, 300 px, then the records' card, its top level with the rail's first title and named by the page's title alone, never a second heading, and the records' rows are `RecordList`'s `line` rows; below 1280 px the records come first and the rail follows them. Each rail card has its title above it at 16 px, an optional 44 px muted summary row with its one outline button at its end (a button never stands in a row of its own, so a card with an `action` has a `summary`), then its items: a figure is one 36 px row, its title and its number at the trailing edge; a record is its 24 px mark, a title over a muted line that wraps to a second before it is cut, and a figure or a status at its end, the whole item opening its record; a card with no items draws its `empty` inside it as one 44 px row like an item. While the rail's read is in flight a card's `items` are undefined and it holds its place with three placeholder lines, so the two columns stand from the first frame; a rail whose read `failed` is one card saying so, and the records beside it stay. Under the title sits only the `description`, when the collection's kind needs explaining; otherwise nothing. The page's title names the collection once, and the records' card never adds a header that only describes it. The title row is `PageActions`'s, drawn from `actions`. The primary stays in the title row whether the collection is empty or not, filled, as Vercel's Flags keeps Create Flag; a first use repeats it as the filled button in its card. The page's actions stay on its title row whichever tab is shown; the toolbar belongs to the tab shown, and switching clears its search and page. One toolbar holds the search, which grows, then the filters, then the sort; it shows while there are records, a search or filter is set, or a facet hides records while unset (`hidesWhileUnset`, as the archived companies), and is glass only where the rows scroll under it. While a new search, filter or sort is read, the toolbar is busy and, after a second, shows the one waiting line, while the last rows stay. The rows, their states and their loading are the RecordList's; no match is offered only in those same cases, so records a facet hides by default are always one choice away.
|
|
56
59
|
* @words “For multi-facet filters use the plural template `No {Items} Match Your Filters` and suggest widening or clearing.” (https://vercel.com/geist/empty-state)
|
|
57
60
|
* Ours: every string is the product's, in sentence case. The title names the collection in the plural ("Agents"); the search says what it finds ("Find a skill"); no match says what found nothing and offers to clear it ("Clear search", "Clear filters").
|
|
58
61
|
* @access “After an async filter change, wrap the region in `aria-live="polite"` so screen readers announce the new state.” (https://vercel.com/geist/empty-state)
|
|
59
62
|
* Ours: the rows' region is the RecordList's, which holds it. The title is the page's h1 when the composition draws it. The toolbar is named by `label` and busy while `pending`; the rows are the RecordList's table, named by `label`.
|
|
60
63
|
*/
|
|
61
|
-
export declare function CollectionPage<TRecord extends RowData
|
|
64
|
+
export declare function CollectionPage<TRecord extends RowData>(props: CollectionPageProps<TRecord>): import("react").JSX.Element;
|
|
62
65
|
//# sourceMappingURL=collection-page.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-page.d.ts","sourceRoot":"","sources":["../../src/components/collection-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACjG,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"collection-page.d.ts","sourceRoot":"","sources":["../../src/components/collection-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACjG,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAkB,KAAK,mBAAmB,EAAE,M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AC;IACnC,iDAAiD;IACjD,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;IACpD,oGAAoG;IACpG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB,CAAC;AAEJ;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,OAAO,EAAE,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,+BAkE1F"}
|
|
@@ -5,6 +5,7 @@ import { CollectionSearch } from "./collection-search.js";
|
|
|
5
5
|
import { CollectionSort } from "./collection-sort.js";
|
|
6
6
|
import { CollectionToolbar } from "./collection-toolbar.js";
|
|
7
7
|
import { CardActionsRow, PageActions, PageActionsHostProvider, usePageTitled, } from "./page-actions.js";
|
|
8
|
+
import { NoticeBanner } from "./notice-banner.js";
|
|
8
9
|
import { PageHeader } from "./page-header.js";
|
|
9
10
|
import { RecordList } from "./record-list.js";
|
|
10
11
|
import { WaitingLine } from "./waiting-line.js";
|
|
@@ -20,20 +21,20 @@ import { CollectionRailColumn } from "../internal/collection-rail.js";
|
|
|
20
21
|
* Ours: Customers and Partners use the full-width list, with actionable attention above the toolbar when present. Business summaries belong on Dashboard and Analytics. A rail remains available for context that belongs to the collection itself, such as the selected Library hub.
|
|
21
22
|
* @instead “For tabular data with sortable columns and shared row shape, use `Table` instead.” (https://vercel.com/geist/entity)
|
|
22
23
|
* Ours: records compared across columns, read by their headings, are a `DataTable` under the page's own title and toolbar. A list inside another page's section is a `RecordList` with its `heading`.
|
|
23
|
-
* @behaviour The page supplies its records and their commands as data, never its own toolbar, table, rows or menus. Title or none, as Vercel decides it: a page that is one plain list of things a person makes, whose concept needs no sentence, such as Vercel's Domains, Storage, Projects and AI Gateway's API Keys, has no title row, and its actions (its create buttons) end its search row, after the filters. A page that needs its one sentence, or whose commands do something other than create, such as Environment Variables, Members, Integrations and Deployments, keeps its title row with the sentence and every action on it. The product says which a page is (`PageActionsHostProvider`'s `titled`, or this composition's own `title`), never what the page shows at the moment, so an issue appearing above the list never moves the actions. With a `rail`, the toolbar spans the page and under it stand two columns from 1280 px: the rail, 300 px, then the records' card, its top level with the rail's first title and named by the page's title alone, never a second heading, and the records' rows are `RecordList`'s `line` rows; below 1280 px the records come first and the rail follows them. Each rail card has its title above it at 16 px, an optional 44 px muted summary row with its one outline button at its end (a button never stands in a row of its own, so a card with an `action` has a `summary`), then its items: a figure is one 36 px row, its title and its number at the trailing edge; a record is its 24 px mark, a title over a muted line that wraps to a second before it is cut, and a figure or a status at its end, the whole item opening its record; a card with no items draws its `empty` inside it as one 44 px row like an item. While the rail's read is in flight a card's `items` are undefined and it holds its place with three placeholder lines, so the two columns stand from the first frame; a rail whose read `failed` is one card saying so, and the records beside it stay. Under the title sits only the `description`, when the collection's kind needs explaining; otherwise nothing. The page's title names the collection once, and the records' card never adds a header that only describes it. The title row
|
|
24
|
+
* @behaviour The page supplies its records and their commands as data, never its own toolbar, table, rows or menus. Title or none, as Vercel decides it: a page that is one plain list of things a person makes, whose concept needs no sentence, such as Vercel's Domains, Storage, Projects and AI Gateway's API Keys, has no title row, and its actions (its create buttons) end its search row, after the filters. A page that needs its one sentence, or whose commands do something other than create, such as Environment Variables, Members, Integrations and Deployments, keeps its title row with the sentence and every action on it. The product says which a page is (`PageActionsHostProvider`'s `titled`, or this composition's own `title`), never what the page shows at the moment, so an issue appearing above the list never moves the actions. With a `rail`, the toolbar spans the page and under it stand two columns from 1280 px: the rail, 300 px, then the records' card, its top level with the rail's first title and named by the page's title alone, never a second heading, and the records' rows are `RecordList`'s `line` rows; below 1280 px the records come first and the rail follows them. Each rail card has its title above it at 16 px, an optional 44 px muted summary row with its one outline button at its end (a button never stands in a row of its own, so a card with an `action` has a `summary`), then its items: a figure is one 36 px row, its title and its number at the trailing edge; a record is its 24 px mark, a title over a muted line that wraps to a second before it is cut, and a figure or a status at its end, the whole item opening its record; a card with no items draws its `empty` inside it as one 44 px row like an item. While the rail's read is in flight a card's `items` are undefined and it holds its place with three placeholder lines, so the two columns stand from the first frame; a rail whose read `failed` is one card saying so, and the records beside it stay. Under the title sits only the `description`, when the collection's kind needs explaining; otherwise nothing. The page's title names the collection once, and the records' card never adds a header that only describes it. The title row is `PageActions`'s, drawn from `actions`. The primary stays in the title row whether the collection is empty or not, filled, as Vercel's Flags keeps Create Flag; a first use repeats it as the filled button in its card. The page's actions stay on its title row whichever tab is shown; the toolbar belongs to the tab shown, and switching clears its search and page. One toolbar holds the search, which grows, then the filters, then the sort; it shows while there are records, a search or filter is set, or a facet hides records while unset (`hidesWhileUnset`, as the archived companies), and is glass only where the rows scroll under it. While a new search, filter or sort is read, the toolbar is busy and, after a second, shows the one waiting line, while the last rows stay. The rows, their states and their loading are the RecordList's; no match is offered only in those same cases, so records a facet hides by default are always one choice away.
|
|
24
25
|
* @words “For multi-facet filters use the plural template `No {Items} Match Your Filters` and suggest widening or clearing.” (https://vercel.com/geist/empty-state)
|
|
25
26
|
* Ours: every string is the product's, in sentence case. The title names the collection in the plural ("Agents"); the search says what it finds ("Find a skill"); no match says what found nothing and offers to clear it ("Clear search", "Clear filters").
|
|
26
27
|
* @access “After an async filter change, wrap the region in `aria-live="polite"` so screen readers announce the new state.” (https://vercel.com/geist/empty-state)
|
|
27
28
|
* Ours: the rows' region is the RecordList's, which holds it. The title is the page's h1 when the composition draws it. The toolbar is named by `label` and busy while `pending`; the rows are the RecordList's table, named by `label`.
|
|
28
29
|
*/
|
|
29
30
|
export function CollectionPage(props) {
|
|
30
|
-
const { title, description, actions, tabs, attention, search, filters, sort, toolbarSurface, noMatch, pending, rail, ...list } = props;
|
|
31
|
+
const { title, description, actions, tabs, attention, notice, search, filters, sort, toolbarSurface, noMatch, pending, rail, ...list } = props;
|
|
31
32
|
const hostTitled = usePageTitled();
|
|
32
33
|
const titled = Boolean(title) || hostTitled;
|
|
33
34
|
const toolbarActions = actions && !titled ? _jsx(CardActionsRow, { ...actions }) : null;
|
|
34
35
|
const hasRecords = list.records !== undefined && list.records.length > 0;
|
|
35
36
|
const narrowed = Boolean(search?.value) ||
|
|
36
37
|
(filters?.facets.some((facet) => facet.value || facet.hidesWhileUnset) ?? false);
|
|
37
|
-
const page = (_jsxs("div", { className: "grid min-w-0 gap-4", "data-slot": "collection-page", children: [title ? _jsx(PageHeader, { description: description, title: title }) : null, actions && titled ? _jsx(PageActions, { ...actions }) : null, tabs, attention, ((search || filters || sort) && (hasRecords || narrowed)) || toolbarActions ? (_jsx(CollectionToolbar, { actions: filters || sort || toolbarActions ? (_jsxs(_Fragment, { children: [filters && (hasRecords || narrowed) ? _jsx(CollectionFilters, { ...filters }) : null, sort && (hasRecords || narrowed) ? _jsx(CollectionSort, { ...sort }) : null, toolbarActions] })) : undefined, "aria-busy": pending ? true : undefined, label: list.label, search: search && (hasRecords || narrowed) ? _jsx(CollectionSearch, { ...search }) : undefined, status: _jsx(WaitingLine, { className: "w-24", decorative: true, waiting: pending === true }), surface: toolbarSurface ?? "plain" })) : null, rail ? (_jsxs("div", { className: "grid min-w-0 gap-6 xl:grid-cols-[18.75rem_minmax(0,1fr)] xl:items-start", "data-slot": "collection-columns", children: [_jsx("div", { className: "min-w-0 xl:col-start-2 xl:row-start-1", children: _jsx(RecordList, { ...list, layout: "line", noMatch: narrowed ? noMatch : undefined }) }), _jsx(CollectionRailColumn, { className: "xl:col-start-1 xl:row-start-1", rail: rail })] })) : (_jsx(RecordList, { ...list, noMatch: narrowed ? noMatch : undefined }))] }));
|
|
38
|
+
const page = (_jsxs("div", { className: "grid min-w-0 gap-4", "data-slot": "collection-page", children: [title ? _jsx(PageHeader, { description: description, title: title }) : null, actions && titled ? _jsx(PageActions, { ...actions }) : null, notice ? _jsx(NoticeBanner, { ...notice }) : null, tabs, attention, ((search || filters || sort) && (hasRecords || narrowed)) || toolbarActions ? (_jsx(CollectionToolbar, { actions: filters || sort || toolbarActions ? (_jsxs(_Fragment, { children: [filters && (hasRecords || narrowed) ? _jsx(CollectionFilters, { ...filters }) : null, sort && (hasRecords || narrowed) ? _jsx(CollectionSort, { ...sort }) : null, toolbarActions] })) : undefined, "aria-busy": pending ? true : undefined, label: list.label, search: search && (hasRecords || narrowed) ? _jsx(CollectionSearch, { ...search }) : undefined, status: _jsx(WaitingLine, { className: "w-24", decorative: true, waiting: pending === true }), surface: toolbarSurface ?? "plain" })) : null, rail ? (_jsxs("div", { className: "grid min-w-0 gap-6 xl:grid-cols-[18.75rem_minmax(0,1fr)] xl:items-start", "data-slot": "collection-columns", children: [_jsx("div", { className: "min-w-0 xl:col-start-2 xl:row-start-1", children: _jsx(RecordList, { ...list, layout: "line", noMatch: narrowed ? noMatch : undefined }) }), _jsx(CollectionRailColumn, { className: "xl:col-start-1 xl:row-start-1", rail: rail })] })) : (_jsx(RecordList, { ...list, noMatch: narrowed ? noMatch : undefined }))] }));
|
|
38
39
|
return title ? _jsx(PageActionsHostProvider, { children: page }) : page;
|
|
39
40
|
}
|