@almadar/ui 2.1.3 → 2.1.4

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.
@@ -3,6 +3,7 @@ import React__default, { ReactNode, ErrorInfo } from 'react';
3
3
  import { LucideIcon } from 'lucide-react';
4
4
  import { SExpr } from '@almadar/evaluator';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import { OrbitalEntity } from '@almadar/core';
6
7
  import { b as DomLayoutData, d as DomStateNode, V as VisualizerConfig, e as DomTransitionLabel, C as ContentSegment } from '../cn-BoBXsxuX.js';
7
8
  export { h as cn } from '../cn-BoBXsxuX.js';
8
9
  import { I as IsometricTile, a as IsometricUnit, b as IsometricFeature, C as CameraState } from '../isometric-ynNHVPZx.js';
@@ -13,7 +14,6 @@ import { S as SlotContent, a as UISlot } from '../useUISlots-D0mttBSP.js';
13
14
  export { D as DEFAULT_SLOTS, R as RenderUIConfig, b as SlotAnimation, c as SlotChangeCallback, U as UISlotManager, u as useUISlotManager } from '../useUISlots-D0mttBSP.js';
14
15
  export { Entity, clearEntities, getAllEntities, getByType, getEntity, getSingleton, removeEntity, spawnEntity, updateEntity, updateSingleton } from '../stores/index.js';
15
16
  import 'clsx';
16
- import '@almadar/core';
17
17
  import '@tanstack/react-query';
18
18
 
19
19
  type ButtonVariant = "primary" | "secondary" | "ghost" | "danger" | "success" | "warning" | "default";
@@ -2543,10 +2543,8 @@ interface SelectPayload {
2543
2543
  ids: (string | number)[];
2544
2544
  }
