@almadar/ui 2.45.0 → 2.46.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,100 @@
1
+ /**
2
+ * AVL Behavior Compose Types
3
+ *
4
+ * Types for behavior-level composition canvas.
5
+ * At this level, each node represents a BEHAVIOR (not an orbital).
6
+ * A behavior is a higher-level unit: atom (1 orbital), molecule (1 orbital
7
+ * with composed traits), or organism (multiple orbitals).
8
+ *
9
+ * Three navigation levels:
10
+ * Behavior (compose): One node per behavior showing AvlBehaviorGlyph
11
+ * Overview: One node per orbital showing live UI (OrbPreviewNode)
12
+ * Expanded: One node per UI state within an orbital (OrbPreviewNode)
13
+ */
14
+ import type { EntityPersistence, EventPayloadField } from '@almadar/core';
15
+ import type { BehaviorLevel, BehaviorGlyphChild, BehaviorGlyphConnection } from './AvlBehaviorGlyph';
16
+ import type { AvlEffectType } from '../../atoms/avl/types';
17
+ /** Extended view level adding 'behavior' to the existing overview/expanded. */
18
+ export type ComposeViewLevel = 'behavior' | 'overview' | 'expanded';
19
+ /** An event that can be wired between behaviors. */
20
+ export interface ConnectableEvent {
21
+ /** Event name (e.g., "ADD_TO_CART"). */
22
+ event: string;
23
+ /** Typed payload fields if declared. */
24
+ payloadFields?: EventPayloadField[];
25
+ /** Vertical position hint (0..1) for handle placement on the node. */
26
+ positionHint: number;
27
+ }
28
+ /** Data for a BehaviorComposeNode in React Flow. */
29
+ export interface BehaviorComposeNodeData extends Record<string, unknown> {
30
+ /** Behavior name from registry (e.g., "std-cart"). */
31
+ behaviorName: string;
32
+ /** Composition level: atom, molecule, organism. */
33
+ level: BehaviorLevel;
34
+ /** Domain for color coding (e.g., "commerce"). */
35
+ domain?: string;
36
+ /** Layer classification (e.g., "Domain", "UI Patterns"). */
37
+ layer?: string;
38
+ /** Primary entity name (e.g., "CartItem"). */
39
+ entityName: string;
40
+ /** Number of states in the behavior. */
41
+ stateCount: number;
42
+ /** Number of entity fields. */
43
+ fieldCount?: number;
44
+ /** Persistence kind. */
45
+ persistence?: EntityPersistence;
46
+ /** Effect types used by this behavior. */
47
+ effectTypes?: AvlEffectType[];
48
+ /** Child behaviors for molecule/organism glyphs. */
49
+ children?: BehaviorGlyphChild[];
50
+ /** Connections between children (for organism glyphs). */
51
+ connections?: BehaviorGlyphConnection[];
52
+ /** Events this behavior can emit (source handles). */
53
+ connectableEvents: ConnectableEvent[];
54
+ /** Behaviors this is composable with (for palette hints). */
55
+ composableWith?: string[];
56
+ /** Names of orbitals produced by this behavior (for drill-down). */
57
+ orbitalNames: string[];
58
+ }
59
+ /** Edge data for behavior-level wiring. */
60
+ export interface BehaviorWireEdgeData extends Record<string, unknown> {
61
+ /** The event name displayed on the edge. */
62
+ event: string;
63
+ /** Source behavior name. */
64
+ sourceBehavior: string;
65
+ /** Target behavior name. */
66
+ targetBehavior: string;
67
+ /** Typed payload fields if declared. */
68
+ payloadFields?: EventPayloadField[];
69
+ }
70
+ /** Mapping from behavior name to its metadata + produced orbitals. */
71
+ export interface BehaviorCanvasEntry {
72
+ /** Behavior name (e.g., "std-cart"). */
73
+ behaviorName: string;
74
+ /** Composition level. */
75
+ level: BehaviorLevel;
76
+ /** Domain for color coding. */
77
+ domain?: string;
78
+ /** Layer classification. */
79
+ layer?: string;
80
+ /** Primary entity name. */
81
+ entityName: string;
82
+ /** Number of states. */
83
+ stateCount: number;
84
+ /** Number of entity fields. */
85
+ fieldCount?: number;
86
+ /** Persistence kind. */
87
+ persistence?: EntityPersistence;
88
+ /** Effect types used. */
89
+ effectTypes?: AvlEffectType[];
90
+ /** Child behaviors (molecule/organism). */
91
+ children?: BehaviorGlyphChild[];
92
+ /** Connections between children (organism). */
93
+ connections?: BehaviorGlyphConnection[];
94
+ /** Events available for wiring. */
95
+ connectableEvents: ConnectableEvent[];
96
+ /** Compatible behavior names. */
97
+ composableWith?: string[];
98
+ /** Orbital names produced by this behavior (for drill-down mapping). */
99
+ orbitalNames: string[];
100
+ }
@@ -19,7 +19,9 @@ import type { PreviewNodeData, EventEdgeData } from './avl-preview-types';
19
19
  * Build a React Flow graph for the overview level.
20
20
  * Each orbital gets one node showing its INIT transition's UI.
21
21
  */
