@factorialco/f0-react 2.55.2 → 2.56.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.
package/dist/f0.d.ts CHANGED
@@ -3958,6 +3958,8 @@ export declare type DataSourceDefinition<R extends RecordType = RecordType, Filt
3958
3958
  }) => number | undefined;
3959
3959
  };
3960
3960
 
3961
+ export declare type DataSourceItemId = string | number | symbol;
3962
+
3961
3963
  /**
3962
3964
  * Wrapper component that conditionally renders a `data-testid` attribute.
3963
3965
  *
@@ -12330,6 +12332,20 @@ declare type NavigationProps = {
12330
12332
 
12331
12333
  declare type NavTarget = HTMLAttributeAnchorTarget;
12332
12334
 
12335
+ export declare type NeighborResolution<R extends RecordType> = {
12336
+ /** Index of the active item within the loaded records, or -1 when not found */
12337
+ activeIndex: number;
12338
+ activeItem: R | null;
12339
+ previousItem: R | null;
12340
+ nextItem: R | null;
12341
+ /**
12342
+ * How the neighbours were resolved. "window" means they were located in the
12343
+ * loaded records. Reserved extension point for id-relative adapter
12344
+ * resolution (e.g. a `fetchItemNeighbors` capability).
12345
+ */
12346
+ resolvedBy: "window";
12347
+ };
12348
+
12333
12349
  /**
12334
12350
  * Utility type to extract all possible paths from nested object.
12335
12351
  * Generates hyphenated paths from nested object structure
@@ -13785,6 +13801,17 @@ export declare interface ResolvedStepAnswer {
13785
13801
  cancelled?: boolean;
13786
13802
  }
13787
13803
 
13804
+ /**
13805
+ * Locates the active item and its immediate neighbours within the currently
13806
+ * loaded records ("the window"). Pure — the single place neighbour resolution
13807
+ * happens, so alternative resolution strategies can be merged at this point.
13808
+ */
13809
+ export declare function resolveWindowNeighbors<R extends RecordType>({ records, activeItemId, idProvider, }: {
13810
+ records: readonly R[];
13811
+ activeItemId: DataSourceItemId | null;
13812
+ idProvider: (item: R, index?: number) => DataSourceItemId;
13813
+ }): NeighborResolution<R>;
13814
+
13788
13815
  declare type ResourceHeaderProps = Props_4;
13789
13816
 
13790
13817
  /** All styling props that can be overridden per breakpoint */
