(props: SelectOptionProps<T>)
| 102 | /// ``` |
| 103 | #[component] |
| 104 | pub fn SelectOption<T: PartialEq + Clone + 'static>(props: SelectOptionProps<T>) -> Element { |
| 105 | let index = props.index; |
| 106 | |
| 107 | let mut ctx: SelectContext = use_context(); |
| 108 | let option = use_selectable_option( |
| 109 | ctx.selectable, |
| 110 | SelectableOptionConfig { |
| 111 | id: props.id, |
| 112 | index, |
| 113 | value: props.value, |
| 114 | text_value: props.text_value, |
| 115 | option_disabled: props.disabled, |
| 116 | component_name: "SelectOption", |
| 117 | }, |
| 118 | ); |
| 119 | |
| 120 | let item = use_item( |
| 121 | collection_item(ctx.selectable.collection, props.index) |
| 122 | .key(move || Some(option.id.cloned())) |
| 123 | .disabled(move || option.disabled.cloned()) |
| 124 | .selected(move || (option.selected)()), |
| 125 | ); |
| 126 | let onmounted = item.onmounted(); |
| 127 | |
| 128 | let render = use_context::<ListboxContext>().render; |
| 129 | |
| 130 | rsx! { |
| 131 | if render() { |
| 132 | div { |
| 133 | role: "option", |
| 134 | id: option.id, |
| 135 | tabindex: if (option.focused)() { "0" } else { "-1" }, |
| 136 | onmounted, |
| 137 | |
| 138 | aria_selected: (option.selected)(), |
| 139 | aria_disabled: (option.disabled)(), |
| 140 | aria_label: props.aria_label.clone(), |
| 141 | aria_roledescription: props.aria_roledescription.clone(), |
| 142 | "data-disabled": (option.disabled)(), |
| 143 | |
| 144 | onpointerdown: move |event| { |
| 145 | pointer_select_start(&event, (option.disabled)(), option.down_pos); |
| 146 | }, |
| 147 | onpointerup: move |event| { |
| 148 | if pointer_select_commit(&event, (option.disabled)(), option.down_pos) { |
| 149 | ctx.selectable.select_value(RcPartialEqValue::new(option.value.cloned())); |
| 150 | } |
| 151 | }, |
| 152 | onpointercancel: move |_| { |
| 153 | pointer_select_cancel(option.down_pos); |
| 154 | }, |
| 155 | onblur: move |_| { |
| 156 | if (option.focused)() { |
| 157 | ctx.selectable.collection.clear_focus(); |
| 158 | ctx.set_open(false); |
| 159 | } |
| 160 | }, |
| 161 |
nothing calls this directly
no test coverage detected