@uiw/react-json-view 1.12.0 → 2.0.0-alpha.1

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 +256 -262
  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 +74 -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 +74 -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
@@ -1,30 +1,43 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["children", "style", "text", "onCopied", "render", "show"];
3
+ var _excluded = ["keyName", "value", "expandKey"],
4
+ _excluded2 = ["as", "render"];
4
5
  import { useState } from 'react';
6
+ import { useStore } from '../store';
7
+ import { useShowToolsStore } from '../store/ShowTools';
8
+ import { useSectionStore } from '../store/Section';
5
9
  import { jsx as _jsx } from "react/jsx-runtime";
6
- export function Copied(props) {
10
+ export var Copied = props => {
7
11
  var {
8
- style,
9
- text = '',
10
- onCopied,
11
- render,
12
- show
12
+ keyName,
13
+ value,
14
+ expandKey
13
15
  } = props,
14
- reset = _objectWithoutPropertiesLoose(props, _excluded);
15
- if (!show) return null;
16
+ other = _objectWithoutPropertiesLoose(props, _excluded);
17
+ var {
18
+ onCopied,
19
+ enableClipboard
20
+ } = useStore();
21
+ var showTools = useShowToolsStore();
22
+ var isShowTools = showTools[expandKey];
16
23
  var [copied, setCopied] = useState(false);
24
+ var {
25
+ Copied: Comp = {}
26
+ } = useSectionStore();
27
+ if (enableClipboard === false || !isShowTools) return null;
17
28
  var click = event => {
18
29
  event.stopPropagation();
19
- var copyText = JSON.stringify(text || '', (key, value) => {
30
+ var copyText = JSON.stringify(value, (key, value) => {
20
31
  if (typeof value === 'bigint') {
21
32
  return value.toString();
22
33
  }
23
34
  return value;
24
35
  }, 2);
25
- if (text === Infinity) copyText = Infinity;
36
+ if (typeof value === 'number' && value === Infinity) copyText = 'Infinity';
37
+ if (typeof value === 'number' && isNaN(value)) copyText = 'NaN';
38
+ if (typeof value === 'bigint') copyText = value + 'n';
26
39
  navigator.clipboard.writeText(copyText).then(() => {
27
- onCopied && onCopied(copyText, text);
40
+ onCopied && onCopied(copyText, value);
28
41
  setCopied(true);
29
42
  var timer = setTimeout(() => {
30
43
  setCopied(false);
@@ -32,25 +45,27 @@ export function Copied(props) {
32
45
  }, 3000);
33
46
  }).catch(error => {});
34
47
  };
35
- var defalutStyle = _extends({}, style, {
36
- cursor: 'pointer',
37
- verticalAlign: 'middle',
38
- marginLeft: 5
48
+ var svgProps = {
49
+ fill: copied ? 'var(--w-rjv-copied-success-color, #28a745)' : 'var(--w-rjv-copied-color, currentColor)',
50
+ onClick: click
51
+ };
52
+ var {
53
+ render
54
+ } = Comp,
55
+ reset = _objectWithoutPropertiesLoose(Comp, _excluded2);
56
+ var elmProps = _extends({}, reset, other, svgProps);
57
+ var isRender = render && typeof render === 'function';
58
+ var child = isRender && render(_extends({}, elmProps, {
59
+ 'data-copied': copied
60
+ }), {
61
+ value,
62
+ keyName
39
63
  });
40
- var svgProps = _extends({
41
- height: '1em',
42
- width: '1em',
43
- fill: 'var(--w-rjv-copied-color, currentColor)',
44
- onClick: click,
45
- style: defalutStyle,
46
- className: 'w-rjv-copied'
47
- }, reset);
48
- if (render) return render(_extends({}, props, svgProps));
64
+ if (child) return child;
49
65
  if (copied) {
50
66
  return /*#__PURE__*/_jsx("svg", _extends({
51
67
  viewBox: "0 0 32 36"
52
- }, svgProps, {
53
- fill: "var(--w-rjv-copied-success-color, #28a745)",
68
+ }, elmProps, {
54
69
  children: /*#__PURE__*/_jsx("path", {
55
70
  d: "M27.5,33 L2.5,33 L2.5,12.5 L27.5,12.5 L27.5,15.2249049 C29.1403264,13.8627542 29.9736597,13.1778155 30,13.1700887 C30,11.9705278 30,10.0804982 30,7.5 C30,6.1 28.9,5 27.5,5 L20,5 C20,2.2 17.8,0 15,0 C12.2,0 10,2.2 10,5 L2.5,5 C1.1,5 0,6.1 0,7.5 L0,33 C0,34.4 1.1,36 2.5,36 L27.5,36 C28.9,36 30,34.4 30,33 L30,26.1114493 L27.5,28.4926435 L27.5,33 Z M7.5,7.5 L10,7.5 C10,7.5 12.5,6.4 12.5,5 C12.5,3.6 13.6,2.5 15,2.5 C16.4,2.5 17.5,3.6 17.5,5 C17.5,6.4 18.8,7.5 20,7.5 L22.5,7.5 C22.5,7.5 25,8.6 25,10 L5,10 C5,8.5 6.1,7.5 7.5,7.5 Z M5,27.5 L10,27.5 L10,25 L5,25 L5,27.5 Z M28.5589286,16 L32,19.6 L21.0160714,30.5382252 L13.5303571,24.2571429 L17.1303571,20.6571429 L21.0160714,24.5428571 L28.5589286,16 Z M17.5,15 L5,15 L5,17.5 L17.5,17.5 L17.5,15 Z M10,20 L5,20 L5,22.5 L10,22.5 L10,20 Z"
56
71
  })
@@ -58,10 +73,10 @@ export function Copied(props) {
58
73
  }
59
74
  return /*#__PURE__*/_jsx("svg", _extends({
60
75
  viewBox: "0 0 32 36"
61
- }, svgProps, {
76
+ }, elmProps, {
62
77
  children: /*#__PURE__*/_jsx("path", {
63
78
  d: "M27.5,33 L2.5,33 L2.5,12.5 L27.5,12.5 L27.5,20 L30,20 L30,7.5 C30,6.1 28.9,5 27.5,5 L20,5 C20,2.2 17.8,0 15,0 C12.2,0 10,2.2 10,5 L2.5,5 C1.1,5 0,6.1 0,7.5 L0,33 C0,34.4 1.1,36 2.5,36 L27.5,36 C28.9,36 30,34.4 30,33 L30,29 L27.5,29 L27.5,33 Z M7.5,7.5 L10,7.5 C10,7.5 12.5,6.4 12.5,5 C12.5,3.6 13.6,2.5 15,2.5 C16.4,2.5 17.5,3.6 17.5,5 C17.5,6.4 18.8,7.5 20,7.5 L22.5,7.5 C22.5,7.5 25,8.6 25,10 L5,10 C5,8.5 6.1,7.5 7.5,7.5 Z M5,27.5 L10,27.5 L10,25 L5,25 L5,27.5 Z M22.5,21.5 L22.5,16.5 L12.5,24 L22.5,31.5 L22.5,26.5 L32,26.5 L32,21.5 L22.5,21.5 Z M17.5,15 L5,15 L5,17.5 L17.5,17.5 L17.5,15 Z M10,20 L5,20 L5,22.5 L10,22.5 L10,20 Z"
64
79
  })
65
80
  }));
66
- }
81
+ };
67
82
  Copied.displayName = 'JVR.Copied';
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { type SectionElementProps } from '../store/Section';
3
+ import { type TagType } from '../store/Types';
4
+ export interface CountInfoProps<T extends object> {
5
+ value?: T;
6
+ keyName: string | number;
7
+ }
8
+ export declare const CountInfo: {
9
+ <T extends object>(props: SectionElementProps<TagType> & CountInfoProps<T> & import("react").HTMLAttributes<HTMLElement>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
10
+ displayName: string;
11
+ };
12
+ export interface CountInfoExtraProps<T extends object> {
13
+ value?: T;
14
+ keyName: string | number;
15
+ }
16
+ export declare const CountInfoExtra: {
17
+ <T extends object>(props: SectionElementProps<TagType> & CountInfoExtraProps<T>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
18
+ displayName: string;
19
+ };
@@ -0,0 +1,70 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["value", "keyName"],
4
+ _excluded2 = ["as", "render"],
5
+ _excluded3 = ["value", "keyName"],
6
+ _excluded4 = ["as", "render"];
7
+ import { useStore } from '../store';
8
+ import { useSectionStore } from '../store/Section';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ export var CountInfo = props => {
11
+ var {
12
+ value = {},
13
+ keyName
14
+ } = props,
15
+ other = _objectWithoutPropertiesLoose(props, _excluded);
16
+ var {
17
+ displayObjectSize
18
+ } = useStore();
19
+ var {
20
+ CountInfo: Comp = {}
21
+ } = useSectionStore();
22
+ if (!displayObjectSize) return null;
23
+ var {
24
+ as,
25
+ render
26
+ } = Comp,
27
+ reset = _objectWithoutPropertiesLoose(Comp, _excluded2);
28
+ var Elm = as || 'span';
29
+ reset.style = _extends({}, reset.style, props.style);
30
+ var len = Object.keys(value).length;
31
+ if (!reset.children) {
32
+ reset.children = len + " items";
33
+ }
34
+ var elmProps = _extends({}, reset, other);
35
+ var isRender = render && typeof render === 'function';
36
+ var child = isRender && render(_extends({}, elmProps, {
37
+ 'data-length': len
38
+ }), {
39
+ value,
40
+ keyName
41
+ });
42
+ if (child) return child;
43
+ return /*#__PURE__*/_jsx(Elm, _extends({}, elmProps));
44
+ };
45
+ CountInfo.displayName = 'JVR.CountInfo';
46
+ export var CountInfoExtra = props => {
47
+ var {
48
+ value = {},
49
+ keyName
50
+ } = props,
51
+ other = _objectWithoutPropertiesLoose(props, _excluded3);
52
+ var {
53
+ CountInfoExtra: Comp = {}
54
+ } = useSectionStore();
55
+ var {
56
+ as,
57
+ render
58
+ } = Comp,
59
+ reset = _objectWithoutPropertiesLoose(Comp, _excluded4);
60
+ var Elm = as || 'span';
61
+ var isRender = render && typeof render === 'function';
62
+ var elmProps = _extends({}, reset, other);
63
+ var child = isRender && render(elmProps, {
64
+ value,
65
+ keyName
66
+ });
67
+ if (child) return child;
68
+ return /*#__PURE__*/_jsx(Elm, _extends({}, elmProps));
69
+ };
70
+ CountInfoExtra.displayName = 'JVR.CountInfoExtra';
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ export interface CountInfoProps<T extends object> {
3
+ value?: T;
4
+ keyName: string | number;
5
+ isExpanded: boolean;
6
+ }
7
+ export declare const Ellipsis: {
8
+ <T extends object>({ isExpanded, value, keyName }: CountInfoProps<T>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
9
+ displayName: string;
10
+ };
@@ -0,0 +1,31 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["as", "render"];
4
+ import { useSectionStore } from '../store/Section';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export var Ellipsis = _ref => {
7
+ var {
8
+ isExpanded,
9
+ value,
10
+ keyName
11
+ } = _ref;
12
+ var {
13
+ Ellipsis: Comp = {}
14
+ } = useSectionStore();
15
+ var {
16
+ as,
17
+ render
18
+ } = Comp,
19
+ reset = _objectWithoutPropertiesLoose(Comp, _excluded);
20
+ var Elm = as || 'span';
21
+ var child = render && typeof render === 'function' && render(_extends({}, reset, {
22
+ 'data-expanded': isExpanded
23
+ }), {
24
+ value,
25
+ keyName
26
+ });
27
+ if (child) return child;
28
+ if (!isExpanded) return null;
29
+ return /*#__PURE__*/_jsx(Elm, _extends({}, reset));
30
+ };
31
+ Ellipsis.displayName = 'JVR.Ellipsis';
@@ -0,0 +1,7 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ type KeyProps = {
3
+ keyName: string | number;
4
+ value?: unknown;
5
+ };
6
+ export declare const Key: FC<PropsWithChildren<KeyProps>>;
7
+ export {};
@@ -0,0 +1,35 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["as", "render"];
4
+ import { useSectionStore } from '../store/Section';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export var Key = props => {
7
+ var {
8
+ children,
9
+ value,
10
+ keyName
11
+ } = props;
12
+ var isNumber = typeof children === 'number';
13
+ var style = {
14
+ color: isNumber ? 'var(--w-rjv-key-number, #268bd2)' : 'var(--w-rjv-key-string, #002b36)'
15
+ };
16
+ var {
17
+ KeyName: Comp = {}
18
+ } = useSectionStore();
19
+ var {
20
+ as,
21
+ render
22
+ } = Comp,
23
+ reset = _objectWithoutPropertiesLoose(Comp, _excluded);
24
+ reset.style = _extends({}, reset.style, style);
25
+ var Elm = as || 'span';
26
+ var child = render && typeof render === 'function' && render(reset, {
27
+ value,
28
+ keyName
29
+ });
30
+ if (child) return child;
31
+ return /*#__PURE__*/_jsx(Elm, _extends({}, reset, {
32
+ children: children
33
+ }));
34
+ };
35
+ Key.displayName = 'JVR.Key';
@@ -0,0 +1,22 @@
1
+ interface KeyValuesProps<T extends object> {
2
+ keyName?: string | number;
3
+ value?: T;
4
+ parentValue?: T;
5
+ expandKey?: string;
6
+ level: number;
7
+ }
8
+ export declare const KeyValues: {
9
+ <T extends object>(props: KeyValuesProps<T>): import("react/jsx-runtime").JSX.Element | null;
10
+ displayName: string;
11
+ };
12
+ interface KayNameProps<T extends object> extends Omit<KeyValuesProps<T>, 'level'> {
13
+ }
14
+ export declare const KayName: {
15
+ <T extends object>(props: KayNameProps<T>): import("react/jsx-runtime").JSX.Element;
16
+ displayName: string;
17
+ };
18
+ export declare const KeyValuesItem: {
19
+ <T extends object>(props: KeyValuesProps<T>): import("react/jsx-runtime").JSX.Element;
20
+ displayName: string;
21
+ };
22
+ export {};
@@ -0,0 +1,142 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import { Fragment, useId, useRef } from 'react';
3
+ import { useStore } from '../store';
4
+ import { useExpandsStore } from '../store/Expands';
5
+ import { useShowToolsDispatch } from '../store/ShowTools';
6
+ import { Value } from './Value';
7
+ import { Key } from './Key';
8
+ import { Container } from '../Container';
9
+ import { Quote, Colon } from './ReRender/Symbols';
10
+ import { useHighlight } from '../utils/useHighlight';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ export var KeyValues = props => {
14
+ var _expands$expandKey;
15
+ var {
16
+ value,
17
+ expandKey = '',
18
+ level
19
+ } = props;
20
+ var expands = useExpandsStore();
21
+ var {
22
+ objectSortKeys,
23
+ indentWidth,
24
+ collapsed
25
+ } = useStore();
26
+ var isMyArray = Array.isArray(value);
27
+ var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
28
+ if (isExpanded) {
29
+ return null;
30
+ }
31
+ // object
32
+ var entries = isMyArray ? Object.entries(value).map(m => [Number(m[0]), m[1]]) : Object.entries(value);
33
+ if (objectSortKeys) {
34
+ entries = objectSortKeys === true ? entries.sort((_ref, _ref2) => {
35
+ var [a] = _ref;
36
+ var [b] = _ref2;
37
+ return typeof a === 'string' && typeof b === 'string' ? a.localeCompare(b) : 0;
38
+ }) : entries.sort((_ref3, _ref4) => {
39
+ var [a] = _ref3;
40
+ var [b] = _ref4;
41
+ return typeof a === 'string' && typeof b === 'string' ? objectSortKeys(a, b) : 0;
42
+ });
43
+ }
44
+ var style = {
45
+ borderLeft: 'var(--w-rjv-border-left-width, 1px) var(--w-rjv-line-style, solid) var(--w-rjv-line-color, #ebebeb)',
46
+ paddingLeft: indentWidth,
47
+ marginLeft: 6
48
+ };
49
+ return /*#__PURE__*/_jsx("div", {
50
+ className: "w-rjv-wrap",
51
+ style: style,
52
+ children: entries.map((_ref5, idx) => {
53
+ var [key, val] = _ref5;
54
+ return /*#__PURE__*/_jsx(KeyValuesItem, {
55
+ parentValue: value,
56
+ keyName: key,
57
+ value: val,
58
+ level: level
59
+ }, idx);
60
+ })
61
+ });
62
+ };
63
+ KeyValues.displayName = 'JVR.KeyValues';
64
+ export var KayName = props => {
65
+ var {
66
+ keyName,
67
+ value
68
+ } = props;
69
+ var {
70
+ highlightUpdates
71
+ } = useStore();
72
+ var isNumber = typeof keyName === 'number';
73
+ var highlightContainer = useRef(null);
74
+ useHighlight({
75
+ value,
76
+ highlightUpdates,
77
+ highlightContainer
78
+ });
79
+ return /*#__PURE__*/_jsxs(Fragment, {
80
+ children: [/*#__PURE__*/_jsxs("span", {
81
+ ref: highlightContainer,
82
+ children: [/*#__PURE__*/_jsx(Quote, {
83
+ isNumber: isNumber
84
+ }), /*#__PURE__*/_jsx(Key, {
85
+ keyName: keyName,
86
+ value: value,
87
+ children: keyName
88
+ }), /*#__PURE__*/_jsx(Quote, {
89
+ isNumber: isNumber
90
+ })]
91
+ }), /*#__PURE__*/_jsx(Colon, {})]
92
+ });
93
+ };
94
+ KayName.displayName = 'JVR.KayName';
95
+ export var KeyValuesItem = props => {
96
+ var {
97
+ keyName,
98
+ value,
99
+ parentValue,
100
+ level = 0
101
+ } = props;
102
+ var dispatch = useShowToolsDispatch();
103
+ var subkeyid = useId();
104
+ var isMyArray = Array.isArray(value);
105
+ var isMySet = value instanceof Set;
106
+ var isMyMap = value instanceof Map;
107
+ var isDate = value instanceof Date;
108
+ var isUrl = value instanceof URL;
109
+ var isMyObject = value && typeof value === 'object' && !isMyArray && !isMySet && !isMyMap && !isDate && !isUrl;
110
+ var isNested = isMyObject || isMyArray || isMySet || isMyMap;
111
+ if (isNested) {
112
+ var myValue = isMySet ? Array.from(value) : isMyMap ? Object.fromEntries(value) : value;
113
+ return /*#__PURE__*/_jsx(Container, {
114
+ keyName: keyName,
115
+ value: myValue,
116
+ parentValue: parentValue,
117
+ initialValue: value,
118
+ level: level + 1
119
+ });
120
+ }
121
+ var reset = {
122
+ onMouseEnter: () => dispatch({
123
+ [subkeyid]: true
124
+ }),
125
+ onMouseLeave: () => dispatch({
126
+ [subkeyid]: false
127
+ })
128
+ };
129
+ return /*#__PURE__*/_jsxs("div", _extends({
130
+ className: "w-rjv-line"
131
+ }, reset, {
132
+ children: [/*#__PURE__*/_jsx(KayName, {
133
+ keyName: keyName,
134
+ value: value
135
+ }), /*#__PURE__*/_jsx(Value, {
136
+ keyName: keyName,
137
+ value: value,
138
+ expandKey: subkeyid
139
+ })]
140
+ }));
141
+ };
142
+ KeyValuesItem.displayName = 'JVR.KeyValuesItem';
@@ -0,0 +1,10 @@
1
+ interface NestedCloseProps<T extends object> {
2
+ value?: T;
3
+ expandKey: string;
4
+ level: number;
5
+ }
6
+ export declare const NestedClose: {
7
+ <T extends object>(props: NestedCloseProps<T>): import("react/jsx-runtime").JSX.Element | null;
8
+ displayName: string;
9
+ };
10
+ export {};
@@ -0,0 +1,34 @@
1
+ import { useStore } from '../store';
2
+ import { useExpandsStore } from '../store/Expands';
3
+ import { BracketsClose } from './ReRender/Symbols';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export var NestedClose = props => {
6
+ var _expands$expandKey;
7
+ var {
8
+ value,
9
+ expandKey,
10
+ level
11
+ } = props;
12
+ var expands = useExpandsStore();
13
+ var isArray = Array.isArray(value);
14
+ var {
15
+ collapsed
16
+ } = useStore();
17
+ var isMySet = value instanceof Set;
18
+ var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
19
+ var len = Object.keys(value).length;
20
+ if (isExpanded || len === 0) {
21
+ return null;
22
+ }
23
+ var style = {
24
+ paddingLeft: 4
25
+ };
26
+ return /*#__PURE__*/_jsx("div", {
27
+ style: style,
28
+ children: /*#__PURE__*/_jsx(BracketsClose, {
29
+ isBrackets: isArray || isMySet,
30
+ isVisiable: true
31
+ })
32
+ });
33
+ };
34
+ NestedClose.displayName = 'JVR.NestedClose';
@@ -0,0 +1,11 @@
1
+ export interface NestedOpenProps<T extends object> {
2
+ keyName?: string | number;
3
+ value?: T;
4
+ initialValue?: T;
5
+ expandKey: string;
6
+ level: number;
7
+ }
8
+ export declare const NestedOpen: {
9
+ <T extends object>(props: NestedOpenProps<T>): import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
@@ -0,0 +1,91 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import { KayName } from './KeyValues';
3
+ import { useExpandsStore, useExpandsDispatch } from '../store/Expands';
4
+ import { useStore } from '../store';
5
+ import { Copied } from './Copied';
6
+ import { CountInfo, CountInfoExtra } from './CountInfo';
7
+ import { Arrow, BracketsOpen, BracketsClose } from './ReRender/Symbols';
8
+ import { Ellipsis } from './Ellipsis';
9
+ import { SetComp, MapComp } from './ReRender/Types';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ export var NestedOpen = props => {
13
+ var _expands$expandKey;
14
+ var {
15
+ keyName,
16
+ expandKey,
17
+ initialValue,
18
+ value,
19
+ level
20
+ } = props;
21
+ var expands = useExpandsStore();
22
+ var dispatchExpands = useExpandsDispatch();
23
+ var {
24
+ onExpand,
25
+ collapsed
26
+ } = useStore();
27
+ var isArray = Array.isArray(value);
28
+ var isMySet = value instanceof Set;
29
+ var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
30
+ var isObject = typeof value === 'object';
31
+ var click = () => {
32
+ var opt = {
33
+ expand: !isExpanded,
34
+ value,
35
+ keyid: expandKey,
36
+ keyName
37
+ };
38
+ onExpand && onExpand(opt);
39
+ dispatchExpands({
40
+ [expandKey]: opt.expand
41
+ });
42
+ };
43
+ var style = {
44
+ display: 'inline-flex',
45
+ alignItems: 'center'
46
+ };
47
+ var arrowStyle = {
48
+ transform: "rotate(" + (!isExpanded ? '0' : '-90') + "deg)",
49
+ transition: 'all 0.3s'
50
+ };
51
+ var len = Object.keys(value).length;
52
+ var showArrow = len !== 0 && (isArray || isMySet || isObject);
53
+ var reset = {
54
+ style
55
+ };
56
+ if (showArrow) {
57
+ reset.onClick = click;
58
+ }
59
+ return /*#__PURE__*/_jsxs("span", _extends({}, reset, {
60
+ children: [showArrow && /*#__PURE__*/_jsx(Arrow, {
61
+ style: arrowStyle,
62
+ expandKey: expandKey
63
+ }), (keyName || typeof keyName === 'number') && /*#__PURE__*/_jsx(KayName, {
64
+ keyName: keyName
65
+ }), /*#__PURE__*/_jsx(SetComp, {
66
+ isSet: initialValue instanceof Set
67
+ }), /*#__PURE__*/_jsx(MapComp, {
68
+ isMap: initialValue instanceof Map
69
+ }), /*#__PURE__*/_jsx(BracketsOpen, {
70
+ isBrackets: isArray || isMySet
71
+ }), /*#__PURE__*/_jsx(Ellipsis, {
72
+ keyName: keyName,
73
+ value: value,
74
+ isExpanded: isExpanded
75
+ }), /*#__PURE__*/_jsx(BracketsClose, {
76
+ isVisiable: isExpanded || !showArrow,
77
+ isBrackets: isArray || isMySet
78
+ }), /*#__PURE__*/_jsx(CountInfo, {
79
+ value: value,
80
+ keyName: keyName
81
+ }), /*#__PURE__*/_jsx(CountInfoExtra, {
82
+ value: value,
83
+ keyName: keyName
84
+ }), /*#__PURE__*/_jsx(Copied, {
85
+ keyName: keyName,
86
+ value: value,
87
+ expandKey: expandKey
88
+ })]
89
+ }));
90
+ };
91
+ NestedOpen.displayName = 'JVR.NestedOpen';
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import { type SymbolsElement } from '../../store/Symbols';
3
+ import { type TagType } from '../../store/Types';
4
+ export declare const Quote: {
5
+ (props: {
6
+ isNumber?: boolean | undefined;
7
+ }): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
8
+ displayName: string;
9
+ };
10
+ export declare const ValueQuote: {
11
+ (props: {
12
+ isNumber?: boolean | undefined;
13
+ }): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
14
+ displayName: string;
15
+ };
16
+ export declare const Colon: {
17
+ (): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
18
+ displayName: string;
19
+ };
20
+ export declare const Arrow: {
21
+ <T extends TagType>(props: {
22
+ as?: T | undefined;
23
+ render?: ((props: SymbolsElement<T>) => import("react").ReactNode) | undefined;
24
+ 'data-type'?: string | undefined;
25
+ } & import("react").PropsWithoutRef<import("react").ComponentProps<T>> & {
26
+ expandKey: string;
27
+ }): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
28
+ displayName: string;
29
+ };
30
+ export declare const BracketsOpen: {
31
+ ({ isBrackets }: {
32
+ isBrackets?: boolean | undefined;
33
+ }): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
34
+ displayName: string;
35
+ };
36
+ type BracketsCloseProps = {
37
+ isBrackets?: boolean;
38
+ isVisiable?: boolean;
39
+ };
40
+ export declare const BracketsClose: {
41
+ ({ isBrackets, isVisiable }: BracketsCloseProps): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
42
+ displayName: string;
43
+ };
44
+ export {};