@verifiedinc-public/shared-ui-elements 1.2.2 → 1.3.1

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 (34) hide show
  1. package/dist/components/form/DateInput.d.ts +1 -1
  2. package/dist/shared-ui-elements.mjs +85 -20068
  3. package/dist/styles/colors.d.ts +25 -0
  4. package/dist/styles/index.d.ts +1 -0
  5. package/dist/styles/shadows.d.ts +3 -0
  6. package/dist/styles/theme.d.ts +13 -0
  7. package/dist/styles/typography.d.ts +85 -0
  8. package/dist/utils/string/index.d.ts +2 -0
  9. package/dist/utils/string/toCapitalize.d.ts +5 -0
  10. package/dist/utils/string/toSentenceCase.d.ts +5 -0
  11. package/package.json +2 -2
  12. package/src/components/form/DateInput.tsx +3 -3
  13. package/src/components/form/DefaultInput.tsx +0 -2
  14. package/src/components/form/PhoneInput.tsx +1 -2
  15. package/src/components/form/SSNInput.tsx +2 -3
  16. package/src/components/form/SelectInput.tsx +0 -2
  17. package/src/styles/colors.ts +30 -4
  18. package/src/styles/index.ts +1 -0
  19. package/src/styles/shadows.ts +6 -0
  20. package/src/styles/theme.ts +67 -16
  21. package/src/styles/typography.ts +86 -0
  22. package/src/utils/string/index.ts +2 -0
  23. package/src/utils/string/toCapitalize.ts +13 -0
  24. package/src/utils/string/toSentenceCase.ts +7 -0
  25. package/dist/components/form/styles/input.d.ts +0 -6
  26. package/dist/stories/components/Alert.stories.d.ts +0 -11
  27. package/dist/stories/components/CredentialRequestsEditor.stories.d.ts +0 -35
  28. package/dist/stories/components/QRCodeDisplay.stories.d.ts +0 -41
  29. package/dist/stories/components/TextField.stories.d.ts +0 -44
  30. package/dist/stories/components/Typography.stories.d.ts +0 -54
  31. package/dist/stories/components/VerifiedImage.stories.d.ts +0 -28
  32. package/dist/stories/components/form/PhoneInput.stories.d.ts +0 -16
  33. package/dist/stories/hooks/useCopyToClipboard.stories.d.ts +0 -14
  34. package/src/components/form/styles/input.ts +0 -24
@@ -21,3 +21,28 @@ export declare const darkGrey = "#797979";
21
21
  export declare const lightGreyContrast: "#bdbdbd";
22
22
  export declare const greyContrast: "#9e9e9e";
23
23
  export declare const darkGreyContrast: "#757575";
