@verifiedinc-public/shared-ui-elements 0.12.0 → 0.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "keywords": [],
@@ -16,7 +16,8 @@ import {
16
16
  type StackProps,
17
17
  type SxProps,
18
18
  TextField,
19
- type TextFieldProps,
19
+ InputBase,
20
+ type InputBaseProps,
20
21
  Typography,
21
22
  useTheme,
22
23
  } from '@mui/material';
@@ -106,7 +107,7 @@ function OTPInputComponent(
106
107
  },
107
108
  },
108
109
  };
109
- const inputProps: TextFieldProps = useMemo(
110
+ const inputProps: InputBaseProps = useMemo(
110
111
  () => ({
111
112
  inputProps: {
112
113
  inputMode: 'numeric',
@@ -115,14 +116,19 @@ function OTPInputComponent(
115
116
  autoCapitalize: 'off',
116
117
  },
117
118
  sx: {
118
- pointerEvents: 'none',
119
+ '& input': {
120
+ borderRadius: 1,
121
+ borderStyle: 'solid',
122
+ borderColor: 'rgba(0, 0, 0, 0.23)',
123
+ borderWidth: 1,
124
+ },
119
125
  ...(isFocused && {
120
- '&:hover fieldset': {
121
- borderColor: `${theme.palette.primary.main}!important`,
122
- },
123
- '& fieldset': {
124
- borderWidth: 2,
126
+ '& input': {
127
+ borderRadius: 1,
128
+ borderStyle: 'solid',
129
+ borderWidth: 1,
125
130
  borderColor: theme.palette.primary.main,
131
+ boxShadow: `inset 0 0 0 1px ${theme.palette.primary.main}`,
126
132
  },
127
133
  }),
128
134
  },
@@ -134,6 +140,10 @@ function OTPInputComponent(
134
140
  const valuesString = values.join('');
135
141
  const firstEmptyInput = inputsRef.current[valuesString.length];
136
142
 
143
+ for (const input of inputsRef.current) {
144
+ input?.blur();
145
+ }
146
+
137
147
  firstEmptyInput?.focus();
138
148
  firstEmptyInput?.select();
139
149
  }, [values]);
@@ -164,7 +174,7 @@ function OTPInputComponent(
164
174
  [props],
165
175
  );
166
176
 
167
- const handleKeyUp = useCallback((event: KeyboardEvent<HTMLDivElement>) => {
177
+ const handleKeyUp = useCallback((event: KeyboardEvent<HTMLInputElement>) => {
168
178
  if (event.key === 'Backspace') {
169
179
  setValues((prev) => {
170
180
  const newValue = [...prev.slice(0, -1)];
@@ -185,7 +195,7 @@ function OTPInputComponent(
185
195
  (startIndex: number) => {
186
196
  return new Array(3).fill(undefined).map((_, index) => {
187
197
  return (
188
- <TextField
198
+ <InputBase
189
199
  key={ids.current[index + startIndex]}
190
200
  inputRef={(input) =>
191
201
  ((inputsRef.current[index + startIndex] as any) = input)
@@ -197,9 +207,7 @@ function OTPInputComponent(
197
207
  onChange={handleChange}
198
208
  onKeyUp={handleKeyUp}
199
209
  onFocus={handleFocus}
200
- onBlur={() => {
201
- setIsFocused(false);
202
- }}
210
+ onBlur={() => setIsFocused(false)}
203
211
  {...inputProps}
204
212
  data-testid={`otp-input-${index + startIndex}`}
205
213
  />