(
selectable: SelectableContext,
option: SelectableOptionConfig<T>,
)
| 227 | } |
| 228 | |
| 229 | pub(crate) fn use_selectable_option<T: Clone + PartialEq + 'static>( |
| 230 | selectable: SelectableContext, |
| 231 | option: SelectableOptionConfig<T>, |
| 232 | ) -> SelectableOption<T> { |
| 233 | let SelectableOptionConfig { |
| 234 | id, |
| 235 | index, |
| 236 | value, |
| 237 | text_value, |
| 238 | option_disabled, |
| 239 | component_name, |
| 240 | } = option; |
| 241 | let disabled = { |
| 242 | let root_disabled = selectable.disabled; |
| 243 | use_memo(move || root_disabled.cloned() || option_disabled.cloned()) |
| 244 | }; |
| 245 | let id = use_listbox_option( |
| 246 | id, |
| 247 | index, |
| 248 | value, |
| 249 | text_value, |
| 250 | selectable.options, |
| 251 | component_name, |
| 252 | ); |
| 253 | let selected = use_memo(move || selectable.is_selected(&RcPartialEqValue::new(value.cloned()))); |
| 254 | let focused = use_memo(move || selectable.collection.is_focused(index())); |
| 255 | let down_pos: Signal<Option<(f64, f64)>> = use_signal(|| None); |
| 256 | |
| 257 | use_context_provider(|| ListboxOptionContext { |
| 258 | selected: selected.into(), |
| 259 | }); |
| 260 | |
| 261 | SelectableOption { |
| 262 | id, |
| 263 | disabled, |
| 264 | selected, |
| 265 | focused, |
| 266 | down_pos, |
| 267 | index, |
| 268 | value, |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | pub(crate) fn pointer_select_start( |
| 273 | event: &Event<PointerData>, |
no test coverage detected