@uiw/react-json-view 2.0.0-alpha.37 → 2.0.0-alpha.38

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.
@@ -40,15 +40,16 @@ var KeyValues = exports.KeyValues = function KeyValues(props) {
40
40
  collapsed = _useStore.collapsed,
41
41
  shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
42
42
  var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
43
- var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
44
- var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
43
+ var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
44
+ var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
45
45
  value: value,
46
46
  keys: keys,
47
47
  level: level,
48
48
  keyName: keyName,
49
49
  parentValue: parentValue
50
50
  });
51
- if (expands[expandKey] === undefined && !!shouldExpand) {
51
+ console.log('KeyValues', expands[expandKey], defaultExpanded, !shouldExpand, shouldExpand, isExpanded);
52
+ if (expands[expandKey] === undefined && !shouldExpand) {
52
53
  return null;
53
54
  }
54
55
  if (isExpanded) {
@@ -24,15 +24,16 @@ var NestedClose = exports.NestedClose = function NestedClose(props) {
24
24
  collapsed = _useStore.collapsed,
25
25
  shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
26
26
  var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
27
- var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
28
- var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
27
+ var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
28
+ var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
29
29
  value: value,
30
30
  keys: keys,
31
31
  level: level,
32
32
  keyName: keyName,
33
33
  parentValue: parentValue
34
34
  });
35
- if (expands[expandKey] === undefined && !!shouldExpand) {
35
+ console.log('NestedClose', expands[expandKey], defaultExpanded, shouldExpand);
36
+ if (expands[expandKey] === undefined && !shouldExpand) {
36
37
  return null;
37
38
  }
38
39
  var len = Object.keys(value).length;
@@ -35,16 +35,17 @@ var NestedOpen = exports.NestedOpen = function NestedOpen(props) {
35
35
  collapsed = _useStore.collapsed,
36
36
  shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
37
37
  var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
38
- var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
39
- var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
38
+ var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
39
+ var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
40
40
  value: value,
41
41
  keys: keys,
42
42
  level: level,
43
43
  keyName: keyName,
44
44
  parentValue: parentValue
45
45
  });
46
+ console.log('NestedOpen', expands[expandKey], defaultExpanded, shouldExpand, !shouldExpand);
46
47
  if (expands[expandKey] === undefined && shouldExpandNodeInitially) {
47
- isExpanded = !!shouldExpand;
48
+ isExpanded = !shouldExpand;
48
49
  }
49
50
  var click = function click() {
50
51
  var opt = {
package/cjs/index.js CHANGED
@@ -117,8 +117,12 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
117
117
  style = props.style,
118
118
  value = props.value,
119
119
  children = props.children,
120
- collapsed = props.collapsed,
121
- shouldExpandNodeInitially = props.shouldExpandNodeInitially,
120
+ _props$collapsed = props.collapsed,
121
+ collapsed = _props$collapsed === void 0 ? false : _props$collapsed,
122
+ _props$shouldExpandNo = props.shouldExpandNodeInitially,
123
+ shouldExpandNodeInitially = _props$shouldExpandNo === void 0 ? function () {
124
+ return true;
125
+ } : _props$shouldExpandNo,
122
126
  _props$indentWidth = props.indentWidth,
123
127
  indentWidth = _props$indentWidth === void 0 ? 15 : _props$indentWidth,
124
128
  _props$displayObjectS = props.displayObjectSize,
@@ -151,7 +155,9 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
151
155
  value: value,
152
156
  objectSortKeys: objectSortKeys,
153
157
  indentWidth: indentWidth,
154
- shouldExpandNodeInitially: shouldExpandNodeInitially,
158
+ shouldExpandNodeInitially: collapsed === false ? shouldExpandNodeInitially : function () {
159
+ return false;
160
+ },
155
161
  displayObjectSize: displayObjectSize,
156
162
  collapsed: collapsed,
157
163
  enableClipboard: enableClipboard,
@@ -30,15 +30,16 @@ export var KeyValues = props => {
30
30
  shouldExpandNodeInitially
31
31
  } = useStore();
32
32
  var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
33
- var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
34
- var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
33
+ var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
34
+ var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
35
35
  value,
36
36
  keys,
37
37
  level,
38
38
  keyName,
39
39
  parentValue
40
40
  });
41
- if (expands[expandKey] === undefined && !!shouldExpand) {
41
+ console.log('KeyValues', expands[expandKey], defaultExpanded, !shouldExpand, shouldExpand, isExpanded);
42
+ if (expands[expandKey] === undefined && !shouldExpand) {
42
43
  return null;
43
44
  }
44
45
  if (isExpanded) {
@@ -19,15 +19,16 @@ export var NestedClose = props => {
19
19
  shouldExpandNodeInitially
20
20
  } = useStore();
21
21
  var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
22
- var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
23
- var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
22
+ var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
23
+ var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
24
24
  value,
25
25
  keys,
26
26
  level,
27
27
  keyName,
28
28
  parentValue
29
29
  });
30
- if (expands[expandKey] === undefined && !!shouldExpand) {
30
+ console.log('NestedClose', expands[expandKey], defaultExpanded, shouldExpand);
31
+ if (expands[expandKey] === undefined && !shouldExpand) {
31
32
  return null;
32
33
  }
33
34
  var len = Object.keys(value).length;
@@ -28,16 +28,17 @@ export var NestedOpen = props => {
28
28
  shouldExpandNodeInitially
29
29
  } = useStore();
30
30
  var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
31
- var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
32
- var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
31
+ var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
32
+ var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
33
33
  value,
34
34
  keys,
35
35
  level,
36
36
  keyName,
37
37
  parentValue
38
38
  });
39
+ console.log('NestedOpen', expands[expandKey], defaultExpanded, shouldExpand, !shouldExpand);
39
40
  if (expands[expandKey] === undefined && shouldExpandNodeInitially) {
40
- isExpanded = !!shouldExpand;
41
+ isExpanded = !shouldExpand;
41
42
  }
42
43
  var click = () => {
43
44
  var opt = {
package/esm/index.js CHANGED
@@ -44,8 +44,8 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
44
44
  style,
45
45
  value,
46
46
  children,
47
- collapsed,
48
- shouldExpandNodeInitially,
47
+ collapsed = false,
48
+ shouldExpandNodeInitially = () => true,
49
49
  indentWidth = 15,
50
50
  displayObjectSize = true,
51
51
  shortenTextAfterLength = 30,
@@ -72,7 +72,7 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
72
72
  value,
73
73
  objectSortKeys,
74
74
  indentWidth,
75
- shouldExpandNodeInitially,
75
+ shouldExpandNodeInitially: collapsed === false ? shouldExpandNodeInitially : () => false,
76
76
  displayObjectSize,
77
77
  collapsed,
78
78
  enableClipboard,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-json-view",
3
- "version": "2.0.0-alpha.37",
3
+ "version": "2.0.0-alpha.38",
4
4
  "description": "JSON viewer for react.",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",