@alexgorbatchev/shadcn 0.0.110 → 0.0.112
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.
|
@@ -26,6 +26,12 @@ type TreeItemProps<T> = useRender.ComponentProps<"div", TreeItemState> & IDensit
|
|
|
26
26
|
isDimmed?: boolean;
|
|
27
27
|
/** Marks a row with activity its reader has not seen yet: the label turns bold. Pair it with a `marker`. */
|
|
28
28
|
isUnread?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The row's start slot, before its icon and label and outside its link: a status control (a `TreeItemAction`
|
|
31
|
+
* holding a `TreeItemStatusIcon`) or a plain status icon. `null` keeps the slot empty so rows stay aligned. It
|
|
32
|
+
* fades with the row.
|
|
33
|
+
*/
|
|
34
|
+
leading?: ReactNode;
|
|
29
35
|
/**
|
|
30
36
|
* A visual marker at the row's end, such as a `TreeItemDot` for new activity, never faded by `isDimmed`. It is
|
|
31
37
|
* hidden from assistive technology; state what it means in `descriptionLabel`.
|
|
@@ -59,6 +65,20 @@ type TreeItemActionProps = ComponentProps<typeof Button>;
|
|
|
59
65
|
* menu trigger renders it, so the tree keeps one Tab stop.
|
|
60
66
|
*/
|
|
61
67
|
export declare function TreeItemAction({ variant, size, ...props }: TreeItemActionProps): ReactElement;
|
|
68
|
+
/**
|
|
69
|
+
* A row's hand-back state, drawn by `TreeItemStatusIcon`: two waiting states, waiting with unsent answers, failed,
|
|
70
|
+
* held for an Undo window, handed back, and handed back with unsent changes.
|
|
71
|
+
*/
|
|
72
|
+
export type TreeItemStatus = "needs-answers" | "needs-review" | "unsent" | "failed" | "held" | "handed-back" | "handed-back-unsent";
|
|
73
|
+
interface ITreeItemStatusIconProps {
|
|
74
|
+
status: TreeItemStatus;
|
|
75
|
+
className?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The status icon set for a row's `leading` slot. Each state has its own shape, so forced colors keep them apart; the
|
|
79
|
+
* unsent states add a filled marker at the top end. It is decorative: the row's `descriptionLabel` names the state.
|
|
80
|
+
*/
|
|
81
|
+
export declare function TreeItemStatusIcon({ status, className }: ITreeItemStatusIconProps): ReactElement;
|
|
62
82
|
interface ITreeItemDotProps {
|
|
63
83
|
/** The number shown beside the dot, such as the new pages inside a collapsed folder; omitted for a single item. */
|
|
64
84
|
count?: number;
|
|
@@ -74,5 +94,5 @@ export declare function TreeItemDot({ count, className }: ITreeItemDotProps): Re
|
|
|
74
94
|
* Registered tree row; compose menus with render, put counts in `description` and pointer shortcuts in `actions`.
|
|
75
95
|
* `endEnhancer` holds controls that must stay keyboard reachable on their own.
|
|
76
96
|
*/
|
|
77
|
-
export declare function TreeItem<T>({ analytics, item, children, startEnhancer, endEnhancer, description, descriptionLabel, actions, expandOn, isEditing, isDropTarget, isDimmed, isUnread, marker, linkProps, dropHint, density, render, ref, ...props }: TreeItemProps<T>): ReactElement;
|
|
97
|
+
export declare function TreeItem<T>({ analytics, item, children, startEnhancer, endEnhancer, description, descriptionLabel, actions, expandOn, isEditing, isDropTarget, isDimmed, isUnread, leading, marker, linkProps, dropHint, density, render, ref, ...props }: TreeItemProps<T>): ReactElement;
|
|
78
98
|
export type { TreeItemProps };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Tree } from "./Tree.js";
|
|
2
|
-
export { TreeItem, TreeItemAction, TreeItemDot } from "./TreeItem.js";
|
|
2
|
+
export { TreeItem, TreeItemAction, TreeItemDot, TreeItemStatusIcon } from "./TreeItem.js";
|
|
3
3
|
export type { TreeProps } from "./Tree.js";
|
|
4
|
-
export type { TreeItemProps } from "./TreeItem.js";
|
|
4
|
+
export type { TreeItemProps, TreeItemStatus } from "./TreeItem.js";
|
|
5
5
|
export { useTree, AssistiveTreeDescription } from "@headless-tree/react";
|
|
6
6
|
export { syncDataLoaderFeature, asyncDataLoaderFeature, hotkeysCoreFeature, selectionFeature, checkboxesFeature, searchFeature, renamingFeature, expandAllFeature, dragAndDropFeature, keyboardDragAndDropFeature, isOrderedDragTarget, } from "@headless-tree/core";
|
|
7
7
|
export type { TreeInstance, ItemInstance, TreeConfig, DragTarget } from "@headless-tree/core";
|
|
@@ -21,7 +21,17 @@ import {
|
|
|
21
21
|
// src/components/tree/TreeItem.tsx
|
|
22
22
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
23
23
|
import { useRender } from "@base-ui/react/use-render";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
ChevronRightIcon,
|
|
26
|
+
CircleAlertIcon,
|
|
27
|
+
CircleCheckIcon,
|
|
28
|
+
CircleDotIcon,
|
|
29
|
+
CircleIcon,
|
|
30
|
+
FileIcon,
|
|
31
|
+
FolderIcon,
|
|
32
|
+
FolderOpenIcon,
|
|
33
|
+
HourglassIcon
|
|
34
|
+
} from "lucide-react";
|
|
25
35
|
import { use, useId } from "react";
|
|
26
36
|
|
|
27
37
|
// src/components/tree/TreeTabStopContext.ts
|
|
@@ -38,6 +48,45 @@ function TreeItemAction({ variant = "ghost", size = "icon-xs", ...props }) {
|
|
|
38
48
|
tabIndex: -1
|
|
39
49
|
});
|
|
40
50
|
}
|
|
51
|
+
var STATUS_ICONS = {
|
|
52
|
+
"needs-answers": CircleDotIcon,
|
|
53
|
+
"needs-review": CircleIcon,
|
|
54
|
+
unsent: CircleIcon,
|
|
55
|
+
failed: CircleAlertIcon,
|
|
56
|
+
held: HourglassIcon,
|
|
57
|
+
"handed-back": CircleCheckIcon,
|
|
58
|
+
"handed-back-unsent": CircleCheckIcon
|
|
59
|
+
};
|
|
60
|
+
function TreeItemStatusIcon({ status, className }) {
|
|
61
|
+
const Icon = STATUS_ICONS[status];
|
|
62
|
+
const hasMarker = status === "unsent" || status === "handed-back-unsent";
|
|
63
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
64
|
+
"aria-hidden": "true",
|
|
65
|
+
"data-slot": "tree-item-status",
|
|
66
|
+
"data-status": status,
|
|
67
|
+
className: cn2("relative inline-flex size-4 shrink-0 items-center justify-center", className),
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
70
|
+
className: "size-3.5"
|
|
71
|
+
}),
|
|
72
|
+
hasMarker && /* @__PURE__ */ jsx("span", {
|
|
73
|
+
"data-slot": "tree-item-status-marker",
|
|
74
|
+
className: "absolute -top-0.5 -right-0.5 flex size-1.5",
|
|
75
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
76
|
+
viewBox: "0 0 6 6",
|
|
77
|
+
className: "size-full",
|
|
78
|
+
focusable: "false",
|
|
79
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
80
|
+
cx: "3",
|
|
81
|
+
cy: "3",
|
|
82
|
+
r: "3",
|
|
83
|
+
fill: "currentColor"
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
41
90
|
function TreeItemDot({ count, className }) {
|
|
42
91
|
return /* @__PURE__ */ jsxs("span", {
|
|
43
92
|
"aria-hidden": "true",
|
|
@@ -79,6 +128,7 @@ function TreeItem({
|
|
|
79
128
|
isDropTarget = false,
|
|
80
129
|
isDimmed = false,
|
|
81
130
|
isUnread = false,
|
|
131
|
+
leading,
|
|
82
132
|
marker,
|
|
83
133
|
linkProps,
|
|
84
134
|
dropHint,
|
|
@@ -231,6 +281,14 @@ function TreeItem({
|
|
|
231
281
|
}) : /* @__PURE__ */ jsx("span", {
|
|
232
282
|
className: cn2("shrink-0", expandOn === "disclosure" ? "size-control-xs" : "size-3.5")
|
|
233
283
|
}),
|
|
284
|
+
leading !== undefined && /* @__PURE__ */ jsx("div", {
|
|
285
|
+
"data-slot": "tree-item-leading",
|
|
286
|
+
className: cn2("flex size-control-xs shrink-0 items-center justify-center", faded),
|
|
287
|
+
onClick: (event) => event.stopPropagation(),
|
|
288
|
+
onDoubleClick: (event) => event.stopPropagation(),
|
|
289
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
290
|
+
children: leading
|
|
291
|
+
}),
|
|
234
292
|
linkProps && !isEditing ? link : isDimmed ? /* @__PURE__ */ jsx("div", {
|
|
235
293
|
className: cn2("flex min-w-0 flex-1 items-center gap-2", faded),
|
|
236
294
|
children: label
|
|
@@ -2583,6 +2641,7 @@ export {
|
|
|
2583
2641
|
TreeItem,
|
|
2584
2642
|
TreeItemAction,
|
|
2585
2643
|
TreeItemDot,
|
|
2644
|
+
TreeItemStatusIcon,
|
|
2586
2645
|
asyncDataLoaderFeature,
|
|
2587
2646
|
checkboxesFeature,
|
|
2588
2647
|
dragAndDropFeature,
|
package/dist/prototype.js
CHANGED
|
@@ -2051,7 +2051,7 @@ var program = new Command;
|
|
|
2051
2051
|
// package.json
|
|
2052
2052
|
var package_default = {
|
|
2053
2053
|
name: "@alexgorbatchev/shadcn",
|
|
2054
|
-
version: "0.0.
|
|
2054
|
+
version: "0.0.112",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact and comfortable densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -8,7 +8,7 @@ Source: src/components/stories/navigation/Tree.stories.tsx
|
|
|
8
8
|
## Public imports
|
|
9
9
|
|
|
10
10
|
```tsx
|
|
11
|
-
import { Tree, TreeItem, TreeItemAction, TreeItemDot, useTree, syncDataLoaderFeature, hotkeysCoreFeature, selectionFeature } from "@alexgorbatchev/shadcn/tree";
|
|
11
|
+
import { Tree, TreeItem, TreeItemAction, TreeItemDot, TreeItemStatusIcon, useTree, syncDataLoaderFeature, hotkeysCoreFeature, selectionFeature, type TreeItemStatus } from "@alexgorbatchev/shadcn/tree";
|
|
12
12
|
import { Button, ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuGroup, ContextMenuItem, InlineEdit } from "@alexgorbatchev/shadcn";
|
|
13
13
|
```
|
|
14
14
|
|
|
@@ -92,3 +92,11 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
92
92
|
render: () => <NewActivityExample />
|
|
93
93
|
}
|
|
94
94
|
```
|
|
95
|
+
|
|
96
|
+
### StatusRows
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
{
|
|
100
|
+
render: () => <StatusRowsExample />
|
|
101
|
+
}
|
|
102
|
+
```
|