@uiw/react-json-view 1.12.0 → 2.0.0-alpha.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.
Files changed (261) hide show
  1. package/README.md +249 -265
  2. package/cjs/Container.d.ts +10 -0
  3. package/cjs/Container.js +67 -0
  4. package/cjs/arrow/TriangleArrow.js +3 -1
  5. package/cjs/arrow/TriangleSolidArrow.js +7 -3
  6. package/cjs/comps/Copied.d.ts +16 -0
  7. package/cjs/{copied.js → comps/Copied.js} +44 -32
  8. package/cjs/comps/CountInfo.d.ts +19 -0
  9. package/cjs/comps/CountInfo.js +72 -0
  10. package/cjs/comps/Ellipsis.d.ts +10 -0
  11. package/cjs/comps/Ellipsis.js +35 -0
  12. package/cjs/comps/Key.d.ts +7 -0
  13. package/cjs/comps/Key.js +39 -0
  14. package/cjs/comps/KeyValues.d.ts +22 -0
  15. package/cjs/comps/KeyValues.js +156 -0
  16. package/cjs/comps/NestedClose.d.ts +10 -0
  17. package/cjs/comps/NestedClose.js +38 -0
  18. package/cjs/comps/NestedOpen.d.ts +11 -0
  19. package/cjs/comps/NestedOpen.js +95 -0
  20. package/cjs/comps/ReRender/Symbols.d.ts +44 -0
  21. package/cjs/comps/ReRender/Symbols.js +144 -0
  22. package/cjs/comps/ReRender/Types.d.ts +36 -0
  23. package/cjs/comps/ReRender/Types.js +590 -0
  24. package/cjs/comps/Value.d.ts +11 -0
  25. package/cjs/comps/Value.js +78 -0
  26. package/cjs/index.d.ts +72 -52
  27. package/cjs/index.js +147 -27
  28. package/cjs/section/Copied.d.ts +6 -0
  29. package/cjs/section/Copied.js +17 -0
  30. package/cjs/section/CountInfo.d.ts +6 -0
  31. package/cjs/section/CountInfo.js +17 -0
  32. package/cjs/section/CountInfoExtra.d.ts +6 -0
  33. package/cjs/section/CountInfoExtra.js +17 -0
  34. package/cjs/section/Ellipsis.d.ts +6 -0
  35. package/cjs/section/Ellipsis.js +17 -0
  36. package/cjs/section/KeyName.d.ts +6 -0
  37. package/cjs/section/KeyName.js +17 -0
  38. package/cjs/store/Expands.d.ts +16 -0
  39. package/cjs/store/Expands.js +44 -0
  40. package/cjs/store/Section.d.ts +33 -0
  41. package/cjs/store/Section.js +86 -0
  42. package/cjs/store/ShowTools.d.ts +14 -0
  43. package/cjs/store/ShowTools.js +44 -0
  44. package/cjs/store/Symbols.d.ts +37 -0
  45. package/cjs/store/Symbols.js +112 -0
  46. package/cjs/store/Types.d.ts +52 -0
  47. package/cjs/store/Types.js +162 -0
  48. package/cjs/store.d.ts +29 -5
  49. package/cjs/store.js +96 -46
  50. package/cjs/symbol/Arrow.d.ts +6 -0
  51. package/cjs/symbol/Arrow.js +17 -0
  52. package/cjs/symbol/BraceLeft.d.ts +6 -0
  53. package/cjs/symbol/BraceLeft.js +17 -0
  54. package/cjs/symbol/BraceRight.d.ts +6 -0
  55. package/cjs/symbol/BraceRight.js +17 -0
  56. package/cjs/symbol/BracketsLeft.d.ts +6 -0
  57. package/cjs/symbol/BracketsLeft.js +17 -0
  58. package/cjs/symbol/BracketsRight.d.ts +6 -0
  59. package/cjs/symbol/BracketsRight.js +17 -0
  60. package/cjs/symbol/Colon.d.ts +6 -0
  61. package/cjs/symbol/Colon.js +17 -0
  62. package/cjs/symbol/Quote.d.ts +6 -0
  63. package/cjs/symbol/Quote.js +17 -0
  64. package/cjs/symbol/ValueQuote.d.ts +6 -0
  65. package/cjs/symbol/ValueQuote.js +17 -0
  66. package/cjs/theme/basic.js +3 -0
  67. package/cjs/theme/dark.js +3 -0
  68. package/cjs/theme/github.dark.js +3 -0
  69. package/cjs/theme/github.light.js +3 -0
  70. package/cjs/theme/gruvbox.js +3 -0
  71. package/cjs/theme/light.js +3 -0
  72. package/cjs/theme/monokai.js +3 -0
  73. package/cjs/theme/nord.js +3 -0
  74. package/cjs/theme/vscode.js +3 -0
  75. package/cjs/type.d.ts +50 -0
  76. package/cjs/type.js +57 -0
  77. package/cjs/types/Bigint.d.ts +5 -0
  78. package/cjs/types/Bigint.js +17 -0
  79. package/cjs/types/Date.d.ts +5 -0
  80. package/cjs/types/Date.js +17 -0
  81. package/cjs/types/False.d.ts +5 -0
  82. package/cjs/types/False.js +17 -0
  83. package/cjs/types/Float.d.ts +5 -0
  84. package/cjs/types/Float.js +17 -0
  85. package/cjs/types/Int.d.ts +5 -0
  86. package/cjs/types/Int.js +17 -0
  87. package/cjs/types/Map.d.ts +5 -0
  88. package/cjs/types/Map.js +17 -0
  89. package/cjs/types/Nan.d.ts +5 -0
  90. package/cjs/types/Nan.js +17 -0
  91. package/cjs/types/Null.d.ts +5 -0
  92. package/cjs/types/Null.js +17 -0
  93. package/cjs/types/Set.d.ts +5 -0
  94. package/cjs/types/Set.js +17 -0
  95. package/cjs/types/String.d.ts +5 -0
  96. package/cjs/types/String.js +17 -0
  97. package/cjs/types/True.d.ts +5 -0
  98. package/cjs/types/True.js +17 -0
  99. package/cjs/types/Undefined.d.ts +5 -0
  100. package/cjs/types/Undefined.js +17 -0
  101. package/cjs/types/Url.d.ts +5 -0
  102. package/cjs/types/Url.js +17 -0
  103. package/cjs/utils/useHighlight.d.ts +9 -0
  104. package/cjs/utils/useHighlight.js +62 -0
  105. package/cjs/utils/useRender.d.ts +6 -0
  106. package/cjs/utils/useRender.js +51 -0
  107. package/esm/Container.d.ts +10 -0
  108. package/esm/Container.js +53 -0
  109. package/esm/arrow/TriangleArrow.js +3 -1
  110. package/esm/arrow/TriangleSolidArrow.js +7 -3
  111. package/esm/comps/Copied.d.ts +16 -0
  112. package/esm/{copied.js → comps/Copied.js} +44 -29
  113. package/esm/comps/CountInfo.d.ts +19 -0
  114. package/esm/comps/CountInfo.js +70 -0
  115. package/esm/comps/Ellipsis.d.ts +10 -0
  116. package/esm/comps/Ellipsis.js +31 -0
  117. package/esm/comps/Key.d.ts +7 -0
  118. package/esm/comps/Key.js +35 -0
  119. package/esm/comps/KeyValues.d.ts +22 -0
  120. package/esm/comps/KeyValues.js +142 -0
  121. package/esm/comps/NestedClose.d.ts +10 -0
  122. package/esm/comps/NestedClose.js +34 -0
  123. package/esm/comps/NestedOpen.d.ts +11 -0
  124. package/esm/comps/NestedOpen.js +91 -0
  125. package/esm/comps/ReRender/Symbols.d.ts +44 -0
  126. package/esm/comps/ReRender/Symbols.js +155 -0
  127. package/esm/comps/ReRender/Types.d.ts +36 -0
  128. package/esm/comps/ReRender/Types.js +621 -0
  129. package/esm/comps/Value.d.ts +11 -0
  130. package/esm/comps/Value.js +69 -0
  131. package/esm/index.d.ts +72 -52
  132. package/esm/index.js +98 -18
  133. package/esm/section/Copied.d.ts +6 -0
  134. package/esm/section/Copied.js +10 -0
  135. package/esm/section/CountInfo.d.ts +6 -0
  136. package/esm/section/CountInfo.js +10 -0
  137. package/esm/section/CountInfoExtra.d.ts +6 -0
  138. package/esm/section/CountInfoExtra.js +10 -0
  139. package/esm/section/Ellipsis.d.ts +6 -0
  140. package/esm/section/Ellipsis.js +10 -0
  141. package/esm/section/KeyName.d.ts +6 -0
  142. package/esm/section/KeyName.js +10 -0
  143. package/esm/store/Expands.d.ts +16 -0
  144. package/esm/store/Expands.js +32 -0
  145. package/esm/store/Section.d.ts +33 -0
  146. package/esm/store/Section.js +73 -0
  147. package/esm/store/ShowTools.d.ts +14 -0
  148. package/esm/store/ShowTools.js +32 -0
  149. package/esm/store/Symbols.d.ts +37 -0
  150. package/esm/store/Symbols.js +100 -0
  151. package/esm/store/Types.d.ts +52 -0
  152. package/esm/store/Types.js +150 -0
  153. package/esm/store.d.ts +29 -5
  154. package/esm/store.js +66 -32
  155. package/esm/symbol/Arrow.d.ts +6 -0
  156. package/esm/symbol/Arrow.js +10 -0
  157. package/esm/symbol/BraceLeft.d.ts +6 -0
  158. package/esm/symbol/BraceLeft.js +10 -0
  159. package/esm/symbol/BraceRight.d.ts +6 -0
  160. package/esm/symbol/BraceRight.js +10 -0
  161. package/esm/symbol/BracketsLeft.d.ts +6 -0
  162. package/esm/symbol/BracketsLeft.js +10 -0
  163. package/esm/symbol/BracketsRight.d.ts +6 -0
  164. package/esm/symbol/BracketsRight.js +10 -0
  165. package/esm/symbol/Colon.d.ts +6 -0
  166. package/esm/symbol/Colon.js +10 -0
  167. package/esm/symbol/Quote.d.ts +6 -0
  168. package/esm/symbol/Quote.js +10 -0
  169. package/esm/symbol/ValueQuote.d.ts +6 -0
  170. package/esm/symbol/ValueQuote.js +10 -0
  171. package/esm/theme/basic.js +3 -0
  172. package/esm/theme/dark.js +3 -0
  173. package/esm/theme/github.dark.js +3 -0
  174. package/esm/theme/github.light.js +3 -0
  175. package/esm/theme/gruvbox.js +3 -0
  176. package/esm/theme/light.js +3 -0
  177. package/esm/theme/monokai.js +3 -0
  178. package/esm/theme/nord.js +3 -0
  179. package/esm/theme/vscode.js +3 -0
  180. package/esm/type.d.ts +50 -0
  181. package/esm/type.js +50 -0
  182. package/esm/types/Bigint.d.ts +5 -0
  183. package/esm/types/Bigint.js +10 -0
  184. package/esm/types/Date.d.ts +5 -0
  185. package/esm/types/Date.js +10 -0
  186. package/esm/types/False.d.ts +5 -0
  187. package/esm/types/False.js +10 -0
  188. package/esm/types/Float.d.ts +5 -0
  189. package/esm/types/Float.js +10 -0
  190. package/esm/types/Int.d.ts +5 -0
  191. package/esm/types/Int.js +10 -0
  192. package/esm/types/Map.d.ts +5 -0
  193. package/esm/types/Map.js +10 -0
  194. package/esm/types/Nan.d.ts +5 -0
  195. package/esm/types/Nan.js +10 -0
  196. package/esm/types/Null.d.ts +5 -0
  197. package/esm/types/Null.js +10 -0
  198. package/esm/types/Set.d.ts +5 -0
  199. package/esm/types/Set.js +10 -0
  200. package/esm/types/String.d.ts +5 -0
  201. package/esm/types/String.js +10 -0
  202. package/esm/types/True.d.ts +5 -0
  203. package/esm/types/True.js +10 -0
  204. package/esm/types/Undefined.d.ts +5 -0
  205. package/esm/types/Undefined.js +10 -0
  206. package/esm/types/Url.d.ts +5 -0
  207. package/esm/types/Url.js +10 -0
  208. package/esm/utils/useHighlight.d.ts +9 -0
  209. package/esm/{semicolon.js → utils/useHighlight.js} +1 -52
  210. package/esm/utils/useRender.d.ts +6 -0
  211. package/esm/utils/useRender.js +41 -0
  212. package/package.json +1 -1
  213. package/cjs/comps/ellipsis.d.ts +0 -7
  214. package/cjs/comps/ellipsis.js +0 -37
  215. package/cjs/comps/meta.d.ts +0 -12
  216. package/cjs/comps/meta.js +0 -46
  217. package/cjs/copied.d.ts +0 -11
  218. package/cjs/editor/countInfoExtra.d.ts +0 -28
  219. package/cjs/editor/countInfoExtra.js +0 -101
  220. package/cjs/editor/icon/add.d.ts +0 -4
  221. package/cjs/editor/icon/add.js +0 -30
  222. package/cjs/editor/icon/delete.d.ts +0 -4
  223. package/cjs/editor/icon/delete.js +0 -30
  224. package/cjs/editor/icon/edit.d.ts +0 -4
  225. package/cjs/editor/icon/edit.js +0 -30
  226. package/cjs/editor/index.d.ts +0 -31
  227. package/cjs/editor/index.js +0 -60
  228. package/cjs/editor/objectKey.d.ts +0 -11
  229. package/cjs/editor/objectKey.js +0 -169
  230. package/cjs/editor/value.d.ts +0 -22
  231. package/cjs/editor/value.js +0 -240
  232. package/cjs/node.d.ts +0 -15
  233. package/cjs/node.js +0 -343
  234. package/cjs/semicolon.d.ts +0 -22
  235. package/cjs/semicolon.js +0 -115
  236. package/cjs/value.d.ts +0 -93
  237. package/cjs/value.js +0 -356
  238. package/esm/comps/ellipsis.d.ts +0 -7
  239. package/esm/comps/ellipsis.js +0 -31
  240. package/esm/comps/meta.d.ts +0 -12
  241. package/esm/comps/meta.js +0 -39
  242. package/esm/copied.d.ts +0 -11
  243. package/esm/editor/countInfoExtra.d.ts +0 -28
  244. package/esm/editor/countInfoExtra.js +0 -68
  245. package/esm/editor/icon/add.d.ts +0 -4
  246. package/esm/editor/icon/add.js +0 -24
  247. package/esm/editor/icon/delete.d.ts +0 -4
  248. package/esm/editor/icon/delete.js +0 -24
  249. package/esm/editor/icon/edit.d.ts +0 -4
  250. package/esm/editor/icon/edit.js +0 -24
  251. package/esm/editor/index.d.ts +0 -31
  252. package/esm/editor/index.js +0 -47
  253. package/esm/editor/objectKey.d.ts +0 -11
  254. package/esm/editor/objectKey.js +0 -135
  255. package/esm/editor/value.d.ts +0 -22
  256. package/esm/editor/value.js +0 -192
  257. package/esm/node.d.ts +0 -15
  258. package/esm/node.js +0 -299
  259. package/esm/semicolon.d.ts +0 -22
  260. package/esm/value.d.ts +0 -93
  261. package/esm/value.js +0 -331
