@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/comps/meta.js DELETED
@@ -1,46 +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.Meta = Meta;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _value = require("../value");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- var _excluded = ["isArray", "start", "level", "className", "render"];
13
- function Meta(props) {
14
- var _props$isArray = props.isArray,
15
- isArray = _props$isArray === void 0 ? false : _props$isArray,
16
- _props$start = props.start,
17
- start = _props$start === void 0 ? false : _props$start,
18
- level = props.level,
19
- className = props.className,
20
- render = props.render,
21
- reset = (0, _objectWithoutProperties2["default"])(props, _excluded);
22
- var mark = isArray ? '[]' : '{}';
23
- var cls = "w-rjv-".concat(isArray ? 'brackets' : 'curlybraces', "-").concat(start ? 'start' : 'end', " ").concat(className || '');
24
- var color = "var(--w-rjv-".concat(isArray ? 'brackets' : 'curlybraces', "-color, #236a7c)");
25
- if (render) {
26
- var viev = render((0, _objectSpread2["default"])({
27
- isArray: isArray,
28
- level: level,
29
- className: cls,
30
- style: {
31
- color: color
32
- },
33
- children: start ? mark.charAt(0) : mark.charAt(1)
34
- }, reset));
35
- if (viev) {
36
- return viev;
37
- }
38
- }
39
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
40
- color: color,
41
- className: cls
42
- }, reset), {}, {
43
- children: start ? mark.charAt(0) : mark.charAt(1)
44
- }));
45
- }
46
- Meta.displayName = 'JVR.Meta';
package/cjs/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
- }
@@ -1,101 +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.CountInfoExtra = CountInfoExtra;
8
- var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
- var _react = require("react");
14
- var _add = require("./icon/add");
15
- var _delete = require("./icon/delete");
16
- var _jsxRuntime = require("react/jsx-runtime");
17
- function CountInfoExtra(props) {
18
- var _ref, _ref2;
19
- var visible = props.visible,
20
- showTools = props.showTools,
21
- editable = props.editable,
22
- keyName = props.keyName,
23
- value = props.value,
24
- namespace = props.namespace,
25
- parentValue = props.parentValue,
26
- setValue = props.setValue,
27
- setParentValue = props.setParentValue,
28
- onAdd = props.onAdd,
29
- onDelete = props.onDelete;
30
- if (!visible || !showTools) return null;
31
- var click = function click(_x) {
32
- return (_ref = _ref || (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee(event) {
33
- var keyOrValue, isArray, isAdd, result, maybeAdd;
34
- return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
35
- while (1) switch (_context.prev = _context.next) {
36
- case 0:
37
- event.stopPropagation();
38
- keyOrValue = 'AddKeyOrValue';
39
- isArray = Array.isArray(value);
40
- isAdd = isArray ? true : !(keyOrValue in value);
41
- result = isArray ? [].concat((0, _toConsumableArray2["default"])(value), [keyOrValue]) : (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, value), {}, (0, _defineProperty2["default"])({}, keyOrValue, undefined));
42
- if (!(onAdd && setValue)) {
43
- _context.next = 10;
44
- break;
45
- }
46
- _context.next = 8;
47
- return onAdd(keyOrValue, result, props.value, isAdd);
48
- case 8:
49
- maybeAdd = _context.sent;
50
- if (maybeAdd) {
51
- setValue(result);
52
- }
53
- case 10:
54
- case "end":
55
- return _context.stop();
56
- }
57
- }, _callee);
58
- }))).apply(this, arguments);
59
- };
60
- var deleteHandle = function deleteHandle(_x2) {
61
- return (_ref2 = _ref2 || (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2(event) {
62
- var maybeDelete;
63
- return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
64
- while (1) switch (_context2.prev = _context2.next) {
65
- case 0:
66
- event.stopPropagation();
67
- if (!(onDelete && (keyName || typeof keyName === 'number') && parentValue)) {
68
- _context2.next = 6;
69
- break;
70
- }
71
- _context2.next = 4;
72
- return onDelete(keyName, value, parentValue, {
73
- namespace: namespace
74
- });
75
- case 4:
76
- maybeDelete = _context2.sent;
77
- if (maybeDelete && setParentValue) {
78
- if (Array.isArray(parentValue)) {
79
- parentValue.splice(keyName, 1);
80
- setParentValue((0, _toConsumableArray2["default"])(parentValue));
81
- } else if (keyName in parentValue) {
82
- delete parentValue[keyName];
83
- setParentValue((0, _objectSpread3["default"])({}, parentValue));
84
- }
85
- }
86
- case 6:
87
- case "end":
88
- return _context2.stop();
89
- }
90
- }, _callee2);
91
- }))).apply(this, arguments);
92
- };
93
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
94
- children: [editable && onAdd && /*#__PURE__*/(0, _jsxRuntime.jsx)(_add.AddIcon, {
95
- onClick: click
96
- }), editable && onDelete && parentValue && /*#__PURE__*/(0, _jsxRuntime.jsx)(_delete.DeleteIcon, {
97
- onClick: deleteHandle
98
- })]
99
- });
100
- }
101
- CountInfoExtra.displayName = 'JVR.CountInfoExtra';
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- export interface AddIconProps extends React.SVGAttributes<SVGElement> {
3
- }
4
- export declare const AddIcon: (props: AddIconProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,30 +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.AddIcon = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _jsxRuntime = require("react/jsx-runtime");
10
- var AddIcon = function AddIcon(props) {
11
- var style = props.style;
12
- var defaultStyle = {
13
- verticalAlign: 'middle',
14
- display: 'inline-block',
15
- cursor: 'pointer',
16
- marginLeft: 5,
17
- height: '1em',
18
- width: '1em'
19
- };
20
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
21
- viewBox: "0 0 40 40",
22
- fill: "var(--w-rjv-add-color, currentColor)"
23
- }, props), {}, {
24
- style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, style), defaultStyle),
25
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
26
- d: "M28.3940997,0 L11.625773,0 C4.34215619,0 0,4.34 0,11.62 L0,28.36 C0,35.66 4.34215619,40 11.625773,40 L28.3740897,40 C35.6577066,40 39.9999316,35.66 39.9999316,28.38 L39.9999316,11.62 C40.0198727,4.34 35.6777165,0 28.3940997,0 Z M30.12022,21.8947368 L21.9056145,21.8947368 L21.9056145,30.1052632 C21.9056145,31.1410526 21.0462404,32 20.0099363,32 C18.9736323,32 18.1142582,31.1410526 18.1142582,30.1052632 L18.1142582,21.8947368 L9.89965272,21.8947368 C8.86334865,21.8947368 8.00397454,21.0357895 8.00397454,20 C8.00397454,18.9642105 8.86334865,18.1052632 9.89965272,18.1052632 L18.1142582,18.1052632 L18.1142582,9.89473684 C18.1142582,8.85894737 18.9736323,8 20.0099363,8 C21.0462404,8 21.9056145,8.85894737 21.9056145,9.89473684 L21.9056145,18.1052632 L30.12022,18.1052632 C31.156524,18.1052632 32.0158982,18.9642105 32.0158982,20 C32.0158982,21.0357895 31.156524,21.8947368 30.12022,21.8947368 Z"
27
- })
28
- }));
29
- };
30
- exports.AddIcon = AddIcon;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- export interface DeleteIconProps extends React.SVGAttributes<SVGElement> {
3
- }
4
- export declare const DeleteIcon: (props: DeleteIconProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,30 +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.DeleteIcon = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _jsxRuntime = require("react/jsx-runtime");
10
- var DeleteIcon = function DeleteIcon(props) {
11
- var style = props.style;
12
- var defaultStyle = {
13
- verticalAlign: 'middle',
14
- display: 'inline-block',
15
- cursor: 'pointer',
16
- marginLeft: 5,
17
- height: '1em',
18
- width: '1em'
19
- };
20
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
21
- viewBox: "0 0 40 40",
22
- fill: "var(--w-rjv-delete-color, #dc3545)"
23
- }, props), {}, {
24
- style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, style), defaultStyle),
25
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
26
- d: "M28.3940997,0 L11.625773,0 C4.34215619,0 0,4.34 0,11.62 L0,28.36 C0,35.66 4.34215619,40 11.625773,40 L28.3740897,40 C35.6577066,40 39.9999316,35.66 39.9999316,28.38 L39.9999316,11.62 C40.0198727,4.34 35.6777165,0 28.3940997,0 Z M30.3428039,27.0681654 C31.2346195,27.9595381 31.2346195,29.4349136 30.3428039,30.3262862 C29.88152,30.7873411 29.2972271,31.0025 28.7129341,31.0025 C28.1286412,31.0025 27.5443483,30.7873411 27.0830644,30.3262862 L20.0100446,23.2567787 L12.9370249,30.3262862 C12.475741,30.7873411 11.891448,31.0025 11.3071551,31.0025 C10.7228621,31.0025 10.1385692,30.7873411 9.67728531,30.3262862 C8.78464325,29.4234847 8.78464325,27.9709669 9.67728531,27.0681654 L16.7503051,19.9986579 L9.67728531,12.9291504 C8.78464325,12.0263488 8.78464325,10.573831 9.67728531,9.67102951 C10.5691008,8.77965683 12.0452093,8.77965683 12.9370249,9.67102951 L20.0100446,16.740537 L27.0830644,9.67102951 C27.9748799,8.77965683 29.4509884,8.77965683 30.3428039,9.67102951 C31.2346195,10.5624022 31.2346195,12.0377777 30.3428039,12.9291504 L23.2697842,19.9986579 L30.3428039,27.0681654 L30.3428039,27.0681654 Z"
27
- })
28
- }));
29
- };
30
- exports.DeleteIcon = DeleteIcon;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- export interface EditIconProps extends React.SVGAttributes<SVGElement> {
3
- }
4
- export declare const EditIcon: (props: EditIconProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,30 +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.EditIcon = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _jsxRuntime = require("react/jsx-runtime");
10
- var EditIcon = function EditIcon(props) {
11
- var style = props.style;
12
- var defaultStyle = {
13
- verticalAlign: 'middle',
14
- display: 'inline-block',
15
- cursor: 'pointer',
16
- marginLeft: 5,
17
- height: '1em',
18
- width: '1em'
19
- };
20
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
21
- viewBox: "0 0 26 26",
22
- fill: "var(--w-rjv-edit-color, currentColor)"
23
- }, props), {}, {
24
- style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, style), defaultStyle),
25
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
26
- d: "M18,0 L7.74666667,0 C2.89333333,0 0,2.89333333 0,7.74666667 L0,17.9066667 C0,22.7733333 2.89333333,26 7.74666667,26 L18,26 C22.8533333,26 26.0001422,22.7733333 26.0001422,17.92 L26.0001422,7.74666667 C26.0133333,2.89333333 22.8533333,0 18,0 Z M11.9333333,20.68 C11.5466667,21.0666667 10.8133333,21.44 10.28,21.52 L7,21.9866667 C6.88,22 6.76,22.0133333 6.64,22.0133333 C6.09333333,22.0133333 5.58666667,21.8266667 5.22666667,21.4666667 C4.78666667,21.0266667 4.6,20.3866667 4.70666667,19.68 L5.17333333,16.4 C5.25333333,15.8533333 5.61333333,15.1333333 6.01333333,14.7466667 L11.96,8.8 C12.1719034,9.3972484 12.4397602,9.97314063 12.76,10.52 C12.8933333,10.7466667 13.04,10.96 13.16,11.12 C13.3066667,11.3466667 13.48,11.56 13.5866667,11.68 C13.6533333,11.7733333 13.7066667,11.84 13.7333333,11.8666667 C14.0666667,12.2666667 14.4533333,12.64 14.7866667,12.92 C14.88,13.0133333 14.9333333,13.0666667 14.96,13.08 C15.16,13.24 15.36,13.4 15.5333333,13.52 C15.7466667,13.68 15.96,13.8266667 16.1866667,13.9466667 C16.4533333,14.1066667 16.7466667,14.2533333 17.04,14.4 C17.3466667,14.5333333 17.6266667,14.6533333 17.9066667,14.7466667 L11.9333333,20.68 L11.9333333,20.68 Z M20.4933333,12.12 L19.2666667,13.36 C19.1887174,13.4373865 19.0831716,13.4805643 18.9733333,13.4800055 C18.9333333,13.4800055 18.88,13.4800055 18.8533333,13.4666667 C16.1309823,12.6775025 14.0024975,10.5490177 13.2133333,7.82666667 C13.1733333,7.68 13.2133333,7.52 13.32,7.42666667 L14.56,6.18666667 C16.5866667,4.16 18.52,4.2 20.5066667,6.18666667 C21.52,7.2 22.0133333,8.17333333 22.0133333,9.18666667 C22,10.1466667 21.5066667,11.1066667 20.4933333,12.12 L20.4933333,12.12 Z"
27
- })
28
- }));
29
- };
30
- exports.EditIcon = EditIcon;
@@ -1,31 +0,0 @@
1
- /// <reference types="react" />
2
- import type { JsonViewProps } from '../';
3
- import type { CountInfoExtraProps } from './countInfoExtra';
4
- export interface JsonViewEditorProps<T extends object> extends Omit<JsonViewProps<T>, 'shortenTextAfterLength'> {
5
- /**
6
- * When a callback function is passed in, edit functionality is enabled. The callback is invoked before edits are completed.
7
- * @returns {boolean} Returning false from onEdit will prevent the change from being made.
8
- */
9
- onEdit?: (option: {
10
- value: unknown;
11
- oldValue: unknown;
12
- keyName?: string | number;
13
- parentName?: string | number;
14
- namespace?: Array<string | number>;
15
- type?: 'value' | 'key';
16
- }) => boolean;
17
- /**
18
- * When a callback function is passed in, add functionality is enabled. The callback is invoked before additions are completed.
19
- * @returns {boolean} Returning false from onAdd will prevent the change from being made.
20
- */
21
- onAdd?: CountInfoExtraProps<T>['onAdd'];
22
- /**
23
- * When a callback function is passed in, delete functionality is enabled. The callback is invoked before deletions are completed.
24
- * @returns Returning false from onDelete will prevent the change from being made.
25
- */
26
- onDelete?: CountInfoExtraProps<T>['onDelete'];
27
- /** Whether enable edit feature. @default true */
28
- editable?: boolean;
29
- }
30
- declare const JsonViewEditor: import("react").ForwardRefExoticComponent<Omit<JsonViewEditorProps<object>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
31
- export default JsonViewEditor;
@@ -1,60 +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["default"] = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _react = require("react");
11
- var _ = _interopRequireDefault(require("../"));
12
- var _objectKey = require("./objectKey");
13
- var _value = require("./value");
14
- var _countInfoExtra = require("./countInfoExtra");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- var _excluded = ["onEdit", "components", "editable", "displayDataTypes", "onAdd", "onDelete"];
17
- var JsonViewEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
18
- var onEdit = props.onEdit,
19
- components = props.components,
20
- _props$editable = props.editable,
21
- editable = _props$editable === void 0 ? true : _props$editable,
22
- _props$displayDataTyp = props.displayDataTypes,
23
- displayDataTypes = _props$displayDataTyp === void 0 ? true : _props$displayDataTyp,
24
- onAdd = props.onAdd,
25
- onDelete = props.onDelete,
26
- reset = (0, _objectWithoutProperties2["default"])(props, _excluded);
27
- var comps = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, components), {}, {
28
- countInfoExtra: function countInfoExtra(reprops) {
29
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_countInfoExtra.CountInfoExtra, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reprops), {}, {
30
- editable: editable,
31
- onAdd: onAdd,
32
- onDelete: onDelete
33
- }));
34
- },
35
- objectKey: function objectKey(reprops) {
36
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_objectKey.ObjectKey, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reprops), {}, {
37
- editableValue: editable,
38
- onEdit: onEdit,
39
- render: components === null || components === void 0 ? void 0 : components.objectKey
40
- }));
41
- },
42
- value: function value(reprops) {
43
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.ReValue, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reprops), {}, {
44
- editableValue: editable,
45
- displayDataTypes: displayDataTypes,
46
- onDelete: onDelete,
47
- onEdit: onEdit
48
- }));
49
- }
50
- });
51
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
52
- displayDataTypes: false,
53
- components: comps,
54
- ref: ref
55
- }));
56
- });
57
- JsonViewEditor.displayName = 'JVR.JsonViewEditor';
58
- var _default = JsonViewEditor;
59
- exports["default"] = _default;
60
- module.exports = exports.default;
@@ -1,11 +0,0 @@
1
- import { FC } from 'react';
2
- import type { SemicolonProps } from '../semicolon';
3
- import type { JsonViewEditorProps } from './';
4
- export interface ObjectKeyProps<T extends object> extends SemicolonProps {
5
- onEdit?: JsonViewEditorProps<T>['onEdit'];
6
- render?: (props: SemicolonProps & {
7
- ref?: React.RefObject<HTMLElement>;
8
- }) => React.ReactNode;
9
- editableValue?: boolean;
10
- }
11
- export declare const ObjectKey: FC<ObjectKeyProps<object>>;
@@ -1,169 +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.ObjectKey = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
- var _react = require("react");
14
- var _semicolon = require("../semicolon");
15
- var _value = require("../value");
16
- var _jsxRuntime = require("react/jsx-runtime");
17
- var _excluded = ["className", "value", "keyName", "parentName", "quotes", "label", "namespace", "editableValue", "onEdit", "highlightUpdates", "render"];
18
- var ObjectKey = function ObjectKey(props) {
19
- var _ref;
20
- var className = props.className,
21
- value = props.value,
22
- keyName = props.keyName,
23
- parentName = props.parentName,
24
- quotes = props.quotes,
25
- label = props.label,
26
- namespace = props.namespace,
27
- editableValue = props.editableValue,
28
- onEdit = props.onEdit,
29
- _props$highlightUpdat = props.highlightUpdates,
30
- highlightUpdates = _props$highlightUpdat === void 0 ? true : _props$highlightUpdat,
31
- render = props.render,
32
- reset = (0, _objectWithoutProperties2["default"])(props, _excluded);
33
- var _useState = (0, _react.useState)(false),
34
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
35
- editable = _useState2[0],
36
- setEditable = _useState2[1];
37
- var _useState3 = (0, _react.useState)(label),
38
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
39
- curentLabel = _useState4[0],
40
- setCurentLabel = _useState4[1];
41
- (0, _react.useEffect)(function () {
42
- return setCurentLabel(label);
43
- }, [label]);
44
- var $edit = (0, _react.useRef)(null);
45
- (0, _semicolon.useHighlight)({
46
- value: value,
47
- highlightUpdates: highlightUpdates,
48
- highlightContainer: $edit
49
- });
50
- var click = function click(evn) {
51
- evn.stopPropagation();
52
- if (!editableValue) return;
53
- if (typeof keyName !== 'string') return;
54
- if (editable) return;
55
- setEditable(true);
56
- if ($edit.current) {
57
- var _$edit$current;
58
- $edit.current.contentEditable = 'true';
59
- (_$edit$current = $edit.current) === null || _$edit$current === void 0 || _$edit$current.focus();
60
- }
61
- };
62
- var blur = function blur() {
63
- return (_ref = _ref || (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
64
- var _$edit$current2, result;
65
- return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
66
- while (1) switch (_context.prev = _context.next) {
67
- case 0:
68
- if (!$edit.current) {
69
- _context.next = 8;
70
- break;
71
- }
72
- if (!onEdit) {
73
- _context.next = 6;
74
- break;
75
- }
76
- _context.next = 4;
77
- return onEdit({
78
- value: $edit.current.innerText,
79
- oldValue: curentLabel,
80
- namespace: namespace,
81
- keyName: keyName,
82
- parentName: parentName,
83
- type: 'key'
84
- });
85
- case 4:
86
- result = _context.sent;
87
- if (result) {
88
- setCurentLabel($edit.current.innerText);
89
- } else {
90
- $edit.current.innerText = curentLabel;
91
- }
92
- case 6:
93
- $edit.current.contentEditable = 'false';
94
- (_$edit$current2 = $edit.current) === null || _$edit$current2 === void 0 || _$edit$current2.focus();
95
- case 8:
96
- setEditable(false);
97
- case 9:
98
- case "end":
99
- return _context.stop();
100
- }
101
- }, _callee);
102
- }))).apply(this, arguments);
103
- };
104
- var focus = function focus() {
105
- if ($edit.current) {
106
- var _$edit$current3;
107
- $edit.current.contentEditable = 'true';
108
- (_$edit$current3 = $edit.current) === null || _$edit$current3 === void 0 || _$edit$current3.focus();
109
- }
110
- };
111
- var keyDown = function keyDown(evn) {
112
- if (evn.key === 'Enter') {
113
- evn.stopPropagation();
114
- evn.preventDefault();
115
- $edit.current.contentEditable = 'false';
116
- }
117
- };
118
- (0, _react.useEffect)(function () {
119
- if ($edit.current) {
120
- $edit.current.addEventListener('paste', function (e) {
121
- e.preventDefault();
122
- // @ts-ignore
123
- var text = e.clipboardData.getData('text/plain');
124
- document.execCommand('insertHTML', false, text);
125
- });
126
- }
127
- }, [$edit]);
128
- var style = {
129
- minWidth: 34,
130
- minHeight: 18,
131
- paddingInline: 3,
132
- display: 'inline-block'
133
- };
134
- var content = typeof keyName === 'string' ? "".concat(quotes).concat(curentLabel).concat(quotes) : curentLabel;
135
- var spanProps = {
136
- onClick: click,
137
- onFocus: focus,
138
- onBlur: blur,
139
- onKeyDown: keyDown,
140
- style: editable ? style : {},
141
- contentEditable: editable,
142
- spellCheck: false,
143
- autoFocus: editable,
144
- suppressContentEditableWarning: true,
145
- children: editable ? curentLabel : content
146
- };
147
- if (render) {
148
- spanProps.value = value;
149
- spanProps.keyName = keyName;
150
- spanProps.parentName = parentName;
151
- return render((0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({
152
- className: className
153
- }, reset), spanProps), {}, {
154
- parentName: parentName,
155
- label: curentLabel,
156
- children: editable ? curentLabel : content,
157
- ref: $edit
158
- }));
159
- }
160
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({
161
- className: className
162
- }, reset), {}, {
163
- autoFocus: editable
164
- }, spanProps), {}, {
165
- ref: $edit
166
- }));
167
- };
168
- exports.ObjectKey = ObjectKey;
169
- ObjectKey.displayName = 'JVR.ObjectKey';
@@ -1,22 +0,0 @@
1
- /// <reference types="react" />
2
- import type { TypeProps } from '../value';
3
- import type { JsonViewEditorProps } from './';
4
- export interface ReValueProps<T extends object> extends React.HTMLAttributes<HTMLSpanElement> {
5
- onEdit?: JsonViewEditorProps<T>['onEdit'];
6
- quotes?: JsonViewEditorProps<T>['quotes'];
7
- keyName?: JsonViewEditorProps<T>['keyName'];
8
- type: TypeProps['type'];
9
- value?: unknown;
10
- parentValue?: T;
11
- data?: T;
12
- visible?: boolean;
13
- namespace?: Array<string | number>;
14
- editableValue?: boolean;
15
- displayDataTypes?: boolean;
16
- setValue?: React.Dispatch<React.SetStateAction<T>>;
17
- onDelete?: JsonViewEditorProps<T>['onDelete'];
18
- }
19
- export declare function ReValue<T extends object>(props: ReValueProps<T>): import("react/jsx-runtime").JSX.Element;
20
- export declare namespace ReValue {
21
- var displayName: string;
22
- }