forked from ToolJet/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONNodeValue.jsx
More file actions
54 lines (50 loc) · 1.46 KB
/
JSONNodeValue.jsx
File metadata and controls
54 lines (50 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from 'react';
import useAppDarkMode from '@/_hooks/useAppDarkMode';
const JSONTreeValueNode = ({ data, type }) => {
const { appMode } = useAppDarkMode();
if (type === 'Function') {
return;
// const functionString = `${data.toString().split('{')[0].trim()}{...}`;
// return (
// <React.Fragment>
// <span
// className={`text-secondary node-value-${type}`}
// style={{ fontSize: '12px', fontFamily: 'monospace', textTransform: 'none' }}
// >
// {functionString}
// </span>
// </React.Fragment>
// );
}
let value = type === 'String' ? `"${data}"` : String(data);
if (value.length > 65) {
value = `${value.substring(0, 65)} ... "`;
}
const clsForUndefinedOrNull = (type === 'Undefined' || type === 'Null') && 'badge badge-secondary';
return (
<>
<span
className={`mx-2 json-tree-valuetype json-tree-node-${String(
type
).toLowerCase()} text-break ${clsForUndefinedOrNull}`}
>
{value}
</span>
{appMode === 'auto' && (data === 'light' || data === 'dark') && (
<span
style={{
fontSize: '10px',
backgroundColor: 'var(--controls-switch-tag)',
borderRadius: '11px',
padding: '3px 6px',
fontWeight: '500',
color: '#6A727C',
}}
>
auto
</span>
)}
</>
);
};
export default JSONTreeValueNode;