@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.
@@ -5,7 +5,7 @@ export const styles = tv({
5
5
  iconBefore: '',
6
6
  iconAfter: '',
7
7
  dropdown: 'ml-[0.4em]',
8
- text: 'overflow-hidden text-ellipsis'
8
+ text: 'min-w-0 overflow-x-clip overflow-y-visible text-ellipsis whitespace-nowrap'
9
9
  },
10
10
  variants: {
11
11
  hasIcon: {
@@ -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.slice(-1);
25
- if (type === 'numbers' && /^\d$/.test(inputValue) || type === 'letters' && /^[a-zA-Z]$/.test(inputValue) || type === 'alphanumeric' && /^[a-zA-Z0-9]$/.test(inputValue)) {
26
- const newPasscode = [
27
- ...passcode.slice(0, index),
28
- inputValue,
29
- ...passcode.slice(index + 1)
30
- ];
31
- if (onChange) {
32
- onChange(newPasscode);
33
- } else {
34
- setInternalPasscode(newPasscode);
35
- }
36
- if (index < length - 1 && inputValue !== '') {
37
- var _inputRefs_current_;
38
- (_inputRefs_current_ = inputRefs.current[index + 1]) === null || _inputRefs_current_ === void 0 ? void 0 : _inputRefs_current_.focus();
39
- }
40
- if (newPasscode.filter((passcode)=>!passcode).length === 0 && onComplete) {
41
- onComplete(newPasscode.join(''));
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.slice(0, length - index).split('').filter((char)=>{
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.12.0",
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
  },
@@ -9,7 +9,7 @@ export const styles = tv({
9
9
  iconBefore: '',
10
10
  iconAfter: '',
11
11
  dropdown: 'ml-[0.4em]',
12
- text: 'overflow-hidden text-ellipsis',
12
+ text: 'min-w-0 overflow-x-clip overflow-y-visible text-ellipsis whitespace-nowrap',
13
13
  },
14
14
  variants: {
15
15
  hasIcon: {
@@ -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.slice(-1);
55
- if (
56
- (type === 'numbers' && /^\d$/.test(inputValue)) ||
57
- (type === 'letters' && /^[a-zA-Z]$/.test(inputValue)) ||
58
- (type === 'alphanumeric' && /^[a-zA-Z0-9]$/.test(inputValue))
59
- ) {
60
- const newPasscode = [...passcode.slice(0, index), inputValue, ...passcode.slice(index + 1)];
61
- if (onChange) {
62
- onChange(newPasscode);
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
- // Move to the next input if available
68
- if (index < length - 1 && inputValue !== '') {
69
- inputRefs.current[index + 1]?.focus();
70
- }
71
- if (newPasscode.filter(passcode => !passcode).length === 0 && onComplete) {
72
- onComplete(newPasscode.join(''));
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