muffin-admin 2.6.6 → 2.6.7

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": "muffin-admin",
3
- "version": "2.6.6",
3
+ "version": "2.6.7",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -5,7 +5,10 @@ import { Button, FunctionField, useRecordContext } from "react-admin"
5
5
  export function JsonField({ label, source }) {
6
6
  const [expand, setExpand] = useState(false)
7
7
  const record = useRecordContext()
8
- const src = JSON.stringify(get(record, source), null, 2)
8
+ const value = get(record, source)
9
+ if (!value || Object.keys(value).length == 0) return null
10
+
11
+ const src = JSON.stringify(value, null, 2)
9
12
  const retval = (
10
13
  <div>
11
14
  <p></p>
@@ -15,7 +18,10 @@ export function JsonField({ label, source }) {
15
18
  color="primary"
16
19
  size="small"
17
20
  label={expand ? "colapse" : "expand"}
18
- onClick={() => setExpand(!expand)}
21
+ onClick={(e) => {
22
+ setExpand(!expand)
23
+ e.stopPropagation()
24
+ }}
19
25
  />
20
26
  <p>{expand && <pre>{src}</pre>}</p>
21
27
  </div>