@almadar/ui 3.9.1 → 4.0.1

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.
@@ -11,7 +11,7 @@
11
11
  * Uses atoms only internally: Box, VStack, HStack, Typography, Badge, Button, Icon.
12
12
  */
13
13
  import React from 'react';
14
- import type { EventKey } from '@almadar/core';
14
+ import type { EntityRow, EventKey } from '@almadar/core';
15
15
  export interface DataGridField {
16
16
  /** Entity field name (dot-notation supported) */
17
17
  name: string;
@@ -35,9 +35,16 @@ export interface DataGridItemAction {
35
35
  /** Button variant */
36
36
  variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
37
37
  }
38
- export interface DataGridProps {
39
- /** Entity data array */
40
- entity: unknown | readonly unknown[];
38
+ export interface DataGridProps<T extends EntityRow = EntityRow> {
39
+ /**
40
+ * Schema entity data single record or collection, typed against
41
+ * `@almadar/core`'s `EntityRow` so the narrow type declared on the
42
+ * emitting trait's `Event { data : [X] }` flows through to the prop
43
+ * without widening. The generic `T` lets consumers pass a narrower
44
+ * entity (e.g. `CartItem`) and have the `children` render function
45
+ * receive cards typed to that exact shape.
46
+ */
47
+ entity: T | readonly T[];
41
48
  /** Field definitions for rendering each card */
42
49
  fields: readonly DataGridField[];
43
50
  /** Alias for fields (compiler generates `columns` for field definitions) */
@@ -68,16 +75,20 @@ export interface DataGridProps {
68
75
  loadMoreEvent?: EventKey;
69
76
  /** Whether more items are available for infinite scroll */
70
77
  hasMore?: boolean;
71
- /** Render prop for custom per-item content. When provided, `fields` and `itemActions` are ignored. */
72
- children?: (item: Record<string, unknown>, index: number) => React.ReactNode;
78
+ /** Render prop for custom per-card content, typed to the grid's entity
79
+ * shape `T`. When provided, `fields` and `itemActions` are ignored. */
80
+ children?: (item: T, index: number) => React.ReactNode;
73
81
  /**
74
82
  * Per-item render function (schema-level alias for children render prop).
75
83
  * In .orb schemas: ["fn", "item", { pattern tree with @item.field bindings }]
76
84
  * The compiler converts this to the children render prop.
77
85
  * @deprecated Use children render prop in React code. This prop exists for pattern registry sync.
78
86
  */
79
- renderItem?: (item: Record<string, unknown>, index: number) => React.ReactNode;
87
+ renderItem?: (item: T, index: number) => React.ReactNode;
80
88
  /** Max items to show before "Show More" button. Defaults to 0 (disabled). */
81
89
  pageSize?: number;
82
90
  }
83
- export declare const DataGrid: React.FC<DataGridProps>;
91
+ export declare function DataGrid<T extends EntityRow = EntityRow>({ entity, fields: fieldsProp, columns: columnsProp, itemActions, cols, gap, minCardWidth, className, isLoading, error, imageField, selectable, selectionEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, }: DataGridProps<T>): import("react/jsx-runtime").JSX.Element;
92
+ export declare namespace DataGrid {
93
+ var displayName: string;
94
+ }
@@ -11,7 +11,7 @@
11
11
  * Uses atoms only internally: Box, VStack, HStack, Typography, Badge, Button, Icon.
12
12
  */
13
13
  import React from 'react';
14
- import type { EventKey } from "@almadar/core";
14
+ import type { EntityRow, EventKey } from "@almadar/core";
15
15
  export interface DataListField {
16
16
  /** Entity field name (dot-notation supported) */
17
17
  name: string;
@@ -35,9 +35,16 @@ export interface DataListItemAction {
35
35
  /** Button variant */
36
36
  variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
37
37
  }
38
- export interface DataListProps {
39
- /** Entity data array */
40
- entity: unknown | readonly unknown[];
38
+ export interface DataListProps<T extends EntityRow = EntityRow> {
39
+ /**
40
+ * Schema entity data single record or collection, typed against
41
+ * `@almadar/core`'s `EntityRow` so the narrow type declared on the
42
+ * emitting trait's `Event { data : [X] }` flows through to the prop
43
+ * without widening. The generic `T` lets consumers pass a narrower
44
+ * entity (e.g. `CartItem`) and have the `children` render function
45
+ * receive items of that exact shape.
46
+ */
47
+ entity: T | readonly T[];
41
48
  /** Field definitions for rendering each row */
42
49
  fields: readonly DataListField[];
43
50
  /** Alias for fields (compiler may generate `columns` for field definitions) */
@@ -89,15 +96,23 @@ export interface DataListProps {
89
96
  /** Whether more items are available for infinite scroll */
90
97
  hasMore?: boolean;
91
98
  /** Render prop for custom per-item content. When provided, `fields` and `itemActions` are ignored. */
92
- children?: (item: Record<string, unknown>, index: number) => React.ReactNode;
99
+ /**
100
+ * Render function for each row's content. Receives an item of the
101
+ * component's entity type `T` (narrowed via the generic parameter)
102
+ * and the row's index in the materialised array.
103
+ */
104
+ children?: (item: T, index: number) => React.ReactNode;
93
105
  /**
94
106
  * Per-item render function (schema-level alias for children render prop).
95
107
  * In .orb schemas: ["fn", "item", { pattern tree with @item.field bindings }]
96
108
  * The compiler converts this to the children render prop.
97
109
  * @deprecated Use children render prop in React code. This prop exists for pattern registry sync.
98
110
  */
99
- renderItem?: (item: Record<string, unknown>, index: number) => React.ReactNode;
111
+ renderItem?: (item: T, index: number) => React.ReactNode;
100
112
  /** Max items to show before "Show More" button. Defaults to 5. Set to 0 to disable. */
101
113
  pageSize?: number;
102
114
  }
103
- export declare const DataList: React.FC<DataListProps>;
115
+ export declare function DataList<T extends EntityRow = EntityRow>({ entity, fields: fieldsProp, columns: columnsProp, itemActions, gap, variant, groupBy, senderField, currentUser, className, isLoading, error, reorderable: _reorderable, reorderEvent: _reorderEvent, swipeLeftEvent: _swipeLeftEvent, swipeLeftActions: _swipeLeftActions, swipeRightEvent: _swipeRightEvent, swipeRightActions: _swipeRightActions, longPressEvent: _longPressEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, }: DataListProps<T>): import("react/jsx-runtime").JSX.Element;
116
+ export declare namespace DataList {
117
+ var displayName: string;
118
+ }
@@ -20,8 +20,8 @@ export interface WizardProgressStep {
20
20
  description?: string;
21
21
  }
22
22
  export interface WizardProgressProps {
23
- /** Step definitions (compatible with WizardContainer's WizardStep) */
24
- steps: WizardProgressStep[];
23
+ /** Step definitions (compatible with WizardContainer's WizardStep). A string is shorthand for `{ id: str, title: str }`. */
24
+ steps: (WizardProgressStep | string)[];
25
25
  /** Current step index (0-based) */
26
26
  currentStep: number;
27
27
  /** Callback when a completed step is clicked */
@@ -68,8 +68,6 @@ export interface DetailPanelProps extends EntityDisplayProps {
68
68
  position?: "left" | "right";
69
69
  /** Panel width (CSS value, e.g., '400px', '50%') */
70
70
  width?: string;
71
- /** Entity ID for fetching specific entity */
72
- entityId?: string;
73
71
  /** Display fields (alias for fields) */
74
72
  displayFields?: readonly string[];
75
73
  /** Show actions flag */
@@ -177,8 +177,6 @@ export interface FormProps extends Omit<React.FormHTMLAttributes<HTMLFormElement
177
177
  submitEvent?: EventKey;
178
178
  /** Event to dispatch on cancel (defaults to 'CANCEL') */
179
179
  cancelEvent?: EventKey;
180
- /** Entity ID binding for edit mode (triggers initialData from selectedEntity in compiled code) */
181
- entityId?: string;
182
180
  /** Data for relation fields: { fieldName: RelationOption[] } */
183
181
  relationsData?: Record<string, readonly RelationOption[]>;
184
182
  /** Loading state for relation data: { fieldName: boolean } */
@@ -15,8 +15,6 @@ export interface FormSectionProps extends EntityDisplayProps {
15
15
  card?: boolean;
16
16
  /** Grid columns for fields */
17
17
  columns?: 1 | 2 | 3;
18
- /** Entity ID for fetching specific entity */
19
- entityId?: string;
20
18
  }
21
19
  export declare const FormSection: React.FC<FormSectionProps>;
22
20
  /**