24
+ export declare const colors: {
25
+ textDisabled: string;
26
+ white: string;
27
+ black: string;
28
+ green: string;
29
+ lightGreen: string;
30
+ darkGreen: string;
31
+ blue: string;
32
+ lightBlue: string;
33
+ darkBlue: string;
34
+ red: string;
35
+ lightRed: string;
36
+ darkRed: string;
37
+ yellow: string;
38
+ lightYellow: string;
39
+ darkYellow: string;
40
+ warningContrast: string;
41
+ infoContrast: string;
42
+ lightGrey: string;
43
+ grey: string;
44
+ darkGrey: string;
45
+ lightGreyContrast: "#bdbdbd";
46
+ greyContrast: "#9e9e9e";
47
+ darkGreyContrast: "#757575";
48
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './colors';
2
2
  export * from './theme';
3
+ export * from './shadows';
@@ -0,0 +1,3 @@
1
+ export declare const shadows: {
2
+ bottomSheet: string;
3
+ };
@@ -1,21 +1,34 @@
1
+ declare module '@mui/material/Button' {
2
+ interface ButtonPropsColorOverrides {
3
+ neutralContrast: true;
4
+ warningContrast: true;
5
+ infoContrast: true;
6
+ }
7
+ }
1
8
  declare module '@mui/material/styles' {
2
9
  interface Palette {
3
10
  neutral: Palette['primary'];
4
11
  neutralContrast: Palette['primary'];
12
+ warningContrast: Palette['primary'];
13
+ infoContrast: Palette['primary'];
5
14
  }
6
15
  interface PaletteOptions {
7
16
  neutral: PaletteOptions['primary'];
8
17
  neutralContrast: PaletteOptions['primary'];
18
+ warningContrast: PaletteOptions['primary'];
19
+ infoContrast: PaletteOptions['primary'];
9
20
  }
10
21
  }
11
22
  declare module '@mui/material' {
12
23
  interface ButtonPropsColorOverrides {
13
24
  neutral: true;
14
25
  neutralContrast: true;
26
+ warningContrast: true;
15
27
  }
16
28
  interface SvgIconPropsColorOverrides {
17
29
  neutral: true;
18
30
  neutralContrast: true;
31
+ warningContrast: true;
19
32
  }
20
33
  }
21
34
  interface ThemeOptions {
@@ -0,0 +1,85 @@
1
+ export declare const typography: {
2
+ h1: {
3
+ fontSize: string;
4
+ fontWeight: number;
5
+ letterSpacing: number;
6
+ lineHeight: number;
7
+ };
8
+ h2: {
9
+ fontSize: string;
10
+ fontWeight: number;
11
+ letterSpacing: number;
12
+ lineHeight: number;
13
+ };
14
+ h3: {
15
+ fontSize: string;
16
+ fontWeight: number;
17
+ letterSpacing: number;
18
+ lineHeight: number;
19
+ };
20
+ h4: {
21
+ fontSize: string;
22
+ fontWeight: number;
23
+ letterSpacing: number;
24
+ lineHeight: number;
25
+ };
26
+ h5: {
27
+ fontSize: string;
28
+ fontWeight: number;
29
+ letterSpacing: number;
30
+ lineHeight: number;
31
+ };
32
+ h6: {
33
+ fontSize: string;
34
+ fontWeight: number;
35
+ letterSpacing: string;
36
+ };
37
+ subtitle1: {
38
+ fontSize: string;
39
+ fontWeight: number;
40
+ letterSpacing: number;
41
+ lineHeight: number;
42
+ };
43
+ subtitle2: {
44
+ fontSize: string;
45
+ fontWeight: number;
46
+ letterSpacing: number;
47
+ lineHeight: number;
48
+ };
49
+ body1: {
50
+ fontSize: string;
51
+ fontWeight: number;
52
+ letterSpacing: number;
53
+ lineHeight: number;
54
+ };
55
+ body2: {
56
+ fontSize: string;
57
+ fontWeight: number;
58
+ letterSpacing: number;
59
+ lineHeight: number;
60
+ };
61
+ button: {
62
+ fontWeight: number;
63
+ letterSpacing: number;
64
+ lineHeight: number;
65
+ textTransform: "uppercase";
66
+ };
67
+ caption: {
68
+ fontSize: string;
69
+ fontWeight: number;
70
+ letterSpacing: number;
71
+ lineHeight: number;
72
+ };
73
+ overline: {
74
+ fontSize: string;
75
+ fontWeight: number;
76
+ letterSpacing: number;
77
+ lineHeight: number;
78
+ };
79
+ label: {
80
+ fontSize: string;
81
+ fontWeight: number;
82
+ letterSpacing: number;
83
+ textTransform: "uppercase";
84
+ };
85
+ };
@@ -0,0 +1,2 @@
1
+ export * from './toCapitalize';
2
+ export * from './toSentenceCase';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Capitalize the first letter of every word, e.g "hello world" -> "Hello World"
3
+ * @param str
4
+ */
5
+ export declare function toCapitalize(str: string): string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Capitalize the first letter of a string e.g "hello world" -> "Hello world"
3
+ * @param str
4
+ */
5
+ export declare function toSentenceCase(str: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "keywords": [],
@@ -33,7 +33,7 @@
33
33
  "storybook": "storybook dev -p 6006",
34
34
  "build-storybook": "storybook build",
35
35
  "prebuild": "rm -rf dist",
36
- "build": "tsc && vite build",
36
+ "build": "tsc && vite build && esbuild dist/shared-ui-elements.mjs --minify --outfile=dist/shared-ui-elements.mjs --allow-overwrite",
37
37
  "prepublishOnly": "npm run build",
38
38
  "publish:prerelease": "npm version prerelease --preid=beta && npm publish --tag beta"
39
39
  },
@@ -1,8 +1,9 @@
1
- import { Box, TextField, type TextFieldProps } from '@mui/material';
2
1
  import { forwardRef, useState, type ChangeEventHandler } from 'react';
2
+ import { Box, TextField, type TextFieldProps } from '@mui/material';
3
+
3
4
  import { masks } from '../../utils/masks';
5
+
4
6
  import { InputMask } from './InputMask';
5
- import { inputStyle } from './styles/input';
6
7
 
7
8
  interface DateInputProps extends Omit<TextFieldProps, 'onBlur' | 'onChange'> {
8
9
  label?: string;
@@ -43,7 +44,6 @@ function DateInputComponent(
43
44
  };
44
45
 
45
46
  const textFieldStyle: TextFieldProps = {
46
- ...inputStyle,
47
47
  label,
48
48
  error,
49
49
  helperText,
@@ -1,5 +1,4 @@
1
1
  import { forwardRef } from 'react';
2
- import { inputStyle } from './styles/input';
3
2
  import { TextField, type TextFieldProps } from '../TextField';
4
3
 
5
4
  /**
@@ -16,7 +15,6 @@ const DefaultInput = (
16
15
  return (
17
16
  <TextField
18
17
  inputRef={ref}
19
- {...inputStyle}
20
18
  variant={variant}
21
19
  margin={margin}
22
20
  fullWidth
@@ -1,8 +1,8 @@
1
1
  import { Box, InputAdornment, type InputProps } from '@mui/material';
2
2
  import { type TextFieldProps } from '../TextField';
3
3
  import { useEffect, useMemo, useRef, useState } from 'react';
4
+
4
5
  import { getPhoneDataByFieldName } from '../../utils/phone';
5
- import { inputStyle } from './styles/input';
6
6
  import { phoneSchema } from '../../validations/phone.schema';
7
7
 
8
8
  import { TextMaskCustom } from './TextMaskCustom';
@@ -104,7 +104,6 @@ export function PhoneInput({
104
104
 
105
105
  const inputProps: TextFieldProps = {
106
106
  inputRef,
107
- ...inputStyle,
108
107
  label,
109
108
  name: `_${name}`,
110
109
  helperText,
@@ -1,8 +1,8 @@
1
+ import { useState } from 'react';
1
2
  import { Box, TextField, type TextFieldProps } from '@mui/material';
2
- import { useEffect, useState } from 'react';
3
+
3
4
  import { usePrevious } from '../../hooks/usePrevious';
4
5
  import { DataFieldClearAdornment } from './DataFieldClearAdornment';
5
- import { inputStyle } from './styles/input';
6
6
  import { TextMaskCustom } from './TextMaskCustom';
7
7
 
8
8
  type TextStyles = Omit<TextFieldProps, 'onChange'> & { onChange: any };
@@ -42,7 +42,6 @@ export function SSNInput({
42
42
  };
43
43
 
44
44
  const textFieldStyle: TextStyles = {
45
- ...inputStyle,
46
45
  value,
47
46
  onChange: (e: any, nativeEvent: any) => {
48
47
  if (!nativeEvent) return;
@@ -4,7 +4,6 @@ import {
4
4
  type TextFieldProps as InternalFieldProps,
5
5
  } from '@mui/material';
6
6
  import { useState } from 'react';
7
- import { inputStyle } from './styles/input';
8
7
 
9
8
  interface TextFieldProps extends Omit<InternalFieldProps, 'onChange'> {}
10
9
 
@@ -62,7 +61,6 @@ export function SelectInput({
62
61
  };
63
62
 
64
63
  const textFieldStyle: TextFieldProps = {
65
- ...inputStyle,
66
64
  inputProps: {
67
65
  tabIndex: 0,
68
66
  },
@@ -1,4 +1,4 @@
1
- import { colors } from '@mui/material';
1
+ import { colors as MUIColors } from '@mui/material';
2
2
 
3
3
  export const textDisabled = 'rgba(0,0,0,0.26)';
4
4
 
@@ -29,6 +29,32 @@ export const lightGrey = '#F9F9FB';
29
29
  export const grey = '#bdbdbd';
30
30
  export const darkGrey = '#797979';
31
31
 
32
- export const lightGreyContrast = colors.grey['400'];
33
- export const greyContrast = colors.grey['500'];
34
- export const darkGreyContrast = colors.grey['600'];
32
+ export const lightGreyContrast = MUIColors.grey['400'];
33
+ export const greyContrast = MUIColors.grey['500'];
34
+ export const darkGreyContrast = MUIColors.grey['600'];
35
+
36
+ export const colors = {
37
+ textDisabled,
38
+ white,
39
+ black,
40
+ green,
41
+ lightGreen,
42
+ darkGreen,
43
+ blue,
44
+ lightBlue,
45
+ darkBlue,
46
+ red,
47
+ lightRed,
48
+ darkRed,
49
+ yellow,
50
+ lightYellow,
51
+ darkYellow,
52
+ warningContrast,
53
+ infoContrast,
54
+ lightGrey,
55
+ grey,
56
+ darkGrey,
57
+ lightGreyContrast,
58
+ greyContrast,
59
+ darkGreyContrast,
60
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './colors';
2
2
  export * from './theme';
3
+ export * from './shadows';
@@ -0,0 +1,6 @@
1
+ const bottomSheet =
2
+ '0px -2px 4px -1px rgba(0,0,0,0.2), 0px -4px 5px 0px rgba(0,0,0,0.14), 0px -1px 10px 0px rgba(0,0,0,0.12)';
3
+
4
+ export const shadows = {
5
+ bottomSheet,
6
+ };
@@ -1,16 +1,29 @@
1
1
  import { createTheme } from '@mui/material';
2
- import * as colors from './colors';
2
+ import { colors } from './colors';
3
+ import { typography } from './typography';
4
+
5
+ declare module '@mui/material/Button' {
6
+ interface ButtonPropsColorOverrides {
7
+ neutralContrast: true;
8
+ warningContrast: true;
9
+ infoContrast: true;
10
+ }
11
+ }
3
12
 
4
13
  declare module '@mui/material/styles' {
5
14
  // custom palette
6
15
  interface Palette {
7
16
  neutral: Palette['primary'];
8
17
  neutralContrast: Palette['primary'];
18
+ warningContrast: Palette['primary'];
19
+ infoContrast: Palette['primary'];
9
20
  }
10
21
 
11
22
  interface PaletteOptions {
12
23
  neutral: PaletteOptions['primary'];
13
24
  neutralContrast: PaletteOptions['primary'];
25
+ warningContrast: PaletteOptions['primary'];
26
+ infoContrast: PaletteOptions['primary'];
14
27
  }
15
28
  }
16
29
 
@@ -19,10 +32,12 @@ declare module '@mui/material' {
19
32
  interface ButtonPropsColorOverrides {
20
33
  neutral: true;
21
34
  neutralContrast: true;
35
+ warningContrast: true;
22
36
  }
23
37
  interface SvgIconPropsColorOverrides {
24
38
  neutral: true;
25
39
  neutralContrast: true;
40
+ warningContrast: true;
26
41
  }
27
42
  }
28
43
 
@@ -32,8 +47,18 @@ interface ThemeOptions {
32
47
 
33
48
  export const theme = ({ primaryFontFace }: ThemeOptions) =>
34
49
  createTheme({
50
+ breakpoints: {
51
+ values: {
52
+ xs: 0,
53
+ sm: 600,
54
+ md: 900,
55
+ lg: 1200,
56
+ xl: 1536,
57
+ },
58
+ },
35
59
  typography: {
36
60
  fontFamily: primaryFontFace.style.fontFamily,
61
+ ...typography,
37
62
  },
38
63
  palette: {
39
64
  text: {
@@ -85,8 +110,43 @@ export const theme = ({ primaryFontFace }: ThemeOptions) =>
85
110
  light: colors.lightGreyContrast,
86
111
  dark: colors.darkGreyContrast,
87
112
  },
113
+ // We can register custom color to our palette with the augmentColor method.
114
+ warningContrast: {
115
+ main: colors.warningContrast,
116
+ },
117
+ infoContrast: {
118
+ main: colors.infoContrast,
119
+ },
88
120
  },
89
121
  components: {
122
+ MuiAlert: {
123
+ styleOverrides: {
124
+ root: {
125
+ maxWidth: '339px',
126
+ },
127
+ action: {
128
+ // the action wrapper is pretty narrow (only fits about 5 characters of text) and the default is to wrap the text, which looks really bad
129
+ overflowWrap: 'normal',
130
+ // we want the action text, element, etc to be vertically centered if there are multiple lines of text in the alert body
131
+ display: 'flex',
132
+ alignItems: 'center',
133
+ padding: '8px 0',
134
+ marginRight: 0,
135
+ '& button, & a': {
136
+ lineHeight: '0',
137
+ },
138
+ },
139
+ },
140
+ },
141
+ MuiAlertTitle: {
142
+ styleOverrides: {
143
+ root: {
144
+ ...typography.body2,
145
+ fontSize: '1.1rem',
146
+ fontWeight: 700,
147
+ },
148
+ },
149
+ },
90
150
  MuiListItemIcon: {
91
151
  styleOverrides: {
92
152
  root: {
@@ -166,21 +226,6 @@ export const theme = ({ primaryFontFace }: ThemeOptions) =>
166
226
  },
167
227
  },
168
228
  },
169
- MuiAlert: {
170
- styleOverrides: {
171
- root: {
172
- maxWidth: '339px',
173
- },
174
- action: {
175
- padding: '8px 0',
176
- marginRight: 0,
177
- alignItems: 'center',
178
- '& button, & a': {
179
- lineHeight: '0',
180
- },
181
- },
182
- },
183
- },
184
229
  MuiRadio: {
185
230
  styleOverrides: {
186
231
  root: {
@@ -205,5 +250,11 @@ export const theme = ({ primaryFontFace }: ThemeOptions) =>
205
250
  },
206
251
  },
207
252
  },
253
+ MuiTextField: {
254
+ defaultProps: {
255
+ variant: 'outlined',
256
+ size: 'small',
257
+ },
258
+ },
208
259
  },
209
260
  });
@@ -0,0 +1,86 @@
1
+ export const typography = {
2
+ h1: {
3
+ fontSize: '2.125rem',
4
+ fontWeight: 700,
5
+ letterSpacing: 0,
6
+ lineHeight: 1.35,
7
+ },
8
+ h2: {
9
+ fontSize: '1.5rem',
10
+ fontWeight: 700,
11
+ letterSpacing: 0,
12
+ lineHeight: 1.33,
13
+ },
14
+ h3: {
15
+ fontSize: '1.25rem',
16
+ fontWeight: 700,
17
+ letterSpacing: 0,
18
+ lineHeight: 1.35,
19
+ },
20
+ h4: {
21
+ fontSize: '1.25rem',
22
+ fontWeight: 700,
23
+ letterSpacing: 0,
24
+ lineHeight: 1.2,
25
+ },
26
+ h5: {
27
+ fontSize: '1rem',
28
+ fontWeight: 700,
29
+ letterSpacing: 0,
30
+ lineHeight: 1.1875,
31
+ },
32
+ h6: {
33
+ fontSize: '1rem',
34
+ fontWeight: 700,
35
+ letterSpacing: '0.15px',
36
+ },
37
+ subtitle1: {
38
+ fontSize: '1rem',
39
+ fontWeight: 700,
40
+ letterSpacing: 0,
41
+ lineHeight: 1.1875,
42
+ },
43
+ subtitle2: {
44
+ fontSize: '0.875rem',
45
+ fontWeight: 700,
46
+ letterSpacing: 0.1,
47
+ lineHeight: 1.5,
48
+ },
49
+ body1: {
50
+ fontSize: '1.25rem',
51
+ fontWeight: 300,
52
+ letterSpacing: 0,
53
+ lineHeight: 1.2,
54
+ },
55
+ body2: {
56
+ fontSize: '1rem',
57
+ fontWeight: 400,
58
+ letterSpacing: 0,
59
+ lineHeight: 1.1875,
60
+ },
61
+ button: {
62
+ // fontSize set by MUI button component sizes, setting it here will screw that up
63
+ fontWeight: 700,
64
+ letterSpacing: 0,
65
+ lineHeight: 1.2,
66
+ textTransform: 'uppercase' as const,
67
+ },
68
+ caption: {
69
+ fontSize: '0.75rem',
70
+ fontWeight: 400,
71
+ letterSpacing: 0,
72
+ lineHeight: 1.25,
73
+ },
74
+ overline: {
75
+ fontSize: '0.75rem',
76
+ fontWeight: 400,
77
+ letterSpacing: 0,
78
+ lineHeight: 1.25,
79
+ },
80
+ label: {
81
+ fontSize: '0.75rem',
82
+ fontWeight: 700,
83
+ letterSpacing: 1,
84
+ textTransform: 'uppercase' as const,
85
+ },
86
+ };
@@ -0,0 +1,2 @@
1
+ export * from './toCapitalize';
2
+ export * from './toSentenceCase';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Capitalize the first letter of every word, e.g "hello world" -> "Hello World"
3
+ * @param str
4
+ */
5
+ export function toCapitalize(str: string): string {
6
+ return str
7
+ .split(' ')
8
+ .map(
9
+ (substr) =>
10
+ `${substr.charAt(0).toUpperCase()}${substr.slice(1).toLowerCase()}`,
11
+ )
12
+ .join(' ');
13
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Capitalize the first letter of a string e.g "hello world" -> "Hello world"
3
+ * @param str
4
+ */
5
+ export function toSentenceCase(str: string) {
6
+ return `${str.charAt(0).toUpperCase()}${str.slice(1).toLowerCase()}`;
7
+ }
@@ -1,6 +0,0 @@
1
- import { TextFieldProps } from '../../../components/TextField';
2
- /**
3
- * The base style definition for input fields, it should reflect changes across all inputs.
4
- */
5
- export declare const inputStyle: TextFieldProps;
6
- export declare const readOnlyInputStyle: TextFieldProps;
@@ -1,11 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { Alert } from '../../components/Alert';
3
- type PropsAndCustomArgs = React.ComponentProps<typeof Alert> & {
4
- text?: string;
5
- withAction?: boolean;
6
- };
7
- declare const meta: Meta<PropsAndCustomArgs>;
8
- export default meta;
9
- type Story = StoryObj<PropsAndCustomArgs>;
10
- export declare const Default: Story;
11
- export declare const WithButton: Story;
@@ -1,35 +0,0 @@
1
- import { StoryObj } from '@storybook/react';
2
- import { CredentialRequestsEditor } from '../../components/CredentialRequestsEditor';
3
- declare const meta: {
4
- title: string;
5
- component: typeof CredentialRequestsEditor;
6
- render: (args: any, { loaded: { credentialRequests, schemas } }: import('@storybook/csf').StoryContext<import('@storybook/react').ReactRenderer, Omit<import('../../components/CredentialRequestsEditor/CredentialRequestsEditor.context').CredentialRequestsEditorProps, "children">>) => import("react").JSX.Element;
7
- parameters: {
8
- layout: string;
9
- docs: {
10
- description: {
11
- component: string;
12
- };
13
- };
14
- };
15
- tags: string[];
16
- argTypes: {
17
- credentialRequests: {
18
- description: string;
19
- };
20
- schemas: {
21
- description: string;
22
- };
23
- addButtonText: {
24
- type: "string";
25
- description: string;
26
- };
27
- features: {
28
- control: "object";
29
- description: string;
30
- };
31
- };
32
- };
33
- export default meta;
34
- type Story = StoryObj<typeof meta>;
35
- export declare const Default: Story;