@verifiedinc-public/shared-ui-elements 1.3.2 → 2.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.
Files changed (117) hide show
  1. package/README.md +4 -24
  2. package/dist/components/index.mjs +1 -0
  3. package/dist/hooks/index.d.ts +1 -0
  4. package/dist/hooks/index.mjs +1 -0
  5. package/dist/hooks/useSearchParams.d.ts +5 -0
  6. package/dist/index.mjs +1 -0
  7. package/dist/shared/index-CTvz4BbG.mjs +105 -0
  8. package/dist/shared/phone.schema-XBbyizhq.mjs +1 -0
  9. package/dist/shared/shadows-fgmuXym6.mjs +1 -0
  10. package/dist/shared/unix.schema-CMYTtXco.mjs +1 -0
  11. package/dist/shared/useQRCode-DXiPIj-D.mjs +1 -0
  12. package/dist/shared/useSearchParams-CW9y02Ym.mjs +1 -0
  13. package/dist/styles/index.mjs +1 -0
  14. package/dist/utils/masks/index.mjs +1 -0
  15. package/dist/utils/string/index.mjs +1 -0
  16. package/dist/validations/index.mjs +1 -0
  17. package/package.json +29 -8
  18. package/dist/shared-ui-elements.mjs +0 -105
  19. package/src/components/Alert/Alert.tsx +0 -8
  20. package/src/components/Alert/FullWidthAlert.tsx +0 -27
  21. package/src/components/Alert/index.ts +0 -2
  22. package/src/components/Backdrop/index.tsx +0 -34
  23. package/src/components/Banners/Banner.tsx +0 -42
  24. package/src/components/Banners/ExactBirthdayBanner.tsx +0 -18
  25. package/src/components/Banners/ResendPhoneBanner.tsx +0 -55
  26. package/src/components/Banners/TestPhoneNumbersBanner.tsx +0 -25
  27. package/src/components/Banners/index.tsx +0 -4
  28. package/src/components/Button/index.tsx +0 -8
  29. package/src/components/CredentialRequestsEditor/CredentialRequestsEditor.context.tsx +0 -98
  30. package/src/components/CredentialRequestsEditor/components/CredentialRequestsField.tsx +0 -103
  31. package/src/components/CredentialRequestsEditor/components/DataFieldAccordion.tsx +0 -337
  32. package/src/components/CredentialRequestsEditor/components/DataFieldDeleteModal.tsx +0 -64
  33. package/src/components/CredentialRequestsEditor/components/DataFieldDescription.tsx +0 -68
  34. package/src/components/CredentialRequestsEditor/components/DataFieldMandatory.tsx +0 -84
  35. package/src/components/CredentialRequestsEditor/components/DataFieldMulti.tsx +0 -74
  36. package/src/components/CredentialRequestsEditor/components/DataFieldOptionType.tsx +0 -84
  37. package/src/components/CredentialRequestsEditor/components/DataFieldSection.tsx +0 -48
  38. package/src/components/CredentialRequestsEditor/components/DataFieldUserInput.tsx +0 -71
  39. package/src/components/CredentialRequestsEditor/components/RadioOption.tsx +0 -89
  40. package/src/components/CredentialRequestsEditor/contexts/CredentialRequestFieldContext.tsx +0 -36
  41. package/src/components/CredentialRequestsEditor/index.tsx +0 -15
  42. package/src/components/CredentialRequestsEditor/types/compositeCredentialSchema.ts +0 -1
  43. package/src/components/CredentialRequestsEditor/types/credentialSchemasDto.ts +0 -3
  44. package/src/components/CredentialRequestsEditor/types/form.ts +0 -28
  45. package/src/components/CredentialRequestsEditor/types/mandatoryEnum.ts +0 -5
  46. package/src/components/CredentialRequestsEditor/utils/buildDataFieldValue.ts +0 -65
  47. package/src/components/CredentialRequestsEditor/utils/prettyField.ts +0 -16
  48. package/src/components/Image.tsx +0 -10
  49. package/src/components/QRCodeDisplay/index.tsx +0 -50
  50. package/src/components/RequiredLabel/index.tsx +0 -15
  51. package/src/components/Snackbar/index.tsx +0 -156
  52. package/src/components/TextField/index.tsx +0 -8
  53. package/src/components/Tip/index.tsx +0 -18
  54. package/src/components/Typography/index.tsx +0 -8
  55. package/src/components/When.tsx +0 -28
  56. package/src/components/form/CountrySelector.tsx +0 -96
  57. package/src/components/form/DataFieldClearAdornment.tsx +0 -28
  58. package/src/components/form/DateInput.tsx +0 -78
  59. package/src/components/form/DefaultInput.tsx +0 -26
  60. package/src/components/form/InputMask.tsx +0 -41
  61. package/src/components/form/OTPInput.tsx +0 -254
  62. package/src/components/form/PhoneInput.tsx +0 -152
  63. package/src/components/form/SSNInput.tsx +0 -99
  64. package/src/components/form/SelectInput.tsx +0 -101
  65. package/src/components/form/TextMaskCustom.tsx +0 -48
  66. package/src/components/form/index.ts +0 -5
  67. package/src/components/index.ts +0 -13
  68. package/src/components/terms/AcceptTermsNotice.tsx +0 -27
  69. package/src/components/terms/LegalLink.tsx +0 -22
  70. package/src/components/verified/VerifiedImage.tsx +0 -272
  71. package/src/components/verified/VerifiedIncLogo.tsx +0 -11
  72. package/src/components/verified/index.ts +0 -2
  73. package/src/hooks/index.ts +0 -5
  74. package/src/hooks/useCallbackRef.ts +0 -22
  75. package/src/hooks/useCopyToClipboard.ts +0 -76
  76. package/src/hooks/useDisclosure.ts +0 -96
  77. package/src/hooks/useLocalStorage.ts +0 -24
  78. package/src/hooks/usePrevious.ts +0 -17
  79. package/src/hooks/useQRCode.ts +0 -62
  80. package/src/index.ts +0 -13
  81. package/src/stories/components/Alert.stories.tsx +0 -41
  82. package/src/stories/components/Button.stories.ts +0 -49
  83. package/src/stories/components/CredentialRequestsEditor.stories.tsx +0 -98
  84. package/src/stories/components/QRCodeDisplay.stories.tsx +0 -60
  85. package/src/stories/components/TextField.stories.ts +0 -59
  86. package/src/stories/components/Typography.stories.ts +0 -140
  87. package/src/stories/components/VerifiedImage.stories.tsx +0 -32
  88. package/src/stories/components/form/DateInput.stories.ts +0 -36
  89. package/src/stories/components/form/OTPInput.stories.tsx +0 -90
  90. package/src/stories/components/form/PhoneInput.stories.tsx +0 -34
  91. package/src/stories/components/form/SSNInput.stories.ts +0 -30
  92. package/src/stories/components/form/SelectInput.stories.ts +0 -39
  93. package/src/stories/hooks/useCopyToClipboard.stories.tsx +0 -45
  94. package/src/styles/colors.ts +0 -60
  95. package/src/styles/index.ts +0 -3
  96. package/src/styles/shadows.ts +0 -6
  97. package/src/styles/theme.ts +0 -257
  98. package/src/styles/typography.ts +0 -86
  99. package/src/utils/date.ts +0 -32
  100. package/src/utils/index.ts +0 -6
  101. package/src/utils/masks/index.ts +0 -6
  102. package/src/utils/omitProperty.ts +0 -19
  103. package/src/utils/phone.ts +0 -76
  104. package/src/utils/ssn.ts +0 -8
  105. package/src/utils/string/index.ts +0 -2
  106. package/src/utils/string/toCapitalize.ts +0 -13
  107. package/src/utils/string/toSentenceCase.ts +0 -7
  108. package/src/utils/wrapPromise.ts +0 -19
  109. package/src/validations/date.schema.ts +0 -18
  110. package/src/validations/description.schema.ts +0 -5
  111. package/src/validations/email.schema.ts +0 -3
  112. package/src/validations/field.schema.ts +0 -3
  113. package/src/validations/index.ts +0 -8
  114. package/src/validations/phone.schema.ts +0 -6
  115. package/src/validations/ssn.schema.ts +0 -24
  116. package/src/validations/state.schema.ts +0 -3
  117. package/src/validations/unix.schema.ts +0 -11
