@uiw/react-json-view 2.0.0-alpha.3 → 2.0.0-alpha.30

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.
Files changed (197) hide show
  1. package/README.md +217 -26
  2. package/basic.d.ts +3 -0
  3. package/cjs/Container.d.ts +2 -0
  4. package/cjs/Container.js +13 -6
  5. package/cjs/arrow/TriangleArrow.js +1 -1
  6. package/cjs/comps/Copied.d.ts +2 -4
  7. package/cjs/comps/Copied.js +50 -17
  8. package/cjs/comps/KeyValues.d.ts +2 -4
  9. package/cjs/comps/KeyValues.js +62 -27
  10. package/cjs/comps/NestedClose.d.ts +1 -0
  11. package/cjs/comps/NestedClose.js +15 -5
  12. package/cjs/comps/NestedOpen.d.ts +2 -3
  13. package/cjs/comps/NestedOpen.js +34 -14
  14. package/cjs/comps/Value.d.ts +1 -2
  15. package/cjs/comps/Value.js +4 -8
  16. package/cjs/comps/useIdCompat.d.ts +1 -0
  17. package/cjs/comps/useIdCompat.js +14 -0
  18. package/cjs/editor/KeyName.d.ts +2 -0
  19. package/cjs/editor/KeyName.js +82 -0
  20. package/cjs/editor/index.d.ts +18 -0
  21. package/cjs/editor/index.js +44 -0
  22. package/cjs/editor/store.d.ts +27 -0
  23. package/cjs/editor/store.js +23 -0
  24. package/cjs/index.d.ts +10 -3
  25. package/cjs/index.js +9 -4
  26. package/cjs/section/Copied.d.ts +1 -1
  27. package/cjs/section/Copied.js +1 -2
  28. package/cjs/section/CountInfo.d.ts +1 -2
  29. package/cjs/section/CountInfo.js +3 -5
  30. package/cjs/section/CountInfoExtra.d.ts +1 -2
  31. package/cjs/section/CountInfoExtra.js +2 -4
  32. package/cjs/section/Ellipsis.d.ts +0 -1
  33. package/cjs/section/Ellipsis.js +4 -5
  34. package/cjs/section/KeyName.d.ts +7 -6
  35. package/cjs/section/KeyName.js +8 -6
  36. package/cjs/section/Row.d.ts +13 -0
  37. package/cjs/section/Row.js +51 -0
  38. package/cjs/store/Expands.js +2 -4
  39. package/cjs/store/Section.d.ts +12 -6
  40. package/cjs/store/Section.js +6 -4
  41. package/cjs/store/ShowTools.js +2 -4
  42. package/cjs/store/Symbols.d.ts +10 -3
  43. package/cjs/store/Symbols.js +2 -4
  44. package/cjs/store/Types.d.ts +29 -25
  45. package/cjs/store/Types.js +8 -8
  46. package/cjs/store.d.ts +8 -4
  47. package/cjs/store.js +5 -10
  48. package/cjs/symbol/Arrow.d.ts +1 -1
  49. package/cjs/symbol/Arrow.js +1 -2
  50. package/cjs/symbol/BraceLeft.d.ts +1 -1
  51. package/cjs/symbol/BraceLeft.js +1 -2
  52. package/cjs/symbol/BraceRight.d.ts +1 -1
  53. package/cjs/symbol/BraceRight.js +1 -2
  54. package/cjs/symbol/BracketsLeft.d.ts +1 -1
  55. package/cjs/symbol/BracketsLeft.js +1 -2
  56. package/cjs/symbol/BracketsRight.d.ts +1 -1
  57. package/cjs/symbol/BracketsRight.js +1 -2
  58. package/cjs/symbol/Colon.d.ts +1 -1
  59. package/cjs/symbol/Colon.js +1 -2
  60. package/cjs/symbol/Quote.d.ts +1 -1
  61. package/cjs/symbol/Quote.js +1 -2
  62. package/cjs/symbol/ValueQuote.d.ts +1 -1
  63. package/cjs/symbol/ValueQuote.js +1 -2
  64. package/cjs/symbol/index.d.ts +11 -16
  65. package/cjs/symbol/index.js +75 -30
  66. package/cjs/theme/basic.d.ts +1 -2
  67. package/cjs/theme/basic.js +4 -3
  68. package/cjs/theme/dark.d.ts +1 -2
  69. package/cjs/theme/dark.js +2 -3
  70. package/cjs/theme/github.dark.d.ts +1 -2
  71. package/cjs/theme/github.dark.js +2 -3
  72. package/cjs/theme/github.light.d.ts +1 -2
  73. package/cjs/theme/github.light.js +2 -3
  74. package/cjs/theme/gruvbox.d.ts +1 -2
  75. package/cjs/theme/gruvbox.js +2 -3
  76. package/cjs/theme/light.d.ts +1 -2
  77. package/cjs/theme/light.js +2 -3
  78. package/cjs/theme/monokai.d.ts +1 -2
  79. package/cjs/theme/monokai.js +2 -3
  80. package/cjs/theme/nord.d.ts +1 -2
  81. package/cjs/theme/nord.js +2 -3
  82. package/cjs/theme/vscode.d.ts +1 -2
  83. package/cjs/theme/vscode.js +2 -3
  84. package/cjs/types/Bigint.d.ts +1 -1
  85. package/cjs/types/Bigint.js +1 -2
  86. package/cjs/types/Date.d.ts +1 -1
  87. package/cjs/types/Date.js +1 -2
  88. package/cjs/types/False.d.ts +1 -1
  89. package/cjs/types/False.js +1 -2
  90. package/cjs/types/Float.d.ts +1 -1
  91. package/cjs/types/Float.js +1 -2
  92. package/cjs/types/Int.d.ts +1 -1
  93. package/cjs/types/Int.js +1 -2
  94. package/cjs/types/Map.d.ts +1 -1
  95. package/cjs/types/Map.js +1 -2
  96. package/cjs/types/Nan.d.ts +1 -1
  97. package/cjs/types/Nan.js +1 -2
  98. package/cjs/types/Null.d.ts +1 -1
  99. package/cjs/types/Null.js +1 -2
  100. package/cjs/types/Set.d.ts +1 -1
  101. package/cjs/types/Set.js +1 -2
  102. package/cjs/types/String.d.ts +1 -1
  103. package/cjs/types/String.js +1 -2
  104. package/cjs/types/True.d.ts +1 -1
  105. package/cjs/types/True.js +1 -2
  106. package/cjs/types/Undefined.d.ts +1 -1
  107. package/cjs/types/Undefined.js +1 -2
  108. package/cjs/types/Url.d.ts +1 -1
  109. package/cjs/types/Url.js +1 -2
  110. package/cjs/types/index.d.ts +3 -1
  111. package/cjs/types/index.js +96 -124
  112. package/cjs/utils/useHighlight.d.ts +0 -1
  113. package/cjs/utils/useRender.d.ts +1 -1
  114. package/editor.d.ts +22 -20
  115. package/esm/Container.d.ts +2 -0
  116. package/esm/Container.js +15 -7
  117. package/esm/arrow/TriangleArrow.js +1 -1
  118. package/esm/comps/Copied.d.ts +2 -4
  119. package/esm/comps/Copied.js +48 -16
  120. package/esm/comps/KeyValues.d.ts +2 -4
  121. package/esm/comps/KeyValues.js +53 -21
  122. package/esm/comps/NestedClose.d.ts +1 -0
  123. package/esm/comps/NestedClose.js +13 -3
  124. package/esm/comps/NestedOpen.d.ts +2 -3
  125. package/esm/comps/NestedOpen.js +33 -14
  126. package/esm/comps/Value.d.ts +1 -2
  127. package/esm/comps/Value.js +2 -4
  128. package/esm/comps/useIdCompat.d.ts +1 -0
  129. package/esm/comps/useIdCompat.js +8 -0
  130. package/esm/editor/KeyName.d.ts +2 -0
  131. package/esm/editor/KeyName.js +77 -0
  132. package/esm/editor/index.d.ts +18 -0
  133. package/esm/editor/index.js +33 -0
  134. package/esm/editor/store.d.ts +27 -0
  135. package/esm/editor/store.js +13 -0
  136. package/esm/index.d.ts +10 -3
  137. package/esm/index.js +10 -5
  138. package/esm/section/Copied.d.ts +1 -1
  139. package/esm/section/CountInfo.d.ts +1 -2
  140. package/esm/section/CountInfo.js +1 -1
  141. package/esm/section/CountInfoExtra.d.ts +1 -2
  142. package/esm/section/Ellipsis.d.ts +0 -1
  143. package/esm/section/Ellipsis.js +1 -1
  144. package/esm/section/KeyName.d.ts +7 -6
  145. package/esm/section/KeyName.js +6 -2
  146. package/esm/section/Row.d.ts +13 -0
  147. package/esm/section/Row.js +47 -0
  148. package/esm/store/Section.d.ts +12 -6
  149. package/esm/store/Section.js +4 -0
  150. package/esm/store/Symbols.d.ts +10 -3
  151. package/esm/store/Types.d.ts +29 -25
  152. package/esm/store/Types.js +6 -4
  153. package/esm/store.d.ts +8 -4
  154. package/esm/symbol/Arrow.d.ts +1 -1
  155. package/esm/symbol/BraceLeft.d.ts +1 -1
  156. package/esm/symbol/BraceRight.d.ts +1 -1
  157. package/esm/symbol/BracketsLeft.d.ts +1 -1
  158. package/esm/symbol/BracketsRight.d.ts +1 -1
  159. package/esm/symbol/Colon.d.ts +1 -1
  160. package/esm/symbol/Quote.d.ts +1 -1
  161. package/esm/symbol/ValueQuote.d.ts +1 -1
  162. package/esm/symbol/index.d.ts +11 -16
  163. package/esm/symbol/index.js +76 -23
  164. package/esm/theme/basic.d.ts +1 -2
  165. package/esm/theme/basic.js +2 -0
  166. package/esm/theme/dark.d.ts +1 -2
  167. package/esm/theme/github.dark.d.ts +1 -2
  168. package/esm/theme/github.light.d.ts +1 -2
  169. package/esm/theme/gruvbox.d.ts +1 -2
  170. package/esm/theme/light.d.ts +1 -2
  171. package/esm/theme/monokai.d.ts +1 -2
  172. package/esm/theme/nord.d.ts +1 -2
  173. package/esm/theme/vscode.d.ts +1 -2
  174. package/esm/types/Bigint.d.ts +1 -1
  175. package/esm/types/Date.d.ts +1 -1
  176. package/esm/types/False.d.ts +1 -1
  177. package/esm/types/Float.d.ts +1 -1
  178. package/esm/types/Int.d.ts +1 -1
  179. package/esm/types/Map.d.ts +1 -1
  180. package/esm/types/Nan.d.ts +1 -1
  181. package/esm/types/Null.d.ts +1 -1
  182. package/esm/types/Set.d.ts +1 -1
  183. package/esm/types/String.d.ts +1 -1
  184. package/esm/types/True.d.ts +1 -1
  185. package/esm/types/Undefined.d.ts +1 -1
  186. package/esm/types/Url.d.ts +1 -1
  187. package/esm/types/index.d.ts +3 -1
  188. package/esm/types/index.js +82 -100
  189. package/esm/utils/useHighlight.d.ts +0 -1
  190. package/esm/utils/useRender.d.ts +1 -1
  191. package/githubDark.d.ts +3 -0
  192. package/githubLight.d.ts +3 -0
  193. package/gruvbox.d.ts +3 -0
  194. package/monokai.d.ts +3 -0
  195. package/nord.d.ts +3 -0
  196. package/package.json +11 -5
  197. package/vscode.d.ts +3 -0
