@motor-hero/ui-kit 0.26.0 → 0.27.0
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/base-dialog.d.ts +8 -1
- package/dist/components/base-dialog.d.ts.map +1 -1
- package/dist/index.cjs +33 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/base-dialog.tsx +11 -1
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { X } from "lucide-react"
|
|
|
3
3
|
import * as React from "react"
|
|
4
4
|
import type { ReactNode } from "react"
|
|
5
5
|
|
|
6
|
+
import { useIsDesktop } from "../hooks/use-is-desktop"
|
|
6
7
|
import { cn } from "../lib/utils"
|
|
7
8
|
|
|
8
9
|
const sizeClasses = {
|
|
@@ -24,6 +25,13 @@ export interface BaseDialogProps {
|
|
|
24
25
|
footer?: ReactNode
|
|
25
26
|
size?: BaseDialogSize
|
|
26
27
|
className?: string
|
|
28
|
+
/**
|
|
29
|
+
* Radix `modal` for the underlying Dialog. Defaults to `!isDesktop`: on
|
|
30
|
+
* desktop the dialog is non-modal so a Combobox/Select popover (portaled
|
|
31
|
+
* outside the dialog) can receive focus and keystrokes; on mobile it stays
|
|
32
|
+
* modal so the bottom-sheet behaves. Pass explicitly to override.
|
|
33
|
+
*/
|
|
34
|
+
modal?: boolean
|
|
27
35
|
/**
|
|
28
36
|
* Advanced: wraps the dialog's inner content (header + body + footer) inside
|
|
29
37
|
* Content. Used by FormDialog to inject a <form>. Defaults to identity.
|
|
@@ -50,8 +58,10 @@ export function BaseDialog({
|
|
|
50
58
|
footer,
|
|
51
59
|
size = "lg",
|
|
52
60
|
className,
|
|
61
|
+
modal,
|
|
53
62
|
contentWrapper = (content) => content,
|
|
54
63
|
}: BaseDialogProps) {
|
|
64
|
+
const isDesktop = useIsDesktop()
|
|
55
65
|
React.useEffect(() => {
|
|
56
66
|
if (open) return
|
|
57
67
|
const id = window.setTimeout(() => {
|
|
@@ -92,7 +102,7 @@ export function BaseDialog({
|
|
|
92
102
|
)
|
|
93
103
|
|
|
94
104
|
return (
|
|
95
|
-
<Dialog.Root open={open} onOpenChange={onOpenChange}>
|
|
105
|
+
<Dialog.Root open={open} onOpenChange={onOpenChange} modal={modal ?? !isDesktop}>
|
|
96
106
|
<Dialog.Portal>
|
|
97
107
|
<Dialog.Overlay className="fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />
|
|
98
108
|
<Dialog.Content
|