@westpac/ui 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
3
3
|
import { Input } from '../index.js';
|
|
4
4
|
import { styles as passCodeStyles } from './pass-code.styles.js';
|
|
5
|
-
export const PassCode = forwardRef(({ length, value, onChange, onComplete, onPasteComplete, className, type = 'alphanumeric', onBlur, oneTimeCode, ...props }, ref)=>{
|
|
5
|
+
export const PassCode = forwardRef(({ length, value, onChange, onComplete, onPasteComplete, className, type = 'alphanumeric', onBlur, oneTimeCode, id, ...props }, ref)=>{
|
|
6
6
|
const [internalPasscode, setInternalPasscode] = useState(Array.from({
|
|
7
7
|
length
|
|
8
8
|
}).map(()=>''));
|
|
@@ -144,7 +144,8 @@ export const PassCode = forwardRef(({ length, value, onChange, onComplete, onPas
|
|
|
144
144
|
className: styles.input({}),
|
|
145
145
|
"aria-label": `Passcode digit ${index + 1}`,
|
|
146
146
|
inputMode: type === 'numbers' ? 'numeric' : 'text',
|
|
147
|
-
autoComplete: oneTimeCode ? 'one-time-code' : undefined
|
|
147
|
+
autoComplete: oneTimeCode ? 'one-time-code' : undefined,
|
|
148
|
+
id: id && `${id}-${index + 1}`
|
|
148
149
|
})));
|
|
149
150
|
});
|
|
150
151
|
PassCode.displayName = 'PassCode';
|
package/package.json
CHANGED
|
@@ -29,6 +29,7 @@ export const PassCode = forwardRef<PassCodeRef, PassCodeProps>(
|
|
|
29
29
|
type = 'alphanumeric',
|
|
30
30
|
onBlur,
|
|
31
31
|
oneTimeCode,
|
|
32
|
+
id,
|
|
32
33
|
...props
|
|
33
34
|
},
|
|
34
35
|
ref,
|
|
@@ -165,6 +166,7 @@ export const PassCode = forwardRef<PassCodeRef, PassCodeProps>(
|
|
|
165
166
|
aria-label={`Passcode digit ${index + 1}`}
|
|
166
167
|
inputMode={type === 'numbers' ? 'numeric' : 'text'}
|
|
167
168
|
autoComplete={oneTimeCode ? 'one-time-code' : undefined}
|
|
169
|
+
id={id && `${id}-${index + 1}`}
|
|
168
170
|
/>
|
|
169
171
|
))}
|
|
170
172
|
</div>
|