@@ -34,6 +34,7 @@ interface PinInputRootStateOpts
3434 extends WithRefOpts ,
3535 WritableBoxedValues < {
3636 value : string ;
37+ inputRef : HTMLInputElement | null ;
3738 } > ,
3839 ReadableBoxedValues < {
3940 inputId : string ;
@@ -83,9 +84,8 @@ export class PinInputRootState {
8384
8485 readonly opts : PinInputRootStateOpts ;
8586 readonly attachment : RefAttachment ;
86- #inputRef = simpleBox < HTMLInputElement | null > ( null ) ;
87+ readonly inputAttachment : RefAttachment < HTMLInputElement > ;
8788 #isHoveringInput = $state ( false ) ;
88- readonly inputAttachment : RefAttachment < HTMLInputElement > = attachRef ( this . #inputRef) ;
8989 #isFocused = simpleBox ( false ) ;
9090 #mirrorSelectionStart = $state < number | null > ( null ) ;
9191 #mirrorSelectionEnd = $state < number | null > ( null ) ;
@@ -110,6 +110,7 @@ export class PinInputRootState {
110110 constructor ( opts : PinInputRootStateOpts ) {
111111 this . opts = opts ;
112112 this . attachment = attachRef ( this . opts . ref ) ;
113+ this . inputAttachment = attachRef ( this . opts . inputRef ) ;
113114 this . domContext = new DOMContext ( opts . ref ) ;
114115
115116 this . #initialLoad = {
@@ -121,14 +122,14 @@ export class PinInputRootState {
121122
122123 this . #pwmb = usePasswordManagerBadge ( {
123124 containerRef : this . opts . ref ,
124- inputRef : this . # inputRef,
125+ inputRef : this . opts . inputRef ,
125126 isFocused : this . #isFocused,
126127 pushPasswordManagerStrategy : this . opts . pushPasswordManagerStrategy ,
127128 domContext : this . domContext ,
128129 } ) ;
129130
130131 onMount ( ( ) => {
131- const input = this . # inputRef. current ;
132+ const input = this . opts . inputRef . current ;
132133 const container = this . opts . ref . current ;
133134
134135 if ( ! input || ! container ) return ;
@@ -180,9 +181,9 @@ export class PinInputRootState {
180181 } ;
181182 } ) ;
182183
183- watch ( [ ( ) => this . opts . value . current , ( ) => this . # inputRef. current ] , ( ) => {
184+ watch ( [ ( ) => this . opts . value . current , ( ) => this . opts . inputRef . current ] , ( ) => {
184185 syncTimeouts ( ( ) => {
185- const input = this . # inputRef. current ;
186+ const input = this . opts . inputRef . current ;
186187 if ( ! input ) return ;
187188 // forcefully remove :autofill state
188189 input . dispatchEvent ( new Event ( "input" ) ) ;
@@ -313,7 +314,7 @@ export class PinInputRootState {
313314 }
314315
315316 #onDocumentSelectionChange = ( ) => {
316- const input = this . # inputRef. current ;
317+ const input = this . opts . inputRef . current ;
317318 const container = this . opts . ref . current ;
318319 if ( ! input || ! container ) return ;
319320
@@ -363,7 +364,7 @@ export class PinInputRootState {
363364 }
364365
365366 if ( start !== - 1 && end !== - 1 && start !== end ) {
366- this . # inputRef. current ?. setSelectionRange ( start , end , direction ) ;
367+ this . opts . inputRef . current ?. setSelectionRange ( start , end , direction ) ;
367368 }
368369 }
369370
@@ -398,7 +399,7 @@ export class PinInputRootState {
398399 } ;
399400
400401 onfocus = ( _ : BitsFocusEvent < HTMLInputElement > ) => {
401- const input = this . # inputRef. current ;
402+ const input = this . opts . inputRef . current ;
402403 if ( input ) {
403404 const start = Math . min ( input . value . length , this . opts . maxLength . current - 1 ) ;
404405 const end = input . value . length ;
@@ -410,7 +411,7 @@ export class PinInputRootState {
410411 } ;
411412
412413 onpaste = ( e : BitsEvent < ClipboardEvent > ) => {
413- const input = this . # inputRef. current ;
414+ const input = this . opts . inputRef . current ;
414415 if ( ! input ) return ;
415416
416417 const getNewValue = ( finalContent : string | undefined ) => {
0 commit comments