@mantine-vue/code-highlight 3.4.0 → 3.6.0

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.
@@ -0,0 +1,11 @@
1
+ export declare const JsonViewer: import("@mantine-vue/core").MantineComponent<{
2
+ props: import("./JsonViewer.types").JsonViewerProps;
3
+ emits: import("./JsonViewer.types").JsonViewerEmits;
4
+ ref: HTMLDivElement;
5
+ element: "div";
6
+ stylesNames: import("./JsonViewer.types").JsonViewerStylesNames;
7
+ vars: import("./JsonViewer.types").JsonViewerCssVariables;
8
+ }>;
9
+ export type * from './JsonViewer.types';
10
+ export { PATH_SEPARATOR, serializePath } from './json-viewer-utils';
11
+ export { serializePath as serializeJsonViewerPath } from './json-viewer-utils';
@@ -0,0 +1,80 @@
1
+ import type { BoxProps, Factory, MantineRadius, MantineSize, StylesApiProps } from '@mantine-vue/core';
2
+ export type JsonViewerStylesNames = 'root' | 'node' | 'toggle' | 'key' | 'value' | 'bracket' | 'type' | 'size' | 'ellipsis' | 'copyButton' | 'content' | 'row' | 'scrollarea' | 'lineNumbers' | 'wrapper' | 'copyAllButton' | 'controls' | 'control';
3
+ export type JsonViewerCssVariables = {
4
+ root: '--jv-radius' | '--jv-fz' | '--jv-indent';
5
+ };
6
+ export type JsonViewerHighlightType = 'added' | 'removed';
7
+ export interface JsonViewerOwnProps {
8
+ classNames?: any;
9
+ styles?: any;
10
+ vars?: any;
11
+ unstyled?: boolean;
12
+ /** JSON data to display */
13
+ value: any;
14
+ /** Label displayed for the root node @default false */
15
+ rootName?: string | false;
16
+ /** Number of levels to expand by default. Applied only to the `value` present on mount; pass a `key` or use controlled `expandedPaths` to re-apply it after `value` changes. @default 1 */
17
+ defaultExpandDepth?: number;
18
+ /** Controlled expanded paths */
19
+ expandedPaths?: string[];
20
+ /** Max number of items to show before truncation @default 100 */
21
+ maxDisplayLength?: number;
22
+ /** Whether to show type badges next to values @default false */
23
+ withTypes?: boolean;
24
+ /** Whether to show item count for objects/arrays @default false */
25
+ withSize?: boolean;
26
+ /** Whether to show copy button on hover for individual nodes @default false */
27
+ withCopy?: boolean;
28
+ /** Whether to show a copy button to copy the entire JSON @default false */
29
+ withCopyButton?: boolean;
30
+ /** Whether to show quotes around string values @default true */
31
+ withQuotes?: boolean;
32
+ /** Whether to show quotes around keys @default false */
33
+ withKeyQuotes?: boolean;
34
+ /** Collapse strings longer than this value @default false */
35
+ collapseStringsAfterLength?: number | false;
36
+ /** Sort object keys @default false */
37
+ sortKeys?: boolean | ((a: string, b: string) => number);
38
+ /** Group arrays into chunks when array length exceeds this value @default false */
39
+ groupArraysAfterLength?: number | false;
40
+ /** Key of `theme.radius` or any valid CSS value to set border-radius @default 'sm' */
41
+ radius?: MantineRadius;
42
+ /** Font size @default '13px' */
43
+ fontSize?: MantineSize | (string & {}) | number;
44
+ /** Indent width in px @default 16 */
45
+ indentWidth?: number;
46
+ /** Adds border to the root element @default false */
47
+ withBorder?: boolean;
48
+ /** Label for copy button @default 'Copy' */
49
+ copyLabel?: string;
50
+ /** Label for copied state @default 'Copied' */
51
+ copiedLabel?: string;
52
+ /** Label for expand all button @default 'Expand all' */
53
+ expandAllLabel?: string;
54
+ /** Label for collapse all button @default 'Collapse all' */
55
+ collapseAllLabel?: string;
56
+ /** Whether to show expand all / collapse all controls @default false */
57
+ withControls?: boolean;
58
+ /** Map of JSON paths to highlight type ('added' or 'removed'), use serializeJsonViewerPath to build keys */
59
+ highlightItems?: Record<string, JsonViewerHighlightType>;
60
+ /** When true, all nodes are expanded and expand/collapse is disabled @default false */
61
+ allExpanded?: boolean;
62
+ /** Whether to show line numbers @default false */
63
+ withLineNumbers?: boolean;
64
+ /** Whether to show expand/collapse chevrons @default false */
65
+ withChevrons?: boolean;
66
+ }
67
+ export type JsonViewerProps = Omit<BoxProps, keyof JsonViewerOwnProps> & JsonViewerOwnProps & StylesApiProps<any>;
68
+ export interface JsonViewerEmits {
69
+ 'update:expandedPaths': [paths: string[]];
70
+ expandedPathsChange: [paths: string[]];
71
+ valueSelect: [path: string[], value: any];
72
+ }
73
+ export type JsonViewerFactory = Factory<{
74
+ props: JsonViewerProps;
75
+ emits: JsonViewerEmits;
76
+ ref: HTMLDivElement;
77
+ element: 'div';
78
+ stylesNames: JsonViewerStylesNames;
79
+ vars: JsonViewerCssVariables;
80
+ }>;
@@ -0,0 +1,14 @@
1
+ import type { JsonViewerOwnProps } from './JsonViewer.types';
2
+ declare const varsResolver: (theme: import("@mantine-vue/core").MantineTheme, props: any, ctx: Record<string, any>) => Record<string, Record<string, string | undefined>>;
3
+ export { varsResolver };
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
6
+ declare const __VLS_export: import("vue").DefineComponent<JsonViewerOwnProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ "update:expandedPaths": (paths: string[]) => any;
8
+ expandedPathsChange: (paths: string[]) => any;
9
+ valueSelect: (path: string[], value: any) => any;
10
+ }, string, import("vue").PublicProps, Readonly<JsonViewerOwnProps> & Readonly<{
11
+ "onUpdate:expandedPaths"?: ((paths: string[]) => any) | undefined;
12
+ onExpandedPathsChange?: ((paths: string[]) => any) | undefined;
13
+ onValueSelect?: ((path: string[], value: any) => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -0,0 +1,32 @@
1
+ import { type JsonViewerArrayChunk } from './json-viewer-utils';
2
+ type __VLS_Props = {
3
+ value: any;
4
+ path: string[];
5
+ nodeKey?: string;
6
+ level: number;
7
+ ancestors: object[];
8
+ expandedPaths: string[];
9
+ togglePath: (path: string) => void;
10
+ getStyles: any;
11
+ maxDisplayLength: number;
12
+ withTypes: boolean;
13
+ withSize: boolean;
14
+ withCopy: boolean;
15
+ withQuotes: boolean;
16
+ withKeyQuotes: boolean;
17
+ collapseStringsAfterLength: number | false;
18
+ sortKeys: boolean | ((a: string, b: string) => number);
19
+ groupArraysAfterLength: number | false;
20
+ copyLabel: string;
21
+ copiedLabel: string;
22
+ onValueSelect?: (path: string[], value: any) => void;
23
+ highlightItems?: Record<string, 'added' | 'removed'>;
24
+ allExpanded: boolean;
25
+ withChevrons: boolean;
26
+ isRoot?: boolean;
27
+ chunk?: JsonViewerArrayChunk;
28
+ chunkEntries?: [string, any][];
29
+ };
30
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const _default: typeof __VLS_export;
32
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export * from './JsonViewer';
2
+ export { getExpandablePaths, safeStringify } from './json-viewer-utils';
@@ -0,0 +1,22 @@
1
+ export declare const PATH_SEPARATOR = "\0";
2
+ export declare const serializePath: (segments: string[]) => string;
3
+ export interface JsonViewerArrayChunk {
4
+ start: number;
5
+ end: number;
6
+ }
7
+ export declare function getArrayChunks(length: number, groupArraysAfterLength: number | false): JsonViewerArrayChunk[] | null;
8
+ export declare const getChunkSegment: (chunk: JsonViewerArrayChunk) => string;
9
+ export declare function resolveDisplayValue(value: any): any;
10
+ export declare const isExpandableValue: (value: any) => value is object;
11
+ export declare const getEntries: (value: object) => [string, any][];
12
+ export declare function getExpandablePaths(value: any, { depth, groupArraysAfterLength, }?: {
13
+ depth?: number;
14
+ groupArraysAfterLength?: number | false;
15
+ }): string[];
16
+ export declare function getValueType(value: any): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null" | "array";
17
+ export declare function getTypeLabel(value: any): "string" | "bigint" | "symbol" | "undefined" | "object" | "function" | "null" | "array" | "int" | "float" | "bool";
18
+ export declare function formatValue(value: any, withQuotes: boolean, collapseStringsAfterLength: number | false): {
19
+ display: string;
20
+ collapsed: boolean;
21
+ };
22
+ export declare function safeStringify(value: any): string;
package/lib/index.d.mts CHANGED
@@ -5,6 +5,7 @@ export { CodeHighlightControl } from './CodeHighlight/CodeHighlightControl/CodeH
5
5
  export { useCodeHighlightContext } from './CodeHighlight/CodeHighlight.context';
6
6
  export { CodeHighlightAdapterProvider, useHighlight, useIsLanguageLoaded, useLoadLanguage, } from './CodeHighlightProvider/CodeHighlightProvider';
7
7
  export { normalizeCode } from './normalize-code';
8
+ export * from './JsonViewer';
8
9
  export type { NormalizeCodeOptions } from './normalize-code';
9
10
  export { createHighlightJsAdapter } from './CodeHighlightProvider/adapters/highlight-js-adapter';
10
11
  export { createShikiAdapter, stripShikiCodeBlocks, } from './CodeHighlightProvider/adapters/shiki-adapter';
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { CodeHighlightControl } from './CodeHighlight/CodeHighlightControl/CodeH
5
5
  export { useCodeHighlightContext } from './CodeHighlight/CodeHighlight.context';
6
6
  export { CodeHighlightAdapterProvider, useHighlight, useIsLanguageLoaded, useLoadLanguage, } from './CodeHighlightProvider/CodeHighlightProvider';
7
7
  export { normalizeCode } from './normalize-code';
8
+ export * from './JsonViewer';
8
9
  export type { NormalizeCodeOptions } from './normalize-code';
9
10
  export { createHighlightJsAdapter } from './CodeHighlightProvider/adapters/highlight-js-adapter';
10
11
  export { createShikiAdapter, stripShikiCodeBlocks, } from './CodeHighlightProvider/adapters/shiki-adapter';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine-vue/code-highlight",
3
- "version": "3.4.0",
3
+ "version": "3.6.0",
4
4
  "description": "Vue code highlight components equivalent to @mantine/code-highlight",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -39,8 +39,8 @@
39
39
  "vue": "^3.5.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@mantine-vue/core": "3.4.0",
43
- "@mantine-vue/hooks": "3.4.0",
42
+ "@mantine-vue/core": "3.6.0",
43
+ "@mantine-vue/hooks": "3.6.0",
44
44
  "vue": "^3.5.0"
45
45
  }
46
46
  }