MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus-components / use_selectable_option

Function use_selectable_option

primitives/src/selectable.rs:229–270  ·  view source on GitHub ↗
(
    selectable: SelectableContext,
    option: SelectableOptionConfig<T>,
)

Source from the content-addressed store, hash-verified

227}
228
229pub(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
272pub(crate) fn pointer_select_start(
273 event: &Event<PointerData>,

Callers 2

ComboboxOptionFunction · 0.85
SelectOptionFunction · 0.85

Calls 3

use_listbox_optionFunction · 0.85
is_selectedMethod · 0.45
is_focusedMethod · 0.45

Tested by

no test coverage detected