@lattix/react 0.1.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.
- package/dist/action-context.d.ts +11 -0
- package/dist/action-context.d.ts.map +1 -0
- package/dist/action-context.js +10 -0
- package/dist/action-context.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/registry-context.d.ts +6 -0
- package/dist/registry-context.d.ts.map +1 -0
- package/dist/registry-context.js +7 -0
- package/dist/registry-context.js.map +1 -0
- package/dist/render-node.d.ts +12 -0
- package/dist/render-node.d.ts.map +1 -0
- package/dist/render-node.js +129 -0
- package/dist/render-node.js.map +1 -0
- package/dist/renderer.d.ts +37 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +35 -0
- package/dist/renderer.js.map +1 -0
- package/dist/resolve-style.d.ts +14 -0
- package/dist/resolve-style.d.ts.map +1 -0
- package/dist/resolve-style.js +88 -0
- package/dist/resolve-style.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LattixAction } from "@lattix/core";
|
|
2
|
+
/**
|
|
3
|
+
* Handler invoked when a semantic action fires (e.g. button onPress).
|
|
4
|
+
* Receives the normalized action object so consumers can dispatch, navigate, etc.
|
|
5
|
+
*/
|
|
6
|
+
export type LattixActionHandler = (action: LattixAction) => void;
|
|
7
|
+
/** React context carrying the action handler for the current renderer subtree. */
|
|
8
|
+
export declare const LattixActionContext: import("react").Context<LattixActionHandler | undefined>;
|
|
9
|
+
/** Read the current action handler from context. Returns a no-op if none is provided. */
|
|
10
|
+
export declare const useLattixAction: () => LattixActionHandler;
|
|
11
|
+
//# sourceMappingURL=action-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-context.d.ts","sourceRoot":"","sources":["../src/action-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;AAEjE,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,0DAE/B,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,eAAe,QAAO,mBAGlC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
/** React context carrying the action handler for the current renderer subtree. */
|
|
3
|
+
export const LattixActionContext = createContext(undefined);
|
|
4
|
+
/** Read the current action handler from context. Returns a no-op if none is provided. */
|
|
5
|
+
export const useLattixAction = () => {
|
|
6
|
+
const handler = useContext(LattixActionContext);
|
|
7
|
+
return handler ?? noop;
|
|
8
|
+
};
|
|
9
|
+
const noop = () => { };
|
|
10
|
+
//# sourceMappingURL=action-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-context.js","sourceRoot":"","sources":["../src/action-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AASlD,kFAAkF;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAC9C,SAAS,CACV,CAAC;AAEF,yFAAyF;AACzF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAwB,EAAE;IACvD,MAAM,OAAO,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAChD,OAAO,OAAO,IAAI,IAAI,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,IAAI,GAAwB,GAAG,EAAE,GAAE,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { LattixRenderer, type LattixRendererProps } from "./renderer.js";
|
|
2
|
+
export { RenderNode, type LattixNodeProps } from "./render-node.js";
|
|
3
|
+
export { LattixActionContext, useLattixAction, type LattixActionHandler, } from "./action-context.js";
|
|
4
|
+
export { LattixRegistryContext, useTokenRegistry, } from "./registry-context.js";
|
|
5
|
+
export { resolveStyleToCSS, type ResolveStyleOptions } from "./resolve-style.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { LattixRenderer } from "./renderer.js";
|
|
2
|
+
export { RenderNode } from "./render-node.js";
|
|
3
|
+
export { LattixActionContext, useLattixAction, } from "./action-context.js";
|
|
4
|
+
export { LattixRegistryContext, useTokenRegistry, } from "./registry-context.js";
|
|
5
|
+
export { resolveStyleToCSS } from "./resolve-style.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,eAAe,GAEhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAA4B,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type TokenRegistry } from "@lattix/tokens";
|
|
2
|
+
/** React context carrying the token registry for style resolution. */
|
|
3
|
+
export declare const LattixRegistryContext: import("react").Context<Readonly<Record<string, import("@lattix/core").LattixStyleValue>>>;
|
|
4
|
+
/** Read the current token registry from context. */
|
|
5
|
+
export declare const useTokenRegistry: () => TokenRegistry;
|
|
6
|
+
//# sourceMappingURL=registry-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-context.d.ts","sourceRoot":"","sources":["../src/registry-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE1E,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,4FAEjC,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,QAAO,aACD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import { defaultTokenRegistry } from "@lattix/tokens";
|
|
3
|
+
/** React context carrying the token registry for style resolution. */
|
|
4
|
+
export const LattixRegistryContext = createContext(defaultTokenRegistry);
|
|
5
|
+
/** Read the current token registry from context. */
|
|
6
|
+
export const useTokenRegistry = () => useContext(LattixRegistryContext);
|
|
7
|
+
//# sourceMappingURL=registry-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-context.js","sourceRoot":"","sources":["../src/registry-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,gBAAgB,CAAC;AAE1E,sEAAsE;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAChD,oBAAoB,CACrB,CAAC;AAEF,oDAAoD;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAkB,EAAE,CAClD,UAAU,CAAC,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { LattixNode } from "@lattix/core";
|
|
3
|
+
/** Props passed to every node renderer. */
|
|
4
|
+
export interface LattixNodeProps {
|
|
5
|
+
readonly node: LattixNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Render a single semantic node by dispatching to the appropriate kind renderer.
|
|
9
|
+
* Unknown kinds render a diagnostic `<div>` with a data attribute.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RenderNode: React.FC<LattixNodeProps>;
|
|
12
|
+
//# sourceMappingURL=render-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-node.d.ts","sourceRoot":"","sources":["../src/render-node.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAO7D,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AAyOD;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAUhD,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { normalizeAction } from "@lattix/core";
|
|
3
|
+
import { resolveMotionToCSS } from "@lattix/motion";
|
|
4
|
+
import { useLattixAction } from "./action-context.js";
|
|
5
|
+
import { useTokenRegistry } from "./registry-context.js";
|
|
6
|
+
import { resolveStyleToCSS } from "./resolve-style.js";
|
|
7
|
+
/** Resolve node styles and motion using renderer-local contexts. */
|
|
8
|
+
const useNodePresentation = (node) => {
|
|
9
|
+
const registry = useTokenRegistry();
|
|
10
|
+
const style = resolveStyleToCSS(node.normalizedStyle, { registry }, node.style);
|
|
11
|
+
const motion = resolveMotionToCSS(node.animation);
|
|
12
|
+
return {
|
|
13
|
+
style: { ...style, ...motion.style },
|
|
14
|
+
motionAttributes: motion.attributes,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/** Recursively render children of a container node. */
|
|
18
|
+
const RenderChildren = ({ children, }) => {
|
|
19
|
+
if (!children || children.length === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return (_jsx(_Fragment, { children: children.map((child, i) => (_jsx(RenderNode, { node: child }, child.id ?? `${child.kind}-${i}`))) }));
|
|
23
|
+
};
|
|
24
|
+
/** Resolve an action prop (string id or LattixAction) into a click handler. */
|
|
25
|
+
const useActionHandler = (actionProp) => {
|
|
26
|
+
const dispatch = useLattixAction();
|
|
27
|
+
if (actionProp === undefined || actionProp === null) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return () => {
|
|
31
|
+
const action = typeof actionProp === "string"
|
|
32
|
+
? normalizeAction(actionProp)
|
|
33
|
+
: actionProp;
|
|
34
|
+
dispatch(action);
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const ScreenRenderer = ({ node }) => {
|
|
38
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
39
|
+
return (_jsx("div", { "data-lattix-kind": "screen", "data-lattix-id": node.id, ...motionAttributes, style: { minHeight: "100vh", ...style }, children: _jsx(RenderChildren, { children: node.children }) }));
|
|
40
|
+
};
|
|
41
|
+
const StackRenderer = ({ node }) => {
|
|
42
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
43
|
+
return (_jsx("div", { "data-lattix-kind": "stack", ...motionAttributes, style: { display: "flex", flexDirection: "column", ...style }, children: _jsx(RenderChildren, { children: node.children }) }));
|
|
44
|
+
};
|
|
45
|
+
const RowRenderer = ({ node }) => {
|
|
46
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
47
|
+
return (_jsx("div", { "data-lattix-kind": "row", ...motionAttributes, style: { display: "flex", flexDirection: "row", ...style }, children: _jsx(RenderChildren, { children: node.children }) }));
|
|
48
|
+
};
|
|
49
|
+
const BoxRenderer = ({ node }) => {
|
|
50
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
51
|
+
return (_jsx("div", { "data-lattix-kind": "box", ...motionAttributes, style: style, children: _jsx(RenderChildren, { children: node.children }) }));
|
|
52
|
+
};
|
|
53
|
+
const TextRenderer = ({ node }) => {
|
|
54
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
55
|
+
const content = node.props.content;
|
|
56
|
+
return (_jsx("span", { "data-lattix-kind": "text", ...motionAttributes, style: style, children: content ?? "" }));
|
|
57
|
+
};
|
|
58
|
+
const ImageRenderer = ({ node }) => {
|
|
59
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
60
|
+
const source = node.props.source;
|
|
61
|
+
const alt = node.props.alt ?? "";
|
|
62
|
+
return (_jsx("img", { "data-lattix-kind": "image", ...motionAttributes, src: source, alt: alt, style: style }));
|
|
63
|
+
};
|
|
64
|
+
const ButtonRenderer = ({ node }) => {
|
|
65
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
66
|
+
const label = node.props.label;
|
|
67
|
+
const variant = node.props.variant;
|
|
68
|
+
const onClick = useActionHandler(node.props.onPress);
|
|
69
|
+
return (_jsx("button", { "data-lattix-kind": "button", "data-lattix-variant": variant, ...motionAttributes, onClick: onClick, style: style, children: node.children && node.children.length > 0 ? (_jsx(RenderChildren, { children: node.children })) : (label ?? "") }));
|
|
70
|
+
};
|
|
71
|
+
const InputRenderer = ({ node }) => {
|
|
72
|
+
const dispatch = useLattixAction();
|
|
73
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
74
|
+
const placeholder = node.props.placeholder;
|
|
75
|
+
const handleChange = (e) => {
|
|
76
|
+
const onChangeProp = node.props.onChange;
|
|
77
|
+
if (onChangeProp !== undefined && onChangeProp !== null) {
|
|
78
|
+
const action = typeof onChangeProp === "string"
|
|
79
|
+
? normalizeAction(onChangeProp)
|
|
80
|
+
: onChangeProp;
|
|
81
|
+
dispatch({ ...action, payload: { ...action.payload, value: e.target.value } });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return (_jsx("input", { "data-lattix-kind": "input", ...motionAttributes, placeholder: placeholder, onChange: handleChange, style: style }));
|
|
85
|
+
};
|
|
86
|
+
const BadgeRenderer = ({ node }) => {
|
|
87
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
88
|
+
const label = node.props.label;
|
|
89
|
+
return (_jsx("span", { "data-lattix-kind": "badge", ...motionAttributes, style: style, children: label ?? "" }));
|
|
90
|
+
};
|
|
91
|
+
const DividerRenderer = ({ node }) => {
|
|
92
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
93
|
+
return _jsx("hr", { "data-lattix-kind": "divider", ...motionAttributes, style: style });
|
|
94
|
+
};
|
|
95
|
+
const SpacerRenderer = ({ node }) => {
|
|
96
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
97
|
+
return (_jsx("div", { "data-lattix-kind": "spacer", ...motionAttributes, style: { flex: 1, ...style } }));
|
|
98
|
+
};
|
|
99
|
+
const ListRenderer = ({ node }) => {
|
|
100
|
+
const { style, motionAttributes } = useNodePresentation(node);
|
|
101
|
+
return (_jsx("ul", { "data-lattix-kind": "list", ...motionAttributes, style: { display: "flex", flexDirection: "column", ...style }, children: node.children?.map((child, i) => (_jsx("li", { children: _jsx(RenderNode, { node: child }) }, child.id ?? `${child.kind}-${i}`))) }));
|
|
102
|
+
};
|
|
103
|
+
/** Built-in node kind → renderer mapping. */
|
|
104
|
+
const NODE_RENDERERS = {
|
|
105
|
+
screen: ScreenRenderer,
|
|
106
|
+
stack: StackRenderer,
|
|
107
|
+
row: RowRenderer,
|
|
108
|
+
box: BoxRenderer,
|
|
109
|
+
text: TextRenderer,
|
|
110
|
+
image: ImageRenderer,
|
|
111
|
+
button: ButtonRenderer,
|
|
112
|
+
input: InputRenderer,
|
|
113
|
+
badge: BadgeRenderer,
|
|
114
|
+
divider: DividerRenderer,
|
|
115
|
+
spacer: SpacerRenderer,
|
|
116
|
+
list: ListRenderer,
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Render a single semantic node by dispatching to the appropriate kind renderer.
|
|
120
|
+
* Unknown kinds render a diagnostic `<div>` with a data attribute.
|
|
121
|
+
*/
|
|
122
|
+
export const RenderNode = ({ node }) => {
|
|
123
|
+
const Renderer = NODE_RENDERERS[node.kind];
|
|
124
|
+
if (Renderer) {
|
|
125
|
+
return _jsx(Renderer, { node: node });
|
|
126
|
+
}
|
|
127
|
+
return (_jsx("div", { "data-lattix-kind": node.kind, "data-lattix-unknown": "true", children: `[unsupported node kind: ${node.kind}]` }));
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=render-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-node.js","sourceRoot":"","sources":["../src/render-node.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAYvD,oEAAoE;AACpE,MAAM,mBAAmB,GAAG,CAAC,IAAgB,EAAoB,EAAE;IACjE,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;IACpC,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO;QACL,KAAK,EAAE,EA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N,CAAC;AACJ,CAAC,CAAC;AAEF,6CAA6C;AAC7C,MAAM,cAAc,GAAwD;IAC1E,MAAM,EAAE,cAAc;IACtB,KAAK,EAAE,aAAa;IACpB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,aAAa;IACpB,MAAM,EAAE,cAAc;IACtB,KAAK,EAAE,aAAa;IACpB,KAAK,EAAE,aAAa;IACpB,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,cAAc;IACtB,IAAI,EAAE,YAAY;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,KAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC;IAClC,CAAC;IACD,OAAO,CACL,kCAAuB,IAAI,CAAC,IAAI,yBAAsB,MAAM,YACzD,2BAA2B,IAAI,CAAC,IAAI,GAAG,GACpC,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { LattixTree } from "@lattix/core";
|
|
3
|
+
import type { TokenRegistry } from "@lattix/tokens";
|
|
4
|
+
import { type LattixActionHandler } from "./action-context.js";
|
|
5
|
+
/** Props for the top-level Lattix web renderer. */
|
|
6
|
+
export interface LattixRendererProps {
|
|
7
|
+
/** The validated semantic tree to render. */
|
|
8
|
+
readonly tree: LattixTree;
|
|
9
|
+
/** Handler invoked when a semantic action fires (e.g. button onPress). */
|
|
10
|
+
readonly onAction?: LattixActionHandler;
|
|
11
|
+
/** Custom token registry for style resolution. Defaults to `defaultTokenRegistry`. */
|
|
12
|
+
readonly registry?: TokenRegistry;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Top-level React component that renders a Lattix semantic tree.
|
|
16
|
+
*
|
|
17
|
+
* Wraps the tree in action and registry context providers so that all
|
|
18
|
+
* descendant node renderers can resolve tokens and dispatch actions.
|
|
19
|
+
*
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { LattixRenderer } from "@lattix/react";
|
|
22
|
+
* import { Screen } from "@lattix/dsl";
|
|
23
|
+
*
|
|
24
|
+
* const tree = Screen("Home", s => s.text("Hello")).toTree();
|
|
25
|
+
*
|
|
26
|
+
* function App() {
|
|
27
|
+
* return (
|
|
28
|
+
* <LattixRenderer
|
|
29
|
+
* tree={tree}
|
|
30
|
+
* onAction={(action) => console.log("action:", action)}
|
|
31
|
+
* />
|
|
32
|
+
* );
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const LattixRenderer: React.FC<LattixRendererProps>;
|
|
37
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAI7B,mDAAmD;AACnD,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IACxC,sFAAsF;IACtF,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAwBxD,CAAC"}
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { LattixActionContext, } from "./action-context.js";
|
|
3
|
+
import { LattixRegistryContext } from "./registry-context.js";
|
|
4
|
+
import { RenderNode } from "./render-node.js";
|
|
5
|
+
/**
|
|
6
|
+
* Top-level React component that renders a Lattix semantic tree.
|
|
7
|
+
*
|
|
8
|
+
* Wraps the tree in action and registry context providers so that all
|
|
9
|
+
* descendant node renderers can resolve tokens and dispatch actions.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { LattixRenderer } from "@lattix/react";
|
|
13
|
+
* import { Screen } from "@lattix/dsl";
|
|
14
|
+
*
|
|
15
|
+
* const tree = Screen("Home", s => s.text("Hello")).toTree();
|
|
16
|
+
*
|
|
17
|
+
* function App() {
|
|
18
|
+
* return (
|
|
19
|
+
* <LattixRenderer
|
|
20
|
+
* tree={tree}
|
|
21
|
+
* onAction={(action) => console.log("action:", action)}
|
|
22
|
+
* />
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export const LattixRenderer = ({ tree, onAction, registry, }) => {
|
|
28
|
+
const content = _jsx(RenderNode, { node: tree.root });
|
|
29
|
+
const withAction = onAction ? (_jsx(LattixActionContext.Provider, { value: onAction, children: content })) : (content);
|
|
30
|
+
if (registry) {
|
|
31
|
+
return (_jsx(LattixRegistryContext.Provider, { value: registry, children: withAction }));
|
|
32
|
+
}
|
|
33
|
+
return withAction;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":";AAGA,OAAO,EACL,mBAAmB,GAEpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAY9C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAC5D,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,KAAC,UAAU,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAI,CAAC;IAEhD,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,CAC5B,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAC1C,OAAO,GACqB,CAChC,CAAC,CAAC,CAAC,CACF,OAAO,CACR,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CACL,KAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAC5C,UAAU,GACoB,CAClC,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NormalizedLattixStyle, LattixStyle } from "@lattix/core";
|
|
2
|
+
import { type TokenRegistry } from "@lattix/tokens";
|
|
3
|
+
export interface ResolveStyleOptions {
|
|
4
|
+
readonly registry?: TokenRegistry;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Resolve semantic styles into a React CSSProperties-compatible object.
|
|
8
|
+
*
|
|
9
|
+
* Uses `normalizedStyle` when available, falling back to `rawStyle` for
|
|
10
|
+
* properties that were not normalized (e.g. tokens unknown to the default
|
|
11
|
+
* registry at build time but present in a custom renderer registry).
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolveStyleToCSS: (normalizedStyle: NormalizedLattixStyle | undefined, options?: ResolveStyleOptions, rawStyle?: LattixStyle) => React.CSSProperties;
|
|
14
|
+
//# sourceMappingURL=resolve-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-style.d.ts","sourceRoot":"","sources":["../src/resolve-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EAErB,WAAW,EAEZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA4DlE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC;CACnC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,iBAAiB,qBAAqB,GAAG,SAAS,EAClD,UAAS,mBAAwB,EACjC,WAAW,WAAW,KACrB,KAAK,CAAC,aAiCR,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isTokenReference } from "@lattix/core";
|
|
2
|
+
import { resolveToken } from "@lattix/tokens";
|
|
3
|
+
/** CSS property names mapped from semantic style property names. */
|
|
4
|
+
const CSS_PROPERTY_MAP = {
|
|
5
|
+
color: "color",
|
|
6
|
+
background: "backgroundColor",
|
|
7
|
+
backgroundColor: "backgroundColor",
|
|
8
|
+
padding: "padding",
|
|
9
|
+
margin: "margin",
|
|
10
|
+
marginTop: "marginTop",
|
|
11
|
+
marginBottom: "marginBottom",
|
|
12
|
+
marginLeft: "marginLeft",
|
|
13
|
+
marginRight: "marginRight",
|
|
14
|
+
gap: "gap",
|
|
15
|
+
borderRadius: "borderRadius",
|
|
16
|
+
fontSize: "fontSize",
|
|
17
|
+
fontWeight: "fontWeight",
|
|
18
|
+
width: "width",
|
|
19
|
+
height: "height",
|
|
20
|
+
flex: "flex",
|
|
21
|
+
flexDirection: "flexDirection",
|
|
22
|
+
alignItems: "alignItems",
|
|
23
|
+
justifyContent: "justifyContent",
|
|
24
|
+
};
|
|
25
|
+
/** Convert a resolved style value to a CSS-compatible value. */
|
|
26
|
+
const toCSSValue = (value) => {
|
|
27
|
+
if (typeof value === "number") {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return String(value);
|
|
31
|
+
};
|
|
32
|
+
/** Resolve a single normalized style entry to a CSS value. */
|
|
33
|
+
const resolveEntry = (entry, registry) => {
|
|
34
|
+
if (entry.kind === "literal") {
|
|
35
|
+
return toCSSValue(entry.value);
|
|
36
|
+
}
|
|
37
|
+
const resolved = resolveToken(entry.ref, registry);
|
|
38
|
+
if (resolved === undefined) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return toCSSValue(resolved);
|
|
42
|
+
};
|
|
43
|
+
/** Resolve a raw style value (from node.style) to a CSS value using the registry. */
|
|
44
|
+
const resolveRawValue = (value, registry) => {
|
|
45
|
+
if (typeof value === "string" && isTokenReference(value)) {
|
|
46
|
+
const resolved = resolveToken(value, registry);
|
|
47
|
+
return resolved !== undefined ? toCSSValue(resolved) : undefined;
|
|
48
|
+
}
|
|
49
|
+
return toCSSValue(value);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Resolve semantic styles into a React CSSProperties-compatible object.
|
|
53
|
+
*
|
|
54
|
+
* Uses `normalizedStyle` when available, falling back to `rawStyle` for
|
|
55
|
+
* properties that were not normalized (e.g. tokens unknown to the default
|
|
56
|
+
* registry at build time but present in a custom renderer registry).
|
|
57
|
+
*/
|
|
58
|
+
export const resolveStyleToCSS = (normalizedStyle, options = {}, rawStyle) => {
|
|
59
|
+
if (!normalizedStyle && !rawStyle) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
const css = {};
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
if (normalizedStyle) {
|
|
65
|
+
for (const [prop, entry] of Object.entries(normalizedStyle)) {
|
|
66
|
+
seen.add(prop);
|
|
67
|
+
const cssKey = CSS_PROPERTY_MAP[prop] ?? prop;
|
|
68
|
+
const value = resolveEntry(entry, options.registry);
|
|
69
|
+
if (value !== undefined) {
|
|
70
|
+
css[cssKey] = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (rawStyle) {
|
|
75
|
+
for (const [prop, value] of Object.entries(rawStyle)) {
|
|
76
|
+
if (seen.has(prop)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const cssKey = CSS_PROPERTY_MAP[prop] ?? prop;
|
|
80
|
+
const resolved = resolveRawValue(value, options.registry);
|
|
81
|
+
if (resolved !== undefined) {
|
|
82
|
+
css[cssKey] = resolved;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return css;
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=resolve-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-style.js","sourceRoot":"","sources":["../src/resolve-style.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAElE,oEAAoE;AACpE,MAAM,gBAAgB,GAAqC;IACzD,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,iBAAiB;IAC7B,eAAe,EAAE,iBAAiB;IAClC,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;IAC1B,GAAG,EAAE,KAAK;IACV,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,aAAa,EAAE,eAAe;IAC9B,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;CACjC,CAAC;AAEF,gEAAgE;AAChE,MAAM,UAAU,GAAG,CAAC,KAAuB,EAAmB,EAAE;IAC9D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QA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E,CAAC;QACpB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACf,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;YAC9C,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,SAAS;YACX,CAAC;YACD,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;YAC9C,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC1D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,GAAG,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAA0B,CAAC;AACpC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lattix/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React web renderer for Lattix semantic trees",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@lattix/core": "0.1.0",
|
|
27
|
+
"@lattix/motion": "0.1.0",
|
|
28
|
+
"@lattix/tokens": "0.1.0",
|
|
29
|
+
"react": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@lattix/diagnostics": "0.1.0",
|
|
33
|
+
"@lattix/dsl": "0.1.0",
|
|
34
|
+
"@types/react": "^18.2.0",
|
|
35
|
+
"@types/react-dom": "^18.3.7",
|
|
36
|
+
"react-dom": "^18.3.1",
|
|
37
|
+
"typescript": "^5.7.3",
|
|
38
|
+
"vitest": "^3.0.5"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": ">=18"
|
|
42
|
+
}
|
|
43
|
+
}
|