@alexgorbatchev/shadcn 0.0.144 → 0.0.146
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 +3 -1
- package/dist/components/tree/TreeSelect.d.ts +35 -0
- package/dist/components/tree/index.d.ts +2 -0
- package/dist/components/tree/index.js +142 -0
- package/dist/components/virtual-data-grid/index.js +45 -9
- package/dist/prototype.js +1 -1
- package/llms/components/navigation/TreeSelect.md +68 -0
- package/llms/setup.md +3 -1
- package/llms.txt +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ Import shared controls and providers from `@alexgorbatchev/shadcn`. Import the f
|
|
|
73
73
|
| `/image-crop` | ImageCrop and native export helpers | `bun add react-image-crop@^11.1.2` |
|
|
74
74
|
| `/image-viewer` | ImageViewer, ImageZoomToggle, ImageComparison, and image helpers | Existing core peers |
|
|
75
75
|
| `/text-diff` | TextDiff: two versions of a text as a line diff | `bun add diff@9.0.0 parse-diff@0.12.0` |
|
|
76
|
-
| `/tree` | Tree, native hooks and features
|
|
76
|
+
| `/tree` | Tree, TreeSelect, native hooks and features | `bun add @headless-tree/core@^1.8.0 @headless-tree/react@^1.8.0`; patched runtimes are bundled |
|
|
77
77
|
| `/editor` | RichTextEditor, native Tiptap hooks and StarterKit | `bun add @tiptap/core@^3.32.0 @tiptap/react@^3.32.0 @tiptap/pm@^3.32.0 @tiptap/starter-kit@^3.32.0` |
|
|
78
78
|
| `/event-calendar` | EventCalendar, EventForm and native calendar APIs | `bun add date-fns@^4.4.0`; TypeScript: `bun add -d @types/react-big-calendar@^1.16.3` |
|
|
79
79
|
| `/gantt` | Gantt and Roadmap | `bun add date-fns@^4.4.0 @date-fns/tz@^1.5.0` |
|
|
@@ -548,6 +548,8 @@ function Screenshot({ src, onPick }: { src: string; onPick: (point: INormalizedI
|
|
|
548
548
|
|
|
549
549
|
"Highlight differences" draws both images at the after image's natural size and compares premultiplied channels against a threshold. Changed pixels are aggregated into 16px cells and connected regions, outlined with the warning token over the after image (toggle and swipe) or both panes (side-by-side), and summarized as "3 changed regions" or "No visible differences". The comparison runs in time-boxed slices that yield to the browser and is cached per image pair for the component's lifetime. When pixels cannot be read, such as a cross-origin image served without CORS or an image that failed to decode, the switch is disabled and the reason is shown. Pass `crossOrigin: "anonymous"` only when the image server sends CORS headers. `computeImageDiff(before, after, options)` exposes the same pure comparison for equally sized `ImageData`.
|
|
550
550
|
|
|
551
|
+
`TreeSelect` (`@alexgorbatchev/shadcn/tree`) chooses one place in a hierarchy, such as a destination folder. Pass `nodes` (`{ id, label, children?, disabledReason? }`), the chosen `value` and `onValueChange`, and `label` to name the tree. A filter (named by `filterLabel`, default "Filter") keeps every node whose name matches, with its ancestors; `emptyLabel` (default "No matches") shows when nothing does. ↓ in the filter enters the tree, which is one Tab stop: arrows move and expand, and Enter, Space or a click chooses. `currentId` marks where the item sits now with `currentLabel` (default "Current location") as the row description; a node with `disabledReason`, such as "Archived", stays listed, faded and `aria-disabled` with its reason as the description, and is never chosen. `isDisabled` disables the filter and choosing.
|
|
552
|
+
|
|
551
553
|
`TextDiff` (`@alexgorbatchev/shadcn/text-diff`) shows two versions of a text, `before` and `after`, as a line diff labelled by `beforeLabel` and `afterLabel` (default "Before" and "After"). Removed lines carry "-" and added lines "+" in a sign gutter as well as colour, and use `del` and `ins`; long lines wrap, so the diff never scrolls sideways. Unchanged runs further than `contextLines` (default 3) from a change fold behind a "Show N unchanged lines" button that toggles them with `aria-expanded`. `viewMode` is `"auto"` (default), `"unified"`, or `"split"`; auto shows the versions side by side once the diff's own width reaches `splitMinWidth` (default 560 px) and stacked below it, and stacked before the first measurement. A missing final newline is not shown as a change. `showLineNumbers` defaults to true.
|
|
552
554
|
|
|
553
555
|
The toolbar holds the mode, orientation (enabled for side-by-side), zoom, hold-to-show-before (enabled for toggle), and highlight controls with the legend and status. It sits beside a comparison at least 48rem wide and wraps below narrower ones; `showToolbar={false}` hides it, leaving consumers to control the props themselves.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
/** A place a `TreeSelect` offers, with the places inside it. */
|
|
3
|
+
export interface ITreeSelectNode {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
children?: readonly ITreeSelectNode[] | undefined;
|
|
7
|
+
/** Why this place cannot be chosen, such as "Archived": it stays listed, reachable and described, but not choosable. */
|
|
8
|
+
disabledReason?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface ITreeSelectProps {
|
|
11
|
+
nodes: readonly ITreeSelectNode[];
|
|
12
|
+
/** The chosen node's id, or null while nothing is chosen. */
|
|
13
|
+
value: string | null;
|
|
14
|
+
/** Called with a node chosen by click, Enter or Space; nodes with a `disabledReason` are never chosen. */
|
|
15
|
+
onValueChange: (id: string) => void;
|
|
16
|
+
/** Names the tree, such as "Destination". */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Names the filter field; defaults to "Filter". */
|
|
19
|
+
filterLabel?: string | undefined;
|
|
20
|
+
filterPlaceholder?: string | undefined;
|
|
21
|
+
/** The node where the item sits now, marked with `currentLabel`. */
|
|
22
|
+
currentId?: string | undefined;
|
|
23
|
+
/** Defaults to "Current location". */
|
|
24
|
+
currentLabel?: string | undefined;
|
|
25
|
+
/** Shown when the filter matches nothing; defaults to "No matches". */
|
|
26
|
+
emptyLabel?: string | undefined;
|
|
27
|
+
isDisabled?: boolean | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Chooses one place in a hierarchy, such as a destination folder: a filter that matches any node's name and keeps its
|
|
31
|
+
* ancestors in view, above a tree that is one Tab stop. ↓ in the filter enters the tree; arrows move and expand; Enter,
|
|
32
|
+
* Space or a click chooses. The current place carries `currentLabel`, and places that cannot be chosen stay listed with
|
|
33
|
+
* their reason as the row's description.
|
|
34
|
+
*/
|
|
35
|
+
export declare function TreeSelect({ nodes, value, onValueChange, label, filterLabel, filterPlaceholder, currentId, currentLabel, emptyLabel, isDisabled, }: ITreeSelectProps): ReactElement;
|
|
@@ -5,3 +5,5 @@ 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";
|
|
8
|
+
export { TreeSelect } from "./TreeSelect.js";
|
|
9
|
+
export type { ITreeSelectNode, ITreeSelectProps } from "./TreeSelect.js";
|
|
@@ -17,6 +17,10 @@ import {
|
|
|
17
17
|
TooltipContent2,
|
|
18
18
|
Button2
|
|
19
19
|
} from "../../chunk-2sx8m8b2.js";
|
|
20
|
+
import"../../chunk-7jpsybag.js";
|
|
21
|
+
import {
|
|
22
|
+
Input2
|
|
23
|
+
} from "../../chunk-7vg045gd.js";
|
|
20
24
|
import {
|
|
21
25
|
useAnalyticsCallback
|
|
22
26
|
} from "../../chunk-5mydsjp3.js";
|
|
@@ -2624,6 +2628,143 @@ var useTree = (config) => {
|
|
|
2624
2628
|
}));
|
|
2625
2629
|
return tree.current;
|
|
2626
2630
|
};
|
|
2631
|
+
// src/components/tree/TreeSelect.tsx
|
|
2632
|
+
import { useEffect as useEffect2, useId as useId2, useMemo, useState as useState2 } from "react";
|
|
2633
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2634
|
+
var ROOT_ID = "tree-select-root";
|
|
2635
|
+
function indexNodes(nodes, parentId, index) {
|
|
2636
|
+
for (const node of nodes) {
|
|
2637
|
+
index.set(node.id, { node, parentId });
|
|
2638
|
+
indexNodes(node.children ?? [], node.id, index);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
function getVisibleIds(index, filter) {
|
|
2642
|
+
const query = filter.trim().toLocaleLowerCase();
|
|
2643
|
+
const visible = new Set;
|
|
2644
|
+
for (const [id, { node }] of index) {
|
|
2645
|
+
if (query && !node.label.toLocaleLowerCase().includes(query))
|
|
2646
|
+
continue;
|
|
2647
|
+
let current = id;
|
|
2648
|
+
while (current && current !== ROOT_ID && !visible.has(current)) {
|
|
2649
|
+
visible.add(current);
|
|
2650
|
+
current = index.get(current)?.parentId;
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
return visible;
|
|
2654
|
+
}
|
|
2655
|
+
function TreeSelect({
|
|
2656
|
+
nodes,
|
|
2657
|
+
value,
|
|
2658
|
+
onValueChange,
|
|
2659
|
+
label,
|
|
2660
|
+
filterLabel = "Filter",
|
|
2661
|
+
filterPlaceholder,
|
|
2662
|
+
currentId,
|
|
2663
|
+
currentLabel = "Current location",
|
|
2664
|
+
emptyLabel = "No matches",
|
|
2665
|
+
isDisabled = false
|
|
2666
|
+
}) {
|
|
2667
|
+
const filterId = useId2();
|
|
2668
|
+
const [filter, setFilter] = useState2("");
|
|
2669
|
+
const index = useMemo(() => {
|
|
2670
|
+
const result = new Map;
|
|
2671
|
+
indexNodes(nodes, ROOT_ID, result);
|
|
2672
|
+
return result;
|
|
2673
|
+
}, [nodes]);
|
|
2674
|
+
const visible = useMemo(() => getVisibleIds(index, filter), [index, filter]);
|
|
2675
|
+
const [collapsed, setCollapsed] = useState2(() => new Set);
|
|
2676
|
+
const getChildren = (id) => (id === ROOT_ID ? nodes : index.get(id)?.node.children ?? []).map((child) => child.id).filter((child) => visible.has(child));
|
|
2677
|
+
const parents = useMemo(() => [...index.values()].filter(({ node }) => (node.children?.length ?? 0) > 0).map(({ node }) => node.id), [index]);
|
|
2678
|
+
const isFiltering = filter.trim() !== "";
|
|
2679
|
+
const expandedItems = useMemo(() => parents.filter((id) => isFiltering || !collapsed.has(id)), [parents, isFiltering, collapsed]);
|
|
2680
|
+
const selectedItems = useMemo(() => value ? [value] : [], [value]);
|
|
2681
|
+
const choose = (id) => {
|
|
2682
|
+
if (isDisabled || index.get(id)?.node.disabledReason)
|
|
2683
|
+
return;
|
|
2684
|
+
onValueChange(id);
|
|
2685
|
+
};
|
|
2686
|
+
const tree = useTree({
|
|
2687
|
+
rootItemId: ROOT_ID,
|
|
2688
|
+
getItemName: (item) => item.getItemData().label,
|
|
2689
|
+
isItemFolder: (item) => getChildren(item.getId()).length > 0,
|
|
2690
|
+
dataLoader: {
|
|
2691
|
+
getItem: (id) => index.get(id)?.node ?? { id: ROOT_ID, label },
|
|
2692
|
+
getChildren
|
|
2693
|
+
},
|
|
2694
|
+
initialState: { focusedItem: value },
|
|
2695
|
+
state: { expandedItems, selectedItems },
|
|
2696
|
+
setExpandedItems: (next) => {
|
|
2697
|
+
const expanded = typeof next === "function" ? next(expandedItems) : next;
|
|
2698
|
+
const nextCollapsed = parents.filter((id) => !expanded.includes(id));
|
|
2699
|
+
if (nextCollapsed.length !== collapsed.size || nextCollapsed.some((id) => !collapsed.has(id)))
|
|
2700
|
+
setCollapsed(new Set(nextCollapsed));
|
|
2701
|
+
},
|
|
2702
|
+
setSelectedItems: () => {
|
|
2703
|
+
return;
|
|
2704
|
+
},
|
|
2705
|
+
onPrimaryAction: (item) => choose(item.getId()),
|
|
2706
|
+
features: [syncDataLoaderFeature, hotkeysCoreFeature, selectionFeature]
|
|
2707
|
+
});
|
|
2708
|
+
const visibleKey = [...visible].join(`
|
|
2709
|
+
`);
|
|
2710
|
+
useEffect2(() => {
|
|
2711
|
+
tree.rebuildTree();
|
|
2712
|
+
}, [tree, visibleKey]);
|
|
2713
|
+
const hasItems = visible.size > 0;
|
|
2714
|
+
return /* @__PURE__ */ jsxs3("div", {
|
|
2715
|
+
"data-testid": "TreeSelect",
|
|
2716
|
+
"data-slot": "tree-select",
|
|
2717
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
2718
|
+
children: [
|
|
2719
|
+
/* @__PURE__ */ jsx3(Input2, {
|
|
2720
|
+
id: filterId,
|
|
2721
|
+
type: "search",
|
|
2722
|
+
"aria-label": filterLabel,
|
|
2723
|
+
placeholder: filterPlaceholder,
|
|
2724
|
+
value: filter,
|
|
2725
|
+
disabled: isDisabled,
|
|
2726
|
+
autoComplete: "off",
|
|
2727
|
+
onChange: (event) => setFilter(event.target.value),
|
|
2728
|
+
onKeyDown: (event) => {
|
|
2729
|
+
if (event.key !== "ArrowDown")
|
|
2730
|
+
return;
|
|
2731
|
+
const target = tree.getItems().find((item) => item.getId() === tree.getState().focusedItem) ?? tree.getItems().at(0);
|
|
2732
|
+
if (!target)
|
|
2733
|
+
return;
|
|
2734
|
+
event.preventDefault();
|
|
2735
|
+
target.setFocused();
|
|
2736
|
+
target.getElement()?.focus();
|
|
2737
|
+
}
|
|
2738
|
+
}),
|
|
2739
|
+
hasItems ? /* @__PURE__ */ jsx3(Tree, {
|
|
2740
|
+
tree,
|
|
2741
|
+
label,
|
|
2742
|
+
renderItem: (item) => {
|
|
2743
|
+
const node = item.getItemData();
|
|
2744
|
+
const description = node.disabledReason ?? (node.id === currentId ? currentLabel : undefined);
|
|
2745
|
+
return /* @__PURE__ */ jsx3(TreeItem, {
|
|
2746
|
+
item,
|
|
2747
|
+
expandOn: "disclosure",
|
|
2748
|
+
description,
|
|
2749
|
+
isDimmed: Boolean(node.disabledReason),
|
|
2750
|
+
"aria-disabled": node.disabledReason || isDisabled ? true : undefined,
|
|
2751
|
+
"data-current": node.id === currentId ? "" : undefined,
|
|
2752
|
+
onKeyDown: (event) => {
|
|
2753
|
+
if (event.key !== " ")
|
|
2754
|
+
return;
|
|
2755
|
+
event.preventDefault();
|
|
2756
|
+
choose(item.getId());
|
|
2757
|
+
}
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2760
|
+
}) : /* @__PURE__ */ jsx3("p", {
|
|
2761
|
+
role: "status",
|
|
2762
|
+
className: "px-2 py-3 text-sm text-muted-foreground",
|
|
2763
|
+
children: emptyLabel
|
|
2764
|
+
})
|
|
2765
|
+
]
|
|
2766
|
+
});
|
|
2767
|
+
}
|
|
2627
2768
|
export {
|
|
2628
2769
|
AssistiveTreeDescription,
|
|
2629
2770
|
Tree,
|
|
@@ -2631,6 +2772,7 @@ export {
|
|
|
2631
2772
|
TreeItemAction,
|
|
2632
2773
|
TreeItemDot,
|
|
2633
2774
|
TreeItemStatusIcon,
|
|
2775
|
+
TreeSelect,
|
|
2634
2776
|
asyncDataLoaderFeature,
|
|
2635
2777
|
checkboxesFeature,
|
|
2636
2778
|
dragAndDropFeature,
|
|
@@ -104,6 +104,50 @@ function renderDefaultRow(row, props) {
|
|
|
104
104
|
})
|
|
105
105
|
}, row.id);
|
|
106
106
|
}
|
|
107
|
+
function revealRow(viewport, row, focus) {
|
|
108
|
+
const keepInView = () => {
|
|
109
|
+
const header = viewport.querySelector("thead")?.getBoundingClientRect().height ?? 0;
|
|
110
|
+
const view = viewport.getBoundingClientRect();
|
|
111
|
+
const bounds = row.getBoundingClientRect();
|
|
112
|
+
const top = view.top + header;
|
|
113
|
+
const bottom = view.top + viewport.clientHeight;
|
|
114
|
+
if (bounds.top < top || bounds.height > bottom - top)
|
|
115
|
+
viewport.scrollTop += bounds.top - top;
|
|
116
|
+
else if (bounds.bottom > bottom)
|
|
117
|
+
viewport.scrollTop += bounds.bottom - bottom;
|
|
118
|
+
};
|
|
119
|
+
keepInView();
|
|
120
|
+
if (!focus)
|
|
121
|
+
return;
|
|
122
|
+
row.focus({ preventScroll: true });
|
|
123
|
+
const table = row.closest("table");
|
|
124
|
+
if (row.ownerDocument.activeElement !== row || !table)
|
|
125
|
+
return;
|
|
126
|
+
const input = new AbortController;
|
|
127
|
+
let frame = 0;
|
|
128
|
+
const schedule = () => {
|
|
129
|
+
if (frame)
|
|
130
|
+
return;
|
|
131
|
+
frame = requestAnimationFrame(() => {
|
|
132
|
+
frame = 0;
|
|
133
|
+
if (row === row.ownerDocument.activeElement)
|
|
134
|
+
keepInView();
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const observer = new ResizeObserver(schedule);
|
|
138
|
+
const stop = () => {
|
|
139
|
+
cancelAnimationFrame(frame);
|
|
140
|
+
observer.disconnect();
|
|
141
|
+
input.abort();
|
|
142
|
+
};
|
|
143
|
+
for (const event of ["wheel", "pointerdown", "touchstart", "keydown"]) {
|
|
144
|
+
viewport.addEventListener(event, stop, { signal: input.signal, passive: true, capture: true });
|
|
145
|
+
}
|
|
146
|
+
row.addEventListener("blur", stop, { signal: input.signal });
|
|
147
|
+
viewport.addEventListener("scroll", schedule, { signal: input.signal, passive: true });
|
|
148
|
+
observer.observe(table);
|
|
149
|
+
return stop;
|
|
150
|
+
}
|
|
107
151
|
function handleRowKeys(cursor, event) {
|
|
108
152
|
if (event.target !== event.currentTarget || event.altKey)
|
|
109
153
|
return;
|
|
@@ -168,15 +212,7 @@ function VirtualDataGrid({
|
|
|
168
212
|
const row = viewport?.querySelector(`tr[data-row-id="${CSS.escape(reveal.rowId)}"]`);
|
|
169
213
|
if (!viewport || !row)
|
|
170
214
|
return;
|
|
171
|
-
|
|
172
|
-
const view = viewport.getBoundingClientRect();
|
|
173
|
-
const bounds = row.getBoundingClientRect();
|
|
174
|
-
if (bounds.top < view.top + header)
|
|
175
|
-
viewport.scrollTop -= view.top + header - bounds.top;
|
|
176
|
-
else if (bounds.bottom > view.bottom)
|
|
177
|
-
viewport.scrollTop += bounds.bottom - view.bottom;
|
|
178
|
-
if (reveal.focus)
|
|
179
|
-
row.focus({ preventScroll: true });
|
|
215
|
+
return revealRow(viewport, row, reveal.focus);
|
|
180
216
|
}, [reveal]);
|
|
181
217
|
const cursorProps = (row) => rowCursor ? {
|
|
182
218
|
tabIndex: row.id === tabStop ? 0 : -1,
|
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.146",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# TreeSelect
|
|
2
|
+
|
|
3
|
+
Story: @alexgorbatchev/shadcn/components/navigation/TreeSelect
|
|
4
|
+
Source: src/components/stories/navigation/TreeSelect.stories.tsx
|
|
5
|
+
|
|
6
|
+
[Full source and local helpers](https://github.com/alexgorbatchev/shadcn/blob/main/src/components/stories/navigation/TreeSelect.stories.tsx)
|
|
7
|
+
|
|
8
|
+
## Public imports
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { TreeSelect, type ITreeSelectNode, type ITreeSelectProps } from "@alexgorbatchev/shadcn/tree";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Supporting imports
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { useState, type ReactElement } from "react";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Default component
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
TreeSelect
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Default render
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
() => <Picker />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Examples
|
|
33
|
+
|
|
34
|
+
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.
|
|
35
|
+
|
|
36
|
+
### Hierarchy
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
{}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### FilterAndKeys
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
{}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### NoMatches
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
{}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### SpaceAndDisabled
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
{
|
|
58
|
+
render: () => <Picker />
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Disabled
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
{
|
|
66
|
+
render: () => <Picker isDisabled/>
|
|
67
|
+
}
|
|
68
|
+
```
|
package/llms/setup.md
CHANGED
|
@@ -73,7 +73,7 @@ Import shared controls and providers from `@alexgorbatchev/shadcn`. Import the f
|
|
|
73
73
|
| `/image-crop` | ImageCrop and native export helpers | `bun add react-image-crop@^11.1.2` |
|
|
74
74
|
| `/image-viewer` | ImageViewer, ImageZoomToggle, ImageComparison, and image helpers | Existing core peers |
|
|
75
75
|
| `/text-diff` | TextDiff: two versions of a text as a line diff | `bun add diff@9.0.0 parse-diff@0.12.0` |
|
|
76
|
-
| `/tree` | Tree, native hooks and features
|
|
76
|
+
| `/tree` | Tree, TreeSelect, native hooks and features | `bun add @headless-tree/core@^1.8.0 @headless-tree/react@^1.8.0`; patched runtimes are bundled |
|
|
77
77
|
| `/editor` | RichTextEditor, native Tiptap hooks and StarterKit | `bun add @tiptap/core@^3.32.0 @tiptap/react@^3.32.0 @tiptap/pm@^3.32.0 @tiptap/starter-kit@^3.32.0` |
|
|
78
78
|
| `/event-calendar` | EventCalendar, EventForm and native calendar APIs | `bun add date-fns@^4.4.0`; TypeScript: `bun add -d @types/react-big-calendar@^1.16.3` |
|
|
79
79
|
| `/gantt` | Gantt and Roadmap | `bun add date-fns@^4.4.0 @date-fns/tz@^1.5.0` |
|
|
@@ -548,6 +548,8 @@ function Screenshot({ src, onPick }: { src: string; onPick: (point: INormalizedI
|
|
|
548
548
|
|
|
549
549
|
"Highlight differences" draws both images at the after image's natural size and compares premultiplied channels against a threshold. Changed pixels are aggregated into 16px cells and connected regions, outlined with the warning token over the after image (toggle and swipe) or both panes (side-by-side), and summarized as "3 changed regions" or "No visible differences". The comparison runs in time-boxed slices that yield to the browser and is cached per image pair for the component's lifetime. When pixels cannot be read, such as a cross-origin image served without CORS or an image that failed to decode, the switch is disabled and the reason is shown. Pass `crossOrigin: "anonymous"` only when the image server sends CORS headers. `computeImageDiff(before, after, options)` exposes the same pure comparison for equally sized `ImageData`.
|
|
550
550
|
|
|
551
|
+
`TreeSelect` (`@alexgorbatchev/shadcn/tree`) chooses one place in a hierarchy, such as a destination folder. Pass `nodes` (`{ id, label, children?, disabledReason? }`), the chosen `value` and `onValueChange`, and `label` to name the tree. A filter (named by `filterLabel`, default "Filter") keeps every node whose name matches, with its ancestors; `emptyLabel` (default "No matches") shows when nothing does. ↓ in the filter enters the tree, which is one Tab stop: arrows move and expand, and Enter, Space or a click chooses. `currentId` marks where the item sits now with `currentLabel` (default "Current location") as the row description; a node with `disabledReason`, such as "Archived", stays listed, faded and `aria-disabled` with its reason as the description, and is never chosen. `isDisabled` disables the filter and choosing.
|
|
552
|
+
|
|
551
553
|
`TextDiff` (`@alexgorbatchev/shadcn/text-diff`) shows two versions of a text, `before` and `after`, as a line diff labelled by `beforeLabel` and `afterLabel` (default "Before" and "After"). Removed lines carry "-" and added lines "+" in a sign gutter as well as colour, and use `del` and `ins`; long lines wrap, so the diff never scrolls sideways. Unchanged runs further than `contextLines` (default 3) from a change fold behind a "Show N unchanged lines" button that toggles them with `aria-expanded`. `viewMode` is `"auto"` (default), `"unified"`, or `"split"`; auto shows the versions side by side once the diff's own width reaches `splitMinWidth` (default 560 px) and stacked below it, and stacked before the first measurement. A missing final newline is not shown as a change. `showLineNumbers` defaults to true.
|
|
552
554
|
|
|
553
555
|
The toolbar holds the mode, orientation (enabled for side-by-side), zoom, hold-to-show-before (enabled for toggle), and highlight controls with the legend and status. It sits beside a comparison at least 48rem wide and wraps below narrower ones; `showToolbar={false}` hides it, leaving consumers to control the props themselves.
|
package/llms.txt
CHANGED
|
@@ -475,6 +475,7 @@ Generated from the public package exports and Storybook sources.
|
|
|
475
475
|
- [SkipLink](./llms/components/navigation/SkipLink.md): SkipLink is the first Tab stop: a link to the main content that stays hidden until it has keyboard focus, then shows as an outline button pinned to the top start corner. It jumps to `targetId`; an `onClick` that calls `preventDefault` lets the app move focus itself.
|
|
476
476
|
- [Tabs](./llms/components/navigation/Tabs.md)
|
|
477
477
|
- [Tree](./llms/components/navigation/Tree.md)
|
|
478
|
+
- [TreeSelect](./llms/components/navigation/TreeSelect.md)
|
|
478
479
|
- [WorkspaceSwitcher](./llms/components/navigation/WorkspaceSwitcher.md)
|
|
479
480
|
|
|
480
481
|
## overlays
|