@zesty-io/material 0.2.0 → 0.2.3

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.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
3
- export interface FieldTypeDateProps extends Omit<DatePickerProps<Date, Date>, 'renderInput'> {
2
+ import { DesktopDatePickerProps } from '@mui/x-date-pickers';
3
+ export interface FieldTypeDateProps extends Omit<DesktopDatePickerProps<Date, Date>, 'renderInput'> {
4
4
  helperText?: string;
5
5
  error?: boolean;
6
6
  required?: boolean;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
3
3
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
4
- import { DatePicker } from '@mui/x-date-pickers/DatePicker';
4
+ import { DesktopDatePicker } from '@mui/x-date-pickers';
5
5
  import { FormControl, FormLabel, TextField } from '@mui/material';
6
6
  ;
7
7
  const FieldTypeDate = ({ label, helperText, error, required, ...props }) => {
8
- return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DatePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error }), ...props }) })] }));
8
+ return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DesktopDatePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error, size: "small" }), ...props }) })] }));
9
9
  };
10
10
  export default FieldTypeDate;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';
3
- export interface FieldTypeDateTimeProps extends Omit<DateTimePickerProps<Date, Date>, 'renderInput'> {
2
+ import { DesktopDateTimePickerProps } from '@mui/x-date-pickers';
3
+ export interface FieldTypeDateTimeProps extends Omit<DesktopDateTimePickerProps<Date, Date>, 'renderInput'> {
4
4
  helperText?: string;
5
5
  error?: boolean;
6
6
  required?: boolean;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
3
3
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
4
- import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
4
+ import { DesktopDateTimePicker } from '@mui/x-date-pickers';
5
5
  import { TextField, FormControl, FormLabel } from '@mui/material';
6
6
  ;
7
7
  const FieldTypeDateTime = ({ label, helperText, error, required, ...props }) => {
8
- return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DateTimePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error }), ...props }) })] }));
8
+ return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DesktopDateTimePicker, { "data-testid": "zds-date-time-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error, size: "small" }), ...props }) })] }));
9
9
  };
10
10
  export default FieldTypeDateTime;
@@ -3,5 +3,5 @@ import { OutlinedTextFieldProps } from '@mui/material/TextField';
3
3
  export interface FieldTypeSortProps extends Omit<OutlinedTextFieldProps, 'variant'> {
4
4
  value: string;
5
5
  }
6
- declare const FieldTypeSort: ({ label, value, InputProps, required, ...props }: FieldTypeSortProps) => JSX.Element;
6
+ declare const FieldTypeSort: ({ label, value, InputProps, required, onChange, ...props }: FieldTypeSortProps) => JSX.Element;
7
7
  export default FieldTypeSort;
@@ -3,17 +3,29 @@ import MuiTextField from '@mui/material/TextField';
3
3
  import { Button, FormControl, FormLabel, InputAdornment } from '@mui/material';
4
4
  import AddIcon from '@mui/icons-material/Add';
5
5
  import RemoveIcon from '@mui/icons-material/Remove';
6
- const FieldTypeSort = ({ label, value, InputProps, required, ...props }) => {
7
- return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'number', value: value, InputProps: {
6
+ const FieldTypeSort = ({ label, value, InputProps, required, onChange, ...props }) => {
7
+ return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'number', value: value, onChange: onChange, InputProps: {
8
8
  startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(Button, { size: "small", variant: "contained", onClick: (e) => {
9
- // References input via event in order to modify its value
9
+ e.stopPropagation();
10
+ // References input via click event in order to obtain its value
10
11
  const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1];
11
- input.value = String(+input.value - 1);
12
+ const newValue = String(+input.value - 1);
13
+ // Updates internal input value in case component is not controlled
14
+ input.value = newValue;
15
+ // Mocks an event change
16
+ const event = { target: { value: newValue } };
17
+ onChange && onChange(event);
12
18
  }, children: _jsx(RemoveIcon, { fontSize: 'small' }) }) })),
13
19
  endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(Button, { size: "small", variant: "contained", onClick: (e) => {
14
- // References input via event in order to modify its value
20
+ e.stopPropagation();
21
+ // References input via click event in order to obtain its value
15
22
  const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1];
16
- input.value = String(+input.value + 1);
23
+ const newValue = String(+input.value + 1);
24
+ // Updates internal input value in case component is not controlled
25
+ input.value = newValue;
26
+ // Mocks an event change
27
+ const event = { target: { value: newValue } };
28
+ onChange && onChange(event);
17
29
  }, children: _jsx(AddIcon, { fontSize: 'small' }) }) })),
18
30
  // Spread props at the end to allow Input prop overrides
19
31
  ...InputProps,
@@ -1,13 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef } from 'react';
2
+ import { useState } from 'react';
3
3
  import MuiTextField from '@mui/material/TextField';
4
4
  import { FormControl, FormLabel, Box } from '@mui/material';