@@ -1,8 +0,0 @@
1
- import MUIAlert from '@mui/material/Alert';
2
- import type { AlertProps as MUIAlertProps } from '@mui/material/Alert';
3
-
4
- export type AlertProps = MUIAlertProps;
5
-
6
- export function Alert(props: AlertProps): React.JSX.Element {
7
- return <MUIAlert {...props} />;
8
- }
@@ -1,27 +0,0 @@
1
- import { Alert, type AlertProps } from '@mui/material';
2
-
3
- interface FullWidthAlertProps extends AlertProps {}
4
-
5
- export function FullWidthAlert({
6
- children,
7
- sx,
8
- ...props
9
- }: FullWidthAlertProps): React.JSX.Element {
10
- return (
11
- <>
12
- <Alert
13
- severity='info'
14
- sx={{
15
- maxWidth: '100%',
16
- width: '100%',
17
- textAlign: 'left',
18
- alignItems: 'center',
19
- ...sx,
20
- }}
21
- {...props}
22
- >
23
- {children}
24
- </Alert>
25
- </>
26
- );
27
- }
@@ -1,2 +0,0 @@
1
- export * from './Alert';
2
- export * from './FullWidthAlert';
@@ -1,34 +0,0 @@
1
- import {
2
- CircularProgress,
3
- Backdrop as MUIBackdrop,
4
- Stack,
5
- type SxProps,
6
- } from '@mui/material';
7
-
8
- interface BackdropProps {
9
- open: boolean;
10
- sx?: SxProps;
11
- children?: React.ReactNode;
12
- }
13
-
14
- export const Backdrop = ({
15
- open,
16
- sx,
17
- children,
18
- }: BackdropProps): React.JSX.Element => {
19
- return (
20
- <MUIBackdrop
21
- sx={{
22
- color: (theme) => theme.palette.primary.main,
23
- zIndex: (theme) => theme.zIndex.drawer + 1,
24
- ...sx,
25
- }}
26
- open={open}
27
- >
28
- <Stack alignItems='center' spacing={3}>
29
- <CircularProgress color='inherit' />
30
- {children}
31
- </Stack>
32
- </MUIBackdrop>
33
- );
34
- };
@@ -1,42 +0,0 @@
1
- import {
2
- AlertTitle,
3
- Box,
4
- type SxProps,
5
- useTheme,
6
- type AlertColor,
7
- } from '@mui/material';
8
-
9
- import { type ReactNode } from 'react';
10
- import { FullWidthAlert } from '../Alert/FullWidthAlert';
11
- import { Typography } from '../Typography';
12
-
13
- interface BannerProps {
14
- title: string;
15
- severity: AlertColor;
16
- children: ReactNode;
17
- sx?: SxProps;
18
- }
19
-
20
- export function Banner({
21
- title,
22
- severity,
23
- children,
24
- sx,
25
- }: BannerProps): React.JSX.Element {
26
- const theme = useTheme();
27
- return (
28
- <Box sx={{ mt: 3, ...sx }}>
29
- <FullWidthAlert severity={severity} sx={{ alignItems: 'start' }}>
30
- <AlertTitle>
31
- <Typography
32
- sx={{ color: theme.palette.info.contrastText }}
33
- fontWeight='bold'
34
- >
35
- {title}
36
- </Typography>
37
- </AlertTitle>
38
- {children}
39
- </FullWidthAlert>
40
- </Box>
41
- );
42
- }
@@ -1,18 +0,0 @@
1
- import { type SxProps } from '@mui/material';
2
- import { Banner } from './Banner';
3
-
4
- /**
5
- * "Enter your exact Birthday" Banner
6
- */
7
- export function ExactBirthdayBanner({
8
- sx,
9
- }: {
10
- sx?: SxProps;
11
- }): React.JSX.Element {
12
- return (
13
- <Banner title='Enter your exact Birthday' severity='info' sx={sx}>
14
- We need this to verify your identity with your phone carrier and pre-fill
15
- your signup info.
16
- </Banner>
17
- );
18
- }
@@ -1,55 +0,0 @@
1
- import { type SxProps, useTheme } from '@mui/material';
2
- import { FullWidthAlert } from '../Alert/FullWidthAlert';
3
- import { Button } from '../Button';
4
- import { parseToPhoneNational } from '../../utils';
5
-
6
- interface ResendPhoneBannerProps {
7
- phone: string;
8
- onClick: () => void;
9
- disabled?: boolean;
10
- sx?: SxProps;
11
- }
12
-
13
- /**
14
- * Banner to verify and resend the phone verification code.
15
- * @param phone
16
- * @param onClick
17
- * @constructor
18
- */
19
- export function ResendPhoneBanner({
20
- phone,
21
- onClick,
22
- disabled = false,
23
- sx,
24
- }: ResendPhoneBannerProps): React.JSX.Element {
25
- const theme = useTheme();
26
- return (
27
- <>
28
- <FullWidthAlert
29
- action={
30
- <Button
31
- onClick={onClick}
32
- disabled={disabled}
33
- sx={{
34
- color: theme.palette.info.contrastText,
35
- fontWeight: 800,
36
- fontSize: '13px',
37
- padding: '0',
38
- '&:hover': {
39
- backgroundColor: 'initial',
40
- },
41
- ...sx,
42
- }}
43
- size='small'
44
- variant='text'
45
- color='info'
46
- >
47
- Resend
48
- </Button>
49
- }
50
- >
51
- Use the text we sent to <strong>{parseToPhoneNational(phone)}</strong>{' '}
52
- </FullWidthAlert>
53
- </>
54
- );
55
- }
@@ -1,25 +0,0 @@
1
- import { Box, type SxProps } from '@mui/material';
2
- import { Banner } from './Banner';
3
-
4
- /**
5
- * Banner to inform about the test phone numbers
6
- */
7
- export function TestPhoneNumbersBanner({
8
- sx,
9
- }: {
10
- sx?: SxProps;
11
- }): React.JSX.Element {
12
- return (
13
- <Banner title='Test Phone Numbers' severity='info' sx={sx}>
14
- <Box
15
- component='ul'
16
- sx={{
17
- listStyle: 'inside',
18
- }}
19
- >
20
- <li>Phone Only Input: +10123456789</li>
21
- <li>Phone and Birth Date Inputs: +10019999999</li>
22
- </Box>
23
- </Banner>
24
- );
25
- }
@@ -1,4 +0,0 @@
1
- export * from './Banner';
2
- export * from './ResendPhoneBanner';
3
- export * from './ExactBirthdayBanner';
4
- export * from './TestPhoneNumbersBanner';
@@ -1,8 +0,0 @@
1
- import MUIButton from '@mui/material/Button';
2
- import type { ButtonProps as MUIButtonProps } from '@mui/material/Button';
3
-
4
- export type ButtonProps = MUIButtonProps;
5
-
6
- export function Button(props: ButtonProps): React.JSX.Element {
7
- return <MUIButton {...props} />;
8
- }
@@ -1,98 +0,0 @@
1
- import { createContext, type ReactNode, useContext, useEffect } from 'react';
2
- import { FormProvider, useForm, type WatchObserver } from 'react-hook-form';
3
- import debounce from 'lodash/debounce';
4
-
5
- import { omitProperties } from '../../utils/omitProperty';
6
-
7
- import {
8
- type CredentialRequests,
9
- type CredentialRequestsEditorForm,
10
- type CredentialRequestsWithNew,
11
- } from './types/form';
12
-
13
- export interface CredentialRequestsEditorFeatures {
14
- allowUserInput?: {
15
- disabled?: boolean;
16
- };
17
- description?: {
18
- disabled?: boolean;
19
- };
20
- mandatory?: {
21
- disabled?: boolean;
22
- };
23
- multi?: {
24
- disabled?: boolean;
25
- };
26
- }
27
-
28
- export interface CredentialRequestsEditorProps {
29
- addButtonText?: string;
30
- credentialRequests: CredentialRequestsWithNew[];
31
- schemas: Record<string, any>;
32
- children: ReactNode;
33
- onChange: (credentialRequests: CredentialRequests[]) => void;
34
- features?: CredentialRequestsEditorFeatures;
35
- }
36
-
37
- export interface CredentialRequestsEditorContext {
38
- addButtonText?: string;
39
- schemas: Record<string, any>;
40
- features?: CredentialRequestsEditorFeatures;
41
- }
42
-
43
- const Context = createContext<CredentialRequestsEditorContext | null>(null);
44
-
45
- export function useCredentialRequestsEditor(): CredentialRequestsEditorContext {
46
- const context = useContext(Context);
47
- if (!context) {
48
- throw new Error(
49
- 'useCredentialRequestsEditor must be used within a CredentialRequestsEditorProvider',
50
- );
51
- }
52
- return context;
53
- }
54
-
55
- export function CredentialRequestsEditorProvider(
56
- props: CredentialRequestsEditorProps,
57
- ): React.JSX.Element {
58
- const form = useForm<CredentialRequestsEditorForm>({
59
- defaultValues: { credentialRequests: props.credentialRequests },
60
- });
61
-
62
- // Listen to credentialRequests changes and call onChange event
63
- useEffect(() => {
64
- // Debouncing the watch observer to prevent multiple calls in a short period of time since it may dispatch child object change plus the property change
65
- const debouncedWatchObserver = debounce<
66
- WatchObserver<CredentialRequestsEditorForm>
67
- >((data, { name, type }) => {
68
- if (data.credentialRequests) {
69
- const credentialRequestsData = data.credentialRequests.filter(
70
- (credentialRequest) => !!credentialRequest?.type,
71
- );
72
-
73
- props.onChange(
74
- omitProperties(credentialRequestsData, [
75
- 'isNew',
76
- 'id',
77
- ]) as CredentialRequests[],
78
- );
79
- }
80
- }, 100);
81
- const subscription = form.watch(debouncedWatchObserver);
82
- return subscription.unsubscribe;
83
- }, [form.watch]);
84
-
85
- return (
86
- <FormProvider {...form}>
87
- <Context.Provider
88
- value={{
89
- addButtonText: props.addButtonText,
90
- schemas: props.schemas,
91
- features: props.features,
92
- }}
93
- >
94
- {props.children}
95
- </Context.Provider>
96
- </FormProvider>
97
- );
98
- }
@@ -1,103 +0,0 @@
1
- import React from 'react';
2
- import { Stack } from '@mui/material';
3
- import { Add } from '@mui/icons-material';
4
- import {
5
- useFieldArray,
6
- type UseFieldArrayReturn,
7
- useFormContext,
8
- } from 'react-hook-form';
9
- import { DndProvider } from 'react-dnd';
10
- import { HTML5Backend } from 'react-dnd-html5-backend';
11
-
12
- import { Button } from '../../Button';
13
-
14
- import { buildDataFieldValue } from '../utils/buildDataFieldValue';
15
- import { CredentialRequestFieldProvider } from '../contexts/CredentialRequestFieldContext';
16
- import { DataFieldAccordion } from './DataFieldAccordion';
17
-
18
- import { useCredentialRequestsEditor } from '../CredentialRequestsEditor.context';
19
- import {
20
- type CredentialRequestsEditorForm,
21
- type CredentialRequestsWithNew,
22
- } from '../types/form';
23
-
24
- function CredentialRequestField({
25
- path = 'credentialRequests',
26
- parentFieldArray,
27
- parentIndex = 0,
28
- level = 0,
29
- }: Readonly<{
30
- path?: string;
31
- parentFieldArray?: UseFieldArrayReturn<CredentialRequestsEditorForm>;
32
- parentIndex?: number;
33
- level?: number;
34
- }>): React.JSX.Element {
35
- const customConfig = useCredentialRequestsEditor();
36
- const form = useFormContext<CredentialRequestsEditorForm>();
37
- const fieldArray = useFieldArray<CredentialRequestsEditorForm>({
38
- control: form.control,
39
- name: path as any,
40
- });
41
-
42
- return (
43
- <>
44
- {fieldArray.fields.map((field, index) => {
45
- const _path = `${path}.${index}`;
46
- return (
47
- <CredentialRequestFieldProvider
48
- key={_path + field.type}
49
- path={_path}
50
- field={field}
51
- fieldArray={fieldArray}
52
- index={index}
53
- level={level}
54
- onAllFieldsDelete={() => {
55
- (parentFieldArray ?? fieldArray)?.remove(parentIndex);
56
- }}
57
- >
58
- <DataFieldAccordion />
59
- {Array.isArray(field.children) && (
60
- <CredentialRequestField
61
- key={`${_path}.children`}
62
- path={`${_path}.children`}
63
- parentFieldArray={fieldArray}
64
- parentIndex={index}
65
- level={level + 1}
66
- />
67
- )}
68
- </CredentialRequestFieldProvider>
69
- );
70
- })}
71
- {path === 'credentialRequests' && (
72
- <Button
73
- type='button'
74
- onClick={() => {
75
- if (!customConfig) return;
76
- const newValue: CredentialRequestsWithNew = {
77
- ...buildDataFieldValue('', customConfig.schemas),
78
- isNew: true,
79
- };
80
- fieldArray.append(newValue);
81
- }}
82
- size='large'
83
- variant='outlined'
84
- startIcon={<Add />}
85
- fullWidth
86
- sx={{ width: '100%' }}
87
- >
88
- {customConfig.addButtonText ?? 'Add Credential Request'}
89
- </Button>
90
- )}
91
- </>
92
- );
93
- }
94
-
95
- export function CredentialRequestsField(): React.JSX.Element {
96
- return (
97
- <DndProvider backend={HTML5Backend}>
98
- <Stack spacing={2}>
99
- <CredentialRequestField />
100
- </Stack>
101
- </DndProvider>
102
- );
103
- }