@alexgorbatchev/shadcn 0.0.109 → 0.0.110
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.
|
@@ -19,8 +19,18 @@ type TreeItemProps<T> = useRender.ComponentProps<"div", TreeItemState> & IDensit
|
|
|
19
19
|
expandOn?: "click" | "doubleClick" | "disclosure";
|
|
20
20
|
isEditing?: boolean;
|
|
21
21
|
isDropTarget?: boolean;
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Fades a settled row, such as completed work, to 70% opacity; hover and keyboard focus restore full opacity. The
|
|
24
|
+
* `marker` stays at full opacity, so new activity on a settled row stands out without un-fading it.
|
|
25
|
+
*/
|
|
23
26
|
isDimmed?: boolean;
|
|
27
|
+
/** Marks a row with activity its reader has not seen yet: the label turns bold. Pair it with a `marker`. */
|
|
28
|
+
isUnread?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* A visual marker at the row's end, such as a `TreeItemDot` for new activity, never faded by `isDimmed`. It is
|
|
31
|
+
* hidden from assistive technology; state what it means in `descriptionLabel`.
|
|
32
|
+
*/
|
|
33
|
+
marker?: ReactNode;
|
|
24
34
|
/** The registered native link owns row focus; disclosure and actions remain siblings. */
|
|
25
35
|
linkProps?: useRender.ComponentProps<"a", TreeItemState>;
|
|
26
36
|
/** Domain-controlled drag feedback; omitted rows have no tooltip wrapper. */
|
|
@@ -49,9 +59,20 @@ type TreeItemActionProps = ComponentProps<typeof Button>;
|
|
|
49
59
|
* menu trigger renders it, so the tree keeps one Tab stop.
|
|
50
60
|
*/
|
|
51
61
|
export declare function TreeItemAction({ variant, size, ...props }: TreeItemActionProps): ReactElement;
|
|
62
|
+
interface ITreeItemDotProps {
|
|
63
|
+
/** The number shown beside the dot, such as the new pages inside a collapsed folder; omitted for a single item. */
|
|
64
|
+
count?: number;
|
|
65
|
+
className?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The new-activity dot for a `TreeItem`'s `marker`, with an optional count for a collapsed container that rolls up its
|
|
69
|
+
* rows. Drawn as an SVG fill in `currentColor`, so forced colors keep it visible. It is decorative: the row's
|
|
70
|
+
* `descriptionLabel` names it ("New round", "1 new page").
|
|
71
|
+
*/
|
|
72
|
+
export declare function TreeItemDot({ count, className }: ITreeItemDotProps): ReactElement;
|
|
52
73
|
/**
|
|
53
74
|
* Registered tree row; compose menus with render, put counts in `description` and pointer shortcuts in `actions`.
|
|
54
75
|
* `endEnhancer` holds controls that must stay keyboard reachable on their own.
|
|
55
76
|
*/
|
|
56
|
-
export declare function TreeItem<T>({ analytics, item, children, startEnhancer, endEnhancer, description, descriptionLabel, actions, expandOn, isEditing, isDropTarget, isDimmed, linkProps, dropHint, density, render, ref, ...props }: TreeItemProps<T>): ReactElement;
|
|
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;
|
|
57
78
|
export type { TreeItemProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Tree } from "./Tree.js";
|
|
2
|
-
export { TreeItem, TreeItemAction } from "./TreeItem.js";
|
|
2
|
+
export { TreeItem, TreeItemAction, TreeItemDot } from "./TreeItem.js";
|
|
3
3
|
export type { TreeProps } from "./Tree.js";
|
|
4
4
|
export type { TreeItemProps } from "./TreeItem.js";
|
|
5
5
|
export { useTree, AssistiveTreeDescription } from "@headless-tree/react";
|
|
@@ -38,6 +38,30 @@ function TreeItemAction({ variant = "ghost", size = "icon-xs", ...props }) {
|
|
|
38
38
|
tabIndex: -1
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
+
function TreeItemDot({ count, className }) {
|
|
42
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
43
|
+
"aria-hidden": "true",
|
|
44
|
+
"data-slot": "tree-item-dot",
|
|
45
|
+
className: cn2("inline-flex items-center gap-1 text-xs font-medium text-primary tabular-nums", className),
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx("svg", {
|
|
48
|
+
viewBox: "0 0 8 8",
|
|
49
|
+
className: "size-2 shrink-0",
|
|
50
|
+
focusable: "false",
|
|
51
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
52
|
+
cx: "4",
|
|
53
|
+
cy: "4",
|
|
54
|
+
r: "4",
|
|
55
|
+
fill: "currentColor"
|
|
56
|
+
})
|
|
57
|
+
}),
|
|
58
|
+
count !== undefined && /* @__PURE__ */ jsx("span", {
|
|
59
|
+
"data-slot": "tree-item-dot-count",
|
|
60
|
+
children: count
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
41
65
|
function isRowControl(event) {
|
|
42
66
|
return event.target !== event.currentTarget && event.target instanceof Element && Boolean(event.target.closest("a,button,input,textarea,select,form"));
|
|
43
67
|
}
|
|
@@ -54,6 +78,8 @@ function TreeItem({
|
|
|
54
78
|
isEditing = false,
|
|
55
79
|
isDropTarget = false,
|
|
56
80
|
isDimmed = false,
|
|
81
|
+
isUnread = false,
|
|
82
|
+
marker,
|
|
57
83
|
linkProps,
|
|
58
84
|
dropHint,
|
|
59
85
|
density,
|
|
@@ -104,6 +130,7 @@ function TreeItem({
|
|
|
104
130
|
item.getTree().getDataRef().current.selectUpToAnchorId = item.getId();
|
|
105
131
|
item.primaryAction();
|
|
106
132
|
};
|
|
133
|
+
const faded = isDimmed && "opacity-70 group-hover/tree-item:opacity-100 group-focus-within/tree-item:opacity-100";
|
|
107
134
|
const label = /* @__PURE__ */ jsxs(Fragment, {
|
|
108
135
|
children: [
|
|
109
136
|
/* @__PURE__ */ jsx("span", {
|
|
@@ -112,7 +139,7 @@ function TreeItem({
|
|
|
112
139
|
children: startEnhancer ?? (item.isFolder() ? isExpanded ? /* @__PURE__ */ jsx(FolderOpenIcon, {}) : /* @__PURE__ */ jsx(FolderIcon, {}) : /* @__PURE__ */ jsx(FileIcon, {}))
|
|
113
140
|
}),
|
|
114
141
|
/* @__PURE__ */ jsx("div", {
|
|
115
|
-
className: "min-w-0 flex-1 truncate",
|
|
142
|
+
className: cn2("min-w-0 flex-1 truncate", isUnread && "font-semibold"),
|
|
116
143
|
children: children ?? item.getItemName()
|
|
117
144
|
})
|
|
118
145
|
]
|
|
@@ -124,7 +151,7 @@ function TreeItem({
|
|
|
124
151
|
props: mergeProps({
|
|
125
152
|
...nativeProps,
|
|
126
153
|
ref: undefined,
|
|
127
|
-
className: "flex min-w-0 flex-1 items-center gap-2 outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
154
|
+
className: cn2("flex min-w-0 flex-1 items-center gap-2 outline-none focus-visible:ring-2 focus-visible:ring-ring", faded),
|
|
128
155
|
children: label,
|
|
129
156
|
onFocus: () => item.setFocused(),
|
|
130
157
|
onClick: (event) => {
|
|
@@ -178,12 +205,13 @@ function TreeItem({
|
|
|
178
205
|
onDragStart: undefined
|
|
179
206
|
} : {},
|
|
180
207
|
style: { paddingInlineStart: `${item.getItemMeta().level * (item.getTree().getConfig().indent ?? 20) + 8}px` },
|
|
181
|
-
className: cn2("relative flex min-h-control min-w-0 cursor-default items-center gap-2 rounded-sm py-1 pr-2 text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring", (isSelected || isDropTarget || isInsideTarget) && "bg-accent text-accent-foreground", isDimmed && "
|
|
208
|
+
className: cn2("relative flex min-h-control min-w-0 cursor-default items-center gap-2 rounded-sm py-1 pr-2 text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring", (isSelected || isDropTarget || isInsideTarget) && "bg-accent text-accent-foreground", isDimmed && "group/tree-item"),
|
|
182
209
|
children: /* @__PURE__ */ jsxs(Fragment, {
|
|
183
210
|
children: [
|
|
184
211
|
item.isFolder() && expandOn === "disclosure" ? /* @__PURE__ */ jsx(Button2, {
|
|
185
212
|
variant: "plain",
|
|
186
213
|
size: "icon-xs",
|
|
214
|
+
className: cn2(faded),
|
|
187
215
|
tabIndex: -1,
|
|
188
216
|
"aria-hidden": "true",
|
|
189
217
|
"aria-label": `${isExpanded ? "Collapse" : "Expand"} ${item.getItemName()}`,
|
|
@@ -199,20 +227,29 @@ function TreeItem({
|
|
|
199
227
|
})
|
|
200
228
|
}) : item.isFolder() ? /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
201
229
|
"aria-hidden": "true",
|
|
202
|
-
className: cn2("size-3.5 shrink-0", isExpanded && "rotate-90")
|
|
230
|
+
className: cn2("size-3.5 shrink-0", isExpanded && "rotate-90", faded)
|
|
203
231
|
}) : /* @__PURE__ */ jsx("span", {
|
|
204
232
|
className: cn2("shrink-0", expandOn === "disclosure" ? "size-control-xs" : "size-3.5")
|
|
205
233
|
}),
|
|
206
|
-
linkProps && !isEditing ? link :
|
|
234
|
+
linkProps && !isEditing ? link : isDimmed ? /* @__PURE__ */ jsx("div", {
|
|
235
|
+
className: cn2("flex min-w-0 flex-1 items-center gap-2", faded),
|
|
236
|
+
children: label
|
|
237
|
+
}) : label,
|
|
207
238
|
endEnhancer && /* @__PURE__ */ jsx("div", {
|
|
208
|
-
className: "flex shrink-0 items-center gap-1 text-xs tabular-nums",
|
|
239
|
+
className: cn2("flex shrink-0 items-center gap-1 text-xs tabular-nums", faded),
|
|
209
240
|
onClick: (event) => event.stopPropagation(),
|
|
210
241
|
onDoubleClick: (event) => event.stopPropagation(),
|
|
211
242
|
onKeyDown: (event) => event.stopPropagation(),
|
|
212
243
|
children: endEnhancer
|
|
213
244
|
}),
|
|
245
|
+
marker !== undefined && marker !== null && marker !== false && /* @__PURE__ */ jsx("div", {
|
|
246
|
+
"aria-hidden": "true",
|
|
247
|
+
"data-slot": "tree-item-marker",
|
|
248
|
+
className: "flex shrink-0 items-center",
|
|
249
|
+
children: marker
|
|
250
|
+
}),
|
|
214
251
|
(hasDescription || actions) && /* @__PURE__ */ jsxs("div", {
|
|
215
|
-
className: "flex shrink-0 items-center gap-1 text-xs tabular-nums",
|
|
252
|
+
className: cn2("flex shrink-0 items-center gap-1 text-xs tabular-nums", faded),
|
|
216
253
|
children: [
|
|
217
254
|
description !== undefined && description !== null && /* @__PURE__ */ jsx("span", {
|
|
218
255
|
"aria-hidden": "true",
|
|
@@ -2545,6 +2582,7 @@ export {
|
|
|
2545
2582
|
Tree,
|
|
2546
2583
|
TreeItem,
|
|
2547
2584
|
TreeItemAction,
|
|
2585
|
+
TreeItemDot,
|
|
2548
2586
|
asyncDataLoaderFeature,
|
|
2549
2587
|
checkboxesFeature,
|
|
2550
2588
|
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.110",
|
|
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, useTree, syncDataLoaderFeature, hotkeysCoreFeature, selectionFeature } from "@alexgorbatchev/shadcn/tree";
|
|
11
|
+
import { Tree, TreeItem, TreeItemAction, TreeItemDot, useTree, syncDataLoaderFeature, hotkeysCoreFeature, selectionFeature } from "@alexgorbatchev/shadcn/tree";
|
|
12
12
|
import { Button, ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuGroup, ContextMenuItem, InlineEdit } from "@alexgorbatchev/shadcn";
|
|
13
13
|
```
|
|
14
14
|
|
|
@@ -84,3 +84,11 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
84
84
|
render: () => <DimmedExample />
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
|
+
|
|
88
|
+
### NewActivity
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
{
|
|
92
|
+
render: () => <NewActivityExample />
|
|
93
|
+
}
|
|
94
|
+
```
|