File tree 2 files changed +24
-2
lines changed
routes/docs/components/TextField
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 61
61
? (node ) => [autoFocus (node , typeof autofocus === ' object' ? autofocus : undefined )]
62
62
: undefined ;
63
63
export let operators: { label: string ; value: string }[] | undefined = undefined ;
64
- export let inputEl: HTMLInputElement | null = null ;
64
+ export let inputEl: HTMLInputElement | HTMLTextAreaElement | null = null ;
65
+ // this is a workaround because Input only accepts an HTMLInputElement, not a TextAreaElement
66
+ const inputHolder = {
67
+ set input(value : HTMLInputElement | null ) {
68
+ inputEl = value ;
69
+ },
70
+ };
65
71
export let debounceChange: boolean | number = false ;
66
72
export let classes: {
67
73
root? : string ;
327
333
{disabled }
328
334
value ={inputValue }
329
335
{autocapitalize }
336
+ bind:this ={inputEl }
330
337
on:input ={handleInput }
331
338
on:focus
332
339
on:blur
366
373
{max }
367
374
{step }
368
375
{actions }
369
- bind:inputEl
376
+ bind:inputEl ={ inputHolder . input }
370
377
on:input ={handleInput }
371
378
on:focus
372
379
on:blur
Original file line number Diff line number Diff line change 20
20
21
21
import Preview from ' $lib/components/Preview.svelte' ;
22
22
import Blockquote from ' $docs/Blockquote.svelte' ;
23
+ import Toggle from ' $lib/components/Toggle.svelte' ;
23
24
24
25
const numberOperators = [
25
26
{ label: ' =' , value: ' equal' },
40
41
let value = ' ' ;
41
42
let numberValue = 1 ;
42
43
let multilineValue = ' one\n two\n three' ;
44
+
45
+ let inputEl: HTMLInputElement | HTMLTextAreaElement | null = null ;
43
46
</script >
44
47
45
48
<h1 >Examples</h1 >
225
228
/>
226
229
</Preview >
227
230
231
+ <h2 >bind:inputEl</h2 >
232
+
233
+ <Preview >
234
+ <div class =" grid gap-2 justify-start" >
235
+ <Button on:click ={() => inputEl ?.focus ()}>Manually Focus</Button >
236
+ <Toggle let:on ={multiline } let:toggle >
237
+ <Button on:click ={toggle }>{multiline ? ' To single line' : ' To multiline' }</Button >
238
+ <TextField label ="Name" {multiline } bind:inputEl />
239
+ </Toggle >
240
+ </div >
241
+ </Preview >
242
+
228
243
<SectionDivider >Type</SectionDivider >
229
244
230
245
<h2 >Input types</h2 >
You can’t perform that action at this time.
0 commit comments