@@ -4,15 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TypeUrl = exports.TypeUndefined = exports.TypeTrue = exports.TypeString = exports.TypeNull = exports.TypeNan = exports.TypeInt = exports.TypeFloat = exports.TypeFalse = exports.TypeDate = exports.TypeBigint = exports.SetComp = exports.MapComp = void 0;
7
+ exports.bigIntToString = exports.TypeUrl = exports.TypeUndefined = exports.TypeTrue = exports.TypeString = exports.TypeNull = exports.TypeNan = exports.TypeInt = exports.TypeFloat = exports.TypeFalse = exports.TypeDate = exports.TypeBigint = exports.SetComp = exports.MapComp = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
11
  var _react = require("react");
12
- var _Types = require("../store/Types");
13
12
  var _store = require("../store");
13
+ var _Types = require("../store/Types");
14
14
  var _symbol = require("../symbol");
15
- var _Copied = require("../comps/Copied");
16
15
  var _jsxRuntime = require("react/jsx-runtime");
17
16
  var _excluded = ["as", "render"],
18
17
  _excluded2 = ["as", "render"],
@@ -27,8 +26,21 @@ var _excluded = ["as", "render"],
27
26
  _excluded11 = ["as", "render"],
28
27
  _excluded12 = ["as", "render"],