2545
2545
  interface EntityDisplayProps<T = unknown> {
2546
- /** Entity name for schema-driven integration */
2547
- entity?: string;
2548
- /** Data array provided by the trait via render-ui */
2549
- data?: readonly T[] | T[];
2546
+ /** Entity data injected by the runtime (array for lists, single object for detail) */
2547
+ entity?: T | readonly T[];
2550
2548
  /** Additional CSS classes */
2551
2549
  className?: string;
2552
2550
  /** Loading state indicator */
@@ -2627,7 +2625,7 @@ interface DataTableProps<T extends {
2627
2625
  }
2628
2626
  declare function DataTable<T extends {
2629
2627
  id: string | number;
2630
- }>({ fields, columns, data, entity, itemActions, isLoading, error, emptyIcon, emptyTitle, emptyDescription, emptyAction, selectable, selectedIds, sortBy, sortDirection, searchable, searchValue, searchPlaceholder, page, pageSize, totalCount, rowActions: externalRowActions, bulkActions, headerActions, showTotal, className, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
2628
+ }>({ fields, columns, entity, itemActions, isLoading, error, emptyIcon, emptyTitle, emptyDescription, emptyAction, selectable, selectedIds, sortBy, sortDirection, searchable, searchValue, searchPlaceholder, page, pageSize, totalCount, rowActions: externalRowActions, bulkActions, headerActions, showTotal, className, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
2631
2629
  declare namespace DataTable {
2632
2630
  var displayName: string;
2633
2631
  }
@@ -2648,7 +2646,7 @@ interface MetricDefinition {
2648
2646
  /** Value format (e.g., 'currency', 'percent', 'number') */
2649
2647
  format?: "currency" | "percent" | "number" | string;
2650
2648
  }
2651
- interface StatCardProps {
2649
+ interface StatCardProps extends EntityDisplayProps<Record<string, unknown>> {
2652
2650
  /** Main label */
2653
2651
  label?: string;
2654
2652
  /** Title (alias for label) */
@@ -2683,17 +2681,8 @@ interface StatCardProps {
2683
2681
  /** Legacy onClick callback */
2684
2682
  onClick?: () => void;
2685
2683
  };
2686
- className?: string;
2687
- /** Entity name for schema-driven stats */
2688
- entity?: string;
2689
2684
  /** Metrics to display (schema format) - accepts readonly for compatibility with generated const arrays */
2690
2685
  metrics?: readonly MetricDefinition[];
2691
- /** Data to calculate stats from - accepts readonly for compatibility with generated const arrays */
2692
- data?: readonly Record<string, unknown>[];
2693
- /** Loading state indicator */
2694
- isLoading?: boolean;
2695
- /** Error state */
2696
- error?: Error | null;
2697
2686
  }
2698
2687
  declare const StatCard: React__default.FC<StatCardProps>;
2699
2688
 
@@ -2760,7 +2749,7 @@ declare const PageHeader: React__default.FC<PageHeaderProps>;
2760
2749
  *
2761
2750
  * Composes atoms and molecules to create a professional detail view.
2762
2751
  *
2763
- * Data is provided by the trait via the `data` prop (render-ui effect).
2752
+ * Data is provided by the runtime via the `entity` prop.
2764
2753
  * See EntityDisplayProps in ./types.ts for base prop contract.
2765
2754
  */
2766
2755
 
@@ -2795,7 +2784,7 @@ type FieldDef$2 = string | {
2795
2784
  key: string;
2796
2785
  header?: string;
2797
2786
  };
2798
- interface DetailPanelProps extends Omit<EntityDisplayProps<Record<string, unknown>>, 'data'> {
2787
+ interface DetailPanelProps extends EntityDisplayProps<Record<string, unknown>> {
2799
2788
  title?: string;
2800
2789
  subtitle?: string;
2801
2790
  status?: {
@@ -2812,8 +2801,6 @@ interface DetailPanelProps extends Omit<EntityDisplayProps<Record<string, unknow
2812
2801
  fields?: readonly (FieldDef$2 | DetailField)[];
2813
2802
  /** Alias for fields - backwards compatibility */
2814
2803
  fieldNames?: readonly string[];
2815
- /** Data object provided by the trait via render-ui */
2816
- data?: Record<string, unknown> | unknown;
2817
2804
  /** Initial data for edit mode (passed by compiler) */
2818
2805
  initialData?: Record<string, unknown> | unknown;
2819
2806
  /** Display mode (passed by compiler) */
@@ -3015,8 +3002,8 @@ interface FormProps extends Omit<React__default.FormHTMLAttributes<HTMLFormEleme
3015
3002
  gap?: "sm" | "md" | "lg";
3016
3003
  /** Additional CSS classes */
3017
3004
  className?: string;
3018
- /** Entity type name (schema format) */
3019
- entity?: string;
3005
+ /** Entity type name or schema object. When OrbitalEntity, fields are auto-derived if not provided. */
3006
+ entity?: string | OrbitalEntity;
3020
3007
  /** Form mode - 'create' for new records, 'edit' for updating existing */
3021
3008
  mode?: "create" | "edit";
3022
3009
  /** Fields definition (schema format) - accepts readonly for generated const arrays */
@@ -3293,6 +3280,11 @@ declare const Section: React__default.FC<SectionProps>;
3293
3280
  *
3294
3281
  * A sidebar component with logo, navigation items, user section, and collapse/expand.
3295
3282
  * Styled to match the main Layout component with theme-aware CSS variables.
3283
+ *
3284
+ * Events:
3285
+ * - collapseChangeEvent — emitted when sidebar collapse state changes, payload: { collapsed: boolean }
3286
+ * - closeEvent — emitted when close button clicked (mobile)
3287
+ * - logoClickEvent — emitted when logo/brand area clicked
3296
3288
  */
3297
3289
 
3298
3290
  interface SidebarItem {
@@ -3315,7 +3307,7 @@ interface SidebarItem {
3315
3307
  /** Sub-items (for nested navigation) */
3316
3308
  subItems?: SidebarItem[];
3317
3309
  }
3318
- interface SidebarProps {
3310
+ interface SidebarProps extends EntityDisplayProps<SidebarItem> {
3319
3311
  /** Logo/Brand content - can be a ReactNode or logo config */
3320
3312
  logo?: React__default.ReactNode;
3321
3313
  /** Logo image source */
@@ -3332,24 +3324,16 @@ interface SidebarProps {
3332
3324
  collapsed?: boolean;
3333
3325
  /** Default collapsed state */
3334
3326
  defaultCollapsed?: boolean;
3335
- /** Callback when collapse state changes */
3336
- onCollapseChange?: (collapsed: boolean) => void;
3327
+ /** Event emitted when collapse state changes, payload: { collapsed: boolean } */
3328
+ collapseChangeEvent?: string;
3337
3329
  /** Hide the collapse/expand button */
3338
3330
  hideCollapseButton?: boolean;
3339
3331
  /** Show a close button (for mobile) */
3340
3332
  showCloseButton?: boolean;
3341
- /** Callback when close button is clicked */
3342
- onClose?: () => void;
3343
- /** Callback when logo/brand is clicked */
3344
- onLogoClick?: () => void;
3345
- /** Additional CSS classes */
3346
- className?: string;
3347
- /** Loading state indicator */
3348
- isLoading?: boolean;
3349
- /** Error state */
3350
- error?: Error | null;
3351
- /** Entity name for schema-driven auto-fetch */
3352
- entity?: string;
3333
+ /** Event emitted when close button is clicked */
3334
+ closeEvent?: string;
3335
+ /** Event emitted when logo/brand is clicked */
3336
+ logoClickEvent?: string;
3353
3337
  }
3354
3338
  declare const Sidebar: React__default.FC<SidebarProps>;
3355
3339
 
@@ -3479,7 +3463,7 @@ interface TableProps<T = Record<string, unknown>> extends EntityDisplayProps<T>
3479
3463
  loading?: boolean;
3480
3464
  }
3481
3465
  declare const Table: {
3482
- <T extends Record<string, any>>({ columns, entity, data, className, isLoading, error, sortBy, sortDirection: entitySortDirection, searchValue, page, pageSize, totalCount, selectedIds, selectable, sortable, sortColumn: sortColumnProp, sortDirection: sortDirectionProp, searchable, searchPlaceholder, paginated, currentPage: currentPageProp, totalPages: totalPagesProp, rowActions, emptyMessage, loading, }: TableProps<T>): react_jsx_runtime.JSX.Element;
3466
+ <T extends Record<string, any>>({ columns, entity, className, isLoading, error, sortBy, sortDirection: entitySortDirection, searchValue, page, pageSize, totalCount, selectedIds, selectable, sortable, sortColumn: sortColumnProp, sortDirection: sortDirectionProp, searchable, searchPlaceholder, paginated, currentPage: currentPageProp, totalPages: totalPagesProp, rowActions, emptyMessage, loading, }: TableProps<T>): react_jsx_runtime.JSX.Element;
3483
3467
  displayName: string;
3484
3468
  };
3485
3469
 
@@ -3539,7 +3523,7 @@ type FieldDef$1 = string | {
3539
3523
  key: string;
3540
3524
  header?: string;
3541
3525
  };
3542
- interface ListProps extends EntityDisplayProps {
3526
+ interface ListProps extends EntityDisplayProps<Record<string, unknown>> {
3543
3527
  /** Entity type name for display */
3544
3528
  entityType?: string;
3545
3529
  selectable?: boolean;
@@ -3563,7 +3547,7 @@ declare const List: React__default.FC<ListProps>;
3563
3547
  * A dumb, responsive grid specifically designed for card layouts.
3564
3548
  * Uses CSS Grid auto-fit for automatic responsive columns.
3565
3549
  *
3566
- * Data comes exclusively from the `data` prop (provided by the trait via render-ui).
3550
+ * Data comes exclusively from the `entity` prop (injected by the runtime).
3567
3551
  * All user interactions emit events via useEventBus — never manages internal state
3568
3552
  * for pagination, filtering, or search. All state is owned by the trait state machine.
3569
3553
  */
@@ -3595,7 +3579,7 @@ type FieldDef = string | {
3595
3579
  key: string;
3596
3580
  header?: string;
3597
3581
  };
3598
- interface CardGridProps extends EntityDisplayProps {
3582
+ interface CardGridProps extends EntityDisplayProps<Record<string, unknown>> {
3599
3583
  /** Minimum width of each card (default: 280px) */
3600
3584
  minCardWidth?: number;
3601
3585
  /** Maximum number of columns */
@@ -3604,7 +3588,7 @@ interface CardGridProps extends EntityDisplayProps {
3604
3588
  gap?: CardGridGap;
3605
3589
  /** Align cards vertically in their cells */
3606
3590
  alignItems?: 'start' | 'center' | 'end' | 'stretch';
3607
- /** Children elements (cards) - optional when using entity/data props */
3591
+ /** Children elements (cards) - optional when using entity prop */
3608
3592
  children?: React__default.ReactNode;
3609
3593
  /** Fields to display - accepts string[] or {key, header}[] for unified interface */
3610
3594
  fields?: readonly FieldDef[];
@@ -3622,9 +3606,9 @@ interface CardGridProps extends EntityDisplayProps {
3622
3606
  *
3623
3607
  * Can be used in two ways:
3624
3608
  * 1. With children: <CardGrid><Card>...</Card></CardGrid>
3625
- * 2. With data: <CardGrid entity="Task" fieldNames={['title']} data={tasks} />
3609
+ * 2. With entity data: <CardGrid entity={tasks} fieldNames={['title']} />
3626
3610
  *
3627
- * All data comes from the `data` prop. Pagination display hints come from
3611
+ * All data comes from the `entity` prop. Pagination display hints come from
3628
3612
  * `page`, `pageSize`, and `totalCount` props (set by the trait via render-ui).
3629
3613
  */
3630
3614
  declare const CardGrid: React__default.FC<CardGridProps>;
@@ -3635,9 +3619,7 @@ declare const CardGrid: React__default.FC<CardGridProps>;
3635
3619
  * A layout pattern that shows a list/table of entities.
3636
3620
  * This is a thin wrapper around DataTable that accepts master-detail specific props.
3637
3621
  *
3638
- * When `entity` prop is provided without `data`, automatically fetches data
3639
- * using the useEntityList hook.
3640
- *
3622
+ * The `entity` prop carries the data array (injected by the runtime).
3641
3623
  * The "detail" part is typically rendered separately via another render_ui effect
3642
3624
  * to a sidebar or detail panel when an item is selected.
3643
3625
  */
@@ -3646,28 +3628,18 @@ interface MasterDetailProps<T extends {
3646
3628
  id: string | number;
3647
3629
  } = {
3648
3630
  id: string | number;
3649
- }> {
3650
- /** Entity type name - when provided without data, auto-fetches from API */
3651
- entity?: string;
3631
+ }> extends EntityDisplayProps<T> {
3652
3632
  /** Fields to show in the master list (maps to DataTable columns) */
3653
3633
  masterFields?: readonly string[];
3654
3634
  /** Fields for detail view (passed through but typically handled by separate render_ui) */
3655
3635
  detailFields?: readonly string[];
3656
- /** Data array - if not provided and entity is set, data is auto-fetched */
3657
- data?: readonly T[] | T[];
3658
- /** Loading state */
3636
+ /** Loading state (alias for isLoading) */
3659
3637
  loading?: boolean;
3660
- /** Loading state alias */
3661
- isLoading?: boolean;
3662
- /** Error state */
3663
- error?: Error | null;
3664
- /** Additional class name */
3665
- className?: string;
3666
3638
  }
3667
3639
  declare function MasterDetail<T extends {
3668
3640
  id: string | number;
3669
3641
  }>({ entity, masterFields, detailFields: _detailFields, // Captured but not used here - detail handled separately
3670
- data: externalData, loading: externalLoading, isLoading: externalIsLoading, error: externalError, className, ...rest }: MasterDetailProps<T>): React__default.ReactElement;
3642
+ loading: externalLoading, isLoading: externalIsLoading, error: externalError, className, ...rest }: MasterDetailProps<T>): React__default.ReactElement;
3671
3643
  declare namespace MasterDetail {
3672
3644
  var displayName: string;
3673
3645
  }
@@ -3955,7 +3927,7 @@ interface TransitionBundle {
3955
3927
  isBidirectional: boolean;
3956
3928
  isReverse: boolean;
3957
3929
  }
3958
- interface StateMachineViewProps extends EntityDisplayProps {
3930
+ interface StateMachineViewProps extends EntityDisplayProps<DomLayoutData> {
3959
3931
  layoutData: DomLayoutData;
3960
3932
  /** Custom state node renderer — when provided, replaces the default circle nodes */
3961
3933
  renderStateNode?: (state: DomStateNode, config: VisualizerConfig) => React__default.ReactNode;
@@ -4007,7 +3979,7 @@ interface SmOrbital {
4007
3979
  interface SmSchema {
4008
3980
  orbitals?: SmOrbital[];
4009
3981
  }
4010
- interface JazariStateMachineProps extends EntityDisplayProps {
3982
+ interface JazariStateMachineProps extends EntityDisplayProps<SmSchema> {
4011
3983
  /** Full schema — extracts first trait's state machine */
4012
3984
  schema?: SmSchema;
4013
3985
  /** Or pass a single trait directly */
@@ -4033,7 +4005,7 @@ declare const JazariStateMachine: React__default.FC<JazariStateMachineProps>;
4033
4005
  * - entityAware: false
4034
4006
  */
4035
4007
 
4036
- interface ContentRendererProps extends EntityDisplayProps {
4008
+ interface ContentRendererProps extends EntityDisplayProps<Record<string, unknown>> {
4037
4009
  /** Raw content string — auto-parsed into segments */
4038
4010
  content?: string;
4039
4011
  /** Pre-parsed segments (overrides content) */
@@ -4140,7 +4112,7 @@ declare function mapBookData(raw: Record<string, unknown>, fields?: BookFieldMap
4140
4112
  * - Listens: UI:BOOK_START, UI:BOOK_NAVIGATE, UI:BOOK_PAGE_PREV/NEXT, UI:BOOK_PRINT, UI:BOOK_SHOW_TOC
4141
4113
  */
4142
4114
 
4143
- interface BookViewerProps extends EntityDisplayProps {
4115
+ interface BookViewerProps extends EntityDisplayProps<BookData | Record<string, unknown>> {
4144
4116
  /** Initial page index (default: 0 = cover) */
4145
4117
  initialPage?: number;
4146
4118
  /** Field name translation map — a BookFieldMap object or locale key ("ar") */
@@ -4158,7 +4130,7 @@ declare const BookViewer: React__default.FC<BookViewerProps>;
4158
4130
  * - Delegates to ContentRenderer children
4159
4131
  */
4160
4132
 
4161
- interface BookChapterViewProps extends EntityDisplayProps {
4133
+ interface BookChapterViewProps extends EntityDisplayProps<BookChapter> {
4162
4134
  chapter: BookChapter;
4163
4135
  direction?: 'rtl' | 'ltr';
4164
4136
  }
@@ -4174,7 +4146,7 @@ declare const BookChapterView: React__default.FC<BookChapterViewProps>;
4174
4146
  * - Emits: UI:BOOK_START
4175
4147
  */
4176
4148
 
4177
- interface BookCoverPageProps extends EntityDisplayProps {
4149
+ interface BookCoverPageProps extends EntityDisplayProps<BookData> {
4178
4150
  title: string;
4179
4151
  subtitle?: string;
4180
4152
  author?: string;
@@ -4193,7 +4165,7 @@ declare const BookCoverPage: React__default.FC<BookCoverPageProps>;
4193
4165
  * - Emits: UI:BOOK_NAVIGATE { chapterId }
4194
4166
  */
4195
4167
 
4196
- interface BookTableOfContentsProps extends EntityDisplayProps {
4168
+ interface BookTableOfContentsProps extends EntityDisplayProps<BookPart> {
4197
4169
  parts: BookPart[];
4198
4170
  currentChapterId?: string;
4199
4171
  direction?: 'rtl' | 'ltr';
@@ -4210,7 +4182,7 @@ declare const BookTableOfContents: React__default.FC<BookTableOfContentsProps>;
4210
4182
  * - Emits: UI:BOOK_PAGE_PREV, UI:BOOK_PAGE_NEXT, UI:BOOK_PRINT, UI:BOOK_SHOW_TOC
4211
4183
  */
4212
4184
 
4213
- interface BookNavBarProps extends EntityDisplayProps {
4185
+ interface BookNavBarProps extends EntityDisplayProps<BookData> {
4214
4186
  currentPage: number;
4215
4187
  totalPages: number;
4216
4188
  chapterTitle?: string;
@@ -6728,11 +6700,15 @@ interface ClassifierItem {
6728
6700
  label: string;
6729
6701
  description?: string;
6730
6702
  correctCategory: string;
6703
+ /** Image URL icon for story-specific visual skin */
6704
+ iconUrl?: string;
6731
6705
  }
6732
6706
  interface ClassifierCategory {
6733
6707
  id: string;
6734
6708
  label: string;
6735
6709
  color?: string;
6710
+ /** Image URL for story-specific category header */
6711
+ imageUrl?: string;
6736
6712
  }
6737
6713
  interface ClassifierPuzzleEntity {
6738
6714
  id: string;
@@ -7538,25 +7514,15 @@ interface TimelineAction {
7538
7514
  navigatesTo?: string;
7539
7515
  variant?: "primary" | "secondary" | "ghost";
7540
7516
  }
7541
- interface TimelineProps {
7517
+ interface TimelineProps extends EntityDisplayProps<TimelineItem> {
7542
7518
  /** Timeline title */
7543
7519
  title?: string;
7544
7520
  /** Timeline items */
7545
7521
  items?: readonly TimelineItem[];
7546
- /** Schema-driven data */
7547
- data?: readonly Record<string, unknown>[];
7548
7522
  /** Fields to display */
7549
7523
  fields?: readonly string[];
7550
7524
  /** Actions per item */
7551
7525
  itemActions?: readonly TimelineAction[];
7552
- /** Entity name for schema-driven auto-fetch */
7553
- entity?: string;
7554
- /** Loading state */
7555
- isLoading?: boolean;
7556
- /** Error state */
7557
- error?: Error | null;
7558
- /** Additional CSS classes */
7559
- className?: string;
7560
7526
  }
7561
7527
  declare const Timeline: React__default.FC<TimelineProps>;
7562
7528
 
@@ -7595,35 +7561,25 @@ interface MediaGalleryAction {
7595
7561
  navigatesTo?: string;
7596
7562
  variant?: "primary" | "secondary" | "ghost";
7597
7563
  }
7598
- interface MediaGalleryProps {
7564
+ interface MediaGalleryProps extends EntityDisplayProps<MediaItem> {
7599
7565
  /** Gallery title */
7600
7566
  title?: string;
7601
7567
  /** Media items */
7602
7568
  items?: readonly MediaItem[];
7603
- /** Schema-driven data */
7604
- data?: readonly Record<string, unknown>[];
7605
7569
  /** Column count */
7606
7570
  columns?: 2 | 3 | 4 | 5 | 6;
7607
7571
  /** Enable item selection */
7608
7572
  selectable?: boolean;
7609
7573
  /** Selected item IDs */
7610
7574
  selectedItems?: readonly string[];
7611
- /** Selection change callback */
7612
- onSelectionChange?: (ids: string[]) => void;
7575
+ /** Event name emitted when selection changes (emitted as UI:{selectionEvent}) */
7576
+ selectionEvent?: string;
7613
7577
  /** Show upload button */
7614
7578
  showUpload?: boolean;
7615
7579
  /** Actions */
7616
7580
  actions?: readonly MediaGalleryAction[];
7617
7581
  /** Aspect ratio for thumbnails */
7618
7582
  aspectRatio?: "square" | "landscape" | "portrait";
7619
- /** Entity name for schema-driven auto-fetch */
7620
- entity?: string;
7621
- /** Loading state */
7622
- isLoading?: boolean;
7623
- /** Error state */
7624
- error?: Error | null;
7625
- /** Additional CSS classes */
7626
- className?: string;
7627
7583
  }
7628
7584
  declare const MediaGallery: React__default.FC<MediaGalleryProps>;
7629
7585