(props: DialogRootProps)
| 113 | /// - `data-state`: Indicates if the dialog is open or closed. It can be either "open" or "closed". |
| 114 | #[component] |
| 115 | pub fn DialogRoot(props: DialogRootProps) -> Element { |
| 116 | let dialog_labelledby = use_unique_id(); |
| 117 | let dialog_describedby = use_unique_id(); |
| 118 | |
| 119 | let (open, set_open) = use_controlled(props.open, props.default_open, props.on_open_change); |
| 120 | |
| 121 | let unique_id = use_unique_id(); |
| 122 | let id = use_id_or(unique_id, props.id); |
| 123 | |
| 124 | use_context_provider(|| DialogCtx { |
| 125 | open, |
| 126 | set_open, |
| 127 | is_modal: props.is_modal, |
| 128 | dialog_labelledby, |
| 129 | dialog_describedby, |
| 130 | }); |
| 131 | |
| 132 | let render = use_animated_open(id, open); |
| 133 | |
| 134 | rsx! { |
| 135 | document::Script { |
| 136 | src: FOCUS_TRAP_JS, |
| 137 | defer: true |
| 138 | } |
| 139 | if render() { |
| 140 | div { |
| 141 | id, |
| 142 | aria_hidden: (!open()).then_some("true"), |
| 143 | "data-state": if open() { "open" } else { "closed" }, |
| 144 | ..props.attributes, |
| 145 | {props.children} |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /// The props for the [`DialogRoot`] component |
| 152 | #[derive(Props, Clone, PartialEq)] |
nothing calls this directly
no test coverage detected