@uiw/react-json-view 2.0.0-alpha.36 → 2.0.0-alpha.38
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.
- package/cjs/comps/Copied.d.ts +1 -0
- package/cjs/comps/Copied.js +12 -2
- package/cjs/comps/KeyValues.js +4 -3
- package/cjs/comps/NestedClose.js +4 -3
- package/cjs/comps/NestedOpen.js +4 -3
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +13 -5
- package/cjs/section/Copied.d.ts +4 -1
- package/cjs/store.d.ts +1 -0
- package/esm/comps/Copied.d.ts +1 -0
- package/esm/comps/Copied.js +13 -3
- package/esm/comps/KeyValues.js +4 -3
- package/esm/comps/NestedClose.js +4 -3
- package/esm/comps/NestedOpen.js +4 -3
- package/esm/index.d.ts +2 -0
- package/esm/index.js +8 -6
- package/esm/section/Copied.d.ts +4 -1
- package/esm/store.d.ts +1 -0
- package/package.json +1 -1
- package/triangle-arrow.d.ts +2 -2
- package/triangle-solid-arrow.d.ts +2 -2
package/cjs/comps/Copied.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type CopiedOption<T extends object> = {
|
|
|
7
7
|
};
|
|
8
8
|
export interface CopiedProps<T extends object> extends React.SVGProps<SVGSVGElement>, SectionElementResult<T> {
|
|
9
9
|
expandKey: string;
|
|
10
|
+
beforeCopy?: (copyText: string, keyName?: string | number, value?: T, parentValue?: T, expandKey?: string, keys?: (number | string)[]) => string;
|
|
10
11
|
}
|
|
11
12
|
export declare const Copied: {
|
|
12
13
|
<T extends object, K extends TagType>(props: CopiedProps<T>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
package/cjs/comps/Copied.js
CHANGED
|
@@ -14,7 +14,7 @@ var _Section = require("../store/Section");
|
|
|
14
14
|
var _ShowTools = require("../store/ShowTools");
|
|
15
15
|
var _types = require("../types/");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
var _excluded = ["keyName", "value", "parentValue", "expandKey", "keys"],
|
|
17
|
+
var _excluded = ["keyName", "value", "parentValue", "expandKey", "keys", "beforeCopy"],
|
|
18
18
|
_excluded2 = ["as", "render"];
|
|
19
19
|
var Copied = exports.Copied = function Copied(props) {
|
|
20
20
|
var keyName = props.keyName,
|
|
@@ -22,10 +22,12 @@ var Copied = exports.Copied = function Copied(props) {
|
|
|
22
22
|
parentValue = props.parentValue,
|
|
23
23
|
expandKey = props.expandKey,
|
|
24
24
|
keys = props.keys,
|
|
25
|
+
beforeCopy = props.beforeCopy,
|
|
25
26
|
other = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
26
27
|
var _useStore = (0, _store.useStore)(),
|
|
27
28
|
onCopied = _useStore.onCopied,
|
|
28
|
-
enableClipboard = _useStore.enableClipboard
|
|
29
|
+
enableClipboard = _useStore.enableClipboard,
|
|
30
|
+
globalBeforeCopy = _useStore.beforeCopy;
|
|
29
31
|
var showTools = (0, _ShowTools.useShowToolsStore)();
|
|
30
32
|
var isShowTools = showTools[expandKey];
|
|
31
33
|
var _useState = (0, _react.useState)(false),
|
|
@@ -35,6 +37,7 @@ var Copied = exports.Copied = function Copied(props) {
|
|
|
35
37
|
var _useSectionStore = (0, _Section.useSectionStore)(),
|
|
36
38
|
_useSectionStore$Copi = _useSectionStore.Copied,
|
|
37
39
|
Comp = _useSectionStore$Copi === void 0 ? {} : _useSectionStore$Copi;
|
|
40
|
+
var sectionBeforeCopy = Comp === null || Comp === void 0 ? void 0 : Comp.beforeCopy;
|
|
38
41
|
if (enableClipboard === false || !isShowTools) return null;
|
|
39
42
|
var click = function click(event) {
|
|
40
43
|
event.stopPropagation();
|
|
@@ -52,6 +55,13 @@ var Copied = exports.Copied = function Copied(props) {
|
|
|
52
55
|
return typeof v === 'bigint' ? (0, _types.bigIntToString)(v) : v;
|
|
53
56
|
}, 2);
|
|
54
57
|
}
|
|
58
|
+
|
|
59
|
+
// Apply beforeCopy transformation if provided
|
|
60
|
+
// Priority: component prop > section prop > global prop
|
|
61
|
+
var finalBeforeCopy = beforeCopy || sectionBeforeCopy || globalBeforeCopy;
|
|
62
|
+
if (finalBeforeCopy && typeof finalBeforeCopy === 'function') {
|
|
63
|
+
copyText = finalBeforeCopy(copyText, keyName, value, parentValue, expandKey, keys);
|
|
64
|
+
}
|
|
55
65
|
onCopied && onCopied(copyText, value);
|
|
56
66
|
setCopied(true);
|
|
57
67
|
var _clipboard = navigator.clipboard || {
|
package/cjs/comps/KeyValues.js
CHANGED
|
@@ -40,15 +40,16 @@ var KeyValues = exports.KeyValues = function KeyValues(props) {
|
|
|
40
40
|
collapsed = _useStore.collapsed,
|
|
41
41
|
shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
|
|
42
42
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
43
|
-
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
|
|
44
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
43
|
+
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
|
|
44
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
45
45
|
value: value,
|
|
46
46
|
keys: keys,
|
|
47
47
|
level: level,
|
|
48
48
|
keyName: keyName,
|
|
49
49
|
parentValue: parentValue
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
console.log('KeyValues', expands[expandKey], defaultExpanded, !shouldExpand, shouldExpand, isExpanded);
|
|
52
|
+
if (expands[expandKey] === undefined && !shouldExpand) {
|
|
52
53
|
return null;
|
|
53
54
|
}
|
|
54
55
|
if (isExpanded) {
|
package/cjs/comps/NestedClose.js
CHANGED
|
@@ -24,15 +24,16 @@ var NestedClose = exports.NestedClose = function NestedClose(props) {
|
|
|
24
24
|
collapsed = _useStore.collapsed,
|
|
25
25
|
shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
|
|
26
26
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
27
|
-
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
|
|
28
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
27
|
+
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
|
|
28
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
29
29
|
value: value,
|
|
30
30
|
keys: keys,
|
|
31
31
|
level: level,
|
|
32
32
|
keyName: keyName,
|
|
33
33
|
parentValue: parentValue
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
console.log('NestedClose', expands[expandKey], defaultExpanded, shouldExpand);
|
|
36
|
+
if (expands[expandKey] === undefined && !shouldExpand) {
|
|
36
37
|
return null;
|
|
37
38
|
}
|
|
38
39
|
var len = Object.keys(value).length;
|
package/cjs/comps/NestedOpen.js
CHANGED
|
@@ -35,16 +35,17 @@ var NestedOpen = exports.NestedOpen = function NestedOpen(props) {
|
|
|
35
35
|
collapsed = _useStore.collapsed,
|
|
36
36
|
shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
|
|
37
37
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
38
|
-
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
|
|
39
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
38
|
+
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
|
|
39
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
40
40
|
value: value,
|
|
41
41
|
keys: keys,
|
|
42
42
|
level: level,
|
|
43
43
|
keyName: keyName,
|
|
44
44
|
parentValue: parentValue
|
|
45
45
|
});
|
|
46
|
+
console.log('NestedOpen', expands[expandKey], defaultExpanded, shouldExpand, !shouldExpand);
|
|
46
47
|
if (expands[expandKey] === undefined && shouldExpandNodeInitially) {
|
|
47
|
-
isExpanded =
|
|
48
|
+
isExpanded = !shouldExpand;
|
|
48
49
|
}
|
|
49
50
|
var click = function click() {
|
|
50
51
|
var opt = {
|
package/cjs/index.d.ts
CHANGED
|
@@ -72,6 +72,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
72
72
|
}) => void;
|
|
73
73
|
/** Fires event when you copy */
|
|
74
74
|
onCopied?: (text: string, value?: T) => void;
|
|
75
|
+
/** Transform the text before copying to clipboard */
|
|
76
|
+
beforeCopy?: (copyText: string, keyName?: string | number, value?: T, parentValue?: T, expandKey?: string, keys?: (number | string)[]) => string;
|
|
75
77
|
}
|
|
76
78
|
type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
|
|
77
79
|
Bigint: typeof Bigint;
|
package/cjs/index.js
CHANGED
|
@@ -110,15 +110,19 @@ Object.keys(_symbol).forEach(function (key) {
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
|
-
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied"];
|
|
113
|
+
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied", "beforeCopy"];
|
|
114
114
|
var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
115
115
|
var _props$className = props.className,
|
|
116
116
|
className = _props$className === void 0 ? '' : _props$className,
|
|
117
117
|
style = props.style,
|
|
118
118
|
value = props.value,
|
|
119
119
|
children = props.children,
|
|
120
|
-
collapsed = props.collapsed,
|
|
121
|
-
|
|
120
|
+
_props$collapsed = props.collapsed,
|
|
121
|
+
collapsed = _props$collapsed === void 0 ? false : _props$collapsed,
|
|
122
|
+
_props$shouldExpandNo = props.shouldExpandNodeInitially,
|
|
123
|
+
shouldExpandNodeInitially = _props$shouldExpandNo === void 0 ? function () {
|
|
124
|
+
return true;
|
|
125
|
+
} : _props$shouldExpandNo,
|
|
122
126
|
_props$indentWidth = props.indentWidth,
|
|
123
127
|
indentWidth = _props$indentWidth === void 0 ? 15 : _props$indentWidth,
|
|
124
128
|
_props$displayObjectS = props.displayObjectSize,
|
|
@@ -136,6 +140,7 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
136
140
|
objectSortKeys = _props$objectSortKeys === void 0 ? false : _props$objectSortKeys,
|
|
137
141
|
onExpand = props.onExpand,
|
|
138
142
|
onCopied = props.onCopied,
|
|
143
|
+
beforeCopy = props.beforeCopy,
|
|
139
144
|
elmProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
140
145
|
var defaultStyle = (0, _objectSpread2["default"])({
|
|
141
146
|
lineHeight: 1.4,
|
|
@@ -150,7 +155,9 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
150
155
|
value: value,
|
|
151
156
|
objectSortKeys: objectSortKeys,
|
|
152
157
|
indentWidth: indentWidth,
|
|
153
|
-
shouldExpandNodeInitially: shouldExpandNodeInitially
|
|
158
|
+
shouldExpandNodeInitially: collapsed === false ? shouldExpandNodeInitially : function () {
|
|
159
|
+
return false;
|
|
160
|
+
},
|
|
154
161
|
displayObjectSize: displayObjectSize,
|
|
155
162
|
collapsed: collapsed,
|
|
156
163
|
enableClipboard: enableClipboard,
|
|
@@ -158,7 +165,8 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
158
165
|
stringEllipsis: stringEllipsis,
|
|
159
166
|
highlightUpdates: highlightUpdates,
|
|
160
167
|
onCopied: onCopied,
|
|
161
|
-
onExpand: onExpand
|
|
168
|
+
onExpand: onExpand,
|
|
169
|
+
beforeCopy: beforeCopy
|
|
162
170
|
},
|
|
163
171
|
initialTypes: {
|
|
164
172
|
displayDataTypes: displayDataTypes
|
package/cjs/section/Copied.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type TagType } from '../store/Types';
|
|
2
2
|
import { type SectionElement } from '../store/Section';
|
|
3
|
+
export type CopiedSectionElement<T extends TagType = 'svg'> = SectionElement<T> & {
|
|
4
|
+
beforeCopy?: (copyText: string, keyName?: string | number, value?: object, parentValue?: object, expandKey?: string, keys?: (number | string)[]) => string;
|
|
5
|
+
};
|
|
3
6
|
export declare const Copied: {
|
|
4
|
-
<K extends TagType = "svg">(props:
|
|
7
|
+
<K extends TagType = "svg">(props: CopiedSectionElement<K>): null;
|
|
5
8
|
displayName: string;
|
|
6
9
|
};
|
package/cjs/store.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface InitialState<T extends object> {
|
|
|
6
6
|
value?: object;
|
|
7
7
|
onExpand?: JsonViewProps<object>['onExpand'];
|
|
8
8
|
onCopied?: JsonViewProps<object>['onCopied'];
|
|
9
|
+
beforeCopy?: JsonViewProps<T>['beforeCopy'];
|
|
9
10
|
objectSortKeys?: JsonViewProps<T>['objectSortKeys'];
|
|
10
11
|
displayObjectSize?: JsonViewProps<T>['displayObjectSize'];
|
|
11
12
|
shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
|
package/esm/comps/Copied.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type CopiedOption<T extends object> = {
|
|
|
7
7
|
};
|
|
8
8
|
export interface CopiedProps<T extends object> extends React.SVGProps<SVGSVGElement>, SectionElementResult<T> {
|
|
9
9
|
expandKey: string;
|
|
10
|
+
beforeCopy?: (copyText: string, keyName?: string | number, value?: T, parentValue?: T, expandKey?: string, keys?: (number | string)[]) => string;
|
|
10
11
|
}
|
|
11
12
|
export declare const Copied: {
|
|
12
13
|
<T extends object, K extends TagType>(props: CopiedProps<T>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
package/esm/comps/Copied.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["keyName", "value", "parentValue", "expandKey", "keys"],
|
|
3
|
+
var _excluded = ["keyName", "value", "parentValue", "expandKey", "keys", "beforeCopy"],
|
|
4
4
|
_excluded2 = ["as", "render"];
|
|
5
5
|
import { useState } from 'react';
|
|
6
6
|
import { useStore } from "../store.js";
|
|
@@ -14,12 +14,14 @@ export var Copied = props => {
|
|
|
14
14
|
value,
|
|
15
15
|
parentValue,
|
|
16
16
|
expandKey,
|
|
17
|
-
keys
|
|
17
|
+
keys,
|
|
18
|
+
beforeCopy
|
|
18
19
|
} = props,
|
|
19
20
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
20
21
|
var {
|
|
21
22
|
onCopied,
|
|
22
|
-
enableClipboard
|
|
23
|
+
enableClipboard,
|
|
24
|
+
beforeCopy: globalBeforeCopy
|
|
23
25
|
} = useStore();
|
|
24
26
|
var showTools = useShowToolsStore();
|
|
25
27
|
var isShowTools = showTools[expandKey];
|
|
@@ -27,6 +29,7 @@ export var Copied = props => {
|
|
|
27
29
|
var {
|
|
28
30
|
Copied: Comp = {}
|
|
29
31
|
} = useSectionStore();
|
|
32
|
+
var sectionBeforeCopy = Comp == null ? void 0 : Comp.beforeCopy;
|
|
30
33
|
if (enableClipboard === false || !isShowTools) return null;
|
|
31
34
|
var click = event => {
|
|
32
35
|
event.stopPropagation();
|
|
@@ -42,6 +45,13 @@ export var Copied = props => {
|
|
|
42
45
|
} else {
|
|
43
46
|
copyText = JSON.stringify(value, (_, v) => typeof v === 'bigint' ? bigIntToString(v) : v, 2);
|
|
44
47
|
}
|
|
48
|
+
|
|
49
|
+
// Apply beforeCopy transformation if provided
|
|
50
|
+
// Priority: component prop > section prop > global prop
|
|
51
|
+
var finalBeforeCopy = beforeCopy || sectionBeforeCopy || globalBeforeCopy;
|
|
52
|
+
if (finalBeforeCopy && typeof finalBeforeCopy === 'function') {
|
|
53
|
+
copyText = finalBeforeCopy(copyText, keyName, value, parentValue, expandKey, keys);
|
|
54
|
+
}
|
|
45
55
|
onCopied && onCopied(copyText, value);
|
|
46
56
|
setCopied(true);
|
|
47
57
|
var _clipboard = navigator.clipboard || {
|
package/esm/comps/KeyValues.js
CHANGED
|
@@ -30,15 +30,16 @@ export var KeyValues = props => {
|
|
|
30
30
|
shouldExpandNodeInitially
|
|
31
31
|
} = useStore();
|
|
32
32
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
33
|
-
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
|
|
34
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
33
|
+
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
|
|
34
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
35
35
|
value,
|
|
36
36
|
keys,
|
|
37
37
|
level,
|
|
38
38
|
keyName,
|
|
39
39
|
parentValue
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
console.log('KeyValues', expands[expandKey], defaultExpanded, !shouldExpand, shouldExpand, isExpanded);
|
|
42
|
+
if (expands[expandKey] === undefined && !shouldExpand) {
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
44
45
|
if (isExpanded) {
|
package/esm/comps/NestedClose.js
CHANGED
|
@@ -19,15 +19,16 @@ export var NestedClose = props => {
|
|
|
19
19
|
shouldExpandNodeInitially
|
|
20
20
|
} = useStore();
|
|
21
21
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
22
|
-
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
|
|
23
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
22
|
+
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
|
|
23
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
24
24
|
value,
|
|
25
25
|
keys,
|
|
26
26
|
level,
|
|
27
27
|
keyName,
|
|
28
28
|
parentValue
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
console.log('NestedClose', expands[expandKey], defaultExpanded, shouldExpand);
|
|
31
|
+
if (expands[expandKey] === undefined && !shouldExpand) {
|
|
31
32
|
return null;
|
|
32
33
|
}
|
|
33
34
|
var len = Object.keys(value).length;
|
package/esm/comps/NestedOpen.js
CHANGED
|
@@ -28,16 +28,17 @@ export var NestedOpen = props => {
|
|
|
28
28
|
shouldExpandNodeInitially
|
|
29
29
|
} = useStore();
|
|
30
30
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
31
|
-
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
|
|
32
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
31
|
+
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
|
|
32
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
33
33
|
value,
|
|
34
34
|
keys,
|
|
35
35
|
level,
|
|
36
36
|
keyName,
|
|
37
37
|
parentValue
|
|
38
38
|
});
|
|
39
|
+
console.log('NestedOpen', expands[expandKey], defaultExpanded, shouldExpand, !shouldExpand);
|
|
39
40
|
if (expands[expandKey] === undefined && shouldExpandNodeInitially) {
|
|
40
|
-
isExpanded =
|
|
41
|
+
isExpanded = !shouldExpand;
|
|
41
42
|
}
|
|
42
43
|
var click = () => {
|
|
43
44
|
var opt = {
|
package/esm/index.d.ts
CHANGED
|
@@ -72,6 +72,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
72
72
|
}) => void;
|
|
73
73
|
/** Fires event when you copy */
|
|
74
74
|
onCopied?: (text: string, value?: T) => void;
|
|
75
|
+
/** Transform the text before copying to clipboard */
|
|
76
|
+
beforeCopy?: (copyText: string, keyName?: string | number, value?: T, parentValue?: T, expandKey?: string, keys?: (number | string)[]) => string;
|
|
75
77
|
}
|
|
76
78
|
type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
|
|
77
79
|
Bigint: typeof Bigint;
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied"];
|
|
3
|
+
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied", "beforeCopy"];
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { Provider } from "./store.js";
|
|
6
6
|
import { Container } from "./Container.js";
|
|
@@ -44,8 +44,8 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
44
44
|
style,
|
|
45
45
|
value,
|
|
46
46
|
children,
|
|
47
|
-
collapsed,
|
|
48
|
-
shouldExpandNodeInitially,
|
|
47
|
+
collapsed = false,
|
|
48
|
+
shouldExpandNodeInitially = () => true,
|
|
49
49
|
indentWidth = 15,
|
|
50
50
|
displayObjectSize = true,
|
|
51
51
|
shortenTextAfterLength = 30,
|
|
@@ -55,7 +55,8 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
55
55
|
displayDataTypes = true,
|
|
56
56
|
objectSortKeys = false,
|
|
57
57
|
onExpand,
|
|
58
|
-
onCopied
|
|
58
|
+
onCopied,
|
|
59
|
+
beforeCopy
|
|
59
60
|
} = props,
|
|
60
61
|
elmProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
61
62
|
var defaultStyle = _extends({
|
|
@@ -71,7 +72,7 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
71
72
|
value,
|
|
72
73
|
objectSortKeys,
|
|
73
74
|
indentWidth,
|
|
74
|
-
shouldExpandNodeInitially,
|
|
75
|
+
shouldExpandNodeInitially: collapsed === false ? shouldExpandNodeInitially : () => false,
|
|
75
76
|
displayObjectSize,
|
|
76
77
|
collapsed,
|
|
77
78
|
enableClipboard,
|
|
@@ -79,7 +80,8 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
79
80
|
stringEllipsis,
|
|
80
81
|
highlightUpdates,
|
|
81
82
|
onCopied,
|
|
82
|
-
onExpand
|
|
83
|
+
onExpand,
|
|
84
|
+
beforeCopy
|
|
83
85
|
},
|
|
84
86
|
initialTypes: {
|
|
85
87
|
displayDataTypes
|
package/esm/section/Copied.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type TagType } from '../store/Types';
|
|
2
2
|
import { type SectionElement } from '../store/Section';
|
|
3
|
+
export type CopiedSectionElement<T extends TagType = 'svg'> = SectionElement<T> & {
|
|
4
|
+
beforeCopy?: (copyText: string, keyName?: string | number, value?: object, parentValue?: object, expandKey?: string, keys?: (number | string)[]) => string;
|
|
5
|
+
};
|
|
3
6
|
export declare const Copied: {
|
|
4
|
-
<K extends TagType = "svg">(props:
|
|
7
|
+
<K extends TagType = "svg">(props: CopiedSectionElement<K>): null;
|
|
5
8
|
displayName: string;
|
|
6
9
|
};
|
package/esm/store.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface InitialState<T extends object> {
|
|
|
6
6
|
value?: object;
|
|
7
7
|
onExpand?: JsonViewProps<object>['onExpand'];
|
|
8
8
|
onCopied?: JsonViewProps<object>['onCopied'];
|
|
9
|
+
beforeCopy?: JsonViewProps<T>['beforeCopy'];
|
|
9
10
|
objectSortKeys?: JsonViewProps<T>['objectSortKeys'];
|
|
10
11
|
displayObjectSize?: JsonViewProps<T>['displayObjectSize'];
|
|
11
12
|
shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
|
package/package.json
CHANGED
package/triangle-arrow.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module '@uiw/react-json-view/triangle-arrow' {
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export interface TriangleArrowProps extends React.SVGProps<SVGSVGElement> {
|
|
4
|
-
export function TriangleArrow(props: TriangleArrowProps): import(
|
|
3
|
+
export interface TriangleArrowProps extends React.SVGProps<SVGSVGElement> {}
|
|
4
|
+
export function TriangleArrow(props: TriangleArrowProps): import('react/jsx-runtime').JSX.Element;
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module '@uiw/react-json-view/triangle-solid-arrow' {
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export interface TriangleSolidArrowProps extends React.SVGProps<SVGSVGElement> {
|
|
4
|
-
export function TriangleSolidArrow(props: TriangleSolidArrowProps): import(
|
|
3
|
+
export interface TriangleSolidArrowProps extends React.SVGProps<SVGSVGElement> {}
|
|
4
|
+
export function TriangleSolidArrow(props: TriangleSolidArrowProps): import('react/jsx-runtime').JSX.Element;
|
|
5
5
|
}
|