@kubuild/renderer 0.0.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/error-boundary.d.ts +20 -0
- package/dist/error-boundary.d.ts.map +1 -0
- package/dist/index.cjs +2084 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2030 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-adapter.d.ts +120 -0
- package/dist/preview-adapter.d.ts.map +1 -0
- package/dist/prop-resolution.d.ts +16 -0
- package/dist/prop-resolution.d.ts.map +1 -0
- package/dist/render-context.d.ts +98 -0
- package/dist/render-context.d.ts.map +1 -0
- package/dist/renderer.d.ts +60 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/styles.d.ts +23 -0
- package/dist/styles.d.ts.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PageDocument, Node } from '@kubuild/schema';
|
|
3
|
+
import { ComponentRegistry } from '@kubuild/components';
|
|
4
|
+
import { RenderContext, Diagnostic } from './render-context';
|
|
5
|
+
export interface EditableTextProps {
|
|
6
|
+
as?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
value: string;
|
|
11
|
+
isEditable: boolean;
|
|
12
|
+
nodeId: string;
|
|
13
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
14
|
+
onChange?: (val: string, isBlur: boolean) => void;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export declare const EditableText: React.FC<EditableTextProps>;
|
|
18
|
+
export declare function transformEmbedHtml(rawHtml: string): string;
|
|
19
|
+
export interface HtmlEmbedViewProps {
|
|
20
|
+
id?: string;
|
|
21
|
+
style?: React.CSSProperties;
|
|
22
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
23
|
+
dataKubuildNode?: string;
|
|
24
|
+
html: string;
|
|
25
|
+
role?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const HtmlEmbedView: React.FC<HtmlEmbedViewProps>;
|
|
28
|
+
export interface KubuildRendererProps {
|
|
29
|
+
document: PageDocument;
|
|
30
|
+
registry?: ComponentRegistry;
|
|
31
|
+
context?: RenderContext;
|
|
32
|
+
viewport?: 'desktop' | 'tablet' | 'mobile';
|
|
33
|
+
mode?: 'editor' | 'runtime';
|
|
34
|
+
className?: string;
|
|
35
|
+
onNodeClick?: (nodeId: string, event: React.MouseEvent) => void;
|
|
36
|
+
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
37
|
+
onActionDispatch?: (actionType: string, payload: Record<string, unknown> | undefined, nodeId: string) => void;
|
|
38
|
+
onNodePropChange?: (nodeId: string, propName: string, value: unknown, isBlur?: boolean) => void;
|
|
39
|
+
}
|
|
40
|
+
export interface NodeRendererProps {
|
|
41
|
+
node: Node;
|
|
42
|
+
document: PageDocument;
|
|
43
|
+
registry: ComponentRegistry;
|
|
44
|
+
context?: RenderContext;
|
|
45
|
+
viewport?: 'desktop' | 'tablet' | 'mobile';
|
|
46
|
+
mode?: 'editor' | 'runtime';
|
|
47
|
+
onNodeClick?: (nodeId: string, event: React.MouseEvent) => void;
|
|
48
|
+
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
49
|
+
onActionDispatch?: (actionType: string, payload: Record<string, unknown> | undefined, nodeId: string) => void;
|
|
50
|
+
onNodePropChange?: (nodeId: string, propName: string, value: unknown, isBlur?: boolean) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Suffix appended to the HTML `id` attribute (never to `data-kubuild-node`, the
|
|
53
|
+
* canonical template-node reference) so a `collection` node's repeated child
|
|
54
|
+
* template produces unique DOM ids per iteration instead of duplicates.
|
|
55
|
+
*/
|
|
56
|
+
instanceSuffix?: string;
|
|
57
|
+
}
|
|
58
|
+
export declare function NodeRenderer({ node, document, registry, context: propContext, viewport, mode, onNodeClick, onDiagnostic, onActionDispatch, onNodePropChange, instanceSuffix, }: NodeRendererProps): React.ReactElement;
|
|
59
|
+
export declare const KubuildRenderer: React.FC<KubuildRendererProps>;
|
|
60
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgE,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,IAAI,EAAwD,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAkC,MAAM,qBAAqB,CAAC;AACxF,OAAO,EACL,aAAa,EAOb,UAAU,EACX,MAAM,kBAAkB,CAAC;AAuC1B,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoEpD,CAAC;AAGF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAY1D;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5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QAAQ,CAAC;IAC3C,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAChE,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAChD,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9G,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAChG;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EAAE,WAAW,EACpB,QAAoB,EACpB,IAAgB,EAChB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,cAAmB,GACpB,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CA8qCxC;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAuC1D,CAAC"}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PageDocument, ResponsiveStyles } from '@kubuild/schema';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare function resolveNodeStyles(styles?: ResponsiveStyles, viewport?: 'desktop' | 'tablet' | 'mobile'): React.CSSProperties;
|
|
4
|
+
/**
|
|
5
|
+
* Serialize a style definition object into CSS declarations.
|
|
6
|
+
* camelCase keys are converted to kebab-case CSS properties.
|
|
7
|
+
*/
|
|
8
|
+
export declare function styleDefinitionToCssDeclarations(styleDefinition: Record<string, unknown> | undefined): string;
|
|
9
|
+
/**
|
|
10
|
+
* Walk the document tree and produce scoped CSS rules for pseudo-state
|
|
11
|
+
* style layers (STORA-222). Each node with `styles.states` gets rules like:
|
|
12
|
+
*
|
|
13
|
+
* [data-kubuild-node="node-1"]:hover { background-color: #1d4ed8; }
|
|
14
|
+
*
|
|
15
|
+
* Scoped via the canonical `data-kubuild-node` attribute so styles never leak
|
|
16
|
+
* between nodes and work identically in editor canvas and runtime preview.
|
|
17
|
+
*/
|
|
18
|
+
export declare function collectStateStylesCss(document: PageDocument | undefined | null): string;
|
|
19
|
+
/**
|
|
20
|
+
* Modern baseline CSS Reset for consistent rendering across viewports and browsers.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_CSS_RESET: string;
|
|
23
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAQ,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,iBAAiB,CAC/B,MAAM,CAAC,EAAE,gBAAgB,EACzB,QAAQ,GAAE,SAAS,GAAG,QAAQ,GAAG,QAAoB,GACpD,KAAK,CAAC,aAAa,CAKrB;AAiBD;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACnD,MAAM,CASR;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAuBvF;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,QA0BtB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubuild/renderer",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Pure recursive React renderer for KUBUILD page documents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup && tsc --emitDeclarationOnly",
|
|
25
|
+
"dev": "tsup --watch",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"lint": "eslint src",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"prepublishOnly": "pnpm run build"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/kustora/kubuild.git"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"page-builder",
|
|
37
|
+
"visual-editor",
|
|
38
|
+
"low-code",
|
|
39
|
+
"website-builder",
|
|
40
|
+
"stora",
|
|
41
|
+
"kubuild"
|
|
42
|
+
],
|
|
43
|
+
"author": "KUBUILD",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/kustora/kubuild/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/kustora/kubuild#readme",
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@kubuild/components": "workspace:*",
|
|
51
|
+
"@kubuild/core": "workspace:*",
|
|
52
|
+
"@kubuild/schema": "workspace:*",
|
|
53
|
+
"lucide-react": "^1.33.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"react": ">=18.0.0",
|
|
57
|
+
"react-dom": ">=18.0.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/react": "^19.2.18",
|
|
61
|
+
"@types/react-dom": "^19.2.4",
|
|
62
|
+
"react": "^19.0.0",
|
|
63
|
+
"react-dom": "^19.0.0",
|
|
64
|
+
"tsup": "^8.3.6",
|
|
65
|
+
"typescript": "^6.0.0",
|
|
66
|
+
"vitest": "^3.0.5"
|
|
67
|
+
}
|
|
68
|
+
}
|