@verifiedinc-public/shared-ui-elements 1.2.1 → 1.3.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 (29) 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/typography.d.ts +85 -0
  5. package/dist/utils/string/index.d.ts +2 -0
  6. package/dist/utils/string/toCapitalize.d.ts +5 -0
  7. package/dist/utils/string/toSentenceCase.d.ts +5 -0
  8. package/package.json +4 -4
  9. package/src/components/form/DateInput.tsx +3 -3
  10. package/src/components/form/DefaultInput.tsx +0 -2
  11. package/src/components/form/PhoneInput.tsx +1 -2
  12. package/src/components/form/SSNInput.tsx +2 -3
  13. package/src/components/form/SelectInput.tsx +0 -2
  14. package/src/styles/colors.ts +30 -4
  15. package/src/styles/theme.ts +18 -1
  16. package/src/styles/typography.ts +86 -0
  17. package/src/utils/string/index.ts +2 -0
  18. package/src/utils/string/toCapitalize.ts +13 -0
  19. package/src/utils/string/toSentenceCase.ts +7 -0
  20. package/dist/components/form/styles/input.d.ts +0 -6
  21. package/dist/stories/components/Alert.stories.d.ts +0 -11
  22. package/dist/stories/components/CredentialRequestsEditor.stories.d.ts +0 -35
  23. package/dist/stories/components/QRCodeDisplay.stories.d.ts +0 -41
  24. package/dist/stories/components/TextField.stories.d.ts +0 -44
  25. package/dist/stories/components/Typography.stories.d.ts +0 -54
  26. package/dist/stories/components/VerifiedImage.stories.d.ts +0 -28
  27. package/dist/stories/components/form/PhoneInput.stories.d.ts +0 -16
  28. package/dist/stories/hooks/useCopyToClipboard.stories.d.ts +0 -14
  29. 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
+ };
@@ -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.1",
3
+ "version": "1.3.0",
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
  },
@@ -98,8 +98,8 @@
98
98
  "@fontsource/lato": "^5.0.21",
99
99
  "@fontsource/material-icons": "^5.0.18",
100
100
  "@mona-health/react-input-mask": "^3.0.3",
101
- "@mui/icons-material": ">= ^5",
102
- "@mui/material": ">= ^5",
101
+ "@mui/icons-material": "^5 || ^6",
102
+ "@mui/material": "^5 || ^6",
103
103
  "libphonenumber-js": "^1.11.11",
104
104
  "qrcode": "^1.5.4",
105
105
  "react": "^18",
@@ -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,5 +1,6 @@
1
1
  import { createTheme } from '@mui/material';
2
- import * as colors from './colors';
2
+ import { colors } from './colors';
3
+ import { typography } from './typography';
3
4
 
4
5
  declare module '@mui/material/styles' {
5
6
  // custom palette
@@ -32,8 +33,18 @@ interface ThemeOptions {
32
33
 
33
34
  export const theme = ({ primaryFontFace }: ThemeOptions) =>
34
35
  createTheme({
36
+ breakpoints: {
37
+ values: {
38
+ xs: 0,
39
+ sm: 600,
40
+ md: 900,
41
+ lg: 1200,
42
+ xl: 1536,
43
+ },
44
+ },
35
45
  typography: {
36
46
  fontFamily: primaryFontFace.style.fontFamily,
47
+ ...typography,
37
48
  },
38
49
  palette: {
39
50
  text: {
@@ -205,5 +216,11 @@ export const theme = ({ primaryFontFace }: ThemeOptions) =>
205
216
  },
206
217
  },
207
218
  },
219
+ MuiTextField: {
220
+ defaultProps: {
221
+ variant: 'outlined',
222
+ size: 'small',
223
+ },
224
+ },
208
225
  },
209
226
  });