29
28
  _excluded13 = ["as", "render"];
30
- var SetComp = function SetComp(_ref) {
31
- var value = _ref.value;
29
+ var bigIntToString = exports.bigIntToString = function bigIntToString(bi) {
30
+ if (bi === undefined) {
31
+ return '0n';
32
+ } else if (typeof bi === 'string') {
33
+ try {
34
+ bi = BigInt(bi);
35
+ } catch (e) {
36
+ return '0n';
37
+ }
38
+ }
39
+ return bi ? bi.toString() + 'n' : '0n';
40
+ };
41
+ var SetComp = exports.SetComp = function SetComp(_ref) {
42
+ var value = _ref.value,
43
+ keyName = _ref.keyName;
32
44
  var _useTypesStore = (0, _Types.useTypesStore)(),
33
45
  _useTypesStore$Set = _useTypesStore.Set,
34
46
  Comp = _useTypesStore$Set === void 0 ? {} : _useTypesStore$Set,
@@ -41,16 +53,17 @@ var SetComp = function SetComp(_ref) {
41
53
  var isRender = render && typeof render === 'function';
42
54
  var type = isRender && render(reset, {
43
55
  type: 'type',
44
- value: value
56
+ value: value,
57
+ keyName: keyName
45
58
  });
46
59
  if (type) return type;
47
60
  var Elm = as || 'span';
48
61
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Elm, (0, _objectSpread2["default"])({}, reset));
49
62
  };
50
- exports.SetComp = SetComp;
51
63
  SetComp.displayName = 'JVR.SetComp';
52
- var MapComp = function MapComp(_ref2) {
53
- var value = _ref2.value;
64
+ var MapComp = exports.MapComp = function MapComp(_ref2) {
65
+ var value = _ref2.value,
66
+ keyName = _ref2.keyName;
54
67
  var _useTypesStore2 = (0, _Types.useTypesStore)(),
55
68
  _useTypesStore2$Map = _useTypesStore2.Map,
56
69
  Comp = _useTypesStore2$Map === void 0 ? {} : _useTypesStore2$Map,
@@ -63,22 +76,21 @@ var MapComp = function MapComp(_ref2) {
63
76
  var isRender = render && typeof render === 'function';
64
77
  var type = isRender && render(reset, {
65
78
  type: 'type',
66
- value: value
79
+ value: value,
80
+ keyName: keyName
67
81
  });
68
82
  if (type) return type;
69
83
  var Elm = as || 'span';
70
84
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Elm, (0, _objectSpread2["default"])({}, reset));
71
85
  };
72
- exports.MapComp = MapComp;
73
86
  MapComp.displayName = 'JVR.MapComp';
74
87
  var defalutStyle = {
75
88
  opacity: 0.75,
76
89
  paddingRight: 4
77
90
  };
78
- var TypeString = function TypeString(_ref3) {
91
+ var TypeString = exports.TypeString = function TypeString(_ref3) {
79
92
  var _ref3$children = _ref3.children,
80
93
  children = _ref3$children === void 0 ? '' : _ref3$children,
81
- expandKey = _ref3.expandKey,
82
94
  keyName = _ref3.keyName;
83
95
  var _useTypesStore3 = (0, _Types.useTypesStore)(),
84
96
  _useTypesStore3$Str = _useTypesStore3.Str,
@@ -86,15 +98,18 @@ var TypeString = function TypeString(_ref3) {
86
98
  displayDataTypes = _useTypesStore3.displayDataTypes;
87
99
  var _useStore = (0, _store.useStore)(),
88
100
  _useStore$shortenText = _useStore.shortenTextAfterLength,
89
- length = _useStore$shortenText === void 0 ? 20 : _useStore$shortenText;
101
+ length = _useStore$shortenText === void 0 ? 30 : _useStore$shortenText;
90
102
  var as = Str.as,
91
103
  render = Str.render,
92
104
  reset = (0, _objectWithoutProperties2["default"])(Str, _excluded3);
93
105
  var childrenStr = children;
94
- var _useState = (0, _react.useState)(length && childrenStr.length >= length),
106
+ var _useState = (0, _react.useState)(length && childrenStr.length > length),
95
107
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
96
108
  shorten = _useState2[0],
97
109
  setShorten = _useState2[1];
110
+ (0, _react.useEffect)(function () {
111
+ return setShorten(length && childrenStr.length > length);
112
+ }, [length]);
98
113
  var Comp = as || 'span';
99
114
  var style = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, defalutStyle), Str.style || {});
100
115
  if (length > 0) {
@@ -113,14 +128,16 @@ var TypeString = function TypeString(_ref3) {
113
128
  style: style
114
129
  }), {
115
130
  type: 'type',
116
- value: children
131
+ value: children,
132
+ keyName: keyName
117
133
  });
118
134
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
119
135
  children: text,
120
136
  className: 'w-rjv-value'
121
137
  }), {
122
138
  type: 'value',
123
- value: children
139
+ value: children,
140
+ keyName: keyName
124
141
  });
