Skip to content

Commit b77f00b

Browse files
committed
doc: update migrate document.
1 parent 0b421e3 commit b77f00b

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

core/README.md

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,45 @@ export default function Demo() {
670670

671671
## Props
672672

673+
Migrate from kkt v1 to v2. The new v2 version has removed the ~~`quotes`~~ and ~~`components`~~ props.
674+
675+
```diff
676+
export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
677+
- quotes?: "'" | '"' | '';
678+
- components?: {};
679+
}
680+
```
681+
682+
```ts
683+
export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
684+
/** This property contains your input JSON */
685+
value?: T;
686+
/** Define the root node name. @default undefined */
687+
keyName?: string | number;
688+
/** Whether sort keys through `String.prototype.localeCompare()` @default false */
689+
objectSortKeys?: boolean | ((a: string, b: string) => number);
690+
/** Set the indent-width for nested objects @default 15 */
691+
indentWidth?: number;
692+
/** When set to `true`, `objects` and `arrays` are labeled with size @default true */
693+
displayObjectSize?: boolean;
694+
/** When set to `true`, data type labels prefix values @default true */
695+
displayDataTypes?: boolean;
696+
/** The user can copy objects and arrays to clipboard by clicking on the clipboard icon. @default true */
697+
enableClipboard?: boolean;
698+
/** Whether to highlight updates. @default true */
699+
highlightUpdates?: boolean;
700+
/** Callback function for when a treeNode is expanded or collapsed */
701+
onExpand?: (props: {
702+
expand: boolean;
703+
value?: T;
704+
keyid: string;
705+
keyName?: string | number;
706+
}) => void;
707+
/** Fires event when you copy */
708+
onCopied?: (text: string, value?: T) => void;
709+
}
710+
```
711+
673712
```ts
674713
import { BraceLeft } from './symbol/BraceLeft';
675714
import { BraceRight } from './symbol/BraceRight';
@@ -700,36 +739,7 @@ import { KeyName } from './section/KeyName';
700739
import { type CountInfoProps } from "./comps/CountInfo";
701740
import { type CopiedOption } from "./comps/Copied";
702741
import { type NestedOpenProps } from "./comps/NestedOpen";
703-
export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
704-
/** This property contains your input JSON */
705-
value?: T;
706-
/** Whether sort keys through `String.prototype.localeCompare()` @default false */
707-
objectSortKeys?: boolean | ((a: string, b: string) => number);
708-
/** Set the indent-width for nested objects @default 15 */
709-
indentWidth?: number;
710-
/** When set to `true`, `objects` and `arrays` are labeled with size @default true */
711-
displayObjectSize?: boolean;
712-
/** When set to `true`, data type labels prefix values @default true */
713-
displayDataTypes?: boolean;
714-
/** The user can copy objects and arrays to clipboard by clicking on the clipboard icon. @default true */
715-
enableClipboard?: boolean;
716-
/** Whether to highlight updates. @default true */
717-
highlightUpdates?: boolean;
718-
/** Callback function for when a treeNode is expanded or collapsed */
719-
onExpand?: (props: {
720-
expand: boolean;
721-
value?: T;
722-
keyid: string;
723-
keyName?: string | number;
724-
}) => void;
725-
/** Fires event when you copy */
726-
onCopied?: (text: string, value?: T) => void;
727-
/** Redefine interface elements to re-render. */
728-
components?: {
729-
copied?: (props: React.SVGProps<SVGSVGElement>, opts: CopiedOption<T>) => React.ReactNode;
730-
countInfoExtra?: (props: NestedOpenProps<T>) => React.ReactNode;
731-
};
732-
}
742+
733743
type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
734744
Bigint: typeof Bigint;
735745
Date: typeof Date;

core/src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export interface JsonViewProps<T extends object>
4242
extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
4343
/** This property contains your input JSON */
4444
value?: T;
45+
/** Define the root node name. @default undefined */
46+
keyName?: string | number;
4547
/** Whether sort keys through `String.prototype.localeCompare()` @default false */
4648
objectSortKeys?: boolean | ((a: string, b: string) => number);
4749
/** Set the indent-width for nested objects @default 15 */

0 commit comments

Comments
 (0)