@@ -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;
@@ -1,41 +0,0 @@
1
- import { StoryObj } from '@storybook/react';
2
- import { QRCodeDisplay } from '../../components';
3
- declare const meta: {
4
- title: string;
5
- component: typeof QRCodeDisplay;
6
- render: (args: any) => 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
- asset: {
18
- type: "string";
19
- description: string;
20
- };
21
- data: {
22
- type: "string";
23
- description: string;
24
- };
25
- svgSize: {
26
- type: "number";
27
- description: string;
28
- };
29
- logoSize: {
30
- type: "number";
31
- description: string;
32
- };
33
- fill: {
34
- type: "string";
35
- description: string;
36
- };
37
- };
38
- };
39
- export default meta;
40
- type Story = StoryObj<typeof meta>;
41
- export declare const Default: Story;
@@ -1,44 +0,0 @@
1
- import { StoryObj } from '@storybook/react';
2
- import { TextField } from '../../components/TextField';
3
- declare const meta: {
4
- title: string;
5
- component: typeof TextField;
6
- parameters: {
7
- layout: string;
8
- };
9
- tags: string[];
10
- argTypes: {
11
- variant: {
12
- description: string;
13
- type: {
14
- name: "enum";
15
- value: string[];
16
- };
17
- table: {
18
- defaultValue: {
19
- summary: string;
20
- };
21
- };
22
- };
23
- size: {
24
- description: string;
25
- type: {
26
- name: "enum";
27
- value: string[];
28
- };
29
- table: {
30
- defaultValue: {
31
- summary: string;
32
- };
33
- };
34
- };
35
- };
36
- args: {
37
- size: "medium";
38
- variant: "standard";
39
- };
40
- };
41
- export default meta;
42
- type Story = StoryObj<typeof meta>;
43
- export declare const Outlined: Story;
44
- export declare const OutlinedFixedLabel: Story;
@@ -1,54 +0,0 @@
1
- import { StoryObj } from '@storybook/react';
2
- import { Typography } from '../../components/Typography';
3
- declare const meta: {
4
- title: string;
5
- component: typeof Typography;
6
- parameters: {
7
- layout: string;
8
- };
9
- tags: string[];
10
- argTypes: {
11
- align: {
12
- options: string[];
13
- control: {
14
- type: "radio";
15
- };
16
- description: string;
17
- table: {
18
- defaultValue: {
19
- summary: string;
20
- };
21
- };
22
- };
23
- variant: {
24
- options: string[];
25
- control: {
26
- type: "radio";
27
- };
28
- description: string;
29
- table: {
30
- defaultValue: {
31
- summary: string;
32
- };
33
- };
34
- };
35
- children: {
36
- description: string;
37
- type: "string";
38
- };
39
- };
40
- };
41
- export default meta;
42
- type Story = StoryObj<typeof meta>;
43
- export declare const Heading1: Story;
44
- export declare const Heading2: Story;
45
- export declare const Heading3: Story;
46
- export declare const Heading4: Story;
47
- export declare const Heading5: Story;
48
- export declare const Heading6: Story;
49
- export declare const Subtitle1: Story;
50
- export declare const Subtitle2: Story;
51
- export declare const Body1: Story;
52
- export declare const Body2: Story;
53
- export declare const Button: Story;
54
- export declare const Overline: Story;
@@ -1,28 +0,0 @@
1
- import { VerifiedImage } from '../../components/verified/VerifiedImage';
2
- declare const _default: {
3
- title: string;
4
- component: typeof VerifiedImage;
5
- parameters: {
6
- layout: string;
7
- };
8
- argTypes: {
9
- themeLight: {
10
- control: {
11
- type: string;
12
- };
13
- };
14
- themeMain: {
15
- control: {
16
- type: string;
17
- };
18
- };
19
- themeDark: {
20
- control: {
21
- type: string;
22
- };
23
- };
24
- };
25
- tags: string[];
26
- };
27
- export default _default;
28
- export declare const Default: any;
@@ -1,16 +0,0 @@
1
- import { StoryObj } from '@storybook/react';
2
- import { PhoneInput } from '../../../components/form/PhoneInput';
3
- declare const meta: {
4
- title: string;
5
- component: typeof PhoneInput;
6
- parameters: {
7
- layout: string;
8
- };
9
- tags: string[];
10
- args: {
11
- shouldHaveClearButton: true;
12
- };
13
- };
14
- export default meta;
15
- type Story = StoryObj<typeof meta>;
16
- export declare const Default: Story;