@verifiedinc-public/shared-ui-elements 1.3.3 → 2.1.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/README.md +3 -29
- package/dist/components/animation/Counter.d.ts +8 -0
- package/dist/components/animation/index.d.ts +2 -0
- package/dist/components/animation/index.mjs +1 -0
- package/dist/components/animation/motions.d.ts +2220 -0
- package/dist/components/index.mjs +1 -0
- package/dist/hooks/index.mjs +1 -0
- package/dist/hooks/useOnClickOutside.d.ts +23 -0
- package/dist/index.mjs +1 -0
- package/dist/shared/index-C9nSeFPi.mjs +105 -0
- package/dist/shared/jsx-runtime-jmtevAuS.mjs +1 -0
- package/dist/shared/phone.schema-XBbyizhq.mjs +1 -0
- package/dist/shared/shadows-fgmuXym6.mjs +1 -0
- package/dist/shared/unix.schema-CMYTtXco.mjs +1 -0
- package/dist/shared/useQRCode-DXiPIj-D.mjs +1 -0
- package/dist/shared/useSearchParams-CW9y02Ym.mjs +1 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/utils/masks/index.mjs +1 -0
- package/dist/utils/string/index.mjs +1 -0
- package/dist/validations/index.mjs +1 -0
- package/package.json +36 -12
- package/dist/shared-ui-elements.mjs +0 -105
- package/src/components/Alert/Alert.tsx +0 -8
- package/src/components/Alert/FullWidthAlert.tsx +0 -27
- package/src/components/Alert/index.ts +0 -2
- package/src/components/Backdrop/index.tsx +0 -34
- package/src/components/Banners/Banner.tsx +0 -42
- package/src/components/Banners/ExactBirthdayBanner.tsx +0 -18
- package/src/components/Banners/ResendPhoneBanner.tsx +0 -55
- package/src/components/Banners/TestPhoneNumbersBanner.tsx +0 -25
- package/src/components/Banners/index.tsx +0 -4
- package/src/components/Button/index.tsx +0 -8
- package/src/components/CredentialRequestsEditor/CredentialRequestsEditor.context.tsx +0 -98
- package/src/components/CredentialRequestsEditor/components/CredentialRequestsField.tsx +0 -103
- package/src/components/CredentialRequestsEditor/components/DataFieldAccordion.tsx +0 -337
- package/src/components/CredentialRequestsEditor/components/DataFieldDeleteModal.tsx +0 -64
- package/src/components/CredentialRequestsEditor/components/DataFieldDescription.tsx +0 -68
- package/src/components/CredentialRequestsEditor/components/DataFieldMandatory.tsx +0 -84
- package/src/components/CredentialRequestsEditor/components/DataFieldMulti.tsx +0 -74
- package/src/components/CredentialRequestsEditor/components/DataFieldOptionType.tsx +0 -84
- package/src/components/CredentialRequestsEditor/components/DataFieldSection.tsx +0 -48
- package/src/components/CredentialRequestsEditor/components/DataFieldUserInput.tsx +0 -71
- package/src/components/CredentialRequestsEditor/components/RadioOption.tsx +0 -89
- package/src/components/CredentialRequestsEditor/contexts/CredentialRequestFieldContext.tsx +0 -36
- package/src/components/CredentialRequestsEditor/index.tsx +0 -15
- package/src/components/CredentialRequestsEditor/types/compositeCredentialSchema.ts +0 -1
- package/src/components/CredentialRequestsEditor/types/credentialSchemasDto.ts +0 -3
- package/src/components/CredentialRequestsEditor/types/form.ts +0 -28
- package/src/components/CredentialRequestsEditor/types/mandatoryEnum.ts +0 -5
- package/src/components/CredentialRequestsEditor/utils/buildDataFieldValue.ts +0 -65
- package/src/components/CredentialRequestsEditor/utils/prettyField.ts +0 -16
- package/src/components/Image.tsx +0 -10
- package/src/components/QRCodeDisplay/index.tsx +0 -50
- package/src/components/RequiredLabel/index.tsx +0 -15
- package/src/components/Snackbar/index.tsx +0 -156
- package/src/components/TextField/index.tsx +0 -8
- package/src/components/Tip/index.tsx +0 -18
- package/src/components/Typography/index.tsx +0 -8
- package/src/components/When.tsx +0 -28
- package/src/components/form/CountrySelector.tsx +0 -96
- package/src/components/form/DataFieldClearAdornment.tsx +0 -28
- package/src/components/form/DateInput.tsx +0 -78
- package/src/components/form/DefaultInput.tsx +0 -26
- package/src/components/form/InputMask.tsx +0 -41
- package/src/components/form/OTPInput.tsx +0 -254
- package/src/components/form/PhoneInput.tsx +0 -152
- package/src/components/form/SSNInput.tsx +0 -99
- package/src/components/form/SelectInput.tsx +0 -101
- package/src/components/form/TextMaskCustom.tsx +0 -48
- package/src/components/form/index.ts +0 -5
- package/src/components/index.ts +0 -13
- package/src/components/terms/AcceptTermsNotice.tsx +0 -27
- package/src/components/terms/LegalLink.tsx +0 -22
- package/src/components/verified/VerifiedImage.tsx +0 -272
- package/src/components/verified/VerifiedIncLogo.tsx +0 -11
- package/src/components/verified/index.ts +0 -2
- package/src/hooks/index.ts +0 -6
- package/src/hooks/useCallbackRef.ts +0 -22
- package/src/hooks/useCopyToClipboard.ts +0 -76
- package/src/hooks/useDisclosure.ts +0 -96
- package/src/hooks/useLocalStorage.ts +0 -24
- package/src/hooks/usePrevious.ts +0 -17
- package/src/hooks/useQRCode.ts +0 -62
- package/src/hooks/useSearchParams.ts +0 -7
- package/src/index.ts +0 -13
- package/src/stories/components/Alert.stories.tsx +0 -41
- package/src/stories/components/Button.stories.ts +0 -49
- package/src/stories/components/CredentialRequestsEditor.stories.tsx +0 -98
- package/src/stories/components/QRCodeDisplay.stories.tsx +0 -60
- package/src/stories/components/TextField.stories.ts +0 -59
- package/src/stories/components/Typography.stories.ts +0 -140
- package/src/stories/components/VerifiedImage.stories.tsx +0 -32
- package/src/stories/components/form/DateInput.stories.ts +0 -36
- package/src/stories/components/form/OTPInput.stories.tsx +0 -90
- package/src/stories/components/form/PhoneInput.stories.tsx +0 -34
- package/src/stories/components/form/SSNInput.stories.ts +0 -30
- package/src/stories/components/form/SelectInput.stories.ts +0 -39
- package/src/stories/hooks/useCopyToClipboard.stories.tsx +0 -45
- package/src/styles/colors.ts +0 -60
- package/src/styles/index.ts +0 -3
- package/src/styles/shadows.ts +0 -6
- package/src/styles/theme.ts +0 -257
- package/src/styles/typography.ts +0 -86
- package/src/utils/date.ts +0 -32
- package/src/utils/index.ts +0 -6
- package/src/utils/masks/index.ts +0 -6
- package/src/utils/omitProperty.ts +0 -19
- package/src/utils/phone.ts +0 -76
- package/src/utils/ssn.ts +0 -8
- package/src/utils/string/index.ts +0 -2
- package/src/utils/string/toCapitalize.ts +0 -13
- package/src/utils/string/toSentenceCase.ts +0 -7
- package/src/utils/wrapPromise.ts +0 -19
- package/src/validations/date.schema.ts +0 -18
- package/src/validations/description.schema.ts +0 -5
- package/src/validations/email.schema.ts +0 -3
- package/src/validations/field.schema.ts +0 -3
- package/src/validations/index.ts +0 -8
- package/src/validations/phone.schema.ts +0 -6
- package/src/validations/ssn.schema.ts +0 -24
- package/src/validations/state.schema.ts +0 -3
- package/src/validations/unix.schema.ts +0 -11
@@ -1,84 +0,0 @@
|
|
1
|
-
import { useMemo } from 'react';
|
2
|
-
import { useController } from 'react-hook-form';
|
3
|
-
import { Autocomplete, TextField } from '@mui/material';
|
4
|
-
|
5
|
-
import { prettyField } from '../utils/prettyField';
|
6
|
-
|
7
|
-
import {
|
8
|
-
type CredentialRequests,
|
9
|
-
type CredentialRequestsEditorForm,
|
10
|
-
} from '../types/form';
|
11
|
-
import { buildDataFieldValue } from '../utils/buildDataFieldValue';
|
12
|
-
import { useCredentialRequestField } from '../contexts/CredentialRequestFieldContext';
|
13
|
-
import { useCredentialRequestsEditor } from '../CredentialRequestsEditor.context';
|
14
|
-
import { DataFieldSection } from './DataFieldSection';
|
15
|
-
|
16
|
-
export function DataFieldOptionType(): React.JSX.Element {
|
17
|
-
const credentialRequestField = useCredentialRequestField();
|
18
|
-
const field = useController<CredentialRequestsEditorForm>({
|
19
|
-
name: `${credentialRequestField?.path as any}` as any,
|
20
|
-
});
|
21
|
-
|
22
|
-
const { schemas } = useCredentialRequestsEditor();
|
23
|
-
const schemaValues = useMemo(() => {
|
24
|
-
if (!schemas) return [];
|
25
|
-
return Object.values(schemas)
|
26
|
-
.map((schema) => ({
|
27
|
-
label: prettyField(schema.$id),
|
28
|
-
id: schema.$id as string,
|
29
|
-
}))
|
30
|
-
.filter((schema) => {
|
31
|
-
const blacklist = ['IdentityCredential'];
|
32
|
-
return !blacklist.includes(schema.id);
|
33
|
-
})
|
34
|
-
.sort((a, b) => (a.label < b.label ? -1 : 1));
|
35
|
-
}, [schemas]);
|
36
|
-
const selectedValue = useMemo(() => {
|
37
|
-
const type = (field.field?.value as CredentialRequests)?.type;
|
38
|
-
return schemaValues?.find((value) => value.id === type);
|
39
|
-
}, [field, schemaValues]);
|
40
|
-
|
41
|
-
return (
|
42
|
-
<DataFieldSection
|
43
|
-
key={JSON.stringify(selectedValue)}
|
44
|
-
title='Field Type'
|
45
|
-
description='What type of user data this field is for'
|
46
|
-
tip={
|
47
|
-
<>
|
48
|
-
<pre>POST /1-click</pre>
|
49
|
-
<pre>{`{\n type: string\n}`}</pre>
|
50
|
-
</>
|
51
|
-
}
|
52
|
-
>
|
53
|
-
<Autocomplete
|
54
|
-
value={selectedValue}
|
55
|
-
onChange={(_, value) => {
|
56
|
-
if (!value) return;
|
57
|
-
|
58
|
-
credentialRequestField?.fieldArray.update(
|
59
|
-
credentialRequestField?.index,
|
60
|
-
buildDataFieldValue(value.id, schemas),
|
61
|
-
);
|
62
|
-
}}
|
63
|
-
options={schemaValues}
|
64
|
-
disablePortal
|
65
|
-
renderInput={(params) => (
|
66
|
-
<TextField
|
67
|
-
{...params}
|
68
|
-
label='Type'
|
69
|
-
color='success'
|
70
|
-
size='small'
|
71
|
-
className='original'
|
72
|
-
fullWidth
|
73
|
-
inputProps={{
|
74
|
-
...params.inputProps,
|
75
|
-
'data-testid': 'custom-demo-dialog-data-field-type-input',
|
76
|
-
}}
|
77
|
-
placeholder='Choose a type...'
|
78
|
-
/>
|
79
|
-
)}
|
80
|
-
disabled={(credentialRequestField?.level ?? 0) > 0 || schemas === null}
|
81
|
-
/>
|
82
|
-
</DataFieldSection>
|
83
|
-
);
|
84
|
-
}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import { type ReactNode } from 'react';
|
2
|
-
import { Stack, SxProps, Typography } from '@mui/material';
|
3
|
-
|
4
|
-
import { Tip } from '../../Tip';
|
5
|
-
|
6
|
-
interface DataFieldSectionProps {
|
7
|
-
children: ReactNode;
|
8
|
-
title: string;
|
9
|
-
description?: string;
|
10
|
-
tip?: ReactNode;
|
11
|
-
sx?: SxProps;
|
12
|
-
}
|
13
|
-
|
14
|
-
export function DataFieldSection(
|
15
|
-
props: DataFieldSectionProps,
|
16
|
-
): React.JSX.Element {
|
17
|
-
const { children, title, description, tip, sx } = props;
|
18
|
-
|
19
|
-
return (
|
20
|
-
<Stack sx={sx}>
|
21
|
-
<Stack direction='row' alignItems='center' spacing={0.5}>
|
22
|
-
<Typography
|
23
|
-
variant='body1'
|
24
|
-
sx={{ fontSize: '16px', fontWeight: '700' }}
|
25
|
-
data-testid='custom-demo-dialog-data-field-title'
|
26
|
-
>
|
27
|
-
{title}
|
28
|
-
</Typography>
|
29
|
-
<Tip>{tip}</Tip>
|
30
|
-
</Stack>
|
31
|
-
{description && (
|
32
|
-
<Typography
|
33
|
-
variant='body2'
|
34
|
-
color='text.secondary'
|
35
|
-
sx={{
|
36
|
-
textAlign: 'left !important',
|
37
|
-
fontSize: '12px',
|
38
|
-
fontWeight: '400',
|
39
|
-
}}
|
40
|
-
data-testid='custom-demo-dialog-data-field-description'
|
41
|
-
>
|
42
|
-
{description}
|
43
|
-
</Typography>
|
44
|
-
)}
|
45
|
-
<Stack sx={{ mt: 3 }}>{children}</Stack>
|
46
|
-
</Stack>
|
47
|
-
);
|
48
|
-
}
|
@@ -1,71 +0,0 @@
|
|
1
|
-
import { RadioGroup } from '@mui/material';
|
2
|
-
import { useController } from 'react-hook-form';
|
3
|
-
|
4
|
-
import { type CredentialRequestsEditorForm } from '../types/form';
|
5
|
-
import { useCredentialRequestsEditor } from '../CredentialRequestsEditor.context';
|
6
|
-
import { useCredentialRequestField } from '../contexts/CredentialRequestFieldContext';
|
7
|
-
import { RadioOption } from './RadioOption';
|
8
|
-
import { DataFieldSection } from './DataFieldSection';
|
9
|
-
|
10
|
-
export function DataFieldUserInput(): React.JSX.Element {
|
11
|
-
const { features } = useCredentialRequestsEditor();
|
12
|
-
const isFeatureDisabled = features?.description?.disabled === true;
|
13
|
-
|
14
|
-
const credentialRequestField = useCredentialRequestField();
|
15
|
-
const allowUserInput = useController<CredentialRequestsEditorForm>({
|
16
|
-
name: `${credentialRequestField?.path as any}.allowUserInput` as any,
|
17
|
-
});
|
18
|
-
|
19
|
-
return (
|
20
|
-
<DataFieldSection
|
21
|
-
title='Allow User Input'
|
22
|
-
description='Whether the user is allowed to add or edit data for this field'
|
23
|
-
tip={
|
24
|
-
<>
|
25
|
-
<pre>POST /1-click</pre>
|
26
|
-
<pre>{`{\n allowUserInput?: boolean\n}`}</pre>
|
27
|
-
</>
|
28
|
-
}
|
29
|
-
sx={{
|
30
|
-
opacity: isFeatureDisabled ? 0.5 : 1,
|
31
|
-
}}
|
32
|
-
>
|
33
|
-
<RadioGroup
|
34
|
-
value={allowUserInput.field.value}
|
35
|
-
onChange={(_, value) => {
|
36
|
-
if (isFeatureDisabled) return;
|
37
|
-
// Update form state
|
38
|
-
allowUserInput.field.onChange({
|
39
|
-
target: { value: value === 'true' },
|
40
|
-
});
|
41
|
-
}}
|
42
|
-
>
|
43
|
-
<RadioOption
|
44
|
-
isDefault
|
45
|
-
value={true}
|
46
|
-
title='Yes'
|
47
|
-
description='The user can add or edit data for the user to share'
|
48
|
-
tip='true'
|
49
|
-
inputProps={
|
50
|
-
{
|
51
|
-
'data-testid': 'custom-demo-dialog-user-input-yes-radio',
|
52
|
-
} as any
|
53
|
-
}
|
54
|
-
disabled={isFeatureDisabled}
|
55
|
-
/>
|
56
|
-
<RadioOption
|
57
|
-
value={false}
|
58
|
-
title='No'
|
59
|
-
description="The user can't add or edit data"
|
60
|
-
tip='false'
|
61
|
-
inputProps={
|
62
|
-
{
|
63
|
-
'data-testid': 'custom-demo-dialog-user-input-no-radio',
|
64
|
-
} as any
|
65
|
-
}
|
66
|
-
disabled={isFeatureDisabled}
|
67
|
-
/>
|
68
|
-
</RadioGroup>
|
69
|
-
</DataFieldSection>
|
70
|
-
);
|
71
|
-
}
|
@@ -1,89 +0,0 @@
|
|
1
|
-
import type { ReactNode } from 'react';
|
2
|
-
import {
|
3
|
-
Chip,
|
4
|
-
Radio,
|
5
|
-
type RadioProps,
|
6
|
-
Stack,
|
7
|
-
type SxProps,
|
8
|
-
Typography,
|
9
|
-
Box,
|
10
|
-
} from '@mui/material';
|
11
|
-
|
12
|
-
import { Tip } from '../../Tip';
|
13
|
-
|
14
|
-
type RadioOptionProps = RadioProps & {
|
15
|
-
isDefault?: boolean;
|
16
|
-
title: string;
|
17
|
-
description?: string;
|
18
|
-
tip?: ReactNode;
|
19
|
-
sx?: SxProps;
|
20
|
-
};
|
21
|
-
export function RadioOption(props: RadioOptionProps): React.JSX.Element {
|
22
|
-
const { isDefault, title, description, tip, sx, ...radioProps } = props;
|
23
|
-
return (
|
24
|
-
<Stack
|
25
|
-
direction='row'
|
26
|
-
justifyContent='space-between'
|
27
|
-
alignItems='center'
|
28
|
-
sx={{ mb: 1, ...(sx as any) }}
|
29
|
-
>
|
30
|
-
<Stack sx={{ alignItems: 'flex-start' }}>
|
31
|
-
<Stack direction='row' spacing={1}>
|
32
|
-
<Radio
|
33
|
-
{...(radioProps as any)}
|
34
|
-
sx={{
|
35
|
-
mt: '1px',
|
36
|
-
width: 34,
|
37
|
-
height: 34,
|
38
|
-
...sx,
|
39
|
-
'&.Mui-checked': {
|
40
|
-
color: '#0dbc3d',
|
41
|
-
},
|
42
|
-
}}
|
43
|
-
/>
|
44
|
-
<Stack>
|
45
|
-
<Stack direction='row' alignItems='center' spacing={1}>
|
46
|
-
<Typography
|
47
|
-
variant='body1'
|
48
|
-
sx={{
|
49
|
-
fontSize: '16px',
|
50
|
-
fontWeight: '400',
|
51
|
-
textAlign: 'left !important',
|
52
|
-
}}
|
53
|
-
>
|
54
|
-
{title}
|
55
|
-
</Typography>
|
56
|
-
<Tip>{tip}</Tip>
|
57
|
-
</Stack>
|
58
|
-
{description && (
|
59
|
-
<Typography
|
60
|
-
variant='body2'
|
61
|
-
color='text.disabled'
|
62
|
-
sx={{
|
63
|
-
textAlign: 'left !important',
|
64
|
-
alignSelf: 'flex-start',
|
65
|
-
fontSize: '12px',
|
66
|
-
fontWeight: '400',
|
67
|
-
mt: 0.5,
|
68
|
-
}}
|
69
|
-
>
|
70
|
-
{description}
|
71
|
-
</Typography>
|
72
|
-
)}
|
73
|
-
</Stack>
|
74
|
-
</Stack>
|
75
|
-
</Stack>
|
76
|
-
<Box sx={{ mt: 1, alignSelf: 'flex-start' }}>
|
77
|
-
{isDefault && (
|
78
|
-
<Chip
|
79
|
-
size='small'
|
80
|
-
label='Default'
|
81
|
-
color='info'
|
82
|
-
variant='outlined'
|
83
|
-
sx={{ fontWeight: 700 }}
|
84
|
-
/>
|
85
|
-
)}
|
86
|
-
</Box>
|
87
|
-
</Stack>
|
88
|
-
);
|
89
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import React, {
|
2
|
-
createContext,
|
3
|
-
type PropsWithChildren,
|
4
|
-
useContext,
|
5
|
-
} from 'react';
|
6
|
-
import {
|
7
|
-
type FieldArrayWithId,
|
8
|
-
type UseFieldArrayReturn,
|
9
|
-
} from 'react-hook-form';
|
10
|
-
import type { CredentialRequestsEditorForm } from '../types/form';
|
11
|
-
|
12
|
-
type CredentialRequestFieldContext = PropsWithChildren & {
|
13
|
-
path: string | undefined;
|
14
|
-
field: FieldArrayWithId<CredentialRequestsEditorForm, 'credentialRequests'>;
|
15
|
-
fieldArray: UseFieldArrayReturn<
|
16
|
-
CredentialRequestsEditorForm,
|
17
|
-
'credentialRequests'
|
18
|
-
>;
|
19
|
-
index: number;
|
20
|
-
level: number;
|
21
|
-
onAllFieldsDelete: () => void;
|
22
|
-
};
|
23
|
-
|
24
|
-
const Context = createContext<CredentialRequestFieldContext | null>(null);
|
25
|
-
|
26
|
-
export const useCredentialRequestField =
|
27
|
-
(): CredentialRequestFieldContext | null => {
|
28
|
-
return useContext(Context);
|
29
|
-
};
|
30
|
-
|
31
|
-
export function CredentialRequestFieldProvider({
|
32
|
-
children,
|
33
|
-
...props
|
34
|
-
}: CredentialRequestFieldContext): React.JSX.Element {
|
35
|
-
return <Context.Provider value={props}>{children}</Context.Provider>;
|
36
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
type CredentialRequestsEditorProps,
|
3
|
-
CredentialRequestsEditorProvider,
|
4
|
-
} from './CredentialRequestsEditor.context';
|
5
|
-
import { CredentialRequestsField } from './components/CredentialRequestsField';
|
6
|
-
|
7
|
-
export function CredentialRequestsEditor(
|
8
|
-
props: Omit<CredentialRequestsEditorProps, 'children'>,
|
9
|
-
): React.JSX.Element {
|
10
|
-
return (
|
11
|
-
<CredentialRequestsEditorProvider {...props}>
|
12
|
-
<CredentialRequestsField />
|
13
|
-
</CredentialRequestsEditorProvider>
|
14
|
-
);
|
15
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export type CompositeCredentialSchema = Record<string, any>;
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { type MandatoryEnum } from './mandatoryEnum';
|
2
|
-
|
3
|
-
export interface CredentialRequests {
|
4
|
-
type: string;
|
5
|
-
issuers?: string[];
|
6
|
-
required?: boolean;
|
7
|
-
mandatory?: MandatoryEnum;
|
8
|
-
description?: string;
|
9
|
-
allowUserInput?: boolean;
|
10
|
-
multi?: boolean;
|
11
|
-
children?: CredentialRequests[];
|
12
|
-
}
|
13
|
-
|
14
|
-
export interface CredentialRequestsWithNew {
|
15
|
-
type: string;
|
16
|
-
issuers?: string[];
|
17
|
-
required?: boolean;
|
18
|
-
mandatory?: MandatoryEnum;
|
19
|
-
description?: string;
|
20
|
-
allowUserInput?: boolean;
|
21
|
-
multi?: boolean;
|
22
|
-
children?: CredentialRequestsWithNew[];
|
23
|
-
isNew?: boolean;
|
24
|
-
}
|
25
|
-
|
26
|
-
export interface CredentialRequestsEditorForm {
|
27
|
-
credentialRequests: CredentialRequestsWithNew[];
|
28
|
-
}
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import _ from 'lodash';
|
2
|
-
import { type CompositeCredentialSchema } from '../types/compositeCredentialSchema';
|
3
|
-
import { CredentialRequests } from '../types/form';
|
4
|
-
import { type CredentialSchemaDto } from '../types/credentialSchemasDto';
|
5
|
-
import { MandatoryEnum } from '../types/mandatoryEnum';
|
6
|
-
|
7
|
-
const isComposed = (schema: unknown): schema is CompositeCredentialSchema =>
|
8
|
-
Object.prototype.hasOwnProperty.call(schema || {}, 'anyOf') ||
|
9
|
-
Object.prototype.hasOwnProperty.call(schema || {}, 'allOf');
|
10
|
-
|
11
|
-
function extractTypes(
|
12
|
-
record: any,
|
13
|
-
result: string[] = [],
|
14
|
-
parentKeys: string[] = [],
|
15
|
-
): string[] {
|
16
|
-
_.forOwn(record, (value, key) => {
|
17
|
-
// Check if the current key is $ref or $id and handle accordingly
|
18
|
-
if (key === '$ref' && typeof value === 'string') {
|
19
|
-
result.push(value);
|
20
|
-
} else if (
|
21
|
-
key === '$id' &&
|
22
|
-
typeof value === 'string' &&
|
23
|
-
_.some(parentKeys, (k) => ['allOf', 'anyOf', 'oneOf'].includes(k))
|
24
|
-
) {
|
25
|
-
result.push(value);
|
26
|
-
}
|
27
|
-
|
28
|
-
// If the value is an object or array, recurse into it
|
29
|
-
if (_.isObject(value)) {
|
30
|
-
extractTypes(value, result, [...parentKeys, key]);
|
31
|
-
}
|
32
|
-
});
|
33
|
-
|
34
|
-
return result;
|
35
|
-
}
|
36
|
-
|
37
|
-
export function buildDataFieldValue(
|
38
|
-
type: string,
|
39
|
-
schema: CredentialSchemaDto['schemas'],
|
40
|
-
): CredentialRequests {
|
41
|
-
const selectedSchema = schema[type];
|
42
|
-
const isComposedSchema = isComposed(selectedSchema);
|
43
|
-
|
44
|
-
if (isComposedSchema) {
|
45
|
-
return {
|
46
|
-
type,
|
47
|
-
mandatory: MandatoryEnum.NO,
|
48
|
-
description: '',
|
49
|
-
allowUserInput: true,
|
50
|
-
multi: false,
|
51
|
-
children: extractTypes(selectedSchema).map((item) =>
|
52
|
-
buildDataFieldValue(item, schema),
|
53
|
-
),
|
54
|
-
};
|
55
|
-
}
|
56
|
-
|
57
|
-
return {
|
58
|
-
type,
|
59
|
-
mandatory: MandatoryEnum.NO,
|
60
|
-
description: '',
|
61
|
-
allowUserInput: true,
|
62
|
-
// We want to default to true if is email credential.
|
63
|
-
multi: type === 'EmailCredential',
|
64
|
-
};
|
65
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
// This pattern will split camel cased string out of the credential,
|
2
|
-
// when a camel word contain a sequence of uppercase character it is kept to maintain consistency of that word.
|
3
|
-
const schemaNamePattern = /([A-Z][a-z0-9]+)/gm;
|
4
|
-
|
5
|
-
// Format the camel cased text to a human-readable.
|
6
|
-
export const prettyField = (field: string): string =>
|
7
|
-
field
|
8
|
-
.split(schemaNamePattern)
|
9
|
-
.map((word) => {
|
10
|
-
if (word === 'Id') return 'ID';
|
11
|
-
if (word === 'Zip') return 'ZIP';
|
12
|
-
if (word === 'Ssn') return 'SSN';
|
13
|
-
return word;
|
14
|
-
})
|
15
|
-
.filter((e) => e !== 'Credential')
|
16
|
-
.join(' ');
|
package/src/components/Image.tsx
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import { Box, type BoxProps } from '@mui/material';
|
2
|
-
|
3
|
-
export interface ImageProps extends BoxProps {
|
4
|
-
src: string;
|
5
|
-
alt: string;
|
6
|
-
}
|
7
|
-
|
8
|
-
export const Image = ({ src, alt, ...props }: ImageProps): JSX.Element => {
|
9
|
-
return <Box src={src} alt={alt} {...props} component='img' />;
|
10
|
-
};
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import { Box } from '@mui/material';
|
2
|
-
|
3
|
-
import { useQRCode } from '../../hooks';
|
4
|
-
|
5
|
-
export interface QRCodeDisplayProps {
|
6
|
-
data: string;
|
7
|
-
asset?: string;
|
8
|
-
svgSize?: number;
|
9
|
-
logoSize?: number;
|
10
|
-
fill?: string;
|
11
|
-
}
|
12
|
-
|
13
|
-
export function QRCodeDisplay({
|
14
|
-
data,
|
15
|
-
asset,
|
16
|
-
svgSize = 300,
|
17
|
-
logoSize = 0,
|
18
|
-
fill = '#000000',
|
19
|
-
}: QRCodeDisplayProps) {
|
20
|
-
const svg = useQRCode({
|
21
|
-
data: data,
|
22
|
-
size: svgSize,
|
23
|
-
imageSize: logoSize,
|
24
|
-
fill,
|
25
|
-
});
|
26
|
-
|
27
|
-
return (
|
28
|
-
<Box position='relative'>
|
29
|
-
<Box
|
30
|
-
display='flex'
|
31
|
-
sx={{ '& svg': { width: '100%', height: 'auto', aspectRatio: 1 } }}
|
32
|
-
dangerouslySetInnerHTML={{ __html: svg }}
|
33
|
-
/>
|
34
|
-
<Box
|
35
|
-
component='img'
|
36
|
-
src={asset}
|
37
|
-
sx={{
|
38
|
-
position: 'absolute',
|
39
|
-
width: (logoSize / svgSize) * 100 + '%',
|
40
|
-
maxWidth: logoSize + 'px',
|
41
|
-
height: 'auto',
|
42
|
-
inset: 0,
|
43
|
-
aspectRatio: 1,
|
44
|
-
m: 'auto',
|
45
|
-
p: 0.5,
|
46
|
-
}}
|
47
|
-
/>
|
48
|
-
</Box>
|
49
|
-
);
|
50
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { type PropsWithChildren } from 'react';
|
2
|
-
import { Box } from '@mui/material';
|
3
|
-
|
4
|
-
export function RequiredLabel(
|
5
|
-
props: Readonly<PropsWithChildren>,
|
6
|
-
): React.JSX.Element {
|
7
|
-
return (
|
8
|
-
<span>
|
9
|
-
{props.children}
|
10
|
-
<Box component='span' color='error.main' sx={{ ml: 0.5 }}>
|
11
|
-
*
|
12
|
-
</Box>
|
13
|
-
</span>
|
14
|
-
);
|
15
|
-
}
|