@alexgorbatchev/shadcn 0.0.110 → 0.0.111

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 { ChevronRightIcon, FileIcon, FolderIcon, FolderOpenIcon } from "lucide-react";
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,39 @@ 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 [&>svg]:size-3.5", className),
68
+ children: [
69
+ /* @__PURE__ */ jsx(Icon, {}),
70
+ hasMarker && /* @__PURE__ */ jsx("svg", {
71
+ viewBox: "0 0 6 6",
72
+ className: "absolute -top-0.5 -right-0.5 size-1.5",
73
+ focusable: "false",
74
+ children: /* @__PURE__ */ jsx("circle", {
75
+ cx: "3",
76
+ cy: "3",
77
+ r: "3",
78
+ fill: "currentColor"
79
+ })
80
+ })
81
+ ]
82
+ });
83
+ }
41
84
  function TreeItemDot({ count, className }) {
42
85
  return /* @__PURE__ */ jsxs("span", {
43
86
  "aria-hidden": "true",
@@ -79,6 +122,7 @@ function TreeItem({
79
122
  isDropTarget = false,
80
123
  isDimmed = false,
81
124
  isUnread = false,
125
+ leading,
82
126
  marker,
83
127
  linkProps,
84
128
  dropHint,
@@ -231,6 +275,14 @@ function TreeItem({
231
275
  }) : /* @__PURE__ */ jsx("span", {
232
276
  className: cn2("shrink-0", expandOn === "disclosure" ? "size-control-xs" : "size-3.5")
233
277
  }),
278
+ leading !== undefined && /* @__PURE__ */ jsx("div", {
279
+ "data-slot": "tree-item-leading",
280
+ className: cn2("flex size-control-xs shrink-0 items-center justify-center", faded),
281
+ onClick: (event) => event.stopPropagation(),
282
+ onDoubleClick: (event) => event.stopPropagation(),
283
+ onKeyDown: (event) => event.stopPropagation(),
284
+ children: leading
285
+ }),
234
286
  linkProps && !isEditing ? link : isDimmed ? /* @__PURE__ */ jsx("div", {
235
287
  className: cn2("flex min-w-0 flex-1 items-center gap-2", faded),
236
288
  children: label
@@ -2583,6 +2635,7 @@ export {
2583
2635
  TreeItem,
2584
2636
  TreeItemAction,
2585
2637
  TreeItemDot,
2638
+ TreeItemStatusIcon,
2586
2639
  asyncDataLoaderFeature,
2587
2640
  checkboxesFeature,
2588
2641
  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.110",
2054
+ version: "0.0.111",
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
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.110",
3
+ "version": "0.0.111",
4
4
  "description": "Sharp, monospace React components with compact and comfortable densities.",
5
5
  "license": "MIT",
6
6
  "repository": {