1import { p as prop, a as set_attribute, b as set_class, t as remove_input_defaults, g as spread_props, i as if_block, k as each, r as rest_props, u as index } from './i18n-CGlVUOvE.js'; 2import { M as push, t as template_effect, U as event, a as append, O as pop, Q as child, S as sibling, R as from_html, $ as set, Z as get, I as tick, a2 as user_derived, X as set_text, T as reset, ab as state, ac as proxy, ad as user_effect, N as first_child, a4 as text, as as to_array, a5 as next } from './index-Bq2njFOY.js'; 3import { G as Gradio } from './utils.svelte-Bi9ASwv9.js'; 4import { B as Block } from './Block-DNK-JdLJ.js'; 5import { B as BlockTitle } from './BlockTitle-Bcj082QO.js'; 6import './ScrollFade.svelte_svelte_type_style_lang-D0JPkGar.js'; 7import './MarkdownCode.svelte_svelte_type_style_lang-B29zDiob.js'; 8import { I as IconButtonWrapper } from './IconButtonWrapper-DAsvkfJg.js'; 9import { S as Static } from './index-1GCmrSlD.js'; 10import './StreamingBar.svelte_svelte_type_style_lang-DWGn5tT_.js'; 11import { c as bind_group } from './input-CXpCw23l.js'; 12export { default as BaseExample } from './Example-ByABbZIR.js'; 13import './Info-CfqzbVCN.js'; 14import './MarkdownCode-BYKuypS7.js'; 15import './html-Bwif0JPw.js'; 16import './snippet-BG7qkY_1.js'; 17import './prism-python-NrKIQnfs.js'; 18import './Clear-C8Tfa7QP.js'; 19 20let id = 0; 21var root = from_html(`<label><input type="radio" class="svelte-19qdtil"/> <span class="svelte-19qdtil"> </span></label>`); 22 23function Radio($$anchor, $$props) { 24 push($$props, true); 25 26 const binding_group = []; 27 let selected = prop($$props, 'selected', 15); 28 let is_selected = user_derived(() => selected() === $$props.internal_value); 29 30 async function handle_input(e) { 31 set(is_selected, e.target.checked); 32 33 if (get(is_selected)) { 34 await tick(); 35 $$props.on_input(); 36 } 37 } 38 39 var label = root(); 40 let classes; 41 var input = child(label); 42 43 remove_input_defaults(input); 44 45 var input_value; 46 var span = sibling(input, 2); 47 var text = child(span, true); 48 49 reset(span); 50 reset(label); 51 52 template_effect(() => { 53 set_attribute(label, 'data-testid', `${$$props.display_value ?? ''}-radio-label`); 54 55 classes = set_class(label, 1, 'svelte-19qdtil', null, classes, { 56 disabled: $$props.disabled, 57 selected: get(is_selected), 58 rtl: $$props.rtl 59 }); 60 61 input.disabled = $$props.disabled; 62 set_attribute(input, 'name', `radio-${++id ?? ''}`); 63 set_attribute(input, 'aria-checked', get(is_selected)); 64 65 if (input_value !== (input_value = $$props.internal_value)) { 66 input.value = (input.__value = $$props.internal_value) ?? ''; 67 } 68 69 set_text(text, $$props.display_value); 70 }); 71 72 bind_group( 73 binding_group, 74 [], 75 input, 76 () => { 77 $$props.internal_value; 78 79 return selected(); 80 }, 81 selected 82 ); 83 84 event('input', input, handle_input); 85 append($$anchor, label); 86 pop(); 87} 88 89var root_1 = from_html(`<!> <!> <!> <div class="wrap svelte-e4x47i"></div>`, 1); 90 91function Index($$anchor, $$props) { 92 push($$props, true); 93 94 const props = rest_props($$props, ['$$slots', '$$events', '$$legacy']); 95 const gradio = new Gradio(props); 96 let disabled = user_derived(() => !gradio.shared.interactive); 97 let old_value = state(proxy(gradio.props.value)); 98 99 user_effect(() => { 100 if (get(old_value) != gradio.props.value) { 101 set(old_value, gradio.props.value, true); 102 gradio.dispatch("change"); 103 } 104 }); 105 106 Block($$anchor, { 107 get visible() { 108 return gradio.shared.visible; 109 }, 110 type: 'fieldset', 111 get elem_id() { 112 return gradio.shared.elem_id; 113 }, 114 115 get elem_classes() { 116 return gradio.shared.elem_classes; 117 }, 118 119 get container() { 120 return gradio.shared.container; 121 }, 122 123 get scale() { 124 return gradio.shared.scale; 125 }, 126 127 get min_width() { 128 return gradio.shared.min_width; 129 }, 130 131 get rtl() { 132 return gradio.props.rtl; 133 }, 134 135 children: ($$anchor, $$slotProps) => { 136 var fragment_1 = root_1(); 137 var node = first_child(fragment_1); 138 139 Static(node, spread_props( 140 { 141 get autoscroll() { 142 return gradio.shared.autoscroll; 143 }, 144 145 get i18n() { 146 return gradio.i18n; 147 } 148 }, 149 () => gradio.shared.loading_status, 150 { 151 on_clear_status: () => gradio.dispatch("clear_status", gradio.shared.loading_status) 152 } 153 )); 154
155 var node_1 = sibling(node, 2); 156 157 { 158 var consequent = ($$anchor) => { 159 IconButtonWrapper($$anchor, { 160 get buttons() { 161 return gradio.props.buttons; 162 }, 163 164 on_custom_button_click: (id) => { 165 gradio.dispatch("custom_button_click", { id }); 166 } 167 }); 168 }; 169 170 if_block(node_1, ($$render) => { 171 if (gradio.shared.show_label && gradio.props.buttons && gradio.props.buttons.length > 0) $$render(consequent); 172 }); 173 } 174 175 var node_2 = sibling(node_1, 2); 176 177 BlockTitle(node_2, { 178 get show_label() { 179 return gradio.shared.show_label; 180 }, 181 182 get info() { 183 return gradio.props.info; 184 }, 185 186 children: ($$anchor, $$slotProps) => { 187 next(); 188 189 var text$1 = text(); 190 191 template_effect(($0) => set_text(text$1, $0), [() => gradio.shared.label || gradio.i18n("radio.radio")]); 192 append($$anchor, text$1); 193 }, 194 $$slots: { default: true } 195 }); 196 197 var div = sibling(node_2, 2); 198 199 each(div, 21, () => gradio.props.choices, index, ($$anchor, $$item, i) => { 200 var $$array = user_derived(() => to_array(get($$item), 2)); 201 let display_value = () => get($$array)[0]; 202 let internal_value = () => get($$array)[1]; 203 204 Radio($$anchor, { 205 get display_value() { 206 return display_value(); 207 }, 208 209 get internal_value() { 210 return internal_value(); 211 }, 212 213 get disabled() { 214 return get(disabled); 215 }, 216 217 get rtl() { 218 return gradio.props.rtl; 219 }, 220 221 on_input: () => { 222 gradio.dispatch("input"); 223 gradio.dispatch("select", { value: internal_value(), index: i }); 224 }, 225 226 get selected() { 227 return gradio.props.value; 228 }, 229 230 set selected($$value) { 231 gradio.props.value = $$value; 232 } 233 }); 234 }); 235 236 reset(div); 237 append($$anchor, fragment_1); 238 }, 239 $$slots: { default: true } 240 }); 241 242 pop(); 243} 244 245export { Radio as BaseRadio, Index as default }; 246//# sourceMappingURL=Index-CEkl9UYg.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.