125
142
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
126
143
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
@@ -130,18 +147,12 @@ var TypeString = function TypeString(_ref3) {
130
147
  className: "w-rjv-value",
131
148
  children: text
132
149
  })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.ValueQuote, {})]
133
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
134
- keyName: keyName,
135
- value: children,
136
- expandKey: expandKey
137
150
  })]
138
151
  });
139
152
  };
140
- exports.TypeString = TypeString;
141
153
  TypeString.displayName = 'JVR.TypeString';
142
- var TypeTrue = function TypeTrue(_ref4) {
154
+ var TypeTrue = exports.TypeTrue = function TypeTrue(_ref4) {
143
155
  var children = _ref4.children,
144
- expandKey = _ref4.expandKey,
145
156
  keyName = _ref4.keyName;
146
157
  var _useTypesStore4 = (0, _Types.useTypesStore)(),
147
158
  _useTypesStore4$True = _useTypesStore4.True,
@@ -157,14 +168,16 @@ var TypeTrue = function TypeTrue(_ref4) {
157
168
  style: style
158
169
  }), {
159
170
  type: 'type',
160
- value: children
171
+ value: children,
172
+ keyName: keyName
161
173
  });
162
174
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
163
175
  children: children,
164
176
  className: 'w-rjv-value'
165
177
  }), {
166
178
  type: 'value',
167
- value: children
179
+ value: children,
180
+ keyName: keyName
168
181
  });
169
182
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
170
183
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
@@ -172,18 +185,12 @@ var TypeTrue = function TypeTrue(_ref4) {
172
185
  }))), child || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
173
186
  className: "w-rjv-value",
174
187
  children: children === null || children === void 0 ? void 0 : children.toString()
175
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
176
- keyName: keyName,
177
- value: children,
178
- expandKey: expandKey
179
- })]
188
+ }))]
180
189
  });
