@factorialco/f0-react 8.25.0 → 8.26.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.
@@ -5472,6 +5472,9 @@ declare const defaultTranslations: {
5472
5472
  readonly language: "Language";
5473
5473
  readonly audio: "Audio";
5474
5474
  };
5475
+ readonly swipeDeck: {
5476
+ readonly label: "Swipe deck";
5477
+ };
5475
5478
  readonly meetingCard: {
5476
5479
  readonly today: "Today";
5477
5480
  readonly yesterday: "Yesterday";
@@ -12450,6 +12453,22 @@ export declare type F0SelectTagProp = string | {
12450
12453
 
12451
12454
  export declare type F0SelectVariant = (typeof selectVariants)[number];
12452
12455
 
12456
+ /**
12457
+ * @experimental This is an experimental component, use it at your own risk.
12458
+ */
12459
+ export declare const F0SwipeDeck: <T>({ deck, renderCard, label, empty, dataTestId, offsetThreshold, velocityThreshold, }: F0SwipeDeckProps<T>) => JSX_2.Element;
12460
+
12461
+ export declare type F0SwipeDeckProps<T> = WithDataTestIdProps & {
12462
+ deck: UseSwipeDeckResult<T>;
12463
+ renderCard: (item: T) => ReactNode;
12464
+ label?: string;
12465
+ empty?: ReactNode;
12466
+ /** Drag distance in pixels that commits a decision. */
12467
+ offsetThreshold?: number;
12468
+ /** Drag speed in pixels per second that commits a decision regardless of distance. */
12469
+ velocityThreshold?: number;
12470
+ };
12471
+
12453
12472
  /**
12454
12473
  * @experimental This is an experimental component use it at your own risk
12455
12474
  */
@@ -18792,6 +18811,24 @@ export declare type SummaryKey<Definition extends SummariesDefinition> = Definit
18792
18811
 
18793
18812
  export declare type SummaryType = "sum";
18794
18813
 
18814
+ export declare type SwipeDecision<T> = {
18815
+ item: T;
18816
+ direction: SwipeDirection;
18817
+ };
18818
+
18819
+ export declare type SwipeDeckAction = {
18820
+ type: "decide";
18821
+ direction: SwipeDirection;
18822
+ } | {
18823
+ type: "undo";
18824
+ } | {
18825
+ type: "rollback";
18826
+ };
18827
+
18828
+ export declare type SwipeDirection = (typeof swipeDirections)[number];
18829
+
18830
+ export declare const swipeDirections: readonly ["left", "right"];
18831
+
18795
18832
  /**
18796
18833
  * @experimental This is an experimental component use it at your own risk
18797
18834
  */
@@ -20058,6 +20095,43 @@ export declare const useSidebarChats: () => SidebarChatStore;
20058
20095
  */
20059
20096
  export declare function useSidePanel(): SidePanelContextValue;
20060
20097
 
20098
+ export declare const useSwipeDeck: <T>({ items, getItemId, onDecide, onUndo, onNeedMore, undoDepth, needMoreThreshold, }: UseSwipeDeckOptions<T>) => UseSwipeDeckResult<T>;
20099
+
20100
+ export declare type UseSwipeDeckOptions<T> = {
20101
+ /**
20102
+ * Append-only: the deck reads it by position, so a page of new items must be
20103
+ * added to the end. Replacing the array with a differently ordered or
20104
+ * filtered one makes the deck skip items.
20105
+ */
20106
+ items: T[];
20107
+ getItemId: (item: T) => string;
20108
+ /**
20109
+ * `rollback` returns the item to the deck, for a consumer whose mutation
20110
+ * failed: as the current card when it was the most recent decision, after
20111
+ * the items loaded so far otherwise.
20112
+ */
20113
+ onDecide?: (decision: SwipeDecision<T>, rollback: () => void) => void;
20114
+ onUndo?: (item: T) => void;
20115
+ /** Fires once each time the remaining items drop to `needMoreThreshold`. */
20116
+ onNeedMore?: () => void;
20117
+ undoDepth?: number;
20118
+ needMoreThreshold?: number;
20119
+ };
20120
+
20121
+ export declare type UseSwipeDeckResult<T> = {
20122
+ current: T | undefined;
20123
+ currentId: string | undefined;
20124
+ index: number;
20125
+ total: number;
20126
+ remaining: number;
20127
+ canUndo: boolean;
20128
+ lastAction: SwipeDeckAction | undefined;
20129
+ decide: (direction: SwipeDirection) => void;
20130
+ swipeLeft: () => void;
20131
+ swipeRight: () => void;
20132
+ undo: () => void;
20133
+ };
20134
+
20061
20135
  /**
20062
20136
  * Attaches a track to a media element F0 owns.
20063
20137
  *