@alexgorbatchev/shadcn 0.0.24 → 0.0.26
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/dist/components/ButtonGroup.d.ts +2 -1
- package/dist/components/tree/TreeItem.d.ts +1 -1
- package/dist/components/tree/index.js +23 -6
- package/dist/index.js +12 -2
- package/llms/components/actions/ButtonGroup.md +15 -0
- package/llms/components/navigation/Tree.md +10 -0
- package/package.json +1 -1
|
@@ -4,10 +4,11 @@ import { useRender } from "@base-ui/react/use-render";
|
|
|
4
4
|
import { type VariantProps } from "class-variance-authority";
|
|
5
5
|
import { Separator } from "./Separator.js";
|
|
6
6
|
declare const buttonGroupVariants: (props?: ({
|
|
7
|
+
layout?: "content" | "equal" | null | undefined;
|
|
7
8
|
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
8
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
10
|
type ButtonGroupProps = ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants> & IDensityProps;
|
|
10
|
-
declare function ButtonGroup({ density, className, orientation, ...props }: ButtonGroupProps): ReactElement;
|
|
11
|
+
declare function ButtonGroup({ density, className, orientation, layout, ...props }: ButtonGroupProps): ReactElement;
|
|
11
12
|
type ButtonGroupTextProps = useRender.ComponentProps<"div"> & IDensityProps;
|
|
12
13
|
declare function ButtonGroupText({ density, className, render, ...props }: ButtonGroupTextProps): ReactElement;
|
|
13
14
|
declare function ButtonGroupSeparator({ density, className, orientation, ...props }: ComponentProps<typeof Separator>): ReactElement;
|
|
@@ -13,7 +13,7 @@ type TreeItemProps<T> = useRender.ComponentProps<"div", TreeItemState> & IDensit
|
|
|
13
13
|
item: ItemInstance<T>;
|
|
14
14
|
startEnhancer?: ReactNode;
|
|
15
15
|
endEnhancer?: ReactNode;
|
|
16
|
-
expandOn?: "click" | "doubleClick";
|
|
16
|
+
expandOn?: "click" | "doubleClick" | "disclosure";
|
|
17
17
|
isEditing?: boolean;
|
|
18
18
|
isDropTarget?: boolean;
|
|
19
19
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cn2
|
|
3
3
|
} from "../../chunk-cp2m7y7v.js";
|
|
4
|
+
import {
|
|
5
|
+
Button2
|
|
6
|
+
} from "../../chunk-btz12z1j.js";
|
|
4
7
|
|
|
5
8
|
// src/components/tree/TreeItem.tsx
|
|
6
9
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
@@ -60,13 +63,13 @@ function TreeItem({
|
|
|
60
63
|
event.preventDefault();
|
|
61
64
|
item.getTree().setSelectedItems?.([item.getId()]);
|
|
62
65
|
item.primaryAction();
|
|
63
|
-
if (expandOn
|
|
66
|
+
if (expandOn !== "click" && item.isFolder())
|
|
64
67
|
toggle();
|
|
65
68
|
},
|
|
66
|
-
...expandOn
|
|
69
|
+
...expandOn !== "click" ? {
|
|
67
70
|
onClick: select,
|
|
68
71
|
onDoubleClick: (event) => {
|
|
69
|
-
if (!isRowControl(event) && item.isFolder())
|
|
72
|
+
if (expandOn === "doubleClick" && !isRowControl(event) && item.isFolder())
|
|
70
73
|
toggle();
|
|
71
74
|
}
|
|
72
75
|
} : {},
|
|
@@ -81,11 +84,25 @@ function TreeItem({
|
|
|
81
84
|
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"),
|
|
82
85
|
children: /* @__PURE__ */ jsxs(Fragment, {
|
|
83
86
|
children: [
|
|
84
|
-
item.isFolder() ? /* @__PURE__ */ jsx(
|
|
87
|
+
item.isFolder() && expandOn === "disclosure" ? /* @__PURE__ */ jsx(Button2, {
|
|
88
|
+
variant: "ghost",
|
|
89
|
+
size: "icon-xs",
|
|
90
|
+
"aria-label": `${isExpanded ? "Collapse" : "Expand"} ${item.getItemName()}`,
|
|
91
|
+
"aria-expanded": isExpanded,
|
|
92
|
+
onClick: (event) => {
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
toggle();
|
|
95
|
+
},
|
|
96
|
+
onDoubleClick: (event) => event.stopPropagation(),
|
|
97
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
98
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
99
|
+
className: cn2(isExpanded && "rotate-90")
|
|
100
|
+
})
|
|
101
|
+
}) : item.isFolder() ? /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
85
102
|
"aria-hidden": "true",
|
|
86
103
|
className: cn2("size-3.5 shrink-0", isExpanded && "rotate-90")
|
|
87
104
|
}) : /* @__PURE__ */ jsx("span", {
|
|
88
|
-
className: "size-3.5
|
|
105
|
+
className: cn2("shrink-0", expandOn === "disclosure" ? "size-control-xs" : "size-3.5")
|
|
89
106
|
}),
|
|
90
107
|
/* @__PURE__ */ jsx("span", {
|
|
91
108
|
"aria-hidden": "true",
|
|
@@ -133,7 +150,7 @@ function Tree({
|
|
|
133
150
|
return /* @__PURE__ */ jsxs2("div", {
|
|
134
151
|
...container,
|
|
135
152
|
"data-density": density,
|
|
136
|
-
className: cn2("grid min-w-0 gap-1", variant === "default" && "rounded-sm border border-border bg-card p-2"),
|
|
153
|
+
className: cn2("grid min-w-0 grid-cols-1 gap-1", variant === "default" && "rounded-sm border border-border bg-card p-2"),
|
|
137
154
|
onKeyDown: (event) => {
|
|
138
155
|
if (event.target instanceof Element && event.target.closest("input,textarea,select,form,button,[role=menu]"))
|
|
139
156
|
return;
|
package/dist/index.js
CHANGED
|
@@ -1400,6 +1400,10 @@ import { cva } from "class-variance-authority";
|
|
|
1400
1400
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1401
1401
|
var buttonGroupVariants = cva("flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-e-sm [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
|
|
1402
1402
|
variants: {
|
|
1403
|
+
layout: {
|
|
1404
|
+
content: "",
|
|
1405
|
+
equal: "grid w-full grid-flow-col auto-cols-fr data-[orientation=vertical]:grid-flow-row"
|
|
1406
|
+
},
|
|
1403
1407
|
orientation: {
|
|
1404
1408
|
horizontal: "*:data-slot:rounded-e-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-e-sm! [&>[data-slot]~[data-slot]]:rounded-s-none [&>[data-slot]~[data-slot]]:border-s-0",
|
|
1405
1409
|
vertical: "flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-sm! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0"
|
|
@@ -1409,13 +1413,19 @@ var buttonGroupVariants = cva("flex w-fit items-stretch *:focus-visible:relative
|
|
|
1409
1413
|
orientation: "horizontal"
|
|
1410
1414
|
}
|
|
1411
1415
|
});
|
|
1412
|
-
function ButtonGroup({
|
|
1416
|
+
function ButtonGroup({
|
|
1417
|
+
density,
|
|
1418
|
+
className,
|
|
1419
|
+
orientation,
|
|
1420
|
+
layout = "content",
|
|
1421
|
+
...props
|
|
1422
|
+
}) {
|
|
1413
1423
|
return /* @__PURE__ */ jsx13("div", {
|
|
1414
1424
|
role: "group",
|
|
1415
1425
|
"data-density": density,
|
|
1416
1426
|
"data-slot": "button-group",
|
|
1417
1427
|
"data-orientation": orientation,
|
|
1418
|
-
className: cn2(buttonGroupVariants({ orientation }), className),
|
|
1428
|
+
className: cn2(buttonGroupVariants({ orientation, layout }), className),
|
|
1419
1429
|
...props
|
|
1420
1430
|
});
|
|
1421
1431
|
}
|
|
@@ -53,6 +53,21 @@ ButtonGroup
|
|
|
53
53
|
|
|
54
54
|
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.
|
|
55
55
|
|
|
56
|
+
### EqualWidthPads
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
{
|
|
60
|
+
args: { layout: "equal" },
|
|
61
|
+
render: (args) => (<div data-testid="ButtonGroup--container" className="w-80">
|
|
62
|
+
<ButtonGroup {...args}>
|
|
63
|
+
{Array.from({ length: 8 }, (_, index) => (<Button key={index} variant="pad" size="content" disabled>
|
|
64
|
+
{index + 1}
|
|
65
|
+
</Button>))}
|
|
66
|
+
</ButtonGroup>
|
|
67
|
+
</div>)
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
56
71
|
### Horizontal
|
|
57
72
|
|
|
58
73
|
```tsx
|
|
@@ -28,6 +28,16 @@ import { useState } from "react";
|
|
|
28
28
|
|
|
29
29
|
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.
|
|
30
30
|
|
|
31
|
+
### ConstrainedRows
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
{
|
|
35
|
+
render: () => (<div className="w-[260px]">
|
|
36
|
+
<Example isComposed isConstrained/>
|
|
37
|
+
</div>)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
31
41
|
### Default
|
|
32
42
|
|
|
33
43
|
```tsx
|