181
190
  };
182
- exports.TypeTrue = TypeTrue;
183
191
  TypeTrue.displayName = 'JVR.TypeTrue';
184
- var TypeFalse = function TypeFalse(_ref5) {
192
+ var TypeFalse = exports.TypeFalse = function TypeFalse(_ref5) {
185
193
  var children = _ref5.children,
186
- expandKey = _ref5.expandKey,
187
194
  keyName = _ref5.keyName;
188
195
  var _useTypesStore5 = (0, _Types.useTypesStore)(),
189
196
  _useTypesStore5$False = _useTypesStore5.False,
@@ -199,14 +206,16 @@ var TypeFalse = function TypeFalse(_ref5) {
199
206
  style: style
200
207
  }), {
201
208
  type: 'type',
202
- value: children
209
+ value: children,
210
+ keyName: keyName
203
211
  });
204
212
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
205
213
  children: children,
206
214
  className: 'w-rjv-value'
207
215
  }), {
208
216
  type: 'value',
209
- value: children
217
+ value: children,
218
+ keyName: keyName
210
219
  });
211
220
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
212
221
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
@@ -214,18 +223,12 @@ var TypeFalse = function TypeFalse(_ref5) {
214
223
  }))), child || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
215
224
  className: "w-rjv-value",
216
225
  children: children === null || children === void 0 ? void 0 : children.toString()
217
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
218
- keyName: keyName,
219
- value: children,
220
- expandKey: expandKey
221
- })]
226
+ }))]
222
227
  });
223
228
  };
224
- exports.TypeFalse = TypeFalse;
225
229
  TypeFalse.displayName = 'JVR.TypeFalse';
226
- var TypeFloat = function TypeFloat(_ref6) {
230
+ var TypeFloat = exports.TypeFloat = function TypeFloat(_ref6) {
227
231
  var children = _ref6.children,
228
- expandKey = _ref6.expandKey,
229
232
  keyName = _ref6.keyName;
230
233
  var _useTypesStore6 = (0, _Types.useTypesStore)(),
231
234
  _useTypesStore6$Float = _useTypesStore6.Float,
@@ -241,14 +244,16 @@ var TypeFloat = function TypeFloat(_ref6) {
241
244
  style: style
242
245
  }), {
243
246
  type: 'type',
244
- value: children
247
+ value: children,
248
+ keyName: keyName
245
249
  });
246
250
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
247
251
  children: children,
248
252
  className: 'w-rjv-value'
249
253
  }), {
250
254
  type: 'value',
251
- value: children
255
+ value: children,
256
+ keyName: keyName
252
257
  });
253
258
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
254
259
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
@@ -256,18 +261,12 @@ var TypeFloat = function TypeFloat(_ref6) {
256
261
  }))), child || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
257
262
  className: "w-rjv-value",
258
263
  children: children === null || children === void 0 ? void 0 : children.toString()
259
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
260
- keyName: keyName,
261
- value: children,
262
- expandKey: expandKey
263
- })]
264
+ }))]
264
265
  });
265
266
  };
266
- exports.TypeFloat = TypeFloat;
267
267
  TypeFloat.displayName = 'JVR.TypeFloat';
268
- var TypeInt = function TypeInt(_ref7) {
268
+ var TypeInt = exports.TypeInt = function TypeInt(_ref7) {
269
269
  var children = _ref7.children,
270
- expandKey = _ref7.expandKey,
271
270
  keyName = _ref7.keyName;
272
271
  var _useTypesStore7 = (0, _Types.useTypesStore)(),
273
272
  _useTypesStore7$Int = _useTypesStore7.Int,
@@ -283,14 +282,16 @@ var TypeInt = function TypeInt(_ref7) {
283
282
  style: style
284
283
  }), {
285
284
  type: 'type',
286
- value: children
285
+ value: children,
286
+ keyName: keyName
287
287
  });
288
288
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
289
289
  children: children,
290
290
  className: 'w-rjv-value'
291
291
  }), {
292
292
  type: 'value',
293
- value: children
293
+ value: children,
294
+ keyName: keyName
294
295
  });
295
296
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
296
297
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
@@ -298,18 +299,12 @@ var TypeInt = function TypeInt(_ref7) {
298
299
  }))), child || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
299
300
  className: "w-rjv-value",
300
301
  children: children === null || children === void 0 ? void 0 : children.toString()
301
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
302
- keyName: keyName,
303
- value: children,
304
- expandKey: expandKey
305
- })]
302
+ }))]
306
303
  });
307
304
  };
308
- exports.TypeInt = TypeInt;
309
305
  TypeInt.displayName = 'JVR.TypeInt';
