@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,156 +0,0 @@
1
- import { Close } from '@mui/icons-material';
2
- import {
3
- Alert,
4
- type AlertColor,
5
- Box,
6
- IconButton,
7
- type SxProps,
8
- } from '@mui/material';
9
- import {
10
- closeSnackbar,
11
- type CustomContentProps,
12
- enqueueSnackbar as _enqueueSnackbar,
13
- SnackbarContent,
14
- type SnackbarKey,
15
- SnackbarProvider,
16
- } from 'notistack';
17
- import { forwardRef } from 'react';
18
- import { When } from '../When';
19
-
20
- declare module 'notistack' {
21
- interface VariantOverrides {
22
- default: false;
23
- success: false;
24
- info: false;
25
- warning: false;
26
- error: false;
27
- customAlertComponent: {
28
- onAction?: (id: SnackbarKey) => void;
29
- icon?: JSX.Element;
30
- severity?: AlertColor;
31
- };
32
- }
33
- }
34
-
35
- export { SnackbarProvider };
36
- export type { SnackbarKey };
37
-
38
- interface AlertAction {
39
- onAction?: (id: SnackbarKey) => void;
40
- icon?: JSX.Element;
41
- }
42
-
43
- interface CustomAlertComponentProps extends Partial<CustomContentProps> {
44
- severity: AlertColor;
45
- alertAction?: AlertAction;
46
- showCloseIcon?: boolean;
47
- sx?: SxProps;
48
- }
49
-
50
- /**
51
- * Hook to manage snackbar messages
52
- * It wraps the enqueueSnackbar and closeSnackbar functions from the notistack library
53
- * @returns
54
- * - enqueueSnackbar: Function to enqueue a snackbar message
55
- * - closeSnackbar: Function to close one or all snackbar messages
56
- * @see https://notistack.com/api-reference
57
- */
58
- export function useSnackbar(): {
59
- enqueueSnackbar: (
60
- message: string,
61
- severity?: AlertColor,
62
- options?: Omit<CustomAlertComponentProps, 'severity'>,
63
- ) => void;
64
- closeSnackbar: (key?: SnackbarKey) => void;
65
- } {
66
- const enqueueSnackbar = (
67
- message: string,
68
- severity: AlertColor = 'success',
69
- options?: Omit<CustomAlertComponentProps, 'severity'>,
70
- ): void => {
71
- _enqueueSnackbar(message, {
72
- severity,
73
- variant: 'customAlertComponent',
74
- persist: true,
75
- ...options,
76
- });
77
- };
78
-
79
- return { enqueueSnackbar, closeSnackbar };
80
- }
81
-
82
- /**
83
- * Custom Alert component to show snackbar messages
84
- * This is a wrapper around the notistack SnackbarContent component
85
- *
86
- * Use it in the SnackbarProvider Components prop:
87
- * @see https://notistack.com/features/customization#custom-component
88
- * @example
89
- * <SnackbarProvider
90
- * Components={{ customAlertComponent: CustomAlertComponent }}
91
- * />
92
- */
93
- export const CustomAlertComponent = forwardRef<
94
- HTMLDivElement,
95
- CustomAlertComponentProps
96
- >(
97
- (
98
- {
99
- id,
100
- message,
101
- severity,
102
- alertAction,
103
- sx,
104
- showCloseIcon = true,
105
-
106
- // remove these props because they were triggering warnings. They are not used in this component anyway
107
- persist,
108
- hideIconVariant,
109
- autoHideDuration,
110
- anchorOrigin,
111
- iconVariant,
112
-
113
- ...props
114
- },
115
- ref,
116
- ) => {
117
- return (
118
- <SnackbarContent ref={ref} {...props}>
119
- <Alert
120
- severity={severity}
121
- action={
122
- <Box ml={1}>
123
- <When value={alertAction}>
124
- <IconButton
125
- size='small'
126
- onClick={() => id && alertAction?.onAction?.(id)}
127
- color='inherit'
128
- >
129
- {alertAction?.icon}
130
- </IconButton>
131
- </When>
132
- <When value={!alertAction && showCloseIcon}>
133
- <IconButton
134
- size='small'
135
- onClick={() => {
136
- closeSnackbar(id);
137
- }}
138
- color='inherit'
139
- >
140
- <Close />
141
- </IconButton>
142
- </When>
143
- </Box>
144
- }
145
- sx={{
146
- alignItems: 'center',
147
- width: '320px',
148
- ...sx,
149
- }}
150
- >
151
- {message}
152
- </Alert>
153
- </SnackbarContent>
154
- );
155
- },
156
- );
@@ -1,8 +0,0 @@
1
- import MUITextField from '@mui/material/TextField';
2
- import type { TextFieldProps as MUITextFieldProps } from '@mui/material/TextField';
3
-
4
- export type TextFieldProps = MUITextFieldProps;
5
-
6
- export function TextField(props: TextFieldProps): JSX.Element {
7
- return <MUITextField {...props} />;
8
- }
@@ -1,18 +0,0 @@
1
- import { type PropsWithChildren } from 'react';
2
- import { IconButton, Tooltip } from '@mui/material';
3
- import { Code } from '@mui/icons-material';
4
-
5
- export function Tip({ children }: PropsWithChildren): React.JSX.Element {
6
- return (
7
- <Tooltip title={children} arrow enterTouchDelay={0}>
8
- <IconButton
9
- size='small'
10
- onClick={(e) => {
11
- e.stopPropagation();
12
- }}
13
- >
14
- <Code />
15
- </IconButton>
16
- </Tooltip>
17
- );
18
- }
@@ -1,8 +0,0 @@
1
- import MUITypography from '@mui/material/Typography';
2
- import type { TypographyProps as MUITypographyProps } from '@mui/material/Typography';
3
-
4
- export type TypographyProps = MUITypographyProps;
5
-
6
- export function Typography(props: TypographyProps): JSX.Element {
7
- return <MUITypography {...props} />;
8
- }
@@ -1,28 +0,0 @@
1
- import { type ReactNode } from 'react';
2
-
3
- export interface WhenProps<T = unknown> {
4
- value: T;
5
- children: ReactNode | ((condition: NonNullable<T>) => ReactNode);
6
- }
7
-
8
- /**
9
- * This component can be used when using value is truthy to render some other component,
10
- * instead of using ternary operators you can use this.
11
- *
12
- * This is particularly useful when you have nested conditional rendering. Also, it allows for safer falsy conditions
13
- * while in a ternary you can risk rendering falsy values in the react tree if you use `&&`.
14
- * @param value
15
- * @param children Children can be direct ReactNode or a function returning ReactNode, when a function,
16
- * the value is being passed as param and is guarantee to be non-nullable excluding undefined and null from the inferred type.
17
- * @constructor
18
- */
19
- export function When<T>({
20
- value,
21
- children,
22
- }: WhenProps<T>): React.JSX.Element | null {
23
- if (!value) return null;
24
-
25
- if (typeof children === 'function') return <>{children(value)}</>;
26
-
27
- return <>{children}</>;
28
- }
@@ -1,96 +0,0 @@
1
- import { useMemo, useState } from 'react';
2
- import { Button, Menu, MenuItem } from '@mui/material';
3
-
4
- import { KeyboardArrowDown } from '@mui/icons-material';
5
- import {
6
- countries,
7
- getPhoneDataByFieldName,
8
- sortByCountryName,
9
- } from '../../utils/phone';
10
-
11
- interface CountrySelectorProps {
12
- value: string;
13
- onChange: (value: string) => void;
14
- shouldShowOnlyNorthAmericanCountries?: boolean;
15
- }
16
-
17
- /**
18
- * Component that renders and allows to manage the desired phone country format.
19
- * @constructor
20
- */
21
- export default function CountrySelector({
22
- shouldShowOnlyNorthAmericanCountries = true,
23
- ...props
24
- }: Readonly<CountrySelectorProps>): React.JSX.Element {
25
- const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
26
- const open = Boolean(anchorEl);
27
- const options = useMemo(() => {
28
- // Remove Brazil from the list of countries, we allow only North American numbers.
29
- let _countries = [
30
- ...countries.filter((country) => country.countryCode !== 'BR'),
31
- ];
32
-
33
- // Show all countries in development mode.
34
- if (!shouldShowOnlyNorthAmericanCountries) {
35
- _countries = [...countries];
36
- }
37
-
38
- return [..._countries].sort(sortByCountryName);
39
- }, [shouldShowOnlyNorthAmericanCountries]);
40
-
41
- const handleClick = (event: React.MouseEvent<HTMLElement>): void => {
42
- setAnchorEl(event.currentTarget);
43
- };
44
-
45
- const handleClose = (): void => {
46
- setAnchorEl(null);
47
- };
48
-
49
- return (
50
- <>
51
- <Button
52
- id='demo-customized-button'
53
- aria-controls={open ? 'country-select-button' : undefined}
54
- aria-haspopup='true'
55
- aria-expanded={open ? 'true' : undefined}
56
- variant='text'
57
- disableElevation
58
- onClick={handleClick}
59
- endIcon={<KeyboardArrowDown />}
60
- >
61
- {getPhoneDataByFieldName('countryCode', props.value)?.emoji}
62
- </Button>
63
- <Menu
64
- anchorEl={anchorEl}
65
- open={open}
66
- onClose={handleClose}
67
- MenuListProps={{
68
- 'aria-labelledby': 'country-select-button',
69
- }}
70
- slotProps={{
71
- paper: {
72
- style: {
73
- maxHeight: 48 * 4.5,
74
- width: '20ch',
75
- minWidth: '300px',
76
- },
77
- },
78
- }}
79
- >
80
- {/* spread to avoid mutating the original countries array with sort method */}
81
- {options.map((country) => (
82
- <MenuItem
83
- role='menuitem'
84
- key={country.countryCode}
85
- onClick={() => {
86
- props.onChange(country.countryCode);
87
- handleClose();
88
- }}
89
- >
90
- {country.emoji} {country.countryName}
91
- </MenuItem>
92
- ))}
93
- </Menu>
94
- </>
95
- );
96
- }
@@ -1,28 +0,0 @@
1
- import { Close } from '@mui/icons-material';
2
- import { InputAdornment, IconButton } from '@mui/material';
3
-
4
- type DataFieldClearAdornmentProps = Readonly<{
5
- onClick?: () => void;
6
- handleClear: () => void;
7
- }>;
8
-
9
- export function DataFieldClearAdornment({
10
- onClick,
11
- handleClear,
12
- }: DataFieldClearAdornmentProps): React.JSX.Element {
13
- return (
14
- <InputAdornment position='end'>
15
- <IconButton
16
- aria-label='clear value'
17
- edge='end'
18
- size='small'
19
- onClick={() => {
20
- handleClear();
21
- onClick?.();
22
- }}
23
- >
24
- <Close fontSize='small' />
25
- </IconButton>
26
- </InputAdornment>
27
- );
28
- }
@@ -1,78 +0,0 @@
1
- import { forwardRef, useState, type ChangeEventHandler } from 'react';
2
- import { Box, TextField, type TextFieldProps } from '@mui/material';
3
-
4
- import { masks } from '../../utils/masks';
5
-
6
- import { InputMask } from './InputMask';
7
-
8
- interface DateInputProps extends Omit<TextFieldProps, 'onBlur' | 'onChange'> {
9
- label?: string;
10
- value?: string;
11
- helperText?: string;
12
- onChange?: (value: string) => void;
13
- onBlur?: ChangeEventHandler<HTMLInputElement>;
14
- }
15
-
16
- function DateInputComponent(
17
- {
18
- label = 'Date',
19
- value: controlledValue,
20
- error,
21
- helperText,
22
- onChange,
23
- onBlur,
24
- disabled,
25
- ...rest
26
- }: Readonly<DateInputProps>,
27
- ref: any,
28
- ): React.JSX.Element {
29
- const [internalValue, setInternalValue] = useState<string>('');
30
-
31
- // Determine the value to display
32
- const isControlled = controlledValue !== undefined;
33
- const value = isControlled ? controlledValue : internalValue;
34
-
35
- const handleChange = (e: any): void => {
36
- const date = e.target.value;
37
- if (!isControlled) {
38
- setInternalValue(date); // Update internal state only if uncontrolled
39
- }
40
-
41
- if (onChange) {
42
- onChange(date);
43
- }
44
- };
45
-
46
- const textFieldStyle: TextFieldProps = {
47
- label,
48
- error,
49
- helperText,
50
- inputProps: {
51
- // Set the input mode to numeric.
52
- inputMode: 'numeric',
53
- // Tab index for each block.
54
- tabIndex: 0,
55
- // Mask type date.
56
- mask: masks.DOB_MASK,
57
- },
58
- fullWidth: true,
59
- ...rest,
60
- };
61
-
62
- return (
63
- <Box width='100%'>
64
- <InputMask
65
- mask={masks.DOB_MASK}
66
- maskPlaceholder={null}
67
- disabled={disabled}
68
- value={value}
69
- onBlur={onBlur}
70
- onChange={handleChange}
71
- >
72
- <TextField {...textFieldStyle} inputRef={ref} />
73
- </InputMask>
74
- </Box>
75
- );
76
- }
77
-
78
- export const DateInput = forwardRef(DateInputComponent);
@@ -1,26 +0,0 @@
1
- import { forwardRef } from 'react';
2
- import { TextField, type TextFieldProps } from '../TextField';
3
-
4
- /**
5
- * A wrapper around the MUI TextField component to encapsulate some common defaults.
6
- * Primarily intended for use creating more specific Input components rather than for direct use.
7
- *
8
- * @param {TextFieldProps} props DefaultInput takes the same props as the MUI TextField component.
9
- * It sets default values for variant ('outlined') and margin ('normal').
10
- */
11
- const DefaultInput = (
12
- { variant = 'outlined', margin = 'normal', ...props }: TextFieldProps,
13
- ref: any,
14
- ): React.JSX.Element => {
15
- return (
16
- <TextField
17
- inputRef={ref}
18
- variant={variant}
19
- margin={margin}
20
- fullWidth
21
- {...props}
22
- />
23
- );
24
- };
25
-
26
- export default forwardRef(DefaultInput);
@@ -1,41 +0,0 @@
1
- import { type ChangeEventHandler, type ReactNode } from 'react';
2
- import RInputMask from '@mona-health/react-input-mask';
3
-
4
- interface Selection {
5
- start: string;
6
- end: string;
7
- }
8
-
9
- interface State {
10
- value: string;
11
- selection: Selection;
12
- }
13
-
14
- interface BeforeMaskedStateChangeOptions {
15
- previousState: State;
16
- currentState: State;
17
- nextState: State;
18
- }
19
-
20
- interface InputMaskProps {
21
- // Custom render function for integration with other input components.
22
- children: ReactNode;
23
- // Mask format.
24
- mask: string | Array<RegExp | string>;
25
- // Input value.
26
- value: string;
27
- // Change event handler.
28
- onChange: ChangeEventHandler<HTMLInputElement>;
29
- // Function to modify value and selection before applying mask.
30
- onBlur?: ChangeEventHandler<HTMLInputElement>;
31
- beforeMaskedStateChange?: (options: BeforeMaskedStateChangeOptions) => void;
32
- // Placeholder to cover unfilled parts of the mask, null to remove the default "_" placeholder.
33
- maskPlaceholder?: string | null;
34
- // Whether mask prefix and placeholder should be displayed when input is empty and has no focus.
35
- alwaysShowMask?: boolean;
36
- disabled?: boolean;
37
- }
38
-
39
- export function InputMask(props: Readonly<InputMaskProps>): React.JSX.Element {
40
- return <RInputMask {...props} />;
41
- }