@nadicodeai/ui 12.1.198 → 12.1.200
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/agent-card.d.ts +54 -22
- package/dist/components/agent-card.d.ts.map +1 -1
- package/dist/components/agent-card.js +47 -20
- package/dist/components/agent-orb.d.ts +2 -2
- package/dist/components/agent-orb.js +2 -2
- package/dist/components/document-tabs.d.ts +46 -0
- package/dist/components/document-tabs.d.ts.map +1 -0
- package/dist/components/document-tabs.js +54 -0
- package/dist/components/drawer-steps.d.ts +31 -0
- package/dist/components/drawer-steps.d.ts.map +1 -0
- package/dist/components/drawer-steps.js +27 -0
- package/dist/components/file-tree.d.ts +42 -0
- package/dist/components/file-tree.d.ts.map +1 -0
- package/dist/components/file-tree.js +93 -0
- package/dist/components/file-type-icon.d.ts +6 -3
- package/dist/components/file-type-icon.d.ts.map +1 -1
- package/dist/components/file-type-icon.js +79 -5
- package/dist/components/form-drawer.d.ts +11 -6
- package/dist/components/form-drawer.d.ts.map +1 -1
- package/dist/components/form-drawer.js +2 -2
- package/dist/components/library-shelf.d.ts +8 -3
- package/dist/components/library-shelf.d.ts.map +1 -1
- package/dist/components/library-shelf.js +14 -6
- package/dist/components/object-workspace.d.ts.map +1 -1
- package/dist/components/object-workspace.js +3 -1
- package/dist/internal/form-drawer-frame.d.ts +2 -0
- package/dist/internal/form-drawer-frame.d.ts.map +1 -1
- package/dist/internal/form-drawer-frame.js +3 -1
- package/dist/showcase/specimens/compositions.d.ts +2 -0
- package/dist/showcase/specimens/compositions.d.ts.map +1 -1
- package/dist/showcase/specimens/compositions.js +20 -1
- package/dist/showcase/specimens/data.d.ts +1 -0
- package/dist/showcase/specimens/data.d.ts.map +1 -1
- package/dist/showcase/specimens/data.js +4 -3
- package/dist/showcase/specimens/index.d.ts +4 -0
- package/dist/showcase/specimens/index.d.ts.map +1 -1
- package/dist/showcase/specimens/navigation.d.ts +2 -0
- package/dist/showcase/specimens/navigation.d.ts.map +1 -1
- package/dist/showcase/specimens/navigation.js +52 -0
- 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 +56 -12
- package/package.json +4 -2
|
@@ -1,38 +1,70 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import { Card } from "./card.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/** What a pressable card's top corner glows with on hover: an app's logo or her orb's colour. */
|
|
4
|
+
export type AgentCardGlow = {
|
|
5
|
+
image: string;
|
|
6
|
+
} | {
|
|
7
|
+
color: string;
|
|
8
|
+
};
|
|
9
|
+
type AgentCardContent = {
|
|
5
10
|
job: ReactNode;
|
|
6
11
|
meta?: ReactNode;
|
|
7
12
|
name: ReactNode;
|
|
8
13
|
status?: ReactNode;
|
|
9
|
-
/** The object's picture: an Agent's orb,
|
|
14
|
+
/** The object's picture: an Agent's orb, at 64 on a card and at 40 in a row. */
|
|
10
15
|
visual?: ReactNode;
|
|
11
16
|
};
|
|
17
|
+
export type AgentCardProps = AgentCardContent & Omit<React.ComponentProps<typeof Card>, "children" | "onClick" | "render"> & ({
|
|
18
|
+
action?: ReactNode;
|
|
19
|
+
glow?: never;
|
|
20
|
+
onOpen?: never;
|
|
21
|
+
}
|
|
22
|
+
/** The whole card is the one target, so it holds no control of its own. */
|
|
23
|
+
| {
|
|
24
|
+
action?: never;
|
|
25
|
+
glow?: AgentCardGlow;
|
|
26
|
+
onOpen: () => void;
|
|
27
|
+
});
|
|
12
28
|
/**
|
|
13
|
-
* One Agent, or another pictured object, as a card in a gallery
|
|
14
|
-
* Templates gallery draws a template.
|
|
29
|
+
* One Agent, or another pictured object, as a card in a gallery.
|
|
15
30
|
*
|
|
16
31
|
* @family Data
|
|
17
32
|
* @when A gallery of Agents or templates where each one is chosen by its picture and its job: the
|
|
18
33
|
* Agents to create from, the templates of a hub. An Agent shown as an object is this one card
|
|
19
34
|
* shape wherever it appears, in the Portal's Library and in Nadia's gallery alike.
|
|
20
|
-
* @instead
|
|
21
|
-
* `
|
|
22
|
-
* collection (`CollectionPage`).
|
|
23
|
-
* @behaviour Vercel's
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
35
|
+
* @instead The same gallery read as a list is `AgentRow`. A list of Agents to open is
|
|
36
|
+
* `AgentListRow`. An Agent's own page opens with `AgentProfileCard`, where the name is the page
|
|
37
|
+
* heading. A Library skill or plugin is a row of its collection (`CollectionPage`).
|
|
38
|
+
* @behaviour As Vercel's Connect cards: every card has the same slots, so what one holds never moves
|
|
39
|
+
* another's. The picture stands top left, her orb at 64 with its empty edge outside the card's
|
|
40
|
+
* padding, and the status (her apps) top right; at the card's foot her name on one line, her job in
|
|
41
|
+
* a slot of two lines cut after the second, and the meta, with the one action at its end. With
|
|
42
|
+
* `onOpen` the whole card is one button and holds no action; on hover its ground lifts and, with
|
|
43
|
+
* `glow`, the corner behind the status fades up in a blurred 112 px of that logo or colour over
|
|
44
|
+
* 500 ms. A text object, with no picture, keeps the same foot.
|
|
30
45
|
* @words The name as the Agent calls herself; the job in one line (*Writes quotes from the price
|
|
31
|
-
* list*); the meta as short facts joined by a middle dot (*6 skills ·
|
|
32
|
-
* and noun (*
|
|
33
|
-
* @access
|
|
34
|
-
* real button or link.
|
|
46
|
+
* list*); the meta as short facts joined by a middle dot (*6 skills · 2 tasks*); the action verb
|
|
47
|
+
* and noun (*Start*).
|
|
48
|
+
* @access With `onOpen` the name, the job and the meta name the button, in that order, and the
|
|
49
|
+
* status and the orb stay out of its name; the glow is hidden; an action is a real button or link.
|
|
50
|
+
*/
|
|
51
|
+
declare function AgentCard({ action, className, glow, job, meta, name, onOpen, status, visual, ...props }: AgentCardProps): import("react").JSX.Element;
|
|
52
|
+
export type AgentRowProps = AgentCardContent & {
|
|
53
|
+
onOpen: () => void;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* One Agent of a gallery as a row: the same object as `AgentCard`, read as a list.
|
|
57
|
+
*
|
|
58
|
+
* @family Data
|
|
59
|
+
* @when A shelf's rows view, inside `LibraryShelf` with `view="rows"`: the Portal's Agent templates.
|
|
60
|
+
* @instead The gallery's default is `AgentCard`. A list of Agents to open as records is a
|
|
61
|
+
* `RecordList` row; Nadia's sidebar is `AgentListRow`.
|
|
62
|
+
* @behaviour The whole row is one button, 64 px high at every width: her orb at 40, her name over her
|
|
63
|
+
* job, each on one line, the status and the meta in columns of 128 px that line up down the shelf,
|
|
64
|
+
* then a chevron. Below `md` the columns go, and the card or the surface it opens holds them.
|
|
65
|
+
* @words As `AgentCard`.
|
|
66
|
+
* @access The row's text names the button; the orb and the chevron are decorative.
|
|
35
67
|
*/
|
|
36
|
-
declare function
|
|
37
|
-
export { AgentCard,
|
|
68
|
+
declare function AgentRow({ job, meta, name, onOpen, status, visual }: AgentRowProps): import("react").JSX.Element;
|
|
69
|
+
export { AgentCard, AgentRow };
|
|
38
70
|
//# sourceMappingURL=agent-card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-card.d.ts","sourceRoot":"","sources":["../../src/components/agent-card.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-card.d.ts","sourceRoot":"","sources":["../../src/components/agent-card.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAS,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,iGAAiG;AACjG,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,KAAK,gBAAgB,GAAG;IACtB,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gFAAgF;IAChF,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAC3C,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC,GAC1E,CACI;IAAE,MAAM,CAAC,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE;AACtD,2EAA2E;GACzE;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAC/D,CAAC;AAwBJ;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,SAAS,CAAC,EACjB,MAAM,EACN,SAAS,EACT,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,MAAM,EACN,MAAM,EACN,GAAG,KAAK,EACT,EAAE,cAAc,+BAsEhB;AAED,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,iBAAS,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,aAAa,+BAsB3E;AAED,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,38 +1,65 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { ChevronRight } from "lucide-react";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Card } from "./card.js";
|
|
3
5
|
import { cn } from "../lib/utils.js";
|
|
4
6
|
function hasSlotContent(value) {
|
|
5
7
|
return value !== null && value !== undefined && value !== false;
|
|
6
8
|
}
|
|
9
|
+
const PRESSABLE = "cursor-pointer text-left outline-ring transition-colors duration-150 hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2";
|
|
10
|
+
function CornerGlow({ glow }) {
|
|
11
|
+
return (_jsx("span", { "aria-hidden": "true", className: "pointer-events-none absolute -top-6 -right-6 size-28 rounded-full bg-contain bg-center bg-no-repeat opacity-0 blur-[40px] saturate-150 transition-opacity duration-500 group-hover/card:opacity-70 group-focus-visible/card:opacity-70", "data-slot": "agent-card-glow", style: "image" in glow
|
|
12
|
+
? { backgroundImage: `url("${glow.image}")` }
|
|
13
|
+
: { backgroundColor: glow.color } }));
|
|
14
|
+
}
|
|
7
15
|
/**
|
|
8
|
-
* One Agent, or another pictured object, as a card in a gallery
|
|
9
|
-
* Templates gallery draws a template.
|
|
16
|
+
* One Agent, or another pictured object, as a card in a gallery.
|
|
10
17
|
*
|
|
11
18
|
* @family Data
|
|
12
19
|
* @when A gallery of Agents or templates where each one is chosen by its picture and its job: the
|
|
13
20
|
* Agents to create from, the templates of a hub. An Agent shown as an object is this one card
|
|
14
21
|
* shape wherever it appears, in the Portal's Library and in Nadia's gallery alike.
|
|
15
|
-
* @instead
|
|
16
|
-
* `
|
|
17
|
-
* collection (`CollectionPage`).
|
|
18
|
-
* @behaviour Vercel's
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* @instead The same gallery read as a list is `AgentRow`. A list of Agents to open is
|
|
23
|
+
* `AgentListRow`. An Agent's own page opens with `AgentProfileCard`, where the name is the page
|
|
24
|
+
* heading. A Library skill or plugin is a row of its collection (`CollectionPage`).
|
|
25
|
+
* @behaviour As Vercel's Connect cards: every card has the same slots, so what one holds never moves
|
|
26
|
+
* another's. The picture stands top left, her orb at 64 with its empty edge outside the card's
|
|
27
|
+
* padding, and the status (her apps) top right; at the card's foot her name on one line, her job in
|
|
28
|
+
* a slot of two lines cut after the second, and the meta, with the one action at its end. With
|
|
29
|
+
* `onOpen` the whole card is one button and holds no action; on hover its ground lifts and, with
|
|
30
|
+
* `glow`, the corner behind the status fades up in a blurred 112 px of that logo or colour over
|
|
31
|
+
* 500 ms. A text object, with no picture, keeps the same foot.
|
|
25
32
|
* @words The name as the Agent calls herself; the job in one line (*Writes quotes from the price
|
|
26
|
-
* list*); the meta as short facts joined by a middle dot (*6 skills ·
|
|
27
|
-
* and noun (*
|
|
28
|
-
* @access
|
|
29
|
-
* real button or link.
|
|
33
|
+
* list*); the meta as short facts joined by a middle dot (*6 skills · 2 tasks*); the action verb
|
|
34
|
+
* and noun (*Start*).
|
|
35
|
+
* @access With `onOpen` the name, the job and the meta name the button, in that order, and the
|
|
36
|
+
* status and the orb stay out of its name; the glow is hidden; an action is a real button or link.
|
|
30
37
|
*/
|
|
31
|
-
function AgentCard({ action, className, job, meta, name, status, visual, ...props }) {
|
|
38
|
+
function AgentCard({ action, className, glow, job, meta, name, onOpen, status, visual, ...props }) {
|
|
32
39
|
const hasStatus = hasSlotContent(status);
|
|
33
40
|
const hasMeta = hasSlotContent(meta);
|
|
34
41
|
const hasAction = hasSlotContent(action);
|
|
35
42
|
const hasVisual = hasSlotContent(visual);
|
|
36
|
-
|
|
43
|
+
const id = useId();
|
|
44
|
+
const words = hasMeta ? `${id}-name ${id}-job ${id}-meta` : `${id}-name ${id}-job`;
|
|
45
|
+
return (_jsxs(Card, { className: cn("relative h-full min-h-48 min-w-0 gap-0 p-4", onOpen && PRESSABLE, className), ...(onOpen
|
|
46
|
+
? { render: _jsx("button", { "aria-labelledby": words, onClick: onOpen, type: "button" }) }
|
|
47
|
+
: {}), ...props, children: [glow ? _jsx(CornerGlow, { glow: glow }) : null, hasVisual || hasStatus ? (_jsxs("span", { className: "relative flex min-h-12 w-full shrink-0 items-start justify-between gap-3", children: [hasVisual ? (_jsx("span", { className: "-mt-2 -ml-2 shrink-0", "data-slot": "agent-card-visual", children: visual })) : (_jsx("span", {})), hasStatus ? (_jsx("span", { className: "flex min-w-0 flex-wrap items-center justify-end gap-nadicode-xxs", "data-slot": "agent-card-status", children: status })) : null] })) : null, _jsxs("span", { className: "relative mt-auto grid w-full min-w-0 gap-1 pt-nadicode-md", children: [_jsx("span", { className: "truncate text-heading-xs text-foreground", "data-slot": "agent-card-name", id: `${id}-name`, children: name }), _jsx("span", { className: "line-clamp-2 h-10 text-sm text-muted-foreground", "data-slot": "agent-card-job", id: `${id}-job`, children: job }), hasMeta || hasAction ? (_jsxs("span", { className: "flex min-h-5 min-w-0 items-center justify-between gap-3 pt-1", children: [_jsx("span", { className: "min-w-0 truncate text-xs text-muted-foreground", "data-slot": "agent-card-meta", id: `${id}-meta`, children: hasMeta ? meta : null }), hasAction ? (_jsx("span", { className: "shrink-0", "data-slot": "agent-card-action", children: action })) : null] })) : null] })] }));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* One Agent of a gallery as a row: the same object as `AgentCard`, read as a list.
|
|
51
|
+
*
|
|
52
|
+
* @family Data
|
|
53
|
+
* @when A shelf's rows view, inside `LibraryShelf` with `view="rows"`: the Portal's Agent templates.
|
|
54
|
+
* @instead The gallery's default is `AgentCard`. A list of Agents to open as records is a
|
|
55
|
+
* `RecordList` row; Nadia's sidebar is `AgentListRow`.
|
|
56
|
+
* @behaviour The whole row is one button, 64 px high at every width: her orb at 40, her name over her
|
|
57
|
+
* job, each on one line, the status and the meta in columns of 128 px that line up down the shelf,
|
|
58
|
+
* then a chevron. Below `md` the columns go, and the card or the surface it opens holds them.
|
|
59
|
+
* @words As `AgentCard`.
|
|
60
|
+
* @access The row's text names the button; the orb and the chevron are decorative.
|
|
61
|
+
*/
|
|
62
|
+
function AgentRow({ job, meta, name, onOpen, status, visual }) {
|
|
63
|
+
return (_jsxs("button", { className: cn("grid h-16 w-full grid-cols-[2.5rem_minmax(0,1fr)_1rem] items-center gap-4 px-4 md:grid-cols-[2.5rem_minmax(0,1fr)_8rem_8rem_1rem]", PRESSABLE, "focus-visible:-outline-offset-2"), "data-slot": "agent-row", onClick: onOpen, type: "button", children: [_jsx("span", { className: "size-10", children: visual }), _jsxs("span", { className: "grid min-w-0 gap-0.5", children: [_jsx("span", { className: "truncate text-sm font-semibold text-foreground", children: name }), _jsx("span", { className: "truncate text-sm text-muted-foreground", children: job })] }), _jsx("span", { className: "hidden min-w-0 md:block", children: status }), _jsx("span", { className: "hidden truncate text-sm text-muted-foreground md:block", children: meta }), _jsx(ChevronRight, { "aria-hidden": "true", className: "size-4 text-muted-foreground" })] }));
|
|
37
64
|
}
|
|
38
|
-
export { AgentCard };
|
|
65
|
+
export { AgentCard, AgentRow };
|
|
@@ -33,8 +33,8 @@ export type AgentOrbProps = AgentOrbBaseProps & ({
|
|
|
33
33
|
* An Agent, anywhere: her orb, the only thing that moves on its own.
|
|
34
34
|
*
|
|
35
35
|
* @family Status
|
|
36
|
-
* @when An Agent, anywhere: 20 in the sidebar, 32 in a row,
|
|
37
|
-
* card, 160 on entry. There is no other Agent picture. The sizes are 20, 24, 32, 40, 64, 96 and
|
|
36
|
+
* @when An Agent, anywhere: 20 in the sidebar, 32 in a row, 40 in a gallery's row, 64 on her Profile
|
|
37
|
+
* card and an Agent card, 160 on entry. There is no other Agent picture. The sizes are 20, 24, 32, 40, 64, 96 and
|
|
38
38
|
* 160 px, and no other. Detail follows the size the orb is drawn at: up to 32 px it draws the
|
|
39
39
|
* engine's lightest dot profile, at 40 px the middle one and from 64 px the full one, since a small
|
|
40
40
|
* orb cannot show the full profile's dots apart. On a photograph the orb takes the stronger `presence="over-picture"`
|
|
@@ -7,8 +7,8 @@ import { cn } from "../lib/utils.js";
|
|
|
7
7
|
* An Agent, anywhere: her orb, the only thing that moves on its own.
|
|
8
8
|
*
|
|
9
9
|
* @family Status
|
|
10
|
-
* @when An Agent, anywhere: 20 in the sidebar, 32 in a row,
|
|
11
|
-
* card, 160 on entry. There is no other Agent picture. The sizes are 20, 24, 32, 40, 64, 96 and
|
|
10
|
+
* @when An Agent, anywhere: 20 in the sidebar, 32 in a row, 40 in a gallery's row, 64 on her Profile
|
|
11
|
+
* card and an Agent card, 160 on entry. There is no other Agent picture. The sizes are 20, 24, 32, 40, 64, 96 and
|
|
12
12
|
* 160 px, and no other. Detail follows the size the orb is drawn at: up to 32 px it draws the
|
|
13
13
|
* engine's lightest dot profile, at 40 px the middle one and from 64 px the full one, since a small
|
|
14
14
|
* orb cannot show the full profile's dots apart. On a photograph the orb takes the stronger `presence="over-picture"`
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface DocumentTab {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon: React.ReactNode;
|
|
6
|
+
/** A longer name shown on hover: the file's path or the page's address. */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** The ×'s hover title, in the product's words: "Close Notes.md". */
|
|
9
|
+
closeLabel: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DocumentTabsProps {
|
|
12
|
+
tabs: readonly DocumentTab[];
|
|
13
|
+
value: string;
|
|
14
|
+
onValueChange: (value: string) => void;
|
|
15
|
+
onClose: (value: string) => void;
|
|
16
|
+
/** Builds the ids that tie each tab to the panel the page draws for it. */
|
|
17
|
+
idBase: string;
|
|
18
|
+
"aria-label": string;
|
|
19
|
+
/** Controls after the tabs, such as the button that opens a new one. */
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/** The id of a tab and of the panel it shows, for a page that draws its panels itself. */
|
|
24
|
+
declare function documentTabIds(idBase: string, value: string): {
|
|
25
|
+
tab: string;
|
|
26
|
+
panel: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Open documents side by side, as a browser's tabs: each a name with its icon and a close button, one of them shown.
|
|
30
|
+
*
|
|
31
|
+
* @family Navigation
|
|
32
|
+
* @when The things a person opened and switches between beside their work, each one closable: the files and web pages
|
|
33
|
+
* of Nadia's side panel. The set changes as they open and close things.
|
|
34
|
+
* @instead A fixed set of sibling views of one object is `Tabs`; a list of records to open is `ItemGroup`.
|
|
35
|
+
* @behaviour One tab stop: the arrow keys move between tabs, Home and End go to the first and the last, and moving
|
|
36
|
+
* selects. Delete or Backspace closes the focused tab and moves the focus to the tab shown next. A click on a tab's ×,
|
|
37
|
+
* which shows `closeLabel` on hover, closes that tab only and does not select it; the × is the pointer's, never a tab stop. Each tab is as wide as its name, from 7rem to 14rem, ending in an
|
|
38
|
+
* ellipsis; a row wider than its space scrolls sideways without a bar, and the tab shown scrolls into view. The tab
|
|
39
|
+
* shown takes the `accent` fill and ink text; the others are muted text that takes a lighter accent on hover.
|
|
40
|
+
* @words Each tab is the document's own name, a file's or a page's title. `closeLabel` is "Close <name>".
|
|
41
|
+
* @access A `tablist` named by `aria-label` of `tab`s, each declaring Delete in `aria-keyshortcuts` and an `aria-controls` naming the panel the page draws with
|
|
42
|
+
* `documentTabIds(idBase, value).panel`, which the panel takes as its id beside `aria-labelledby` set to `.tab`.
|
|
43
|
+
*/
|
|
44
|
+
declare function DocumentTabs({ tabs, value, onValueChange, onClose, idBase, children, className, ...props }: DocumentTabsProps): React.JSX.Element;
|
|
45
|
+
export { DocumentTabs, documentTabIds };
|
|
46
|
+
//# sourceMappingURL=document-tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-tabs.d.ts","sourceRoot":"","sources":["../../src/components/document-tabs.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,0FAA0F;AAC1F,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;EAEpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,YAAY,CAAC,EACpB,IAAI,EACJ,KAAK,EACL,aAAa,EACb,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,iBAAiB,qBA2EnB;AAED,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
|
|
4
|
+
import { XIcon } from "lucide-react";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
const idPart = (value) => encodeURIComponent(value).replaceAll("%", "_");
|
|
8
|
+
/** The id of a tab and of the panel it shows, for a page that draws its panels itself. */
|
|
9
|
+
function documentTabIds(idBase, value) {
|
|
10
|
+
return { tab: `${idBase}-tab-${idPart(value)}`, panel: `${idBase}-panel-${idPart(value)}` };
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Open documents side by side, as a browser's tabs: each a name with its icon and a close button, one of them shown.
|
|
14
|
+
*
|
|
15
|
+
* @family Navigation
|
|
16
|
+
* @when The things a person opened and switches between beside their work, each one closable: the files and web pages
|
|
17
|
+
* of Nadia's side panel. The set changes as they open and close things.
|
|
18
|
+
* @instead A fixed set of sibling views of one object is `Tabs`; a list of records to open is `ItemGroup`.
|
|
19
|
+
* @behaviour One tab stop: the arrow keys move between tabs, Home and End go to the first and the last, and moving
|
|
20
|
+
* selects. Delete or Backspace closes the focused tab and moves the focus to the tab shown next. A click on a tab's ×,
|
|
21
|
+
* which shows `closeLabel` on hover, closes that tab only and does not select it; the × is the pointer's, never a tab stop. Each tab is as wide as its name, from 7rem to 14rem, ending in an
|
|
22
|
+
* ellipsis; a row wider than its space scrolls sideways without a bar, and the tab shown scrolls into view. The tab
|
|
23
|
+
* shown takes the `accent` fill and ink text; the others are muted text that takes a lighter accent on hover.
|
|
24
|
+
* @words Each tab is the document's own name, a file's or a page's title. `closeLabel` is "Close <name>".
|
|
25
|
+
* @access A `tablist` named by `aria-label` of `tab`s, each declaring Delete in `aria-keyshortcuts` and an `aria-controls` naming the panel the page draws with
|
|
26
|
+
* `documentTabIds(idBase, value).panel`, which the panel takes as its id beside `aria-labelledby` set to `.tab`.
|
|
27
|
+
*/
|
|
28
|
+
function DocumentTabs({ tabs, value, onValueChange, onClose, idBase, children, className, ...props }) {
|
|
29
|
+
const list = React.useRef(null);
|
|
30
|
+
const focusShown = React.useRef(false);
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
const shown = list.current?.querySelector(`#${CSS.escape(documentTabIds(idBase, value).tab)}`);
|
|
33
|
+
shown?.scrollIntoView?.({ block: "nearest", inline: "nearest" });
|
|
34
|
+
if (focusShown.current) {
|
|
35
|
+
focusShown.current = false;
|
|
36
|
+
shown?.focus();
|
|
37
|
+
}
|
|
38
|
+
}, [idBase, value]);
|
|
39
|
+
const closeByKey = (event, tab) => {
|
|
40
|
+
if (event.key === "Delete" || event.key === "Backspace") {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
focusShown.current = true;
|
|
43
|
+
onClose(tab.value);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return (_jsxs(TabsPrimitive.Root, { className: cn("flex min-w-0 items-center gap-1", className), "data-slot": "document-tabs", onValueChange: (next) => onValueChange(String(next)), value: value, children: [_jsx(TabsPrimitive.List, { activateOnFocus: true, "aria-label": props["aria-label"], className: "flex min-w-0 items-center gap-0.5 overflow-x-auto scrollbar-none", ref: list, children: tabs.map((tab) => {
|
|
47
|
+
const ids = documentTabIds(idBase, tab.value);
|
|
48
|
+
return (_jsxs(TabsPrimitive.Tab, { "aria-controls": ids.panel, "aria-keyshortcuts": "Delete", className: cn("group/document-tab nc-transition-paint flex h-7 max-w-56 min-w-28 shrink items-center gap-1.5 rounded-md ps-2 pe-1 text-sm text-muted-foreground hover:bg-accent/60 data-active:bg-accent data-active:text-foreground [&_svg]:size-4 [&_svg]:shrink-0"), id: ids.tab, onKeyDown: (event) => closeByKey(event, tab), title: tab.title, value: tab.value, children: [tab.icon, _jsx("span", { className: "min-w-0 flex-1 truncate text-start", children: tab.label }), _jsx("span", { "aria-hidden": "true", className: "nc-transition-paint grid size-5 shrink-0 place-items-center rounded-sm hover:bg-accent [&_svg]:size-3.5", "data-slot": "document-tab-close", onClick: (event) => {
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
onClose(tab.value);
|
|
51
|
+
}, title: tab.closeLabel, children: _jsx(XIcon, {}) })] }, tab.value));
|
|
52
|
+
}) }), children] }));
|
|
53
|
+
}
|
|
54
|
+
export { DocumentTabs, documentTabIds };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
export type DrawerStep = {
|
|
3
|
+
id: string;
|
|
4
|
+
/** The step's name; for what was already chosen, the thing's own name. */
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
state: "chosen" | "current";
|
|
7
|
+
/** What was chosen stands with this in place of a number, such as an Agent's orb. */
|
|
8
|
+
mark?: ReactNode;
|
|
9
|
+
/** A `DrawerStepBody` and a `DrawerStepFooter`, with the step's form around them if it has one. */
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A job in a drawer as a stack of cards, one per step, every step in sight from the start.
|
|
14
|
+
*
|
|
15
|
+
* @family Compositions
|
|
16
|
+
* @when Inside a `FormDrawer` with `job="stack"`: a job a person starts from a card and finishes in the drawer, as Vercel's Add Connection: what they chose, then the steps that remain.
|
|
17
|
+
* @instead Steps a person follows on a page are `NumberedSteps`; a setup whose steps replace each other around a wait is `FormDrawer` with `job="steps"`.
|
|
18
|
+
* @behaviour One card per step, 16 px apart. Each card's first row is 20 px of mark and its title, 24 px in from its sides. What was chosen stands first with its own mark, and what the person should know about it under that; the current step has its number in ink, its content and its actions in a band under it. The orb may overhang its 20 px, since its drawn edge is inside its box.
|
|
19
|
+
* @words A step's title is one or two words: *Review*, *Configure*.
|
|
20
|
+
* @access An ordered list; the current step carries `aria-current="step"`; the drawn numbers are hidden, since the list reads the position.
|
|
21
|
+
*/
|
|
22
|
+
export declare function DrawerSteps({ steps }: {
|
|
23
|
+
steps: readonly DrawerStep[];
|
|
24
|
+
}): import("react").JSX.Element;
|
|
25
|
+
/** What the current step holds, under its row. */
|
|
26
|
+
export declare function DrawerStepBody({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
27
|
+
/** The band under the current step, its primary at the end. */
|
|
28
|
+
export declare function DrawerStepFooter({ children }: {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
//# sourceMappingURL=drawer-steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-steps.d.ts","sourceRoot":"","sources":["../../src/components/drawer-steps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvD,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,qFAAqF;IACrF,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,mGAAmG;IACnG,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAaF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;CAAE,+BAoBtE;AAED,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,+BAQ5E;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAMrE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardFooter } from "./card.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
function StepNumber({ index }) {
|
|
5
|
+
return (_jsx("span", { "aria-hidden": "true", className: "flex size-5 items-center justify-center rounded-full bg-foreground text-xs font-medium tabular-nums text-background", children: index + 1 }));
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A job in a drawer as a stack of cards, one per step, every step in sight from the start.
|
|
9
|
+
*
|
|
10
|
+
* @family Compositions
|
|
11
|
+
* @when Inside a `FormDrawer` with `job="stack"`: a job a person starts from a card and finishes in the drawer, as Vercel's Add Connection: what they chose, then the steps that remain.
|
|
12
|
+
* @instead Steps a person follows on a page are `NumberedSteps`; a setup whose steps replace each other around a wait is `FormDrawer` with `job="steps"`.
|
|
13
|
+
* @behaviour One card per step, 16 px apart. Each card's first row is 20 px of mark and its title, 24 px in from its sides. What was chosen stands first with its own mark, and what the person should know about it under that; the current step has its number in ink, its content and its actions in a band under it. The orb may overhang its 20 px, since its drawn edge is inside its box.
|
|
14
|
+
* @words A step's title is one or two words: *Review*, *Configure*.
|
|
15
|
+
* @access An ordered list; the current step carries `aria-current="step"`; the drawn numbers are hidden, since the list reads the position.
|
|
16
|
+
*/
|
|
17
|
+
export function DrawerSteps({ steps }) {
|
|
18
|
+
return (_jsx("ol", { className: "grid grid-cols-[minmax(0,1fr)] gap-4", "data-slot": "drawer-steps", children: steps.map((step, index) => (_jsx("li", { "aria-current": step.state === "current" ? "step" : undefined, children: _jsxs(Card, { className: "gap-0 py-0", "data-state": step.state, children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3 px-6 py-5", children: [_jsx("span", { className: "flex size-5 shrink-0 items-center justify-center", children: step.mark ?? _jsx(StepNumber, { index: index }) }), _jsx("span", { className: "min-w-0 text-heading-xs wrap-break-word text-foreground", children: step.title })] }), step.children] }) }, step.id))) }));
|
|
19
|
+
}
|
|
20
|
+
/** What the current step holds, under its row. */
|
|
21
|
+
export function DrawerStepBody({ className, ...props }) {
|
|
22
|
+
return (_jsx("div", { className: cn("grid min-w-0 gap-5 px-6 pb-6", className), "data-slot": "drawer-step-body", ...props }));
|
|
23
|
+
}
|
|
24
|
+
/** The band under the current step, its primary at the end. */
|
|
25
|
+
export function DrawerStepFooter({ children }) {
|
|
26
|
+
return (_jsx(CardFooter, { className: "justify-end px-6", "data-slot": "drawer-step-footer", children: children }));
|
|
27
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface FileTreeEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
path: string;
|
|
5
|
+
isFolder: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface FileTreeProps {
|
|
8
|
+
/** The folder the tree shows the inside of; it is not drawn as a row. */
|
|
9
|
+
root: FileTreeEntry;
|
|
10
|
+
/** Reads one folder's entries, in the order to show them. */
|
|
11
|
+
readFolder: (path: string) => Promise<FileTreeEntry[]>;
|
|
12
|
+
/** The paths of the folders open in the tree. */
|
|
13
|
+
expanded: readonly string[];
|
|
14
|
+
onExpandedChange: (expanded: string[]) => void;
|
|
15
|
+
/** The file shown elsewhere, marked in the tree. */
|
|
16
|
+
selected?: null | string;
|
|
17
|
+
onOpenFile: (entry: FileTreeEntry) => void;
|
|
18
|
+
/** Called when a folder cannot be read; the folder keeps what it last listed. */
|
|
19
|
+
onReadError?: (error: unknown, path: string) => void;
|
|
20
|
+
/** Changes whenever the folder may have changed on disk; each open folder is read again. */
|
|
21
|
+
changed?: number;
|
|
22
|
+
"aria-label": string;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A folder and everything in it, as a tree of folders that open in place, each file with its kind's coloured icon.
|
|
27
|
+
*
|
|
28
|
+
* @family Navigation
|
|
29
|
+
* @when The files a person browses beside the thing they work on: an Agent's folder in Nadia's side panel. It is ReUI's
|
|
30
|
+
* file-explorer tree (`@reui/c-tree-5`) on Headless Tree, which reads each folder only when it opens.
|
|
31
|
+
* @instead One list of records is `ItemGroup`; a choice of one file to send is a file picker.
|
|
32
|
+
* @behaviour Folders first, then files, in the order `readFolder` gives. A click on a folder opens or closes it; a click
|
|
33
|
+
* on a file calls `onOpenFile`, and the file `selected` names is marked. The arrow keys move between rows, Right and Left
|
|
34
|
+
* open and close a folder, and Enter opens a file. Each level is indented 16 px. When
|
|
35
|
+
* `changed` changes, every open folder is read again and the tree keeps what is open. A folder that cannot be read keeps
|
|
36
|
+
* what it last listed and calls `onReadError`, so the page can say so and offer to read it again.
|
|
37
|
+
* @words Each row is the file's or the folder's own name. `aria-label` names whose folder it is: "Nadia's folder".
|
|
38
|
+
* @access A `tree` of `treeitem`s, with `aria-expanded` on a folder and `aria-current` on the file shown.
|
|
39
|
+
*/
|
|
40
|
+
declare function FileTree({ root, readFolder, expanded, onExpandedChange, selected, onOpenFile, onReadError, changed, className, ...props }: FileTreeProps): React.JSX.Element;
|
|
41
|
+
export { FileTree };
|
|
42
|
+
//# sourceMappingURL=file-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-tree.d.ts","sourceRoot":"","sources":["../../src/components/file-tree.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,IAAI,EAAE,aAAa,CAAC;IACpB,6DAA6D;IAC7D,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACvD,iDAAiD;IACjD,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC/C,oDAAoD;IACpD,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,UAAU,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC3C,iFAAiF;IACjF,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,4FAA4F;IAC5F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAoDD;;;;;;;;;;;;;;GAcG;AACH,iBAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,QAAe,EACf,UAAU,EACV,WAAW,EACX,OAAW,EACX,SAAS,EACT,GAAG,KAAK,EACT,EAAE,aAAa,qBAyFf;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { asyncDataLoaderFeature, hotkeysCoreFeature, selectionFeature, } from "@headless-tree/core";
|
|
4
|
+
import { useTree } from "@headless-tree/react";
|
|
5
|
+
import { ChevronDownIcon, FolderIcon, FolderOpenIcon } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
import { FileTypeIcon } from "./file-type-icon.js";
|
|
9
|
+
const INDENT = 16;
|
|
10
|
+
function FileTreeRow({ item, selected }) {
|
|
11
|
+
const entry = item.getItemData();
|
|
12
|
+
const folder = item.isFolder();
|
|
13
|
+
const open = item.isExpanded();
|
|
14
|
+
const props = item.getProps();
|
|
15
|
+
return (_jsx("button", { ...props, "aria-current": selected || undefined, className: "w-full rounded-sm text-start select-none", "data-slot": "file-tree-row", style: { paddingInlineStart: item.getItemMeta().level * INDENT }, title: entry?.name, type: "button", children: _jsxs("span", { className: cn("nc-transition-paint flex h-7 min-w-0 items-center gap-1.5 rounded-sm px-1.5 text-sm text-foreground hover:bg-accent", selected && "bg-accent font-medium"), children: [folder ? (_jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn("size-4 shrink-0 text-muted-foreground transition-transform", !open && "-rotate-90 rtl:rotate-90") })) : (_jsx("span", { "aria-hidden": "true", className: "size-4 shrink-0" })), folder ? (open ? (_jsx(FolderOpenIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-label-yellow" })) : (_jsx(FolderIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-label-yellow" }))) : (_jsx(FileTypeIcon, { path: entry?.name })), _jsx("span", { className: "truncate", children: entry?.name })] }) }));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A folder and everything in it, as a tree of folders that open in place, each file with its kind's coloured icon.
|
|
19
|
+
*
|
|
20
|
+
* @family Navigation
|
|
21
|
+
* @when The files a person browses beside the thing they work on: an Agent's folder in Nadia's side panel. It is ReUI's
|
|
22
|
+
* file-explorer tree (`@reui/c-tree-5`) on Headless Tree, which reads each folder only when it opens.
|
|
23
|
+
* @instead One list of records is `ItemGroup`; a choice of one file to send is a file picker.
|
|
24
|
+
* @behaviour Folders first, then files, in the order `readFolder` gives. A click on a folder opens or closes it; a click
|
|
25
|
+
* on a file calls `onOpenFile`, and the file `selected` names is marked. The arrow keys move between rows, Right and Left
|
|
26
|
+
* open and close a folder, and Enter opens a file. Each level is indented 16 px. When
|
|
27
|
+
* `changed` changes, every open folder is read again and the tree keeps what is open. A folder that cannot be read keeps
|
|
28
|
+
* what it last listed and calls `onReadError`, so the page can say so and offer to read it again.
|
|
29
|
+
* @words Each row is the file's or the folder's own name. `aria-label` names whose folder it is: "Nadia's folder".
|
|
30
|
+
* @access A `tree` of `treeitem`s, with `aria-expanded` on a folder and `aria-current` on the file shown.
|
|
31
|
+
*/
|
|
32
|
+
function FileTree({ root, readFolder, expanded, onExpandedChange, selected = null, onOpenFile, onReadError, changed = 0, className, ...props }) {
|
|
33
|
+
const read = React.useRef(readFolder);
|
|
34
|
+
const open = React.useRef(onOpenFile);
|
|
35
|
+
const failed = React.useRef(onReadError);
|
|
36
|
+
const listed = React.useRef(new Map());
|
|
37
|
+
React.useLayoutEffect(() => {
|
|
38
|
+
read.current = readFolder;
|
|
39
|
+
open.current = onOpenFile;
|
|
40
|
+
failed.current = onReadError;
|
|
41
|
+
});
|
|
42
|
+
const known = React.useRef(new Map([[root.path, root]]));
|
|
43
|
+
const state = React.useMemo(() => ({ expandedItems: [...expanded], selectedItems: selected ? [selected] : [] }), [expanded, selected]);
|
|
44
|
+
const tree = useTree({
|
|
45
|
+
rootItemId: root.path,
|
|
46
|
+
indent: INDENT,
|
|
47
|
+
state,
|
|
48
|
+
setExpandedItems: (next) => onExpandedChange(typeof next === "function" ? next([...expanded]) : next),
|
|
49
|
+
setSelectedItems: () => undefined,
|
|
50
|
+
getItemName: (item) => item.getItemData()?.name ?? "",
|
|
51
|
+
isItemFolder: (item) => item.getItemData()?.isFolder ?? false,
|
|
52
|
+
onPrimaryAction: (item) => {
|
|
53
|
+
const entry = item.getItemData();
|
|
54
|
+
if (entry && !entry.isFolder) {
|
|
55
|
+
open.current(entry);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
dataLoader: {
|
|
59
|
+
getItem: (id) => known.current.get(id) ?? { isFolder: true, name: id.split(/[\\/]/).at(-1) ?? id, path: id },
|
|
60
|
+
getChildrenWithData: async (id) => {
|
|
61
|
+
let entries;
|
|
62
|
+
try {
|
|
63
|
+
entries = await read.current(id);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
failed.current?.(error, id);
|
|
67
|
+
entries = listed.current.get(id) ?? [];
|
|
68
|
+
}
|
|
69
|
+
listed.current.set(id, entries);
|
|
70
|
+
for (const entry of entries) {
|
|
71
|
+
known.current.set(entry.path, entry);
|
|
72
|
+
}
|
|
73
|
+
return entries.map((entry) => ({ id: entry.path, data: entry }));
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
features: [asyncDataLoaderFeature, selectionFeature, hotkeysCoreFeature],
|
|
77
|
+
});
|
|
78
|
+
const shown = React.useRef(changed);
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
if (shown.current === changed) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
shown.current = changed;
|
|
84
|
+
for (const id of [root.path, ...expanded]) {
|
|
85
|
+
tree
|
|
86
|
+
.getItemInstance(id)
|
|
87
|
+
?.invalidateChildrenIds(true)
|
|
88
|
+
.catch(() => undefined);
|
|
89
|
+
}
|
|
90
|
+
}, [changed, expanded, root.path, tree]);
|
|
91
|
+
return (_jsx("div", { ...tree.getContainerProps(props["aria-label"]), "aria-label": props["aria-label"], className: cn("flex flex-col gap-px", className), "data-slot": "file-tree", children: tree.getItems().map((item) => (_jsx(FileTreeRow, { item: item, selected: item.getId() === selected }, item.getId()))) }));
|
|
92
|
+
}
|
|
93
|
+
export { FileTree };
|
|
@@ -7,11 +7,14 @@ export interface FileTypeIconProps extends Omit<React.ComponentProps<"svg">, "ch
|
|
|
7
7
|
* A file's kind as a Lucide icon, from its path or its language.
|
|
8
8
|
*
|
|
9
9
|
* @family Status
|
|
10
|
-
* @when Beside a file's name: a file an Agent wrote, a code block's language, an attachment.
|
|
10
|
+
* @when Beside a file's name: a file an Agent wrote, a code block's language, an attachment, a row of a folder.
|
|
11
11
|
* @instead An app is `AppMark`; a Library entry is its `IdentityMark`. A file's content is
|
|
12
12
|
* `CodeBlock` or `FileDiff`.
|
|
13
|
-
* @behaviour Maps a path's extension or a language name to one icon: terminal, document,
|
|
14
|
-
* settings, database, diff, palette, regex, globe, package,
|
|
13
|
+
* @behaviour Maps a path's extension or a language name to one icon: terminal, document, PDF, spreadsheet,
|
|
14
|
+
* slides, image, audio, video, archive, braces, settings, database, diff, palette, regex, globe, package,
|
|
15
|
+
* share; anything else is the code icon. The files people keep take their kind's category colour, as a file
|
|
16
|
+
* manager draws them: documents and Markdown blue, PDFs red, spreadsheets green, slides orange, pictures purple, audio pink,
|
|
17
|
+
* video teal, archives yellow; the others stay in the text colour.
|
|
15
18
|
* @words None; the file's name stands beside it.
|
|
16
19
|
* @access Always `aria-hidden`.
|
|
17
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-type-icon.d.ts","sourceRoot":"","sources":["../../src/components/file-type-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"file-type-icon.d.ts","sourceRoot":"","sources":["../../src/components/file-type-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AA0LpC,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,qBAY/E;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|