@servicetitan/json-render-react 0.1.1
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/dist/catalog/core/catalog-prompt.md +281 -0
- package/dist/catalog/core/schema.json +63 -0
- package/dist/catalog/marketing/catalog-prompt.md +282 -0
- package/dist/catalog/marketing/schema.json +64 -0
- package/dist/core/actions.d.ts +20 -0
- package/dist/core/catalog/alert.catalog.d.ts +15 -0
- package/dist/core/catalog/alert.d.ts +9 -0
- package/dist/core/catalog/badge.catalog.d.ts +12 -0
- package/dist/core/catalog/badge.d.ts +8 -0
- package/dist/core/catalog/bar-chart.catalog.d.ts +22 -0
- package/dist/core/catalog/bar-chart.d.ts +6 -0
- package/dist/core/catalog/button.catalog.d.ts +21 -0
- package/dist/core/catalog/button.d.ts +7 -0
- package/dist/core/catalog/card.catalog.d.ts +18 -0
- package/dist/core/catalog/card.d.ts +8 -0
- package/dist/core/catalog/catalog-def.d.ts +394 -0
- package/dist/core/catalog/chart-utils.d.ts +2 -0
- package/dist/core/catalog/checkbox.catalog.d.ts +10 -0
- package/dist/core/catalog/checkbox.d.ts +8 -0
- package/dist/core/catalog/chip.catalog.d.ts +19 -0
- package/dist/core/catalog/chip.d.ts +7 -0
- package/dist/core/catalog/divider.catalog.d.ts +25 -0
- package/dist/core/catalog/divider.d.ts +6 -0
- package/dist/core/catalog/donut-chart.catalog.d.ts +19 -0
- package/dist/core/catalog/donut-chart.d.ts +6 -0
- package/dist/core/catalog/flex.catalog.d.ts +42 -0
- package/dist/core/catalog/flex.d.ts +8 -0
- package/dist/core/catalog/grid.catalog.d.ts +17 -0
- package/dist/core/catalog/grid.d.ts +8 -0
- package/dist/core/catalog/icon.catalog.d.ts +19 -0
- package/dist/core/catalog/icon.d.ts +6 -0
- package/dist/core/catalog/index.d.ts +7 -0
- package/dist/core/catalog/input.catalog.d.ts +19 -0
- package/dist/core/catalog/input.d.ts +8 -0
- package/dist/core/catalog/line-chart.catalog.d.ts +18 -0
- package/dist/core/catalog/line-chart.d.ts +6 -0
- package/dist/core/catalog/link.catalog.d.ts +18 -0
- package/dist/core/catalog/link.d.ts +7 -0
- package/dist/core/catalog/listbox.catalog.d.ts +14 -0
- package/dist/core/catalog/listbox.d.ts +8 -0
- package/dist/core/catalog/progress-bar.catalog.d.ts +11 -0
- package/dist/core/catalog/progress-bar.d.ts +6 -0
- package/dist/core/catalog/radio-group.catalog.d.ts +14 -0
- package/dist/core/catalog/radio-group.d.ts +8 -0
- package/dist/core/catalog/schemas.d.ts +353 -0
- package/dist/core/catalog/switch.catalog.d.ts +10 -0
- package/dist/core/catalog/switch.d.ts +8 -0
- package/dist/core/catalog/text.catalog.d.ts +28 -0
- package/dist/core/catalog/text.d.ts +6 -0
- package/dist/generate.d.ts +9 -0
- package/dist/index.d.ts +6 -0
- package/dist/json-render-react.js +11132 -0
- package/dist/json-render-react.js.map +1 -0
- package/dist/marketing/catalog/catalog.d.ts +1 -0
- package/dist/marketing/catalog/components/index.d.ts +14 -0
- package/dist/marketing/catalog/components/revenue-card.catalog.d.ts +15 -0
- package/dist/marketing/catalog/components/revenue-card.d.ts +6 -0
- package/dist/marketing/catalog/index.d.ts +6 -0
- package/dist/marketing/catalog/teams.d.ts +4 -0
- package/dist/registry-utils.d.ts +6 -0
- package/dist/registry.d.ts +8 -0
- package/dist/renderers/internal/enrichments/button-actions.d.ts +7 -0
- package/dist/renderers/internal/enrichments/useEnrichedSpec.d.ts +3 -0
- package/dist/renderers/spec-renderer.d.ts +15 -0
- package/dist/renderers/types.d.ts +3 -0
- package/dist/team-catalog.d.ts +26 -0
- package/dist/types.d.ts +14 -0
- package/dist/utils/defined-props.d.ts +6 -0
- package/package.json +80 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const marketingCatalog: import('../..').TeamCatalogDef;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const marketingRenderers: {
|
|
2
|
+
RevenueCard: ({ props, }: {
|
|
3
|
+
props: import('zod').infer<import('zod').ZodObject<{
|
|
4
|
+
title: import('zod').ZodString;
|
|
5
|
+
value: import('zod').ZodString;
|
|
6
|
+
trend: import('zod').ZodOptional<import('zod').ZodEnum<{
|
|
7
|
+
flat: "flat";
|
|
8
|
+
up: "up";
|
|
9
|
+
down: "down";
|
|
10
|
+
}>>;
|
|
11
|
+
delta: import('zod').ZodOptional<import('zod').ZodString>;
|
|
12
|
+
}, import('zod/v4/core').$strip>>;
|
|
13
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const revenueCardCatalog: {
|
|
3
|
+
props: z.ZodObject<{
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
value: z.ZodString;
|
|
6
|
+
trend: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
flat: "flat";
|
|
8
|
+
up: "up";
|
|
9
|
+
down: "down";
|
|
10
|
+
}>>;
|
|
11
|
+
delta: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
slots: string[];
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { revenueCardCatalog } from './revenue-card.catalog';
|
|
3
|
+
export { revenueCardCatalog };
|
|
4
|
+
export declare const RevenueCardRenderer: ({ props, }: {
|
|
5
|
+
props: z.infer<typeof revenueCardCatalog.props>;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CatalogEntry } from '../../types';
|
|
2
|
+
import { marketingCatalog } from './catalog';
|
|
3
|
+
export { marketingRenderers } from './components';
|
|
4
|
+
export { marketingCatalog };
|
|
5
|
+
export declare const marketingCatalogEntries: CatalogEntry[];
|
|
6
|
+
export { teams } from './teams';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AllComponentRenderers } from './renderers/types';
|
|
2
|
+
import { ComponentCatalogDef } from './team-catalog';
|
|
3
|
+
import { CatalogEntry, RendererContext } from './types';
|
|
4
|
+
export declare function filterCatalogEntries(entries: CatalogEntry[], renderer: RendererContext): CatalogEntry[];
|
|
5
|
+
export declare function toComponentCatalogMap(entries: CatalogEntry[]): Record<string, ComponentCatalogDef>;
|
|
6
|
+
export declare function toComponentRendererMap(entries: CatalogEntry[]): AllComponentRenderers;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { catalog as coreCatalog } from './core/catalog/catalog-def';
|
|
2
|
+
import { RendererContext } from './types';
|
|
3
|
+
export declare function getRegistry(renderer?: RendererContext): import('@json-render/react').DefineRegistryResult;
|
|
4
|
+
export declare const registry: import('@json-render/react').ComponentRegistry;
|
|
5
|
+
export declare const handlers: (getSetState: () => import('@json-render/react').SetState | undefined, getState: () => import('@json-render/core').StateModel) => Record<string, (params: Record<string, unknown>) => Promise<void>>;
|
|
6
|
+
export declare const executeAction: (actionName: string, params: Record<string, unknown> | undefined, setState: import('@json-render/react').SetState, state?: import('@json-render/core').StateModel) => Promise<void>;
|
|
7
|
+
/** Core catalog used for schema generation and prompt artifacts. */
|
|
8
|
+
export { coreCatalog as catalog };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Spec } from '@json-render/core';
|
|
2
|
+
/**
|
|
3
|
+
* Enrich the spec so every Button element automatically gets
|
|
4
|
+
* on.press → submitUserAction wired up, using the button's element key
|
|
5
|
+
* as actionId. Buttons that already have on.press are left untouched.
|
|
6
|
+
*/
|
|
7
|
+
export declare function enrichButtonActions(spec: Spec): Spec;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Spec } from '@json-render/core';
|
|
2
|
+
import { ComponentRegistry, DefineRegistryResult } from '@json-render/react';
|
|
3
|
+
type SetState = (path: string, value: unknown) => void;
|
|
4
|
+
export interface SpecRendererProps {
|
|
5
|
+
spec: Spec;
|
|
6
|
+
registry: ComponentRegistry;
|
|
7
|
+
handlers: DefineRegistryResult["handlers"];
|
|
8
|
+
onUserActionSubmit?: (params: {
|
|
9
|
+
actionId: string;
|
|
10
|
+
data: Record<string, unknown>;
|
|
11
|
+
}, setState: SetState) => void | Promise<void>;
|
|
12
|
+
onNavigate?: (url: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const SpecRenderer: ({ spec, registry, handlers, onUserActionSubmit, onNavigate, }: SpecRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Catalog } from '@json-render/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export interface ComponentCatalogDef {
|
|
4
|
+
props: z.ZodType;
|
|
5
|
+
slots: string[];
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ActionCatalogDef {
|
|
9
|
+
params: z.ZodType;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TeamCatalogDef {
|
|
13
|
+
prefix: string;
|
|
14
|
+
components?: Record<string, ComponentCatalogDef>;
|
|
15
|
+
actions?: Record<string, ActionCatalogDef>;
|
|
16
|
+
/** Appended to base rules in generated prompt */
|
|
17
|
+
rules?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface MergedCatalog {
|
|
20
|
+
prefix: string;
|
|
21
|
+
catalog: Catalog;
|
|
22
|
+
prompt(baseRules: string): string;
|
|
23
|
+
jsonSchema(): object;
|
|
24
|
+
}
|
|
25
|
+
export declare function createTeamCatalog(def: TeamCatalogDef): TeamCatalogDef;
|
|
26
|
+
export declare function mergeCatalogs(teamDef: TeamCatalogDef): MergedCatalog;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ComponentCatalogDef } from './team-catalog';
|
|
3
|
+
export type RendererContext = "chat" | "panel" | "app";
|
|
4
|
+
export declare const ALL_RENDERERS: RendererContext[];
|
|
5
|
+
export interface CatalogEntry {
|
|
6
|
+
name: string;
|
|
7
|
+
catalog: ComponentCatalogDef;
|
|
8
|
+
/** json-render component renderer — typed at defineRegistry boundary. */
|
|
9
|
+
renderer: unknown;
|
|
10
|
+
renderers: RendererContext[];
|
|
11
|
+
}
|
|
12
|
+
export type InferCatalogProps<T extends {
|
|
13
|
+
props: z.ZodType;
|
|
14
|
+
}> = z.infer<T["props"]>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type DefinedProps<T extends Record<string, unknown>> = {
|
|
2
|
+
[K in keyof T as T[K] extends undefined ? never : K]: Exclude<T[K], undefined>;
|
|
3
|
+
};
|
|
4
|
+
/** Omit keys whose values are `undefined` — required for exactOptionalPropertyTypes spreads. */
|
|
5
|
+
export declare function definedProps<T extends Record<string, unknown>>(props: T): DefinedProps<T>;
|
|
6
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@servicetitan/json-render-react",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Generative UI catalog, registry, and renderers for json-render",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./catalog/*": "./dist/catalog/*"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@json-render/core": "^0.15.0",
|
|
24
|
+
"@json-render/react": "^0.15.0",
|
|
25
|
+
"zod": "^4.3.6"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@amcharts/amcharts5": "^5.0.0",
|
|
29
|
+
"@servicetitan/anvil2": ">=1.0.0",
|
|
30
|
+
"@servicetitan/anvil2-ext-charts": "0.1.7",
|
|
31
|
+
"react": ">=18 <20",
|
|
32
|
+
"react-dom": ">=18 <20"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@amcharts/amcharts5": "^5.0.0",
|
|
36
|
+
"@biomejs/biome": "^2.4.15",
|
|
37
|
+
"@chromatic-com/storybook": "^5.2.1",
|
|
38
|
+
"@servicetitan/anvil2": "^3.0.6",
|
|
39
|
+
"@servicetitan/anvil2-ext-charts": "0.1.7",
|
|
40
|
+
"@storybook/addon-a11y": "^10.4.1",
|
|
41
|
+
"@storybook/addon-docs": "^10.4.1",
|
|
42
|
+
"@storybook/addon-vitest": "^10.4.1",
|
|
43
|
+
"@storybook/react-vite": "^10.4.1",
|
|
44
|
+
"@testing-library/react": "^16.3.2",
|
|
45
|
+
"@types/node": "^22.0.0",
|
|
46
|
+
"@types/prismjs": "^1.26.6",
|
|
47
|
+
"@types/react": "^18.3.28",
|
|
48
|
+
"@types/react-dom": "^18.3.7",
|
|
49
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
50
|
+
"@vitest/browser": "^4.1.6",
|
|
51
|
+
"@vitest/browser-playwright": "^4.1.6",
|
|
52
|
+
"jsdom": "^29.1.1",
|
|
53
|
+
"playwright": "^1.55.0",
|
|
54
|
+
"prismjs": "^1.30.0",
|
|
55
|
+
"react": "^18.3.1",
|
|
56
|
+
"react-dom": "^18.3.1",
|
|
57
|
+
"react-simple-code-editor": "^0.14.1",
|
|
58
|
+
"storybook": "^10.4.1",
|
|
59
|
+
"tsx": "^4.0.0",
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
|
+
"vite": "^8.0.12",
|
|
62
|
+
"vite-plugin-dts": "^5.0.0",
|
|
63
|
+
"vite-plugin-svgr": "^4.5.0",
|
|
64
|
+
"vitest": "^4.1.6",
|
|
65
|
+
"@carto-internal/biome-config": "0.0.0",
|
|
66
|
+
"@carto-internal/tsconfig": "0.0.0"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "vite build && pnpm schema:gen",
|
|
70
|
+
"dev": "vite build --watch",
|
|
71
|
+
"schema:gen": "tsx scripts/generate-schema.ts",
|
|
72
|
+
"typecheck": "tsc --noEmit",
|
|
73
|
+
"lint": "biome check .",
|
|
74
|
+
"test": "vitest --project unit run",
|
|
75
|
+
"test-storybook": "PLAYWRIGHT_BROWSERS_PATH=0 vitest --project storybook run",
|
|
76
|
+
"storybook": "storybook dev -p 6007",
|
|
77
|
+
"build-storybook": "storybook build --stats-json",
|
|
78
|
+
"clean": "rm -rf dist storybook-static"
|
|
79
|
+
}
|
|
80
|
+
}
|