@almadar/ui 4.48.0 → 4.50.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.
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import React from 'react';
14
14
  import type { EntityRow, EventKey } from '@almadar/core';
15
+ import { type DataDndProps } from './useDataDnd';
15
16
  export interface DataGridField {
16
17
  /** Entity field name (dot-notation supported) */
17
18
  name: string;
@@ -45,7 +46,7 @@ export interface DataGridItemAction {
45
46
  /** Button variant */
46
47
  variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
47
48
  }
48
- export interface DataGridProps<T extends EntityRow = EntityRow> {
49
+ export interface DataGridProps<T extends EntityRow = EntityRow> extends DataDndProps {
49
50
  /**
50
51
  * Schema entity data — single record or collection, typed against
51
52
  * `@almadar/core`'s `EntityRow` so the narrow type declared on the
@@ -102,7 +103,7 @@ export interface DataGridProps<T extends EntityRow = EntityRow> {
102
103
  /** Max items to show before "Show More" button. Defaults to 0 (disabled). */
103
104
  pageSize?: number;
104
105
  }
105
- export declare function DataGrid<T extends EntityRow = EntityRow>({ entity, fields, columns, itemActions, cols, gap, minCardWidth, className, isLoading, error, imageField, selectable, selectionEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, renderItem: schemaRenderItem, }: DataGridProps<T>): import("react/jsx-runtime").JSX.Element;
106
+ export declare function DataGrid<T extends EntityRow = EntityRow>({ entity, fields, columns, itemActions, cols, gap, minCardWidth, className, isLoading, error, imageField, selectable, selectionEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, renderItem: schemaRenderItem, dragGroup, accepts, sortable, dropEvent, reorderEvent, dndItemIdField, }: DataGridProps<T>): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
106
107
  export declare namespace DataGrid {
107
108
  var displayName: string;
108
109
  }
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import React from 'react';
14
14
  import type { EntityRow, EventKey } from "@almadar/core";
15
+ import { type DataDndProps } from './useDataDnd';
15
16
  export interface DataListField {
16
17
  /** Entity field name (dot-notation supported) */
17
18
  name: string;
@@ -35,7 +36,7 @@ export interface DataListItemAction {
35
36
  /** Button variant */
36
37
  variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
37
38
  }
38
- export interface DataListProps<T extends EntityRow = EntityRow> {
39
+ export interface DataListProps<T extends EntityRow = EntityRow> extends DataDndProps {
39
40
  /**
40
41
  * Schema entity data — single record or collection, typed against
41
42
  * `@almadar/core`'s `EntityRow` so the narrow type declared on the
@@ -116,7 +117,7 @@ export interface DataListProps<T extends EntityRow = EntityRow> {
116
117
  /** Max items to show before "Show More" button. Defaults to 5. Set to 0 to disable. */
117
118
  pageSize?: number;
118
119
  }
119
- export declare function DataList<T extends EntityRow = EntityRow>({ entity, fields, columns, 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, renderItem: schemaRenderItem, }: DataListProps<T>): import("react/jsx-runtime").JSX.Element;
120
+ export declare function DataList<T extends EntityRow = EntityRow>({ entity, fields, columns, 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, renderItem: schemaRenderItem, dragGroup, accepts, sortable: sortableProp, dropEvent, reorderEvent: dndReorderEvent, dndItemIdField, }: DataListProps<T>): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
120
121
  export declare namespace DataList {
121
122
  var displayName: string;
122
123
  }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * useDataDnd — shared drag-drop machinery for DataList + DataGrid.
3
+ *
4
+ * Both primitives expose six identical drag-drop props:
5
+ * - dragGroup?: string items in this container announce this group when picked up
6
+ * - accepts?: string this container accepts drops whose dragGroup matches (or "*" for any)
7
+ * - sortable?: boolean enable in-container reorder
8
+ * - dropEvent?: EventKey bus event on cross-container drop: { id, sourceGroup, targetGroup, newIndex }
9
+ * - reorderEvent?: EventKey bus event on in-container reorder: { id, oldIndex, newIndex }
10
+ * - dndItemIdField?: string row field used as the @dnd-kit draggable id (default "id")
11
+ *
12
+ * Architecture
13
+ * - A container that opts in via any dnd prop becomes a "zone".
14
+ * - The first ancestor zone in the tree creates the DndContext (the "root").
15
+ * - Inner zones detect the root via React context and skip creating their own.
16
+ * - The root's onDragEnd reads source + target zone metadata off the dragged
17
+ * item and the drop target, dispatches to the bus accordingly.
18
+ */
19
+ import React from 'react';
20
+ import { type UniqueIdentifier } from '@dnd-kit/core';
21
+ import type { EntityRow, EventKey } from '@almadar/core';
22
+ export interface DataDndProps {
23
+ dragGroup?: string;
24
+ accepts?: string;
25
+ sortable?: boolean;
26
+ dropEvent?: EventKey;
27
+ reorderEvent?: EventKey;
28
+ dndItemIdField?: string;
29
+ }
30
+ interface UseDataDndArgs<T extends EntityRow> extends DataDndProps {
31
+ items: readonly T[];
32
+ layout: 'list' | 'grid';
33
+ }
34
+ interface UseDataDndResult<T extends EntityRow> {
35
+ enabled: boolean;
36
+ wrapContainer: (children: React.ReactNode) => React.ReactNode;
37
+ SortableItem: React.FC<{
38
+ id: UniqueIdentifier;
39
+ children: React.ReactNode;
40
+ }>;
41
+ orderedItems: readonly T[];
42
+ }
43
+ export declare function useDataDnd<T extends EntityRow>(args: UseDataDndArgs<T>): UseDataDndResult<T>;
44
+ export {};