@zoneflow/renderer-dom 0.0.17 → 0.0.19
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/engines/drawEngine.js +4 -0
- package/dist/renderer.js +2 -1
- package/dist/types.d.ts +28 -0
- package/package.json +2 -2
|
@@ -334,6 +334,8 @@ function renderPathFallback(host, slot, context) {
|
|
|
334
334
|
host.textContent = title;
|
|
335
335
|
applyStyles(host, {
|
|
336
336
|
...base,
|
|
337
|
+
// Consumer-resolved per-path color (resolvePathColor) overrides the theme.
|
|
338
|
+
color: context.pathColor ?? context.theme.pathLabel,
|
|
337
339
|
fontSize: "12px",
|
|
338
340
|
fontWeight: 700,
|
|
339
341
|
});
|
|
@@ -420,6 +422,7 @@ function createZoneSlotHost(params) {
|
|
|
420
422
|
componentLayout,
|
|
421
423
|
camera: input.camera,
|
|
422
424
|
theme: input.theme,
|
|
425
|
+
zoneColor: input.resolveZoneColor?.(zoneVisual.zone) ?? undefined,
|
|
423
426
|
textScale: input.textScale,
|
|
424
427
|
};
|
|
425
428
|
const renderer = input.zoneComponentRenderers?.[slot];
|
|
@@ -468,6 +471,7 @@ function createPathSlotHost(params) {
|
|
|
468
471
|
componentLayout,
|
|
469
472
|
camera: input.camera,
|
|
470
473
|
theme: input.theme,
|
|
474
|
+
pathColor: input.resolvePathColor?.(pathVisual.path) ?? undefined,
|
|
471
475
|
textScale: input.textScale,
|
|
472
476
|
};
|
|
473
477
|
const renderer = input.pathComponentRenderers?.[slot];
|
package/dist/renderer.js
CHANGED
|
@@ -69,7 +69,7 @@ export function createRenderer() {
|
|
|
69
69
|
update(input) {
|
|
70
70
|
if (!host)
|
|
71
71
|
return;
|
|
72
|
-
const { model, layoutModel, theme, textScale = "md", camera = DEFAULT_CAMERA, graphLayoutEngine = defaultGraphLayoutEngine, densityEngine = defaultDensityEngine, visibilityEngine = defaultVisibilityEngine, componentLayoutEngine = defaultComponentLayoutEngine, drawEngine = domDrawEngine, zoneComponentRenderers, pathComponentRenderers, resolveZoneShape, resolveZoneColor, backgroundRenderer, gridOptions, interactionHandlers, exclusionState, debug, } = input;
|
|
72
|
+
const { model, layoutModel, theme, textScale = "md", camera = DEFAULT_CAMERA, graphLayoutEngine = defaultGraphLayoutEngine, densityEngine = defaultDensityEngine, visibilityEngine = defaultVisibilityEngine, componentLayoutEngine = defaultComponentLayoutEngine, drawEngine = domDrawEngine, zoneComponentRenderers, pathComponentRenderers, resolveZoneShape, resolveZoneColor, resolvePathColor, backgroundRenderer, gridOptions, interactionHandlers, exclusionState, debug, } = input;
|
|
73
73
|
const mergedTheme = resolveTheme(theme);
|
|
74
74
|
const viewportInfo = resolveViewportInfo(host, camera, input);
|
|
75
75
|
const pipeline = runRenderPipeline({
|
|
@@ -121,6 +121,7 @@ export function createRenderer() {
|
|
|
121
121
|
pathComponentRenderers,
|
|
122
122
|
resolveZoneShape,
|
|
123
123
|
resolveZoneColor,
|
|
124
|
+
resolvePathColor,
|
|
124
125
|
backgroundRenderer,
|
|
125
126
|
gridOptions,
|
|
126
127
|
interactionHandlers,
|
package/dist/types.d.ts
CHANGED
|
@@ -111,6 +111,15 @@ export type ZoneComponentRendererContext = {
|
|
|
111
111
|
componentLayout: ZoneComponentLayout;
|
|
112
112
|
camera: CameraState;
|
|
113
113
|
theme: ZoneflowTheme;
|
|
114
|
+
/**
|
|
115
|
+
* Per-zone color resolved once from the consumer's `resolveZoneColor` prop —
|
|
116
|
+
* the same value that tints the zone's border/accent on the DOM shape
|
|
117
|
+
* (undefined when not provided or it returned nullish). Symmetric with
|
|
118
|
+
* {@link PathComponentRendererContext.pathColor}: custom slot renderers can
|
|
119
|
+
* read this to match the accent instead of reaching into `zone.meta`. The
|
|
120
|
+
* built-in title/body fallbacks stay theme-driven to preserve contrast.
|
|
121
|
+
*/
|
|
122
|
+
zoneColor?: string;
|
|
114
123
|
textScale: TextScaleLevel;
|
|
115
124
|
};
|
|
116
125
|
export type PathComponentRendererContext = {
|
|
@@ -123,12 +132,29 @@ export type PathComponentRendererContext = {
|
|
|
123
132
|
componentLayout: PathComponentLayout;
|
|
124
133
|
camera: CameraState;
|
|
125
134
|
theme: ZoneflowTheme;
|
|
135
|
+
/**
|
|
136
|
+
* Per-path color resolved once from the consumer's `resolvePathColor` prop
|
|
137
|
+
* (undefined when not provided or it returned nullish). Single source of
|
|
138
|
+
* truth for both the DOM fallback label and custom slot renderers — mirrors
|
|
139
|
+
* how `resolveZoneColor` drives a zone's accent, so slots should read this
|
|
140
|
+
* rather than reaching into `path.meta` themselves.
|
|
141
|
+
*/
|
|
142
|
+
pathColor?: string;
|
|
126
143
|
textScale: TextScaleLevel;
|
|
127
144
|
};
|
|
128
145
|
export type ZoneComponentRenderer = (host: HTMLElement, context: ZoneComponentRendererContext) => void;
|
|
129
146
|
export type PathComponentRenderer = (host: HTMLElement, context: PathComponentRendererContext) => void;
|
|
130
147
|
export type ZoneComponentRendererMap = Partial<Record<ZoneComponentSlotName, ZoneComponentRenderer>>;
|
|
131
148
|
export type PathComponentRendererMap = Partial<Record<PathComponentSlotName, PathComponentRenderer>>;
|
|
149
|
+
/**
|
|
150
|
+
* Resolver invoked once per path to decide its label color. Return a CSS color
|
|
151
|
+
* to override the path label's text color for that path; return
|
|
152
|
+
* `undefined`/`null` to fall back to the theme's `pathLabel` color. Like
|
|
153
|
+
* {@link ResolveZoneColor}, a purely presentational hook decided by the
|
|
154
|
+
* consumer (e.g. from `path.meta.color`, `path.rule`, …). Only the label text
|
|
155
|
+
* is affected — the rule/target/body slots stay theme-driven for contrast.
|
|
156
|
+
*/
|
|
157
|
+
export type ResolvePathColor = (path: Path) => string | null | undefined;
|
|
132
158
|
export type ZoneComponentMount = {
|
|
133
159
|
key: string;
|
|
134
160
|
zoneId: ZoneId;
|
|
@@ -206,6 +232,7 @@ export type RendererDrawInput = {
|
|
|
206
232
|
pathComponentRenderers?: PathComponentRendererMap;
|
|
207
233
|
resolveZoneShape?: ResolveZoneShape;
|
|
208
234
|
resolveZoneColor?: ResolveZoneColor;
|
|
235
|
+
resolvePathColor?: ResolvePathColor;
|
|
209
236
|
backgroundRenderer?: BackgroundRenderer;
|
|
210
237
|
gridOptions?: GridOptions;
|
|
211
238
|
interactionHandlers?: RendererInteractionHandlers;
|
|
@@ -271,6 +298,7 @@ export type RendererInput = {
|
|
|
271
298
|
pathComponentRenderers?: PathComponentRendererMap;
|
|
272
299
|
resolveZoneShape?: ResolveZoneShape;
|
|
273
300
|
resolveZoneColor?: ResolveZoneColor;
|
|
301
|
+
resolvePathColor?: ResolvePathColor;
|
|
274
302
|
backgroundRenderer?: BackgroundRenderer;
|
|
275
303
|
gridOptions?: GridOptions;
|
|
276
304
|
interactionHandlers?: RendererInteractionHandlers;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoneflow/renderer-dom",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Low-level DOM renderer engines for Zoneflow.",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@zoneflow/core": "0.0.
|
|
22
|
+
"@zoneflow/core": "0.0.19"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc -p tsconfig.json",
|