310
- var TypeBigint = function TypeBigint(_ref8) {
306
+ var TypeBigint = exports.TypeBigint = function TypeBigint(_ref8) {
311
307
  var children = _ref8.children,
312
- expandKey = _ref8.expandKey,
313
308
  keyName = _ref8.keyName;
314
309
  var _useTypesStore8 = (0, _Types.useTypesStore)(),
315
310
  _useTypesStore8$Bigin = _useTypesStore8.Bigint,
@@ -325,33 +320,29 @@ var TypeBigint = function TypeBigint(_ref8) {
325
320
  style: style
326
321
  }), {
327
322
  type: 'type',
328
- value: children
323
+ value: children,
324
+ keyName: keyName
329
325
  });
330
326
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
331
327
  children: children,
332
328
  className: 'w-rjv-value'
333
329
  }), {
334
330
  type: 'value',
335
- value: children
331
+ value: children,
332
+ keyName: keyName
336
333
  });
337
334
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
338
335
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
339
336
  style: style
340
337
  }))), child || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
341
338
  className: "w-rjv-value",
342
- children: (children === null || children === void 0 ? void 0 : children.toString()) + 'n'
343
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
344
- keyName: keyName,
345
- value: children,
346
- expandKey: expandKey
347
- })]
339
+ children: bigIntToString(children === null || children === void 0 ? void 0 : children.toString())
340
+ }))]
348
341
  });
349
342
  };
350
- exports.TypeBigint = TypeBigint;
351
343
  TypeBigint.displayName = 'JVR.TypeFloat';
352
- var TypeUrl = function TypeUrl(_ref9) {
344
+ var TypeUrl = exports.TypeUrl = function TypeUrl(_ref9) {
353
345
  var children = _ref9.children,
354
- expandKey = _ref9.expandKey,
355
346
  keyName = _ref9.keyName;
356
347
  var _useTypesStore9 = (0, _Types.useTypesStore)(),
357
348
  _useTypesStore9$Url = _useTypesStore9.Url,
@@ -367,14 +358,16 @@ var TypeUrl = function TypeUrl(_ref9) {
367
358
  style: style
368
359
  }), {
369
360
  type: 'type',
370
- value: children
361
+ value: children,
362
+ keyName: keyName
371
363
  });
372
364
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
373
365
  children: children === null || children === void 0 ? void 0 : children.href,
374
366
  className: 'w-rjv-value'
375
367
  }), {
376
368
  type: 'value',
377
- value: children
369
+ value: children,
370
+ keyName: keyName
378
371
  });
379
372
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
380
373
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
@@ -385,18 +378,12 @@ var TypeUrl = function TypeUrl(_ref9) {
385
378
  }, reset), {}, {
386
379
  className: "w-rjv-value",
387
380
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.ValueQuote, {}), children === null || children === void 0 ? void 0 : children.href, /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.ValueQuote, {})]
388
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
389
- keyName: keyName,
390
- value: children,
391
- expandKey: expandKey
392
- })]
381
+ }))]
393
382
  });
394
383
  };
395
- exports.TypeUrl = TypeUrl;
396
384
  TypeUrl.displayName = 'JVR.TypeUrl';
397
- var TypeDate = function TypeDate(_ref10) {
385
+ var TypeDate = exports.TypeDate = function TypeDate(_ref10) {
398
386
  var children = _ref10.children,
399
- expandKey = _ref10.expandKey,
400
387
  keyName = _ref10.keyName;
401
388
  var _useTypesStore10 = (0, _Types.useTypesStore)(),
402
389
  _useTypesStore10$Date = _useTypesStore10.Date,
@@ -412,15 +399,17 @@ var TypeDate = function TypeDate(_ref10) {
412
399
  style: style
413
400
  }), {
414
401
  type: 'type',
415
- value: children
402
+ value: children,
403
+ keyName: keyName
416
404
  });
417
- var childStr = children === null || children === void 0 ? void 0 : children.toString();
405
+ var childStr = children instanceof Date ? children.toLocaleString() : children;
418
406
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
419
407
  children: childStr,
420
408
  className: 'w-rjv-value'
421
409
  }), {
422
410
  type: 'value',
423
- value: children
411
+ value: children,
412
+ keyName: keyName
424
413
  });
425
414
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
426
415
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
@@ -428,18 +417,12 @@ var TypeDate = function TypeDate(_ref10) {
428
417
  }))), child || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
429
418
  className: "w-rjv-value",
430
419
  children: childStr
431
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
432
- keyName: keyName,
433
- value: children,
434
- expandKey: expandKey
435
- })]
420
+ }))]
436
421
  });
437
422
  };
438
- exports.TypeDate = TypeDate;
439
423
  TypeDate.displayName = 'JVR.TypeDate';
440
- var TypeUndefined = function TypeUndefined(_ref11) {
424
+ var TypeUndefined = exports.TypeUndefined = function TypeUndefined(_ref11) {
441
425
  var children = _ref11.children,
442
- expandKey = _ref11.expandKey,
443
426
  keyName = _ref11.keyName;
444
427
  var _useTypesStore11 = (0, _Types.useTypesStore)(),
445
428
  _useTypesStore11$Unde = _useTypesStore11.Undefined,
@@ -455,30 +438,26 @@ var TypeUndefined = function TypeUndefined(_ref11) {
455
438
  style: style
456
439
  }), {
457
440
  type: 'type',
458
- value: children
441
+ value: children,
442
+ keyName: keyName
459
443
  });
