@dinachi/cli 0.7.0 → 0.7.2
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/index.js
CHANGED
|
@@ -332,7 +332,7 @@ function getComponentRegistry() {
|
|
|
332
332
|
name: "toast",
|
|
333
333
|
description: "Generates toast notifications with support for different types, promises, actions, and global management.",
|
|
334
334
|
files: [{ name: "toast.tsx" }, { name: "index.ts" }],
|
|
335
|
-
dependencies: ["@base-ui/react", "class-variance-authority"],
|
|
335
|
+
dependencies: ["@base-ui/react", "class-variance-authority", "lucide-react"],
|
|
336
336
|
utilityDependencies: ["cn"]
|
|
337
337
|
},
|
|
338
338
|
toggle: {
|
|
@@ -940,6 +940,16 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
940
940
|
if (comp.dependencies?.length) {
|
|
941
941
|
allDepsInstalled.push(...comp.dependencies);
|
|
942
942
|
}
|
|
943
|
+
if (name === "toast") {
|
|
944
|
+
const toastLibPath = path3.join(libDir, "toast.ts");
|
|
945
|
+
if (!fs3.existsSync(toastLibPath)) {
|
|
946
|
+
const toastContent = `import { createToastManager } from "${config.aliases.ui}/toast";
|
|
947
|
+
export const toastManager = createToastManager();
|
|
948
|
+
`;
|
|
949
|
+
await fs3.writeFile(toastLibPath, toastContent);
|
|
950
|
+
allFilesAdded.push({ name: "toast.ts", path: toastLibPath });
|
|
951
|
+
}
|
|
952
|
+
}
|
|
943
953
|
}
|
|
944
954
|
spinner.text = "Updating Tailwind configuration...";
|
|
945
955
|
const tailwindMajor = detectTailwindMajorVersion(projectRoot);
|
package/package.json
CHANGED
|
@@ -4,7 +4,79 @@ import * as React from "react"
|
|
|
4
4
|
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
|
|
5
5
|
import { cn } from "@/lib/utils"
|
|
6
6
|
|
|
7
|
+
/* -------------------------------------------------------------------------------------------------
|
|
8
|
+
* Compound ScrollArea — handles Root + Viewport + Content + Scrollbar + Thumb internally
|
|
9
|
+
* ------------------------------------------------------------------------------------------------*/
|
|
10
|
+
|
|
7
11
|
const ScrollArea = React.forwardRef<
|
|
12
|
+
React.ComponentRef<typeof ScrollAreaPrimitive.Root>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {
|
|
14
|
+
orientation?: "vertical" | "horizontal" | "both"
|
|
15
|
+
viewportClassName?: string
|
|
16
|
+
scrollbarClassName?: string
|
|
17
|
+
}
|
|
18
|
+
>(
|
|
19
|
+
(
|
|
20
|
+
{
|
|
21
|
+
className,
|
|
22
|
+
orientation = "vertical",
|
|
23
|
+
viewportClassName,
|
|
24
|
+
scrollbarClassName,
|
|
25
|
+
children,
|
|
26
|
+
...props
|
|
27
|
+
},
|
|
28
|
+
ref
|
|
29
|
+
) => (
|
|
30
|
+
<ScrollAreaPrimitive.Root
|
|
31
|
+
ref={ref}
|
|
32
|
+
className={cn("relative overflow-hidden", className)}
|
|
33
|
+
{...props}
|
|
34
|
+
>
|
|
35
|
+
<ScrollAreaPrimitive.Viewport
|
|
36
|
+
className={cn("size-full rounded-[inherit]", viewportClassName)}
|
|
37
|
+
>
|
|
38
|
+
<ScrollAreaPrimitive.Content className="min-w-full">
|
|
39
|
+
{children}
|
|
40
|
+
</ScrollAreaPrimitive.Content>
|
|
41
|
+
</ScrollAreaPrimitive.Viewport>
|
|
42
|
+
|
|
43
|
+
{(orientation === "vertical" || orientation === "both") && (
|
|
44
|
+
<ScrollAreaPrimitive.Scrollbar
|
|
45
|
+
orientation="vertical"
|
|
46
|
+
className={cn(
|
|
47
|
+
"flex touch-none select-none p-0.5 transition-colors",
|
|
48
|
+
"h-full w-2.5 border-l border-l-transparent",
|
|
49
|
+
scrollbarClassName
|
|
50
|
+
)}
|
|
51
|
+
>
|
|
52
|
+
<ScrollAreaPrimitive.Thumb className="relative flex-1 rounded-full bg-border" />
|
|
53
|
+
</ScrollAreaPrimitive.Scrollbar>
|
|
54
|
+
)}
|
|
55
|
+
|
|
56
|
+
{(orientation === "horizontal" || orientation === "both") && (
|
|
57
|
+
<ScrollAreaPrimitive.Scrollbar
|
|
58
|
+
orientation="horizontal"
|
|
59
|
+
className={cn(
|
|
60
|
+
"flex touch-none select-none p-0.5 transition-colors",
|
|
61
|
+
"h-2.5 w-full flex-col border-t border-t-transparent",
|
|
62
|
+
scrollbarClassName
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
<ScrollAreaPrimitive.Thumb className="relative flex-1 rounded-full bg-border" />
|
|
66
|
+
</ScrollAreaPrimitive.Scrollbar>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
{orientation === "both" && <ScrollAreaPrimitive.Corner className="bg-background" />}
|
|
70
|
+
</ScrollAreaPrimitive.Root>
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
ScrollArea.displayName = "ScrollArea"
|
|
74
|
+
|
|
75
|
+
/* -------------------------------------------------------------------------------------------------
|
|
76
|
+
* Primitives — re-exported for advanced composition (e.g. dual-axis with custom placement)
|
|
77
|
+
* ------------------------------------------------------------------------------------------------*/
|
|
78
|
+
|
|
79
|
+
const ScrollAreaRoot = React.forwardRef<
|
|
8
80
|
React.ComponentRef<typeof ScrollAreaPrimitive.Root>,
|
|
9
81
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
|
10
82
|
>(({ className, ...props }, ref) => (
|
|
@@ -14,7 +86,7 @@ const ScrollArea = React.forwardRef<
|
|
|
14
86
|
{...props}
|
|
15
87
|
/>
|
|
16
88
|
))
|
|
17
|
-
|
|
89
|
+
ScrollAreaRoot.displayName = "ScrollAreaRoot"
|
|
18
90
|
|
|
19
91
|
const ScrollAreaViewport = React.forwardRef<
|
|
20
92
|
React.ComponentRef<typeof ScrollAreaPrimitive.Viewport>,
|
|
@@ -85,6 +157,7 @@ ScrollAreaCorner.displayName = "ScrollAreaCorner"
|
|
|
85
157
|
|
|
86
158
|
export {
|
|
87
159
|
ScrollArea,
|
|
160
|
+
ScrollAreaRoot,
|
|
88
161
|
ScrollAreaViewport,
|
|
89
162
|
ScrollAreaContent,
|
|
90
163
|
ScrollAreaScrollbar,
|
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { Toast as BaseToast } from "@base-ui/react/toast";
|
|
5
5
|
import { cn } from "@/lib/utils";
|
|
6
6
|
import { type VariantProps, cva } from "class-variance-authority";
|
|
7
|
+
import { XIcon } from "lucide-react";
|
|
7
8
|
|
|
8
9
|
// Toast Provider
|
|
9
10
|
const ToastProvider = BaseToast.Provider;
|
|
@@ -166,13 +167,14 @@ const ToastAction = React.forwardRef<
|
|
|
166
167
|
));
|
|
167
168
|
ToastAction.displayName = "ToastAction";
|
|
168
169
|
|
|
169
|
-
// Toast Close
|
|
170
|
+
// Toast Close — renders XIcon by default, overridable via children
|
|
170
171
|
const ToastClose = React.forwardRef<
|
|
171
172
|
HTMLButtonElement,
|
|
172
173
|
React.ComponentProps<typeof BaseToast.Close>
|
|
173
|
-
>(({ className, ...props }, ref) => (
|
|
174
|
+
>(({ className, children, ...props }, ref) => (
|
|
174
175
|
<BaseToast.Close
|
|
175
176
|
ref={ref}
|
|
177
|
+
aria-label="Close"
|
|
176
178
|
className={cn(
|
|
177
179
|
"absolute top-2 right-2 flex h-5 w-5 items-center justify-center rounded border-none bg-transparent opacity-60 transition-opacity",
|
|
178
180
|
"hover:opacity-100 focus:outline-none focus:ring-1 focus:ring-ring",
|
|
@@ -180,10 +182,45 @@ const ToastClose = React.forwardRef<
|
|
|
180
182
|
className
|
|
181
183
|
)}
|
|
182
184
|
{...props}
|
|
183
|
-
|
|
185
|
+
>
|
|
186
|
+
{children ?? <XIcon className="h-4 w-4" />}
|
|
187
|
+
</BaseToast.Close>
|
|
184
188
|
));
|
|
185
189
|
ToastClose.displayName = "ToastClose";
|
|
186
190
|
|
|
191
|
+
// Toast Positioner — positions a toast relative to an anchor element
|
|
192
|
+
const ToastPositioner = React.forwardRef<
|
|
193
|
+
HTMLDivElement,
|
|
194
|
+
React.ComponentProps<typeof BaseToast.Positioner>
|
|
195
|
+
>(({ className, ...props }, ref) => (
|
|
196
|
+
<BaseToast.Positioner
|
|
197
|
+
ref={ref}
|
|
198
|
+
className={cn("z-50", className)}
|
|
199
|
+
{...props}
|
|
200
|
+
/>
|
|
201
|
+
));
|
|
202
|
+
ToastPositioner.displayName = "ToastPositioner";
|
|
203
|
+
|
|
204
|
+
// Toast Arrow — decorative arrow for anchored toasts
|
|
205
|
+
const ToastArrow = React.forwardRef<
|
|
206
|
+
HTMLDivElement,
|
|
207
|
+
React.ComponentProps<typeof BaseToast.Arrow>
|
|
208
|
+
>(({ className, ...props }, ref) => (
|
|
209
|
+
<BaseToast.Arrow
|
|
210
|
+
ref={ref}
|
|
211
|
+
className={cn(
|
|
212
|
+
"fill-background [stroke-width:1px] stroke-border",
|
|
213
|
+
"data-[side=bottom]:top-[-8px]",
|
|
214
|
+
"data-[side=left]:right-[-8px]",
|
|
215
|
+
"data-[side=right]:left-[-8px]",
|
|
216
|
+
"data-[side=top]:bottom-[-8px]",
|
|
217
|
+
className
|
|
218
|
+
)}
|
|
219
|
+
{...props}
|
|
220
|
+
/>
|
|
221
|
+
));
|
|
222
|
+
ToastArrow.displayName = "ToastArrow";
|
|
223
|
+
|
|
187
224
|
// Hook for using toast manager
|
|
188
225
|
const useToastManager = BaseToast.useToastManager;
|
|
189
226
|
|
|
@@ -208,10 +245,16 @@ function getVariantFromType(
|
|
|
208
245
|
}
|
|
209
246
|
}
|
|
210
247
|
|
|
248
|
+
// Toast object type from Base UI
|
|
249
|
+
type ToastObject = React.ComponentProps<typeof BaseToast.Root>["toast"];
|
|
250
|
+
|
|
251
|
+
// renderToast callback type
|
|
252
|
+
type RenderToastFn = (toast: ToastObject) => React.ReactNode;
|
|
253
|
+
|
|
211
254
|
// Default ToastList component for easy usage
|
|
212
255
|
// Returns toast roots directly without a wrapper — Base UI requires
|
|
213
256
|
// Toast.Root elements as direct children of Toast.Viewport.
|
|
214
|
-
function ToastList() {
|
|
257
|
+
function ToastList({ renderToast }: { renderToast?: RenderToastFn }) {
|
|
215
258
|
const { toasts } = useToastManager();
|
|
216
259
|
|
|
217
260
|
return toasts.map((toast) => (
|
|
@@ -221,45 +264,24 @@ function ToastList() {
|
|
|
221
264
|
variant={getVariantFromType(toast.type)}
|
|
222
265
|
swipeDirection={["down", "right"]}
|
|
223
266
|
>
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
267
|
+
{renderToast ? (
|
|
268
|
+
renderToast(toast)
|
|
269
|
+
) : (
|
|
270
|
+
<ToastContent>
|
|
271
|
+
<div className="grid gap-1">
|
|
272
|
+
{toast.title && <ToastTitle>{toast.title}</ToastTitle>}
|
|
273
|
+
{toast.description && (
|
|
274
|
+
<ToastDescription>{toast.description}</ToastDescription>
|
|
275
|
+
)}
|
|
276
|
+
</div>
|
|
277
|
+
{toast.actionProps && <ToastAction {...toast.actionProps} />}
|
|
278
|
+
<ToastClose />
|
|
279
|
+
</ToastContent>
|
|
280
|
+
)}
|
|
236
281
|
</ToastRoot>
|
|
237
282
|
));
|
|
238
283
|
}
|
|
239
284
|
|
|
240
|
-
// X Icon component
|
|
241
|
-
const X = React.forwardRef<SVGSVGElement, React.ComponentProps<"svg">>(
|
|
242
|
-
(props, ref) => (
|
|
243
|
-
<svg
|
|
244
|
-
ref={ref}
|
|
245
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
246
|
-
width="24"
|
|
247
|
-
height="24"
|
|
248
|
-
viewBox="0 0 24 24"
|
|
249
|
-
fill="none"
|
|
250
|
-
stroke="currentColor"
|
|
251
|
-
strokeWidth="2"
|
|
252
|
-
strokeLinecap="round"
|
|
253
|
-
strokeLinejoin="round"
|
|
254
|
-
{...props}
|
|
255
|
-
>
|
|
256
|
-
<path d="M18 6 6 18" />
|
|
257
|
-
<path d="m6 6 12 12" />
|
|
258
|
-
</svg>
|
|
259
|
-
)
|
|
260
|
-
);
|
|
261
|
-
X.displayName = "X";
|
|
262
|
-
|
|
263
285
|
// Complete Toast component for easy setup
|
|
264
286
|
interface ToastComponentProps {
|
|
265
287
|
children?: React.ReactNode;
|
|
@@ -267,18 +289,27 @@ interface ToastComponentProps {
|
|
|
267
289
|
limit?: number;
|
|
268
290
|
timeout?: number;
|
|
269
291
|
toastManager?: ReturnType<typeof createToastManager>;
|
|
292
|
+
renderToast?: RenderToastFn;
|
|
270
293
|
}
|
|
271
294
|
|
|
272
295
|
const Toast = React.forwardRef<HTMLDivElement, ToastComponentProps>(
|
|
273
296
|
(
|
|
274
|
-
{
|
|
297
|
+
{
|
|
298
|
+
children,
|
|
299
|
+
className,
|
|
300
|
+
limit = 3,
|
|
301
|
+
timeout = 5000,
|
|
302
|
+
toastManager,
|
|
303
|
+
renderToast,
|
|
304
|
+
...props
|
|
305
|
+
},
|
|
275
306
|
ref
|
|
276
307
|
) => (
|
|
277
308
|
<ToastProvider limit={limit} timeout={timeout} toastManager={toastManager}>
|
|
278
309
|
{children}
|
|
279
310
|
<ToastPortal>
|
|
280
311
|
<ToastViewport ref={ref} className={className} {...props}>
|
|
281
|
-
<ToastList />
|
|
312
|
+
<ToastList renderToast={renderToast} />
|
|
282
313
|
</ToastViewport>
|
|
283
314
|
</ToastPortal>
|
|
284
315
|
</ToastProvider>
|
|
@@ -297,9 +328,13 @@ export {
|
|
|
297
328
|
ToastDescription,
|
|
298
329
|
ToastAction,
|
|
299
330
|
ToastClose,
|
|
331
|
+
ToastPositioner,
|
|
332
|
+
ToastArrow,
|
|
300
333
|
ToastList,
|
|
301
334
|
useToastManager,
|
|
302
335
|
createToastManager,
|
|
303
336
|
toastVariants,
|
|
304
337
|
getVariantFromType,
|
|
305
338
|
};
|
|
339
|
+
|
|
340
|
+
export type { ToastComponentProps, RenderToastFn, ToastObject };
|