22
- export declare function schemaToOverviewGraph(schema: OrbitalSchema, mockData?: Record<string, unknown[]>): {
22
+ export declare function schemaToOverviewGraph(schema: OrbitalSchema, mockData?: Record<string, unknown[]>, behaviorMeta?: Record<string, {
23
+ layer: string;
24
+ }>, layoutHint?: 'pipeline' | 'grid'): {
23
25
  nodes: Node<PreviewNodeData>[];
24
26
  edges: Edge<EventEdgeData>[];
25
27
  };
@@ -39,6 +39,12 @@ export interface PatternEventSource {
39
39
  path: string;
40
40
  /** Vertical position hint (0..1) for handle placement on the node. */
41
41
  positionHint: number;
42
+ /** Typed payload fields if this event carries data. */
43
+ payloadFields?: Array<{
44
+ name: string;
45
+ type: string;
46
+ required?: boolean;
47
+ }>;
42
48
  }
43
49
  /** A slot + pattern config pair extracted from a render-ui effect. */
44
50
  export interface RenderUIEntry {
@@ -70,6 +76,8 @@ export interface PreviewNodeData extends Record<string, unknown> {
70
76
  * to connect from the specific button/link to the target screen.
71
77
  */
72
78
  eventSources: PatternEventSource[];
79
+ /** Behavior layer for visual indicator (color band). */
80
+ layer?: string;
73
81
  /** State role for visual indicator. */
74
82
  stateRole?: 'initial' | 'terminal' | 'hub' | 'error' | 'default';
75
83
  /** All effect types on this transition (for overlay). */
@@ -27,6 +27,9 @@ export { type ViewLevel, type PreviewNodeData, type EventEdgeData, type PatternE
27
27
  export { schemaToOverviewGraph, orbitalToExpandedGraph } from './avl-preview-converter';
28
28
  export { OrbPreviewNode, ScreenSizeContext } from './OrbPreviewNode';
29
29
  export { EventFlowEdge } from './EventFlowEdge';
30
+ export { type ComposeViewLevel, type BehaviorComposeNodeData, type BehaviorWireEdgeData, type BehaviorCanvasEntry, type ConnectableEvent } from './avl-behavior-compose-types';
31
+ export { BehaviorComposeNode } from './BehaviorComposeNode';
32
+ export { behaviorsToComposeGraph, registryEntryToCanvasEntry, type BehaviorRegistryRecord } from './avl-behavior-compose-converter';
30
33
  export { Avl3DOrbitalNode, type Avl3DOrbitalNodeProps } from './Avl3DOrbitalNode';
31
34
  export { Avl3DCrossWire, type Avl3DCrossWireProps } from './Avl3DCrossWire';
32
35
  export { Avl3DEntityCore, type Avl3DEntityCoreProps } from './Avl3DEntityCore';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Wire Validation
3
+ *
4
+ * Validates event wire compatibility between behaviors based on typed payloads.
5
+ * Used by FlowCanvas when the user drags between event handles.
6
+ */
7
+ export interface PayloadField {
8
+ name: string;
9
+ type: string;
10
+ required?: boolean;
11
+ }
12
+ export interface WireValidationResult {
13
+ valid: boolean;
14
+ warnings: string[];
15
+ }
16
+ /**
17
+ * Validate that a wire between two event handles is payload-compatible.
18
+ *
19
+ * Rules:
20
+ * - If neither side declares a payload, the wire is valid (no data contract).
21
+ * - If source has payload but target doesn't, valid with info (data is unused).
22
+ * - If target expects required fields that source doesn't provide, warn.
23
+ * - If both have fields with the same name but different types, warn.
24
+ */
25
+ export declare function validateWire(sourcePayload: PayloadField[] | undefined, targetPayload: PayloadField[] | undefined): WireValidationResult;
26
+ /**
27
+ * Format payload fields into a tooltip string.
28
+ * Example: "{ data: object (req), query: string }"
29
+ */
30
+ export declare function formatPayloadTooltip(fields: PayloadField[]): string;
@@ -14,6 +14,7 @@
14
14
  import React from 'react';
15
15
  import type { OrbitalSchema } from '@almadar/core';
16
16
  import type { ViewLevel, PreviewNodeData } from '../../molecules/avl/avl-preview-types';
17
+ import type { ComposeViewLevel, BehaviorCanvasEntry, BehaviorWireEdgeData } from '../../molecules/avl/avl-behavior-compose-types';
17
18
  export interface FlowCanvasProps {
18
19
  schema: OrbitalSchema | string;
19
20
  mockData?: Record<string, unknown[]>;
@@ -49,6 +50,20 @@ export interface FlowCanvasProps {
49
50
  sourceTraitName?: string;
50
51
  targetTraitName?: string;
51
52
  }) => void;
53
+ /** Behavior layer metadata for node styling (layer color bands). */
54
+ behaviorMeta?: Record<string, {
55
+ layer: string;
56
+ }>;
57
+ /** Layout hint: 'pipeline' renders nodes left-to-right, 'grid' (default) uses sqrt-based grid. */
58
+ layoutHint?: 'pipeline' | 'grid';
59
+ /** Called when the user clicks a node in overview level (for composition hints). */
60
+ onNodeSelect?: (orbitalName: string) => void;
61
+ /** When 'behavior', shows behavior-level glyph nodes instead of orbital previews. */
62
+ composeLevel?: ComposeViewLevel;
63
+ /** Behavior entries for compose mode (only when composeLevel='behavior'). */
64
+ behaviorEntries?: BehaviorCanvasEntry[];
65
+ /** Event wires between behaviors (only when composeLevel='behavior'). */
66
+ behaviorWires?: BehaviorWireEdgeData[];
52
67
  /** @deprecated Use onNodeClick instead. Kept for AvlCosmicZoom compat. */
53
68
  onZoomChange?: (level: string, context: Record<string, string | undefined>) => void;
54
69
  /** @deprecated Not used in V3. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "2.45.0",
3
+ "version": "2.46.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",