@factorialco/f0-react 1.189.3 → 1.191.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
@@ -45,6 +45,7 @@ import { LongTextCellValue } from './types/longText.tsx';
45
45
  import { MouseEventHandler } from 'react';
46
46
  import { NumberCellValue } from '../../value-display/types/number';
47
47
  import { NumberCellValue as NumberCellValue_2 } from './types/number.tsx';
48
+ import { Observable } from 'zen-observable-ts';
48
49
  import { PercentageCellValue } from './types/percentage.tsx';
49
50
  import { PersonCellValue } from '../../value-display/types/person';
50
51
  import { PersonCellValue as PersonCellValue_2 } from './types/person.tsx';
@@ -101,6 +102,19 @@ declare const alertAvatarVariants: (props?: ({
101
102
 
102
103
  declare type AlertTagProps = ComponentProps<typeof F0TagAlert>;
103
104
 
105
+ export declare type AllSelectionStatus = {
106
+ checked: boolean;
107
+ indeterminate: boolean;
108
+ selectedCount: number;
109
+ unselectedCount: number;
110
+ };
111
+
112
+ declare type AnimationVariantsOptions = {
113
+ delay?: number;
114
+ duration?: number;
115
+ maxDelay?: number;
116
+ };
117
+
104
118
  export declare const AreaChart: ForwardRefExoticComponent<Omit<LineChartPropsBase<LineChartConfig> & {
105
119
  lineType?: "step" | "linear" | "natural" | "monotoneX";
106
120
  marginTop?: number;
@@ -283,6 +297,33 @@ declare interface BaseChipProps extends VariantProps<typeof chipVariants> {
283
297
 
284
298
  declare type BaseColor = keyof typeof baseColors;
285
299
 
300
+ /**
301
+ * Base data adapter configuration for non-paginated collections
302
+ * @template R - The type of records in the collection
303
+ * @template Filters - The available filter configurations
304
+ */
305
+ export declare type BaseDataAdapter<R extends RecordType, Filters extends FiltersDefinition, Options extends BaseFetchOptions<Filters>, FetchReturn = BaseResponse<R>> = {
306
+ /** Indicates this adapter doesn't use pagination */
307
+ paginationType?: never | undefined;
308
+ /**
309
+ * Function to fetch data based on filter options
310
+ * @param options - The filter options to apply when fetching data
311
+ * @returns Array of records, promise of records, or observable of records
312
+ */
313
+ fetchData: (options: Options) => FetchReturn | Promise<FetchReturn> | Observable<PromiseState<FetchReturn>>;
314
+ };
315
+
316
+ /**
317
+ * Base options for data fetching
318
+ * @template Filters - The available filter configurations
319
+ */
320
+ export declare type BaseFetchOptions<Filters extends FiltersDefinition> = {
321
+ /** Currently applied filters */
322
+ filters: FiltersState<Filters>;
323
+ sortings: SortingsStateMultiple;
324
+ search?: string;
325
+ };
326
+
286
327
  /**
287
328
  * Base definition for all filter types.
288
329
  * Provides common properties that all filters must implement.
@@ -298,6 +339,34 @@ declare type BaseFilterDefinition<T extends FilterTypeKey> = {
298
339
  hideSelector?: boolean;
299
340
  };
300
341
 
342
+ /**
343
+ * Represents a base structure for paginated API responses, providing
344
+ * details about the records on the current page and pagination metadata.
345
+ *
346
+ * @template R The type of each record in the paginated response.
347
+ *
348
+ * @property {number} total The total number of records available.
349
+ * @property {number} perPage The number of records displayed per page.
350
+ */
351
+ export declare type BasePaginatedResponse<R> = BaseResponse<R> & {
352
+ /** Total number of records available */
353
+ total: number;
354
+ /** Number of records per page */
355
+ perPage: number;
356
+ };
357
+
358
+ /**
359
+ * Base response type for collection data
360
+ * @template R - The type of records in the collection
361
+ *
362
+ * @property {R[]} records The list of records for the current page.
363
+ * @property {TRecord} [summaries] Optional summaries data for the collection.
364
+ */
365
+ export declare type BaseResponse<R> = {
366
+ records: R[];
367
+ summaries?: R;
368
+ };
369
+
301
370
  declare type BaseTag<T extends {
302
371
  type: string;
303
372
  }> = T & WithTooltipDescription;
@@ -631,6 +700,16 @@ declare type CopyButtonProps = Omit<ComponentProps<typeof Button_2>, "onClick" |
631
700
 
632
701
  export declare function createAtlaskitDriver(instanceId: symbol): DndDriver;
633
702
 
703
+ /**
704
+ * Create a data source definition from a data source definition
705
+ * This function is a helper to allow to infer the type of the data source definition
706
+ * from the data source definition.
707
+ *
708
+ * @param definition - The data source definition to create from
709
+ * @returns The created data source definition
710
+ */
711
+ export declare const createDataSourceDefinition: <R extends RecordType = RecordType, FiltersSchema extends FiltersDefinition = FiltersDefinition, Sortings extends SortingsDefinition = SortingsDefinition, Grouping extends GroupingDefinition<R> = GroupingDefinition<R>>(definition: DataSourceDefinition<R, FiltersSchema, Sortings, Grouping>) => DataSourceDefinition<R, FiltersSchema, Sortings, Grouping>;
712
+
634
713
  /**
635
714
  * Extracts the current filters type from filter options.
636
715
  * Creates a type mapping filter keys to their respective value types.
@@ -643,6 +722,92 @@ export declare type CurrentFilters<F extends FilterOptions<string>> = F extends
643
722
  [Key in K]?: FilterValue<F["fields"][Key]>;
644
723
  } : Record<string, never>;
645
724
 
725
+ export declare type Data<R extends RecordType> = {
726
+ records: WithGroupId<R>[];
727
+ type: "grouped" | "flat";
728
+ groups: GroupRecord<R>[];
729
+ };
730
+
731
+ /**
732
+ * Combined type for all possible data adapter configurations
733
+ * @template R - The type of records in the collection
734
+ * @template Filters - The available filter configurations
735
+ */
736
+ export declare type DataAdapter<R extends RecordType, Filters extends FiltersDefinition> = BaseDataAdapter<R, Filters, BaseFetchOptions<Filters>, BaseResponse<R>> | PaginatedDataAdapter<R, Filters, PaginatedFetchOptions<Filters>, PaginatedResponse<R>>;
737
+
738
+ /**
739
+ * Represents an error that occurred during data fetching
740
+ */
741
+ export declare interface DataError {
742
+ message: string;
743
+ cause?: unknown;
744
+ }
745
+
746
+ /**
747
+ * Represents a data source with filtering capabilities and data fetching functionality.
748
+ * Extends DataSourceDefinition with runtime properties for state management.
749
+ * @template R - The type of records in the collection
750
+ * @template Filters - The available filter configurations for the collection
751
+ * @template ItemActions - The available actions that can be performed on records
752
+ */
753
+ export declare type DataSource<R extends RecordType, Filters extends FiltersDefinition, Sortings extends SortingsDefinition, Grouping extends GroupingDefinition<R>> = DataSourceDefinition<R, Filters, Sortings, Grouping> & {
754
+ /** Current state of applied filters */
755
+ currentFilters: FiltersState<Filters>;
756
+ /** Function to update the current filters state */
757
+ setCurrentFilters: React.Dispatch<React.SetStateAction<FiltersState<Filters>>>;
758
+ /** Current state of applied sortings */
759
+ currentSortings: SortingsState<Sortings>;
760
+ /** Function to update the current sortings state */
761
+ setCurrentSortings: React.Dispatch<React.SetStateAction<SortingsState<Sortings>>>;
762
+ currentSearch: undefined | string;
763
+ debouncedCurrentSearch: undefined | string;
764
+ setCurrentSearch: (search: string | undefined) => void;
765
+ isLoading: boolean;
766
+ setIsLoading: (loading: boolean) => void;
767
+ /** Current state of applied grouping */
768
+ currentGrouping?: Grouping["mandatory"] extends true ? Exclude<GroupingState<R, Grouping>, undefined> : GroupingState<R, Grouping>;
769
+ /** Function to update the current grouping state */
770
+ setCurrentGrouping: React.Dispatch<React.SetStateAction<GroupingState<R, Grouping>>>;
771
+ /** Function to provide an id for a record, necessary for append mode */
772
+ idProvider?: <Item extends R>(item: Item, index?: number) => string | number | symbol;
773
+ };
774
+
775
+ /**
776
+ * Defines the structure and configuration of a data source for a collection.
777
+ * @template R - The type of records in the collection
778
+ * @template Filters - The available filter configurations for the collection
779
+ * @template ItemActions - The available actions that can be performed on records
780
+ * @template NavigationFilters - The available navigation filters for the collection
781
+ * @template Sortings - The available sortings for the collection
782
+ * @template ItemActions - The available actions that can be performed on records
783
+ * @template PrimaryActions - The available primary actions that can be performed on the collection
784
+ * @template SecondaryActions - The available actions that can be performed on the collection
785
+ * @template OtherActions - The available actions that can be performed on the collection
786
+ * @template Summaries - The available summaries for the collection
787
+ */
788
+ export declare type DataSourceDefinition<R extends RecordType = RecordType, Filters extends FiltersDefinition = FiltersDefinition, Sortings extends SortingsDefinition = SortingsDefinition, Grouping extends GroupingDefinition<R> = GroupingDefinition<R>> = {
789
+ /** Available filter configurations */
790
+ filters?: Filters;
791
+ /** Current state of applied filters */
792
+ currentFilters?: FiltersState<Filters>;
793
+ /** Predefined filter configurations that can be applied */
794
+ presets?: PresetsDefinition<Filters>;
795
+ /** Search configuration */
796
+ search?: SearchOptions;
797
+ /** Available sorting fields. If not provided, sorting is not allowed. */
798
+ sortings?: Sortings;
799
+ defaultSorting?: SortingsState<Sortings>;
800
+ /** Data adapter responsible for fetching and managing data */
801
+ dataAdapter: DataAdapter<R, Filters>;
802
+ /** Selectable items value under the checkbox column (undefined if not selectable) */
803
+ selectable?: (item: R) => string | number | undefined;
804
+ /** Default selected items */
805
+ defaultSelectedItems?: SelectedItemsState;
806
+ /** Grouping configuration */
807
+ grouping?: Grouping;
808
+ currentGrouping?: GroupingState<R, Grouping>;
809
+ };
810
+
646
811
  declare type DateFilterDefinition = BaseFilterDefinition<"date"> & {
647
812
  options?: DateFilterOptions_2;
648
813
  };
@@ -841,10 +1006,8 @@ export declare const defaultTranslations: {
841
1006
  };
842
1007
  readonly notifications: "Notifications";
843
1008
  readonly ai: {
844
- readonly description: "Chat with AI";
845
- readonly expandChat: "Expand chat";
846
- readonly minimizeChat: "Minimize chat window";
847
- readonly openChat: "Open Chat";
1009
+ readonly openChat: "Open Chat with One AI";
1010
+ readonly closeChat: "Close Chat with One AI";
848
1011
  readonly scrollToBottom: "Scroll to bottom";
849
1012
  readonly welcome: "I'm One. Ask or make anything.";
850
1013
  readonly initialMessage: "How can I help you today?";
@@ -1305,8 +1468,83 @@ declare type FilterTypeSchema<Options extends object = never> = {
1305
1468
  */
1306
1469
  export declare type FilterValue<T extends FilterDefinition> = T extends InFilterDefinition<infer U> ? U[] : T extends SearchFilterDefinition ? string : T extends DateFilterDefinition ? DateRange | Date | undefined : never;
1307
1470
 
1471
+ export declare const getAnimationVariants: (options?: AnimationVariantsOptions) => {
1472
+ hidden: {
1473
+ opacity: number;
1474
+ y: number;
1475
+ };
1476
+ visible: (i: number) => {
1477
+ opacity: number;
1478
+ y: number;
1479
+ transition: {
1480
+ delay: number;
1481
+ duration: number;
1482
+ type: string;
1483
+ stiffness: number;
1484
+ damping: number;
1485
+ };
1486
+ };
1487
+ };
1488
+
1489
+ /**
1490
+ * Get the pagination type of a data adapter
1491
+ * @param dataAdapter - The data adapter to get the pagination type of
1492
+ * @returns The pagination type of the data adapter
1493
+ */
1494
+ export declare const getDataSourcePaginationType: <D extends {
1495
+ paginationType?: PaginationType | undefined | never;
1496
+ }>(dataAdapter: D) => PaginationType;
1497
+
1308
1498
  export declare function getEmojiLabel(emoji: string): string;
1309
1499
 
1500
+ /**
1501
+ * Symbol used to identify the groupId in the data
1502
+ */
1503
+ export declare const GROUP_ID_SYMBOL: unique symbol;
1504
+
1505
+ /**
1506
+ * Defines the structure and configuration of a grouping options for a data source.
1507
+ * @template RecordType - The type of records in the collection
1508
+ */
1509
+ export declare type GroupingDefinition<R extends RecordType> = {
1510
+ /** Whether grouping is mandatory or the user can chose not to group */
1511
+ mandatory?: boolean;
1512
+ hideSelector?: boolean;
1513
+ groupBy: {
1514
+ [K in RecordPaths<R>]?: {
1515
+ /** The label for the grouping */
1516
+ name: string;
1517
+ /** The item count for the grouping */
1518
+ label: (groupId: RecordPathValue<R, K>, filters: FiltersState<FiltersDefinition>) => string | Promise<string>;
1519
+ itemCount?: (groupId: RecordPathValue<R, K>, filters: FiltersState<FiltersDefinition>) => number | undefined | Promise<number | undefined>;
1520
+ };
1521
+ };
1522
+ } & ({
1523
+ /** Whether the grouping is non collapsible */
1524
+ collapsible: true;
1525
+ /** The initial open groups */
1526
+ defaultOpenGroups?: boolean | string[];
1527
+ } | {
1528
+ collapsible?: false;
1529
+ defaultOpenGroups?: never;
1530
+ });
1531
+
1532
+ /**
1533
+ * The selected the grouping state
1534
+ * @template Grouping - The grouping definition
1535
+ */
1536
+ export declare type GroupingState<R extends RecordType, Grouping extends GroupingDefinition<R>> = {
1537
+ field: keyof Grouping["groupBy"];
1538
+ order: SortOrder;
1539
+ } | undefined;
1540
+
1541
+ export declare type GroupRecord<RecordType> = {
1542
+ key: string;
1543
+ label: string | Promise<string>;
1544
+ itemCount: number | undefined | Promise<number | undefined>;
1545
+ records: RecordType[];
1546
+ };
1547
+
1310
1548
  export declare const HomeLayout: ForwardRefExoticComponent<Omit<{
1311
1549
  widgets?: ReactNode[];
1312
1550
  children?: ReactNode;
@@ -1369,6 +1607,33 @@ declare type InFilterOptions_2<T> = {
1369
1607
  options: Array<InFilterOptionItem<T>> | (() => Array<InFilterOptionItem<T>> | Promise<Array<InFilterOptionItem<T>>>);
1370
1608
  };
1371
1609
 
1610
+ /**
1611
+ * Represents a paginated response structure tailored for infinite scroll implementations.
1612
+ *
1613
+ * @template TRecord The type of the individual record contained in the paginated response.
1614
+ *
1615
+ * @extends BasePaginatedResponse
1616
+ *
1617
+ * @property {"infinite-scroll"} type Identifies the pagination type as "infinite-scroll".
1618
+ * @property {string | null} cursor The current position cursor used to fetch the next set of records.
1619
+ * @property {boolean} hasMore Indicates whether there are additional records available for loading.
1620
+ */
1621
+ export declare type InfiniteScrollPaginatedResponse<TRecord> = BasePaginatedResponse<TRecord> & {
1622
+ type: Extract<PaginationType, "infinite-scroll">;
1623
+ /**
1624
+ * Represents the current position cursor for pagination.
1625
+ * This is typically a string (often Base64-encoded) that represents
1626
+ * the position of the last item in the current result set.
1627
+ * Used to fetch the next page of results.
1628
+ */
1629
+ cursor: string | null;
1630
+ /**
1631
+ * A boolean flag indicating whether there are more items available for fetching.
1632
+ * Used to determine if additional requests should be made for pagination.
1633
+ */
1634
+ hasMore: boolean;
1635
+ };
1636
+
1372
1637
  declare const internalAvatarColors: readonly ["viridian", "malibu", "yellow", "purple", "lilac", "barbie", "smoke", "army", "flubber", "indigo", "camel"];
1373
1638
 
1374
1639
  declare type InternalAvatarProps = React_2.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> & {
@@ -1381,6 +1646,10 @@ declare const internalAvatarSizes: readonly ["xsmall", "small", "medium", "large
1381
1646
 
1382
1647
  declare const internalAvatarTypes: readonly ["base", "rounded"];
1383
1648
 
1649
+ export declare function isInfiniteScrollPagination<R extends RecordType>(pagination: PaginationInfo | null): pagination is InfiniteScrollPaginatedResponse<R>;
1650
+
1651
+ export declare function isPageBasedPagination<R extends RecordType>(pagination: PaginationInfo | null): pagination is PageBasedPaginatedResponse<R>;
1652
+
1384
1653
  declare type L10nContextValue = {
1385
1654
  locale: string;
1386
1655
  };
@@ -1570,6 +1839,82 @@ declare type OneFilterPickerRootProps<Definition extends FiltersDefinition> = {
1570
1839
  children?: React.ReactNode;
1571
1840
  };
1572
1841
 
1842
+ export declare type OnSelectItemsCallback<R extends RecordType, Filters extends FiltersDefinition> = (selectedItems: SelectedItemsDetailedStatus<R, Filters> & {
1843
+ byLane?: Record<string, SelectedItemsDetailedStatus<R, Filters>>;
1844
+ }, clearSelectedItems: () => void) => void;
1845
+
1846
+ /**
1847
+ * Represents a paginated response with page-based navigation.
1848
+ *
1849
+ * Combines the base pagination response with additional properties specific to
1850
+ * page-based pagination, allowing clients to navigate the dataset using page numbers.
1851
+ *
1852
+ * This type is useful for APIs returning data in discrete pages, where both the
1853
+ * current page index and the total number of pages are provided.
1854
+ *
1855
+ * @template TRecord - The type of the individual records in the dataset.
1856
+ *
1857
+ * @property {"pages"} type - Indicates the pagination type is page-based.
1858
+ * @property {number} currentPage - The index of the current page being viewed.
1859
+ * @property {number} pagesCount - The total number of pages available.
1860
+ */
1861
+ export declare type PageBasedPaginatedResponse<TRecord> = BasePaginatedResponse<TRecord> & {
1862
+ type: Extract<PaginationType, "pages">;
1863
+ /** Current page number (1-indexed) */
1864
+ currentPage: number;
1865
+ /** Total number of pages available */
1866
+ pagesCount: number;
1867
+ };
1868
+
1869
+ /**
1870
+ * Paginated data adapter configuration
1871
+ * @template R - The type of records in the collection
1872
+ * @template Filters - The available filter configurations
1873
+ */
1874
+ export declare type PaginatedDataAdapter<R extends RecordType, Filters extends FiltersDefinition, Options extends PaginatedFetchOptions<Filters> = PaginatedFetchOptions<Filters>, FetchReturn = PaginatedResponse<R>> = {
1875
+ /** Indicates this adapter uses page-based pagination */
1876
+ paginationType: PaginationType;
1877
+ /** Default number of records per page */
1878
+ perPage?: number;
1879
+ /**
1880
+ * Function to fetch paginated data based on filter and pagination options
1881
+ * @param options - The filter and pagination options to apply when fetching data
1882
+ * @returns Paginated response with records and pagination info
1883
+ */
1884
+ fetchData: (options: Options) => FetchReturn | Promise<FetchReturn> | Observable<PromiseState<FetchReturn>>;
1885
+ };
1886
+
1887
+ export declare type PaginatedFetchOptions<Filters extends FiltersDefinition> = BaseFetchOptions<Filters> & {
1888
+ pagination: {
1889
+ perPage?: number;
1890
+ } & ({
1891
+ currentPage: number;
1892
+ cursor?: never;
1893
+ } | {
1894
+ cursor?: string | null;
1895
+ currentPage?: never;
1896
+ });
1897
+ };
1898
+
1899
+ /**
1900
+ * Response type for paginated collection data
1901
+ * @template Record - The type of records in the collection
1902
+ */
1903
+ export declare type PaginatedResponse<TRecord> = PageBasedPaginatedResponse<TRecord> | InfiniteScrollPaginatedResponse<TRecord>;
1904
+
1905
+ /**
1906
+ * Pagination state and controls
1907
+ */
1908
+ export declare type PaginationInfo = Omit<PageBasedPaginatedResponse<unknown>, "records"> | Omit<InfiniteScrollPaginatedResponse<unknown>, "records">;
1909
+
1910
+ /**
1911
+ * Defines the available pagination types used throughout the application.
1912
+ * - "pages": Represents traditional page-based navigation with numbered pages.
1913
+ * - "infinite-scroll": Represents continuous loading of content as the user scrolls.
1914
+ * - "no-pagination": Represents a collection that does not use pagination.
1915
+ */
1916
+ export declare type PaginationType = "pages" | "infinite-scroll" | "no-pagination";
1917
+
1573
1918
  export declare type PersonAvatarVariant = Extract<AvatarVariant, {
1574
1919
  type: "person";
1575
1920
  }>;
@@ -1694,6 +2039,18 @@ label?: string;
1694
2039
  color?: string;
1695
2040
  } & RefAttributes<HTMLDivElement>, "ref"> & RefAttributes<HTMLElement | SVGElement>>;
1696
2041
 
2042
+ /**
2043
+ * Utility type for handling both Promise and Observable return types.
2044
+ * @template T - The type of the value being promised or observed
2045
+ */
2046
+ export declare type PromiseOrObservable<T> = T | Promise<T> | Observable<PromiseState<T>>;
2047
+
2048
+ declare interface PromiseState<T> {
2049
+ loading: boolean;
2050
+ error?: Error | null;
2051
+ data?: T | null;
2052
+ }
2053
+
1697
2054
  declare type PromoteAction = {
1698
2055
  variant: "promote";
1699
2056
  label: string;
@@ -1736,6 +2093,27 @@ declare type Props_2 = {
1736
2093
  list?: TagCounterItem[];
1737
2094
  };
1738
2095
 
2096
+ /**
2097
+ * Utility type to get all possible paths through an object using dot notation
2098
+ * @template T - The object type to traverse
2099
+ */
2100
+ declare type RecordPaths<T> = T extends Record<string, unknown> ? {
2101
+ [K in keyof T]: K extends string ? T[K] extends Record<string, unknown> ? K | `${K}.${RecordPaths<T[K]>}` : K : never;
2102
+ }[keyof T] : never;
2103
+
2104
+ /**
2105
+ * Utility type to get the value type at a given path
2106
+ * @template T - The object type
2107
+ * @template P - The path string
2108
+ */
2109
+ declare type RecordPathValue<T, P extends string> = P extends keyof T ? T[P] : P extends `${infer K}.${infer Rest}` ? K extends keyof T ? RecordPathValue<T[K], Rest> : never : never;
2110
+
2111
+ /**
2112
+ * Represents a record type with string keys and unknown values.
2113
+ * This type is used to represent the data structure of a collection.
2114
+ */
2115
+ export declare type RecordType = Record<string, unknown>;
2116
+
1739
2117
  declare type RegularAction = BaseAction & {
1740
2118
  type: "regular";
1741
2119
  variant: ButtonVariant;
@@ -1743,8 +2121,78 @@ declare type RegularAction = BaseAction & {
1743
2121
 
1744
2122
  declare type SearchFilterDefinition = BaseFilterDefinition<"search">;
1745
2123
 
2124
+ declare type SearchOptions = {
2125
+ /** Whether search is enabled */
2126
+ enabled: boolean;
2127
+ /** Whether search is synchronous */
2128
+ sync?: boolean;
2129
+ /** Debounce time for search */
2130
+ debounceTime?: number;
2131
+ };
2132
+
2133
+ /**
2134
+ * Represents a collection of selected items.
2135
+ * @template T - The type of items in the collection
2136
+ */
2137
+ export declare type SelectedItems<T> = ReadonlyArray<T>;
2138
+
2139
+ export declare type SelectedItemsDetailedStatus<R extends RecordType, Filters extends FiltersDefinition> = {
2140
+ allSelected: boolean | "indeterminate";
2141
+ itemsStatus: ReadonlyArray<{
2142
+ item: R;
2143
+ checked: boolean;
2144
+ }>;
2145
+ groupsStatus: Record<string, boolean>;
2146
+ filters: FiltersState<Filters>;
2147
+ selectedCount: number;
2148
+ };
2149
+
2150
+ /**
2151
+ * Represents the selected items by id
2152
+ */
2153
+ export declare type SelectedItemsState = {
2154
+ allSelected?: boolean | "indeterminate";
2155
+ items?: ReadonlyArray<{
2156
+ id: string;
2157
+ checked: boolean;
2158
+ }>;
2159
+ groups?: ReadonlyArray<{
2160
+ groupId: string;
2161
+ checked: boolean;
2162
+ }>;
2163
+ };
2164
+
2165
+ /**
2166
+ * Response structure for non-paginated data
2167
+ */
2168
+ declare type SimpleResult<T> = T[];
2169
+
1746
2170
  declare const sizes: readonly ["sm", "md", "lg"];
1747
2171
 
2172
+ /**
2173
+ * Type helper to extract keys from a SortingsDefinition
2174
+ */
2175
+ export declare type SortingKey<Definition extends SortingsDefinition> = Definition extends readonly string[] ? Definition[number] : keyof Definition;
2176
+
2177
+ export declare type SortingsDefinition = Record<string, {
2178
+ label: string;
2179
+ }>;
2180
+
2181
+ export declare type SortingsState<Definition extends SortingsDefinition> = {
2182
+ field: keyof Definition;
2183
+ order: SortOrder;
2184
+ } | null;
2185
+
2186
+ /**
2187
+ * Type helper to create a multiple sortings state (the main sorting and the grouping sorting)
2188
+ */
2189
+ export declare type SortingsStateMultiple = {
2190
+ field: string;
2191
+ order: "asc" | "desc";
2192
+ }[];
2193
+
2194
+ export declare type SortOrder = "asc" | "desc";
2195
+
1748
2196
  declare type SrcProps = Pick<ImgHTMLAttributes<HTMLImageElement>, "src" | "srcSet" | "sizes">;
1749
2197
 
1750
2198
  export declare const StandardLayout: ForwardRefExoticComponent<Omit<StandardLayoutProps & HTMLAttributes<HTMLElement> & RefAttributes<HTMLElement>, "ref"> & RefAttributes<HTMLElement | SVGElement>>;
@@ -2015,6 +2463,152 @@ declare interface UpsellRequestResponseDialogProps {
2015
2463
  portalContainer?: HTMLElement | null;
2016
2464
  }
2017
2465
 
2466
+ /**
2467
+ * A core React hook that manages data fetching, state management, and pagination within the Collections ecosystem.
2468
+ *
2469
+ * ## Why a Separate Hook?
2470
+ *
2471
+ * `useData` exists as a separate hook for three main reasons:
2472
+ *
2473
+ * - **Visualization-Specific Needs**: Different visualizations have unique data requirements:
2474
+ * - Card visualizations need grid-aligned pagination (multiples of grid columns)
2475
+ * - Table visualizations work best with row-optimized data fetching
2476
+ * - Custom visualizations may need specialized data transformations
2477
+ *
2478
+ * - **Separation of Concerns**: Maintains clear boundaries between:
2479
+ * - Data source configuration (managed by `useDataSource`)
2480
+ * - Data fetching & state management (handled by `useData`)
2481
+ * - UI presentation (implemented by visualization components)
2482
+ *
2483
+ * - **Extensibility**: New visualization types can be added without modifying core data logic,
2484
+ * as each visualization directly controls how it consumes data
2485
+ *
2486
+ * ## Core Features
2487
+ *
2488
+ * - Handles multiple data source types seamlessly (synchronous, Promise-based, Observable-based)
2489
+ * - Manages pagination state with automatic page handling
2490
+ * - Provides consistent loading states (`isInitialLoading`, `isLoading`)
2491
+ * - Implements standardized error handling with detailed error information
2492
+ * - Performs automatic cleanup of subscriptions to prevent memory leaks
2493
+ * - Supports filter application with proper filter state management
2494
+ *
2495
+ * ## Usage in Visualizations
2496
+ *
2497
+ * Each visualization component calls `useData` directly to maintain control over its specific data needs:
2498
+ *
2499
+ * ```tsx
2500
+ * // Example: CardCollection customizing pagination before calling useData
2501
+ * function CardCollection({ source }) {
2502
+ * // Override source to ensure grid-friendly pagination (multiples of 2,3,4)
2503
+ * const adaptedSource = useMemo(() => ({
2504
+ * ...source,
2505
+ * dataAdapter: {
2506
+ * ...source.dataAdapter,
2507
+ * perPage: source.dataAdapter.perPage ?? 24,
2508
+ * }
2509
+ * }), [source]);
2510
+ *
2511
+ * // Let useData handle the data fetching with our customized source
2512
+ * const { data, isInitialLoading, paginationInfo, setPage } = useData(adaptedSource);
2513
+ *
2514
+ * // Rendering logic follows...
2515
+ * }
2516
+ * ```
2517
+ *
2518
+ * @template R - The type of records in the collection
2519
+ * @template Filters - The filters type extending FiltersDefinition
2520
+ *
2521
+ * @param source - The data source object containing dataAdapter and filter state
2522
+ * @param options - Optional configuration including filter overrides
2523
+ *
2524
+ * @returns {UseDataReturn<R>} An object containing:
2525
+ * - data: The current collection records
2526
+ * - isInitialLoading: Whether this is the first data load
2527
+ * - isLoading: Whether any data fetch is in progress
2528
+ * - error: Any error that occurred during data fetching
2529
+ * - paginationInfo: Pagination state and metadata if available
2530
+ * - setPage: Function to navigate to a specific page
2531
+ */
2532
+ 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>;
2533
+
2534
+ /**
2535
+ * Hook options for useData
2536
+ */
2537
+ export declare interface UseDataOptions<R extends RecordType, Filters extends FiltersDefinition> {
2538
+ filters?: Partial<FiltersState<Filters>>;
2539
+ /**
2540
+ * A function that is called when an error occurs during data fetching.
2541
+ * It is called with the error object.
2542
+ * @param error - The error object.
2543
+ */
2544
+ onError?: (error: DataError) => void;
2545
+ /**
2546
+ * A function that provides the fetch parameters for the data source.
2547
+ * It is called before each fetch request and can be used to modify the fetch parameters.
2548
+ * @param options - The fetch parameters for the data source.
2549
+ * @returns The fetch parameters for the data source.
2550
+ */
2551
+ fetchParamsProvider?: <O extends BaseFetchOptions<Filters>>(options: O) => O;
2552
+ /**
2553
+ * A function that is called when the data is fetched successfully.
2554
+ * It is called with the response data.
2555
+ * @param response - The response data.
2556
+ */
2557
+ onResponse?: (response: PaginatedResponse<R> | SimpleResult<R>) => void;
2558
+ }
2559
+
2560
+ /**
2561
+ * Hook return type for useData
2562
+ */
2563
+ export declare interface UseDataReturn<R extends RecordType> {
2564
+ data: Data<R>;
2565
+ isInitialLoading: boolean;
2566
+ isLoading: boolean;
2567
+ isLoadingMore: boolean;
2568
+ error: DataError | null;
2569
+ paginationInfo: PaginationInfo | null;
2570
+ setPage: (page: number) => void;
2571
+ loadMore: () => void;
2572
+ totalItems: number | undefined;
2573
+ mergedFilters: FiltersState<FiltersDefinition>;
2574
+ }
2575
+
2576
+ /**
2577
+ * A hook that manages data source state and filtering capabilities for a collection.
2578
+ * It creates and returns a reusable data source that can be shared across different
2579
+ * visualizations and components.
2580
+ *
2581
+ * This hook is intentionally separated from the rendering components to:
2582
+ * 1. Enable sharing the same data source across multiple components
2583
+ * 2. Allow for state management outside the rendering layer
2584
+ * 3. Support more complex data filtering, querying, and pagination logic
2585
+ * 4. Provide a clean separation between data management and visualization
2586
+ *
2587
+ * @template R - The type of records in the collection
2588
+ * @template Filters - The definition of available filters for the collection
2589
+ * @template ItemActions - The definition of available item actions
2590
+ * @template Actions - The definition of available actions for the collection
2591
+ *
2592
+ * @param options - Configuration object containing:
2593
+ * - filters: Optional filter configurations for the collection
2594
+ * - currentFilters: Initial state of the filters
2595
+ * - dataAdapter: Adapter for data fetching and manipulation
2596
+ * - itemActions: Optional item actions available
2597
+ * - actions: Optional DataCollection actions
2598
+ * - presets: Optional filter presets
2599
+ * @param deps - Dependency array for memoization, similar to useEffect dependencies
2600
+ *
2601
+ * @returns A DataSource object containing:
2602
+ * - filters: The available filter configurations
2603
+ * - currentFilters: The current state of the filters
2604
+ * - setCurrentFilters: Function to update the filter state
2605
+ * - dataAdapter: The data adapter for fetching/manipulating data
2606
+ * - itemActions: Available actions for records (items)
2607
+ * - actions: Available actions for the collection
2608
+ * - presets: Available filter presets
2609
+ */
2610
+ export declare function useDataSource<R extends RecordType = RecordType, FiltersSchema extends FiltersDefinition = FiltersDefinition, Sortings extends SortingsDefinition = SortingsDefinition, Grouping extends GroupingDefinition<R> = GroupingDefinition<R>>({ currentFilters: initialCurrentFilters, currentGrouping: initialCurrentGrouping, filters, search, defaultSorting, dataAdapter, grouping, ...rest }: DataSourceDefinition<R, FiltersSchema, Sortings, Grouping>, deps?: ReadonlyArray<unknown>): DataSource<R, FiltersSchema, Sortings, Grouping>;
2611
+
2018
2612
  export declare function useDndEvents(handler: (e: {
2019
2613
  phase: "start" | "over" | "drop" | "cancel";
2020
2614
  source: DragPayload;
@@ -2037,6 +2631,11 @@ export declare const useEmojiConfetti: () => {
2037
2631
  fireEmojiConfetti: (emoji: string, elementRef: RefObject<HTMLElement>) => void;
2038
2632
  };
2039
2633
 
2634
+ export declare const useGroups: <R extends RecordType>(groups: GroupRecord<R>[], defaultOpenGroups?: boolean | GroupRecord<R>["key"][]) => {
2635
+ openGroups: Record<string, boolean>;
2636
+ setGroupOpen: (key: string, open: boolean) => void;
2637
+ };
2638
+
2040
2639
  export declare const usePrivacyMode: () => {
2041
2640
  enabled: boolean;
2042
2641
  enable: () => void;
@@ -2046,6 +2645,20 @@ export declare const usePrivacyMode: () => {
2046
2645
 
2047
2646
  export declare const useReducedMotion: () => boolean;
2048
2647
 
2648
+ export declare type UseSelectable<R extends RecordType> = {
2649
+ isAllSelected: boolean;
2650
+ selectedItems: Map<number | string, R>;
2651
+ selectedGroups: Map<string, GroupRecord<R>>;
2652
+ isPartiallySelected: boolean;
2653
+ handleSelectItemChange: (item: R, checked: boolean) => void;
2654
+ handleSelectAll: (checked: boolean) => void;
2655
+ handleSelectGroupChange: (group: GroupRecord<R>, checked: boolean) => void;
2656
+ groupAllSelectedStatus: Record<string, AllSelectionStatus>;
2657
+ allSelectedStatus: AllSelectionStatus;
2658
+ };
2659
+
2660
+ export declare function useSelectable<R extends RecordType, Filters extends FiltersDefinition, Sortings extends SortingsDefinition, Grouping extends GroupingDefinition<R>>(data: Data<R>, paginationInfo: PaginationInfo | null, source: DataSourceDefinition<R, Filters, Sortings, Grouping>, onSelectItems: OnSelectItemsCallback<R, Filters> | undefined, defaultSelectedItems?: SelectedItemsState | undefined): UseSelectable<R>;
2661
+
2049
2662
  export declare const useXRay: () => {
2050
2663
  enabled: boolean;
2051
2664
  filter: ComponentTypes[];
@@ -2090,6 +2703,10 @@ showRatio?: boolean;
2090
2703
  valueFormatter?: (value: string | number | undefined) => string | number;
2091
2704
  } & RefAttributes<HTMLDivElement>, "ref"> & RefAttributes<HTMLElement | SVGElement>>;
2092
2705
 
2706
+ export declare type WithGroupId<RecordType> = RecordType & {
2707
+ [GROUP_ID_SYMBOL]: unknown | undefined;
2708
+ };
2709
+
2093
2710
  declare interface WithTooltipDescription {
2094
2711
  /**
2095
2712
  * Optional description to show in the tooltip
@@ -2141,6 +2758,11 @@ declare module "@tiptap/core" {
2141
2758
  }
2142
2759
 
2143
2760
 
2761
+ declare namespace Calendar {
2762
+ var displayName: string;
2763
+ }
2764
+
2765
+
2144
2766
  declare module "@tiptap/core" {
2145
2767
  interface Commands<ReturnType> {
2146
2768
  moodTracker: {
@@ -2148,8 +2770,3 @@ declare module "@tiptap/core" {
2148
2770
  };
2149
2771
  }
2150
2772
  }
2151
-
2152
-
2153
- declare namespace Calendar {
2154
- var displayName: string;
2155
- }