Skip to content

Commit 10e887b

Browse files
authored
Passing in additional headless ui props and updated documentation (#232)
1 parent 297010a commit 10e887b

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

lib/components/display/modal.jsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ import {
88
import gwMerge from "../../gw-merge";
99
import { WIDTH_OPTIONS } from "../../utils/sizes";
1010

11+
const roleOptions = ["dialog", "alertdialog"];
12+
1113
function Modal({
1214
opened = false,
1315
onClose,
1416
dialogTitle,
1517
dialogDescription,
18+
isStatic = false,
19+
autoFocus=false,
20+
dialogTransition=false,
21+
dialogPanelTransition= false,
22+
unmount = true,
23+
role='dialog',
1624
buttons,
1725
size = "2xl",
1826
className,
@@ -28,11 +36,27 @@ function Modal({
2836
);
2937
size = "2xl";
3038
}
39+
40+
// Check if Role exists
41+
if (!roleOptions[role]) {
42+
console.error(
43+
`Invalid role option for dialog ${role}. Must be one of: 'dialog','alertdialog'`)
44+
console.warn(
45+
`Defaulting to 'dialog' for role of <Modal modalTitle="${dialogTitle}" .../>`,
46+
);
47+
role = "dialog";
48+
49+
}
3150

3251
return (
3352
<Dialog
3453
open={opened}
3554
onClose={onClose}
55+
static= {isStatic}
56+
autoFocus={autoFocus}
57+
dialogTransition={dialogTransition}
58+
unount={unmount}
59+
role={role}
3660
className={gwMerge("gw-relative", "gw-z-[200]", className)}
3761
>
3862
<DialogBackdrop className="gw-fixed gw-inset-0 gw-bg-black/30" />
@@ -48,6 +72,7 @@ function Modal({
4872
"gw-bg-white",
4973
"gw-p-12",
5074
)}
75+
transition={dialogPanelTransition}
5176
>
5277
{dialogTitle && (
5378
<DialogTitle className="gw-font-bold gw-text-center">

src/app-pages/documentation/display/modal.jsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,42 @@ const componentProps = [
5858
default: "2xl",
5959
desc: "Size of the modal dialog. Options include: 'sx', 'sm', 'md', 'lg', 'xl', '2xl', '4xl', 'full'.",
6060
},
61+
{
62+
name: "isStatic",
63+
type:"boolean",
64+
default:"false",
65+
desc:"Whether the element should ignore the internally managed open/closed state."
66+
},
67+
{
68+
name:"autoFocus",
69+
type:"boolean",
70+
default:"false",
71+
desc:"Whether or not the dialog should receive focus when first rendered."
72+
},
73+
{
74+
name:"dialogTransition",
75+
type:"boolean",
76+
default:"false",
77+
desc:"Whether the element should render transition attributes like data-closed, data-enter and data-leave."
78+
},
79+
{
80+
name:"unmount",
81+
type:"boolean",
82+
default:"true",
83+
desc:"Whether the element should be unmounted or hidden based on the open/closed state."
84+
},
85+
{
86+
name:"role",
87+
type:"string",
88+
default:"dialog",
89+
desc:"The role to apply to the dialog root element. Options include: 'dialog' , 'alertdialog'"
90+
},
91+
{
92+
name:"dialogPanelTransition",
93+
type:"boolean",
94+
default:"false",
95+
desc:"Whether the element should render transition attributes like data-closed, data-enter and data-leave."
96+
},
6197
{
6298
name: "className",
6399
type: "string",

0 commit comments

Comments
 (0)