@verifiedinc-public/shared-ui-elements 0.14.5-beta.5 → 1.0.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/dist/components/form/SelectInput.d.ts +2 -1
- package/dist/shared-ui-elements.mjs +3767 -3801
- package/dist/validations/index.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/form/SelectInput.tsx +5 -2
- package/src/utils/ssn.ts +1 -1
- package/src/validations/index.ts +0 -1
- package/dist/validations/birthDate.schema.d.ts +0 -5
- package/src/validations/birthDate.schema.ts +0 -60
package/package.json
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { Autocomplete } from '@mui/material';
|
2
|
-
import { useState } from 'react';
|
3
1
|
import {
|
2
|
+
Autocomplete,
|
4
3
|
TextField,
|
5
4
|
type TextFieldProps as InternalFieldProps,
|
6
5
|
} from '@mui/material';
|
6
|
+
import { useState } from 'react';
|
7
7
|
import { inputStyle } from './styles/input';
|
8
8
|
|
9
9
|
interface TextFieldProps extends Omit<InternalFieldProps, 'onChange'> {}
|
@@ -21,6 +21,7 @@ interface SelectInputProps {
|
|
21
21
|
value?: Option | null; // Controlled value
|
22
22
|
defaultOption?: Option;
|
23
23
|
InputProps?: TextFieldProps;
|
24
|
+
disableClearable?: boolean;
|
24
25
|
}
|
25
26
|
|
26
27
|
/**
|
@@ -33,6 +34,7 @@ export function SelectInput({
|
|
33
34
|
value: controlledValue,
|
34
35
|
onChange,
|
35
36
|
onClear,
|
37
|
+
disableClearable,
|
36
38
|
...props
|
37
39
|
}: SelectInputProps): React.JSX.Element {
|
38
40
|
const [internalValue, setInternalValue] = useState<Option | null>(
|
@@ -74,6 +76,7 @@ export function SelectInput({
|
|
74
76
|
autoHighlight
|
75
77
|
defaultValue={defaultOption}
|
76
78
|
options={options}
|
79
|
+
disableClearable={disableClearable}
|
77
80
|
isOptionEqualToValue={(option, value) => option?.id === value?.id}
|
78
81
|
value={value}
|
79
82
|
onChange={(_event, newInputValue) => {
|
package/src/utils/ssn.ts
CHANGED
@@ -4,5 +4,5 @@
|
|
4
4
|
* @param {string} rawValue the raw value of the ssncredential
|
5
5
|
* @returns {string} the formatted value
|
6
6
|
*/
|
7
|
-
export const ssnFormatter = (rawValue: string) =>
|
7
|
+
export const ssnFormatter = (rawValue: string): string =>
|
8
8
|
rawValue.replace(/(\d{3})-?(\d{2})-?(\d{4})/, '•••-••-$3');
|
package/src/validations/index.ts
CHANGED
@@ -1,5 +0,0 @@
|
|
1
|
-
import * as zod from 'zod';
|
2
|
-
export declare const birthDateSchema: zod.ZodEffects<zod.ZodString, string, string>;
|
3
|
-
export declare const birthDateSchemaWithPastOnlyValidation: zod.ZodEffects<zod.ZodDate, Date, Date>;
|
4
|
-
export declare const simpleBirthDateSchema: zod.ZodEffects<zod.ZodString, string, string>;
|
5
|
-
export declare const shortenBirthDateSchema: zod.ZodEffects<zod.ZodString, string, string>;
|
@@ -1,60 +0,0 @@
|
|
1
|
-
import * as zod from 'zod';
|
2
|
-
|
3
|
-
const validate = (value: string) => {
|
4
|
-
const now = new Date();
|
5
|
-
const minDate = new Date('1900-01-01');
|
6
|
-
const maxDate = new Date(
|
7
|
-
now.getFullYear(),
|
8
|
-
now.getMonth(),
|
9
|
-
now.getDate(),
|
10
|
-
23,
|
11
|
-
59,
|
12
|
-
59,
|
13
|
-
999,
|
14
|
-
);
|
15
|
-
// Safari doesn't allow date strings with hyphens
|
16
|
-
const formattedValue = value.replace(/-/g, '/');
|
17
|
-
const valueDate = new Date(formattedValue);
|
18
|
-
|
19
|
-
if (valueDate >= minDate && valueDate <= maxDate) {
|
20
|
-
const date = Date.parse(String(new Date(formattedValue)));
|
21
|
-
return !isNaN(date);
|
22
|
-
}
|
23
|
-
|
24
|
-
return false;
|
25
|
-
};
|
26
|
-
|
27
|
-
export const birthDateSchema = zod.string().refine((value: string) => {
|
28
|
-
const regex = /\d{2}-\d{2}-\d{4}/;
|
29
|
-
if (regex.test(value)) {
|
30
|
-
return validate(value);
|
31
|
-
}
|
32
|
-
return false;
|
33
|
-
}, 'Date of Birth is invalid');
|
34
|
-
|
35
|
-
export const birthDateSchemaWithPastOnlyValidation = zod.z
|
36
|
-
.date()
|
37
|
-
.refine((date) => date.getTime() < Date.now(), {
|
38
|
-
message: 'Birthday must be in the past',
|
39
|
-
});
|
40
|
-
|
41
|
-
export const simpleBirthDateSchema = zod.string().refine((value: string) => {
|
42
|
-
const regex = /^\d{2}\d{2}\d{4}$/;
|
43
|
-
if (regex.test(value)) {
|
44
|
-
const formattedValue = `${value.slice(0, 2)}/${value.slice(
|
45
|
-
2,
|
46
|
-
4,
|
47
|
-
)}/${value.slice(4, 8)}`;
|
48
|
-
return validate(formattedValue);
|
49
|
-
}
|
50
|
-
return false;
|
51
|
-
}, 'Date of Birth is invalid');
|
52
|
-
|
53
|
-
export const shortenBirthDateSchema = zod.string().refine((value: string) => {
|
54
|
-
const regex = /^\d{2}\d{2}$/;
|
55
|
-
if (regex.test(value)) {
|
56
|
-
const formattedValue = `${value.slice(0, 2)}/${value.slice(2, 4)}/1970`;
|
57
|
-
return validate(formattedValue);
|
58
|
-
}
|
59
|
-
return false;
|
60
|
-
}, 'Date of Birth is invalid');
|