1import { g as spread_props, i as if_block, k as each, r as rest_props, u as index, v as set_checked, b as set_class, a as set_attribute, t as remove_input_defaults } from './i18n-CGlVUOvE.js'; 2import { M as push, ad as user_effect, N as first_child, a3 as comment, a as append, Z as get, S as sibling, a2 as user_derived, O as pop, R as from_html, t as template_effect, X as set_text, U as event, Q as child, a4 as text, as as to_array, T as reset } from './index-Bq2njFOY.js'; 3import { G as Gradio, a as snapshot } 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 { d as dequal } from './index-DnoGeqVF.js'; 12import './Info-CfqzbVCN.js'; 13import './MarkdownCode-BYKuypS7.js'; 14import './html-Bwif0JPw.js'; 15import './snippet-BG7qkY_1.js'; 16import './prism-python-NrKIQnfs.js'; 17import './Clear-C8Tfa7QP.js'; 18 19var root_4 = from_html(`<div class="select-all-container svelte-yb2gcx"><label class="select-all-label svelte-yb2gcx"><input class="select-all-checkbox svelte-yb2gcx" type="checkbox" title="Select/Deselect All"/></label> <button type="button" class="label-text svelte-yb2gcx"> </button></div>`); 20var root_7 = from_html(`<label><input type="checkbox" class="svelte-yb2gcx"/> <span class="ml-2 svelte-yb2gcx"> </span></label>`); 21var root_1 = from_html(`<!> <!> <!> <div class="wrap svelte-yb2gcx" data-testid="checkbox-group"></div>`, 1); 22 23function Index($$anchor, $$props) { 24 push($$props, true); 25 26 let props = rest_props($$props, ['$$slots', '$$events', '$$legacy']); 27 let gradio = new Gradio(props); 28 29 function toggle_choice(choice) { 30 if (gradio.props.value.includes(choice)) { 31 gradio.props.value = gradio.props.value.filter((v) => v !== choice); 32 } else { 33 gradio.props.value = [...gradio.props.value, choice]; 34 } 35 36 gradio.dispatch("input"); 37 } 38 39 function toggle_select_all() { 40 const all_values = gradio.props.choices.map(([, internal_value]) => internal_value); 41 42 if (gradio.props.value.length === all_values.length) { 43 gradio.props.value = []; 44 } else { 45 gradio.props.value = all_values.slice(); 46 } 47 48 gradio.dispatch("input"); 49 } 50 51 let select_all_state = user_derived(() => { 52 const all_values = gradio.props.choices.map(([, internal_value]) => internal_value); 53 54 if (gradio.props.value.length === 0) return "unchecked"; 55 if (gradio.props.value.length === all_values.length) return "checked"; 56 57 return "indeterminate"; 58 }); 59 60 let disabled = user_derived(() => !gradio.shared.interactive); 61 let old_value = gradio.props.value; 62 63 user_effect(() => { 64 gradio.props.value; 65 66 if (dequal(old_value, gradio.props.value)) { 67 return; 68 } 69 70 old_value = gradio.props.value; 71 gradio.dispatch("change", snapshot(gradio.props.value)); 72 }); 73 74 Block($$anchor, { 75 get visible() { 76 return gradio.shared.visible; 77 }, 78 79 get elem_id() { 80 return gradio.shared.elem_id; 81 }, 82 83 get elem_classes() { 84 return gradio.shared.elem_classes; 85 }, 86 type: 'fieldset', 87 get container() { 88 return gradio.shared.container; 89 }, 90 91 get scale() { 92 return gradio.shared.scale; 93 }, 94 95 get min_width() { 96 return gradio.shared.min_width; 97 }, 98 99 children: ($$anchor, $$slotProps) => { 100 var fragment_1 = root_1(); 101 var node = first_child(fragment_1); 102 103 Static(node, spread_props( 104 { 105 get autoscroll() { 106 return gradio.shared.autoscroll; 107 }, 108 109 get i18n() { 110 return gradio.i18n; 111 } 112 }, 113 () => gradio.shared.loading_status, 114 { 115 on_clear_status: () => gradio.dispatch("clear_status", gradio.shared.loading_status) 116 } 117 )); 118 119 var node_1 = sibling(node, 2); 120 121 { 122 var consequent = ($$anchor) => { 123 IconButtonWrapper($$anchor, { 124 get buttons() { 125 return gradio.props.buttons; 126 }, 127 128 on_custom_button_click: (id) => { 129 gradio.dispatch("custom_button_click", { id }); 130 } 131 }); 132 }; 133 134 if_block(node_1, ($$render) => { 135 if (gradio.shared.show_label && gradio.props.buttons && gradio.props.buttons.length > 0) $$render(consequent); 136 }); 137 } 138 139 var node_2 = sibling(node_1, 2); 140 141 { 142 let $0 = user_derived(() => gradio.shared.show_label || gradio.props.show_select_all && gradio.shared.interactive); 143 144 BlockTitle(node_2, { 145 get show_label() { 146 return get($0); 147 }, 148 149 get info() { 150 return gradio.props.info; 151 }, 152 153 children: ($$anchor, $$slotProps) => { 154 var fragment_3 = comment(); 155 var node_3 = first_child(fragment_3); 156 157 { 158 var consequent_1 = ($$anchor) => { 159 var div = root_4(); 160 var label = child(div); 161 var input = child(label); 162 163 remove_input_defaults(input); 164 reset(label); 165 166 var button = sibling(label, 2); 167 var text = child(button, true); 168 169 reset(button); 170 reset(div); 171 172 template_effect(() => { 173 set_checked(input, get(select_all_state) === "checked"); 174 input.indeterminate = get(select_all_state) === "indeterminate"; 175 set_text(text, gradio.shared.show_label ? gradio.shared.label : "Select All"); 176 }); 177 178 event('change', input, toggle_select_all); 179 event('click', button, toggle_select_all); 180 append($$anchor, div); 181 }; 182 183 var alternate = ($$anchor) => { 184 var fragment_4 = comment(); 185 var node_4 = first_child(fragment_4); 186 187 { 188 var consequent_2 = ($$anchor) => { 189 var text_1 = text(); 190 191 template_effect(($0) => set_text(text_1, $0), [ 192 () => gradio.shared.label || gradio.i18n("checkbox.checkbox_group") 193 ]); 194 195 append($$anchor, text_1); 196 }; 197 198 if_block( 199 node_4, 200 ($$render) => { 201 if (gradio.shared.show_label) $$render(consequent_2); 202 }, 203 true 204 ); 205 } 206 207 append($$anchor, fragment_4); 208 }; 209 210 if_block(node_3, ($$render) => { 211 if (gradio.props.show_select_all && gradio.shared.interactive) $$render(consequent_1); else $$render(alternate, false); 212 }); 213 } 214 215 append($$anchor, fragment_3); 216 }, 217 $$slots: { default: true } 218 }); 219 } 220 221 var div_1 = sibling(node_2, 2); 222 223 each(div_1, 21, () => gradio.props.choices, index, ($$anchor, $$item, i) => { 224 var $$array = user_derived(() => to_array(get($$item), 2)); 225 let display_value = () => get($$array)[0]; 226 let internal_value = () => get($$array)[1]; 227 var label_1 = root_7(); 228 let classes; 229 var input_1 = child(label_1); 230 231 remove_input_defaults(input_1); 232 233 var span = sibling(input_1, 2); 234 var text_2 = child(span, true); 235 236 reset(span);
237 reset(label_1); 238 239 template_effect( 240 ($0, $1, $2, $3) => { 241 classes = set_class(label_1, 1, 'svelte-yb2gcx', null, classes, $0); 242 input_1.disabled = get(disabled); 243 set_checked(input_1, $1); 244 set_attribute(input_1, 'name', $2); 245 set_attribute(input_1, 'title', $3); 246 set_text(text_2, display_value()); 247 }, 248 [ 249 () => ({ 250 disabled: get(disabled), 251 selected: gradio.props.value.includes(internal_value()) 252 }), 253 () => gradio.props.value.includes(internal_value()), 254 () => internal_value()?.toString(), 255 () => internal_value()?.toString() 256 ] 257 ); 258 259 event('change', input_1, () => toggle_choice(internal_value())); 260 261 event('input', input_1, (evt) => gradio.dispatch("select", { 262 index: i, 263 value: internal_value(), 264 selected: evt.currentTarget.checked 265 })); 266 267 event('keydown', input_1, (event) => { 268 if (event.key === "Enter") { 269 toggle_choice(internal_value()); 270 271 gradio.dispatch("select", { 272 index: i, 273 value: internal_value(), 274 selected: !gradio.props.value.includes(internal_value()) 275 }); 276 } 277 }); 278 279 append($$anchor, label_1); 280 }); 281 282 reset(div_1); 283 append($$anchor, fragment_1); 284 }, 285 $$slots: { default: true } 286 }); 287 288 pop(); 289} 290 291export { Index as default }; 292//# sourceMappingURL=Index-CnKzAZJw.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.