@uiw/react-json-view 1.11.1 → 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 -263
  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 -13
  233. package/cjs/node.js +0 -329
  234. package/cjs/semicolon.d.ts +0 -22
  235. package/cjs/semicolon.js +0 -115
  236. package/cjs/value.d.ts +0 -84
  237. package/cjs/value.js +0 -348
  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 -13
  258. package/esm/node.js +0 -287
  259. package/esm/semicolon.d.ts +0 -22
  260. package/esm/value.d.ts +0 -84
  261. package/esm/value.js +0 -324
package/cjs/semicolon.js DELETED
@@ -1,115 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Semicolon = void 0;
8
- exports.useHighlight = useHighlight;
9
- exports.usePrevious = usePrevious;
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
- var _react = require("react");
14
- var _value = require("./value");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- var _excluded = ["children", "render", "color", "value", "className", "keyName", "highlightUpdates", "quotes", "style", "namespace", "parentName"];
17
- function usePrevious(value) {
18
- var ref = (0, _react.useRef)();
19
- (0, _react.useEffect)(function () {
20
- ref.current = value;
21
- });
22
- return ref.current;
23
- }
24
- function useHighlight(_ref) {
25
- var value = _ref.value,
26
- highlightUpdates = _ref.highlightUpdates,
27
- highlightContainer = _ref.highlightContainer;
28
- var prevValue = usePrevious(value);
29
- var isHighlight = (0, _react.useMemo)(function () {
30
- if (!highlightUpdates || prevValue === undefined) return false;
31
- // highlight if value type changed
32
- if ((0, _typeof2["default"])(value) !== (0, _typeof2["default"])(prevValue)) {
33
- return true;
34
- }
35
- if (typeof value === 'number') {
36
- // notice: NaN !== NaN
37
- if (isNaN(value) && isNaN(prevValue)) return false;
38
- return value !== prevValue;
39
- }
40
- // highlight if isArray changed
41
- if (Array.isArray(value) !== Array.isArray(prevValue)) {
42
- return true;
43
- }
44
- // not highlight object/function
45
- // deep compare they will be slow
46
- if ((0, _typeof2["default"])(value) === 'object' || typeof value === 'function') {
47
- return false;
48
- }
49
-
50
- // highlight if not equal
51
- if (value !== prevValue) {
52
- return true;
53
- }
54
- return false;
55
- }, [highlightUpdates, value]);
56
- (0, _react.useEffect)(function () {
57
- if (highlightContainer && highlightContainer.current && isHighlight && 'animate' in highlightContainer.current) {
58
- highlightContainer.current.animate([{
59
- backgroundColor: 'var(--w-rjv-update-color, #ebcb8b)'
60
- }, {
61
- backgroundColor: ''
62
- }], {
63
- duration: 1000,
64
- easing: 'ease-in'
65
- });
66
- }
67
- }, [isHighlight, value, highlightContainer]);
68
- }
69
- var Semicolon = function Semicolon(_ref2) {
70
- var children = _ref2.children,
71
- render = _ref2.render,
72
- color = _ref2.color,
73
- value = _ref2.value,
74
- _ref2$className = _ref2.className,
75
- className = _ref2$className === void 0 ? 'w-rjv-object-key' : _ref2$className,
76
- keyName = _ref2.keyName,
77
- highlightUpdates = _ref2.highlightUpdates,
78
- quotes = _ref2.quotes,
79
- style = _ref2.style,
80
- namespace = _ref2.namespace,
81
- parentName = _ref2.parentName,
82
- props = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
83
- var highlightContainer = (0, _react.useRef)(null);
84
- var content = typeof keyName === 'string' ? "".concat(quotes).concat(keyName).concat(quotes) : keyName;
85
- if (render) {
86
- return render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({
87
- className: className
88
- }, props), {}, {
89
- value: value,
90
- namespace: namespace,
91
- style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, style), {}, {
92
- color: color
93
- }),
94
- parentName: parentName,
95
- keyName: keyName,
96
- quotes: quotes,
97
- label: keyName,
98
- children: content
99
- }));
100
- }
101
- useHighlight({
102
- value: value,
103
- highlightUpdates: highlightUpdates,
104
- highlightContainer: highlightContainer
105
- });
106
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
107
- className: className,
108
- color: color
109
- }, props), {}, {
110
- ref: highlightContainer,
111
- children: content
112
- }));
113
- };
114
- exports.Semicolon = Semicolon;
115
- Semicolon.displayName = 'JSR.Semicolon';
package/cjs/value.d.ts DELETED
@@ -1,84 +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
- NaN: {
39
- color: string;
40
- label: string;
41
- };
42
- undefined: {
43
- color: string;
44
- label: string;
45
- };
46
- };
47
- export declare const Colon: FC<PropsWithChildren<React.HTMLAttributes<HTMLSpanElement>>>;
48
- export interface ValueViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
49
- keyName?: string | number;
50
- value?: unknown;
51
- parentValue?: T;
52
- data?: T;
53
- displayDataTypes: boolean;
54
- displayObjectSize: boolean;
55
- enableClipboard: boolean;
56
- indentWidth: number;
57
- level?: number;
58
- shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
59
- namespace?: Array<string | number>;
60
- quotes?: JsonViewProps<T>['quotes'];
61
- components?: JsonViewProps<T>['components'];
62
- renderKey?: JSX.Element;
63
- countInfo?: JSX.Element;
64
- setValue?: React.Dispatch<React.SetStateAction<T>>;
65
- }
66
- export declare function getValueString<T>(value: T): {
67
- type: "string" | "number" | "bigint" | "boolean" | "undefined" | "date" | "url" | "float" | "null" | "NaN";
68
- content: string;
69
- };
70
- export declare function ValueView<T extends object>(props: ValueViewProps<T>): import("react/jsx-runtime").JSX.Element;
71
- export declare namespace ValueView {
72
- var displayName: string;
73
- }
74
- export interface LabelProps extends React.HTMLAttributes<HTMLSpanElement> {
75
- color?: string;
76
- fontSize?: number;
77
- opacity?: number;
78
- paddingRight?: number;
79
- }
80
- export declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLSpanElement>>;
81
- export interface TypeProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
82
- type: keyof typeof typeMap;
83
- }
84
- export declare const Type: FC<PropsWithChildren<TypeProps>>;
package/cjs/value.js DELETED
@@ -1,348 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Type = exports.Line = exports.Label = exports.Colon = void 0;
8
- exports.ValueView = ValueView;
9
- exports.getValueString = getValueString;
10
- exports.typeMap = exports.isFloat = void 0;
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
14
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
- var _react = require("react");
16
- var _meta = require("./comps/meta");
17
- var _copied = require("./copied");
18
- var _jsxRuntime = require("react/jsx-runtime");
19
- var _excluded = ["children", "style"],
20
- _excluded2 = ["children", "length", "style"],
21
- _excluded3 = ["color", "style", "isURL", "href", "children"],
22
- _excluded4 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes", "shortenTextAfterLength"],
23
- _excluded5 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
24
- var Line = function Line(props) {
25
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _objectSpread2["default"])({}, props));
26
- };
27
- exports.Line = Line;
28
- Line.displayName = 'JVR.Line';
29
- var isFloat = function isFloat(n) {
30
- return Number(n) === n && n % 1 !== 0 || isNaN(n);
31
- };
32
- exports.isFloat = isFloat;
33
- var typeMap = {
34
- string: {
35
- color: 'var(--w-rjv-type-string-color, #cb4b16)',
36
- label: 'string'
37
- },
38
- number: {
39
- color: 'var(--w-rjv-type-int-color, #268bd2)',
40
- label: 'int'
41
- },
42
- "float": {
43
- color: 'var(--w-rjv-type-float-color, #859900)',
44
- label: 'float'
45
- },
46
- bigint: {
47
- color: 'var(--w-rjv-type-bigint-color, #268bd2)',
48
- label: 'bigint'
49
- },
50
- "boolean": {
51
- color: 'var(--w-rjv-type-boolean-color, #2aa198)',
52
- label: 'bool'
53
- },
54
- date: {
55
- color: 'var(--w-rjv-type-date-color, #586e75)',
56
- label: 'date'
57
- },
58
- url: {
59
- color: 'var(--w-rjv-type-url-color, #0969da)',
60
- label: 'url'
61
- },
62
- "null": {
63
- color: 'var(--w-rjv-type-null-color, #d33682)',
64
- label: 'null'
65
- },
66
- NaN: {
67
- color: 'var(--w-rjv-type-nan-color, #859900)',
68
- label: 'NaN'
69
- },
70
- undefined: {
71
- color: 'var(--w-rjv-type-undefined-color, #586e75)',
72
- label: 'undefined'
73
- }
74
- };
75
- exports.typeMap = typeMap;
76
- var Colon = function Colon(_ref) {
77
- var _ref$children = _ref.children,
78
- children = _ref$children === void 0 ? ':' : _ref$children,
79
- style = _ref.style,
80
- props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
81
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
82
- className: "w-rjv-colon",
83
- style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
84
- paddingRight: 3
85
- }, style), {}, {
86
- color: 'var(--w-rjv-colon-color, var(--w-rjv-color))'
87
- })
88
- }, props), {}, {
89
- children: children
90
- }));
91
- };
92
- exports.Colon = Colon;
93
- Colon.displayName = 'JVR.Colon';
94
- function getValueString(value) {
95
- var type = (0, _typeof2["default"])(value);
96
- var content = '';
97
- if (typeof value === 'number') {
98
- type = isFloat(value) ? 'float' : 'number';
99
- content = value.toString();
100
- if (isNaN(value)) {
101
- type = 'NaN';
102
- content = 'NaN';
103
- }
104
- }
105
- if (typeof value === 'boolean') {
106
- type = 'boolean';
107
- content = value.toString();
108
- }
109
- if ((0, _typeof2["default"])(value) === 'object' && value instanceof Date) {
110
- type = 'date';
111
- content = value.toString();
112
- }
113
- if (value === null) {
114
- type = 'null';
115
- content = "".concat(value).toLocaleUpperCase();
116
- }
117
- if (value === undefined) {
118
- type = 'undefined';
119
- content = String(value);
120
- }
121
- if (typeof value === 'bigint') {
122
- type = 'bigint';
123
- content = "".concat(value, "n");
124
- }
125
- var isURL = value instanceof URL;
126
- if (isURL) {
127
- type = 'url';
128
- content = "\"".concat(value.href, "\"");
129
- }
130
- if (typeof value === 'string') {
131
- content = "\"".concat(value, "\"");
132
- }
133
- return {
134
- type: type,
135
- content: content
136
- };
137
- }
138
- var RenderShortenTextValue = function RenderShortenTextValue(_ref2) {
139
- var children = _ref2.children,
140
- length = _ref2.length,
141
- style = _ref2.style,
142
- rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2);
143
- var childrenStr = children;
144
- var _useState = (0, _react.useState)(length && childrenStr.length >= length),
145
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
146
- shorten = _useState2[0],
147
- setShorten = _useState2[1];
148
- var click = function click() {
149
- console.log(shorten);
150
- if (length && childrenStr.length <= length) return setShorten(false);
151
- setShorten(!shorten);
152
- };
153
- var text = shorten ? "".concat(childrenStr.slice(0, length), "...") : childrenStr;
154
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderStringValue, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, rest), {}, {
155
- style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, style), {}, {
156
- cursor: 'pointer'
157
- }),
158
- onClick: click,
159
- children: text
160
- }));
161
- };
162
- RenderShortenTextValue.displayName = 'JVR.RenderShortenTextValue';
163
- var RenderStringValue = function RenderStringValue(_ref3) {
164
- var color = _ref3.color,
165
- style = _ref3.style,
166
- isURL = _ref3.isURL,
167
- href = _ref3.href,
168
- children = _ref3.children,
169
- rest = (0, _objectWithoutProperties2["default"])(_ref3, _excluded3);
170
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
171
- color: color,
172
- style: style
173
- }, rest), {}, {
174
- className: "w-rjv-value",
175
- children: [isURL && /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
176
- href: href,
177
- style: {
178
- color: color
179
- },
180
- target: "_blank",
181
- rel: "noopener noreferrer",
182
- children: children
183
- }), !isURL && children]
184
- }));
185
- };
186
- RenderStringValue.displayName = 'JVR.RenderStringValue';
187
- function ValueView(props) {
188
- var _typeMap$type;
189
- var value = props.value,
190
- parentValue = props.parentValue,
191
- setValue = props.setValue,
192
- countInfo = props.countInfo,
193
- data = props.data,
194
- keyName = props.keyName,
195
- indentWidth = props.indentWidth,
196
- namespace = props.namespace,
197
- renderKey = props.renderKey,
198
- _props$components = props.components,
199
- components = _props$components === void 0 ? {} : _props$components,
200
- quotes = props.quotes,
201
- level = props.level,
202
- enableClipboard = props.enableClipboard,
203
- displayObjectSize = props.displayObjectSize,
204
- displayDataTypes = props.displayDataTypes,
205
- shortenTextAfterLength = props.shortenTextAfterLength,
206
- reset = (0, _objectWithoutProperties2["default"])(props, _excluded4);
207
- var color = '';
208
- var style = {};
209
- var _getValueString = getValueString(value),
210
- type = _getValueString.type,
211
- content = _getValueString.content;
212
- var typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(Type, {
213
- type: type
214
- });
215
- if (value === null) {
216
- typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
217
- style = {
218
- fontWeight: 'bold'
219
- };
220
- }
221
- if (value === undefined || type.toLocaleLowerCase() === 'nan' || !displayDataTypes) {
222
- typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
223
- }
224
- var isURL = value instanceof URL;
225
- color = ((_typeMap$type = typeMap[type]) === null || _typeMap$type === void 0 ? void 0 : _typeMap$type.color) || '';
226
- var _useState3 = (0, _react.useState)(false),
227
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
228
- showTools = _useState4[0],
229
- setShowTools = _useState4[1];
230
- var tools = (0, _react.useMemo)(function () {
231
- return enableClipboard && showTools && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copied.Copied, {
232
- show: showTools,
233
- text: value
234
- });
235
- }, [enableClipboard, showTools, value]);
236
- // const tools = enableClipboard ? <Copied show={showTools} text={value} /> : undefined;
237
- var eventProps = {
238
- className: 'w-rjv-line',
239
- style: {
240
- paddingLeft: indentWidth
241
- }
242
- };
243
- if (enableClipboard) {
244
- eventProps.onMouseEnter = function () {
245
- return setShowTools(true);
246
- };
247
- eventProps.onMouseLeave = function () {
248
- return setShowTools(false);
249
- };
250
- }
251
- if (content && typeof content === 'string') {
252
- var reView = components.value && components.value({
253
- className: 'w-rjv-value',
254
- style: (0, _objectSpread2["default"])({
255
- color: color
256
- }, style),
257
- type: type,
258
- value: value,
259
- setValue: setValue,
260
- data: data,
261
- parentValue: parentValue,
262
- quotes: quotes,
263
- keyName: keyName,
264
- namespace: namespace,
265
- visible: showTools,
266
- content: content,
267
- children: content
268
- });
269
- var valueView = shortenTextAfterLength && type === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderShortenTextValue, {
270
- color: color,
271
- href: isURL ? value.href : '',
272
- style: style,
273
- isURL: isURL,
274
- length: shortenTextAfterLength,
275
- children: content
276
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderStringValue, {
277
- color: color,
278
- href: isURL ? value.href : '',
279
- style: style,
280
- isURL: isURL,
281
- children: content
282
- });
283
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, eventProps), {}, {
284
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
285
- ref: null,
286
- children: [renderKey, /*#__PURE__*/(0, _jsxRuntime.jsx)(Colon, {}), typeView, reView ? reView : valueView, tools]
287
- }))
288
- }));
289
- }
290
- var empty = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
291
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_meta.Meta, {
292
- render: components.braces,
293
- start: true,
294
- isArray: Array.isArray(value)
295
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_meta.Meta, {
296
- render: components.braces,
297
- isArray: Array.isArray(value)
298
- }), countInfo]
299
- });
300
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, eventProps), {}, {
301
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
302
- ref: null,
303
- children: [renderKey, /*#__PURE__*/(0, _jsxRuntime.jsx)(Colon, {}), typeView, empty, tools]
304
- }))
305
- }));
306
- }
307
- ValueView.displayName = 'JVR.ValueView';
308
- var Label = /*#__PURE__*/(0, _react.forwardRef)(function (_ref4, ref) {
309
- var children = _ref4.children,
310
- color = _ref4.color,
311
- fontSize = _ref4.fontSize,
312
- opacity = _ref4.opacity,
313
- paddingRight = _ref4.paddingRight,
314
- style = _ref4.style,
315
- reset = (0, _objectWithoutProperties2["default"])(_ref4, _excluded5);
316
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
317
- style: (0, _objectSpread2["default"])({
318
- color: color,
319
- fontSize: fontSize,
320
- opacity: opacity,
321
- paddingRight: paddingRight
322
- }, style)
323
- }, reset), {}, {
324
- ref: ref,
325
- children: children
326
- }));
327
- });
328
- exports.Label = Label;
329
- Label.displayName = 'JVR.Label';
330
- var Type = function Type(props) {
331
- var _typeMap$type2, _typeMap$type3;
332
- var type = props.type;
333
- var color = (_typeMap$type2 = typeMap[type]) === null || _typeMap$type2 === void 0 ? void 0 : _typeMap$type2.color;
334
- var label = (_typeMap$type3 = typeMap[type]) === null || _typeMap$type3 === void 0 ? void 0 : _typeMap$type3.label;
335
- if (color && label) {
336
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
337
- color: color,
338
- fontSize: 11,
339
- opacity: 0.8,
340
- paddingRight: 4,
341
- className: "w-rjv-type",
342
- "data-type": type,
343
- children: label
344
- });
345
- }
346
- };
347
- exports.Type = Type;
348
- Type.displayName = 'JVR.Type';
@@ -1,7 +0,0 @@
1
- import { FC, PropsWithChildren } from 'react';
2
- export interface EllipsisProps extends React.HTMLAttributes<HTMLSpanElement> {
3
- count: number;
4
- level: number;
5
- render?: (props: EllipsisProps) => JSX.Element;
6
- }
7
- export declare const Ellipsis: FC<PropsWithChildren<EllipsisProps>>;
@@ -1,31 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["style", "render", "count", "level"];
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- export var Ellipsis = _ref => {
6
- var {
7
- style,
8
- render,
9
- count,
10
- level
11
- } = _ref,
12
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
13
- var styl = _extends({
14
- cursor: 'pointer'
15
- }, style);
16
- var className = "w-rjv-ellipsis " + (props.className || '');
17
- if (render) return render(_extends({
18
- style: styl,
19
- count,
20
- level
21
- }, props, {
22
- className
23
- }));
24
- return /*#__PURE__*/_jsx("span", _extends({
25
- className: className,
26
- style: styl
27
- }, props, {
28
- children: "..."
29
- }));
30
- };
31
- Ellipsis.displayName = 'JVR.Ellipsis';
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- import { LabelProps } from '../value';
3
- export interface MetaProps extends LabelProps {
4
- isArray?: boolean;
5
- start?: boolean;
6
- level?: number;
7
- render?: (props: Pick<MetaProps, 'start' | 'level' | 'isArray' | 'className' | 'children'>) => JSX.Element;
8
- }
9
- export declare function Meta(props: MetaProps): JSX.Element;
10
- export declare namespace Meta {
11
- var displayName: string;
12
- }
package/esm/comps/meta.js DELETED
@@ -1,39 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["isArray", "start", "level", "className", "render"];
4
- import { Label } from '../value';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- export function Meta(props) {
7
- var {
8
- isArray = false,
9
- start = false,
10
- level,
11
- className,
12
- render
13
- } = props,
14
- reset = _objectWithoutPropertiesLoose(props, _excluded);
15
- var mark = isArray ? '[]' : '{}';
16
- var cls = "w-rjv-" + (isArray ? 'brackets' : 'curlybraces') + "-" + (start ? 'start' : 'end') + " " + (className || '');
17
- var color = "var(--w-rjv-" + (isArray ? 'brackets' : 'curlybraces') + "-color, #236a7c)";
18
- if (render) {
19
- var viev = render(_extends({
20
- isArray,
21
- level,
22
- className: cls,
23
- style: {
24
- color
25
- },
26
- children: start ? mark.charAt(0) : mark.charAt(1)
27
- }, reset));
28
- if (viev) {
29
- return viev;
30
- }
31
- }
32
- return /*#__PURE__*/_jsx(Label, _extends({
33
- color: color,
34
- className: cls
35
- }, reset, {
36
- children: start ? mark.charAt(0) : mark.charAt(1)
37
- }));
38
- }
39
- Meta.displayName = 'JVR.Meta';
package/esm/copied.d.ts DELETED
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- export interface CopiedProps<T = object> extends React.SVGProps<SVGSVGElement> {
3
- show?: boolean;
4
- text?: T;
5
- onCopied?: (text: string, obj: T | '') => void;
6
- render?: (props: Omit<CopiedProps<T>, 'render'>) => JSX.Element;
7
- }
8
- export declare function Copied<T>(props: CopiedProps<T>): JSX.Element | null;
9
- export declare namespace Copied {
10
- var displayName: string;
11
- }
@@ -1,28 +0,0 @@
1
- /// <reference types="react" />
2
- import type { CountInfoProps } from '../';
3
- export interface CountInfoExtraProps<T> extends Partial<CountInfoProps> {
4
- editable: boolean;
5
- showTools: boolean;
6
- value: T;
7
- parentValue?: T;
8
- keyName?: string | number;
9
- namespace?: Array<string | number>;
10
- setValue?: React.Dispatch<React.SetStateAction<T>>;
11
- setParentValue?: React.Dispatch<React.SetStateAction<T>>;
12
- /**
13
- * When a callback function is passed in, add functionality is enabled. The callback is invoked before additions are completed.
14
- * @returns {boolean} Returning false from onAdd will prevent the change from being made.
15
- */
16
- onAdd?: (keyOrValue: string, newValue: T, value: T, isAdd: boolean) => boolean;
17
- /**
18
- * When a callback function is passed in, delete functionality is enabled. The callback is invoked before deletions are completed.
19
- * @returns Returning false from onDelete will prevent the change from being made.
20
- */
21
- onDelete?: (keyName: string | number, value: T, parentValue: T | null, opt: {
22
- namespace?: Array<string | number>;
23
- }) => boolean;
24
- }
25
- export declare function CountInfoExtra<T extends object>(props: CountInfoExtraProps<T>): import("react/jsx-runtime").JSX.Element | null;
26
- export declare namespace CountInfoExtra {
27
- var displayName: string;
28
- }