@dartech/arsenal-ui 1.2.5 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dartech/arsenal-ui",
3
- "version": "1.2.5",
3
+ "version": "1.3.0",
4
4
  "author": "DAR",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
package/project.json CHANGED
@@ -51,11 +51,6 @@
51
51
  "@uiw/react-codemirror"
52
52
  ],
53
53
  "assets": [
54
- {
55
- "glob": "packages/arsenal-ui/src/assets/fonts/Euclid",
56
- "input": ".",
57
- "output": "./src/assets/fonts"
58
- },
59
54
  {
60
55
  "glob": "packages/arsenal-ui/src/assets/chevron_left.svg",
61
56
  "input": ".",
@@ -1,14 +1,4 @@
1
1
  import { createTheme } from '@mui/material/styles';
2
- import Euclid from '../assets/fonts/Euclid/EuclidCircularB-Regular.woff2';
3
- import EuclidItalic from '../assets/fonts/Euclid/EuclidCircularB-RegularItalic.woff2';
4
- import EuclidBold from '../assets/fonts/Euclid/EuclidCircularB-Bold.woff2';
5
- import EuclidBoldItalic from '../assets/fonts/Euclid/EuclidCircularB-BoldItalic.woff2';
6
- import EuclidLight from '../assets/fonts/Euclid/EuclidCircularB-Light.woff2';
7
- import EuclidLightItalic from '../assets/fonts/Euclid/EuclidCircularB-LightItalic.woff2';
8
- import EuclidMedium from '../assets/fonts/Euclid/EuclidCircularB-Medium.woff2';
9
- import EuclidMediumItalic from '../assets/fonts/Euclid/EuclidCircularB-MediumItalic.woff2';
10
- import EuclidSemiBold from '../assets/fonts/Euclid/EuclidCircularB-Semibold.woff2';
11
- import EuclidSemiBoldItalic from '../assets/fonts/Euclid/EuclidCircularB-SemiboldItalic.woff2';
12
2
 
13
3
  const baseThemeOptions = {
14
4
  spacing: 4,
@@ -24,20 +14,17 @@ const baseThemeOptions = {
24
14
  light: '#cbe8ee',
25
15
  },
26
16
  text: {
27
- disabled: '#A9A9B8'
28
-
17
+ disabled: '#A9A9B8',
29
18
  },
30
19
  success: {
31
20
  main: '#2DB77B',
32
21
  light: '#DBFCEE',
33
22
  },
34
23
  grey: {
35
- 700: '#101F2B'
36
- }
37
-
24
+ 700: '#101F2B',
25
+ },
38
26
  },
39
27
  typography: {
40
- fontFamily: 'Euclid,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
41
28
  fontSize: 14,
42
29
  h1: {
43
30
  fontWeight: 400,
@@ -47,82 +34,8 @@ const baseThemeOptions = {
47
34
  },
48
35
  h4: {
49
36
  fontWeight: 500,
50
- }
37
+ },
51
38
  },
52
- components: {
53
- MuiCssBaseline: {
54
- styleOverrides: `
55
- @font-face {
56
- font-family: 'Euclid';
57
- font-display: swap;
58
- src: url(${EuclidLight}) format('woff2');
59
- font-weight: 300;
60
- }
61
- @font-face {
62
- font-family: 'Euclid';
63
- font-display: swap;
64
- src: url(${EuclidLightItalic}) format('woff2');
65
- font-weight: 300;
66
- font-style: italic;
67
- }
68
- @font-face {
69
- font-family: 'Euclid';
70
- font-display: swap;
71
- src: url(${Euclid}) format('woff2');
72
- font-weight: 400;
73
- }
74
- @font-face {
75
- font-family: 'Euclid';
76
- font-display: swap;
77
- src: url(${EuclidItalic}) format('woff2');
78
- font-weight: 400;
79
- font-style: italic;
80
- }
81
- @font-face {
82
- font-family: 'Euclid';
83
- font-display: swap;
84
- src: url(${EuclidMedium}) format('woff2');
85
- font-weight: 500;
86
- }
87
-
88
- @font-face {
89
- font-family: 'Euclid';
90
- font-display: swap;
91
- src: url(${EuclidMediumItalic}) format('woff2');
92
- font-style: italic;
93
- font-weight: 500;
94
- }
95
- @font-face {
96
- font-family: 'Euclid';
97
- font-display: swap;
98
- src: url(${EuclidSemiBold}) format('woff2');
99
- font-weight: 600;
100
- }
101
- @font-face {
102
- font-family: 'Euclid';
103
- font-display: swap;
104
- src: url(${EuclidSemiBoldItalic}) format('woff2');
105
- font-style: italic;
106
- font-weight: 600;
107
- }
108
- @font-face {
109
- font-family: 'Euclid';
110
- font-display: swap;
111
- src: url(${EuclidBold}) format('woff2');
112
- font-weight: 700;
113
- }
114
-
115
- @font-face {
116
- font-family: 'Euclid';
117
- font-display: swap;
118
- src: url(${EuclidBoldItalic}) format('woff2');
119
- font-style: italic;
120
- font-weight: 700;
121
- }
122
-
123
- `
124
- }
125
- }
126
39
  };
