@dinachi/cli 0.7.0 → 0.7.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dinachi/cli",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "CLI for adding Dinachi UI components to your project",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -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
- <ToastContent>
225
- <div className="grid gap-1">
226
- {toast.title && <ToastTitle>{toast.title}</ToastTitle>}
227
- {toast.description && (
228
- <ToastDescription>{toast.description}</ToastDescription>
229
- )}
230
- </div>
231
- {toast.actionProps && <ToastAction {...toast.actionProps} />}
232
- <ToastClose aria-label="Close">
233
- <X className="h-4 w-4" />
234
- </ToastClose>
235
- </ToastContent>
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
- { children, className, limit = 3, timeout = 5000, toastManager, ...props },
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 };