@almadar/ui 4.54.5 → 4.54.7

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,33 @@
1
+ /**
2
+ * TraitCardNode — React Flow node for the `trait-expanded` view level.
3
+ *
4
+ * Renders one card per trait of a single orbital. The card body shows
5
+ * the trait's state-machine flow chart (states + transitions, laid out
6
+ * by ELK) via the existing `AvlTraitScene` organism. Clicking a
7
+ * transition arc drills into L4 transition detail.
8
+ *
9
+ * Left edge has one target handle per `listens[]` event; right edge
10
+ * has one source handle per `emits[]` event. Edges produced by
11
+ * `orbitalToTraitGraph` connect emit handles to listen handles where
12
+ * the event names match within the same orbital.
13
+ *
14
+ * Transition clicks bubble through `TraitCardSelectionContext`
15
+ * (mirrors `PatternSelectionContext` in `OrbPreviewNode`). FlowCanvas
16
+ * wraps the canvas in a provider that translates the context callback
17
+ * into its `onNodeClick({ level: 'transition', ... })` prop.
18
+ */
19
+ import React from 'react';
20
+ import { type NodeProps } from '@xyflow/react';
21
+ export interface TraitCardTransitionClick {
22
+ orbitalName: string;
23
+ traitName: string;
24
+ transitionEvent: string;
25
+ fromState: string;
26
+ toState: string;
27
+ index: number;
28
+ }
29
+ export interface TraitCardSelectionContextValue {
30
+ selectTransition: (sel: TraitCardTransitionClick) => void;
31
+ }
32
+ export declare const TraitCardSelectionContext: React.Context<TraitCardSelectionContextValue>;
33
+ export declare const TraitCardNode: React.NamedExoticComponent<NodeProps>;
@@ -51,3 +51,21 @@ export declare function orbitalAliasToExpandedGraph(schema: OrbitalSchema, orbit
51
51
  nodes: Node<PreviewNodeData>[];
52
52
  edges: Edge<EventEdgeData>[];
53
53
  };
54
+ /**
55
+ * Build a React Flow graph for the `trait-expanded` level: one node per
56
+ * trait of `orbitalName`, with intra-orbital `emits → listens` edges
57
+ * between trait cards (an emit on trait A connects to a listen for the
58
+ * same event on trait B in the same orbital).
59
+ *
60
+ * Used by the cosmic tab at L3 (after the user drills into an orbital
61
+ * from the L1 grid). The canvas tab does not call this today; the new
62
+ * level is opt-in via `initialLevel="trait-expanded"`.
63
+ *
64
+ * Layout: grid (`ceil(sqrt(N))` cols). Nodes are `type: 'traitCard'`
65
+ * with `data.kind === 'trait-card'` so `FlowCanvas`'s NODE_TYPES routes
66
+ * them to `TraitCardNode`.
67
+ */
68
+ export declare function orbitalToTraitGraph(schema: OrbitalSchema, orbitalName: string, _mockData?: Record<string, unknown[]>): {
69
+ nodes: Node<PreviewNodeData>[];
70
+ edges: Edge<EventEdgeData>[];
71
+ };
@@ -18,8 +18,12 @@ import type { Expression, UISlot } from '@almadar/core';
18
18
  * - `behavior-expanded` (L3) — drilled into a single imported behavior at
19
19
  * L2: one card per transition of THAT behavior. Used to inspect what an
20
20
  * import contributes without leaving the canvas.
21
+ * - `trait-expanded` — one card per trait of a single orbital, connected
22
+ * by intra-orbital `emits → listens` edges. Used by the cosmic tab to
23
+ * render the trait-level circuit when the user drills into an orbital
24
+ * from the L1 grid. Not used by the canvas tab today.
21
25
  */
22
- export type ViewLevel = 'overview' | 'expanded' | 'behavior-expanded';
26
+ export type ViewLevel = 'overview' | 'expanded' | 'behavior-expanded' | 'trait-expanded';
23
27
  /**
24
28
  * Screen size preset for OrbPreview rendering inside nodes.
25
29
  *
@@ -162,6 +166,42 @@ export interface PreviewNodeData extends Record<string, unknown> {
162
166
  * card. Renderer can surface it as a "+N screens" badge.
163
167
  */
164
168
  transitionCount?: number;
169
+ /**
170
+ * Discriminator for the node variant. Absent on overview/expanded/
171
+ * behavior-expanded cards (those use field-presence-based discrimination
172
+ * via `behaviorAlias`/`transitionEvent`). Set to `'trait-card'` for nodes
173
+ * produced by `orbitalToTraitGraph` so renderers can branch cleanly.
174
+ */
175
+ kind?: 'trait-card';
176
+ /**
177
+ * Trait-card transitions (`kind === 'trait-card'` only). One row per
178
+ * transition; each row is clickable and drills to L4 transition detail
179
+ * in cosmic. `event` is the trigger; `fromState` / `toState` mirror the
180
+ * underlying state-machine edge.
181
+ */
182
+ transitions?: Array<{
183
+ event: string;
184
+ fromState: string;
185
+ toState: string;
186
+ }>;
187
+ /**
188
+ * Trait-card `emits` event names (`kind === 'trait-card'` only). One
189
+ * source handle per entry on the right edge of the card. Drives the
190
+ * outgoing wire endpoints in `orbitalToTraitGraph`.
191
+ */
192
+ emits?: string[];
193
+ /**
194
+ * Trait-card `listens` event names (`kind === 'trait-card'` only). One
195
+ * target handle per entry on the left edge of the card. Drives the
196
+ * incoming wire endpoints in `orbitalToTraitGraph`.
197
+ */
198
+ listens?: string[];
199
+ /**
200
+ * Trait-card `linkedEntity` (`kind === 'trait-card'` only). Surfaced as a
201
+ * subtitle/badge next to the trait name so users can see what entity the
202
+ * trait operates on. Mirrors `Trait.linkedEntity` from the resolved schema.
203
+ */
204
+ linkedEntity?: string;
165
205
  }
