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.
@@ -15,4 +15,5 @@ export type Config = {
15
15
  ignoreCaseForKey: boolean;
16
16
  recursiveEqual: boolean;
17
17
  preserveKeyOrder: DifferOptions["preserveKeyOrder"];
18
+ inlineDiffMode: "word" | "char";
18
19
  };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
@@ -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;
@@ -41,6 +41,7 @@ export type VirtualizedDiffViewerProps = {
41
41
  className?: string;
42
42
  miniMapWidth?: number;
43
43
  inlineDiffOptions?: InlineDiffOptions;
44
+ overScanCount?: number;
44
45
  };
45
46
  export type DiffMinimapProps = {
46
47
  leftDiff: DiffRowOrCollapsed[];
@@ -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";
@@ -0,0 +1,6 @@
1
+ import type { InlineDiffOptions, InlineDiffResult } from "json-diff-kit";
2
+ declare function getInlineDiff(l: string, r: string, options: InlineDiffOptions): [
3
+ InlineDiffResult[],
4
+ InlineDiffResult[]
5
+ ];
6
+ export default getInlineDiff;
@@ -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
@@ -15,6 +15,7 @@ type VirtualizedDiffViewerProps = {
15
15
  className?: string;
16
16
  miniMapWidth?: number;
17
17
  inlineDiffOptions?: InlineDiffOptions;
18
+ overScanCount?: number;
18
19
  };
19
20
 
20
21
  declare const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps>;
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.10",
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
- };