@miman/json-schema-viewer-react 1.0.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,4 @@
1
+ export { SchemaViewer, type SchemaViewerProps } from './react';
2
+ export { ensureSchemaViewerStyles } from './styles/ensureStyles';
3
+ export { escapeHtml, generateExampleValue, getType, hasNestedContent, hasRemoteRef, resolveRef, syntaxHighlightJson, type SchemaBundle } from './viewerCore';
4
+ export { renderSchemaInto, type RenderSchemaOptions } from './viewerDom';
@@ -0,0 +1,9 @@
1
+ import type { SchemaBundle } from '../viewerCore';
2
+ export type SchemaViewerProps = {
3
+ schema: any;
4
+ bundle?: SchemaBundle;
5
+ importedFileNames?: string[];
6
+ missingFileNames?: string[];
7
+ className?: string;
8
+ };
9
+ export declare function SchemaViewer(props: SchemaViewerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { SchemaViewer, type SchemaViewerProps } from './SchemaViewer';
@@ -0,0 +1 @@
1
+ export declare function ensureSchemaViewerStyles(): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This function returns a string containing all the CSS styles for the schema viewer.
3
+ * It includes styles for both light and dark themes, using CSS variables.
4
+ *
5
+ * @returns {string} The CSS styles for the viewer.
6
+ */
7
+ export declare function getStyles(): string;
@@ -0,0 +1,15 @@
1
+ export type SchemaBundle = Record<string, any>;
2
+ export declare function hasRemoteRef(obj: any): boolean;
3
+ /**
4
+ * Resolves a $ref pointer.
5
+ * Supports:
6
+ * - local refs: "#/..."
7
+ * - file refs: "other.schema.json"
8
+ * - file + pointer: "other.schema.json#/$defs/X"
9
+ */
10
+ export declare function resolveRef(schema: any, rootSchema: any, bundle: SchemaBundle): any;
11
+ export declare function getType(prop: any): string;
12
+ export declare function hasNestedContent(prop: any): boolean;
13
+ export declare function generateExampleValue(prop: any, rootSchema: any, bundle: SchemaBundle, visitedRefs: Set<string>): any;
14
+ export declare function syntaxHighlightJson(json: string): string;
15
+ export declare function escapeHtml(text: unknown): string;
@@ -0,0 +1,11 @@
1
+ import { type RenderSchemaOptions as NormalOptions } from './viewerDomNormal';
2
+ export type RenderSchemaOptions = NormalOptions & {
3
+ initialView?: 'normal' | 'tree';
4
+ sourcePositions?: {
5
+ [key: string]: number;
6
+ };
7
+ activeLinkEnabled?: boolean;
8
+ onActiveLinkChange?: (enabled: boolean) => void;
9
+ onNavigateToSource?: (line: number) => void;
10
+ };
11
+ export declare function renderSchemaInto(container: HTMLElement, options: RenderSchemaOptions): void;
@@ -0,0 +1,13 @@
1
+ import { type SchemaBundle } from './viewerCore';
2
+ export type RenderSchemaOptions = {
3
+ schema: any;
4
+ bundle?: SchemaBundle;
5
+ importedFileNames?: string[];
6
+ missingFileNames?: string[];
7
+ sourcePositions?: {
8
+ [key: string]: number;
9
+ };
10
+ activeLinkEnabled?: boolean;
11
+ onNavigateToSource?: (line: number) => void;
12
+ };
13
+ export declare function renderNormalViewInto(container: HTMLElement, options: RenderSchemaOptions): void;
@@ -0,0 +1,11 @@
1
+ import { type SchemaBundle } from './viewerCore';
2
+ export type TreeRenderOptions = {
3
+ schema: any;
4
+ bundle?: SchemaBundle;
5
+ sourcePositions?: {
6
+ [key: string]: number;
7
+ };
8
+ activeLinkEnabled?: boolean;
9
+ onNavigateToSource?: (line: number) => void;
10
+ };
11
+ export declare function renderTreeViewInto(container: HTMLElement, options: TreeRenderOptions): void;
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@miman/json-schema-viewer-react",
3
+ "version": "1.0.0",
4
+ "description": "React component for visualizing JSON Schema files",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "vite build --config vite.config.ts && tsc -p tsconfig.json"
8
+ },
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/types/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/types/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "peerDependencies": {
23
+ "react": "^18.0.0",
24
+ "react-dom": "^18.0.0"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/miman/json-schema-viewer.git",
29
+ "directory": "web"
30
+ },
31
+ "license": "MIT",
32
+ "keywords": [
33
+ "json-schema",
34
+ "viewer",
35
+ "react",
36
+ "backstage"
37
+ ]
38
+ }