@almadar/ui 2.34.2 → 2.36.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.
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { OrbitalSchema } from '@almadar/core';
3
+ import { OrbitalSchema, UISlot, Expression } from '@almadar/core';
4
4
  import { Node, Edge, NodeProps, EdgeProps } from '@xyflow/react';
5
5
 
6
6
  /**
@@ -820,43 +820,209 @@ declare const AvlPageEdge: React__default.FC<EdgeProps>;
820
820
  declare const AvlBindingEdge: React__default.FC<EdgeProps>;
821
821
 
822
822
  /**
823
- * AVL Cosmic Zoom State Machine
823
+ * AVL Preview Types
824
824
  *
825
- * useReducer-based state machine managing which zoom level is displayed,
826
- * what is selected, and animation state.
825
+ * Types for the V3 FlowCanvas: UI projection mode.
826
+ * Nodes show rendered UI thumbnails, edges show events.
827
+ * Two levels: overview (one node per orbital) and expanded (one node per UI state).
827
828
  *
828
- * @packageDocumentation
829
+ * Uses @almadar/core types for schema-level constructs.
829
830
  */
830
- type ZoomLevel = 'application' | 'orbital' | 'trait' | 'transition';
831
+
832
+ /** The two navigation levels of the FlowCanvas. */
833
+ type ViewLevel = 'overview' | 'expanded';
834
+ /**
835
+ * An interactive element inside a render-ui pattern that fires an event.
836
+ * For example, a button with `event: "CHECKOUT"` is an event source.
837
+ * These are used to draw edges from the specific trigger element to the
838
+ * target screen, making the prototype flow concrete.
839
+ */
840
+ interface PatternEventSource {
841
+ /** The event name fired by this element (e.g., "CHECKOUT"). */
842
+ event: string;
843
+ /** The pattern type of the trigger element (e.g., "button", "link", "icon-button"). */
844
+ patternType: string;
845
+ /** Human label if available (e.g., "Checkout", "Submit"). */
846
+ label?: string;
847
+ /**
848
+ * Path within the pattern tree (e.g., "children.2" means third child).
849
+ * Used to position the handle near the trigger element.
850
+ */
851
+ path: string;
852
+ /** Vertical position hint (0..1) for handle placement on the node. */
853
+ positionHint: number;
854
+ }
855
+ /** A slot + pattern config pair extracted from a render-ui effect. */
856
+ interface RenderUIEntry {
857
+ slot: UISlot | string;
858
+ pattern: Record<string, unknown>;
859
+ }
860
+ /** Data for a preview node (used at both overview and expanded levels). */
861
+ interface PreviewNodeData extends Record<string, unknown> {
862
+ /** Orbital this node belongs to. */
863
+ orbitalName: string;
864
+ /** Trait name (only at expanded level). */
865
+ traitName?: string;
866
+ /** State name after this transition fires (expanded level). */
867
+ stateName?: string;
868
+ /** Event that triggers this transition (expanded level). */
869
+ transitionEvent?: string;
870
+ /** From state (expanded level). */
871
+ fromState?: string;
872
+ /** To state (expanded level). */
873
+ toState?: string;
874
+ /**
875
+ * Render-ui patterns extracted from the transition's effects.
876
+ * Each entry is a slot + pattern config pair.
877
+ */
878
+ patterns: RenderUIEntry[];
879
+ /**
880
+ * Interactive elements within the patterns that fire events.
881
+ * Each one becomes a source handle on the node, allowing edges
882
+ * to connect from the specific button/link to the target screen.
883
+ */
884
+ eventSources: PatternEventSource[];
885
+ /** State role for visual indicator. */
886
+ stateRole?: 'initial' | 'terminal' | 'hub' | 'error' | 'default';
887
+ /** All effect types on this transition (for overlay). */
888
+ effectTypes?: string[];
889
+ /** Guard expression (for overlay). */
890
+ guard?: Expression | null;
891
+ entityName?: string;
892
+ persistence?: string;
893
+ fieldCount?: number;
894
+ traitCount?: number;
895
+ pageRoutes?: string[];
896
+ }
897
+ /** Data for event flow edges. */
898
+ interface EventEdgeData extends Record<string, unknown> {
899
+ /** The event name displayed on the edge. */
900
+ event: string;
901
+ /** Source state name (expanded level). */
902
+ fromState?: string;
903
+ /** Target state name (expanded level). */
904
+ toState?: string;
905
+ /** Whether this is a backward/retry transition. */
906
+ isBackward?: boolean;
907
+ /** Whether this is a cross-orbital event wire (overview level). */
908
+ isCrossOrbital?: boolean;
909
+ /** Source trait (for cross-orbital wires). */
910
+ fromTrait?: string;
911
+ /** Target trait (for cross-orbital wires). */
912
+ toTrait?: string;
913
+ /**
914
+ * The pattern type that triggers this event (e.g., "button").
915
+ * Displayed on the edge label for context.
916
+ */
917
+ triggerPatternType?: string;
918
+ /** The trigger element's label (e.g., "Checkout"). */
919
+ triggerLabel?: string;
920
+ }
921
+
922
+ /**
923
+ * AVL Preview Converter
924
+ *
925
+ * Extracts render-ui pattern configs from OrbitalSchema transitions
926
+ * and builds React Flow graphs for the two FlowCanvas levels:
927
+ * - Overview: one node per orbital (INIT transition UI)
928
+ * - Expanded: one node per UI state within an orbital
929
+ *
930
+ * Key feature: detects interactive elements (buttons, links) inside
931
+ * patterns that fire events. These become per-element source handles
932
+ * so edges connect from the specific trigger element to the target screen.
933
+ *
934
+ * Uses @almadar/core types for schema-level constructs.
935
+ */
936
+
937
+ /**
938
+ * Build a React Flow graph for the overview level.
939
+ * Each orbital gets one node showing its INIT transition's UI.
940
+ */
941
+ declare function schemaToOverviewGraph(schema: OrbitalSchema, mockData?: Record<string, unknown[]>): {
942
+ nodes: Node<PreviewNodeData>[];
943
+ edges: Edge<EventEdgeData>[];
944
+ };
945
+ /**
946
+ * Build a React Flow graph for the expanded level.
947
+ * Each transition with a render-ui effect gets a node.
948
+ * Edges connect from the specific button/pattern that fires the event
949
+ * to the target screen node.
950
+ */
951
+ declare function orbitalToExpandedGraph(schema: OrbitalSchema, orbitalName: string, mockData?: Record<string, unknown[]>): {
952
+ nodes: Node<PreviewNodeData>[];
953
+ edges: Edge<EventEdgeData>[];
954
+ };
831
955
 