460
444
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
461
445
  children: children,
462
446
  className: 'w-rjv-value'
463
447
  }), {
464
448
  type: 'value',
465
- value: children
449
+ value: children,
450
+ keyName: keyName
466
451
  });
467
452
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
468
453
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
469
454
  style: style
470
- }))), child, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
471
- keyName: keyName,
472
- value: children,
473
- expandKey: expandKey
474
- })]
455
+ }))), child]
475
456
  });
476
457
  };
477
- exports.TypeUndefined = TypeUndefined;
478
458
  TypeUndefined.displayName = 'JVR.TypeUndefined';
479
- var TypeNull = function TypeNull(_ref12) {
459
+ var TypeNull = exports.TypeNull = function TypeNull(_ref12) {
480
460
  var children = _ref12.children,
481
- expandKey = _ref12.expandKey,
482
461
  keyName = _ref12.keyName;
483
462
  var _useTypesStore12 = (0, _Types.useTypesStore)(),
484
463
  _useTypesStore12$Null = _useTypesStore12.Null,
@@ -494,30 +473,26 @@ var TypeNull = function TypeNull(_ref12) {
494
473
  style: style
495
474
  }), {
496
475
  type: 'type',
497
- value: children
476
+ value: children,
477
+ keyName: keyName
498
478
  });
499
479
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
500
480
  children: children,
501
481
  className: 'w-rjv-value'
502
482
  }), {
503
483
  type: 'value',
504
- value: children
484
+ value: children,
485
+ keyName: keyName
505
486
  });
506
487
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
507
488
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
508
489
  style: style
509
- }))), child, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
510
- keyName: keyName,
511
- value: children,
512
- expandKey: expandKey
513
- })]
490
+ }))), child]
514
491
  });
515
492
  };
516
- exports.TypeNull = TypeNull;
517
493
  TypeNull.displayName = 'JVR.TypeNull';
518
- var TypeNan = function TypeNan(_ref13) {
494
+ var TypeNan = exports.TypeNan = function TypeNan(_ref13) {
519
495
  var children = _ref13.children,
520
- expandKey = _ref13.expandKey,
521
496
  keyName = _ref13.keyName;
522
497
  var _useTypesStore13 = (0, _Types.useTypesStore)(),
523
498
  _useTypesStore13$Nan = _useTypesStore13.Nan,
@@ -533,24 +508,21 @@ var TypeNan = function TypeNan(_ref13) {
533
508
  style: style
534
509
  }), {
535
510
  type: 'type',
536
- value: children
511
+ value: children,
512
+ keyName: keyName
537
513
  });
538
514
  var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
539
515
  children: children === null || children === void 0 ? void 0 : children.toString(),
540
516
  className: 'w-rjv-value'
541
517
  }), {
542
518
  type: 'value',
543
- value: children
519
+ value: children,
520
+ keyName: keyName
544
521
  });
545
522
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
546
523
  children: [displayDataTypes && (type || /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
547
524
  style: style
548
- }))), child, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
549
- keyName: keyName,
550
- value: children,
551
- expandKey: expandKey
552
- })]
525
+ }))), child]
553
526
  });
554
527
  };
555
- exports.TypeNan = TypeNan;
556
528
  TypeNan.displayName = 'JVR.TypeNan';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare function usePrevious<T>(value: T): T | undefined;
