@jinaan/uikit 0.1.28 → 0.1.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinaan/uikit",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "Reusable React and Tailwind UI components for Jinaan projects.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/src/dialog.tsx CHANGED
@@ -83,6 +83,7 @@ function resolveOrigin(content: HTMLElement): DialogOriginRect | null {
83
83
  const DIALOG_CLOSE_MS = 250;
84
84
  const DialogClosingContext = createContext(false);
85
85
  const DialogRequestCloseContext = createContext<() => void>(() => {});
86
+ const InDialogContext = createContext(false);
86
87
 
87
88
  /** Dialog root; owns the delayed close so the fly-out can finish. */
88
89
  export function Dialog({
@@ -158,13 +159,15 @@ export function Dialog({
158
159
  return (
159
160
  <DialogRequestCloseContext.Provider value={() => handleOpenChange(false)}>
160
161
  <DialogClosingContext.Provider value={closing}>
161
- <DialogPrimitive.Root
162
- open={open}
163
- onOpenChange={handleOpenChange}
164
- {...props}
165
- >
166
- {children}
167
- </DialogPrimitive.Root>
162
+ <InDialogContext.Provider value={true}>
163
+ <DialogPrimitive.Root
164
+ open={open}
165
+ onOpenChange={handleOpenChange}
166
+ {...props}
167
+ >
168
+ {children}
169
+ </DialogPrimitive.Root>
170
+ </InDialogContext.Provider>
168
171
  </DialogClosingContext.Provider>
169
172
  </DialogRequestCloseContext.Provider>
170
173
  );
@@ -393,26 +396,45 @@ export function DialogFooter({
393
396
  );
394
397
  }
395
398
 
399
+ /**
400
+ * Dialog heading. Standalone-safe: outside a `Dialog` root it renders a plain
401
+ * heading with the same classes (Radix's Title requires a dialog context).
402
+ */
396
403
  export const DialogTitle = forwardRef<
397
404
  ElementRef<typeof DialogPrimitive.Title>,
398
405
  ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
399
- >(({ className, ...props }, ref) => (
400
- <DialogPrimitive.Title
401
- ref={ref}
402
- className={cn("text-base font-semibold text-fg", className)}
403
- {...props}
404
- />
405
- ));
406
+ >(({ className, ...props }, ref) => {
407
+ const Comp = useContext(InDialogContext)
408
+ ? DialogPrimitive.Title
409
+ : "h2";
410
+ return (
411
+ <Comp
412
+ ref={ref}
413
+ className={cn("text-base font-semibold text-fg", className)}
414
+ {...props}
415
+ />
416
+ );
417
+ });
406
418
  DialogTitle.displayName = "DialogTitle";
407
419
 
420
+ /**
421
+ * Dialog body copy. Standalone-safe: outside a `Dialog` root it renders a
422
+ * plain paragraph with the same classes (Radix's Description requires a
423
+ * dialog context).
424
+ */
408
425
  export const DialogDescription = forwardRef<
409
426
  ElementRef<typeof DialogPrimitive.Description>,
410
427
  ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
411
- >(({ className, ...props }, ref) => (
412
- <DialogPrimitive.Description
413
- ref={ref}
414
- className={cn("text-sm text-muted", className)}
415
- {...props}
416
- />
417
- ));
428
+ >(({ className, ...props }, ref) => {
429
+ const Comp = useContext(InDialogContext)
430
+ ? DialogPrimitive.Description
431
+ : "p";
432
+ return (
433
+ <Comp
434
+ ref={ref}
435
+ className={cn("text-sm text-muted", className)}
436
+ {...props}
437
+ />
438
+ );
439
+ });
418
440
  DialogDescription.displayName = "DialogDescription";