1import { B as Block } from './Button-f2ef1e3f.js'; 2import { B as BlockTitle } from './BlockTitle-8e3f82b6.js'; 3import { S as Static } from './Index-f4e7a341.js'; 4import './index-546f83db.js'; 5import './svelte/svelte.js'; 6import './Info-c6eafbfa.js'; 7 8const Index_svelte_svelte_type_style_lang = ''; 9 10/* home/runner/work/gradio/gradio/js/slider/Index.svelte generated by Svelte v4.2.2 */ 11const { 12 SvelteComponent, 13 append, 14 assign, 15 attr, 16 binding_callbacks, 17 create_component, 18 destroy_component, 19 detach, 20 element, 21 get_spread_object, 22 get_spread_update, 23 init, 24 insert, 25 listen, 26 mount_component, 27 run_all, 28 safe_not_equal, 29 set_data, 30 set_input_value, 31 space, 32 text, 33 to_number, 34 transition_in, 35 transition_out 36} = window.__gradio__svelte__internal;const { afterUpdate } = window.__gradio__svelte__internal; 37function create_default_slot_1(ctx) { 38 let t; 39 40 return { 41 c() { 42 t = text(/*label*/ ctx[5]); 43 }, 44 m(target, anchor) { 45 insert(target, t, anchor); 46 }, 47 p(ctx, dirty) { 48 if (dirty & /*label*/ 32) set_data(t, /*label*/ ctx[5]); 49 }, 50 d(detaching) { 51 if (detaching) { 52 detach(t); 53 } 54 } 55 }; 56} 57 58// (63:0) <Block {visible} {elem_id} {elem_classes} {container} {scale} {min_width}> 59function create_default_slot(ctx) { 60 let statustracker; 61 let t0; 62 let div1; 63 let div0; 64 let label_1; 65 let blocktitle; 66 let t1; 67 let input0; 68 let input0_aria_label_value; 69 let t2; 70 let input1; 71 let input1_aria_label_value; 72 let current; 73 let mounted; 74 let dispose; 75 76 const statustracker_spread_levels = [ 77 { autoscroll: /*gradio*/ ctx[1].autoscroll }, 78 { i18n: /*gradio*/ ctx[1].i18n }, 79 /*loading_status*/ ctx[14] 80 ]; 81 82 let statustracker_props = {}; 83 84 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 85 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 86 } 87 88 statustracker = new Static({ props: statustracker_props }); 89 90 blocktitle = new BlockTitle({ 91 props: { 92 show_label: /*show_label*/ ctx[13], 93 info: /*info*/ ctx[6], 94 $$slots: { default: [create_default_slot_1] }, 95 $$scope: { ctx } 96 } 97 }); 98 99 return { 100 c() { 101 create_component(statustracker.$$.fragment); 102 t0 = space(); 103 div1 = element("div"); 104 div0 = element("div"); 105 label_1 = element("label"); 106 create_component(blocktitle.$$.fragment); 107 t1 = space(); 108 input0 = element("input"); 109 t2 = space(); 110 input1 = element("input"); 111 attr(label_1, "for", /*id*/ ctx[18]); 112 attr(input0, "aria-label", input0_aria_label_value = `number input for ${/*label*/ ctx[5]}`); 113 attr(input0, "data-testid", "number-input"); 114 attr(input0, "type", "number"); 115 attr(input0, "min", /*minimum*/ ctx[10]); 116 attr(input0, "max", /*maximum*/ ctx[11]); 117 attr(input0, "step", /*step*/ ctx[12]); 118 input0.disabled = /*disabled*/ ctx[17]; 119 attr(input0, "class", "svelte-3iwdd6"); 120 attr(div0, "class", "head svelte-3iwdd6"); 121 attr(div1, "class", "wrap svelte-3iwdd6"); 122 attr(input1, "type", "range"); 123 attr(input1, "id", /*id*/ ctx[18]); 124 attr(input1, "name", "cowbell"); 125 attr(input1, "min", /*minimum*/ ctx[10]); 126 attr(input1, "max", /*maximum*/ ctx[11]); 127 attr(input1, "step", /*step*/ ctx[12]); 128 input1.disabled = /*disabled*/ ctx[17]; 129 attr(input1, "aria-label", input1_aria_label_value = `range slider for ${/*label*/ ctx[5]}`); 130 attr(input1, "class", "svelte-3iwdd6"); 131 }, 132 m(target, anchor) { 133 mount_component(statustracker, target, anchor); 134 insert(target, t0, anchor); 135 insert(target, div1, anchor); 136 append(div1, div0); 137 append(div0, label_1); 138 mount_component(blocktitle, label_1, null); 139 append(div0, t1); 140 append(div0, input0); 141 set_input_value(input0, /*value*/ ctx[0]); 142 /*input0_binding*/ ctx[24](input0); 143 insert(target, t2, anchor); 144 insert(target, input1, anchor); 145 set_input_value(input1, /*value*/ ctx[0]); 146 /*input1_binding*/ ctx[26](input1); 147 current = true; 148 149 if (!mounted) { 150 dispose = [ 151 listen(input0, "input", /*input0_input_handler*/ ctx[23]), 152 listen(input0, "blur", /*clamp*/ ctx[20]), 153 listen(input0, "pointerup", /*handle_release*/ ctx[19]), 154 listen(input1, "change", /*input1_change_input_handler*/ ctx[25]), 155 listen(input1, "input", /*input1_change_input_handler*/ ctx[25]), 156 listen(input1, "pointerup", /*handle_release*/ ctx[19]) 157 ]; 158 159 mounted = true; 160 } 161 }, 162 p(ctx, dirty) { 163 const statustracker_changes = (dirty & /*gradio, loading_status*/ 16386) 164 ? get_spread_update(statustracker_spread_levels, [ 165 dirty & /*gradio*/ 2 && { autoscroll: /*gradio*/ ctx[1].autoscroll }, 166 dirty & /*gradio*/ 2 && { i18n: /*gradio*/ ctx[1].i18n }, 167 dirty & /*loading_status*/ 16384 && get_spread_object(/*loading_status*/ ctx[14]) 168 ]) 169 : {}; 170 171 statustracker.$set(statustracker_changes); 172 const blocktitle_changes = {};
173 if (dirty & /*show_label*/ 8192) blocktitle_changes.show_label = /*show_label*/ ctx[13]; 174 if (dirty & /*info*/ 64) blocktitle_changes.info = /*info*/ ctx[6]; 175 176 if (dirty & /*$$scope, label*/ 1073741856) { 177 blocktitle_changes.$$scope = { dirty, ctx }; 178 } 179 180 blocktitle.$set(blocktitle_changes); 181 182 if (!current || dirty & /*label*/ 32 && input0_aria_label_value !== (input0_aria_label_value = `number input for ${/*label*/ ctx[5]}`)) { 183 attr(input0, "aria-label", input0_aria_label_value); 184 } 185 186 if (!current || dirty & /*minimum*/ 1024) { 187 attr(input0, "min", /*minimum*/ ctx[10]); 188 } 189 190 if (!current || dirty & /*maximum*/ 2048) { 191 attr(input0, "max", /*maximum*/ ctx[11]); 192 } 193 194 if (!current || dirty & /*step*/ 4096) { 195 attr(input0, "step", /*step*/ ctx[12]); 196 } 197 198 if (!current || dirty & /*disabled*/ 131072) { 199 input0.disabled = /*disabled*/ ctx[17]; 200 } 201 202 if (dirty & /*value*/ 1 && to_number(input0.value) !== /*value*/ ctx[0]) { 203 set_input_value(input0, /*value*/ ctx[0]); 204 } 205 206 if (!current || dirty & /*minimum*/ 1024) { 207 attr(input1, "min", /*minimum*/ ctx[10]); 208 } 209 210 if (!current || dirty & /*maximum*/ 2048) { 211 attr(input1, "max", /*maximum*/ ctx[11]); 212 } 213 214 if (!current || dirty & /*step*/ 4096) { 215 attr(input1, "step", /*step*/ ctx[12]); 216 } 217 218 if (!current || dirty & /*disabled*/ 131072) { 219 input1.disabled = /*disabled*/ ctx[17]; 220 } 221 222 if (!current || dirty & /*label*/ 32 && input1_aria_label_value !== (input1_aria_label_value = `range slider for ${/*label*/ ctx[5]}`)) { 223 attr(input1, "aria-label", input1_aria_label_value); 224 } 225 226 if (dirty & /*value*/ 1) { 227 set_input_value(input1, /*value*/ ctx[0]); 228 } 229 }, 230 i(local) { 231 if (current) return; 232 transition_in(statustracker.$$.fragment, local); 233 transition_in(blocktitle.$$.fragment, local); 234 current = true; 235 }, 236 o(local) { 237 transition_out(statustracker.$$.fragment, local); 238 transition_out(blocktitle.$$.fragment, local); 239 current = false; 240 }, 241 d(detaching) { 242 if (detaching) { 243 detach(t0); 244 detach(div1); 245 detach(t2); 246 detach(input1); 247 } 248 249 destroy_component(statustracker, detaching); 250 destroy_component(blocktitle); 251 /*input0_binding*/ ctx[24](null); 252 /*input1_binding*/ ctx[26](null); 253 mounted = false; 254 run_all(dispose); 255 } 256 }; 257} 258 259function create_fragment(ctx) { 260 let block; 261 let current; 262 263 block = new Block({ 264 props: { 265 visible: /*visible*/ ctx[4], 266 elem_id: /*elem_id*/ ctx[2], 267 elem_classes: /*elem_classes*/ ctx[3], 268 container: /*container*/ ctx[7], 269 scale: /*scale*/ ctx[8], 270 min_width: /*min_width*/ ctx[9], 271 $$slots: { default: [create_default_slot] }, 272 $$scope: { ctx } 273 } 274 }); 275 276 return { 277 c() { 278 create_component(block.$$.fragment); 279 }, 280 m(target, anchor) { 281 mount_component(block, target, anchor); 282 current = true; 283 }, 284 p(ctx, [dirty]) { 285 const block_changes = {}; 286 if (dirty & /*visible*/ 16) block_changes.visible = /*visible*/ ctx[4]; 287 if (dirty & /*elem_id*/ 4) block_changes.elem_id = /*elem_id*/ ctx[2]; 288 if (dirty & /*elem_classes*/ 8) block_changes.elem_classes = /*elem_classes*/ ctx[3]; 289 if (dirty & /*container*/ 128) block_changes.container = /*container*/ ctx[7]; 290 if (dirty & /*scale*/ 256) block_changes.scale = /*scale*/ ctx[8]; 291 if (dirty & /*min_width*/ 512) block_changes.min_width = /*min_width*/ ctx[9]; 292 293 if (dirty & /*$$scope, minimum, maximum, step, disabled, label, value, rangeInput, numberInput, show_label, info, gradio, loading_status*/ 1074003043) { 294 block_changes.$$scope = { dirty, ctx }; 295 } 296 297 block.$set(block_changes); 298 }, 299 i(local) { 300 if (current) return; 301 transition_in(block.$$.fragment, local); 302 current = true; 303 }, 304 o(local) { 305 transition_out(block.$$.fragment, local); 306 current = false; 307 }, 308 d(detaching) { 309 destroy_component(block, detaching); 310 } 311 }; 312} 313 314let _id = 0; 315 316function instance($$self, $$props, $$invalidate) { 317 let disabled; 318 let { gradio } = $$props; 319 let { elem_id = "" } = $$props; 320 let { elem_classes = [] } = $$props; 321 let { visible = true } = $$props; 322 let { value = 0 } = $$props; 323 let { label = gradio.i18n("slider.slider") } = $$props; 324 let { info = undefined } = $$props; 325 let { container = true } = $$props; 326 let { scale = null } = $$props; 327 let { min_width = undefined } = $$props; 328 let { minimum } = $$props; 329 let { maximum } = $$props; 330 let { step } = $$props; 331 let { show_label } = $$props; 332 let { interactive } = $$props; 333 let { loading_status } = $$props; 334 let { value_is_output = false } = $$props; 335 let rangeInput; 336 let numberInput; 337 const id = `range_id_${_id++}`; 338 339 function handle_change() { 340 gradio.dispatch("change"); 341 342 if (!value_is_output) { 343 gradio.dispatch("input"); 344 } 345 } 346 347 afterUpdate(() => {
348 $$invalidate(21, value_is_output = false); 349 setSlider(); 350 }); 351 352 function handle_release(e) { 353 gradio.dispatch("release", value); 354 } 355 356 function clamp() { 357 gradio.dispatch("release", value); 358 $$invalidate(0, value = Math.min(Math.max(value, minimum), maximum)); 359 } 360 361 function setSlider() { 362 setSliderRange(); 363 rangeInput.addEventListener("input", setSliderRange); 364 numberInput.addEventListener("input", setSliderRange); 365 } 366 367 function setSliderRange() { 368 $$invalidate(15, rangeInput.style.backgroundSize = (Number(rangeInput.value) - Number(rangeInput.min)) / (Number(rangeInput.max) - Number(rangeInput.min)) * 100 + "% 100%", rangeInput); 369 } 370 371 function input0_input_handler() { 372 value = to_number(this.value); 373 $$invalidate(0, value); 374 } 375 376 function input0_binding($$value) { 377 binding_callbacks[$$value ? 'unshift' : 'push'](() => { 378 numberInput = $$value; 379 $$invalidate(16, numberInput); 380 }); 381 } 382 383 function input1_change_input_handler() { 384 value = to_number(this.value); 385 $$invalidate(0, value); 386 } 387 388 function input1_binding($$value) { 389 binding_callbacks[$$value ? 'unshift' : 'push'](() => { 390 rangeInput = $$value; 391 $$invalidate(15, rangeInput); 392 }); 393 } 394 395 $$self.$$set = $$props => {
396 if ('gradio' in $$props) $$invalidate(1, gradio = $$props.gradio); 397 if ('elem_id' in $$props) $$invalidate(2, elem_id = $$props.elem_id); 398 if ('elem_classes' in $$props) $$invalidate(3, elem_classes = $$props.elem_classes); 399 if ('visible' in $$props) $$invalidate(4, visible = $$props.visible); 400 if ('value' in $$props) $$invalidate(0, value = $$props.value); 401 if ('label' in $$props) $$invalidate(5, label = $$props.label); 402 if ('info' in $$props) $$invalidate(6, info = $$props.info); 403 if ('container' in $$props) $$invalidate(7, container = $$props.container); 404 if ('scale' in $$props) $$invalidate(8, scale = $$props.scale); 405 if ('min_width' in $$props) $$invalidate(9, min_width = $$props.min_width); 406 if ('minimum' in $$props) $$invalidate(10, minimum = $$props.minimum); 407 if ('maximum' in $$props) $$invalidate(11, maximum = $$props.maximum); 408 if ('step' in $$props) $$invalidate(12, step = $$props.step); 409 if ('show_label' in $$props) $$invalidate(13, show_label = $$props.show_label); 410 if ('interactive' in $$props) $$invali
410date(22, interactive = $$props.interactive); 411 if ('loading_status' in $$props) $$invalidate(14, loading_status = $$props.loading_status); 412 if ('value_is_output' in $$props) $$invalidate(21, value_is_output = $$props.value_is_output); 413 }; 414 415 $$self.$$.update = () => { 416 if ($$self.$$.dirty & /*interactive*/ 4194304) { 417 $$invalidate(17, disabled = !interactive); 418 } 419 420 if ($$self.$$.dirty & /*value*/ 1) { 421 // When the value changes, dispatch the change event via handle_change() 422 // See the docs for an explanation: https://svelte.dev/docs/svelte-components#script-3-$-marks-a-statement-as-reactive 423 (handle_change()); 424 } 425 }; 426 427 return [ 428 value, 429 gradio, 430 elem_id, 431 elem_classes, 432 visible, 433 label, 434 info, 435 container, 436 scale, 437 min_width, 438 minimum, 439 maximum, 440 step, 441 show_label, 442 loading_status, 443 rangeInput, 444 numberInput, 445 disabled, 446 id, 447 handle_release, 448 clamp, 449 value_is_output, 450 interactive, 451 input0_input_handler, 452 input0_binding, 453 input1_change_input_handler, 454 input1_binding 455 ]; 456} 457 458class Index extends SvelteComponent { 459 constructor(options) { 460 super(); 461 462 init(this, options, instance, create_fragment, safe_not_equal, { 463 gradio: 1, 464 elem_id: 2, 465 elem_classes: 3, 466 visible: 4, 467 value: 0, 468 label: 5, 469 info: 6, 470 container: 7, 471 scale: 8, 472 min_width: 9, 473 minimum: 10, 474 maximum: 11, 475 step: 12, 476 show_label: 13, 477 interactive: 22, 478 loading_status: 14, 479 value_is_output: 21 480 }); 481 } 482} 483 484export { Index as default }; 485//# sourceMappingURL=Index-8a960a35.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.