@westpac/ui 1.12.0 → 1.13.1
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.
- package/CHANGELOG.md +13 -0
- package/dist/component-type.json +1 -1
- package/dist/components/button/button.styles.js +1 -1
- package/dist/components/button-group/button-group.types.d.ts +0 -1
- package/dist/components/pass-code/pass-code.component.js +31 -21
- package/package.json +4 -1
- package/src/components/button/button.styles.ts +1 -1
- package/src/components/button-group/button-group.types.ts +0 -1
- package/src/components/pass-code/pass-code.component.tsx +34 -21
- package/utils/build-svg-zip/index.ts +1 -1
|
@@ -27,7 +27,6 @@ type ButtonGroupPropsPerSelectionMode = {
|
|
|
27
27
|
defaultSelectedKeys?: Key;
|
|
28
28
|
/** Handler that is called when the selection changes. */
|
|
29
29
|
onSelectionChange?: (key: Key) => void;
|
|
30
|
-
batata?: string;
|
|
31
30
|
};
|
|
32
31
|
multiple: BaseButtonGroupProps & {
|
|
33
32
|
selectionMode: 'multiple';
|
|
@@ -21,25 +21,35 @@ export const PassCode = forwardRef(({ length, value, onChange, onComplete, onPas
|
|
|
21
21
|
}
|
|
22
22
|
}));
|
|
23
23
|
const handleChange = useCallback((index, event)=>{
|
|
24
|
-
const inputValue = event.target.value
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
const inputValue = event.target.value;
|
|
25
|
+
const validData = inputValue.split('').filter((char)=>{
|
|
26
|
+
if (type === 'numbers') return /^\d$/.test(char);
|
|
27
|
+
if (type === 'letters') return /^[a-zA-Z]$/.test(char);
|
|
28
|
+
return /^[a-zA-Z0-9]$/.test(char);
|
|
29
|
+
}).slice(0, length - index);
|
|
30
|
+
if (validData.length === 0) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const previousSlice = passcode.slice(0, index);
|
|
34
|
+
const afterSlice = passcode.slice(index);
|
|
35
|
+
const newPasscode = [
|
|
36
|
+
...previousSlice,
|
|
37
|
+
...[
|
|
38
|
+
...validData,
|
|
39
|
+
...afterSlice.slice(validData.length)
|
|
40
|
+
]
|
|
41
|
+
].slice(0, length);
|
|
42
|
+
if (onChange) {
|
|
43
|
+
onChange(newPasscode);
|
|
44
|
+
} else {
|
|
45
|
+
setInternalPasscode(newPasscode);
|
|
46
|
+
}
|
|
47
|
+
if (index + validData.length < length) {
|
|
48
|
+
var _inputRefs_current_;
|
|
49
|
+
(_inputRefs_current_ = inputRefs.current[index + validData.length]) === null || _inputRefs_current_ === void 0 ? void 0 : _inputRefs_current_.focus();
|
|
50
|
+
}
|
|
51
|
+
if (newPasscode.filter((passcode)=>!passcode).length === 0 && onComplete) {
|
|
52
|
+
onComplete(newPasscode.join(''));
|
|
43
53
|
}
|
|
44
54
|
}, [
|
|
45
55
|
passcode,
|
|
@@ -51,11 +61,11 @@ export const PassCode = forwardRef(({ length, value, onChange, onComplete, onPas
|
|
|
51
61
|
const handlePaste = useCallback((index, event)=>{
|
|
52
62
|
event.preventDefault();
|
|
53
63
|
const pastedData = event.clipboardData.getData('text');
|
|
54
|
-
const validData = pastedData.
|
|
64
|
+
const validData = pastedData.split('').filter((char)=>{
|
|
55
65
|
if (type === 'numbers') return /^\d$/.test(char);
|
|
56
66
|
if (type === 'letters') return /^[a-zA-Z]$/.test(char);
|
|
57
67
|
return /^[a-zA-Z0-9]$/.test(char);
|
|
58
|
-
});
|
|
68
|
+
}).slice(0, length - index);
|
|
59
69
|
const previousSlice = passcode.slice(0, index);
|
|
60
70
|
const afterSlice = passcode.slice(index);
|
|
61
71
|
const newPasscode = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@westpac/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -73,6 +73,9 @@
|
|
|
73
73
|
"./date-picker": {
|
|
74
74
|
"default": "./dist/components/date-picker/index.js"
|
|
75
75
|
},
|
|
76
|
+
"./dropdown": {
|
|
77
|
+
"default": "./dist/components/dropdown/index.js"
|
|
78
|
+
},
|
|
76
79
|
"./error-message": {
|
|
77
80
|
"default": "./dist/components/error-message/index.js"
|
|
78
81
|
},
|
|
@@ -34,7 +34,6 @@ type ButtonGroupPropsPerSelectionMode = {
|
|
|
34
34
|
defaultSelectedKeys?: Key;
|
|
35
35
|
/** Handler that is called when the selection changes. */
|
|
36
36
|
onSelectionChange?: (key: Key) => void;
|
|
37
|
-
batata?: string;
|
|
38
37
|
};
|
|
39
38
|
multiple: BaseButtonGroupProps & {
|
|
40
39
|
selectionMode: 'multiple';
|
|
@@ -51,26 +51,39 @@ export const PassCode = forwardRef<PassCodeRef, PassCodeProps>(
|
|
|
51
51
|
|
|
52
52
|
const handleChange = useCallback(
|
|
53
53
|
(index: number, event: ChangeEvent<HTMLInputElement>) => {
|
|
54
|
-
const inputValue = event.target.value
|
|
55
|
-
|
|
56
|
-
(
|
|
57
|
-
(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} else {
|
|
64
|
-
setInternalPasscode(newPasscode);
|
|
65
|
-
}
|
|
54
|
+
const inputValue = event.target.value;
|
|
55
|
+
const validData = inputValue
|
|
56
|
+
.split('')
|
|
57
|
+
.filter(char => {
|
|
58
|
+
if (type === 'numbers') return /^\d$/.test(char);
|
|
59
|
+
if (type === 'letters') return /^[a-zA-Z]$/.test(char);
|
|
60
|
+
return /^[a-zA-Z0-9]$/.test(char);
|
|
61
|
+
})
|
|
62
|
+
.slice(0, length - index);
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
if (validData.length === 0) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const previousSlice = passcode.slice(0, index);
|
|
69
|
+
const afterSlice = passcode.slice(index);
|
|
70
|
+
const newPasscode = [...previousSlice, ...[...validData, ...afterSlice.slice(validData.length)]].slice(
|
|
71
|
+
0,
|
|
72
|
+
length,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (onChange) {
|
|
76
|
+
onChange(newPasscode);
|
|
77
|
+
} else {
|
|
78
|
+
setInternalPasscode(newPasscode);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Move to the next input if available
|
|
82
|
+
if (index + validData.length < length) {
|
|
83
|
+
inputRefs.current[index + validData.length]?.focus();
|
|
84
|
+
}
|
|
85
|
+
if (newPasscode.filter(passcode => !passcode).length === 0 && onComplete) {
|
|
86
|
+
onComplete(newPasscode.join(''));
|
|
74
87
|
}
|
|
75
88
|
},
|
|
76
89
|
[passcode, length, onChange, onComplete, type],
|
|
@@ -81,13 +94,13 @@ export const PassCode = forwardRef<PassCodeRef, PassCodeProps>(
|
|
|
81
94
|
event.preventDefault();
|
|
82
95
|
const pastedData = event.clipboardData.getData('text');
|
|
83
96
|
const validData = pastedData
|
|
84
|
-
.slice(0, length - index)
|
|
85
97
|
.split('')
|
|
86
98
|
.filter(char => {
|
|
87
99
|
if (type === 'numbers') return /^\d$/.test(char);
|
|
88
100
|
if (type === 'letters') return /^[a-zA-Z]$/.test(char);
|
|
89
101
|
return /^[a-zA-Z0-9]$/.test(char);
|
|
90
|
-
})
|
|
102
|
+
})
|
|
103
|
+
.slice(0, length - index);
|
|
91
104
|
const previousSlice = passcode.slice(0, index);
|
|
92
105
|
const afterSlice = passcode.slice(index);
|
|
93
106
|
const newPasscode = [...previousSlice, ...[...validData, ...afterSlice.slice(validData.length)]].slice(
|
|
@@ -19,7 +19,7 @@ const exportZip = (zipRoot: string, zipFiles: string[], zipStoragePath: string,
|
|
|
19
19
|
const filePath = path.resolve(file);
|
|
20
20
|
const fileData = fs.readFileSync(filePath);
|
|
21
21
|
const relativePath = path.relative('assets', file);
|
|
22
|
-
const zipPathInArchive = path.join(zipRoot, type, relativePath.replace(`${type}
|
|
22
|
+
const zipPathInArchive = path.join(zipRoot, type, relativePath.replace(`${type}${path.sep}`, ''));
|
|
23
23
|
zip.addFile(zipPathInArchive, fileData);
|
|
24
24
|
});
|
|
25
25
|
|