@nadicodeai/ui 12.1.206 → 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/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
|
@@ -1,65 +1,21 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
3
|
-
import { type
|
|
4
|
-
export type PageCommandAction
|
|
5
|
-
onClick: (event: MouseEvent<HTMLElement>) => void;
|
|
6
|
-
link?: never;
|
|
7
|
-
render?: never;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* The product's router link, such as `<Link href="/agents" />`: it keeps its
|
|
11
|
-
* own behaviour and is drawn as a link with the button's look.
|
|
12
|
-
*/
|
|
13
|
-
| {
|
|
14
|
-
link: ReactElement;
|
|
15
|
-
onClick?: never;
|
|
16
|
-
render?: never;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* An element that is itself a command, such as a component that renders a
|
|
20
|
-
* `Button` and opens a dialog: it takes the button's look and props.
|
|
21
|
-
*/
|
|
22
|
-
| {
|
|
23
|
-
render: ReactElement;
|
|
24
|
-
onClick?: never;
|
|
25
|
-
link?: never;
|
|
26
|
-
};
|
|
27
|
-
/** Running: the pair travels together, so a command that can be pending always has the word to say. */
|
|
28
|
-
export type PendingWord = {
|
|
29
|
-
/** Running: the button keeps its place, size and icon and says `pendingLabel`, with aria-busy. */
|
|
30
|
-
pending?: boolean | undefined;
|
|
31
|
-
pendingLabel: string;
|
|
32
|
-
} | {
|
|
33
|
-
pending?: false | undefined;
|
|
34
|
-
pendingLabel?: string | undefined;
|
|
35
|
-
};
|
|
36
|
-
type PageCommandFace = PendingWord & {
|
|
37
|
-
label: string;
|
|
38
|
-
icon?: ReactElement | undefined;
|
|
39
|
-
/** Read instead of the label when the label alone does not name the target: "Sign in to Notion". */
|
|
40
|
-
accessibleName?: string | undefined;
|
|
41
|
-
/** Opens outside the product: the arrow after the label. */
|
|
42
|
-
external?: boolean | undefined;
|
|
43
|
-
disabled?: boolean | undefined;
|
|
44
|
-
};
|
|
45
|
-
/** A command drawn as a button: on the title row, in an empty state, in a row. Its icon leads the label. */
|
|
46
|
-
export type PageCommand = PageCommandAction & PageCommandFace;
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import { type CommandLook, type PageCommand, type PageCommandFace } from "../internal/page-command-button.js";
|
|
3
|
+
import { type MenuCommands, type RecordMenu } from "./action-menu.js";
|
|
4
|
+
export type { PageCommand, PageCommandAction, PendingWord } from "../internal/page-command-button.js";
|
|
47
5
|
/**
|
|
48
6
|
* A page's main command that comes in a few kinds of the same job, such as Add source's folder,
|
|
49
7
|
* documents or web page: the button opens a menu of them, as Vercel's "Add New…" does. Only the
|
|
50
8
|
* page's primary and a first use's action take it.
|
|
51
9
|
*/
|
|
52
10
|
export type PageChoicesCommand = PageCommandFace & {
|
|
53
|
-
choices:
|
|
11
|
+
choices: MenuCommands;
|
|
54
12
|
onClick?: never;
|
|
55
13
|
link?: never;
|
|
56
14
|
render?: never;
|
|
57
15
|
};
|
|
58
16
|
export type PagePrimaryCommand = PageCommand | PageChoicesCommand;
|
|
59
17
|
/** The page's three dots, which open only for two commands or more. */
|
|
60
|
-
export type PageMenu =
|
|
61
|
-
commands: readonly [MenuCommand, MenuCommand, ...MenuCommand[]];
|
|
62
|
-
};
|
|
18
|
+
export type PageMenu = RecordMenu;
|
|
63
19
|
export type PageActionsProps = {
|
|
64
20
|
/** An overview's reading period, first on the title row: a period `Select` or `DateRangeControl`. */
|
|
65
21
|
period?: ReactElement | undefined;
|
|
@@ -83,7 +39,7 @@ export type CardActions = Omit<PageActionsProps, "secondary"> & {
|
|
|
83
39
|
*
|
|
84
40
|
* @family Actions
|
|
85
41
|
* @when The header of every card composition draws it from the card's `actions`: ObjectPage, ObjectSection, SettingsSection, SettingsFactsSection and TableCard. A page gives the card its `actions` and never renders this row.
|
|
86
|
-
* @instead A page's own commands are `PageActions` on the title's row. A
|
|
42
|
+
* @instead A page's own commands are `PageActions` on the title's row. A record's commands are its list's (`RecordList`) or its `RecordCommands`. A setting card whose value stands at its header's end, such as an avatar upload, gives `SettingsSection` its `control`. A link inside the card's description or footer line is a `TextLink` in that sentence (nadicode decision).
|
|
87
43
|
* @behaviour As Vercel's card headers draw it (the plan card's "Invoices" and "Usage", a deployment's "Share" and "Logs" before "Visit", the overview's Usage card's "Billing"): the muted `meta` (a period or a count), the reading `period`, up to two secondaries as outline buttons, the primary as the filled button, and the three dots last. A way to another page is a secondary with its `link`, drawn as a button like the others and named for the page; it is never a text link in the header's corner. A page has one filled button, so a card on a page whose primary stands elsewhere takes outline buttons only. It wraps under the title when the header is narrow, as the card's header places it.
|
|
88
44
|
* @words A command is a verb on the card's object ("Add card", "Buy Extra usage for Customers"); a way to another page is that page's name as its navigation writes it ("Statements"); `meta` is a short count or period ("2 of 5 Agents").
|
|
89
45
|
* @access DOM order is visual order. A command whose label does not name its target carries `accessibleName`. A way to another page is a real link.
|
|
@@ -91,12 +47,8 @@ export type CardActions = Omit<PageActionsProps, "secondary"> & {
|
|
|
91
47
|
export declare function CardActionsRow({ meta, period, secondary, primary, menu }: CardActions): import("react").JSX.Element | null;
|
|
92
48
|
/** Whether a card's header has anything of `actions` to draw, so it keeps no empty cell for them. */
|
|
93
49
|
export declare function hasCardActions({ meta, period, secondary, primary, menu }: CardActions): boolean;
|
|
94
|
-
|
|
95
|
-
export declare function PageCommandButton({ command, shape, size, variant, }: {
|
|
50
|
+
export declare function PageCommandButton({ command, ...appearance }: CommandLook & {
|
|
96
51
|
command: PagePrimaryCommand;
|
|
97
|
-
shape?: TextButtonProps["shape"];
|
|
98
|
-
size?: TextButtonProps["size"];
|
|
99
|
-
variant: CommandVariant;
|
|
100
52
|
}): import("react").JSX.Element;
|
|
101
53
|
/** The row of a page's actions where it stands, for a page whose header is its own card. */
|
|
102
54
|
export declare function PageActionsRow({ period, primary, secondary, menu }: PageActionsProps): import("react").JSX.Element | null;
|
|
@@ -129,12 +81,11 @@ export declare function PageActionsSlot(): import("react").JSX.Element;
|
|
|
129
81
|
* `PageActionsHostProvider`, they render where they stand.
|
|
130
82
|
*
|
|
131
83
|
* @family Actions
|
|
132
|
-
* @when The actions of a collection, an object or an overview page, on the title's row at its trailing edge
|
|
133
|
-
* @instead A
|
|
134
|
-
* @behaviour
|
|
135
|
-
* @words
|
|
84
|
+
* @when The actions of a collection, an object or an overview page, on the title's row at its trailing edge; the page compositions draw it from their `actions`. A settings page (`SettingsPage`) has none: each section saves from its footer (nadicode decision).
|
|
85
|
+
* @instead A record's commands are its list's (`RecordList`) or its `RecordCommands`. A collection toolbar holds search and filters, never a page action, except on a list page that draws no title row, where `CollectionPage` ends the toolbar with the page's actions. A page whose parts each have commands gathers them in the one `PageActions` of the component that owns the page; a part never draws a second (nadicode decision).
|
|
86
|
+
* @behaviour Ours: an action sits on the title of the thing it acts on, never on a tab's, and a page's commands are the same on each of its sibling tabs, whatever its list shows or has chosen: only the viewer's permission removes one (nadicode decision). A command on chosen records is the list's own (`select.chosen`), and a record's is its row's (nadicode decision). One per page: a second `PageActions` on the page a person sees would hide the first's commands, so it throws in development and in tests, and in production the one that mounted last keeps the row; a page kept hidden for a quick return (an `Activity` with `mode="hidden"`) has given the row back (nadicode decision). It takes `period`, `secondary`, `primary` and `menu` and draws their order: the period, the outline secondary, the filled primary, then the three dots last; one filled button per page (nadicode decision). The page's three dots hold two commands or more, which the type requires; a single extra command is the secondary (owner, 2026-11-06). A primary whose job comes in a few kinds takes `choices`: its button opens a menu of them aligned to its end, each with its icon; a kind that needs its own fields opens its dialog from its row (nadicode decision). A destination outside the product ends in the arrow. A running command (`pending`) keeps its place and icon and says its pending word, and the type requires `pendingLabel` whenever `pending` is set; one that cannot run now stays, disabled, with `disabledReason` in its tooltip (nadicode decision). Deleting the page's own record is never here: it is the danger zone of the record's Settings, in a card. A reversible command on the record, such as Archive, may stand last in the page's three dots, after a divider, with its `confirm` or `undo` (nadicode decision). “Disable a button only when the action is impossible right now (missing input, insufficient permission); pair with a `Tooltip` that explains why.” (https://vercel.com/geist/button) “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)
|
|
87
|
+
* @words Ours: the primary is the page's main job as verb and noun: "Invite member", "New Agent"; its choices are the kinds, as nouns: "Folder", "Documents", "Web page"; the pending word is its -ing form: "Inviting member"; the menu names the page's record at its top (nadicode decision).
|
|
136
88
|
* @access DOM order is visual order. A command whose label does not name its target carries `accessibleName`. A running command is `aria-busy` and keeps focus. The three dots carry "More for {record}"; the menu returns focus to them when it closes.
|
|
137
89
|
*/
|
|
138
90
|
export declare function PageActions(props: PageActionsProps): import("react").JSX.Element | null;
|
|
139
|
-
export {};
|
|
140
91
|
//# sourceMappingURL=page-actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-actions.d.ts","sourceRoot":"","sources":["../../src/components/page-actions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"page-actions.d.ts","sourceRoot":"","sources":["../../src/components/page-actions.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAKf,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAI/E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElG;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG;IACjD,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAElE,uEAAuE;AACvE,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC;AAElC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qGAAqG;IACrG,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACpC,OAAO,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACzC,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG;IAC9D,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,SAAS,CAAC;CAC3E,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,WAAW,sCAkBrF;AAED,qGAAqG;AACrG,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,WAAW,GAAG,OAAO,CAG/F;AAED,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,GAAG,UAAU,EACd,EAAE,WAAW,GAAG;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,+BAG/C;AAwCD,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,gBAAgB,sCAUpF;AAyCD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,MAAa,GACd,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,+BAIA;AAED,uGAAuG;AACvG,wBAAgB,aAAa,IAAI,OAAO,CAGvC;AAED,yFAAyF;AACzF,wBAAgB,eAAe,gCAS9B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,sCA6BlD"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { createContext, isValidElement, useContext, useEffect, useId, useLayoutEffect, useState, } from "react";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useId, useLayoutEffect, useState, } from "react";
|
|
5
4
|
import { createPortal } from "react-dom";
|
|
6
5
|
import { createStore, useStore } from "zustand";
|
|
6
|
+
import { useCommandRunner } from "../internal/command-runner.js";
|
|
7
|
+
import { lookOf, PageCommandButton as PlainCommandButton, WithDisabledReason, } from "../internal/page-command-button.js";
|
|
7
8
|
import { MenuCommandRow } from "../internal/record-menu-items.js";
|
|
8
9
|
import { ActionMenu } from "./action-menu.js";
|
|
9
|
-
import { Button
|
|
10
|
+
import { Button } from "./button.js";
|
|
10
11
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "./dropdown-menu.js";
|
|
11
12
|
/**
|
|
12
13
|
* The end of a card's header: what the card's reader can do from it, and where it leads.
|
|
13
14
|
*
|
|
14
15
|
* @family Actions
|
|
15
16
|
* @when The header of every card composition draws it from the card's `actions`: ObjectPage, ObjectSection, SettingsSection, SettingsFactsSection and TableCard. A page gives the card its `actions` and never renders this row.
|
|
16
|
-
* @instead A page's own commands are `PageActions` on the title's row. A
|
|
17
|
+
* @instead A page's own commands are `PageActions` on the title's row. A record's commands are its list's (`RecordList`) or its `RecordCommands`. A setting card whose value stands at its header's end, such as an avatar upload, gives `SettingsSection` its `control`. A link inside the card's description or footer line is a `TextLink` in that sentence (nadicode decision).
|
|
17
18
|
* @behaviour As Vercel's card headers draw it (the plan card's "Invoices" and "Usage", a deployment's "Share" and "Logs" before "Visit", the overview's Usage card's "Billing"): the muted `meta` (a period or a count), the reading `period`, up to two secondaries as outline buttons, the primary as the filled button, and the three dots last. A way to another page is a secondary with its `link`, drawn as a button like the others and named for the page; it is never a text link in the header's corner. A page has one filled button, so a card on a page whose primary stands elsewhere takes outline buttons only. It wraps under the title when the header is narrow, as the card's header places it.
|
|
18
19
|
* @words A command is a verb on the card's object ("Add card", "Buy Extra usage for Customers"); a way to another page is that page's name as its navigation writes it ("Statements"); `meta` is a short count or period ("2 of 5 Agents").
|
|
19
20
|
* @access DOM order is visual order. A command whose label does not name its target carries `accessibleName`. A way to another page is a real link.
|
|
@@ -22,43 +23,34 @@ export function CardActionsRow({ meta, period, secondary, primary, menu }) {
|
|
|
22
23
|
if (!hasCardActions({ meta, period, secondary, primary, menu }))
|
|
23
24
|
return null;
|
|
24
25
|
const secondaries = secondary === undefined ? [] : "label" in secondary ? [secondary] : secondary;
|
|
25
|
-
return (_jsxs("div", { "data-slot": "card-actions", className: "flex max-w-full min-w-0 flex-wrap items-center gap-2", children: [meta ? (_jsx("span", { className: "mr-1 text-label-sm text-muted-foreground", "data-slot": "card-actions-meta", children: meta })) : null, period, secondaries.map((command) => (_jsx(PageCommandButton, { command: command, variant: "outline" }, command.label))), primary ? _jsx(PageCommandButton, { command: primary, variant: "default" }) : null, menu ? _jsx(ActionMenu, { ...menu }) : null] }));
|
|
26
|
+
return (_jsxs("div", { "data-slot": "card-actions", className: "flex max-w-full min-w-0 flex-wrap items-center gap-2", children: [meta ? (_jsx("span", { className: "mr-1 text-label-sm text-muted-foreground", "data-slot": "card-actions-meta", children: meta })) : null, period, secondaries.map((command) => (_jsx(PageCommandButton, { command: command, variant: "outline" }, command.label))), primary ? _jsx(PageCommandButton, { command: primary, variant: "default" }) : null, menu ? _jsx(ActionMenu, { ...menu, size: "page" }) : null] }));
|
|
26
27
|
}
|
|
27
28
|
/** Whether a card's header has anything of `actions` to draw, so it keeps no empty cell for them. */
|
|
28
29
|
export function hasCardActions({ meta, period, secondary, primary, menu }) {
|
|
29
30
|
const secondaries = secondary === undefined ? 0 : "label" in secondary ? 1 : secondary.length;
|
|
30
31
|
return Boolean(meta || period || secondaries > 0 || primary || menu);
|
|
31
32
|
}
|
|
32
|
-
export function PageCommandButton({ command,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
return (_jsx(ButtonLink, { ...look, render: link, children: command.label }));
|
|
48
|
-
}
|
|
49
|
-
if (command.render) {
|
|
50
|
-
return (_jsx(Button, { ...look, render: command.render, children: command.label }));
|
|
51
|
-
}
|
|
52
|
-
if ("choices" in command && command.choices) {
|
|
53
|
-
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { ...look }), children: command.label }), _jsx(DropdownMenuContent, { align: "end", children: command.choices.map((choice) => (_jsx(MenuCommandRow, { command: choice }, choice.label))) })] }));
|
|
54
|
-
}
|
|
55
|
-
return (_jsx(Button, { ...look, onClick: command.onClick, type: "button", children: command.label }));
|
|
33
|
+
export function PageCommandButton({ command, ...appearance }) {
|
|
34
|
+
if ("choices" in command)
|
|
35
|
+
return _jsx(ChoicesCommandButton, { command: command, ...appearance });
|
|
36
|
+
return _jsx(PlainCommandButton, { command: command, ...appearance });
|
|
37
|
+
}
|
|
38
|
+
/** A primary whose job comes in a few kinds: its button opens a menu of them. */
|
|
39
|
+
function ChoicesCommandButton({ command, ...appearance }) {
|
|
40
|
+
const reasonId = useId();
|
|
41
|
+
return (_jsx(WithDisabledReason, { button: _jsx(ChoicesButton, { command: command, look: lookOf(command, reasonId, appearance) }), reason: command.disabledReason, reasonId: reasonId }));
|
|
42
|
+
}
|
|
43
|
+
/** The button itself; a tooltip's trigger renders it with its own props, which it passes on. */
|
|
44
|
+
function ChoicesButton({ command, look: ownLook, ...trigger }) {
|
|
45
|
+
const look = { ...trigger, ...ownLook };
|
|
46
|
+
const { arm, dialog } = useCommandRunner();
|
|
47
|
+
return (_jsxs(_Fragment, { children: [_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { ...look }), children: command.label }), _jsx(DropdownMenuContent, { align: "end", children: command.choices.map((choice) => (_jsx(MenuCommandRow, { command: arm(choice) }, choice.label))) })] }), dialog] }));
|
|
56
48
|
}
|
|
57
49
|
/** The row of a page's actions where it stands, for a page whose header is its own card. */
|
|
58
50
|
export function PageActionsRow({ period, primary, secondary, menu }) {
|
|
59
51
|
if (!period && !primary && !secondary && !menu)
|
|
60
52
|
return null;
|
|
61
|
-
return (_jsxs("div", { "data-slot": "page-actions", className: "flex max-w-full min-w-0 flex-wrap items-center gap-2", children: [period, secondary ? _jsx(PageCommandButton, { command: secondary, variant: "outline" }) : null, primary ? _jsx(PageCommandButton, { command: primary, variant: "default" }) : null, menu ? _jsx(ActionMenu, { ...menu }) : null] }));
|
|
53
|
+
return (_jsxs("div", { "data-slot": "page-actions", className: "flex max-w-full min-w-0 flex-wrap items-center gap-2", children: [period, secondary ? _jsx(PageCommandButton, { command: secondary, variant: "outline" }) : null, primary ? _jsx(PageCommandButton, { command: primary, variant: "default" }) : null, menu ? _jsx(ActionMenu, { ...menu, size: "page" }) : null] }));
|
|
62
54
|
}
|
|
63
55
|
const TWO_OWNERS = "Two PageActions are on the page at once. The title row has one owner, so the one that mounted last hides the commands of the other. Give the page one PageActions.";
|
|
64
56
|
function createHost(titled = true) {
|
|
@@ -113,10 +105,10 @@ export function PageActionsSlot() {
|
|
|
113
105
|
* `PageActionsHostProvider`, they render where they stand.
|
|
114
106
|
*
|
|
115
107
|
* @family Actions
|
|
116
|
-
* @when The actions of a collection, an object or an overview page, on the title's row at its trailing edge
|
|
117
|
-
* @instead A
|
|
118
|
-
* @behaviour
|
|
119
|
-
* @words
|
|
108
|
+
* @when The actions of a collection, an object or an overview page, on the title's row at its trailing edge; the page compositions draw it from their `actions`. A settings page (`SettingsPage`) has none: each section saves from its footer (nadicode decision).
|
|
109
|
+
* @instead A record's commands are its list's (`RecordList`) or its `RecordCommands`. A collection toolbar holds search and filters, never a page action, except on a list page that draws no title row, where `CollectionPage` ends the toolbar with the page's actions. A page whose parts each have commands gathers them in the one `PageActions` of the component that owns the page; a part never draws a second (nadicode decision).
|
|
110
|
+
* @behaviour Ours: an action sits on the title of the thing it acts on, never on a tab's, and a page's commands are the same on each of its sibling tabs, whatever its list shows or has chosen: only the viewer's permission removes one (nadicode decision). A command on chosen records is the list's own (`select.chosen`), and a record's is its row's (nadicode decision). One per page: a second `PageActions` on the page a person sees would hide the first's commands, so it throws in development and in tests, and in production the one that mounted last keeps the row; a page kept hidden for a quick return (an `Activity` with `mode="hidden"`) has given the row back (nadicode decision). It takes `period`, `secondary`, `primary` and `menu` and draws their order: the period, the outline secondary, the filled primary, then the three dots last; one filled button per page (nadicode decision). The page's three dots hold two commands or more, which the type requires; a single extra command is the secondary (owner, 2026-11-06). A primary whose job comes in a few kinds takes `choices`: its button opens a menu of them aligned to its end, each with its icon; a kind that needs its own fields opens its dialog from its row (nadicode decision). A destination outside the product ends in the arrow. A running command (`pending`) keeps its place and icon and says its pending word, and the type requires `pendingLabel` whenever `pending` is set; one that cannot run now stays, disabled, with `disabledReason` in its tooltip (nadicode decision). Deleting the page's own record is never here: it is the danger zone of the record's Settings, in a card. A reversible command on the record, such as Archive, may stand last in the page's three dots, after a divider, with its `confirm` or `undo` (nadicode decision). “Disable a button only when the action is impossible right now (missing input, insufficient permission); pair with a `Tooltip` that explains why.” (https://vercel.com/geist/button) “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)
|
|
111
|
+
* @words Ours: the primary is the page's main job as verb and noun: "Invite member", "New Agent"; its choices are the kinds, as nouns: "Folder", "Documents", "Web page"; the pending word is its -ing form: "Inviting member"; the menu names the page's record at its top (nadicode decision).
|
|
120
112
|
* @access DOM order is visual order. A command whose label does not name its target carries `accessibleName`. A running command is `aria-busy` and keeps focus. The three dots carry "More for {record}"; the menu returns focus to them when it closes.
|
|
121
113
|
*/
|
|
122
114
|
export function PageActions(props) {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { type ActionMenuProps, type MenuCommand, type MenuCommands } from "./action-menu.js";
|
|
3
|
+
import { type PageCommand } from "./page-actions.js";
|
|
4
|
+
import { type CommandRunner, type DrawnCommand } from "../internal/command-runner.js";
|
|
5
|
+
/** One command of a record. `main` marks the record's main job, which stands as a button first. */
|
|
6
|
+
export type RowCommand = MenuCommand & {
|
|
7
|
+
main?: true | undefined;
|
|
8
|
+
/** Opens outside the product: as a button, the arrow after its label. */
|
|
9
|
+
external?: boolean | undefined;
|
|
10
|
+
};
|
|
11
|
+
/** What a record's commands become: the buttons, in order, and the three dots' commands, two or more. */
|
|
12
|
+
export type RowCommandShape = {
|
|
13
|
+
buttons: readonly RowCommand[];
|
|
14
|
+
menu: MenuCommands | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The one decision for a record's commands (owner, 2026-11-06): none draws nothing; one is its
|
|
18
|
+
* button; two are two buttons, the main first; three or more are the main as a button (or none)
|
|
19
|
+
* and the rest in the three dots, which therefore always hold two or more.
|
|
20
|
+
*/
|
|
21
|
+
export declare function rowCommandShape(name: string, commands: readonly RowCommand[]): RowCommandShape;
|
|
22
|
+
/**
|
|
23
|
+
* A record's command as its outline button: its label alone, since its icon leads it only in the
|
|
24
|
+
* three dots, and a command that cannot run stays, disabled, with its reason in the tooltip.
|
|
25
|
+
*/
|
|
26
|
+
export declare function asRowButton(command: DrawnCommand<RowCommand>): PageCommand;
|
|
27
|
+
/**
|
|
28
|
+
* The row buttons, armed by the runner of the record that owns them, which draws their
|
|
29
|
+
* confirmation where it outlives the buttons, such as a list's row changing layout.
|
|
30
|
+
*/
|
|
31
|
+
export declare function RowCommandButtons({ commands, arm, }: {
|
|
32
|
+
commands: readonly RowCommand[];
|
|
33
|
+
arm: CommandRunner["arm"];
|
|
34
|
+
}): import("react").JSX.Element[];
|
|
35
|
+
export type RecordCommandsProps = {
|
|
36
|
+
/** The record's name: the three dots' first line, "pec@acme.it". */
|
|
37
|
+
record: string;
|
|
38
|
+
/** The three dots' name, from the catalogue: "More for pec@acme.it". */
|
|
39
|
+
moreLabel: string;
|
|
40
|
+
/** Everything the record can do now, in the product's order; a command it may never run is left out. */
|
|
41
|
+
commands: readonly RowCommand[];
|
|
42
|
+
} & Pick<ActionMenuProps, "open" | "onOpenChange" | "modal" | "side" | "finalFocus" | "triggerId">;
|
|
43
|
+
/**
|
|
44
|
+
* One record's commands outside a list: a message's hover bar, a member's card, an Agent's header.
|
|
45
|
+
*
|
|
46
|
+
* @family Actions
|
|
47
|
+
* @when Ours: the commands of one record that is not a row of a `RecordList`: Alveare's message hover bar and member card, Nadia's assignment card and an Agent's header (nadicode decision).
|
|
48
|
+
* @instead Ours: the records of a list give their commands to `RecordList`, which draws the same decision on every row; a page's own commands are its composition's `actions` (nadicode decision).
|
|
49
|
+
* @behaviour Ours: one record's commands drawn by the rule `RecordList` holds for its rows, which decides which stand as buttons, which go in the three dots and how a destructive one confirms; the buttons and the three dots are 32 px, aligned to the end (nadicode decision).
|
|
50
|
+
* @words “Keep right-column buttons Verb + Noun (`Remove Member`, `Resend Invite`). Bare verbs like `Remove` or `Confirm` lose context once the row scrolls offscreen.” (https://vercel.com/geist/entity)
|
|
51
|
+
* Ours: sentence case, "Cancel invite"; the three dots read "More for {record}" (nadicode decision).
|
|
52
|
+
* @access Ours: each button is named by its label, or its `accessibleName` where the label alone does not name the record; a reason is the button's description; the three dots carry `moreLabel` (nadicode decision).
|
|
53
|
+
*/
|
|
54
|
+
export declare function RecordCommands({ record, moreLabel, commands, ...menuProps }: RecordCommandsProps): import("react").JSX.Element | null;
|
|
55
|
+
export type RecordContextMenuProps = Pick<RecordCommandsProps, "record" | "moreLabel" | "commands"> & {
|
|
56
|
+
/** The record's card or row, which keeps its own element and opens the menu. */
|
|
57
|
+
children: ReactElement;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A record's right-click: every command its `RecordCommands` draws, in one menu.
|
|
61
|
+
*
|
|
62
|
+
* @family Actions
|
|
63
|
+
* @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)
|
|
64
|
+
* Ours: around a card that also draws `RecordCommands`, given the same commands (nadicode decision).
|
|
65
|
+
* @instead Ours: a `RecordList` row already opens the same menu on a right-click (nadicode decision).
|
|
66
|
+
* @behaviour Ours: every command, destructive last after a divider, a destructive one opening its confirmation; with none, the card keeps its element and the browser its own menu (nadicode decision).
|
|
67
|
+
* @words Ours: the same labels as the visible commands (nadicode decision).
|
|
68
|
+
* @access Ours: the menu is named by `moreLabel` (nadicode decision).
|
|
69
|
+
*/
|
|
70
|
+
export declare function RecordContextMenu({ record, moreLabel, commands, children, }: RecordContextMenuProps): import("react").JSX.Element;
|
|
71
|
+
//# sourceMappingURL=record-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-commands.d.ts","sourceRoot":"","sources":["../../src/components/record-commands.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAoB,MAAM,2BAA2B,CAAC;AAEpG,mGAAmG;AACnG,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,yGAAyG;AACzG,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;CAC3B,CAAC;AAOF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,UAAU,EAAE,GAAG,eAAe,CAe9F;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,GAAG,WAAW,CAkB1E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;IAChC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC3B,iCASA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;IAClB,wGAAwG;IACxG,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;CACjC,GAAG,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,CAAC,CAAC;AAEnG;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EAAE,mBAAmB,sCAahG;AAED,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,mBAAmB,EACnB,QAAQ,GAAG,WAAW,GAAG,UAAU,CACpC,GAAG;IACF,gFAAgF;IAChF,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,GACT,EAAE,sBAAsB,+BAMxB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ActionContextMenu, ActionMenu, refuseTooManyCommands, } from "./action-menu.js";
|
|
4
|
+
import { PageCommandButton } from "./page-actions.js";
|
|
5
|
+
import { useCommandRunner } from "../internal/command-runner.js";
|
|
6
|
+
function twoOrMore(commands) {
|
|
7
|
+
const [first, second, ...rest] = commands;
|
|
8
|
+
return first && second ? [first, second, ...rest] : null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The one decision for a record's commands (owner, 2026-11-06): none draws nothing; one is its
|
|
12
|
+
* button; two are two buttons, the main first; three or more are the main as a button (or none)
|
|
13
|
+
* and the rest in the three dots, which therefore always hold two or more.
|
|
14
|
+
*/
|
|
15
|
+
export function rowCommandShape(name, commands) {
|
|
16
|
+
refuseTooManyCommands(name, commands.length);
|
|
17
|
+
const mains = commands.filter((command) => command.main === true);
|
|
18
|
+
if (mains.length > 1 && typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
19
|
+
throw new Error(`${name} marks ${mains.length} commands as main; a record has one main job.`);
|
|
20
|
+
}
|
|
21
|
+
if (commands.length <= 2) {
|
|
22
|
+
const ordered = [...mains, ...commands.filter((command) => command.main !== true)];
|
|
23
|
+
return { buttons: ordered, menu: null };
|
|
24
|
+
}
|
|
25
|
+
const [main] = mains;
|
|
26
|
+
return {
|
|
27
|
+
buttons: main ? [main] : [],
|
|
28
|
+
menu: twoOrMore(commands.filter((command) => command !== main)),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A record's command as its outline button: its label alone, since its icon leads it only in the
|
|
33
|
+
* three dots, and a command that cannot run stays, disabled, with its reason in the tooltip.
|
|
34
|
+
*/
|
|
35
|
+
export function asRowButton(command) {
|
|
36
|
+
const reason = command.locked ? command.reason : command.disabledReason;
|
|
37
|
+
const action = command.link
|
|
38
|
+
? { link: command.link }
|
|
39
|
+
: command.render
|
|
40
|
+
? { render: command.render }
|
|
41
|
+
: { onClick: command.onClick };
|
|
42
|
+
const pendingWord = command.pending
|
|
43
|
+
? { pending: true, pendingLabel: command.pendingLabel ?? command.label }
|
|
44
|
+
: { pendingLabel: command.pendingLabel };
|
|
45
|
+
return {
|
|
46
|
+
...action,
|
|
47
|
+
...pendingWord,
|
|
48
|
+
label: command.label,
|
|
49
|
+
accessibleName: command.accessibleName,
|
|
50
|
+
external: command.external,
|
|
51
|
+
disabledReason: reason,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The row buttons, armed by the runner of the record that owns them, which draws their
|
|
56
|
+
* confirmation where it outlives the buttons, such as a list's row changing layout.
|
|
57
|
+
*/
|
|
58
|
+
export function RowCommandButtons({ commands, arm, }) {
|
|
59
|
+
return commands.map((command) => (_jsx(PageCommandButton, { command: asRowButton(arm(command)), size: "sm", variant: "outline" }, command.label)));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* One record's commands outside a list: a message's hover bar, a member's card, an Agent's header.
|
|
63
|
+
*
|
|
64
|
+
* @family Actions
|
|
65
|
+
* @when Ours: the commands of one record that is not a row of a `RecordList`: Alveare's message hover bar and member card, Nadia's assignment card and an Agent's header (nadicode decision).
|
|
66
|
+
* @instead Ours: the records of a list give their commands to `RecordList`, which draws the same decision on every row; a page's own commands are its composition's `actions` (nadicode decision).
|
|
67
|
+
* @behaviour Ours: one record's commands drawn by the rule `RecordList` holds for its rows, which decides which stand as buttons, which go in the three dots and how a destructive one confirms; the buttons and the three dots are 32 px, aligned to the end (nadicode decision).
|
|
68
|
+
* @words “Keep right-column buttons Verb + Noun (`Remove Member`, `Resend Invite`). Bare verbs like `Remove` or `Confirm` lose context once the row scrolls offscreen.” (https://vercel.com/geist/entity)
|
|
69
|
+
* Ours: sentence case, "Cancel invite"; the three dots read "More for {record}" (nadicode decision).
|
|
70
|
+
* @access Ours: each button is named by its label, or its `accessibleName` where the label alone does not name the record; a reason is the button's description; the three dots carry `moreLabel` (nadicode decision).
|
|
71
|
+
*/
|
|
72
|
+
export function RecordCommands({ record, moreLabel, commands, ...menuProps }) {
|
|
73
|
+
const { arm, dialog } = useCommandRunner();
|
|
74
|
+
const { buttons, menu } = rowCommandShape(`RecordCommands "${record}"`, commands);
|
|
75
|
+
if (buttons.length === 0 && !menu)
|
|
76
|
+
return null;
|
|
77
|
+
return (_jsxs("div", { className: "flex items-center justify-end gap-2", "data-slot": "record-commands", children: [_jsx(RowCommandButtons, { arm: arm, commands: buttons }), dialog, menu ? (_jsx(ActionMenu, { ...menuProps, commands: menu, label: moreLabel, record: record, size: "row" })) : null] }));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A record's right-click: every command its `RecordCommands` draws, in one menu.
|
|
81
|
+
*
|
|
82
|
+
* @family Actions
|
|
83
|
+
* @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)
|
|
84
|
+
* Ours: around a card that also draws `RecordCommands`, given the same commands (nadicode decision).
|
|
85
|
+
* @instead Ours: a `RecordList` row already opens the same menu on a right-click (nadicode decision).
|
|
86
|
+
* @behaviour Ours: every command, destructive last after a divider, a destructive one opening its confirmation; with none, the card keeps its element and the browser its own menu (nadicode decision).
|
|
87
|
+
* @words Ours: the same labels as the visible commands (nadicode decision).
|
|
88
|
+
* @access Ours: the menu is named by `moreLabel` (nadicode decision).
|
|
89
|
+
*/
|
|
90
|
+
export function RecordContextMenu({ record, moreLabel, commands, children, }) {
|
|
91
|
+
return (_jsx(ActionContextMenu, { commands: commands, label: moreLabel, record: record, children: children }));
|
|
92
|
+
}
|