virtual-react-json-diff 1.0.10 → 1.0.12
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 +2 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/demo/src/types/index.d.ts +1 -0
- package/dist/cjs/types/demo/vite.config.d.ts +2 -0
- package/dist/cjs/types/src/components/DiffViewer/components/SearchboxHolder.d.ts +9 -0
- package/dist/cjs/types/src/components/DiffViewer/components/VirtualDiffGrid.d.ts +25 -0
- package/dist/cjs/types/src/components/DiffViewer/components/VirtualDiffTable.d.ts +19 -0
- package/dist/cjs/types/src/components/DiffViewer/types/index.d.ts +1 -0
- package/dist/cjs/types/src/components/DiffViewer/utils/constants.d.ts +4 -0
- package/dist/cjs/types/src/components/DiffViewer/utils/json-diff/get-inline-diff.d.ts +6 -0
- package/dist/cjs/types/src/components/DiffViewer/utils/json-diff/get-inline-syntax-highlight.d.ts +7 -0
- package/dist/cjs/types/src/components/DiffViewer/utils/json-diff/get-segments.d.ts +5 -0
- package/dist/cjs/types/src/components/DiffViewer/utils/json-diff/row-renderer-grid.d.ts +10 -0
- package/dist/cjs/types/src/components/DiffViewer/utils/json-diff/row-renderer.d.ts +10 -0
- package/dist/cjs/types/src/components/DiffViewer/utils/json-diff/segment-util.d.ts +11 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/types/src/components/DiffViewer/Diff.stories.d.ts +0 -18
- package/dist/cjs/types/src/components/DiffViewer/hooks/useDiffSegments.d.ts +0 -8
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SearchState } from "../types";
|
|
2
|
+
type Props = {
|
|
3
|
+
searchState: SearchState;
|
|
4
|
+
handleSearch: (term: string) => void;
|
|
5
|
+
navigateMatch: (direction: "next" | "prev") => void;
|
|
6
|
+
hideSearch?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare function SearchboxHolder({ searchState, handleSearch, navigateMatch, hideSearch }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export default SearchboxHolder;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InlineDiffOptions } from "json-diff-kit";
|
|
2
|
+
import type { Dispatch } from "react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { VariableSizeList as List } from "react-window";
|
|
5
|
+
import type { DiffRowOrCollapsed } from "../types";
|
|
6
|
+
type ListDataType = {
|
|
7
|
+
leftDiff: DiffRowOrCollapsed[];
|
|
8
|
+
rightDiff: DiffRowOrCollapsed[];
|
|
9
|
+
onExpand: (segmentIndex: number) => void;
|
|
10
|
+
inlineDiffOptions?: InlineDiffOptions;
|
|
11
|
+
};
|
|
12
|
+
type VirtualDiffGridProps = {
|
|
13
|
+
leftDiff: DiffRowOrCollapsed[];
|
|
14
|
+
rightDiff: DiffRowOrCollapsed[];
|
|
15
|
+
outerRef: React.RefObject<Node | null>;
|
|
16
|
+
listRef: React.RefObject<List<ListDataType>>;
|
|
17
|
+
height: number;
|
|
18
|
+
inlineDiffOptions?: InlineDiffOptions;
|
|
19
|
+
className?: string;
|
|
20
|
+
setScrollTop: Dispatch<React.SetStateAction<number>>;
|
|
21
|
+
onExpand: (segmentIndex: number) => void;
|
|
22
|
+
overScanCount?: number;
|
|
23
|
+
};
|
|
24
|
+
declare const VirtualDiffGrid: React.FC<VirtualDiffGridProps>;
|
|
25
|
+
export default VirtualDiffGrid;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { InlineDiffOptions } from "json-diff-kit";
|
|
2
|
+
import type { Dispatch } from "react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { VariableSizeList as List } from "react-window";
|
|
5
|
+
import type { DiffRowOrCollapsed } from "../types";
|
|
6
|
+
type VirtualDiffTableProps = {
|
|
7
|
+
leftDiff: DiffRowOrCollapsed[];
|
|
8
|
+
rightDiff: DiffRowOrCollapsed[];
|
|
9
|
+
outerRef: React.RefObject<Node | null>;
|
|
10
|
+
listRef: React.RefObject<List<any>>;
|
|
11
|
+
height: number;
|
|
12
|
+
inlineDiffOptions?: InlineDiffOptions;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
setScrollTop: Dispatch<React.SetStateAction<number>>;
|
|
16
|
+
onExpand: (segmentIndex: number) => void;
|
|
17
|
+
};
|
|
18
|
+
declare const VirtualDiffTable: React.FC<VirtualDiffTableProps>;
|
|
19
|
+
export default VirtualDiffTable;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { DiffRow } from "../types";
|
|
1
2
|
export declare const DIFF_VIEWER_CLASS = "json-diff-viewer-theme-custom";
|
|
2
3
|
export declare const DEFAULT_ROW_HEIGHT = 20;
|
|
4
|
+
export declare const DEFAULT_HEIGHT = 380;
|
|
5
|
+
export declare const DEFAULT_MINIMAP_WIDTH = 20;
|
|
3
6
|
export declare function getRowHeightFromCSS(): number;
|
|
4
7
|
export declare const COLLAPSED_ROW_HEIGHT = 20;
|
|
5
8
|
export declare const SEARCH_DEBOUNCE_MS = 300;
|
|
@@ -7,3 +10,4 @@ export declare function isCollapsed(line: any): line is {
|
|
|
7
10
|
type: "collapsed";
|
|
8
11
|
segmentIndex: number;
|
|
9
12
|
};
|
|
13
|
+
export declare function equalEmptyLine(cell: DiffRow): "" | "empty-equal-cell";
|
package/dist/cjs/types/src/components/DiffViewer/utils/json-diff/get-inline-syntax-highlight.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type InlineHighlightResult = {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
token: "plain" | "number" | "boolean" | "null" | "key" | "punctuation" | "string" | "invalid";
|
|
5
|
+
};
|
|
6
|
+
declare function syntaxHighlightLine(enabled: boolean, text: string, offset: number): InlineHighlightResult[];
|
|
7
|
+
export default syntaxHighlightLine;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DiffResult } from "json-diff-kit";
|
|
2
|
+
import type { HideUnchangedLinesOptions } from "json-diff-kit/typings/viewer";
|
|
3
|
+
import type { HiddenUnchangedLinesInfo, SegmentItem } from "../../types";
|
|
4
|
+
declare function getSegments(l: DiffResult[], r: DiffResult[], options: HideUnchangedLinesOptions, jsonsAreEqual: boolean): (SegmentItem | HiddenUnchangedLinesInfo)[];
|
|
5
|
+
export default getSegments;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InlineDiffOptions } from "json-diff-kit";
|
|
2
|
+
import type { ListChildComponentProps } from "react-window";
|
|
3
|
+
import type { DiffRowOrCollapsed } from "../../types";
|
|
4
|
+
declare function RowRendererGrid({ index, style, data }: ListChildComponentProps<{
|
|
5
|
+
leftDiff: DiffRowOrCollapsed[];
|
|
6
|
+
rightDiff: DiffRowOrCollapsed[];
|
|
7
|
+
onExpand: (segmentIndex: number) => void;
|
|
8
|
+
inlineDiffOptions?: InlineDiffOptions;
|
|
9
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default RowRendererGrid;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InlineDiffOptions } from "json-diff-kit";
|
|
2
|
+
import type { ListChildComponentProps } from "react-window";
|
|
3
|
+
import type { DiffRowOrCollapsed } from "../../types";
|
|
4
|
+
declare function RowRenderer({ index, style, data }: ListChildComponentProps<{
|
|
5
|
+
leftDiff: DiffRowOrCollapsed[];
|
|
6
|
+
rightDiff: DiffRowOrCollapsed[];
|
|
7
|
+
onExpand: (segmentIndex: number) => void;
|
|
8
|
+
inlineDiffOptions?: InlineDiffOptions;
|
|
9
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default RowRenderer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InlineDiffResult } from "json-diff-kit";
|
|
2
|
+
import type { SegmentItem } from "../../types";
|
|
3
|
+
import type { InlineHighlightResult } from "./get-inline-syntax-highlight";
|
|
4
|
+
export type InlineRenderInfo = InlineDiffResult & InlineHighlightResult;
|
|
5
|
+
/**
|
|
6
|
+
* Merge two segments array into one, divide the segment if necessary.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mergeSegments(tokens: InlineHighlightResult[], diffs: InlineDiffResult[]): InlineRenderInfo[];
|
|
9
|
+
export declare function expandSegment(prev: SegmentItem[], index: number): SegmentItem[];
|
|
10
|
+
export declare function hideAllSegments(prev: SegmentItem[]): SegmentItem[];
|
|
11
|
+
export declare function hasExpandedSegments(segments: SegmentItem[]): boolean;
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtual-react-json-diff",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"description": "Fast, virtualized React component for visually comparing large JSON objects. Includes search, theming, and minimap.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Utku Akyüz"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import type { DifferOptions } from "json-diff-kit";
|
|
3
|
-
import { VirtualDiffViewer } from "../..";
|
|
4
|
-
type StoryProps = React.ComponentProps<typeof VirtualDiffViewer> & {
|
|
5
|
-
detectCircular?: boolean;
|
|
6
|
-
maxDepth?: number;
|
|
7
|
-
showModifications?: boolean;
|
|
8
|
-
arrayDiffMethod?: DifferOptions["arrayDiffMethod"];
|
|
9
|
-
compareKey?: string;
|
|
10
|
-
ignoreCase?: boolean;
|
|
11
|
-
ignoreCaseForKey?: boolean;
|
|
12
|
-
recursiveEqual?: boolean;
|
|
13
|
-
preserveKeyOrder?: DifferOptions["preserveKeyOrder"];
|
|
14
|
-
};
|
|
15
|
-
declare const meta: Meta<StoryProps>;
|
|
16
|
-
export default meta;
|
|
17
|
-
type Story = StoryObj<StoryProps>;
|
|
18
|
-
export declare const Primary: Story;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { DiffRowOrCollapsed, SegmentItem } from "../types";
|
|
2
|
-
export declare function useDiffSegments(oldValue: any, newValue: any, differOptions?: any): {
|
|
3
|
-
leftView: DiffRowOrCollapsed[];
|
|
4
|
-
rightView: DiffRowOrCollapsed[];
|
|
5
|
-
segments: SegmentItem[];
|
|
6
|
-
expandSegment: (segmentIndex: number) => void;
|
|
7
|
-
hideAllSegments: () => void;
|
|
8
|
-
};
|