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