package/esm/node.js DELETED
@@ -1,299 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "shortenTextAfterLength", "collapsed", "level", "keyid", "quotes", "namespace", "isSet", "isMap", "onCopied", "onExpand", "parentValue", "setParentValue"];
4
- import { Fragment, useId, cloneElement, useState, useEffect, forwardRef } from 'react';
5
- import { ValueView, Type, Colon, Label, Line, typeMap } from './value';
6
- import { TriangleArrow } from './arrow/TriangleArrow';
7
- import { useExpandsStatus, store } from './store';
8
- import { Semicolon } from './semicolon';
9
- import { Copied } from './copied';
10
- import { Ellipsis } from './comps/ellipsis';
11
- import { Meta } from './comps/meta';
12
- import { jsxs as _jsxs } from "react/jsx-runtime";
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- function getLength(obj) {
15
- try {
16
- return Object.keys(obj).length;
17
- } catch (error) {
18
- return -1;
19
- }
20
- }
21
- export var CountInfo = _ref => {
22
- var {
23
- children
24
- } = _ref;
25
- return /*#__PURE__*/_jsxs(Label, {
26
- style: {
27
- paddingLeft: 4,
28
- fontStyle: 'italic'
29
- },
30
- color: "var(--w-rjv-info-color, #0000004d)",
31
- className: "w-rjv-object-size",
32
- children: [children, " items"]
33
- });
34
- };
35
- CountInfo.displayName = 'JVR.CountInfo';
36
- export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
37
- var _expands$keyid;
38
- var {
39
- value = {},
40
- keyName,
41
- className,
42
- displayDataTypes = true,
43
- components = {},
44
- displayObjectSize = true,
45
- enableClipboard = true,
46
- highlightUpdates = true,
47
- objectSortKeys = false,
48
- indentWidth = 15,
49
- shortenTextAfterLength = 20,
50
- collapsed,
51
- level = 1,
52
- keyid = 'root',
53
- quotes = '"',
54
- namespace = [],
55
- isSet = false,
56
- isMap = false,
57
- onCopied,
58
- onExpand,
59
- parentValue,
60
- setParentValue
61
- } = props,
62
- reset = _objectWithoutPropertiesLoose(props, _excluded);
63
- var isArray = Array.isArray(value);
64
- var subkeyid = useId();
65
- var expands = useExpandsStatus();
66
- var expand = (_expands$keyid = expands[keyid]) != null ? _expands$keyid : typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level <= collapsed : true;
67
- var handle = () => {
68
- onExpand && typeof onExpand === 'function' && onExpand({
69
- expand: !expand,
70
- keyid,
71
- keyName,
72
- value: value
73
- });
74
- !expand ? store.expand(keyid) : store.collapse(keyid);
75
- };
76
- var [valueData, setValueData] = useState(value);
77
- var subNodeProps = {
78
- components,
79
- indentWidth,
80
- displayDataTypes,
81
- displayObjectSize,
82
- enableClipboard,
83
- highlightUpdates,
84
- onCopied,
85
- onExpand,
86
- collapsed,
87
- parentValue: value,
88
- setParentValue: setValueData,
89
- quotes,
90
- level: level + 1,
91
- style: {
92
- paddingLeft: indentWidth
93
- }
94
- };
95
- var valueViewProps = {
96
- displayDataTypes,
97
- displayObjectSize,
98
- enableClipboard,
99
- shortenTextAfterLength,
100
- level: level + 1,
101
- parentValue: value,
102
- indentWidth,
103
- data: valueData,
104
- quotes,
105
- setValue: setValueData
106
- };
107
- var arrowStyle = {
108
- transform: "rotate(" + (expand ? '0' : '-90') + "deg)",
109
- transition: 'all 0.3s'
110
- };
111
- var arrowView = components.arrow ? /*#__PURE__*/cloneElement(components.arrow, {
112
- style: arrowStyle,
113
- 'data-expand': expand,
114
- className: 'w-rjv-arrow'
115
- }) : /*#__PURE__*/_jsx(TriangleArrow, {
116
- style: arrowStyle,
117
- className: "w-rjv-arrow"
118
- });
119
- var [showTools, setShowTools] = useState(false);
120
- var eventProps = {};
121
- if (enableClipboard) {
122
- eventProps.onMouseEnter = () => setShowTools(true);
123
- eventProps.onMouseLeave = () => setShowTools(false);
124
- }
125
- useEffect(() => setValueData(value), [value]);
126
- var nameKeys = isArray ? Object.keys(valueData).map(m => Number(m)) : Object.keys(valueData);
127
-
128
- // object
129
- var entries = isArray ? Object.entries(valueData).map(m => [Number(m[0]), m[1]]) : Object.entries(valueData);
130
- if (objectSortKeys) {
131
- entries = objectSortKeys === true ? entries.sort((_ref2, _ref3) => {
132
- var [a] = _ref2;
133
- var [b] = _ref3;
134
- return typeof a === 'string' && typeof b === 'string' ? a.localeCompare(b) : 0;
135
- }) : entries.sort((_ref4, _ref5) => {
136
- var [a] = _ref4;
137
- var [b] = _ref5;
138
- return typeof a === 'string' && typeof b === 'string' ? objectSortKeys(a, b) : 0;
139
- });
140
- }
141
- var countInfo = /*#__PURE__*/_jsx(CountInfo, {
142
- children: nameKeys.length
143
- });
144
- if (components.countInfo) {
145
- countInfo = components.countInfo({
146
- count: nameKeys.length,
147
- level,
148
- visible: expand
149
- }) || countInfo;
150
- }
151
- if (!displayObjectSize) countInfo = null;
152
- var countInfoExtra = components.countInfoExtra && components.countInfoExtra({
153
- count: nameKeys.length,
154
- level,
155
- showTools,
156
- keyName,
157
- visible: expand,
158
- value: valueData,
159
- namespace: [...namespace],
160
- parentValue,
161
- setParentValue,
162
- setValue: setValueData
163
- });
164
- return /*#__PURE__*/_jsxs("div", _extends({
165
- ref: ref
166
- }, reset, {
167
- className: className + " w-rjv-inner"
168
- }, eventProps, {
169
- children: [/*#__PURE__*/_jsxs(Line, {
170
- style: {
171
- display: 'inline-flex',
172
- alignItems: 'center'
173
- },
174
- onClick: handle,
175
- children: [arrowView, (typeof keyName === 'string' || typeof keyName === 'number') && /*#__PURE__*/_jsxs(Fragment, {
176
- children: [/*#__PURE__*/_jsx(Semicolon, {
177
- value: valueData,
178
- quotes: quotes,
179
- "data-keys": keyid,
180
- namespace: [...namespace],
181
- render: components.objectKey,
182
- keyName: keyName,
183
- parentName: keyName,
184
- color: typeof keyName === 'number' ? typeMap['number'].color : ''
185
- }), /*#__PURE__*/_jsx(Colon, {})]
186
- }), isSet && /*#__PURE__*/_jsx(Type, {
187
- type: "Set"
188
- }), isMap && /*#__PURE__*/_jsx(Type, {
189
- type: "Map"
190
- }), /*#__PURE__*/_jsx(Meta, {
191
- start: true,
192
- isArray: isArray,
193
- level: level,
194
- render: components.braces
195
- }), !expand && /*#__PURE__*/_jsx(Ellipsis, {
196
- render: components.ellipsis,
197
- count: nameKeys.length,
198
- level: level
199
- }), !expand && /*#__PURE__*/_jsx(Meta, {
200
- isArray: isArray,
201
- level: level,
202
- render: components.braces
203
- }), countInfo, countInfoExtra, enableClipboard && /*#__PURE__*/_jsx(Copied, {
204
- show: showTools,
205
- text: valueData,
206
- onCopied: onCopied,
207
- render: components == null ? void 0 : components.copied
208
- })]
209
- }), expand && /*#__PURE__*/_jsx(Line, {
210
- className: "w-rjv-content",
211
- style: {
212
- borderLeft: 'var(--w-rjv-border-left-width, 1px) var(--w-rjv-line-style, solid) var(--w-rjv-line-color, #ebebeb)',
213
- marginLeft: 6
214
- },
215
- children: entries.length > 0 && [...entries].map((_ref6, idx) => {
216
- var [key, itemVal] = _ref6;
217
- var item = itemVal;
218
- var isMySet = item instanceof Set;
219
- var isMyMap = item instanceof Map;
220
- var myValue = isMySet ? Array.from(item) : isMyMap ? Object.fromEntries(item) : item;
221
- var isEmpty = Array.isArray(myValue) && myValue.length === 0 || typeof myValue === 'object' && myValue && !(myValue instanceof Date) && Object.keys(myValue).length === 0;
222
- if ((Array.isArray(myValue) || isMySet || isMyMap) && !isEmpty) {
223
- var label = isArray ? idx : key;
224
- return /*#__PURE__*/_jsx(Line, {
225
- className: "w-rjv-wrap",
226
- children: /*#__PURE__*/_jsx(RootNode, _extends({
227
- value: myValue,
228
- isSet: isMySet,
229
- isMap: isMyMap,
230
- namespace: [...namespace, label],
231
- keyName: label,
232
- keyid: keyid + subkeyid + label
233
- }, subNodeProps))
234
- }, label + idx);
235
- }
236
- if (typeof myValue === 'object' && myValue && !(myValue instanceof Date) && !isEmpty) {
237
- return /*#__PURE__*/_jsx(Line, {
238
- className: "w-rjv-wrap",
239
- children: /*#__PURE__*/_jsx(RootNode, _extends({
240
- value: myValue,
241
- namespace: [...namespace, key],
242
- keyName: key,
243
- keyid: keyid + subkeyid + key
244
- }, subNodeProps))
245
- }, key + '' + idx);
246
- }
247
- if (typeof myValue === 'function') {
248
- return;
249
- }
250
- var renderKey = /*#__PURE__*/_jsx(Semicolon, {
251
- value: myValue,
252
- "data-keys": keyid,
253
- quotes: quotes,
254
- namespace: [...namespace, key],
255
- parentName: keyName,
256
- highlightUpdates: highlightUpdates,
257
- render: components.objectKey,
258
- color: typeof key === 'number' ? typeMap['number'].color : '',
259
- keyName: key
260
- });
261
- var length = Array.isArray(myValue) ? myValue.length : getLength(myValue);
262
- countInfo = /*#__PURE__*/_jsx(CountInfo, {
263
- children: length
264
- });
265
- if (components.countInfo) {
266
- countInfo = components.countInfo({
267
- count: length,
268
- level,
269
- visible: expand
270
- }) || countInfo;
271
- }
272
- return /*#__PURE__*/_jsx(ValueView, _extends({
273
- components: components,
274
- namespace: [...namespace, key]
275
- }, valueViewProps, {
276
- countInfo: countInfo,
277
- renderKey: renderKey,
278
- keyName: key,
279
- isSet: isSet,
280
- value: myValue
281
- }), idx);
282
- })
283
- }), expand && /*#__PURE__*/_jsx(Line, {
284
- style: {
285
- paddingLeft: 2
286
- },
287
- children: /*#__PURE__*/_jsx(Meta, {
288
- render: components.braces,
289
- isArray: isArray,
290
- level: level,
291
- style: {
292
- paddingLeft: 2,
293
- display: 'inline-block'
294
- }
295
- })
296
- })]
297
- }));
298
- });
299
- RootNode.displayName = 'JVR.RootNode';
@@ -1,22 +0,0 @@
1
- import type { FC, PropsWithChildren } from 'react';
2
- import type { LabelProps } from './value';
3
- import type { JsonViewProps } from './';
4
- export declare function usePrevious<T>(value: T): T | undefined;
5
- interface UseHighlight {
6
- value: any;
7
- highlightUpdates?: boolean;
8
- highlightContainer: React.MutableRefObject<HTMLSpanElement | null>;
9
- }
10
- export declare function useHighlight({ value, highlightUpdates, highlightContainer }: UseHighlight): void;
11
- export interface SemicolonProps extends LabelProps {
12
- highlightUpdates?: boolean;
13
- keyName?: string | number;
14
- parentName?: string | number;
15
- quotes?: JsonViewProps<object>['quotes'];
16
- value?: object;
17
- label?: string;
18
- namespace?: Array<string | number>;
19
- render?: (props: SemicolonProps) => React.ReactNode;
20
- }
21
- export declare const Semicolon: FC<PropsWithChildren<SemicolonProps>>;
22
- export {};
package/esm/value.d.ts DELETED
@@ -1,93 +0,0 @@
1
- import type { FC, PropsWithChildren } from 'react';
2
- import type { JsonViewProps } from './';
3
- export declare const Line: FC<PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>>;
4
- export declare const isFloat: (n: number) => boolean;
5
- export declare const typeMap: {
6
- string: {
7
- color: string;
8
- label: string;
9
- };
10
- number: {
11
- color: string;
12
- label: string;
13
- };
14
- float: {
15
- color: string;
16
- label: string;
17
- };
18
- bigint: {
19
- color: string;
20
- label: string;
21
- };
22
- boolean: {
23
- color: string;
24
- label: string;
25
- };
26
- date: {
27
- color: string;
28
- label: string;
29
- };
30
- url: {
31
- color: string;
32
- label: string;
33
- };
34
- null: {
35
- color: string;
36
- label: string;
37
- };
38
- Set: {
39
- color: string;
40
- label: string;
41
- };
42
- Map: {
43
- color: string;
44
- label: string;
45
- };
46
- NaN: {
47
- color: string;
48
- label: string;
49
- };
50
- undefined: {
51
- color: string;
52
- label: string;
53
- };
54
- };
55
- export declare const Colon: FC<PropsWithChildren<React.HTMLAttributes<HTMLSpanElement>>>;
56
- export interface ValueViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
57
- keyName?: string | number;
58
- value?: unknown;
59
- parentValue?: T;
60
- data?: T;
61
- displayDataTypes: boolean;
62
- displayObjectSize: boolean;
63
- enableClipboard: boolean;
64
- isSet: boolean;
65
- indentWidth: number;
66
- level?: number;
67
- shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
68
- namespace?: Array<string | number>;
69
- quotes?: JsonViewProps<T>['quotes'];
70
- components?: JsonViewProps<T>['components'];
71
- renderKey?: JSX.Element;
72
- countInfo?: JSX.Element;
73
- setValue?: React.Dispatch<React.SetStateAction<T>>;
74
- }
75
- export declare function getValueString<T>(value: T): {
76
- type: "string" | "number" | "bigint" | "boolean" | "undefined" | "date" | "url" | "float" | "null" | "Set" | "Map" | "NaN";
77
- content: string;
78
- };
79
- export declare function ValueView<T extends object>(props: ValueViewProps<T>): import("react/jsx-runtime").JSX.Element;
80
- export declare namespace ValueView {
81
- var displayName: string;
82
- }
83
- export interface LabelProps extends React.HTMLAttributes<HTMLSpanElement> {
84
- color?: string;
85
- fontSize?: number;
86
- opacity?: number;
87
- paddingRight?: number;
88
- }
89
- export declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLSpanElement>>;
90
- export interface TypeProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
91
- type: keyof typeof typeMap;
92
- }
93
- export declare const Type: FC<PropsWithChildren<TypeProps>>;