832
956
  /**
833
- * FlowCanvas — Unified AVL + Flow canvas organism.
957
+ * OrbPreviewNode
834
958
  *
835
- * One React Flow canvas with continuous semantic zoom. AVL primitives
836
- * render inside React Flow nodes. The ZoomBandContext drives node
837
- * rendering at different zoom levels.
959
+ * React Flow node that renders a real OrbPreview inside it.
960
+ * The canvas is always live and editable (like Figma). Clicking any
961
+ * rendered UI element selects its pattern and shows props in the
962
+ * TransitionPanel. No edit mode toggle needed.
838
963
  *
839
- * Replaces both AvlCosmicZoom (SVG viewer) and OrbitalFlow (Flow editor).
964
+ * The header is the drag handle for React Flow. The content area
965
+ * passes clicks through to the pattern elements.
966
+ */
967
+
968
+ declare const OrbPreviewNode: React__default.NamedExoticComponent<NodeProps>;
969
+
970
+ /**
971
+ * EventFlowEdge
972
+ *
973
+ * React Flow edge for the V3 FlowCanvas. Shows the event name and
974
+ * optionally the trigger element (button label) that fires it.
975
+ *
976
+ * When the edge originates from a specific event source handle,
977
+ * the label shows "Button Label \u2192 EVENT" to make the connection
978
+ * between UI element and transition clear.
979
+ */
980
+
981
+ declare const EventFlowEdge: React__default.NamedExoticComponent<EdgeProps>;
982
+
983
+ /**
984
+ * FlowCanvas — V3 UI Projection Canvas
985
+ *
986
+ * The canvas IS the app. Nodes show rendered UI thumbnails from
987
+ * render-ui effects. Edges show events connecting screens.
988
+ *
989
+ * Two navigation levels:
990
+ * Level 1 (Overview): One node per orbital showing INIT UI
991
+ * Level 2 (Expanded): One node per UI state within an orbital
992
+ *
993
+ * Double-click to expand an orbital. Click a node for code callback.
994
+ * Escape to go back. AVL overlays on hover (future).
840
995
  */