@@ -15361,13 +15388,21 @@ declare type UseChatHistoryReturn = {
15361
15388
  * - paginationInfo: Pagination state and metadata if available
15362
15389
  * - setPage: Function to navigate to a specific page
15363
15390
  */
15364
- export declare function useData<R extends RecordType = RecordType, Filters extends FiltersDefinition = FiltersDefinition, Sortings extends SortingsDefinition = SortingsDefinition, Grouping extends GroupingDefinition<R> = GroupingDefinition<R>>(source: DataSource<R, Filters, Sortings, Grouping>, { filters, onError, fetchParamsProvider, onResponse, }?: UseDataOptions<R, Filters>, deps?: unknown[]): UseDataReturn<R>;
15391
+ export declare function useData<R extends RecordType = RecordType, Filters extends FiltersDefinition = FiltersDefinition, Sortings extends SortingsDefinition = SortingsDefinition, Grouping extends GroupingDefinition<R> = GroupingDefinition<R>>(source: DataSource<R, Filters, Sortings, Grouping>, { filters, enabled, onError, fetchParamsProvider, onResponse, }?: UseDataOptions<R, Filters>, deps?: unknown[]): UseDataReturn<R>;
15365
15392
 
15366
15393
  /**
15367
15394
  * Hook options for useData
15368
15395
  */
15369
15396
  export declare interface UseDataOptions<R extends RecordType, Filters extends FiltersDefinition> {
15370
15397
  filters?: Partial<FiltersState<Filters>>;
15398
+ /**
15399
+ * When false, suspends all data fetching: the initial fetch effect does not
15400
+ * run until `enabled` becomes true. Useful to delay the first fetch until
15401
+ * async state (e.g. persisted filters) has been applied to the source.
15402
+ * `isInitialLoading` stays true while disabled.
15403
+ * @default true
15404
+ */
15405
+ enabled?: boolean;
15371
15406
  /**
15372
15407
  * A function that is called when an error occurs during data fetching.
15373
15408
  * It is called with the error object.
@@ -15443,6 +15478,72 @@ export declare interface UseDataReturn<R extends RecordType> {
15443
15478
  */
15444
15479
  export declare function useDataSource<R extends RecordType = RecordType, FiltersSchema extends FiltersDefinition = FiltersDefinition, Sortings extends SortingsDefinition = SortingsDefinition, Grouping extends GroupingDefinition<R> = GroupingDefinition<R>>({ defaultFilters, currentFilters: externalCurrentFilters, defaultGrouping: externalDefaultGrouping, currentGrouping: externalCurrentGrouping, filters, search, defaultSortings, currentSortings: externalCurrentSortings, dataAdapter, grouping, ...rest }: DataSourceDefinition<R, FiltersSchema, Sortings, Grouping>, deps?: ReadonlyArray<unknown>): DataSource<R, FiltersSchema, Sortings, Grouping>;
15445
15480
 
15481
+ export declare function useDataSourceItemNavigation<R extends RecordType>(props: UseDataSourceItemNavigationProps<R>): UseDataSourceItemNavigationReturn<R>;
15482
+
15483
+ export declare interface UseDataSourceItemNavigationProps<R extends RecordType> {
15484
+ /** The data source returned by `useDataSource`. Used to extract `idProvider` */
15485
+ dataSource: {
15486
+ idProvider?: <Item extends R>(item: Item, index?: number) => DataSourceItemId;
15487
+ };
15488
+ /** The data returned by `useData` */
15489
+ data: Data<R>;
15490
+ /** Pagination info returned by `useData` */
15491
+ paginationInfo: PaginationInfo | null;
15492
+ /** Navigate to a specific page (from `useData`) */
15493
+ setPage: UseDataReturn<R>["setPage"];
15494
+ /** Load more items for infinite-scroll (from `useData`) */
15495
+ loadMore: UseDataReturn<R>["loadMore"];
15496
+ /** Whether `useData` is currently loading data */
15497
+ isLoading: boolean;
15498
+ /** Overrides `dataSource.idProvider`. Extracts a unique ID from a record. Falls back to `item.id` */
15499
+ idProvider?: (item: R, index?: number) => DataSourceItemId;
15500
+ /** Returns the URL for a given item. Used to derive `nextItemUrl` / `previousItemUrl` */
15501
+ itemUrl?: (item: R) => string | undefined;
15502
+ /** Controlled active item ID */
15503
+ activeItemId?: DataSourceItemId | null;
15504
+ /** Default active item ID (uncontrolled) */
15505
+ defaultActiveItemId?: DataSourceItemId | null;
15506
+ /** Callback when active item changes */
15507
+ onActiveItemChange?: (id: DataSourceItemId | null) => void;
15508
+ }
15509
+
15510
+ export declare interface UseDataSourceItemNavigationReturn<R extends RecordType> {
15511
+ /** The currently active item ID */
15512
+ activeItemId: DataSourceItemId | null;
15513
+ /** The currently active item record, or null if not found in loaded data */
15514
+ activeItem: R | null;
15515
+ /** The active item index within the currently loaded records */
15516
+ activeIndex: number;
15517
+ /** The active item index within the full collection when it can be inferred */
15518
+ absoluteIndex: number | null;
15519
+ /** Number of records currently loaded into the datasource */
15520
+ loadedItemsCount: number;
15521
+ /** Total number of matching records when pagination exposes it */
15522
+ totalItems: number | undefined;
15523
+ /** The previous loaded item record, or null if unavailable */
15524
+ previousItem: R | null;
15525
+ /** The next loaded item record, or null if unavailable */
15526
+ nextItem: R | null;
15527
+ /** URL of the active item (derived via `itemUrl`), or null if unavailable */
15528
+ activeItemUrl: string | null;
15529
+ /** Navigate to the next item. Fetches next page if at boundary */
15530
+ goToNext: () => void;
15531
+ /** Navigate to the previous item. Fetches previous page if at boundary */
15532
+ goToPrevious: () => void;
15533
+ /** Whether there is a next item (or more pages to load) */
15534
+ hasNext: boolean;
15535
+ /** Whether there is a previous item (or previous pages to load) */
15536
+ hasPrevious: boolean;
15537
+ /** Directly set the active item ID */
15538
+ setActiveItemId: (id: DataSourceItemId | null) => void;
15539
+ /** True while waiting for a page transition to resolve the pending navigation */
15540
+ isNavigating: boolean;
15541
+ /** URL of the next loaded item (derived via `itemUrl`), or null if unavailable */
15542
+ nextItemUrl: string | null;
15543
+ /** URL of the previous loaded item (derived via `itemUrl`), or null if unavailable */
15544
+ previousItemUrl: string | null;
15545
+ }
15546
+
15446
15547
  export declare function useDndEvents(handler: (e: {
15447
15548
  phase: "start" | "over" | "drop" | "cancel";
15448
15549
  source: DragPayload;
@@ -16144,6 +16245,11 @@ declare module "gridstack" {
16144
16245
  }
16145
16246
 
16146
16247
 
16248
+ declare namespace Calendar {
16249
+ var displayName: string;
16250
+ }
16251
+
16252
+
16147
16253
  declare module "@tiptap/core" {
16148
16254
  interface Commands<ReturnType> {
16149
16255
  aiBlock: {
@@ -16193,11 +16299,6 @@ declare module "@tiptap/core" {
16193
16299
  }
16194
16300
 
16195
16301
 
16196
- declare namespace Calendar {
16197
- var displayName: string;
16198
- }
16199
-
16200
-
16201
16302
  declare namespace F0GraphNodeWrapperInner {
16202
16303
  var displayName: string;
16203
16304
  }