@factorialco/f0-react 1.236.4 → 1.238.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.
@@ -63,6 +63,7 @@ import { ReactElement } from 'react';
63
63
  import { ReactNode } from 'react';
64
64
  import * as RechartsPrimitive from 'recharts';
65
65
  import { RefAttributes } from 'react';
66
+ import { RefObject } from 'react';
66
67
  import { ScrollAreaProps } from '@radix-ui/react-scroll-area';
67
68
  import { StatusCellValue } from './types/status.tsx';
68
69
  import { StatusCellValue as StatusCellValue_2 } from '../../value-display/types/status';
@@ -117,6 +118,15 @@ export declare interface ActionItemProps {
117
118
  }
118
119
 
119
120
  declare type ActionProps = {
121
+ buttonType: "gradient" | "internal";
122
+ label: string;
123
+ onClick: () => void;
124
+ isLoading: boolean;
125
+ buttonVariant?: ButtonVariant;
126
+ icon?: IconType;
127
+ };
128
+
129
+ declare type ActionProps_2 = {
120
130
  /**
121
131
  * The label of the action
122
132
  */
@@ -309,6 +319,64 @@ declare interface AiChatState {
309
319
  onThumbsDown?: (message: AIMessage, threadId: string) => void;
310
320
  }
311
321
 
322
+ /**
323
+ * @experimental This is an experimental component use it at your own risk
324
+ */
325
+ export declare const AiPromotionChat: () => JSX_2.Element | null;
326
+
327
+ export declare const AiPromotionChatProvider: ({ enabled, greeting, title, description, benefits, actions, onShow, onHide, children, }: AiPromotionChatProviderProps) => JSX_2.Element;
328
+
329
+ export declare type AiPromotionChatProviderProps = {
330
+ enabled?: boolean;
331
+ greeting?: string;
332
+ title?: string;
333
+ description?: string;
334
+ benefits?: {
335
+ noBoldText: string;
336
+ boldText: string;
337
+ }[];
338
+ actions?: ActionProps[];
339
+ onShow?: () => void;
340
+ onHide?: () => void;
341
+ children: React.ReactNode;
342
+ };
343
+
344
+ declare type AiPromotionChatProviderReturnValue = {
345
+ enabled: boolean;
346
+ setEnabled: React.Dispatch<React.SetStateAction<boolean>>;
347
+ open: boolean;
348
+ setOpen: React.Dispatch<React.SetStateAction<boolean>>;
349
+ shouldPlayEntranceAnimation: boolean;
350
+ setShouldPlayEntranceAnimation: React.Dispatch<React.SetStateAction<boolean>>;
351
+ /**
352
+ * Set the amount of minutes after which the chat will be cleared automatically
353
+ * Set `null` to disable auto-clearing
354
+ *
355
+ * @default 15
356
+ */
357
+ setAutoClearMinutes: React.Dispatch<React.SetStateAction<number | null>>;
358
+ autoClearMinutes: number | null;
359
+ /**
360
+ * Clear/reset the chat conversation
361
+ */
362
+ clear: () => void;
363
+ /* Excluded from this release type: setClearFunction */
364
+ } & Pick<AiPromotionChatState, "greeting" | "title" | "description" | "benefits" | "actions" | "onShow" | "onHide">;
365
+
366
+ declare interface AiPromotionChatState {
367
+ enabled: boolean;
368
+ greeting?: string;
369
+ title?: string;
370
+ description?: string;
371
+ benefits?: {
372
+ noBoldText: string;
373
+ boldText: string;
374
+ }[];
375
+ actions?: ActionProps[];
376
+ onShow?: () => void;
377
+ onHide?: () => void;
378
+ }
379
+
312
380
  export declare const Alert: React_2.ForwardRefExoticComponent<Omit<React_2.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
313
381
  variant?: "info" | "warning" | "positive" | "destructive" | undefined;
314
382
  } & ({
@@ -370,10 +438,11 @@ declare const alertVariants: (props?: ({
370
438
  className?: ClassValue;
371
439
  })) | undefined) => string;
372
440
 
373
- export declare function ApplicationFrame({ children, sidebar, banner, ai, }: ApplicationFrameProps): JSX_2.Element;
441
+ export declare function ApplicationFrame({ children, sidebar, banner, ai, aiPromotion, }: ApplicationFrameProps): JSX_2.Element;
374
442
 
375
443
  export declare interface ApplicationFrameProps {
376
444
  ai?: Omit<AiChatProviderProps, "children">;
445
+ aiPromotion?: Omit<AiPromotionChatProviderProps, "children">;
377
446
  banner?: React.ReactNode;
378
447
  sidebar: React.ReactNode;
379
448
  children: React.ReactNode;
@@ -813,7 +882,7 @@ declare interface ButtonProps_2 extends React_2.ButtonHTMLAttributes<HTMLButtonE
813
882
 
814
883
  declare type ButtonSize = (typeof sizes)[number];
815
884
 
816
- declare type ButtonVariant = (typeof variants_3)[number];
885
+ declare type ButtonVariant = (typeof variants)[number];
817
886
 
818
887
  declare const buttonVariants: (props?: ({
819
888
  disabled?: boolean | undefined;
@@ -882,7 +951,7 @@ declare interface CalloutSkeletonProps {
882
951
  variant?: CalloutVariant;
883
952
  }
884
953
 
885
- declare type CalloutVariant = (typeof variants)[number];
954
+ declare type CalloutVariant = (typeof variants_2)[number];
886
955
 
887
956
  declare type CardAvatarVariant = AvatarVariant | {
888
957
  type: "emoji";
@@ -1027,7 +1096,7 @@ declare type ChartConfig_2 = {
1027
1096
 
1028
1097
  declare const ChartContainer: React_2.ForwardRefExoticComponent<Omit<ChartContainerComponentProps, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
1029
1098
 
1030
- declare interface ChartContainerComponentProps extends React_2.ComponentProps<"div">, VariantProps<typeof variants_2> {
1099
+ declare interface ChartContainerComponentProps extends React_2.ComponentProps<"div">, VariantProps<typeof variants_3> {
1031
1100
  config: ChartConfig_2;
1032
1101
  children: React_2.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
1033
1102
  }
@@ -1282,6 +1351,15 @@ export declare type CurrentFilters<F extends FilterOptions<string>> = F extends
1282
1351
 
1283
1352
  declare type CustomEmptyStates = Partial<Record<EmptyStateType, Partial<EmptyState>>>;
1284
1353
 
1354
+ export declare type CustomVisualizationProps<Source extends {
1355
+ dataAdapter: DataCollectionDataAdapter<any, any, any>;
1356
+ }> = {
1357
+ onSelectItems: OnSelectItemsCallback<InferRecord<Source>, InferFilters<Source>>;
1358
+ onLoadData: OnLoadDataCallback<InferRecord<Source>, InferFilters<Source>>;
1359
+ onLoadError: OnLoadErrorCallback;
1360
+ source: Source;
1361
+ };
1362
+
1285
1363
  export declare const Dashboard: ForwardRefExoticComponent<DashboardProps & RefAttributes<HTMLDivElement>> & {
1286
1364
  Skeleton: () => JSX_2.Element;
1287
1365
  };
@@ -1295,6 +1373,12 @@ declare type DashboardProps_2 = {
1295
1373
  children: ReactNode[];
1296
1374
  };
1297
1375
 
1376
+ declare type Data<R extends RecordType> = {
1377
+ records: WithGroupId<R>[];
1378
+ type: "grouped" | "flat";
1379
+ groups: GroupRecord<R>[];
1380
+ };
1381
+
1298
1382
  /**
1299
1383
  * Combined type for all possible data adapter configurations
1300
1384
  * @template R - The type of records in the collection
@@ -1916,7 +2000,7 @@ declare type EmptyState = {
1916
2000
  emoji?: string;
1917
2001
  title: string;
1918
2002
  description?: string;
1919
- actions?: ActionProps[];
2003
+ actions?: ActionProps_2[];
1920
2004
  };
1921
2005
 
1922
2006
  declare const emptyStatesTypes: readonly ["no-data", "no-results", "error"];
@@ -2450,6 +2534,11 @@ export declare const granularityDefinitions: Record<string, GranularityDefinitio
2450
2534
 
2451
2535
  export declare type GranularityDefinitionSimple = Pick<GranularityDefinition, "toRangeString" | "toString">;
2452
2536
 
2537
+ /**
2538
+ * Symbol used to identify the groupId in the data
2539
+ */
2540
+ declare const GROUP_ID_SYMBOL: unique symbol;
2541
+
2453
2542
  /**
2454
2543
  * Defines the structure and configuration of a grouping options for a data source.
2455
2544
  * @template RecordType - The type of records in the collection
@@ -2487,6 +2576,13 @@ export declare type GroupingState<R extends RecordType, Grouping extends Groupin
2487
2576
  order?: SortOrder;
2488
2577
  } | undefined;
2489
2578
 
2579
+ declare type GroupRecord<RecordType> = {
2580
+ key: string;
2581
+ label: string | Promise<string>;
2582
+ itemCount: number | undefined | Promise<number | undefined>;
2583
+ records: RecordType[];
2584
+ };
2585
+
2490
2586
  declare type HeaderProps = {
2491
2587
  module: {
2492
2588
  id: ModuleId;
@@ -2569,6 +2665,19 @@ export declare interface IndicatorsListProps {
2569
2665
  items: ComponentProps<typeof Indicator>[];
2570
2666
  }
2571
2667
 
2668
+ declare type InferFilters<S> = S extends {
2669
+ dataAdapter: DataCollectionDataAdapter<any, infer F, any>;
2670
+ } ? F : never;
2671
+
2672
+ /**
2673
+ * Returns the custom visualization props based on the data collection source.
2674
+ *
2675
+ * @template Source - The data collection source
2676
+ */
2677
+ declare type InferRecord<S> = S extends {
2678
+ dataAdapter: DataCollectionDataAdapter<infer R, any, any>;
2679
+ } ? R : never;
2680
+
2572
2681
  declare type InferSchema<T extends SchemaType> = z.infer<T>;
2573
2682
 
2574
2683
  declare type InFilterDefinition<T = unknown> = BaseFilterDefinition<"in"> & {
@@ -3383,7 +3492,7 @@ declare type OneEmptyStateProps = {
3383
3492
  * and can include a label, click handler, optional icon, and button variant.
3384
3493
  * @optional
3385
3494
  */
3386
- actions?: ActionProps[];
3495
+ actions?: ActionProps_2[];
3387
3496
  } & ({
3388
3497
  /**
3389
3498
  * The variant of the empty state
@@ -4284,6 +4393,11 @@ declare interface SidebarProps {
4284
4393
 
4285
4394
  declare type SidebarState = "locked" | "unlocked" | "hidden";
4286
4395
 
4396
+ /**
4397
+ * Response structure for non-paginated data
4398
+ */
4399
+ declare type SimpleResult<T> = T[];
4400
+
4287
4401
  declare const sizes: readonly ["sm", "md", "lg"];
4288
4402
 
4289
4403
  declare const skeletonVariants: (props?: ({
@@ -4863,7 +4977,7 @@ declare type Type = "bar-chart" | "line-chart";
4863
4977
 
4864
4978
  declare namespace Types {
4865
4979
  export {
4866
- ActionProps,
4980
+ ActionProps_2 as ActionProps,
4867
4981
  OneEmptyStateProps
4868
4982
  }
4869
4983
  }
@@ -4872,12 +4986,73 @@ declare type URL_2 = string;
4872
4986
 
4873
4987
  export declare function useAiChat(): AiChatProviderReturnValue;
4874
4988
 
4989
+ export declare function useAiPromotionChat(): AiPromotionChatProviderReturnValue;
4990
+
4991
+ export declare type UseDataCollectionData<R extends RecordType> = UseDataCollectionDataReturn<R> & {
4992
+ summaries?: R;
4993
+ };
4994
+
4995
+ export declare function useDataCollectionData<R extends RecordType, Filters extends FiltersDefinition, Sortings extends SortingsDefinition, Summaries extends SummariesDefinition, NavigationFilters extends NavigationFiltersDefinition, Grouping extends GroupingDefinition<R>>(source: DataCollectionSource<R, Filters, Sortings, Summaries, ItemActionsDefinition<R>, NavigationFilters, Grouping>, options?: UseDataOptions<R, Filters>): UseDataCollectionData<R>;
4996
+
4997
+ /**
4998
+ * Hook return type for useData
4999
+ */
5000
+ declare type UseDataCollectionDataReturn<R extends RecordType> = UseDataReturn<R> & {
5001
+ summaries?: R;
5002
+ };
5003
+
4875
5004
  export declare const useDataCollectionSource: <R extends RecordType = RecordType, FiltersSchema extends FiltersDefinition = FiltersDefinition, Sortings extends SortingsDefinition = SortingsDefinition, Summaries extends SummariesDefinition = SummariesDefinition, ItemActions extends ItemActionsDefinition<R> = ItemActionsDefinition<R>, NavigationFilters extends NavigationFiltersDefinition = NavigationFiltersDefinition, Grouping extends GroupingDefinition<R> = GroupingDefinition<R>>(source: DataCollectionSourceDefinition<R, FiltersSchema, Sortings, Summaries, ItemActions, NavigationFilters, Grouping>, deps?: ReadonlyArray<unknown>) => DataCollectionSource<R, FiltersSchema, Sortings, Summaries, ItemActions, NavigationFilters, Grouping>;
4876
5005
 
5006
+ /**
5007
+ * Hook options for useData
5008
+ */
5009
+ declare interface UseDataOptions<R extends RecordType, Filters extends FiltersDefinition> {
5010
+ filters?: Partial<FiltersState<Filters>>;
5011
+ /**
5012
+ * A function that is called when an error occurs during data fetching.
5013
+ * It is called with the error object.
5014
+ * @param error - The error object.
5015
+ */
5016
+ onError?: (error: DataError) => void;
5017
+ /**
5018
+ * A function that provides the fetch parameters for the data source.
5019
+ * It is called before each fetch request and can be used to modify the fetch parameters.
5020
+ * @param options - The fetch parameters for the data source.
5021
+ * @returns The fetch parameters for the data source.
5022
+ */
5023
+ fetchParamsProvider?: <O extends BaseFetchOptions<Filters>>(options: O) => O;
5024
+ /**
5025
+ * A function that is called when the data is fetched successfully.
5026
+ * It is called with the response data.
5027
+ * @param response - The response data.
5028
+ */
5029
+ onResponse?: (response: PaginatedResponse<R> | SimpleResult<R>) => void;
5030
+ }
5031
+
5032
+ /**
5033
+ * Hook return type for useData
5034
+ */
5035
+ declare interface UseDataReturn<R extends RecordType> {
5036
+ data: Data<R>;
5037
+ isInitialLoading: boolean;
5038
+ isLoading: boolean;
5039
+ isLoadingMore: boolean;
5040
+ error: DataError | null;
5041
+ paginationInfo: PaginationInfo | null;
5042
+ setPage: (page: number) => void;
5043
+ loadMore: () => void;
5044
+ totalItems: number | undefined;
5045
+ mergedFilters: FiltersState<FiltersDefinition>;
5046
+ }
5047
+
4877
5048
  export { useForm }
4878
5049
 
4879
5050
  export declare function useFormSchema<Schema extends SchemaType, FormData extends InferSchema<Schema>>(schema: Schema, options: UseFormProps<FormData>, onSubmit: OnSubmitHandler<FormData>): FormType<Schema, FormData>;
4880
5051
 
5052
+ export declare const useInfiniteScrollPagination: (paginationInfo: PaginationInfo | null, isLoading: boolean, isLoadingMore: boolean, loadMore: () => void) => {
5053
+ loadingIndicatorRef: RefObject<HTMLTableCellElement>;
5054
+ };
5055
+
4881
5056
  export declare interface User {
4882
5057
  id: string;
4883
5058
  fullname: string;
@@ -4930,9 +5105,11 @@ declare type ValueDisplayVisualizationType = "table" | "card" | "list" | (string
4930
5105
 
4931
5106
  declare type Variant = "neutral" | "info" | "positive" | "warning" | "critical";
4932
5107
 
4933
- declare const variants: readonly ["ai", "critical", "positive", "info", "warning"];
5108
+ declare const variants: readonly ["default", "outline", "critical", "neutral", "ghost", "promote", "outlinePromote"];
4934
5109
 
4935
- declare const variants_2: (props?: ({
5110
+ declare const variants_2: readonly ["ai", "critical", "positive", "info", "warning"];
5111
+
5112
+ declare const variants_3: (props?: ({
4936
5113
  aspect?: "small" | "square" | "wide" | undefined;
4937
5114
  } & ({
4938
5115
  class?: ClassValue;
@@ -4942,8 +5119,6 @@ declare const variants_2: (props?: ({
4942
5119
  className?: ClassValue;
4943
5120
  })) | undefined) => string;
4944
5121
 
4945
- declare const variants_3: readonly ["default", "outline", "critical", "neutral", "ghost", "promote", "outlinePromote"];
4946
-
4947
5122
  export declare const VerticalBarChartWidget: ForwardRefExoticComponent<Omit<WidgetProps_2 & {
4948
5123
  chart: VerticalBarChartProps;
4949
5124
  } & RefAttributes<HTMLDivElement>, "ref"> & RefAttributes<HTMLElement | SVGElement>>;
@@ -5135,6 +5310,10 @@ export declare const WidgetStrip: ForwardRefExoticComponent<DashboardProps_2 & R
5135
5310
 
5136
5311
  declare type WidgetWidth = "sm" | "md" | "lg";
5137
5312
 
5313
+ declare type WithGroupId<RecordType> = RecordType & {
5314
+ [GROUP_ID_SYMBOL]: unknown | undefined;
5315
+ };
5316
+
5138
5317
  declare type WithOptionalSorting<R extends RecordType, Sortings extends SortingsDefinition> = Omit<PropertyDefinition_2<R>, "hide"> & {
5139
5318
  sorting?: SortingKey<Sortings>;
5140
5319
  /**
@@ -5191,11 +5370,6 @@ declare module "@tiptap/core" {
5191
5370
  }
5192
5371
 
5193
5372
 
5194
- declare namespace Calendar {
5195
- var displayName: string;
5196
- }
5197
-
5198
-
5199
5373
  declare module "@tiptap/core" {
5200
5374
  interface Commands<ReturnType> {
5201
5375
  moodTracker: {
@@ -5203,3 +5377,8 @@ declare module "@tiptap/core" {
5203
5377
  };
5204
5378
  }
5205
5379
  }
5380
+
5381
+
5382
+ declare namespace Calendar {
5383
+ var displayName: string;
5384
+ }