841
996
 
842
997
  interface FlowCanvasProps {
843
998
  schema: OrbitalSchema | string;
999
+ mockData?: Record<string, unknown[]>;
844
1000
  className?: string;
845
- color?: string;
846
- animated?: boolean;
847
1001
  width?: number | string;
848
1002
  height?: number | string;
849
- onZoomChange?: (level: ZoomLevel, context: {
850
- orbital?: string;
1003
+ onNodeClick?: (context: {
1004
+ level: ViewLevel | 'code';
1005
+ orbital: string;
851
1006
  trait?: string;
1007
+ transition?: string;
852
1008
  }) => void;
1009
+ onLevelChange?: (level: ViewLevel, orbital?: string) => void;
1010
+ initialOrbital?: string;
1011
+ /** @deprecated Use onNodeClick instead. Kept for AvlCosmicZoom compat. */
1012
+ onZoomChange?: (level: string, context: Record<string, string | undefined>) => void;
1013
+ /** @deprecated Not used in V3. */
853
1014
  focusTarget?: {
854
- type: 'orbital' | 'trait';
1015
+ type: string;
855
1016
  name: string;
856
1017
  };
857
- initialOrbital?: string;
1018
+ /** @deprecated Not used in V3. */
1019
+ color?: string;
1020
+ /** @deprecated Not used in V3. */
1021
+ animated?: boolean;
1022
+ /** @deprecated Not used in V3. */
858
1023
  initialTrait?: string;
859
- stateCoverage?: Record<string, 'covered' | 'uncovered' | 'partial'>;
1024
+ /** @deprecated Not used in V3. */
1025
+ stateCoverage?: Record<string, string>;
860
1026
  }
861
1027
  declare const FlowCanvas: React__default.FC<FlowCanvasProps>;
862
1028
 
@@ -887,11 +1053,21 @@ interface ZoomLegendProps {
887
1053
  declare const ZoomLegend: React__default.FC<ZoomLegendProps>;
888
1054
 
889
1055
  /**
890
- * AvlCosmicZoom Interactive Zoomable Orbital Visualization
1056
+ * AVL Cosmic Zoom State Machine
1057
+ *
1058
+ * useReducer-based state machine managing which zoom level is displayed,
1059
+ * what is selected, and animation state.
1060
+ *
1061
+ * @packageDocumentation
1062
+ */
1063
+ type ZoomLevel = 'application' | 'orbital' | 'trait' | 'transition';
1064
+
1065
+ /**
1066
+ * AvlCosmicZoom — Interactive Orbital Visualization
891
1067
  *
892
- * V3: Delegates to FlowCanvas, which renders AVL primitives inside
893
- * React Flow nodes with continuous semantic zoom. The Props interface
894
- * is preserved for backward compatibility with callers.
1068
+ * V3: Delegates to FlowCanvas. Nodes are live OrbPreview renders
1069
+ * of each orbital/transition. Two-level navigation (overview + expanded).
1070
+ * Props interface preserved for backward compatibility with callers.
895
1071
  */
896
1072
 
897
1073
  interface AvlCosmicZoomProps {
@@ -988,4 +1164,4 @@ interface AvlClickTargetProps {
988
1164
  }
989
1165
  declare const AvlClickTarget: React__default.FC<AvlClickTargetProps>;
990
1166
 
991
- export { AVL_FIELD_TYPE_SHAPES, AVL_OPERATOR_COLORS, type ApplicationLevelData, AvlApplication, type AvlApplicationProps, AvlBackwardEdge, type AvlBaseProps, AvlBehaviorGlyph, type AvlBehaviorGlyphProps, AvlBinding, AvlBindingEdge, type AvlBindingProps, AvlBindingRef, type AvlBindingRefProps, AvlClickTarget, type AvlClickTargetProps, AvlClosedCircuit, type AvlClosedCircuitProps, type AvlClosedCircuitState, type AvlClosedCircuitTransition, AvlCosmicZoom, type AvlCosmicZoomProps, type AvlEdgeData, AvlEffect, type AvlEffectProps, type AvlEffectType, AvlEmitListen, type AvlEmitListenProps, AvlEntity, type AvlEntityProps, AvlEvent, type AvlEventProps, AvlEventWireEdge, type AvlEventWireEdgeData, AvlExprTree, type AvlExprTreeNode, type AvlExprTreeProps, AvlField, type AvlFieldProps, AvlFieldType, type AvlFieldTypeKind, type AvlFieldTypeProps, AvlGuard, type AvlGuardProps, AvlLiteral, type AvlLiteralProps, type AvlNodeData, AvlOperator, type AvlOperatorNamespace, type AvlOperatorProps, AvlOrbital, AvlOrbitalNode, type AvlOrbitalProps, AvlOrbitalUnit, type AvlOrbitalUnitPage, type AvlOrbitalUnitProps, type AvlOrbitalUnitTrait, AvlPage, AvlPageEdge, type AvlPageProps, AvlPersistence, type AvlPersistenceKind, type AvlPersistenceProps, AvlSExpr, type AvlSExprProps, AvlSlotMap, type AvlSlotMapProps, type AvlSlotMapSlot, AvlState, AvlStateMachine, type AvlStateMachineProps, type AvlStateMachineState, type AvlStateMachineTransition, type AvlStateProps, AvlSwimLane, type AvlSwimLaneProps, AvlTrait, type AvlTraitProps, AvlTraitScene, type AvlTraitSceneProps, AvlTransition, AvlTransitionEdge, type AvlTransitionEdgeData, AvlTransitionLane, type AvlTransitionLaneProps, type AvlTransitionProps, AvlTransitionScene, type AvlTransitionSceneProps, type BehaviorGlyphChild, type BehaviorGlyphConnection, type BehaviorLevel, BehaviorView, CONNECTION_COLORS, type CrossLink, DOMAIN_COLORS, DetailView, EFFECT_CATEGORY_COLORS, EFFECT_TYPE_TO_CATEGORY, type EffectCategory, type ElkLayout, FlowCanvas, type FlowCanvasProps, type GlyphSize, type LayoutEdge, type LayoutNode, MiniStateMachine, ModuleCard, type OrbitalLevelData, STATE_COLORS, type StateRole, SystemNode, type TraitLevelData, type TransitionLevelData, ZOOM_BAND_THRESHOLDS, type ZoomBand, ZoomBandContext, ZoomBreadcrumb, type ZoomBreadcrumbProps, ZoomLegend, type ZoomLegendProps, type ZoomLevel, arcPath, computeTraitLayout, computeZoomBand, curveControlPoint, edgePath, getStateRole, gridPositions, parseApplicationLevel, parseOrbitalLevel, parseTraitLevel, parseTransitionLevel, radialPositions, ringPositions, schemaToFlowGraph, useZoomBand, zoomProgress };
1167
+ export { AVL_FIELD_TYPE_SHAPES, AVL_OPERATOR_COLORS, type ApplicationLevelData, AvlApplication, type AvlApplicationProps, AvlBackwardEdge, type AvlBaseProps, AvlBehaviorGlyph, type AvlBehaviorGlyphProps, AvlBinding, AvlBindingEdge, type AvlBindingProps, AvlBindingRef, type AvlBindingRefProps, AvlClickTarget, type AvlClickTargetProps, AvlClosedCircuit, type AvlClosedCircuitProps, type AvlClosedCircuitState, type AvlClosedCircuitTransition, AvlCosmicZoom, type AvlCosmicZoomProps, type AvlEdgeData, AvlEffect, type AvlEffectProps, type AvlEffectType, AvlEmitListen, type AvlEmitListenProps, AvlEntity, type AvlEntityProps, AvlEvent, type AvlEventProps, AvlEventWireEdge, type AvlEventWireEdgeData, AvlExprTree, type AvlExprTreeNode, type AvlExprTreeProps, AvlField, type AvlFieldProps, AvlFieldType, type AvlFieldTypeKind, type AvlFieldTypeProps, AvlGuard, type AvlGuardProps, AvlLiteral, type AvlLiteralProps, type AvlNodeData, AvlOperator, type AvlOperatorNamespace, type AvlOperatorProps, AvlOrbital, AvlOrbitalNode, type AvlOrbitalProps, AvlOrbitalUnit, type AvlOrbitalUnitPage, type AvlOrbitalUnitProps, type AvlOrbitalUnitTrait, AvlPage, AvlPageEdge, type AvlPageProps, AvlPersistence, type AvlPersistenceKind, type AvlPersistenceProps, AvlSExpr, type AvlSExprProps, AvlSlotMap, type AvlSlotMapProps, type AvlSlotMapSlot, AvlState, AvlStateMachine, type AvlStateMachineProps, type AvlStateMachineState, type AvlStateMachineTransition, type AvlStateProps, AvlSwimLane, type AvlSwimLaneProps, AvlTrait, type AvlTraitProps, AvlTraitScene, type AvlTraitSceneProps, AvlTransition, AvlTransitionEdge, type AvlTransitionEdgeData, AvlTransitionLane, type AvlTransitionLaneProps, type AvlTransitionProps, AvlTransitionScene, type AvlTransitionSceneProps, type BehaviorGlyphChild, type BehaviorGlyphConnection, type BehaviorLevel, BehaviorView, CONNECTION_COLORS, type CrossLink, DOMAIN_COLORS, DetailView, EFFECT_CATEGORY_COLORS, EFFECT_TYPE_TO_CATEGORY, type EffectCategory, type ElkLayout, type EventEdgeData, EventFlowEdge, FlowCanvas, type FlowCanvasProps, type GlyphSize, type LayoutEdge, type LayoutNode, MiniStateMachine, ModuleCard, OrbPreviewNode, type OrbitalLevelData, type PatternEventSource, type PreviewNodeData, type RenderUIEntry, STATE_COLORS, type StateRole, SystemNode, type TraitLevelData, type TransitionLevelData, type ViewLevel, ZOOM_BAND_THRESHOLDS, type ZoomBand, ZoomBandContext, ZoomBreadcrumb, type ZoomBreadcrumbProps, ZoomLegend, type ZoomLegendProps, type ZoomLevel, arcPath, computeTraitLayout, computeZoomBand, curveControlPoint, edgePath, getStateRole, gridPositions, orbitalToExpandedGraph, parseApplicationLevel, parseOrbitalLevel, parseTraitLevel, parseTransitionLevel, radialPositions, ringPositions, schemaToFlowGraph, schemaToOverviewGraph, useZoomBand, zoomProgress };
@@ -51,4 +51,8 @@ export { AvlBackwardEdge } from '../components/molecules/avl/AvlBackwardEdge';
51
51
  export { AvlPageEdge } from '../components/molecules/avl/AvlPageEdge';
52
52
  export { AvlBindingEdge } from '../components/molecules/avl/AvlBindingEdge';
53
53
  export { computeTraitLayout, edgePath, type LayoutNode, type LayoutEdge, type ElkLayout } from '../components/molecules/avl/avl-elk-layout';
54
+ export { type ViewLevel, type PreviewNodeData, type EventEdgeData, type PatternEventSource, type RenderUIEntry } from '../components/molecules/avl/avl-preview-types';
55
+ export { schemaToOverviewGraph, orbitalToExpandedGraph } from '../components/molecules/avl/avl-preview-converter';
56
+ export { OrbPreviewNode } from '../components/molecules/avl/OrbPreviewNode';
57
+ export { EventFlowEdge } from '../components/molecules/avl/EventFlowEdge';
54
58
  export { FlowCanvas, type FlowCanvasProps, ZoomBreadcrumb, type ZoomBreadcrumbProps, ZoomLegend, type ZoomLegendProps, AvlCosmicZoom, type AvlCosmicZoomProps, AvlTraitScene, type AvlTraitSceneProps, AvlTransitionScene, type AvlTransitionSceneProps, AvlClickTarget, type AvlClickTargetProps, parseApplicationLevel, parseOrbitalLevel, parseTraitLevel, parseTransitionLevel, type ApplicationLevelData, type OrbitalLevelData, type TraitLevelData, type TransitionLevelData, type CrossLink, type ZoomLevel, } from '../components/organisms/avl';