@@ -3,12 +3,11 @@ import type { Extracted, MaybeGetter } from "$lib/types";
33import { dataAttr , disabledAttr } from "$lib/utils/attribute" ;
44import { inBrowser } from "$lib/utils/browser" ;
55import { extract } from "$lib/utils/extract" ;
6- import { createDataIds , createId } from "$lib/utils/identifiers" ;
6+ import { createBuilderMetadata } from "$lib/utils/identifiers" ;
77import { isHtmlInputElement } from "$lib/utils/is" ;
88import type { HTMLInputAttributes } from "svelte/elements" ;
99
10- const identifiers = createDataIds ( "pin-input" , [ "root" , "input" ] ) ;
11-
10+ const { dataAttrs, dataSelectors, createIds } = createBuilderMetadata ( "pin-input" , [ "root" , "input" ] )
1211export type PinInputError = {
1312 method : "paste" | "input" ;
1413 message : string ;
@@ -122,7 +121,7 @@ function setInputSelectionRange(input: HTMLInputElement, start: number, end: num
122121}
123122
124123export class PinInput {
125- #id = createId ( ) ;
124+ #ids = createIds ( ) ;
126125
127126 /* Props */
128127 #props! : PinInputProps ;
@@ -143,15 +142,16 @@ export class PinInput {
143142 value : props . value ,
144143 onChange : props . onValueChange ,
145144 defaultValue : "" ,
145+ equalityCheck : true ,
146146 } ) ;
147147 this . #props = props ;
148148 }
149149
150150 #getInputEls( ) : HTMLInputElement [ ] {
151151 if ( ! inBrowser ( ) ) return [ ] ;
152- const rootEl = document . getElementById ( this . #id ) ;
152+ const rootEl = document . getElementById ( this . #ids . root ) ;
153153 if ( ! rootEl ) return [ ] ;
154- return [ ...rootEl . querySelectorAll ( `[ ${ identifiers . input } ]` ) ] . filter ( isHtmlInputElement ) ;
154+ return [ ...rootEl . querySelectorAll ( dataSelectors . input ) ] . filter ( isHtmlInputElement ) ;
155155 }
156156
157157 get value ( ) {
@@ -176,8 +176,8 @@ export class PinInput {
176176 /** The root element's props. */
177177 get root ( ) {
178178 return {
179- [ identifiers . root ] : "" ,
180- id : this . #id ,
179+ [ dataAttrs . root ] : "" ,
180+ id : this . #ids . root ,
181181 "data-complete" : dataAttr ( this . isFilled ) ,
182182 } as const ;
183183 }
@@ -234,7 +234,7 @@ export class PinInput {
234234 } ;
235235
236236 return {
237- [ identifiers . input ] : "" ,
237+ [ dataAttrs . input ] : "" ,
238238 placeholder : isFocused ? undefined : this . placeholder ,
239239 disabled : disabledAttr ( this . disabled ) ,
240240 type : this . mask ? "password" : "text" ,
0 commit comments