3
2
  interface UseHighlight {
4
3
  value: any;
@@ -1,6 +1,6 @@
1
1
  import { type SymbolsElement } from '../store/Symbols';
2
2
  import { type TagType, type TypesElement } from '../store/Types';
3
3
  import { type SectionElement } from '../store/Section';
4
- export declare function useSymbolsRender(currentProps: SymbolsElement<TagType>, props: SymbolsElement<TagType>, key: string): void;
4
+ export declare function useSymbolsRender<K extends TagType>(currentProps: SymbolsElement<TagType>, props: SymbolsElement<K>, key: string): void;
5
5
  export declare function useTypesRender<K extends TagType>(currentProps: TypesElement<TagType>, props: TypesElement<K>, key: string): void;
6
6
  export declare function useSectionRender<K extends TagType>(currentProps: SectionElement<TagType>, props: SectionElement<K>, key: string): void;
package/editor.d.ts CHANGED
@@ -2,35 +2,37 @@
2
2
 
3
3
  declare module '@uiw/react-json-view/editor' {
4
4
  import { JsonViewProps } from '@uiw/react-json-view';
5
- import type { CountInfoExtraProps } from '@uiw/react-json-view/cjs/editor/countInfoExtra';
5
+ // import type { CountInfoExtraProps } from '@uiw/react-json-view/cjs/editor/countInfoExtra';
6
6
  type Option = {
7
- value: string;
8
- prevValue: string;
9
- keyName: string | number;
7
+ value: string;
8
+ prevValue: string;
9
+ keyName: string | number;
10
10
  };
11
11
 
12
12
  export interface JsonViewEditorProps<T extends object> extends JsonViewProps<T> {
13
13
  /** Callback when value edit functionality */
14
14
  onEdit?: (option: {
15
- value: unknown;
16
- oldValue: unknown;
17
- keyName?: string | number;
18
- parentName?: string | number;
19
- type?: 'value' | 'key';
15
+ value: unknown;
16
+ oldValue: unknown;
17
+ keyName?: string | number;
18
+ parentName?: string | number;
19
+ type?: 'value' | 'key';
20
20
  }) => void;
21
- /**
22
- * When a callback function is passed in, add functionality is enabled. The callback is invoked before additions are completed.
23
- * @returns {boolean} Returning false from onAdd will prevent the change from being made.
24
- */
25
- onAdd?: CountInfoExtraProps<T>['onAdd'];
26
- /**
27
- * When a callback function is passed in, delete functionality is enabled. The callback is invoked before deletions are completed.
28
- * @returns Returning false from onDelete will prevent the change from being made.
29
- */
30
- onDelete?: CountInfoExtraProps<T>['onDelete'];
21
+ // /**
22
+ // * When a callback function is passed in, add functionality is enabled. The callback is invoked before additions are completed.
23
+ // * @returns {boolean} Returning false from onAdd will prevent the change from being made.
24
+ // */
25
+ // onAdd?: CountInfoExtraProps<T>['onAdd'];
26
+ // /**
27
+ // * When a callback function is passed in, delete functionality is enabled. The callback is invoked before deletions are completed.
28
+ // * @returns Returning false from onDelete will prevent the change from being made.
29
+ // */
30
+ // onDelete?: CountInfoExtraProps<T>['onDelete'];
31
31
  /** Whether enable edit feature. @default true */
32
32
  editable?: boolean;
33
33
  }
34
- const JsonViewEditor: import("react").ForwardRefExoticComponent<Omit<JsonViewEditorProps<object>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
34
+ const JsonViewEditor: import('react').ForwardRefExoticComponent<
35
+ Omit<JsonViewEditorProps<object>, 'ref'> & import('react').RefAttributes<HTMLDivElement>
36
+ >;
35
37
  export default JsonViewEditor;
36
38
  }
@@ -6,5 +6,7 @@ export interface ContainerProps<T extends object> extends React.HTMLAttributes<H
6
6
  level?: number;
7
7
  value?: T;
8
8
  initialValue?: T;
9
+ /** Index of the parent `keyName` */
10
+ keys?: (string | number)[];
9
11
  }
10
12
  export declare const Container: React.ForwardRefExoticComponent<ContainerProps<object> & React.RefAttributes<HTMLDivElement>>;
package/esm/Container.js CHANGED
@@ -1,24 +1,26 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["className", "children", "parentValue", "keyid", "level", "value", "initialValue", "keyName"];
4
- import React, { forwardRef, useId } from 'react';
3
+ var _excluded = ["className", "children", "parentValue", "keyid", "level", "value", "initialValue", "keys", "keyName"];
4
+ import React, { forwardRef } from 'react';
5
5
  import { NestedClose } from './comps/NestedClose';
6
6
  import { NestedOpen } from './comps/NestedOpen';
7
7
  import { KeyValues } from './comps/KeyValues';
8
+ import { useIdCompat } from './comps/useIdCompat';
8
9
  import { useShowToolsDispatch } from './store/ShowTools';
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  export var Container = /*#__PURE__*/forwardRef((props, ref) => {
12
12
  var {
13
13
  className = '',
14
+ parentValue,
14
15
  level = 1,
15
16
  value,
16
17
  initialValue,
18
+ keys,
17
19
  keyName
18
20
  } = props,
19
21
  elmProps = _objectWithoutPropertiesLoose(props, _excluded);
20
22
  var dispatch = useShowToolsDispatch();
21
- var subkeyid = useId();
23
+ var subkeyid = useIdCompat();
22
24
  var defaultClassNames = [className, 'w-rjv-inner'].filter(Boolean).join(' ');
23
25
  var reset = {
24
26
  onMouseEnter: () => dispatch({
@@ -36,16 +38,22 @@ export var Container = /*#__PURE__*/forwardRef((props, ref) => {
36
38
  expandKey: subkeyid,
37
39
  value: value,
38
40
  level: level,
41
+ keys: keys,
42
+ parentValue: parentValue,
39
43
  keyName: keyName,
40
44
  initialValue: initialValue
41
45
  }), /*#__PURE__*/_jsx(KeyValues, {
42
46
  expandKey: subkeyid,
43
47
  value: value,
44
- level: level
48
+ level: level,
49
+ keys: keys,
50
+ parentValue: parentValue,
51
+ keyName: keyName
45
52
  }), /*#__PURE__*/_jsx(NestedClose, {
46
53
  expandKey: subkeyid,
47
54
  value: value,
48
- level: level
55
+ level: level,
56
+ keys: keys
49
57
  })]
50
58
  }));
51
59
  });