gradio-pr-bot commited on
Commit
8a6e0be
·
verified ·
1 Parent(s): 443762f

Upload folder using huggingface_hub

Browse files
6.4.0/multimodaltextbox/shared/MultimodalTextbox.svelte CHANGED
@@ -7,7 +7,7 @@
7
  tick
8
  } from "svelte";
9
  import { text_area_resize, resize } from "../shared/utils";
10
- import { BlockTitle } from "@gradio/atoms";
11
  import { Upload } from "@gradio/upload";
12
  import { Image } from "@gradio/image/shared";
13
  import type { I18nFormatter } from "js/core/src/gradio_helper";
@@ -24,7 +24,7 @@
24
  Microphone,
25
  Check
26
  } from "@gradio/icons";
27
- import type { SelectData } from "@gradio/utils";
28
  import { BaseInteractiveAudio as InteractiveAudio } from "@gradio/audio";
29
  import {
30
  MinimalAudioPlayer,
@@ -77,6 +77,7 @@
77
  let can_scroll: boolean;
78
  let previous_scroll_top = 0;
79
  let user_has_scrolled_up = false;
 
80
  export let dragging = false;
81
  let uploading = false;
82
  // value can be null in multimodalchatinterface when loading a deep link
@@ -110,6 +111,14 @@
110
  $: if (value === null) value = { text: "", files: [] };
111
  $: (value, el && lines !== max_lines && resize(el, lines, max_lines));
112
 
 
 
 
 
 
 
 
 
113
  const dispatch = createEventDispatcher<{
114
  change: typeof value;
115
  submit: undefined;
@@ -206,6 +215,7 @@
206
  if (user_has_scrolled_to_bottom) {
207
  user_has_scrolled_up = false;
208
  }
 
209
  }
210
 
211
  async function handle_upload(detail: FileData | FileData[]): Promise<void> {
@@ -500,35 +510,38 @@
500
  <Paperclip />
501
  </button>
502
  {/if}
503
- <textarea
504
- data-testid="textbox"
505
- use:text_area_resize={{
506
- text: value.text,
507
- lines: lines,
508
- max_lines: max_lines
509
- }}
510
- class:no-label={!show_label}
511
- dir={rtl ? "rtl" : "ltr"}
512
- bind:value={value.text}
513
- bind:this={el}
514
- {placeholder}
515
- rows={lines}
516
- {disabled}
517
- on:keypress={handle_keypress}
518
- on:blur
519
- on:select={handle_select}
520
- on:focus
521
- on:scroll={handle_scroll}
522
- on:paste={handle_paste}
523
- style={text_align ? "text-align: " + text_align : ""}
524
- autocapitalize={html_attributes?.autocapitalize}
525
- autocorrect={html_attributes?.autocorrect}
526
- spellcheck={html_attributes?.spellcheck}
527
- autocomplete={html_attributes?.autocomplete}
528
- tabindex={html_attributes?.tabindex}
529
- enterkeyhint={html_attributes?.enterkeyhint}
530
- lang={html_attributes?.lang}
531
- />
 
 
 
532
 
533
  {#if sources && sources.includes("microphone")}
534
  <button
@@ -1006,4 +1019,13 @@
1006
  opacity: 1;
1007
  }
1008
  }
 
 
 
 
 
 
 
 
 
1009
  </style>
 
7
  tick
8
  } from "svelte";
9
  import { text_area_resize, resize } from "../shared/utils";
10
+ import { BlockTitle, ScrollFade } from "@gradio/atoms";
11
  import { Upload } from "@gradio/upload";
12
  import { Image } from "@gradio/image/shared";
13
  import type { I18nFormatter } from "js/core/src/gradio_helper";
 
24
  Microphone,
25
  Check
26
  } from "@gradio/icons";
27
+ import { should_show_scroll_fade, type SelectData } from "@gradio/utils";
28
  import { BaseInteractiveAudio as InteractiveAudio } from "@gradio/audio";
29
  import {
30
  MinimalAudioPlayer,
 
77
  let can_scroll: boolean;
78
  let previous_scroll_top = 0;
79
  let user_has_scrolled_up = false;
80
+ let show_fade = false;
81
  export let dragging = false;
82
  let uploading = false;
83
  // value can be null in multimodalchatinterface when loading a deep link
 
111
  $: if (value === null) value = { text: "", files: [] };
112
  $: (value, el && lines !== max_lines && resize(el, lines, max_lines));
113
 
114
+ function update_fade(): void {
115
+ show_fade = should_show_scroll_fade(el);
116
+ }
117
+
118
+ $: if (el && value.text !== undefined) {
119
+ tick().then(update_fade);
120
+ }
121
+
122
  const dispatch = createEventDispatcher<{
123
  change: typeof value;
124
  submit: undefined;
 
215
  if (user_has_scrolled_to_bottom) {
216
  user_has_scrolled_up = false;
217
  }
218
+ update_fade();
219
  }
220
 
221
  async function handle_upload(detail: FileData | FileData[]): Promise<void> {
 
510
  <Paperclip />
511
  </button>
512
  {/if}
513
+ <div class="textarea-wrapper">
514
+ <textarea
515
+ data-testid="textbox"
516
+ use:text_area_resize={{
517
+ text: value.text,
518
+ lines: lines,
519
+ max_lines: max_lines
520
+ }}
521
+ class:no-label={!show_label}
522
+ dir={rtl ? "rtl" : "ltr"}
523
+ bind:value={value.text}
524
+ bind:this={el}
525
+ {placeholder}
526
+ rows={lines}
527
+ {disabled}
528
+ on:keypress={handle_keypress}
529
+ on:blur
530
+ on:select={handle_select}
531
+ on:focus
532
+ on:scroll={handle_scroll}
533
+ on:paste={handle_paste}
534
+ style={text_align ? "text-align: " + text_align : ""}
535
+ autocapitalize={html_attributes?.autocapitalize}
536
+ autocorrect={html_attributes?.autocorrect}
537
+ spellcheck={html_attributes?.spellcheck}
538
+ autocomplete={html_attributes?.autocomplete}
539
+ tabindex={html_attributes?.tabindex}
540
+ enterkeyhint={html_attributes?.enterkeyhint}
541
+ lang={html_attributes?.lang}
542
+ />
543
+ <ScrollFade visible={show_fade} position="absolute" />
544
+ </div>
545
 
546
  {#if sources && sources.includes("microphone")}
547
  <button
 
1019
  opacity: 1;
1020
  }
1021
  }
1022
+
1023
+ .textarea-wrapper {
1024
+ position: relative;
1025
+ flex-grow: 1;
1026
+ }
1027
+
1028
+ .textarea-wrapper textarea {
1029
+ width: 100%;
1030
+ }
1031
  </style>