5
5
  const FieldTypeUrl = ({ label, maxLength = 2000, value, helperText, required, inputProps, ...props }) => {
6
- const inputRef = useRef(null);
6
+ // Use state to hold input reference to re-render once ref changes in case error needs to be shown on mount
7
+ const [inputRef, setInputRef] = useState();
7
8
  return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsxs(FormLabel, { sx: { display: 'flex', justifyContent: 'space-between', '& .MuiFormLabel-asterisk': { order: 2 } }, children: [_jsx(Box, { sx: { order: 1 }, children: label }), _jsxs(Box, { sx: { order: 3, flex: 1, textAlign: 'right' }, children: [value?.length, "/", maxLength] })] }), _jsx(MuiTextField, { size: "small", type: 'url', variant: 'outlined', value: value, inputProps: {
8
- ref: inputRef,
9
+ ref: (inputRef) => setInputRef(inputRef),
9
10
  // Spread props at the end to allow inputProps prop overrides
10
11
  ...inputProps,
11
- }, error: (value && !inputRef.current?.validity.valid) || value?.length > maxLength, helperText: value?.length > maxLength ? 'Your input is over the specified limit' : (value && !inputRef.current?.validity.valid) ? 'Your input is not a valid url' : helperText, ...props })] }));
12
+ }, error: (value && !inputRef?.validity.valid) || value?.length > maxLength, helperText: value?.length > maxLength ? 'Your input is over the specified limit' : (value && !inputRef?.validity.valid) ? 'Your input is not a valid url' : helperText, ...props })] }));
12
13
  };
13
14
  export default FieldTypeUrl;
@@ -0,0 +1,3 @@
1
+ import { Theme } from '@mui/material/styles';
2
+ declare let theme: Theme;
3
+ export default theme;
@@ -0,0 +1,81 @@
1
+ import palette from './palette';
2
+ import typography from './typography';
3
+ import { createTheme } from '@mui/material/styles';
4
+ let theme = createTheme({
5
+ palette,
6
+ typography,
7
+ });
8
+ theme = createTheme(theme, {
9
+ components: {
10
+ MuiAccordionSummary: {
11
+ styleOverrides: {
12
+ root: {
13
+ backgroundColor: '#e4e9f1',
14
+ },
15
+ },
16
+ },
17
+ MuiButton: {
18
+ styleOverrides: {
19
+ root: {
20
+ minWidth: 'auto',
21
+ },
22
+ },
23
+ },
24
+ MuiTooltip: {
25
+ styleOverrides: {
26
+ tooltip: {
27
+ color: theme.palette.primary.contrastText,
28
+ backgroundColor: theme.palette.primary.main,
29
+ fontSize: '14px',
30
+ lineHeight: '20px',
31
+ },
32
+ arrow: {
33
+ color: theme.palette.primary.main,
34
+ },
35
+ },
36
+ },
37
+ MuiInputBase: {
38
+ styleOverrides: {
39
+ root: {
40
+ backgroundColor: theme.palette.primary.contrastText,
41
+ },
42
+ },
43
+ },
44
+ MuiFormLabel: {
45
+ styleOverrides: {
46
+ root: {
47
+ color: theme.palette.primary.dark,
48
+ },
49
+ asterisk: {
50
+ color: theme.palette.error.main,
51
+ },
52
+ },
53
+ },
54
+ MuiCard: {
55
+ styleOverrides: {
56
+ root: {
57
+ overflow: 'visible',
58
+ },
59
+ },
60
+ },
61
+ MuiCardHeader: {
62
+ styleOverrides: {
63
+ root: {
64
+ backgroundColor: '#e4e9f1',
65
+ },
66
+ },
67
+ },
68
+ MuiToggleButton: {
69
+ styleOverrides: {
70
+ root: ({ ownerState, theme }) => ({
71
+ backgroundColor: `${theme.palette[ownerState.color].contrastText} !important`,
72
+ ...(ownerState.selected && {
73
+ color: `${theme.palette[ownerState.color].contrastText} !important`,
74
+ backgroundColor: `${theme.palette[ownerState.color].main} !important`,
75
+ }),
76
+ }),
77
+ },
78
+ },
79
+ },
80
+ });
81
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { PaletteOptions } from '@mui/material/styles';
2
+ declare const palette: PaletteOptions;
3
+ export default palette;
@@ -0,0 +1,23 @@
1
+ const palette = {
2
+ primary: {
3
+ main: '#404759',
4
+ contrastText: '#ffffff',
5
+ },
6
+ secondary: {
7
+ main: '#497edf',
8
+ contrastText: '#ffffff',
9
+ },
10
+ success: {
11
+ main: '#75bf25',
12
+ contrastText: '#ffffff',
13
+ },
14
+ warning: {
15
+ main: '#f17829',
16
+ contrastText: '#ffffff',
17
+ },
18
+ error: {
19
+ main: '#e53c05',
20
+ contrastText: '#ffffff',
21
+ },
22
+ };
23
+ export default palette;
@@ -0,0 +1,3 @@
1
+ import { TypographyVariantsOptions } from '@mui/material/styles';
2
+ declare const typography: TypographyVariantsOptions;
3
+ export default typography;
@@ -0,0 +1,4 @@
1
+ const typography = {
2
+ fontFamily: "'Mulish'",
3
+ };
4
+ export default typography;
package/es/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as legacyTheme } from './LegacyTheme';
1
2
  export { default as theme } from './theme';
2
3
  export { default as FieldTypeText } from './FieldTypeText';
3
4
  export { default as FieldTypeSort } from './FieldTypeSort';
package/es/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as legacyTheme } from './LegacyTheme';
1
2
  export { default as theme } from './theme';
2
3
  export { default as FieldTypeText } from './FieldTypeText';
3
4
  export { default as FieldTypeSort } from './FieldTypeSort';
package/es/theme/index.js CHANGED
@@ -7,66 +7,42 @@ let theme = createTheme({
7
7
  });
8
8
  theme = createTheme(theme, {
9
9
  components: {
10
- MuiButton: {
11
- styleOverrides: {
12
- root: {
13
- minWidth: 'auto',
14
- },
15
- },
16
- },
17
- MuiTooltip: {
18
- styleOverrides: {
19
- tooltip: {
20
- color: theme.palette.primary.contrastText,
21
- backgroundColor: theme.palette.primary.main,
22
- fontSize: '14px',
23
- lineHeight: '20px',
24
- },
25
- arrow: {
26
- color: theme.palette.primary.main,
27
- },
28
- },
29
- },
30
- MuiInputBase: {
10
+ MuiFormLabel: {
31
11
  styleOverrides: {
32
12
  root: {
33
- backgroundColor: theme.palette.primary.contrastText,
13
+ ...theme.typography.body2,
34
14
  },
35
15
  },
36
16
  },
37
- MuiFormLabel: {
17
+ MuiTab: {
38
18
  styleOverrides: {
39
19
  root: {
40
- color: theme.palette.primary.dark,
41
- },
42
- asterisk: {
43
- color: theme.palette.error.main,
20
+ borderBottom: 2,
21
+ borderColor: theme.palette.grey[100],
22
+ borderStyle: "solid",
44
23
  },
45
24
  },
46
25
  },
47
- MuiCard: {
26
+ MuiCardHeader: {
48
27
  styleOverrides: {
49
28
  root: {
50
- overflow: 'visible',
29
+ padding: "16px 16px 0px",
51
30
  },
52
31
  },
53
32
  },
54
- MuiCardHeader: {
33
+ MuiCardContent: {
55
34
  styleOverrides: {
56
35
  root: {
57
- backgroundColor: '#e4e9f1',
36
+ padding: "8px 16px 16px",
37
+ ":last-child": {
38
+ paddingBottom: "16px",
39
+ },
58
40
  },
59
41
  },
60
42
  },
61
- MuiToggleButton: {
62
- styleOverrides: {
63
- root: ({ ownerState, theme }) => ({
64
- backgroundColor: `${theme.palette[ownerState.color].contrastText} !important`,
65
- ...(ownerState.selected && {
66
- color: `${theme.palette[ownerState.color].contrastText} !important`,
67
- backgroundColor: `${theme.palette[ownerState.color].main} !important`,
68
- }),
69
- }),
43
+ MuiButton: {
44
+ defaultProps: {
45
+ disableElevation: true,
70
46
  },
71
47
  },
72
48
  },
@@ -1,3 +1,15 @@
1
+ import { Color } from '@mui/material';
1
2
  import { PaletteOptions } from '@mui/material/styles';
3
+ declare module '@mui/material/styles' {
4
+ interface PaletteOptions {
5
+ red?: Partial<Color>;
6
+ deepPurple?: Partial<Color>;
7
+ deepOrange?: Partial<Color>;
8
+ pink?: Partial<Color>;
9
+ blue?: Partial<Color>;
10
+ green?: Partial<Color>;
11
+ purple?: Partial<Color>;
12
+ }
13
+ }
2
14
  declare const palette: PaletteOptions;
3
15
  export default palette;
@@ -1,36 +1,136 @@
1
1
  const palette = {
2
2
  primary: {
3
- main: '#404759',
4
- contrastText: '#ffffff',
5
- },
6
- secondary: {
7
- main: '#497edf',
8
- contrastText: '#ffffff',
3
+ main: "#FF5D03",
4
+ dark: "#EC4A0A",
5
+ light: "#FD853A",
9
6
  },
10
7
  success: {
11
- main: '#75bf25',
12
- contrastText: '#ffffff',
8
+ main: "#12B76A",
9
+ dark: "#027A48",
10
+ light: "#D1FADF",
13
11
  },
14
12
  warning: {
15
- main: '#f17829',
16
- contrastText: '#ffffff',
13
+ main: "#F79009",
14
+ dark: "B54708",
15
+ light: "#FEF0C7",
17
16
  },
18
17
  error: {
19
- main: '#e53c05',
20
- contrastText: '#ffffff',
21
- },
22
- // action: {
23
- // active: 'rgba(0,0,0,54)',
24
- // hover: 'rgba(0,0,0,0.04)',
25
- // hoverOpacity: 0.04,
26
- // selected: 'rgba(0,0,0,0.08)',
27
- // selectedOpacity: 0.08,
28
- // disabled: 'rgba(26, 32, 44, 0.4)',
29
- // disabledBackground: 'rgba(26, 32, 44, 0.12)',
30
- // disabledOpacity: 0.4,
31
- // focus: 'rgba(0,0,0,0.12)',
32
- // focusOpacity: 0.12,
33
- // activatedOpacity: 0.12,
34
- // },
18
+ main: "#F04438",
19
+ dark: "#B42318",
20
+ light: "#FECDCA",
21
+ },
22
+ info: {
23
+ main: "#0BA5EC",
24
+ dark: "#026AA2",
25
+ light: "#7CD4FD",
26
+ },
27
+ text: {
28
+ primary: "#101828",
29
+ secondary: "#475467",
30
+ },
31
+ grey: {
32
+ 50: "#F9FAFB",
33
+ 100: "#F2F4F7",
34
+ 200: "#E4E7EC",
35
+ 300: "#D0D5DD",
36
+ 400: "#98A2B3",
37
+ 500: "#667085",
38
+ 600: "#475467",
39
+ 700: "#344054",
40
+ 800: "#1D2939",
41
+ 900: "#101828",
42
+ },
43
+ deepPurple: {
44
+ 50: '#F8F9FC',
45
+ 100: '#EAECF5',
46
+ 200: '#C8CCE5',
47
+ 300: '#9EA5D1',
48
+ 400: "#4E5BA6",
49
+ 500: '#4E5BA6',
50
+ 600: '#3E4784',
51
+ 700: '#363F72',
52
+ 800: '#293056',
53
+ 900: '#101323'
54
+ },
55
+ deepOrange: {
56
+ 50: "#FFF6ED",
57
+ 100: "#FFEAD5",
58
+ 200: "#FDDCAB",
59
+ 300: "#FEB273",
60
+ 400: "#FD853A",
61
+ 500: "#FF5C08",
62
+ 600: "#EC4A0A",
63
+ 700: "#C4320A",
64
+ 800: "#9C2A10",
65
+ 900: "#7E2410",
66
+ },
67
+ red: {
68
+ 50: '#FEF3F2',
69
+ 100: '#FEE4E2',
70
+ 200: '#FECDCA',
71
+ 300: '#FDA29B',
72
+ 400: '#F97066',
73
+ 500: '#F04438',
74
+ 600: '#D92D20',
75
+ 700: '#B42318',
76
+ 800: '#912018',
77
+ 900: '#7A271A',
78
+ },
79
+ pink: {
80
+ 50: '#FDF2FA',
81
+ 100: '#FCE7F6',
82
+ 200: '#FCCEEE',
83
+ 300: '#FAA7E0',
84
+ 400: "#F670C7",
85
+ 500: '#EE46BC',
86
+ 600: '#DD2590',
87
+ 700: '#C11574',
88
+ 800: '#9E165F',
89
+ 900: '#851651',
90
+ },
91
+ blue: {
92
+ 50: '#F0F9FF',
93
+ 100: "#E0F2FE",
94
+ 200: '#B9E6FE',
95
+ 300: '#7CD4FD',
96
+ 400: "#36BFFA",
97
+ 500: '#0BA5EC',
98
+ 600: '#0086C9',
99
+ 700: '#026AA2',
100
+ 800: '#065986',
101
+ 900: '#0B4A6F',
102
+ },
103
+ green: {
104
+ 50: '#ECFDF3',
105
+ 100: "#D1FADF",
106
+ 200: '#A6F4C5',
107
+ 300: '#6CE9A6',
108
+ 400: "#32D583",
109
+ 500: '#12B76A',
110
+ 600: '#039855',
111
+ 700: '#027A48',
112
+ 800: '#05603A',
113
+ 900: '#054F31',
114
+ },
115
+ purple: {
116
+ 50: '#F3E5F5',
117
+ 100: '#E1BEE7',
118
+ 200: '#CE93D8',
119
+ 300: '#BA68C8',
120
+ 400: '#AB47BC',
121
+ 500: '#9C27B0',
122
+ 600: '#8E24AA',
123
+ 700: '#7B1FA2',
124
+ 800: '#6A1B9A',
125
+ 900: '#4A148C',
126
+ },
127
+ action: {
128
+ active: "rgba(16, 24, 40, 0.40)",
129
+ hover: "rgba(16, 24, 40, 0.04)",
130
+ selected: "rgba(16, 24, 40, 0.08)",
131
+ disabled: "rgba(16, 24, 40, 0.26)",
132
+ disabledBackground: "rgba(16, 24, 40, 0.12)",
133
+ focus: "rgba(16, 24, 40, 0.12)",
134
+ }
35
135
  };
36
136
  export default palette;
@@ -1,3 +1,9 @@
1
1
  import { TypographyVariantsOptions } from '@mui/material/styles';
2
+ import { TypographyStyleOptions } from '@mui/material/styles/createTypography';
3
+ declare module '@mui/material/styles' {
4
+ interface TypographyVariantsOptions {
5
+ body3?: TypographyStyleOptions;
6
+ }
7
+ }
2
8
  declare const typography: TypographyVariantsOptions;
3
9
  export default typography;
@@ -1,4 +1,57 @@
1
1
  const typography = {
2
2
  fontFamily: "'Mulish'",
3
+ h1: {
4
+ fontSize: "36px",
5
+ lineHeight: "44px",
6
+ },
7
+ h2: {
8
+ fontSize: "32px",
9
+ lineHeight: "40px",
10
+ },
11
+ h3: {
12
+ fontSize: "28px",
13
+ lineHeight: "36px",
14
+ },
15
+ h4: {
16
+ fontSize: "24px",
17
+ lineHeight: "32px",
18
+ },
19
+ h5: {
20
+ fontSize: "20px",
21
+ lineHeight: "28px",
22
+ },
23
+ h6: {
24
+ fontSize: "16px",
25
+ lineHeight: "22px",
26
+ },
27
+ body1: {
28
+ fontSize: '16px',
29
+ lineHeight: '24px',
30
+ },
31
+ body2: {
32
+ fontSize: '14px',
33
+ lineHeight: '20px',
34
+ },
35
+ body3: {
36
+ fontSize: '12px',
37
+ lineHeight: '18px',
38
+ letterSpacing: '0.15px',
39
+ },
40
+ subtitle1: {
41
+ fontSize: '16px',
42
+ lineHeight: "28px",
43
+ },
44
+ subtitle2: {
45
+ fontSize: '14px',
46
+ lineHeight: "22px",
47
+ },
48
+ caption: {
49
+ fontSize: '20px',
50
+ lineHeight: "20px",
51
+ },
52
+ overline: {
53
+ fontSize: "12px",
54
+ letterSpacing: "1px",
55
+ },
3
56
  };
4
57
  export default typography;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zesty-io/material",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "Contains custom components which are in addition to the @mui design-system",
5
5
  "author": "Zesty.io",
6
6
  "license": "MIT",
@@ -1,9 +1,9 @@
1
1
  import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
2
2
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
3
- import { DatePicker, DatePickerProps} from '@mui/x-date-pickers/DatePicker';
3
+ import { DesktopDatePicker, DesktopDatePickerProps } from '@mui/x-date-pickers';
4
4
  import { FormControl, FormLabel, TextField } from '@mui/material';
5
5
 
6
- export interface FieldTypeDateProps extends Omit<DatePickerProps<Date, Date>, 'renderInput'> {
6
+ export interface FieldTypeDateProps extends Omit<DesktopDatePickerProps<Date, Date>, 'renderInput'> {
7
7
  helperText?: string;
8
8
  error?: boolean;
9
9
  required?: boolean;
@@ -14,13 +14,14 @@ const FieldTypeDate = ({label, helperText, error, required, ...props}: FieldType
14
14
  <FormControl fullWidth required={required}>
15
15
  <FormLabel>{label}</FormLabel>
16
16
  <LocalizationProvider dateAdapter={AdapterDateFns}>
17
- <DatePicker
17
+ <DesktopDatePicker
18
18
  data-testid="zds-date-picker"
19
19
  renderInput={(params) =>
20
20
  <TextField
21
21
  {...params}
22
22
  helperText={helperText}
23
23
  error={error}
24
+ size="small"
24
25
  />
25
26
  }
26
27
  // Spread props at the end to allow prop overrides
@@ -1,9 +1,9 @@
1
1
  import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
2
2
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
3
- import { DateTimePicker, DateTimePickerProps} from '@mui/x-date-pickers/DateTimePicker';
3
+ import { DesktopDateTimePicker, DesktopDateTimePickerProps } from '@mui/x-date-pickers';
4
4
  import { TextField, FormControl, FormLabel } from '@mui/material';
5
5
 
6
- export interface FieldTypeDateTimeProps extends Omit<DateTimePickerProps<Date, Date>, 'renderInput'> {
6
+ export interface FieldTypeDateTimeProps extends Omit<DesktopDateTimePickerProps<Date, Date>, 'renderInput'> {
7
7
  helperText?: string;
8
8
  error?: boolean;
9
9
  required?: boolean;
@@ -14,14 +14,15 @@ const FieldTypeDateTime = ({label, helperText, error, required, ...props}: Field
14
14
  <FormControl fullWidth required={required}>
15
15
  <FormLabel>{label}</FormLabel>
16
16
  <LocalizationProvider dateAdapter={AdapterDateFns}>
17
- <DateTimePicker
18
- data-testid="zds-date-picker"
17
+ <DesktopDateTimePicker
18
+ data-testid="zds-date-time-picker"
19
19
  renderInput={(params) =>
20
20
  <TextField
21
21
 
22
22
  {...params}
23
23
  helperText={helperText}
24
24
  error={error}
25
+ size="small"
25
26
  />
26
27
  }
27
28
  // Spread props at the end to allow prop overrides
@@ -1,3 +1,4 @@
1
+ import { ChangeEvent } from 'react';
1
2
  import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
2
3
  import { Button, FormControl, FormLabel, InputAdornment } from '@mui/material';
3
4
  import AddIcon from '@mui/icons-material/Add';
@@ -7,7 +8,7 @@ export interface FieldTypeSortProps extends Omit<OutlinedTextFieldProps, 'varian
7
8
  value: string;
8
9
  }
9
10
 
10
- const FieldTypeSort = ({label, value, InputProps, required, ...props }: FieldTypeSortProps) => {
11
+ const FieldTypeSort = ({label, value, InputProps, required, onChange, ...props }: FieldTypeSortProps) => {
11
12
  return (
12
13
  <FormControl fullWidth required={required}>
13
14
  <FormLabel>{label}</FormLabel>
@@ -16,6 +17,7 @@ const FieldTypeSort = ({label, value, InputProps, required, ...props }: FieldTyp
16
17
  variant='outlined'
17
18
  type='number'
18
19
  value={value}
20
+ onChange={onChange}
19
21
  InputProps={{
20
22
  startAdornment: (
21
23
  <InputAdornment position="start">
@@ -23,9 +25,15 @@ const FieldTypeSort = ({label, value, InputProps, required, ...props }: FieldTyp
23
25
  size="small"
24
26
  variant="contained"
25
27
  onClick={(e) => {
26
- // References input via event in order to modify its value
28
+ e.stopPropagation();
29
+ // References input via click event in order to obtain its value
27
30
  const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1] as HTMLInputElement;
28
- input.value = String(+input.value - 1)
31
+ const newValue = String(+input.value - 1)
32
+ // Updates internal input value in case component is not controlled
33
+ input.value = newValue
34
+ // Mocks an event change
35
+ const event = {target: {value: newValue}}
36
+ onChange && onChange(event as ChangeEvent<HTMLTextAreaElement | HTMLInputElement>);
29
37
  }}><RemoveIcon fontSize='small' />
30
38
  </Button>
31
39
  </InputAdornment>
@@ -36,9 +44,15 @@ const FieldTypeSort = ({label, value, InputProps, required, ...props }: FieldTyp
36
44
  size="small"
37
45
  variant="contained"
38
46
  onClick={(e) => {
39
- // References input via event in order to modify its value
47
+ e.stopPropagation();
48
+ // References input via click event in order to obtain its value
40
49
  const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1] as HTMLInputElement;
41
- input.value = String(+input.value + 1)
50
+ const newValue = String(+input.value + 1)
51
+ // Updates internal input value in case component is not controlled
52
+ input.value = newValue
53
+ // Mocks an event change
54
+ const event = {target: {value: newValue}}
55
+ onChange && onChange(event as ChangeEvent<HTMLTextAreaElement | HTMLInputElement>);
42
56
  }}><AddIcon fontSize='small' />
43
57
  </Button>
44
58
  </InputAdornment>
@@ -1,4 +1,4 @@
1
- import { useRef } from 'react';
1
+ import { useState } from 'react';
2
2
  import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
3
3
  import { FormControl, FormLabel, Box } from '@mui/material';
4
4
 
@@ -12,7 +12,8 @@ export interface FieldTypeUrlProps extends Omit<OutlinedTextFieldProps, 'variant
12
12
  }
13
13
 
14
14
  const FieldTypeUrl = ({label, maxLength = 2000, value, helperText, required, inputProps, ...props }: FieldTypeUrlProps) => {
15
- const inputRef = useRef<HTMLInputElement>(null);
15
+ // Use state to hold input reference to re-render once ref changes in case error needs to be shown on mount
16
+ const [inputRef, setInputRef] = useState<HTMLInputElement>();
16
17
 
17
18
  return (
18
19
  <FormControl fullWidth required={required}>
@@ -27,12 +28,12 @@ const FieldTypeUrl = ({label, maxLength = 2000, value, helperText, required, inp
27
28
  variant='outlined'
28
29
  value={value}
29
30
  inputProps={{
30
- ref: inputRef,
31
+ ref: (inputRef: HTMLInputElement) => setInputRef(inputRef),
31
32
  // Spread props at the end to allow inputProps prop overrides
32
33
  ...inputProps,
33
34
  }}
34
- error={(value && !inputRef.current?.validity.valid) || value?.length > maxLength}
35
- helperText={value?.length > maxLength ? 'Your input is over the specified limit' : (value && !inputRef.current?.validity.valid) ? 'Your input is not a valid url' : helperText}
35
+ error={(value && !inputRef?.validity.valid) || value?.length > maxLength}
36
+ helperText={value?.length > maxLength ? 'Your input is over the specified limit' : (value && !inputRef?.validity.valid) ? 'Your input is not a valid url' : helperText}
36
37
  // Spread props at the end to allow prop overrides
37
38
  {...props}
38
39
  />
@@ -0,0 +1,88 @@
1
+ import palette from './palette';
2
+ import typography from './typography';
3
+ import { createTheme, Theme } from '@mui/material/styles';
4
+
5
+ let theme: Theme = createTheme({
6
+ palette,
7
+ typography,
8
+ });
9
+
10
+ theme = createTheme(theme, {
11
+ components: {
12
+ MuiAccordionSummary: {
13
+ styleOverrides: {
14
+ root: {
15
+ backgroundColor: '#e4e9f1',
16
+ },
17
+ },
18
+ },
19
+ MuiButton: {
20
+ styleOverrides: {
21
+ root: {
22
+ minWidth: 'auto',
23
+ },
24
+ },
25
+ },
26
+ MuiTooltip: {
27
+ styleOverrides: {
28
+ tooltip: {
29
+ color: theme.palette.primary.contrastText,
30
+ backgroundColor: theme.palette.primary.main,
31
+ fontSize: '14px',
32
+ lineHeight: '20px',
33
+ },
34
+ arrow: {
35
+ color: theme.palette.primary.main,
36
+ },
37
+ },
38
+ },
39
+ MuiInputBase: {
40
+ styleOverrides: {
41
+ root: {
42
+ backgroundColor: theme.palette.primary.contrastText,
43
+ },
44
+ },
45
+ },
46
+ MuiFormLabel: {
47
+ styleOverrides: {
48
+ root: {
49
+ color: theme.palette.primary.dark,
50
+ },
51
+ asterisk: {
52
+ color: theme.palette.error.main,
53
+ },
54
+ },
55
+ },
56
+ MuiCard: {
57
+ styleOverrides: {
58
+ root: {
59
+ overflow: 'visible',
60
+ },
61
+ },
62
+ },
63
+ MuiCardHeader: {
64
+ styleOverrides: {
65
+ root: {
66
+ backgroundColor: '#e4e9f1',
67
+ },
68
+ },
69
+ },
70
+ MuiToggleButton: {
71
+ styleOverrides: {
72
+ root: ({ ownerState, theme }: any) => ({
73
+ backgroundColor: `${
74
+ theme.palette[ownerState.color].contrastText
75
+ } !important`,
76
+ ...(ownerState.selected && {
77
+ color: `${theme.palette[ownerState.color].contrastText} !important`,
78
+ backgroundColor: `${
79
+ theme.palette[ownerState.color].main
80
+ } !important`,
81
+ }),
82
+ }),
83
+ },
84
+ },
85
+ },
86
+ });
87
+
88
+ export default theme;
@@ -0,0 +1,25 @@
1
+ import { PaletteOptions } from '@mui/material/styles';
2
+ const palette: PaletteOptions = {
3
+ primary: {
4
+ main: '#404759',
5
+ contrastText: '#ffffff',
6
+ },
7
+ secondary: {
8
+ main: '#497edf',
9
+ contrastText: '#ffffff',
10
+ },
11
+ success: {
12
+ main: '#75bf25',
13
+ contrastText: '#ffffff',
14
+ },
15
+ warning: {
16
+ main: '#f17829',
17
+ contrastText: '#ffffff',
18
+ },
19
+ error: {
20
+ main: '#e53c05',
21
+ contrastText: '#ffffff',
22
+ },
23
+ };
24
+
25
+ export default palette;
@@ -0,0 +1,7 @@
1
+ import { TypographyVariantsOptions } from '@mui/material/styles';
2
+
3
+ const typography: TypographyVariantsOptions = {
4
+ fontFamily: "'Mulish'",
5
+ };
6
+
7
+ export default typography;
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as legacyTheme } from './LegacyTheme';
1
2
  export { default as theme } from './theme';
2
3
  export { default as FieldTypeText } from './FieldTypeText';
3
4
  export { default as FieldTypeSort } from './FieldTypeSort';
@@ -9,70 +9,42 @@ let theme: Theme = createTheme({
9
9
 
10
10
  theme = createTheme(theme, {
11
11
  components: {
12
- MuiButton: {
13
- styleOverrides: {
14
- root: {
15
- minWidth: 'auto',
16
- },
17
- },
18
- },
19
- MuiTooltip: {
20
- styleOverrides: {
21
- tooltip: {
22
- color: theme.palette.primary.contrastText,
23
- backgroundColor: theme.palette.primary.main,
24
- fontSize: '14px',
25
- lineHeight: '20px',
26
- },
27
- arrow: {
28
- color: theme.palette.primary.main,
29
- },
30
- },
31
- },
32
- MuiInputBase: {
12
+ MuiFormLabel: {
33
13
  styleOverrides: {
34
14
  root: {
35
- backgroundColor: theme.palette.primary.contrastText,
15
+ ...theme.typography.body2,
36
16
  },
37
17
  },
38
18
  },
39
- MuiFormLabel: {
19
+ MuiTab: {
40
20
  styleOverrides: {
41
21
  root: {
42
- color: theme.palette.primary.dark,
43
- },
44
- asterisk: {
45
- color: theme.palette.error.main,
22
+ borderBottom: 2,
23
+ borderColor: theme.palette.grey[100],
24
+ borderStyle: "solid",
46
25
  },
47
26
  },
48
27
  },
49
- MuiCard: {
28
+ MuiCardHeader: {
50
29
  styleOverrides: {
51
30
  root: {
52
- overflow: 'visible',
31
+ padding: "16px 16px 0px",
53
32
  },
54
33
  },
55
34
  },
56
- MuiCardHeader: {
35
+ MuiCardContent: {
57
36
  styleOverrides: {
58
37
  root: {
59
- backgroundColor: '#e4e9f1',
38
+ padding: "8px 16px 16px",
39
+ ":last-child": {
40
+ paddingBottom: "16px",
41
+ },
60
42
  },
61
43
  },
62
44
  },
63
- MuiToggleButton: {
64
- styleOverrides: {
65
- root: ({ ownerState, theme }: any) => ({
66
- backgroundColor: `${
67
- theme.palette[ownerState.color].contrastText
68
- } !important`,
69
- ...(ownerState.selected && {
70
- color: `${theme.palette[ownerState.color].contrastText} !important`,
71
- backgroundColor: `${
72
- theme.palette[ownerState.color].main
73
- } !important`,
74
- }),
75
- }),
45
+ MuiButton: {
46
+ defaultProps: {
47
+ disableElevation: true,
76
48
  },
77
49
  },
78
50
  },
@@ -1,38 +1,153 @@
1
+ import { Color } from '@mui/material';
1
2
  import { PaletteOptions } from '@mui/material/styles';
3
+
4
+ // Module augmentation
5
+ declare module '@mui/material/styles' {
6
+ export interface PaletteOptions {
7
+ red?: Partial<Color>;
8
+ deepPurple?: Partial<Color>;
9
+ deepOrange?: Partial<Color>;
10
+ pink?: Partial<Color>;
11
+ blue?: Partial<Color>;
12
+ green?: Partial<Color>;
13
+ purple?: Partial<Color>;
14
+ }
15
+ }
16
+
2
17
  const palette: PaletteOptions = {
3
18
  primary: {
4
- main: '#404759',
5
- contrastText: '#ffffff',
6
- },
7
- secondary: {
8
- main: '#497edf',
9
- contrastText: '#ffffff',
19
+ main: "#FF5D03",
20
+ dark: "#EC4A0A",
21
+ light: "#FD853A",
10
22
  },
11
23
  success: {
12
- main: '#75bf25',
13
- contrastText: '#ffffff',
24
+ main: "#12B76A",
25
+ dark: "#027A48",
26
+ light: "#D1FADF",
14
27
  },
15
28
  warning: {
16
- main: '#f17829',
17
- contrastText: '#ffffff',
29
+ main: "#F79009",
30
+ dark: "B54708",
31
+ light: "#FEF0C7",
18
32
  },
19
33
  error: {
20
- main: '#e53c05',
21
- contrastText: '#ffffff',
22
- },
23
- // action: {
24
- // active: 'rgba(0,0,0,54)',
25
- // hover: 'rgba(0,0,0,0.04)',
26
- // hoverOpacity: 0.04,
27
- // selected: 'rgba(0,0,0,0.08)',
28
- // selectedOpacity: 0.08,
29
- // disabled: 'rgba(26, 32, 44, 0.4)',
30
- // disabledBackground: 'rgba(26, 32, 44, 0.12)',
31
- // disabledOpacity: 0.4,
32
- // focus: 'rgba(0,0,0,0.12)',
33
- // focusOpacity: 0.12,
34
- // activatedOpacity: 0.12,
35
- // },
34
+ main: "#F04438",
35
+ dark: "#B42318",
36
+ light: "#FECDCA",
37
+ },
38
+ info: {
39
+ main: "#0BA5EC",
40
+ dark: "#026AA2",
41
+ light: "#7CD4FD",
42
+ },
43
+ text: {
44
+ primary: "#101828",
45
+ secondary: "#475467",
46
+ },
47
+ grey: {
48
+ 50: "#F9FAFB",
49
+ 100: "#F2F4F7",
50
+ 200: "#E4E7EC",
51
+ 300: "#D0D5DD",
52
+ 400: "#98A2B3",
53
+ 500: "#667085",
54
+ 600: "#475467",
55
+ 700: "#344054",
56
+ 800: "#1D2939",
57
+ 900: "#101828",
58
+ },
59
+ deepPurple: {
60
+ 50: '#F8F9FC',
61
+ 100: '#EAECF5',
62
+ 200: '#C8CCE5',
63
+ 300: '#9EA5D1',
64
+ 400: "#4E5BA6",
65
+ 500: '#4E5BA6',
66
+ 600: '#3E4784',
67
+ 700: '#363F72',
68
+ 800: '#293056',
69
+ 900: '#101323'
70
+ },
71
+ deepOrange: {
72
+ 50: "#FFF6ED",
73
+ 100: "#FFEAD5",
74
+ 200: "#FDDCAB",
75
+ 300: "#FEB273",
76
+ 400: "#FD853A",
77
+ 500: "#FF5C08",
78
+ 600: "#EC4A0A",
79
+ 700: "#C4320A",
80
+ 800: "#9C2A10",
81
+ 900: "#7E2410",
82
+ },
83
+ red: {
84
+ 50: '#FEF3F2',
85
+ 100: '#FEE4E2',
86
+ 200: '#FECDCA',
87
+ 300: '#FDA29B',
88
+ 400: '#F97066',
89
+ 500: '#F04438',
90
+ 600: '#D92D20',
91
+ 700: '#B42318',
92
+ 800: '#912018',
93
+ 900: '#7A271A',
94
+ },
95
+ pink: {
96
+ 50: '#FDF2FA',
97
+ 100: '#FCE7F6',
98
+ 200: '#FCCEEE',
99
+ 300: '#FAA7E0',
100
+ 400: "#F670C7",
101
+ 500: '#EE46BC',
102
+ 600: '#DD2590',
103
+ 700: '#C11574',
104
+ 800: '#9E165F',
105
+ 900: '#851651',
106
+ },
107
+ blue: {
108
+ 50: '#F0F9FF',
109
+ 100: "#E0F2FE",
110
+ 200: '#B9E6FE',
111
+ 300: '#7CD4FD',
112
+ 400: "#36BFFA",
113
+ 500: '#0BA5EC',
114
+ 600: '#0086C9',
115
+ 700: '#026AA2',
116
+ 800: '#065986',
117
+ 900: '#0B4A6F',
118
+ },
119
+ green: {
120
+ 50: '#ECFDF3',
121
+ 100: "#D1FADF",
122
+ 200: '#A6F4C5',
123
+ 300: '#6CE9A6',
124
+ 400: "#32D583",
125
+ 500: '#12B76A',
126
+ 600: '#039855',
127
+ 700: '#027A48',
128
+ 800: '#05603A',
129
+ 900: '#054F31',
130
+ },
131
+ purple: {
132
+ 50: '#F3E5F5',
133
+ 100: '#E1BEE7',
134
+ 200: '#CE93D8',
135
+ 300: '#BA68C8',
136
+ 400: '#AB47BC',
137
+ 500: '#9C27B0',
138
+ 600: '#8E24AA',
139
+ 700: '#7B1FA2',
140
+ 800: '#6A1B9A',
141
+ 900: '#4A148C',
142
+ },
143
+ action: {
144
+ active: "rgba(16, 24, 40, 0.40)",
145
+ hover: "rgba(16, 24, 40, 0.04)",
146
+ selected: "rgba(16, 24, 40, 0.08)",
147
+ disabled: "rgba(16, 24, 40, 0.26)",
148
+ disabledBackground: "rgba(16, 24, 40, 0.12)",
149
+ focus: "rgba(16, 24, 40, 0.12)",
150
+ }
36
151
  };
37
152
 
38
153
  export default palette;
@@ -1,7 +1,69 @@
1
1
  import { TypographyVariantsOptions } from '@mui/material/styles';
2
+ import { TypographyStyleOptions } from '@mui/material/styles/createTypography';
3
+
4
+ // Module augmentation
5
+ declare module '@mui/material/styles' {
6
+ export interface TypographyVariantsOptions {
7
+ body3?: TypographyStyleOptions;
8
+ }
9
+ }
2
10
 
3
11
  const typography: TypographyVariantsOptions = {
4
12
  fontFamily: "'Mulish'",
13
+ h1: {
14
+ fontSize: "36px",
15
+ lineHeight: "44px",
16
+ },
17
+ h2: {
18
+ fontSize: "32px",
19
+ lineHeight: "40px",
20
+ },
21
+ h3: {
22
+ fontSize: "28px",
23
+ lineHeight: "36px",
24
+ },
25
+ h4: {
26
+ fontSize: "24px",
27
+ lineHeight: "32px",
28
+ },
29
+ h5: {
30
+ fontSize: "20px",
31
+ lineHeight: "28px",
32
+ },
33
+ h6: {
34
+ fontSize: "16px",
35
+ lineHeight: "22px",
36
+ },
37
+ body1: {
38
+ fontSize: '16px',
39
+ lineHeight : '24px',
40
+ },
41
+ body2: {
42
+ fontSize: '14px',
43
+ lineHeight : '20px',
44
+ },
45
+ body3: {
46
+ fontSize: '12px',
47
+ lineHeight: '18px',
48
+ letterSpacing: '0.15px',
49
+ },
50
+ subtitle1: {
51
+ fontSize: '16px',
52
+ lineHeight: "28px",
53
+ },
54
+ subtitle2: {
55
+ fontSize: '14px',
56
+ lineHeight: "22px",
57
+ },
58
+ caption: {
59
+ fontSize: '20px',
60
+ lineHeight: "20px",
61
+ },
62
+ overline: {
63
+ fontSize: "12px",
64
+ letterSpacing: "1px",
65
+ },
66
+
5
67
  };
6
68
 
7
69
  export default typography;
Binary file