@uiw/react-json-view 2.0.0-alpha.4 → 2.0.0-alpha.41
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/README.md +280 -39
- package/basic.d.ts +4 -0
- package/cjs/Container.d.ts +2 -0
- package/cjs/Container.js +15 -6
- package/cjs/arrow/TriangleArrow.js +1 -1
- package/cjs/comps/Copied.d.ts +3 -4
- package/cjs/comps/Copied.js +61 -18
- package/cjs/comps/KeyValues.d.ts +2 -4
- package/cjs/comps/KeyValues.js +73 -28
- package/cjs/comps/NestedClose.d.ts +2 -2
- package/cjs/comps/NestedClose.js +42 -12
- package/cjs/comps/NestedOpen.d.ts +2 -3
- package/cjs/comps/NestedOpen.js +42 -20
- package/cjs/comps/Value.d.ts +2 -2
- package/cjs/comps/Value.js +5 -7
- package/cjs/comps/useIdCompat.d.ts +1 -0
- package/cjs/comps/useIdCompat.js +14 -0
- package/cjs/editor/KeyName.d.ts +2 -0
- package/cjs/editor/KeyName.js +82 -0
- package/cjs/editor/index.d.ts +18 -0
- package/cjs/editor/index.js +44 -0
- package/cjs/editor/store.d.ts +27 -0
- package/cjs/editor/store.js +23 -0
- package/cjs/index.d.ts +26 -4
- package/cjs/index.js +17 -7
- package/cjs/section/Copied.d.ts +4 -1
- package/cjs/section/Copied.js +1 -2
- package/cjs/section/CountInfo.d.ts +1 -2
- package/cjs/section/CountInfo.js +3 -5
- package/cjs/section/CountInfoExtra.d.ts +1 -2
- package/cjs/section/CountInfoExtra.js +2 -4
- package/cjs/section/Ellipsis.d.ts +0 -1
- package/cjs/section/Ellipsis.js +4 -5
- package/cjs/section/KeyName.d.ts +7 -6
- package/cjs/section/KeyName.js +8 -6
- package/cjs/section/Row.d.ts +13 -0
- package/cjs/section/Row.js +51 -0
- package/cjs/store/Expands.js +2 -4
- package/cjs/store/Section.d.ts +12 -6
- package/cjs/store/Section.js +6 -4
- package/cjs/store/ShowTools.js +2 -4
- package/cjs/store/Symbols.d.ts +10 -3
- package/cjs/store/Symbols.js +2 -4
- package/cjs/store/Types.d.ts +30 -25
- package/cjs/store/Types.js +8 -8
- package/cjs/store.d.ts +12 -6
- package/cjs/store.js +5 -10
- package/cjs/symbol/Arrow.d.ts +1 -1
- package/cjs/symbol/Arrow.js +1 -2
- package/cjs/symbol/BraceLeft.d.ts +1 -1
- package/cjs/symbol/BraceLeft.js +1 -2
- package/cjs/symbol/BraceRight.d.ts +1 -1
- package/cjs/symbol/BraceRight.js +1 -2
- package/cjs/symbol/BracketsLeft.d.ts +1 -1
- package/cjs/symbol/BracketsLeft.js +1 -2
- package/cjs/symbol/BracketsRight.d.ts +1 -1
- package/cjs/symbol/BracketsRight.js +1 -2
- package/cjs/symbol/Colon.d.ts +1 -1
- package/cjs/symbol/Colon.js +1 -2
- package/cjs/symbol/Quote.d.ts +1 -1
- package/cjs/symbol/Quote.js +1 -2
- package/cjs/symbol/ValueQuote.d.ts +1 -1
- package/cjs/symbol/ValueQuote.js +1 -2
- package/cjs/symbol/index.d.ts +12 -17
- package/cjs/symbol/index.js +82 -30
- package/cjs/theme/basic.d.ts +2 -2
- package/cjs/theme/basic.js +4 -3
- package/cjs/theme/dark.d.ts +2 -2
- package/cjs/theme/dark.js +2 -3
- package/cjs/theme/github.dark.d.ts +2 -2
- package/cjs/theme/github.dark.js +2 -3
- package/cjs/theme/github.light.d.ts +2 -2
- package/cjs/theme/github.light.js +2 -3
- package/cjs/theme/gruvbox.d.ts +2 -2
- package/cjs/theme/gruvbox.js +2 -3
- package/cjs/theme/light.d.ts +2 -2
- package/cjs/theme/light.js +2 -3
- package/cjs/theme/monokai.d.ts +2 -2
- package/cjs/theme/monokai.js +2 -3
- package/cjs/theme/nord.d.ts +2 -2
- package/cjs/theme/nord.js +2 -3
- package/cjs/theme/vscode.d.ts +2 -2
- package/cjs/theme/vscode.js +2 -3
- package/cjs/types/Bigint.d.ts +1 -1
- package/cjs/types/Bigint.js +1 -2
- package/cjs/types/Date.d.ts +1 -1
- package/cjs/types/Date.js +1 -2
- package/cjs/types/False.d.ts +1 -1
- package/cjs/types/False.js +1 -2
- package/cjs/types/Float.d.ts +1 -1
- package/cjs/types/Float.js +1 -2
- package/cjs/types/Int.d.ts +1 -1
- package/cjs/types/Int.js +1 -2
- package/cjs/types/Map.d.ts +1 -1
- package/cjs/types/Map.js +1 -2
- package/cjs/types/Nan.d.ts +1 -1
- package/cjs/types/Nan.js +1 -2
- package/cjs/types/Null.d.ts +1 -1
- package/cjs/types/Null.js +1 -2
- package/cjs/types/Set.d.ts +1 -1
- package/cjs/types/Set.js +1 -2
- package/cjs/types/String.d.ts +1 -1
- package/cjs/types/String.js +1 -2
- package/cjs/types/True.d.ts +1 -1
- package/cjs/types/True.js +1 -2
- package/cjs/types/Undefined.d.ts +1 -1
- package/cjs/types/Undefined.js +1 -2
- package/cjs/types/Url.d.ts +1 -1
- package/cjs/types/Url.js +1 -2
- package/cjs/types/index.d.ts +5 -2
- package/cjs/types/index.js +174 -166
- package/cjs/utils/useHighlight.d.ts +0 -1
- package/cjs/utils/useRender.d.ts +1 -1
- package/dark.d.ts +2 -1
- package/editor.d.ts +22 -20
- package/esm/Container.d.ts +2 -0
- package/esm/Container.js +21 -11
- package/esm/arrow/TriangleArrow.js +1 -1
- package/esm/comps/Copied.d.ts +3 -4
- package/esm/comps/Copied.js +61 -19
- package/esm/comps/KeyValues.d.ts +2 -4
- package/esm/comps/KeyValues.js +71 -27
- package/esm/comps/NestedClose.d.ts +2 -2
- package/esm/comps/NestedClose.js +40 -11
- package/esm/comps/NestedOpen.d.ts +2 -3
- package/esm/comps/NestedOpen.js +47 -26
- package/esm/comps/Value.d.ts +2 -2
- package/esm/comps/Value.js +3 -3
- package/esm/comps/useIdCompat.d.ts +1 -0
- package/esm/comps/useIdCompat.js +8 -0
- package/esm/editor/KeyName.d.ts +2 -0
- package/esm/editor/KeyName.js +77 -0
- package/esm/editor/index.d.ts +18 -0
- package/esm/editor/index.js +33 -0
- package/esm/editor/store.d.ts +27 -0
- package/esm/editor/store.js +13 -0
- package/esm/index.d.ts +26 -4
- package/esm/index.js +50 -41
- package/esm/section/Copied.d.ts +4 -1
- package/esm/section/Copied.js +2 -2
- package/esm/section/CountInfo.d.ts +1 -2
- package/esm/section/CountInfo.js +4 -4
- package/esm/section/CountInfoExtra.d.ts +1 -2
- package/esm/section/CountInfoExtra.js +2 -2
- package/esm/section/Ellipsis.d.ts +0 -1
- package/esm/section/Ellipsis.js +3 -3
- package/esm/section/KeyName.d.ts +7 -6
- package/esm/section/KeyName.js +8 -4
- package/esm/section/Row.d.ts +13 -0
- package/esm/section/Row.js +47 -0
- package/esm/store/Section.d.ts +12 -6
- package/esm/store/Section.js +4 -0
- package/esm/store/Symbols.d.ts +10 -3
- package/esm/store/Symbols.js +1 -1
- package/esm/store/Types.d.ts +30 -25
- package/esm/store/Types.js +6 -4
- package/esm/store.d.ts +12 -6
- package/esm/store.js +5 -5
- package/esm/symbol/Arrow.d.ts +1 -1
- package/esm/symbol/Arrow.js +2 -2
- package/esm/symbol/BraceLeft.d.ts +1 -1
- package/esm/symbol/BraceLeft.js +2 -2
- package/esm/symbol/BraceRight.d.ts +1 -1
- package/esm/symbol/BraceRight.js +2 -2
- package/esm/symbol/BracketsLeft.d.ts +1 -1
- package/esm/symbol/BracketsLeft.js +2 -2
- package/esm/symbol/BracketsRight.d.ts +1 -1
- package/esm/symbol/BracketsRight.js +2 -2
- package/esm/symbol/Colon.d.ts +1 -1
- package/esm/symbol/Colon.js +2 -2
- package/esm/symbol/Quote.d.ts +1 -1
- package/esm/symbol/Quote.js +2 -2
- package/esm/symbol/ValueQuote.d.ts +1 -1
- package/esm/symbol/ValueQuote.js +2 -2
- package/esm/symbol/index.d.ts +12 -17
- package/esm/symbol/index.js +85 -25
- package/esm/theme/basic.d.ts +2 -2
- package/esm/theme/basic.js +2 -0
- package/esm/theme/dark.d.ts +2 -2
- package/esm/theme/github.dark.d.ts +2 -2
- package/esm/theme/github.light.d.ts +2 -2
- package/esm/theme/gruvbox.d.ts +2 -2
- package/esm/theme/light.d.ts +2 -2
- package/esm/theme/monokai.d.ts +2 -2
- package/esm/theme/nord.d.ts +2 -2
- package/esm/theme/vscode.d.ts +2 -2
- package/esm/types/Bigint.d.ts +1 -1
- package/esm/types/Bigint.js +2 -2
- package/esm/types/Date.d.ts +1 -1
- package/esm/types/Date.js +2 -2
- package/esm/types/False.d.ts +1 -1
- package/esm/types/False.js +2 -2
- package/esm/types/Float.d.ts +1 -1
- package/esm/types/Float.js +2 -2
- package/esm/types/Int.d.ts +1 -1
- package/esm/types/Int.js +2 -2
- package/esm/types/Map.d.ts +1 -1
- package/esm/types/Map.js +2 -2
- package/esm/types/Nan.d.ts +1 -1
- package/esm/types/Nan.js +2 -2
- package/esm/types/Null.d.ts +1 -1
- package/esm/types/Null.js +2 -2
- package/esm/types/Set.d.ts +1 -1
- package/esm/types/Set.js +2 -2
- package/esm/types/String.d.ts +1 -1
- package/esm/types/String.js +2 -2
- package/esm/types/True.d.ts +1 -1
- package/esm/types/True.js +2 -2
- package/esm/types/Undefined.d.ts +1 -1
- package/esm/types/Undefined.js +2 -2
- package/esm/types/Url.d.ts +1 -1
- package/esm/types/Url.js +2 -2
- package/esm/types/index.d.ts +5 -2
- package/esm/types/index.js +148 -131
- package/esm/utils/useHighlight.d.ts +0 -1
- package/esm/utils/useRender.d.ts +1 -1
- package/esm/utils/useRender.js +3 -3
- package/githubDark.d.ts +4 -0
- package/githubLight.d.ts +4 -0
- package/gruvbox.d.ts +4 -0
- package/light.d.ts +2 -1
- package/monokai.d.ts +4 -0
- package/nord.d.ts +4 -0
- package/package.json +12 -6
- package/triangle-arrow.d.ts +2 -2
- package/triangle-solid-arrow.d.ts +2 -2
- package/vscode.d.ts +4 -0
package/dark.d.ts
CHANGED
package/editor.d.ts
CHANGED
|
@@ -2,35 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
declare module '@uiw/react-json-view/editor' {
|
|
4
4
|
import { JsonViewProps } from '@uiw/react-json-view';
|
|
5
|
-
import type { CountInfoExtraProps } from '@uiw/react-json-view/cjs/editor/countInfoExtra';
|
|
5
|
+
// import type { CountInfoExtraProps } from '@uiw/react-json-view/cjs/editor/countInfoExtra';
|
|
6
6
|
type Option = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
value: string;
|
|
8
|
+
prevValue: string;
|
|
9
|
+
keyName: string | number;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export interface JsonViewEditorProps<T extends object> extends JsonViewProps<T> {
|
|
13
13
|
/** Callback when value edit functionality */
|
|
14
14
|
onEdit?: (option: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
value: unknown;
|
|
16
|
+
oldValue: unknown;
|
|
17
|
+
keyName?: string | number;
|
|
18
|
+
parentName?: string | number;
|
|
19
|
+
type?: 'value' | 'key';
|
|
20
20
|
}) => void;
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
onAdd?: CountInfoExtraProps<T>['onAdd'];
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
onDelete?: CountInfoExtraProps<T>['onDelete'];
|
|
21
|
+
// /**
|
|
22
|
+
// * When a callback function is passed in, add functionality is enabled. The callback is invoked before additions are completed.
|
|
23
|
+
// * @returns {boolean} Returning false from onAdd will prevent the change from being made.
|
|
24
|
+
// */
|
|
25
|
+
// onAdd?: CountInfoExtraProps<T>['onAdd'];
|
|
26
|
+
// /**
|
|
27
|
+
// * When a callback function is passed in, delete functionality is enabled. The callback is invoked before deletions are completed.
|
|
28
|
+
// * @returns Returning false from onDelete will prevent the change from being made.
|
|
29
|
+
// */
|
|
30
|
+
// onDelete?: CountInfoExtraProps<T>['onDelete'];
|
|
31
31
|
/** Whether enable edit feature. @default true */
|
|
32
32
|
editable?: boolean;
|
|
33
33
|
}
|
|
34
|
-
const JsonViewEditor: import(
|
|
34
|
+
const JsonViewEditor: import('react').ForwardRefExoticComponent<
|
|
35
|
+
Omit<JsonViewEditorProps<object>, 'ref'> & import('react').RefAttributes<HTMLDivElement>
|
|
36
|
+
>;
|
|
35
37
|
export default JsonViewEditor;
|
|
36
38
|
}
|
package/esm/Container.d.ts
CHANGED
|
@@ -6,5 +6,7 @@ export interface ContainerProps<T extends object> extends React.HTMLAttributes<H
|
|
|
6
6
|
level?: number;
|
|
7
7
|
value?: T;
|
|
8
8
|
initialValue?: T;
|
|
9
|
+
/** Index of the parent `keyName` */
|
|
10
|
+
keys?: (string | number)[];
|
|
9
11
|
}
|
|
10
12
|
export declare const Container: React.ForwardRefExoticComponent<ContainerProps<object> & React.RefAttributes<HTMLDivElement>>;
|
package/esm/Container.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["className", "children", "parentValue", "keyid", "level", "value", "initialValue", "keyName"];
|
|
4
|
-
import React, { forwardRef
|
|
5
|
-
import { NestedClose } from
|
|
6
|
-
import { NestedOpen } from
|
|
7
|
-
import { KeyValues } from
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
var _excluded = ["className", "children", "parentValue", "keyid", "level", "value", "initialValue", "keys", "keyName"];
|
|
4
|
+
import React, { forwardRef } from 'react';
|
|
5
|
+
import { NestedClose } from "./comps/NestedClose.js";
|
|
6
|
+
import { NestedOpen } from "./comps/NestedOpen.js";
|
|
7
|
+
import { KeyValues } from "./comps/KeyValues.js";
|
|
8
|
+
import { useIdCompat } from "./comps/useIdCompat.js";
|
|
9
|
+
import { useShowToolsDispatch } from "./store/ShowTools.js";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
export var Container = /*#__PURE__*/forwardRef((props, ref) => {
|
|
12
12
|
var {
|
|
13
13
|
className = '',
|
|
14
|
+
parentValue,
|
|
14
15
|
level = 1,
|
|
15
16
|
value,
|
|
16
17
|
initialValue,
|
|
18
|
+
keys,
|
|
17
19
|
keyName
|
|
18
20
|
} = props,
|
|
19
21
|
elmProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
20
22
|
var dispatch = useShowToolsDispatch();
|
|
21
|
-
var subkeyid =
|
|
23
|
+
var subkeyid = useIdCompat();
|
|
22
24
|
var defaultClassNames = [className, 'w-rjv-inner'].filter(Boolean).join(' ');
|
|
23
25
|
var reset = {
|
|
24
26
|
onMouseEnter: () => dispatch({
|
|
@@ -36,16 +38,24 @@ export var Container = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
36
38
|
expandKey: subkeyid,
|
|
37
39
|
value: value,
|
|
38
40
|
level: level,
|
|
41
|
+
keys: keys,
|
|
42
|
+
parentValue: parentValue,
|
|
39
43
|
keyName: keyName,
|
|
40
44
|
initialValue: initialValue
|
|
41
45
|
}), /*#__PURE__*/_jsx(KeyValues, {
|
|
42
46
|
expandKey: subkeyid,
|
|
43
47
|
value: value,
|
|
44
|
-
level: level
|
|
48
|
+
level: level,
|
|
49
|
+
keys: keys,
|
|
50
|
+
parentValue: parentValue,
|
|
51
|
+
keyName: keyName
|
|
45
52
|
}), /*#__PURE__*/_jsx(NestedClose, {
|
|
46
53
|
expandKey: subkeyid,
|
|
47
54
|
value: value,
|
|
48
|
-
level: level
|
|
55
|
+
level: level,
|
|
56
|
+
keys: keys,
|
|
57
|
+
parentValue: parentValue,
|
|
58
|
+
keyName: keyName
|
|
49
59
|
})]
|
|
50
60
|
}));
|
|
51
61
|
});
|
package/esm/comps/Copied.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { type SectionElementResult } from '../store/Section';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
export type CopiedOption<T extends object> = {
|
|
4
4
|
value?: T;
|
|
5
5
|
copied: boolean;
|
|
6
6
|
setCopied: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
7
|
};
|
|
8
|
-
export interface CopiedProps<T extends object> extends React.SVGProps<SVGSVGElement> {
|
|
9
|
-
value?: T;
|
|
10
|
-
keyName: string | number;
|
|
8
|
+
export interface CopiedProps<T extends object> extends React.SVGProps<SVGSVGElement>, SectionElementResult<T> {
|
|
11
9
|
expandKey: string;
|
|
10
|
+
beforeCopy?: (copyText: string, keyName?: string | number, value?: T, parentValue?: T, expandKey?: string, keys?: (number | string)[]) => string;
|
|
12
11
|
}
|
|
13
12
|
export declare const Copied: {
|
|
14
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,22 +1,27 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["keyName", "value", "expandKey"],
|
|
3
|
+
var _excluded = ["keyName", "value", "parentValue", "expandKey", "keys", "beforeCopy"],
|
|
4
4
|
_excluded2 = ["as", "render"];
|
|
5
5
|
import { useState } from 'react';
|
|
6
|
-
import { useStore } from
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { useStore } from "../store.js";
|
|
7
|
+
import { useSectionStore } from "../store/Section.js";
|
|
8
|
+
import { useShowToolsStore } from "../store/ShowTools.js";
|
|
9
|
+
import { bigIntToString } from "../types/index.js";
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
export var Copied = props => {
|
|
11
12
|
var {
|
|
12
13
|
keyName,
|
|
13
14
|
value,
|
|
14
|
-
|
|
15
|
+
parentValue,
|
|
16
|
+
expandKey,
|
|
17
|
+
keys,
|
|
18
|
+
beforeCopy
|
|
15
19
|
} = props,
|
|
16
20
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
17
21
|
var {
|
|
18
22
|
onCopied,
|
|
19
|
-
enableClipboard
|
|
23
|
+
enableClipboard,
|
|
24
|
+
beforeCopy: globalBeforeCopy
|
|
20
25
|
} = useStore();
|
|
21
26
|
var showTools = useShowToolsStore();
|
|
22
27
|
var isShowTools = showTools[expandKey];
|
|
@@ -24,21 +29,51 @@ export var Copied = props => {
|
|
|
24
29
|
var {
|
|
25
30
|
Copied: Comp = {}
|
|
26
31
|
} = useSectionStore();
|
|
32
|
+
var sectionBeforeCopy = Comp == null ? void 0 : Comp.beforeCopy;
|
|
27
33
|
if (enableClipboard === false || !isShowTools) return null;
|
|
28
34
|
var click = event => {
|
|
29
35
|
event.stopPropagation();
|
|
30
|
-
var copyText =
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
var copyText = '';
|
|
37
|
+
if (typeof value === 'number' && value === Infinity) {
|
|
38
|
+
copyText = 'Infinity';
|
|
39
|
+
} else if (typeof value === 'number' && isNaN(value)) {
|
|
40
|
+
copyText = 'NaN';
|
|
41
|
+
} else if (typeof value === 'bigint') {
|
|
42
|
+
copyText = bigIntToString(value);
|
|
43
|
+
} else if (value instanceof Date) {
|
|
44
|
+
copyText = value.toLocaleString();
|
|
45
|
+
} else {
|
|
46
|
+
copyText = JSON.stringify(value, (_, v) => typeof v === 'bigint' ? bigIntToString(v) : v, 2);
|
|
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
|
+
}
|
|
55
|
+
onCopied && onCopied(copyText, value);
|
|
56
|
+
setCopied(true);
|
|
57
|
+
var _clipboard = navigator.clipboard || {
|
|
58
|
+
writeText(text) {
|
|
59
|
+
return new Promise((reslove, reject) => {
|
|
60
|
+
var textarea = document.createElement('textarea');
|
|
61
|
+
textarea.style.position = 'absolute';
|
|
62
|
+
textarea.style.opacity = '0';
|
|
63
|
+
textarea.style.left = '-99999999px';
|
|
64
|
+
textarea.value = text;
|
|
65
|
+
document.body.appendChild(textarea);
|
|
66
|
+
textarea.select();
|
|
67
|
+
if (!document.execCommand('copy')) {
|
|
68
|
+
reject();
|
|
69
|
+
} else {
|
|
70
|
+
reslove();
|
|
71
|
+
}
|
|
72
|
+
textarea.remove();
|
|
73
|
+
});
|
|
33
74
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (typeof value === 'number' && value === Infinity) copyText = 'Infinity';
|
|
37
|
-
if (typeof value === 'number' && isNaN(value)) copyText = 'NaN';
|
|
38
|
-
if (typeof value === 'bigint') copyText = value + 'n';
|
|
39
|
-
navigator.clipboard.writeText(copyText).then(() => {
|
|
40
|
-
onCopied && onCopied(copyText, value);
|
|
41
|
-
setCopied(true);
|
|
75
|
+
};
|
|
76
|
+
_clipboard.writeText(copyText).then(() => {
|
|
42
77
|
var timer = setTimeout(() => {
|
|
43
78
|
setCopied(false);
|
|
44
79
|
clearTimeout(timer);
|
|
@@ -46,6 +81,9 @@ export var Copied = props => {
|
|
|
46
81
|
}).catch(error => {});
|
|
47
82
|
};
|
|
48
83
|
var svgProps = {
|
|
84
|
+
style: {
|
|
85
|
+
display: 'inline-flex'
|
|
86
|
+
},
|
|
49
87
|
fill: copied ? 'var(--w-rjv-copied-success-color, #28a745)' : 'var(--w-rjv-copied-color, currentColor)',
|
|
50
88
|
onClick: click
|
|
51
89
|
};
|
|
@@ -53,13 +91,17 @@ export var Copied = props => {
|
|
|
53
91
|
render
|
|
54
92
|
} = Comp,
|
|
55
93
|
reset = _objectWithoutPropertiesLoose(Comp, _excluded2);
|
|
56
|
-
var elmProps = _extends({}, reset, other, svgProps
|
|
94
|
+
var elmProps = _extends({}, reset, other, svgProps, {
|
|
95
|
+
style: _extends({}, reset.style, other.style, svgProps.style)
|
|
96
|
+
});
|
|
57
97
|
var isRender = render && typeof render === 'function';
|
|
58
98
|
var child = isRender && render(_extends({}, elmProps, {
|
|
59
99
|
'data-copied': copied
|
|
60
100
|
}), {
|
|
61
101
|
value,
|
|
62
|
-
keyName
|
|
102
|
+
keyName,
|
|
103
|
+
keys,
|
|
104
|
+
parentValue
|
|
63
105
|
});
|
|
64
106
|
if (child) return child;
|
|
65
107
|
if (copied) {
|
package/esm/comps/KeyValues.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
value?: T;
|
|
4
|
-
parentValue?: T;
|
|
1
|
+
import { type SectionElementResult } from '../store/Section';
|
|
2
|
+
interface KeyValuesProps<T extends object> extends SectionElementResult<T> {
|
|
5
3
|
expandKey?: string;
|
|
6
4
|
level: number;
|
|
7
5
|
}
|
package/esm/comps/KeyValues.js
CHANGED
|
@@ -1,33 +1,56 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import { Fragment,
|
|
3
|
-
import { useStore } from
|
|
4
|
-
import { useExpandsStore } from
|
|
5
|
-
import { useShowToolsDispatch } from
|
|
6
|
-
import { Value } from
|
|
7
|
-
import { KeyNameComp } from
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
2
|
+
import { Fragment, useRef } from 'react';
|
|
3
|
+
import { useStore } from "../store.js";
|
|
4
|
+
import { useExpandsStore } from "../store/Expands.js";
|
|
5
|
+
import { useShowToolsDispatch } from "../store/ShowTools.js";
|
|
6
|
+
import { Value } from "./Value.js";
|
|
7
|
+
import { KeyNameComp } from "../section/KeyName.js";
|
|
8
|
+
import { RowComp } from "../section/Row.js";
|
|
9
|
+
import { Container } from "../Container.js";
|
|
10
|
+
import { Quote, Colon } from "../symbol/index.js";
|
|
11
|
+
import { useHighlight } from "../utils/useHighlight.js";
|
|
12
|
+
import { Copied } from "../comps/Copied.js";
|
|
13
|
+
import { useIdCompat } from "../comps/useIdCompat.js";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
15
|
export var KeyValues = props => {
|
|
14
16
|
var _expands$expandKey;
|
|
15
17
|
var {
|
|
18
|
+
keyName,
|
|
16
19
|
value,
|
|
17
20
|
expandKey = '',
|
|
18
|
-
level
|
|
21
|
+
level,
|
|
22
|
+
keys = [],
|
|
23
|
+
parentValue
|
|
19
24
|
} = props;
|
|
20
25
|
var expands = useExpandsStore();
|
|
21
26
|
var {
|
|
22
27
|
objectSortKeys,
|
|
23
28
|
indentWidth,
|
|
24
|
-
collapsed
|
|
29
|
+
collapsed,
|
|
30
|
+
shouldExpandNodeInitially
|
|
25
31
|
} = useStore();
|
|
26
|
-
var
|
|
27
|
-
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey :
|
|
32
|
+
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
33
|
+
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
|
|
34
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
35
|
+
value,
|
|
36
|
+
keys,
|
|
37
|
+
level,
|
|
38
|
+
keyName,
|
|
39
|
+
parentValue
|
|
40
|
+
});
|
|
41
|
+
if (shouldExpandNodeInitially && collapsed === false) {
|
|
42
|
+
if (expands[expandKey] === undefined && !shouldExpand) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
if (expands[expandKey] === undefined && shouldExpand) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
28
50
|
if (isExpanded) {
|
|
29
51
|
return null;
|
|
30
52
|
}
|
|
53
|
+
var isMyArray = Array.isArray(value);
|
|
31
54
|
// object
|
|
32
55
|
var entries = isMyArray ? Object.entries(value).map(m => [Number(m[0]), m[1]]) : Object.entries(value);
|
|
33
56
|
if (objectSortKeys) {
|
|
@@ -54,6 +77,7 @@ export var KeyValues = props => {
|
|
|
54
77
|
return /*#__PURE__*/_jsx(KeyValuesItem, {
|
|
55
78
|
parentValue: value,
|
|
56
79
|
keyName: key,
|
|
80
|
+
keys: [...keys, key],
|
|
57
81
|
value: val,
|
|
58
82
|
level: level
|
|
59
83
|
}, idx);
|
|
@@ -64,6 +88,8 @@ KeyValues.displayName = 'JVR.KeyValues';
|
|
|
64
88
|
export var KayName = props => {
|
|
65
89
|
var {
|
|
66
90
|
keyName,
|
|
91
|
+
parentValue,
|
|
92
|
+
keys,
|
|
67
93
|
value
|
|
68
94
|
} = props;
|
|
69
95
|
var {
|
|
@@ -76,21 +102,25 @@ export var KayName = props => {
|
|
|
76
102
|
highlightUpdates,
|
|
77
103
|
highlightContainer
|
|
78
104
|
});
|
|
105
|
+
var compProps = {
|
|
106
|
+
keyName,
|
|
107
|
+
value,
|
|
108
|
+
keys,
|
|
109
|
+
parentValue
|
|
110
|
+
};
|
|
79
111
|
return /*#__PURE__*/_jsxs(Fragment, {
|
|
80
112
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
81
113
|
ref: highlightContainer,
|
|
82
|
-
children: [/*#__PURE__*/_jsx(Quote, {
|
|
114
|
+
children: [/*#__PURE__*/_jsx(Quote, _extends({
|
|
83
115
|
isNumber: isNumber,
|
|
84
116
|
"data-placement": "left"
|
|
85
|
-
}), /*#__PURE__*/_jsx(KeyNameComp, {
|
|
86
|
-
keyName: keyName,
|
|
87
|
-
value: value,
|
|
117
|
+
}, compProps)), /*#__PURE__*/_jsx(KeyNameComp, _extends({}, compProps, {
|
|
88
118
|
children: keyName
|
|
89
|
-
}), /*#__PURE__*/_jsx(Quote, {
|
|
119
|
+
})), /*#__PURE__*/_jsx(Quote, _extends({
|
|
90
120
|
isNumber: isNumber,
|
|
91
121
|
"data-placement": "right"
|
|
92
|
-
})]
|
|
93
|
-
}), /*#__PURE__*/_jsx(Colon, {})]
|
|
122
|
+
}, compProps))]
|
|
123
|
+
}), /*#__PURE__*/_jsx(Colon, _extends({}, compProps))]
|
|
94
124
|
});
|
|
95
125
|
};
|
|
96
126
|
KayName.displayName = 'JVR.KayName';
|
|
@@ -99,10 +129,11 @@ export var KeyValuesItem = props => {
|
|
|
99
129
|
keyName,
|
|
100
130
|
value,
|
|
101
131
|
parentValue,
|
|
102
|
-
level = 0
|
|
132
|
+
level = 0,
|
|
133
|
+
keys = []
|
|
103
134
|
} = props;
|
|
104
135
|
var dispatch = useShowToolsDispatch();
|
|
105
|
-
var subkeyid =
|
|
136
|
+
var subkeyid = useIdCompat();
|
|
106
137
|
var isMyArray = Array.isArray(value);
|
|
107
138
|
var isMySet = value instanceof Set;
|
|
108
139
|
var isMyMap = value instanceof Map;
|
|
@@ -117,6 +148,7 @@ export var KeyValuesItem = props => {
|
|
|
117
148
|
value: myValue,
|
|
118
149
|
parentValue: parentValue,
|
|
119
150
|
initialValue: value,
|
|
151
|
+
keys: keys,
|
|
120
152
|
level: level + 1
|
|
121
153
|
});
|
|
122
154
|
}
|
|
@@ -128,15 +160,27 @@ export var KeyValuesItem = props => {
|
|
|
128
160
|
[subkeyid]: false
|
|
129
161
|
})
|
|
130
162
|
};
|
|
131
|
-
return /*#__PURE__*/_jsxs(
|
|
132
|
-
className: "w-rjv-line"
|
|
163
|
+
return /*#__PURE__*/_jsxs(RowComp, _extends({
|
|
164
|
+
className: "w-rjv-line",
|
|
165
|
+
value: value,
|
|
166
|
+
keyName: keyName,
|
|
167
|
+
keys: keys,
|
|
168
|
+
parentValue: parentValue
|
|
133
169
|
}, reset, {
|
|
134
170
|
children: [/*#__PURE__*/_jsx(KayName, {
|
|
135
171
|
keyName: keyName,
|
|
136
|
-
value: value
|
|
172
|
+
value: value,
|
|
173
|
+
keys: keys,
|
|
174
|
+
parentValue: parentValue
|
|
137
175
|
}), /*#__PURE__*/_jsx(Value, {
|
|
138
176
|
keyName: keyName,
|
|
139
177
|
value: value,
|
|
178
|
+
keys: keys
|
|
179
|
+
}), /*#__PURE__*/_jsx(Copied, {
|
|
180
|
+
keyName: keyName,
|
|
181
|
+
value: value,
|
|
182
|
+
keys: keys,
|
|
183
|
+
parentValue: parentValue,
|
|
140
184
|
expandKey: subkeyid
|
|
141
185
|
})]
|
|
142
186
|
}));
|
package/esm/comps/NestedClose.js
CHANGED
|
@@ -1,21 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import { useStore } from "../store.js";
|
|
3
|
+
import { useExpandsStore } from "../store/Expands.js";
|
|
4
|
+
import { BracketsClose } from "../symbol/index.js";
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
export var NestedClose = props => {
|
|
6
7
|
var _expands$expandKey;
|
|
7
8
|
var {
|
|
9
|
+
keyName,
|
|
8
10
|
value,
|
|
9
11
|
expandKey,
|
|
10
|
-
|
|
12
|
+
parentValue,
|
|
13
|
+
level,
|
|
14
|
+
keys = []
|
|
11
15
|
} = props;
|
|
12
16
|
var expands = useExpandsStore();
|
|
13
|
-
var isArray = Array.isArray(value);
|
|
14
17
|
var {
|
|
15
|
-
collapsed
|
|
18
|
+
collapsed,
|
|
19
|
+
shouldExpandNodeInitially
|
|
16
20
|
} = useStore();
|
|
17
|
-
var
|
|
18
|
-
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey :
|
|
21
|
+
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
22
|
+
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : shouldExpandNodeInitially ? false : defaultExpanded;
|
|
23
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
24
|
+
value,
|
|
25
|
+
keys,
|
|
26
|
+
level,
|
|
27
|
+
keyName,
|
|
28
|
+
parentValue
|
|
29
|
+
});
|
|
30
|
+
if (shouldExpandNodeInitially && collapsed === false) {
|
|
31
|
+
if (expands[expandKey] === undefined && !shouldExpand) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
if (expands[expandKey] === undefined && shouldExpand) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
19
39
|
var len = Object.keys(value).length;
|
|
20
40
|
if (isExpanded || len === 0) {
|
|
21
41
|
return null;
|
|
@@ -23,12 +43,21 @@ export var NestedClose = props => {
|
|
|
23
43
|
var style = {
|
|
24
44
|
paddingLeft: 4
|
|
25
45
|
};
|
|
46
|
+
var compProps = {
|
|
47
|
+
keyName,
|
|
48
|
+
value,
|
|
49
|
+
keys,
|
|
50
|
+
parentValue
|
|
51
|
+
};
|
|
52
|
+
var isArray = Array.isArray(value);
|
|
53
|
+
var isMySet = value instanceof Set;
|
|
26
54
|
return /*#__PURE__*/_jsx("div", {
|
|
27
55
|
style: style,
|
|
28
|
-
children: /*#__PURE__*/_jsx(BracketsClose, {
|
|
29
|
-
isBrackets: isArray || isMySet
|
|
56
|
+
children: /*#__PURE__*/_jsx(BracketsClose, _extends({
|
|
57
|
+
isBrackets: isArray || isMySet
|
|
58
|
+
}, compProps, {
|
|
30
59
|
isVisiable: true
|
|
31
|
-
})
|
|
60
|
+
}))
|
|
32
61
|
});
|
|
33
62
|
};
|
|
34
63
|
NestedClose.displayName = 'JVR.NestedClose';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
value?: T;
|
|
1
|
+
import { type SectionElementResult } from '../store/Section';
|
|
2
|
+
export interface NestedOpenProps<T extends object> extends SectionElementResult<T> {
|
|
4
3
|
initialValue?: T;
|
|
5
4
|
expandKey: string;
|
|
6
5
|
level: number;
|