127
40
 
128
41
  export default createTheme(baseThemeOptions);
@@ -3,64 +3,39 @@ import SvgIcon from '@mui/material/SvgIcon';
3
3
  import Tooltip from '@mui/material/Tooltip';
4
4
  import { CopyButton, Status } from '../lib';
5
5
  import { format } from 'date-fns';
6
- import { StatusVariant, TableDataType } from '../interfaces';
6
+ import { StatusVariant } from '../interfaces';
7
7
  import JsonTypeCell from '../lib/Table/DataGrid/JsonTypeCell';
8
8
 
9
- export const formatTableRowValue = ({
10
- value,
11
- type,
12
- copyText,
13
- status,
14
- }: {
9
+ type TableFormatProps = {
15
10
  value: any;
16
- type?: TableDataType;
17
- copyText?: string;
18
- status?: StatusVariant;
19
- }) => {
20
- switch (type) {
21
- case 'id':
22
- return (
23
- <Box display="flex" alignItems="center" minWidth="100%">
24
- <Tooltip title={value}>
25
- <Box mr="auto">
26
- {value
27
- ? `${(value as string).slice(0, 6)}...${(value as string).slice(
28
- -6
29
- )}`
30
- : '...'}
31
- </Box>
32
- </Tooltip>
33
-
34
- <CopyButton copyText={(copyText ? copyText : value) as string} />
35
- </Box>
36
- );
37
- case 'JSON_copy':
38
- return <JsonTypeCell value={value} copyButton />;
39
- case 'JSON':
40
- return <JsonTypeCell value={value} />;
41
- case 'JSON_text':
42
- return <JsonTypeCell value={value} textField />;
43
- case 'copy':
44
- return (
45
- <Box display="flex" alignItems="center" minWidth="100%">
46
- <Tooltip title={value}>
47
- <Box
48
- mr="auto"
49
- overflow="hidden"
50
- textOverflow="ellipsis"
51
- whiteSpace="nowrap"
52
- >
53
- {value?.length > 12
54
- ? `${(value as string).slice(0, 6)}...${(value as string).slice(
55
- -6
56
- )}`
57
- : value}
58
- </Box>
59
- </Tooltip>
11
+ canCopy?: boolean;
12
+ copyValue?: string;
13
+ shortId?: boolean;
14
+ fullText?: boolean;
15
+ textParams?: {
16
+ displayAs?:
17
+ | 'text'
18
+ | 'boolean'
19
+ | 'date'
20
+ | 'status'
21
+ | 'json_text'
22
+ | 'json_code'
23
+ | 'array'
24
+ | 'number';
25
+ dateFormat?: string[];
26
+ statusVariant?: StatusVariant;
27
+ };
28
+ };
60
29
 
61
- <CopyButton copyText={(copyText ? copyText : value) as string} />
62
- </Box>
63
- );
30
+ export const formatTableRowValue = ({
31
+ value,
32
+ canCopy,
33
+ copyValue,
34
+ shortId,
35
+ fullText,
36
+ textParams: { displayAs = 'text', dateFormat, statusVariant },
37
+ }: TableFormatProps) => {
38
+ switch (displayAs) {
64
39
  case 'boolean':
65
40
  return value ? (
66
41
  <SvgIcon color="primary" fontSize="small">
@@ -73,15 +48,32 @@ export const formatTableRowValue = ({
73
48
  );
74
49
  case 'date':
75
50
  return value ? (
76
- <div>
77
- <div>{format(new Date(value as string), 'dd.MM.yyyy')}</div>
78
- <div>{format(new Date(value as string), 'HH:mm:ss')}</div>
79
- </div>
51
+ dateFormat ? (
52
+ <Box>
53
+ {dateFormat.map((formatString) => (
54
+ <Box>{format(new Date(value as string), formatString)}</Box>
55
+ ))}
56
+ </Box>
57
+ ) : (
58
+ <Box>
59
+ <Box>{format(new Date(value as string), 'dd.MM.yyyy')}</Box>
60
+ <Box>{format(new Date(value as string), 'HH:mm:ss')}</Box>
61
+ </Box>
62
+ )
80
63
  ) : (
81
64
  ''
82
65
  );
83
66
  case 'status':
84
- return <Status text={value as string} status={status} />;
67
+ return (
68
+ <Status
69
+ text={value as string}
70
+ status={statusVariant ? statusVariant : 'default'}
71
+ />
72
+ );
73
+ case 'json_text':
74
+ return <JsonTypeCell value={value} textField />;
75
+ case 'json_code':
76
+ return <JsonTypeCell value={value} copyButton />;
85
77
  case 'array':
86
78
  return (
87
79
  <Box>
@@ -90,13 +82,53 @@ export const formatTableRowValue = ({
90
82
  ))}
91
83
  </Box>
92
84
  );
93
- default:
85
+ case 'number':
94
86
  return (
95
- <Tooltip title={value}>
96
- <div className="MuiDataGrid-cellContent" title={value}>
97
- {value}
98
- </div>
99
- </Tooltip>
87
+ <Box display="flex" justifyContent="flex-end">
88
+ <Box>
89
+ {value.toLocaleString('ru-Ru', { minimumFractionDigits: 2 })}
90
+ </Box>
91
+ </Box>
92
+ );
93
+ case 'text':
94
+ default:
95
+ return value ? (
96
+ <Box display="flex" alignItems="center" width="100%">
97
+ {shortId ? (
98
+ <Tooltip title={value}>
99
+ <Box mr="auto">
100
+ {value
101
+ ? `${(value as string).slice(0, 6)}...${(
102
+ value as string
103
+ ).slice(-6)}`
104
+ : '...'}
105
+ </Box>
106
+ </Tooltip>
107
+ ) : fullText ? (
108
+ <Box sx={{ whiteSpace: 'normal' }} title={value}>
109
+ {typeof value === 'string' ? value : JSON.stringify(value)}
110
+ </Box>
111
+ ) : (
112
+ <Tooltip title={value}>
113
+ <Box className="MuiDataGrid-cellContent" title={value}>
114
+ {typeof value === 'string' ? value : JSON.stringify(value)}
115
+ </Box>
116
+ </Tooltip>
117
+ )}
118
+ {canCopy && (
119
+ <CopyButton
120
+ copyText={
121
+ copyValue
122
+ ? typeof copyValue === 'string'
123
+ ? copyValue
124
+ : JSON.stringify(copyValue)
125
+ : value
126
+ }
127
+ />
128
+ )}
129
+ </Box>
130
+ ) : (
131
+ ''
100
132
  );
101
133
  }
102
134
  };