166
206
  /** Data for event flow edges. */
167
207
  export interface EventEdgeData extends Record<string, unknown> {
@@ -22,7 +22,7 @@ export interface FlowCanvasProps {
22
22
  width?: number | string;
23
23
  height?: number | string;
24
24
  onNodeClick?: (context: {
25
- level: ViewLevel | 'code';
25
+ level: ViewLevel | 'code' | 'transition';
26
26
  orbital: string;
27
27
  trait?: string;
28
28
  transition?: string;
@@ -4,6 +4,12 @@
4
4
  * useReducer-based state machine managing which zoom level is displayed,
5
5
  * what is selected, and animation state.
6
6
  *
7
+ * Shared by AvlOrbitalsCosmicZoom (2D) and Avl3DViewer (3D). The 3D
8
+ * viewer drills through every level (`application → orbital → trait →
9
+ * transition`); the 2D cosmic view skips the `'orbital'` level after
10
+ * COSMIC-1 (no Orbital-View screen) by dispatching `JUMP_TO_TRAIT_CIRCUIT`
11
+ * to land directly at `'trait'`.
12
+ *
7
13
  * @packageDocumentation
8
14
  */
9
15
  export type ZoomLevel = 'application' | 'orbital' | 'trait' | 'transition';
@@ -50,6 +56,12 @@ export type ZoomAction = {
50
56
  } | {
51
57
  type: 'SWITCH_TRAIT';
52
58
  trait: string;
59
+ } | {
60
+ type: 'JUMP_TO_TRAIT_CIRCUIT';
61
+ orbital: string;
62
+ } | {
63
+ type: 'SELECT_TRAIT';
64
+ trait: string;
53
65
  };
54
66
  export declare const initialZoomState: ZoomState;
55
67
  export declare function zoomReducer(state: ZoomState, action: ZoomAction): ZoomState;
@@ -3707,6 +3707,22 @@ function zoomReducer(state, action) {
3707
3707
  selectedTransition: action.transitionIndex
3708
3708
  };
3709
3709
  }
3710
+ case "JUMP_TO_TRAIT_CIRCUIT": {
3711
+ if (state.level !== "application" || state.animating) return state;
3712
+ return {
3713
+ ...state,
3714
+ level: "trait",
3715
+ selectedOrbital: action.orbital,
3716
+ selectedTrait: null,
3717
+ selectedTransition: null,
3718
+ animating: false,
3719
+ animationDirection: "in",
3720
+ animationTarget: null
3721
+ };
3722
+ }
3723
+ case "SELECT_TRAIT": {
3724
+ return { ...state, selectedTrait: action.trait };
3725
+ }
3710
3726
  case "ZOOM_OUT": {
3711
3727
  if (state.level === "application" || state.animating) return state;
3712
3728
  return {
@@ -3739,7 +3755,8 @@ function zoomReducer(state, action) {
3739
3755
  if (state.level === "trait") {
3740
3756
  return {
3741
3757
  ...state,
3742
- level: "orbital",
3758
+ level: "application",
3759
+ selectedOrbital: null,
3743
3760
  selectedTrait: null,
3744
3761
  animating: false,
3745
3762
  animationTarget: null
@@ -3683,6 +3683,22 @@ function zoomReducer(state, action) {
3683
3683
  selectedTransition: action.transitionIndex
3684
3684
  };
3685
3685
  }
3686
+ case "JUMP_TO_TRAIT_CIRCUIT": {
3687
+ if (state.level !== "application" || state.animating) return state;
3688
+ return {
3689
+ ...state,
3690
+ level: "trait",
3691
+ selectedOrbital: action.orbital,
3692
+ selectedTrait: null,
3693
+ selectedTransition: null,
3694
+ animating: false,
3695
+ animationDirection: "in",
3696
+ animationTarget: null
3697
+ };
3698
+ }
3699
+ case "SELECT_TRAIT": {
3700
+ return { ...state, selectedTrait: action.trait };
3701
+ }
3686
3702
  case "ZOOM_OUT": {
3687
3703
  if (state.level === "application" || state.animating) return state;
3688
3704
  return {
@@ -3715,7 +3731,8 @@ function zoomReducer(state, action) {
3715
3731
  if (state.level === "trait") {
3716
3732
  return {
3717
3733
  ...state,
3718
- level: "orbital",
3734
+ level: "application",
3735
+ selectedOrbital: null,
3719
3736
  selectedTrait: null,
3720
3737
  animating: false,
3721
3738
  animationTarget: null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.54.5",
3
+ "version": "4.54.7",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [