1import { S as SvelteComponent, i as init, s as safe_not_equal, f as element, m as space, h as text, b as attr, t as toggle_class, c as insert, d as append, l as listen, j as set_data, n as noop, e as detach, A as createEventDispatcher, q as create_component, u as mount_component, v as transition_in, w as transition_out, x as destroy_component, L as assign, M as StatusTracker, D as binding_callbacks, J as bind, N as get_spread_update, O as get_spread_object, G as add_flush_callback, F as bubble } from './index.230aa104.js'; 2import { g as get_styles } from './styles.db46e346.js'; 3import { B as Block } from './Block.67caaa62.js'; 4 5/* home/runner/work/gradio/gradio/ui/packages/form/src/Checkbox.svelte generated by Svelte v3.49.0 */ 6 7function create_fragment$1(ctx) { 8 let label_1; 9 let input; 10 let input_class_value; 11 let t0; 12 let span; 13 let t1; 14 let mounted; 15 let dispose; 16 17 return { 18 c() { 19 label_1 = element("label"); 20 input = element("input"); 21 t0 = space(); 22 span = element("span"); 23 t1 = text(/*label*/ ctx[2]); 24 input.disabled = /*disabled*/ ctx[1]; 25 input.checked = /*value*/ ctx[0]; 26 attr(input, "type", "checkbox"); 27 attr(input, "name", "test"); 28 attr(input, "class", input_class_value = "gr-check-radio gr-checkbox " + /*rounded*/ ctx[4] + " " + /*border*/ ctx[3]); 29 attr(span, "class", "ml-2"); 30 attr(label_1, "class", "flex items-center text-gray-700 text-sm space-x-2 rounded-lg cursor-pointer dark:bg-transparent "); 31 toggle_class(label_1, "!cursor-not-allowed", /*disabled*/ ctx[1]); 32 }, 33 m(target, anchor) { 34 insert(target, label_1, anchor); 35 append(label_1, input); 36 append(label_1, t0); 37 append(label_1, span); 38 append(span, t1); 39 40 if (!mounted) { 41 dispose = listen(input, "change", /*change_handler*/ ctx[7]); 42 mounted = true; 43 } 44 }, 45 p(ctx, [dirty]) { 46 if (dirty & /*disabled*/ 2) { 47 input.disabled = /*disabled*/ ctx[1]; 48 } 49 50 if (dirty & /*value*/ 1) { 51 input.checked = /*value*/ ctx[0]; 52 } 53 54 if (dirty & /*rounded, border*/ 24 && input_class_value !== (input_class_value = "gr-check-radio gr-checkbox " + /*rounded*/ ctx[4] + " " + /*border*/ ctx[3])) { 55 attr(input, "class", input_class_value); 56 } 57 58 if (dirty & /*label*/ 4) set_data(t1, /*label*/ ctx[2]); 59 60 if (dirty & /*disabled*/ 2) { 61 toggle_class(label_1, "!cursor-not-allowed", /*disabled*/ ctx[1]); 62 } 63 }, 64 i: noop, 65 o: noop, 66 d(detaching) { 67 if (detaching) detach(label_1); 68 mounted = false; 69 dispose(); 70 } 71 }; 72} 73 74function instance$1($$self, $$props, $$invalidate) { 75 let rounded; 76 let border; 77 let { value } = $$props; 78 let { style = {} } = $$props; 79 let { disabled = false } = $$props; 80 let { label } = $$props; 81 82 // export let show_label: boolean; 83 const dispatch = createEventDispatcher(); 84 85 function handle_change(evt) { 86 $$invalidate(0, value = evt.currentTarget.checked); 87 dispatch("change", value); 88 } 89 90 const change_handler = evt => handle_change(evt); 91 92 $$self.$$set = $$props => {
93 if ('value' in $$props) $$invalidate(0, value = $$props.value); 94 if ('style' in $$props) $$invalidate(6, style = $$props.style); 95 if ('disabled' in $$props) $$invalidate(1, disabled = $$props.disabled); 96 if ('label' in $$props) $$invalidate(2, label = $$props.label); 97 }; 98 99 $$self.$$.update = () => { 100 if ($$self.$$.dirty & /*style*/ 64) { 101 $$invalidate(4, { rounded, border } = get_styles(style, ["rounded", "border"]), rounded, ($$invalidate(3, border), $$invalidate(6, style))); 102 } 103 }; 104 105 return [value, disabled, label, border, rounded, handle_change, style, change_handler]; 106} 107 108class Checkbox extends SvelteComponent { 109 constructor(options) { 110 super(); 111 112 init(this, options, instance$1, create_fragment$1, safe_not_equal, { 113 value: 0, 114 style: 6, 115 disabled: 1, 116 label: 2 117 }); 118 } 119} 120 121/* src/components/Checkbox/Checkbox.svelte generated by Svelte v3.49.0 */ 122 123function create_default_slot(ctx) { 124 let statustracker; 125 let t; 126 let checkbox; 127 let updating_value; 128 let current; 129 const statustracker_spread_levels = [/*loading_status*/ ctx[7]]; 130 let statustracker_props = {}; 131 132 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 133 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 134 } 135 136 statustracker = new StatusTracker({ props: statustracker_props }); 137 138 function checkbox_value_binding(value) { 139 /*checkbox_value_binding*/ ctx[8](value); 140 } 141 142 let checkbox_props = { 143 label: /*label*/ ctx[3], 144 style: /*style*/ ctx[6], 145 disabled: /*mode*/ ctx[4] === "static" 146 }; 147 148 if (/*value*/ ctx[0] !== void 0) { 149 checkbox_props.value = /*value*/ ctx[0]; 150 } 151 152 checkbox = new Checkbox({ props: checkbox_props }); 153 binding_callbacks.push(() => bind(checkbox, 'value', checkbox_value_binding)); 154 checkbox.$on("change", /*change_handler*/ ctx[9]); 155 156 return { 157 c() { 158 create_component(statustracker.$$.fragment); 159 t = space(); 160 create_component(checkbox.$$.fragment); 161 }, 162 m(target, anchor) { 163 mount_component(statustracker, target, anchor); 164 insert(target, t, anchor); 165 mount_component(checkbox, target, anchor); 166 current = true; 167 }, 168 p(ctx, dirty) { 169 const statustracker_changes = (dirty & /*loading_status*/ 128) 170 ? get_spread_update(statustracker_spread_levels, [get_spread_object(/*loading_status*/ ctx[7])]) 171 : {}; 172 173 statustracker.$set(statustracker_changes); 174 const checkbox_changes = {}; 175 if (dirty & /*label*/ 8) checkbox_changes.label = /*label*/ ctx[3]; 176 if (dirty & /*style*/ 64) checkbox_changes.style = /*style*/ ctx[6]; 177 if (dirty & /*mode*/ 16) checkbox_changes.disabled = /*mode*/ ctx[4] === "static"; 178 179 if (!updating_value && dirty & /*value*/ 1) { 180 updating_value = true; 181 checkbox_changes.value = /*value*/ ctx[0]; 182 add_flush_callback(() => updating_value = false); 183 } 184 185 checkbox.$set(checkbox_changes); 186 }, 187 i(local) { 188 if (current) return; 189 transition_in(statustracker.$$.fragment, local); 190 transition_in(checkbox.$$.fragment, local); 191 current = true; 192 }, 193 o(local) { 194 transition_out(statustracker.$$.fragment, local); 195 transition_out(checkbox.$$.fragment, local); 196 current = false; 197 }, 198 d(detaching) { 199 destroy_component(statustracker, detaching); 200 if (detaching) detach(t); 201 destroy_component(checkbox, detaching); 202 } 203 }; 204} 205 206function create_fragment(ctx) { 207 let block; 208 let current; 209 210 block = new Block({ 211 props: { 212 visible: /*visible*/ ctx[2], 213 form_position: /*form_position*/ ctx[5], 214 elem_id: /*elem_id*/ ctx[1], 215 disable: typeof /*style*/ ctx[6].container === "boolean" && !/*style*/ ctx[6].container, 216 $$slots: { default: [create_default_slot] }, 217 $$scope: { ctx } 218 } 219 }); 220 221 return { 222 c() { 223 create_component(block.$$.fragment); 224 }, 225 m(target, anchor) { 226 mount_component(block, target, anchor); 227 current = true; 228 }, 229 p(ctx, [dirty]) { 230 const block_changes = {}; 231 if (dirty & /*visible*/ 4) block_changes.visible = /*visible*/ ctx[2]; 232 if (dirty & /*form_position*/ 32) block_changes.form_position = /*form_position*/ ctx[5]; 233 if (dirty & /*elem_id*/ 2) block_changes.elem_id = /*elem_id*/ ctx[1];
234 if (dirty & /*style*/ 64) block_changes.disable = typeof /*style*/ ctx[6].container === "boolean" && !/*style*/ ctx[6].container; 235 236 if (dirty & /*$$scope, label, style, mode, value, loading_status*/ 1241) { 237 block_changes.$$scope = { dirty, ctx }; 238 } 239 240 block.$set(block_changes); 241 }, 242 i(local) { 243 if (current) return; 244 transition_in(block.$$.fragment, local); 245 current = true; 246 }, 247 o(local) { 248 transition_out(block.$$.fragment, local); 249 current = false; 250 }, 251 d(detaching) { 252 destroy_component(block, detaching); 253 } 254 }; 255} 256 257function instance($$self, $$props, $$invalidate) { 258 let { elem_id = "" } = $$props; 259 let { visible = true } = $$props; 260 let { value = false } = $$props; 261 let { label = "Checkbox" } = $$props; 262 let { mode } = $$props; 263 let { form_position = "single" } = $$props; 264 let { style = {} } = $$props; 265 let { loading_status } = $$props; 266 267 function checkbox_value_binding(value$1) { 268 value = value$1; 269 $$invalidate(0, value); 270 } 271 272 function change_handler(event) { 273 bubble.call(this, $$self, event); 274 } 275 276 $$self.$$set = $$props => {
277 if ('elem_id' in $$props) $$invalidate(1, elem_id = $$props.elem_id); 278 if ('visible' in $$props) $$invalidate(2, visible = $$props.visible); 279 if ('value' in $$props) $$invalidate(0, value = $$props.value); 280 if ('label' in $$props) $$invalidate(3, label = $$props.label); 281 if ('mode' in $$props) $$invalidate(4, mode = $$props.mode); 282 if ('form_position' in $$props) $$invalidate(5, form_position = $$props.form_position); 283 if ('style' in $$props) $$invalidate(6, style = $$props.style); 284 if ('loading_status' in $$props) $$invalidate(7, loading_status = $$props.loading_status); 285 }; 286 287 return [ 288 value, 289 elem_id, 290 visible, 291 label, 292 mode, 293 form_position, 294 style, 295 loading_status, 296 checkbox_value_binding, 297 change_handler 298 ]; 299} 300 301class Checkbox_1 extends SvelteComponent { 302 constructor(options) { 303 super(); 304 305 init(this, options, instance, create_fragment, safe_not_equal, { 306 elem_id: 1, 307 visible: 2, 308 value: 0, 309 label: 3, 310 mode: 4, 311 form_position: 5, 312 style: 6, 313 loading_status: 7 314 }); 315 } 316} 317 318var Checkbox_1$1 = Checkbox_1; 319 320const modes = ["static", "dynamic"]; 321 322export { Checkbox_1$1 as Component, modes };
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.