@alexgorbatchev/shadcn 0.0.75 → 0.0.77
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/README.md +5 -3
- package/dist/{chunk-jrf138sy.js → chunk-bv2bar22.js} +1 -1
- package/dist/{chunk-jdvyr7tw.js → chunk-k1jr6r51.js} +12 -6
- package/dist/{chunk-yywr1jgk.js → chunk-tegj7xts.js} +15 -1
- package/dist/components/MenuParts.d.ts +1 -1
- package/dist/components/StarRating.d.ts +7 -1
- package/dist/components/assistant-ui/elements/RegenerateMenu.js +2 -2
- package/dist/components/assistant-ui/index.js +2 -2
- package/dist/components/data-grid/DataGridSelectCell.d.ts +6 -1
- package/dist/components/data-grid/index.js +3 -1
- package/dist/components/json-render/index.js +2 -2
- package/dist/components/tree/Tree.d.ts +4 -1
- package/dist/components/tree/TreeItem.d.ts +26 -3
- package/dist/components/tree/TreeTabStopContext.d.ts +5 -0
- package/dist/components/tree/index.d.ts +1 -1
- package/dist/components/tree/index.js +100 -34
- package/dist/index.js +2 -2
- package/dist/menu/types.d.ts +5 -0
- package/dist/prototype.js +2 -1
- package/llms/components/data-display/DataGridSelectCell.md +8 -0
- package/llms/components/forms/StarRating.md +24 -0
- package/llms/components/navigation/DropdownMenu.md +3 -1
- package/llms/components/navigation/Tree.md +1 -1
- package/llms/setup.md +5 -3
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -456,6 +456,8 @@ For nested layouts, compose `ActionsMenuTrigger`, `ActionsMenuContextTarget`, an
|
|
|
456
456
|
|
|
457
457
|
`TreeItem linkProps` places the registered tree item, roving focus, and native drag handlers on an anchor. Pass `href` and anchor events directly, or compose a router link through `linkProps.render`. The outer `render` and `ref` remain available for row overlays; disclosure and `endEnhancer` controls remain siblings of the link. Enter and modified clicks retain native link behavior, while tree arrows retain navigation and expansion behavior. Optional `dropHint={{ content, open, side }}` displays caller-controlled drag feedback without adding a focus target. `isDimmed` fades a settled row, such as completed work, to 70% opacity and exposes `data-dimmed`; hovering or focusing anything in the row restores full opacity, and the row stays interactive.
|
|
458
458
|
|
|
459
|
+
A `Tree` is one Tab stop: Tab reaches the focused item while it is visible, else the first selected item, else the first item, and the arrow keys move from there. Disclosure buttons are pointer targets outside the Tab order and the accessibility tree; the item's `aria-expanded` and the arrow keys carry the same state. Put secondary text such as a count in `description`, which the item exposes through `aria-describedby` instead of its name, with `descriptionLabel` when the spoken text differs ("12 tracks" for "12"). Put pointer shortcuts such as a ⋯ menu trigger in `actions`, each rendered as a `TreeItemAction` (including as a menu trigger's `render`): they stay out of the Tab order and the accessibility tree, so give the item a keyboard path to the same commands, such as Shift+F10 and the Menu key. Rows without an `endEnhancer` take their name from their visible label; `endEnhancer` keeps controls that must remain keyboard reachable on their own, and those rows keep the item name as their label.
|
|
460
|
+
|
|
459
461
|
Embedded actions, links, menus, editable fields, and media controls retain their own keyboard behavior. Registered anchor and button rows still participate in tree navigation; rename and search inputs retain their completion and cancellation shortcuts.
|
|
460
462
|
|
|
461
463
|
`PageHeader` accepts an optional `eyebrow` above its single page title. It accepts any React content without introducing another heading. Breadcrumbs, description, actions, and density remain independent slots; long action content wraps within narrow layouts.
|
|
@@ -578,7 +580,7 @@ The preview shows compact individual badges, up to five labels followed by `+N m
|
|
|
578
580
|
|
|
579
581
|
# Devhost Preview
|
|
580
582
|
|
|
581
|
-
The routed preview serves Storybook at `shadcn.localhost` through devhost.
|
|
583
|
+
The routed preview serves Storybook at `shadcn.localhost` through devhost v0.0.14 or newer. The manifest names its services with the bare host labels `shadcn` and `shadcn-snapshots`, and devhost's machine configuration supplies the domain: a custom `domainSuffix` changes the hostname, and a machine enrolled in [remote previews](https://alexgorbatchev.github.io/devhost/stacks/remote-previews/) serves the preview through its relay.
|
|
582
584
|
|
|
583
585
|
From this repository, start the configured Storybook service:
|
|
584
586
|
|
|
@@ -586,9 +588,9 @@ From this repository, start the configured Storybook service:
|
|
|
586
588
|
just run
|
|
587
589
|
```
|
|
588
590
|
|
|
589
|
-
`just run`
|
|
591
|
+
`just run` starts the preview in the background and passes its arguments to `devhost start --detach`; `just run --local` keeps local routing on a machine enrolled in remote previews.
|
|
590
592
|
|
|
591
|
-
Open the hostname printed by devhost over HTTPS. The manifest allocates a port automatically and serves Storybook through the shared devhost HTTPS proxy.
|
|
593
|
+
Open the hostname printed by devhost over HTTPS. The manifest allocates a port automatically and serves Storybook through the shared devhost HTTPS proxy. For local routing, the hostname must resolve to the machine running devhost; `.localhost` names need no DNS setup. The managed Caddy instance must be running (`devhost caddy start`).
|
|
592
594
|
|
|
593
595
|
Storybook binds to IPv4 loopback and allows the configured hostname in both Storybook and Vite. Caddy listens on all interfaces and serves HTTP as well as HTTPS, so the external devbox gateway can reach it. The direct `just storybook` preview remains available on `127.0.0.1:6006`.
|
|
594
596
|
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
MenuShortcut2,
|
|
39
39
|
DropdownMenu2,
|
|
40
40
|
DropdownMenuTrigger2
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-tegj7xts.js";
|
|
42
42
|
import {
|
|
43
43
|
Alert2,
|
|
44
44
|
AlertTitle2,
|
|
@@ -2745,38 +2745,44 @@ function InlineEdit2({
|
|
|
2745
2745
|
import { Radio } from "@base-ui/react/radio";
|
|
2746
2746
|
import { StarIcon, CircleOffIcon } from "lucide-react";
|
|
2747
2747
|
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
2748
|
+
var ITEM_SIZES = { comfortable: "size-5", compact: "size-4" };
|
|
2749
|
+
var STAR_SIZES = { comfortable: "size-3.5", compact: "size-3" };
|
|
2750
|
+
var CLEAR_SIZES = { comfortable: "size-3", compact: "size-2.5" };
|
|
2748
2751
|
function StarRating2({
|
|
2749
2752
|
analytics,
|
|
2750
2753
|
label,
|
|
2751
2754
|
value,
|
|
2752
2755
|
disabled,
|
|
2753
|
-
density,
|
|
2756
|
+
density: densityProp,
|
|
2757
|
+
focusable = true,
|
|
2754
2758
|
onValueChange
|
|
2755
2759
|
}) {
|
|
2760
|
+
const density = useDensity(densityProp);
|
|
2756
2761
|
return /* @__PURE__ */ jsx28(RadioGroup2, {
|
|
2757
2762
|
analytics,
|
|
2758
2763
|
"aria-label": label,
|
|
2759
2764
|
value,
|
|
2760
2765
|
disabled,
|
|
2761
|
-
"data-density":
|
|
2766
|
+
"data-density": densityProp,
|
|
2762
2767
|
className: "inline-flex w-fit shrink-0 items-center gap-0.5",
|
|
2763
2768
|
onValueChange,
|
|
2764
2769
|
children: [1, 2, 3, 4, 5, 0].map((star) => /* @__PURE__ */ jsx28(Radio.Root, {
|
|
2765
2770
|
value: star,
|
|
2766
2771
|
nativeButton: true,
|
|
2772
|
+
...focusable ? {} : { tabIndex: -1 },
|
|
2767
2773
|
render: /* @__PURE__ */ jsx28(AnalyticsButton, {
|
|
2768
2774
|
component: "StarRating",
|
|
2769
2775
|
type: "button"
|
|
2770
2776
|
}),
|
|
2771
2777
|
"aria-label": star === 0 ? "Unrated" : `${star} ${star === 1 ? "star" : "stars"}`,
|
|
2772
2778
|
title: star === 0 ? "Clear rating" : `${star} stars`,
|
|
2773
|
-
className: "inline-flex
|
|
2779
|
+
className: cn2("inline-flex shrink-0 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-primary focus-visible:ring-1 focus-visible:ring-ring data-disabled:cursor-not-allowed data-disabled:opacity-50", ITEM_SIZES[density]),
|
|
2774
2780
|
children: star === 0 ? /* @__PURE__ */ jsx28(CircleOffIcon, {
|
|
2775
2781
|
"aria-hidden": "true",
|
|
2776
|
-
className:
|
|
2782
|
+
className: CLEAR_SIZES[density]
|
|
2777
2783
|
}) : /* @__PURE__ */ jsx28(StarIcon, {
|
|
2778
2784
|
"aria-hidden": "true",
|
|
2779
|
-
className: star <= value ? "
|
|
2785
|
+
className: star <= value ? cn2(STAR_SIZES[density], "fill-primary text-primary") : STAR_SIZES[density]
|
|
2780
2786
|
})
|
|
2781
2787
|
}, star))
|
|
2782
2788
|
});
|
|
@@ -71,7 +71,7 @@ import { Menu as MenuPrimitive2 } from "@base-ui/react/menu";
|
|
|
71
71
|
import { ChevronRightIcon, CheckIcon } from "lucide-react";
|
|
72
72
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
73
73
|
"use client";
|
|
74
|
-
var menuItemClassName = "group/menu-item relative flex cursor-default items-center data-has-reason:flex-wrap data-has-reason:data-disabled:opacity-100 data-has-reason:data-disabled:text-muted-foreground gap-control-gap rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:ps-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive";
|
|
74
|
+
var menuItemClassName = "group/menu-item relative flex cursor-default items-center data-has-reason:flex-wrap data-has-reason:data-disabled:pointer-events-auto data-has-reason:data-disabled:opacity-100 data-has-reason:data-disabled:text-muted-foreground gap-control-gap rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:ps-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive";
|
|
75
75
|
function MenuGroup2({ ...props }) {
|
|
76
76
|
return /* @__PURE__ */ jsx2(MenuPrimitive2.Group, {
|
|
77
77
|
"data-slot": "menu-group",
|
|
@@ -94,11 +94,24 @@ function MenuItem2({
|
|
|
94
94
|
inset,
|
|
95
95
|
variant = "default",
|
|
96
96
|
disabledReason,
|
|
97
|
+
onDisabledSelect,
|
|
97
98
|
children,
|
|
98
99
|
...props
|
|
99
100
|
}) {
|
|
100
101
|
const trackedOnClick = useAnalyticsCallback("MenuItem", analytics, { name: "ui.activate" }, props.onClick);
|
|
101
102
|
const reasonId = useId();
|
|
103
|
+
const disabledSelect = disabledReason ? {
|
|
104
|
+
onClickCapture: (event) => {
|
|
105
|
+
props.onClickCapture?.(event);
|
|
106
|
+
onDisabledSelect?.();
|
|
107
|
+
},
|
|
108
|
+
onKeyDownCapture: (event) => {
|
|
109
|
+
props.onKeyDownCapture?.(event);
|
|
110
|
+
if (event.target !== event.currentTarget || event.repeat || event.key !== "Enter" && event.key !== " ")
|
|
111
|
+
return;
|
|
112
|
+
onDisabledSelect?.();
|
|
113
|
+
}
|
|
114
|
+
} : {};
|
|
102
115
|
return /* @__PURE__ */ jsxs(MenuPrimitive2.Item, {
|
|
103
116
|
"data-density": density,
|
|
104
117
|
"data-slot": "menu-item",
|
|
@@ -110,6 +123,7 @@ function MenuItem2({
|
|
|
110
123
|
disabled: Boolean(disabledReason) || props.disabled,
|
|
111
124
|
"aria-describedby": [props["aria-describedby"], disabledReason ? reasonId : undefined].filter(Boolean).join(" ") || undefined,
|
|
112
125
|
onClick: trackedOnClick,
|
|
126
|
+
...disabledSelect,
|
|
113
127
|
children: [
|
|
114
128
|
children,
|
|
115
129
|
disabledReason && /* @__PURE__ */ jsx2("span", {
|
|
@@ -5,7 +5,7 @@ import { type ComponentProps, type ReactElement } from "react";
|
|
|
5
5
|
import { Menu as MenuPrimitive } from "@base-ui/react/menu";
|
|
6
6
|
declare function MenuGroup({ ...props }: MenuPrimitive.Group.Props): ReactElement;
|
|
7
7
|
declare function MenuLabel({ density, className, inset, ...props }: MenuLabelProps): ReactElement;
|
|
8
|
-
declare function MenuItem({ analytics, density, className, inset, variant, disabledReason, children, ...props }: MenuItemProps & IAnalyticsProps): ReactElement;
|
|
8
|
+
declare function MenuItem({ analytics, density, className, inset, variant, disabledReason, onDisabledSelect, children, ...props }: MenuItemProps & IAnalyticsProps): ReactElement;
|
|
9
9
|
type MenuLinkItemProps = MenuPrimitive.LinkItem.Props & IDensityProps & IAnalyticsProps & {
|
|
10
10
|
inset?: boolean;
|
|
11
11
|
variant?: "default" | "destructive";
|
|
@@ -5,7 +5,13 @@ interface IStarRatingProps extends IDensityProps, IAnalyticsProps {
|
|
|
5
5
|
label: string;
|
|
6
6
|
value: number;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the stars take a tab stop. Turn it off where the rating is a pointer affordance of a larger keyboard
|
|
10
|
+
* target, such as a data-grid row that rates its track with its own keys.
|
|
11
|
+
*/
|
|
12
|
+
focusable?: boolean;
|
|
8
13
|
onValueChange: (value: number) => void;
|
|
9
14
|
}
|
|
10
|
-
|
|
15
|
+
/** Five stars and Unrated as one radio group; compact density draws it to fit a single-line row. */
|
|
16
|
+
export declare function StarRating({ analytics, label, value, disabled, density: densityProp, focusable, onValueChange, }: IStarRatingProps): ReactElement;
|
|
11
17
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RegenerateMenu2
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import"../../../chunk-
|
|
3
|
+
} from "../../../chunk-bv2bar22.js";
|
|
4
|
+
import"../../../chunk-tegj7xts.js";
|
|
5
5
|
import"../../../chunk-bd09gygt.js";
|
|
6
6
|
import"../../../chunk-x90xmrba.js";
|
|
7
7
|
import"../../../chunk-jpvw9xqy.js";
|
|
@@ -481,10 +481,10 @@ import {
|
|
|
481
481
|
import {
|
|
482
482
|
RecommendationCard2
|
|
483
483
|
} from "../../chunk-58cpjhsr.js";
|
|
484
|
-
import"../../chunk-
|
|
484
|
+
import"../../chunk-tegj7xts.js";
|
|
485
485
|
import {
|
|
486
486
|
RegenerateMenu2
|
|
487
|
-
} from "../../chunk-
|
|
487
|
+
} from "../../chunk-bv2bar22.js";
|
|
488
488
|
import {
|
|
489
489
|
ResearchReport2
|
|
490
490
|
} from "../../chunk-fdhssr0q.js";
|
|
@@ -6,7 +6,12 @@ interface DataGridSelectCellProps<T extends RowData> extends IDensityProps, IDat
|
|
|
6
6
|
row: DataGridRow<T>;
|
|
7
7
|
/** Names this row's selection control, such as "Select project Atlas". */
|
|
8
8
|
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the checkbox takes a tab stop. Turn it off when the row itself is the keyboard target and selects with
|
|
11
|
+
* its own keys, so each row costs one tab stop.
|
|
12
|
+
*/
|
|
13
|
+
focusable?: boolean;
|
|
9
14
|
}
|
|
10
15
|
/** Uses the row's native selection rules, including disabled and partially selected parent rows. */
|
|
11
|
-
export declare function DataGridSelectCell<T extends RowData>({ row, table, label, density, }: DataGridSelectCellProps<T>): ReactElement;
|
|
16
|
+
export declare function DataGridSelectCell<T extends RowData>({ row, table, label, density, focusable, }: DataGridSelectCellProps<T>): ReactElement;
|
|
12
17
|
export type { DataGridSelectCellProps };
|
|
@@ -592,13 +592,15 @@ function DataGridSelectCell({
|
|
|
592
592
|
row,
|
|
593
593
|
table,
|
|
594
594
|
label,
|
|
595
|
-
density
|
|
595
|
+
density,
|
|
596
|
+
focusable = true
|
|
596
597
|
}) {
|
|
597
598
|
return /* @__PURE__ */ jsx5(Subscribe5, {
|
|
598
599
|
source: table.atoms.rowSelection,
|
|
599
600
|
children: () => /* @__PURE__ */ jsx5(Checkbox2, {
|
|
600
601
|
"aria-label": label,
|
|
601
602
|
density,
|
|
603
|
+
...focusable ? {} : { tabIndex: -1 },
|
|
602
604
|
checked: row.getIsSelected(),
|
|
603
605
|
indeterminate: row.getIsSomeSelected(),
|
|
604
606
|
disabled: !row.getCanSelect(),
|
|
@@ -31,13 +31,13 @@ import {
|
|
|
31
31
|
DrawerHeader2,
|
|
32
32
|
DrawerTitle2,
|
|
33
33
|
DrawerDescription2
|
|
34
|
-
} from "../../chunk-
|
|
34
|
+
} from "../../chunk-k1jr6r51.js";
|
|
35
35
|
import {
|
|
36
36
|
MenuPopup,
|
|
37
37
|
MenuItem2,
|
|
38
38
|
DropdownMenu2,
|
|
39
39
|
DropdownMenuTrigger2
|
|
40
|
-
} from "../../chunk-
|
|
40
|
+
} from "../../chunk-tegj7xts.js";
|
|
41
41
|
import {
|
|
42
42
|
Alert2,
|
|
43
43
|
AlertTitle2,
|
|
@@ -10,7 +10,10 @@ type TreeProps<T> = IAnalyticsProps & IDensityProps & {
|
|
|
10
10
|
renderLabel?: (item: ItemInstance<T>) => ReactNode;
|
|
11
11
|
renderItem?: (item: ItemInstance<T>) => ReactNode;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Headless Tree owns navigation, selection, expansion, and optional pointer/keyboard drag and drop. The tree is one Tab
|
|
15
|
+
* stop: arrows move between items, and row controls stay out of the Tab order.
|
|
16
|
+
*/
|
|
14
17
|
declare function Tree<T>({ analytics, tree, label, variant, renderIcon, renderLabel, renderItem, density, }: TreeProps<T>): ReactElement;
|
|
15
18
|
export { Tree };
|
|
16
19
|
export type { TreeProps };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IAnalyticsProps } from "../../analytics/types.js";
|
|
2
2
|
import { useRender } from "@base-ui/react/use-render";
|
|
3
3
|
import type { ItemInstance } from "@headless-tree/core";
|
|
4
|
-
import type { ReactElement, ReactNode } from "react";
|
|
4
|
+
import type { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
5
|
import type { IDensityProps } from "../../density/types.js";
|
|
6
|
+
import { Button } from "../Button.js";
|
|
6
7
|
type TreeItemState = {
|
|
7
8
|
slot: "tree-item";
|
|
8
9
|
selected: boolean;
|
|
@@ -28,7 +29,29 @@ type TreeItemProps<T> = useRender.ComponentProps<"div", TreeItemState> & IDensit
|
|
|
28
29
|
open: boolean;
|
|
29
30
|
side?: "top" | "right" | "bottom" | "left";
|
|
30
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Secondary text at the row's end, such as a count. It is the item's accessible description, never part of its
|
|
34
|
+
* name, so names stay stable for typeahead, drag announcements and tests.
|
|
35
|
+
*/
|
|
36
|
+
description?: ReactNode;
|
|
37
|
+
/** Spoken description when the visible `description` is terse, such as "12 tracks" for "12". */
|
|
38
|
+
descriptionLabel?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Pointer shortcuts at the row's end, such as a ⋯ menu trigger, each rendered as a `TreeItemAction`. A tree is one
|
|
41
|
+
* Tab stop whose items carry their own keys (arrows, Enter, Shift+F10 and the Menu key), so actions stay out of the
|
|
42
|
+
* Tab order and the accessibility tree, and the tree owns only tree items.
|
|
43
|
+
*/
|
|
44
|
+
actions?: ReactNode;
|
|
31
45
|
};
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
type TreeItemActionProps = ComponentProps<typeof Button>;
|
|
47
|
+
/**
|
|
48
|
+
* A row's pointer shortcut for a command its item also offers through keys. It is never a Tab stop, including when a
|
|
49
|
+
* menu trigger renders it, so the tree keeps one Tab stop.
|
|
50
|
+
*/
|
|
51
|
+
export declare function TreeItemAction({ variant, size, ...props }: TreeItemActionProps): ReactElement;
|
|
52
|
+
/**
|
|
53
|
+
* Registered tree row; compose menus with render, put counts in `description` and pointer shortcuts in `actions`.
|
|
54
|
+
* `endEnhancer` holds controls that must stay keyboard reachable on their own.
|
|
55
|
+
*/
|
|
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;
|
|
34
57
|
export type { TreeItemProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Tree } from "./Tree.js";
|
|
2
|
-
export { TreeItem } from "./TreeItem.js";
|
|
2
|
+
export { TreeItem, TreeItemAction } 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";
|
|
@@ -22,8 +22,22 @@ import {
|
|
|
22
22
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
23
23
|
import { useRender } from "@base-ui/react/use-render";
|
|
24
24
|
import { ChevronRightIcon, FileIcon, FolderIcon, FolderOpenIcon } from "lucide-react";
|
|
25
|
-
import { useId } from "react";
|
|
25
|
+
import { use, useId } from "react";
|
|
26
|
+
|
|
27
|
+
// src/components/tree/TreeTabStopContext.ts
|
|
28
|
+
import { createContext } from "react";
|
|
29
|
+
var TreeTabStopContext = createContext(undefined);
|
|
30
|
+
|
|
31
|
+
// src/components/tree/TreeItem.tsx
|
|
26
32
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
33
|
+
function TreeItemAction({ variant = "ghost", size = "icon-xs", ...props }) {
|
|
34
|
+
return /* @__PURE__ */ jsx(Button2, {
|
|
35
|
+
variant,
|
|
36
|
+
size,
|
|
37
|
+
...props,
|
|
38
|
+
tabIndex: -1
|
|
39
|
+
});
|
|
40
|
+
}
|
|
27
41
|
function isRowControl(event) {
|
|
28
42
|
return event.target !== event.currentTarget && event.target instanceof Element && Boolean(event.target.closest("a,button,input,textarea,select,form"));
|
|
29
43
|
}
|
|
@@ -33,6 +47,9 @@ function TreeItem({
|
|
|
33
47
|
children,
|
|
34
48
|
startEnhancer,
|
|
35
49
|
endEnhancer,
|
|
50
|
+
description,
|
|
51
|
+
descriptionLabel,
|
|
52
|
+
actions,
|
|
36
53
|
expandOn = "click",
|
|
37
54
|
isEditing = false,
|
|
38
55
|
isDropTarget = false,
|
|
@@ -44,7 +61,16 @@ function TreeItem({
|
|
|
44
61
|
ref,
|
|
45
62
|
...props
|
|
46
63
|
}) {
|
|
47
|
-
const
|
|
64
|
+
const tabStop = use(TreeTabStopContext);
|
|
65
|
+
const descriptionId = useId();
|
|
66
|
+
const hasDescription = description !== undefined && description !== null || Boolean(descriptionLabel);
|
|
67
|
+
const registered = item.getProps();
|
|
68
|
+
const nativeProps = {
|
|
69
|
+
...registered,
|
|
70
|
+
...tabStop === undefined ? {} : { tabIndex: item.getId() === tabStop ? 0 : -1 },
|
|
71
|
+
"aria-label": endEnhancer || isEditing ? registered["aria-label"] : undefined,
|
|
72
|
+
"aria-describedby": hasDescription ? descriptionId : undefined
|
|
73
|
+
};
|
|
48
74
|
const hintId = useId();
|
|
49
75
|
const activate = useAnalyticsCallback("TreeItem", analytics, { name: "ui.activate" }, undefined);
|
|
50
76
|
const isExpanded = item.isExpanded();
|
|
@@ -117,6 +143,10 @@ function TreeItem({
|
|
|
117
143
|
props: mergeProps({
|
|
118
144
|
...linkProps && !isEditing ? {} : nativeProps,
|
|
119
145
|
ref: undefined,
|
|
146
|
+
onFocus: (event) => {
|
|
147
|
+
if (event.target === event.currentTarget && item.getTree().getState().focusedItem !== item.getId())
|
|
148
|
+
item.setFocused();
|
|
149
|
+
},
|
|
120
150
|
onKeyDown: (event) => {
|
|
121
151
|
if (event.target !== event.currentTarget || event.defaultPrevented || event.key !== "Enter" || event.repeat || item.getTree().getState().dnd)
|
|
122
152
|
return;
|
|
@@ -154,8 +184,10 @@ function TreeItem({
|
|
|
154
184
|
item.isFolder() && expandOn === "disclosure" ? /* @__PURE__ */ jsx(Button2, {
|
|
155
185
|
variant: "plain",
|
|
156
186
|
size: "icon-xs",
|
|
187
|
+
tabIndex: -1,
|
|
188
|
+
"aria-hidden": "true",
|
|
157
189
|
"aria-label": `${isExpanded ? "Collapse" : "Expand"} ${item.getItemName()}`,
|
|
158
|
-
|
|
190
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
159
191
|
onClick: (event) => {
|
|
160
192
|
event.stopPropagation();
|
|
161
193
|
toggle();
|
|
@@ -178,6 +210,31 @@ function TreeItem({
|
|
|
178
210
|
onDoubleClick: (event) => event.stopPropagation(),
|
|
179
211
|
onKeyDown: (event) => event.stopPropagation(),
|
|
180
212
|
children: endEnhancer
|
|
213
|
+
}),
|
|
214
|
+
(hasDescription || actions) && /* @__PURE__ */ jsxs("div", {
|
|
215
|
+
className: "flex shrink-0 items-center gap-1 text-xs tabular-nums",
|
|
216
|
+
children: [
|
|
217
|
+
description !== undefined && description !== null && /* @__PURE__ */ jsx("span", {
|
|
218
|
+
"aria-hidden": "true",
|
|
219
|
+
id: descriptionLabel ? undefined : descriptionId,
|
|
220
|
+
"data-slot": "tree-item-description",
|
|
221
|
+
children: description
|
|
222
|
+
}),
|
|
223
|
+
descriptionLabel && /* @__PURE__ */ jsx("span", {
|
|
224
|
+
id: descriptionId,
|
|
225
|
+
hidden: true,
|
|
226
|
+
children: descriptionLabel
|
|
227
|
+
}),
|
|
228
|
+
actions && /* @__PURE__ */ jsx("div", {
|
|
229
|
+
"aria-hidden": "true",
|
|
230
|
+
"data-slot": "tree-item-actions",
|
|
231
|
+
className: "flex items-center gap-1",
|
|
232
|
+
onClick: (event) => event.stopPropagation(),
|
|
233
|
+
onDoubleClick: (event) => event.stopPropagation(),
|
|
234
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
235
|
+
children: actions
|
|
236
|
+
})
|
|
237
|
+
]
|
|
181
238
|
})
|
|
182
239
|
]
|
|
183
240
|
})
|
|
@@ -209,6 +266,10 @@ function TreeItem({
|
|
|
209
266
|
|
|
210
267
|
// src/components/tree/Tree.tsx
|
|
211
268
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
269
|
+
function tabStopId(items, focusedId) {
|
|
270
|
+
const focused = focusedId == null ? undefined : items.find((item) => item.getId() === focusedId);
|
|
271
|
+
return (focused ?? items.find((item) => item.isSelected?.()) ?? items.at(0))?.getId();
|
|
272
|
+
}
|
|
212
273
|
function Tree({
|
|
213
274
|
analytics,
|
|
214
275
|
tree,
|
|
@@ -223,37 +284,41 @@ function Tree({
|
|
|
223
284
|
const container = tree.getContainerProps(label);
|
|
224
285
|
const dragLine = tree.getDragLineData?.();
|
|
225
286
|
const element = tree.getElement();
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
287
|
+
const items = tree.getItems();
|
|
288
|
+
return /* @__PURE__ */ jsx2(TreeTabStopContext, {
|
|
289
|
+
value: tabStopId(items, tree.getState().focusedItem),
|
|
290
|
+
children: /* @__PURE__ */ jsxs2("div", {
|
|
291
|
+
...container,
|
|
292
|
+
"data-density": density,
|
|
293
|
+
className: cn2("grid min-w-0 grid-cols-1 gap-1", variant === "default" && "rounded-sm border border-border bg-card p-2"),
|
|
294
|
+
onKeyDown: (event) => {
|
|
295
|
+
if (event.target instanceof Element && event.target.closest("input,textarea,select,form,button,[role=menu]"))
|
|
296
|
+
return;
|
|
297
|
+
if (event.defaultPrevented)
|
|
298
|
+
return;
|
|
299
|
+
container.onKeyDown?.(event);
|
|
300
|
+
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End", "Enter", " "].includes(event.key)) {
|
|
301
|
+
track({ name: "ui.navigate" }, event.nativeEvent);
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
children: [
|
|
305
|
+
items.map((item) => renderItem ? /* @__PURE__ */ jsx2("div", {
|
|
306
|
+
role: "none",
|
|
307
|
+
children: renderItem(item)
|
|
308
|
+
}, item.getKey()) : /* @__PURE__ */ jsx2(TreeItem, {
|
|
309
|
+
item,
|
|
310
|
+
startEnhancer: renderIcon?.(item),
|
|
311
|
+
density,
|
|
312
|
+
children: renderLabel?.(item)
|
|
313
|
+
}, item.getKey())),
|
|
314
|
+
dragLine && /* @__PURE__ */ jsx2("span", {
|
|
315
|
+
"data-slot": "tree-drop-indicator",
|
|
316
|
+
"aria-hidden": "true",
|
|
317
|
+
className: "pointer-events-none absolute h-0.5 bg-primary",
|
|
318
|
+
style: tree.getDragLineStyle(-1 - (element?.clientTop ?? 0), -(element?.clientLeft ?? 0))
|
|
319
|
+
})
|
|
320
|
+
]
|
|
321
|
+
})
|
|
257
322
|
});
|
|
258
323
|
}
|
|
259
324
|
// node_modules/@headless-tree/react/dist/chunk-FWCSY2DS.mjs
|
|
@@ -2479,6 +2544,7 @@ export {
|
|
|
2479
2544
|
AssistiveTreeDescription,
|
|
2480
2545
|
Tree,
|
|
2481
2546
|
TreeItem,
|
|
2547
|
+
TreeItemAction,
|
|
2482
2548
|
asyncDataLoaderFeature,
|
|
2483
2549
|
checkboxesFeature,
|
|
2484
2550
|
dragAndDropFeature,
|
package/dist/index.js
CHANGED
|
@@ -173,7 +173,7 @@ import {
|
|
|
173
173
|
StatusTracker2,
|
|
174
174
|
DashboardLayout2,
|
|
175
175
|
BillingUsage2
|
|
176
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-k1jr6r51.js";
|
|
177
177
|
import {
|
|
178
178
|
Combobox2,
|
|
179
179
|
ComboboxValue2,
|
|
@@ -242,7 +242,7 @@ import {
|
|
|
242
242
|
MenuShortcut2,
|
|
243
243
|
DropdownMenu2,
|
|
244
244
|
DropdownMenuTrigger2
|
|
245
|
-
} from "./chunk-
|
|
245
|
+
} from "./chunk-tegj7xts.js";
|
|
246
246
|
import {
|
|
247
247
|
Empty2,
|
|
248
248
|
EmptyHeader2,
|
package/dist/menu/types.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ interface IMenuItemOptions extends IMenuInsetProps {
|
|
|
10
10
|
* the item references through `aria-describedby`.
|
|
11
11
|
*/
|
|
12
12
|
disabledReason?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Runs once for each Enter, Space or click on an item disabled by `disabledReason`, so the consumer can announce the
|
|
15
|
+
* reason. The item still does nothing and the menu stays open; held keys do not repeat it.
|
|
16
|
+
*/
|
|
17
|
+
onDisabledSelect?: () => void;
|
|
13
18
|
}
|
|
14
19
|
export type MenuLabelProps = Menu.GroupLabel.Props & IMenuInsetProps;
|
|
15
20
|
export type MenuItemProps = Menu.Item.Props & IMenuItemOptions;
|
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.77",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact and comfortable densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -3157,6 +3157,7 @@ var package_default = {
|
|
|
3157
3157
|
"@vitest/coverage-istanbul": "4.1.11",
|
|
3158
3158
|
"@vitest/coverage-v8": "^4.1.6",
|
|
3159
3159
|
anser: "2.3.5",
|
|
3160
|
+
"axe-core": "4.14.0",
|
|
3160
3161
|
"beautiful-mermaid": "^1.1.3",
|
|
3161
3162
|
bun: "1.4.2",
|
|
3162
3163
|
"bun-plugin-tailwind": "^0.1.2",
|
|
@@ -26,3 +26,11 @@ DataGridSelectCell
|
|
|
26
26
|
## Examples
|
|
27
27
|
|
|
28
28
|
Storybook CSF excerpts. Default args and render apply unless overridden. Local helpers, fixtures, decorators, and providers may be required; these are reference excerpts, not standalone consumer modules. Interaction tests are omitted.
|
|
29
|
+
|
|
30
|
+
### OutsideTabOrder
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
{
|
|
34
|
+
render: () => <SelectionControls focusable={false}/>
|
|
35
|
+
}
|
|
36
|
+
```
|
|
@@ -51,6 +51,30 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
51
51
|
{}
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
### Compact
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
{
|
|
58
|
+
args: { density: "compact" }
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### OutsideTabOrder
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
{
|
|
66
|
+
args: { focusable: false },
|
|
67
|
+
render: function Example(args): ReactElement {
|
|
68
|
+
const [value, setValue] = useState(args.value);
|
|
69
|
+
return (<div className="flex items-center gap-2">
|
|
70
|
+
<button type="button">Before</button>
|
|
71
|
+
<StarRating {...args} value={value} onValueChange={setValue}/>
|
|
72
|
+
<button type="button">After</button>
|
|
73
|
+
</div>);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
54
78
|
### Disabled
|
|
55
79
|
|
|
56
80
|
```tsx
|
|
@@ -607,6 +607,7 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
607
607
|
{
|
|
608
608
|
render: function Render() {
|
|
609
609
|
const [action, setAction] = useState("None");
|
|
610
|
+
const [announcements, setAnnouncements] = useState<string[]>([]);
|
|
610
611
|
return (<>
|
|
611
612
|
<DropdownMenu>
|
|
612
613
|
<DropdownMenuTrigger render={<Button variant="outline"/>}>Track actions</DropdownMenuTrigger>
|
|
@@ -616,7 +617,7 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
616
617
|
<FileIcon />
|
|
617
618
|
Edit track info…
|
|
618
619
|
</DropdownMenuItem>
|
|
619
|
-
<DropdownMenuItem disabledReason="One track only" onClick={() => setAction("Move")}>
|
|
620
|
+
<DropdownMenuItem disabledReason="One track only" onClick={() => setAction("Move")} onDisabledSelect={() => setAnnouncements((current) => [...current, "One track only"])}>
|
|
620
621
|
<SaveIcon />
|
|
621
622
|
Move audio file…
|
|
622
623
|
</DropdownMenuItem>
|
|
@@ -625,6 +626,7 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
625
626
|
</DropdownMenuContent>
|
|
626
627
|
</DropdownMenu>
|
|
627
628
|
<output aria-label="Menu action">{action}</output>
|
|
629
|
+
<output aria-label="Announcements">{announcements.join(" | ")}</output>
|
|
628
630
|
</>);
|
|
629
631
|
}
|
|
630
632
|
}
|
|
@@ -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, useTree, syncDataLoaderFeature, hotkeysCoreFeature, selectionFeature } from "@alexgorbatchev/shadcn/tree";
|
|
11
|
+
import { Tree, TreeItem, TreeItemAction, 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
|
|
package/llms/setup.md
CHANGED
|
@@ -456,6 +456,8 @@ For nested layouts, compose `ActionsMenuTrigger`, `ActionsMenuContextTarget`, an
|
|
|
456
456
|
|
|
457
457
|
`TreeItem linkProps` places the registered tree item, roving focus, and native drag handlers on an anchor. Pass `href` and anchor events directly, or compose a router link through `linkProps.render`. The outer `render` and `ref` remain available for row overlays; disclosure and `endEnhancer` controls remain siblings of the link. Enter and modified clicks retain native link behavior, while tree arrows retain navigation and expansion behavior. Optional `dropHint={{ content, open, side }}` displays caller-controlled drag feedback without adding a focus target. `isDimmed` fades a settled row, such as completed work, to 70% opacity and exposes `data-dimmed`; hovering or focusing anything in the row restores full opacity, and the row stays interactive.
|
|
458
458
|
|
|
459
|
+
A `Tree` is one Tab stop: Tab reaches the focused item while it is visible, else the first selected item, else the first item, and the arrow keys move from there. Disclosure buttons are pointer targets outside the Tab order and the accessibility tree; the item's `aria-expanded` and the arrow keys carry the same state. Put secondary text such as a count in `description`, which the item exposes through `aria-describedby` instead of its name, with `descriptionLabel` when the spoken text differs ("12 tracks" for "12"). Put pointer shortcuts such as a ⋯ menu trigger in `actions`, each rendered as a `TreeItemAction` (including as a menu trigger's `render`): they stay out of the Tab order and the accessibility tree, so give the item a keyboard path to the same commands, such as Shift+F10 and the Menu key. Rows without an `endEnhancer` take their name from their visible label; `endEnhancer` keeps controls that must remain keyboard reachable on their own, and those rows keep the item name as their label.
|
|
460
|
+
|
|
459
461
|
Embedded actions, links, menus, editable fields, and media controls retain their own keyboard behavior. Registered anchor and button rows still participate in tree navigation; rename and search inputs retain their completion and cancellation shortcuts.
|
|
460
462
|
|
|
461
463
|
`PageHeader` accepts an optional `eyebrow` above its single page title. It accepts any React content without introducing another heading. Breadcrumbs, description, actions, and density remain independent slots; long action content wraps within narrow layouts.
|
|
@@ -578,7 +580,7 @@ The preview shows compact individual badges, up to five labels followed by `+N m
|
|
|
578
580
|
|
|
579
581
|
# Devhost Preview
|
|
580
582
|
|
|
581
|
-
The routed preview serves Storybook at `shadcn.localhost` through devhost.
|
|
583
|
+
The routed preview serves Storybook at `shadcn.localhost` through devhost v0.0.14 or newer. The manifest names its services with the bare host labels `shadcn` and `shadcn-snapshots`, and devhost's machine configuration supplies the domain: a custom `domainSuffix` changes the hostname, and a machine enrolled in [remote previews](https://alexgorbatchev.github.io/devhost/stacks/remote-previews/) serves the preview through its relay.
|
|
582
584
|
|
|
583
585
|
From this repository, start the configured Storybook service:
|
|
584
586
|
|
|
@@ -586,9 +588,9 @@ From this repository, start the configured Storybook service:
|
|
|
586
588
|
just run
|
|
587
589
|
```
|
|
588
590
|
|
|
589
|
-
`just run`
|
|
591
|
+
`just run` starts the preview in the background and passes its arguments to `devhost start --detach`; `just run --local` keeps local routing on a machine enrolled in remote previews.
|
|
590
592
|
|
|
591
|
-
Open the hostname printed by devhost over HTTPS. The manifest allocates a port automatically and serves Storybook through the shared devhost HTTPS proxy.
|
|
593
|
+
Open the hostname printed by devhost over HTTPS. The manifest allocates a port automatically and serves Storybook through the shared devhost HTTPS proxy. For local routing, the hostname must resolve to the machine running devhost; `.localhost` names need no DNS setup. The managed Caddy instance must be running (`devhost caddy start`).
|
|
592
594
|
|
|
593
595
|
Storybook binds to IPv4 loopback and allows the configured hostname in both Storybook and Vite. Caddy listens on all interfaces and serves HTTP as well as HTTPS, so the external devbox gateway can reach it. The direct `just storybook` preview remains available on `127.0.0.1:6006`.
|
|
594
596
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexgorbatchev/shadcn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
4
4
|
"description": "Sharp, monospace React components with compact and comfortable densities.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -1106,6 +1106,7 @@
|
|
|
1106
1106
|
"@vitest/coverage-istanbul": "4.1.11",
|
|
1107
1107
|
"@vitest/coverage-v8": "^4.1.6",
|
|
1108
1108
|
"anser": "2.3.5",
|
|
1109
|
+
"axe-core": "4.14.0",
|
|
1109
1110
|
"beautiful-mermaid": "^1.1.3",
|
|
1110
1111
|
"bun": "1.4.2",
|
|
1111
1112
|
"bun-plugin-tailwind": "^0.1.2",
|